Skip to content

Commit

Permalink
xa_play on command_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopallini committed May 12, 2024
1 parent 2ff703f commit 71ff865
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cdrom/CONF.CTI
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -147,7 +145,8 @@ void game_load(){

void game_update()
{
if(command_mode == 0){
if(command_mode == 0)
{

if(balloon.display == 1)
{
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
11 changes: 8 additions & 3 deletions src/xa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions src/xa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 71ff865

Please sign in to comment.