--- SIDPlayer/src/main.cpp 2003/04/11 20:23:02 1.6 +++ SIDPlayer/src/main.cpp 2003/10/21 16:56:19 1.7 @@ -46,9 +46,10 @@ char copyright_info[64]; static bool psid_loaded = false; // Data from PSID header -static uint16 init_adr; // C64 init routine address -uint16 play_adr; // C64 replay routine address -static uint32 speed_flags; // Speed flags (1 bit/song) +static uint16 init_adr; // C64 init routine address +uint16 play_adr; // C64 replay routine address +static bool play_adr_from_irq_vec; // Flag: dynamically update play_adr from IRQ vector ($0314/$0315 or $fffe/$ffff) +static uint32 speed_flags; // Speed flags (1 bit/song) @@ -69,7 +70,7 @@ void InitAll(int &argc, char **&argv) * Exit everything */ -void ExitAll(void) +void ExitAll() { CPUExit(); SIDExit(); @@ -160,6 +161,7 @@ bool LoadPSIDFile(const char *file) init_adr = read_psid_16(header, PSID_INIT); play_adr = read_psid_16(header, PSID_MAIN); + play_adr_from_irq_vec = (play_adr == 0); speed_flags = read_psid_32(header, PSID_SPEED); @@ -202,14 +204,6 @@ bool LoadPSIDFile(const char *file) // Select default song SelectSong(current_song); - // Set replay routine address if not given in header - if (play_adr == 0) { // Replay routine address is given by interrupt vector - if (ram[1] & 2) // Kernal ROM switched in - play_adr = (ram[0x0315] << 8) | ram[0x0314]; - else // Kernal ROM switched out - play_adr = (ram[0xffff] << 8) | ram[0xfffe]; - } - // Everything OK psid_loaded = true; return true; @@ -220,7 +214,7 @@ bool LoadPSIDFile(const char *file) * PSID file loaded and ready? */ -bool IsPSIDLoaded(void) +bool IsPSIDLoaded() { return psid_loaded; } @@ -249,3 +243,18 @@ void SelectSong(int num) // Execute init routine CPUExecute(init_adr, current_song, 0, 0, 1000000); } + + +/* + * Update play_adr from IRQ vector if necessary + */ + +void UpdatePlayAdr() +{ + if (play_adr_from_irq_vec) { + if (ram[1] & 2) // Kernal ROM switched in + play_adr = (ram[0x0315] << 8) | ram[0x0314]; + else // Kernal ROM switched out + play_adr = (ram[0xffff] << 8) | ram[0xfffe]; + } +}