--- SIDPlayer/src/main.cpp 2001/04/01 12:13:49 1.5 +++ SIDPlayer/src/main.cpp 2004/01/12 15:15:49 1.8 @@ -1,7 +1,7 @@ /* * main.cpp - SIDPlayer common routines * - * SIDPlayer (C) Copyright 1996-2001 Christian Bauer + * SIDPlayer (C) Copyright 1996-2004 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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]; + } +}