mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Fix SC command
This fixes a bug where SC command did not return 999/999/999/999 when CD-DA is not available.
This commit is contained in:
+3
-6
@@ -208,7 +208,7 @@ int cdrom_getPlayingInfo (cd_time *info) {
|
||||
struct cd_sub_channel_info data;
|
||||
|
||||
if (!enabled)
|
||||
goto errexit;
|
||||
return NG;
|
||||
memset(&s, 0, sizeof(s));
|
||||
|
||||
s.data = &data;
|
||||
@@ -217,17 +217,14 @@ int cdrom_getPlayingInfo (cd_time *info) {
|
||||
s.data_format = CD_CURRENT_POSITION;
|
||||
if (do_ioctl(CDIOCREADSUBCHANNEL, &s) < 0) {
|
||||
perror("CDIOCREADSUBCHANNEL");
|
||||
goto errexit;
|
||||
return NG;
|
||||
}
|
||||
if (s.data->header.audio_status != CD_AS_PLAY_IN_PROGRESS) {
|
||||
goto errexit;
|
||||
return NG;
|
||||
}
|
||||
info->t = s.data->what.position.track_number;
|
||||
info->m = s.data->what.position.reladdr.msf.minute;
|
||||
info->s = s.data->what.position.reladdr.msf.second;
|
||||
info->f = s.data->what.position.reladdr.msf.frame;
|
||||
return OK;
|
||||
errexit:
|
||||
info->t = info->m = info->s = info->f = 999;
|
||||
return NG;
|
||||
}
|
||||
|
||||
+3
-6
@@ -241,22 +241,19 @@ static int cdrom_getPlayingInfo (cd_time *info) {
|
||||
struct cdrom_subchnl sc;
|
||||
|
||||
if (!enabled)
|
||||
goto errexit;
|
||||
return NG;
|
||||
|
||||
sc.cdsc_format = CDROM_MSF;
|
||||
if (do_ioctl(CDROMSUBCHNL, &sc) < 0) {
|
||||
perror("CDROMSUBCHNL");
|
||||
goto errexit;
|
||||
return NG;
|
||||
}
|
||||
if (sc.cdsc_audiostatus != CDROM_AUDIO_PLAY) {
|
||||
goto errexit;
|
||||
return NG;
|
||||
}
|
||||
info->t = sc.cdsc_trk;
|
||||
info->m = sc.cdsc_reladdr.msf.minute;
|
||||
info->s = sc.cdsc_reladdr.msf.second;
|
||||
info->f = sc.cdsc_reladdr.msf.frame;
|
||||
return OK;
|
||||
errexit:
|
||||
info->t = info->m = info->s = info->f = 999;
|
||||
return NG;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,5 @@ int cdrom_stop() {
|
||||
}
|
||||
|
||||
int cdrom_getPlayingInfo (cd_time *info) {
|
||||
info->t = info->m = info->s = info->f = 999;
|
||||
return NG;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ int cdrom_getPlayingInfo(cd_time *info) {
|
||||
frame_of_getpos = nact->frame_count;
|
||||
|
||||
int t = EM_ASM_INT_V( return xsystem35.cdPlayer.getPosition(); );
|
||||
if (!t)
|
||||
return NG;
|
||||
info->t = t & 0xff;
|
||||
FRAMES_TO_MSF(t >> 8, &info->m, &info->s, &info->f);
|
||||
return OK;
|
||||
|
||||
+4
-11
@@ -198,18 +198,15 @@ static int cdrom_stop() {
|
||||
|
||||
/* 現在演奏中のトラック情報の取得 */
|
||||
static int cdrom_getPlayingInfo (cd_time *inf) {
|
||||
int cnt;
|
||||
|
||||
if (!enabled || !mix_music) {
|
||||
goto errout;
|
||||
}
|
||||
if (!enabled || !mix_music)
|
||||
return NG;
|
||||
|
||||
if (!Mix_PlayingMusic()) {
|
||||
Mix_FreeMusic(mix_music);
|
||||
mix_music = NULL;
|
||||
goto errout;
|
||||
return NG;
|
||||
}
|
||||
cnt = get_high_counter(SYSTEMCOUNTER_MP3) - counter;
|
||||
int cnt = get_high_counter(SYSTEMCOUNTER_MP3) - counter;
|
||||
|
||||
inf->t = trackno;
|
||||
inf->m = cnt / (60*100); cnt %= (60*100);
|
||||
@@ -217,8 +214,4 @@ static int cdrom_getPlayingInfo (cd_time *inf) {
|
||||
inf->f = (cnt * CD_FPS) / 100;
|
||||
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
inf->t = inf->m = inf->s = inf->f = 999;
|
||||
return NG;
|
||||
}
|
||||
|
||||
+14
-13
@@ -56,17 +56,19 @@ void commandSS() {
|
||||
void commandSC() {
|
||||
/* CDのプレイ中のタイムを取得する */
|
||||
int *var = getCaliVariable();
|
||||
cd_time info;
|
||||
int t, m, s, f;
|
||||
|
||||
mus_cdrom_get_playposition(&info);
|
||||
if (info.t == 999) {
|
||||
*var++ = 999;
|
||||
if (mus_cdrom_get_playposition(&t, &m, &s, &f) == OK) {
|
||||
*var++ = t - 1;
|
||||
*var++ = m;
|
||||
*var++ = s;
|
||||
*var++ = f;
|
||||
} else {
|
||||
*var++ = info.t - 1;
|
||||
*var++ = 999;
|
||||
*var++ = 999;
|
||||
*var++ = 999;
|
||||
*var++ = 999;
|
||||
}
|
||||
*var++ = info.m;
|
||||
*var++ = info.s;
|
||||
*var++ = info.f;
|
||||
|
||||
DEBUG_COMMAND("SC %p:\n",var);
|
||||
}
|
||||
@@ -98,12 +100,11 @@ void commandSR() {
|
||||
var = getCaliVariable();
|
||||
|
||||
if (num == 0) {
|
||||
cd_time info;
|
||||
mus_cdrom_get_playposition(&info);
|
||||
if (info.t == 999) {
|
||||
*var = 0;
|
||||
int t, m, s, f;
|
||||
if (mus_cdrom_get_playposition(&t, &m, &s, &f) == OK) {
|
||||
*var = t - 1;
|
||||
} else {
|
||||
*var = info.t - 1;
|
||||
*var = 0;
|
||||
}
|
||||
} else {
|
||||
midiplaystate st;
|
||||
|
||||
+10
-5
@@ -67,13 +67,18 @@ int mus_cdrom_stop() {
|
||||
}
|
||||
|
||||
/*
|
||||
* cdrom の演奏状態の取得
|
||||
* info: 演奏時間(track/min/sec/frame)の状態を格納する場所
|
||||
* 停止している場合は 999/999/999/999 が返る
|
||||
* cdrom の演奏時間(track/min/sec/frame)の取得
|
||||
* 停止している場合は NG が返る
|
||||
*/
|
||||
int mus_cdrom_get_playposition(cd_time *tm) {
|
||||
int mus_cdrom_get_playposition(int *t, int *m, int *s, int *f) {
|
||||
if (!prv.cd_valid) return NG;
|
||||
*tm = muscd_getpos();
|
||||
cd_time info;
|
||||
if (muscd_getpos(&info) != OK)
|
||||
return NG;
|
||||
*t = info.t;
|
||||
*m = info.m;
|
||||
*s = info.s;
|
||||
*f = info.f;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@
|
||||
#define __MUSIC_CLIENT_H__
|
||||
|
||||
#include "portab.h"
|
||||
#include "cdrom.h"
|
||||
#include "midi.h"
|
||||
|
||||
enum MixDevice {
|
||||
@@ -42,7 +41,7 @@ extern int mus_exit();
|
||||
/* cdrom related function */
|
||||
extern int mus_cdrom_start(int track, int loop);
|
||||
extern int mus_cdrom_stop(void);
|
||||
extern int mus_cdrom_get_playposition(cd_time *tm);
|
||||
extern int mus_cdrom_get_playposition(int *t, int *m, int *s, int *f);
|
||||
extern int mus_cdrom_get_maxtrack(void);
|
||||
extern boolean mus_cdrom_get_state(void);
|
||||
|
||||
|
||||
+2
-4
@@ -80,10 +80,8 @@ int muscd_stop() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
cd_time muscd_getpos() {
|
||||
cd_time tm;
|
||||
prv.cddev.getpos(&tm);
|
||||
return tm;
|
||||
int muscd_getpos(cd_time *tm) {
|
||||
return prv.cddev.getpos(tm);
|
||||
}
|
||||
|
||||
int muscd_cb() {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ extern int muscd_init();
|
||||
extern int muscd_exit();
|
||||
extern int muscd_start(int trk, int loop);
|
||||
extern int muscd_stop();
|
||||
extern cd_time muscd_getpos();
|
||||
extern int muscd_getpos(cd_time *tm);
|
||||
extern int muscd_cb();
|
||||
|
||||
#endif /* __MUSIC_CDROM_H__ */
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "graphicsdevice.h"
|
||||
#include "menu.h"
|
||||
#include "music.h"
|
||||
#include "cdrom.h"
|
||||
#include "savedata.h"
|
||||
#include "scenario.h"
|
||||
#include "variable.h"
|
||||
|
||||
Reference in New Issue
Block a user