From 71ff865838177f6589d8c9ab613b481c23d77666 Mon Sep 17 00:00:00 2001 From: Fabio Pallini Date: Sun, 12 May 2024 17:56:48 +0200 Subject: [PATCH] xa_play on command_mode --- cdrom/CONF.CTI | 6 +++--- src/game.c | 18 ++++++++++++++---- src/xa.c | 11 ++++++++--- src/xa.h | 5 +++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/cdrom/CONF.CTI b/cdrom/CONF.CTI index bee2e35..57cb788 100644 --- a/cdrom/CONF.CTI +++ b/cdrom/CONF.CTI @@ -109,9 +109,9 @@ Disc CDROMXA_PSX ;the disk format EndFile ;Directory XA ;make a new directory called XA and put the files below in it - ;File FINAL.XA - ; XASource [root]\DATA\FINAL.XA - ;EndFile + File FINAL.XA + XASource [root]\data\FINAL.XA + EndFile ;File FINAL2.XA ;XASource [root]\DATA\FINAL2.XA diff --git a/src/game.c b/src/game.c index 1cab5c0..6d5da99 100644 --- a/src/game.c +++ b/src/game.c @@ -40,6 +40,7 @@ void zoneTo(int id, u_char *fileName, long camX, long camY, long camZ, short cam void commands(u_long pad, u_long opad, Sprite *player); void zones(); void startCommandMode(); +void stopCommandMode(); typedef struct { u_char type; @@ -116,9 +117,6 @@ void game_load(){ scene_add_sprite(&dmg.sprite[3]); init_balloon(&balloon, tpages[0], SCREEN_WIDTH, SCREEN_HEIGHT); - - xa_play(); - //free3(cd_data); sprite_init(&sprite_player, 64, 64, tpages[2]); sprite_set_uv(&sprite_player, 0, 0, 16, 16); @@ -147,7 +145,8 @@ void game_load(){ void game_update() { - if(command_mode == 0){ + if(command_mode == 0) + { if(balloon.display == 1) { @@ -261,6 +260,10 @@ void game_update() enemy_update(e); enemy_node = enemy_node->next; } + if(opad == 0 && pad & PADLsquare){ + xaChannel = (xaChannel+1)%NUMCHANNELS; + xa_play(xaChannel); + } } } @@ -358,6 +361,7 @@ void commands(u_long pad, u_long opad, Sprite *player) { command_index = 0; } if(pad & PADLcircle && (opad & PADLcircle) == 0){ + stopCommandMode(); closeCommandMenu(); camera = prevCamera; command_mode = 0; @@ -588,5 +592,11 @@ void startCommandMode(){ mesh_player_fight.pos.vx = -200; mesh_player_fight.pos.vz = 0; mesh_player_fight.rot.vy = 3072; + xaChannel = 0; + xa_play(xaChannel); } } + +void stopCommandMode(){ + xa_pause(); +} diff --git a/src/xa.c b/src/xa.c index 43b80fe..7dd7b01 100644 --- a/src/xa.c +++ b/src/xa.c @@ -16,7 +16,7 @@ u_char buffer[2340]; CdlCB PrepareXA(void); int currentPos = 0; // current position of the CD-ROM -void xa_play() +void xa_init() { CdlFILE fp; // CD file details CdlCB Oldcallback; // keep any old CdCallback @@ -32,7 +32,7 @@ void xa_play() xafile.endpos = xafile.startpos + (fp.size/2048) -1; // set up for XA playing Oldcallback = PrepareXA(); - PlayXAChannel(0,xafile.startpos,xafile.endpos); + //PlayXAChannel(0,xafile.startpos,xafile.endpos); //stop //CdControlF(CdlPause,0); //VSync(3); //maybe useless @@ -44,10 +44,15 @@ void xa_play() //StopCallback(); } -void xa_play_channel(int channel){ +void xa_play(int channel){ + xa_init(); PlayXAChannel(channel, xafile.startpos, xafile.endpos); } +void xa_pause(){ + CdControlF(CdlPause, 0); +} + // plays channel zero of an .XA file void PlayXAChannel(int channelNum, int startPos, int endpos) { diff --git a/src/xa.h b/src/xa.h index 8f3eeb3..f287503 100644 --- a/src/xa.h +++ b/src/xa.h @@ -10,8 +10,9 @@ #define NUMCHANNELS 8 -void xa_play(); -void xa_play_channel(int channel); +void xa_init(); +void xa_play(int channel); +void xa_pause(); void PlayXAChannel(int channel, int startPos, int endpos); void cbready(int intr, u_char *result); void UnprepareXA(CdlCB oldCallback);