1 |
|
/* |
2 |
|
* main.cpp - SIDPlayer common routines |
3 |
|
* |
4 |
< |
* SIDPlayer (C) Copyright 1996-2001 Christian Bauer |
4 |
> |
* SIDPlayer (C) Copyright 1996-2003 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
46 |
|
static bool psid_loaded = false; |
47 |
|
|
48 |
|
// Data from PSID header |
49 |
< |
static uint16 init_adr; // C64 init routine address |
50 |
< |
uint16 play_adr; // C64 replay routine address |
51 |
< |
static uint32 speed_flags; // Speed flags (1 bit/song) |
49 |
> |
static uint16 init_adr; // C64 init routine address |
50 |
> |
uint16 play_adr; // C64 replay routine address |
51 |
> |
static bool play_adr_from_irq_vec; // Flag: dynamically update play_adr from IRQ vector ($0314/$0315 or $fffe/$ffff) |
52 |
> |
static uint32 speed_flags; // Speed flags (1 bit/song) |
53 |
|
|
54 |
|
|
55 |
|
|
57 |
|
* Init everything |
58 |
|
*/ |
59 |
|
|
60 |
< |
void InitAll(int argc, char **argv) |
60 |
> |
void InitAll(int &argc, char **&argv) |
61 |
|
{ |
62 |
|
PrefsInit(argc, argv); |
63 |
|
MemoryInit(); |
70 |
|
* Exit everything |
71 |
|
*/ |
72 |
|
|
73 |
< |
void ExitAll(void) |
73 |
> |
void ExitAll() |
74 |
|
{ |
75 |
|
CPUExit(); |
76 |
|
SIDExit(); |
161 |
|
|
162 |
|
init_adr = read_psid_16(header, PSID_INIT); |
163 |
|
play_adr = read_psid_16(header, PSID_MAIN); |
164 |
+ |
play_adr_from_irq_vec = (play_adr == 0); |
165 |
|
|
166 |
|
speed_flags = read_psid_32(header, PSID_SPEED); |
167 |
|
|
204 |
|
// Select default song |
205 |
|
SelectSong(current_song); |
206 |
|
|
205 |
– |
// Set replay routine address if not given in header |
206 |
– |
if (play_adr == 0) { // Replay routine address is given by interrupt vector |
207 |
– |
if (ram[1] & 2) // Kernal ROM switched in |
208 |
– |
play_adr = (ram[0x0315] << 8) | ram[0x0314]; |
209 |
– |
else // Kernal ROM switched out |
210 |
– |
play_adr = (ram[0xffff] << 8) | ram[0xfffe]; |
211 |
– |
} |
212 |
– |
|
207 |
|
// Everything OK |
208 |
|
psid_loaded = true; |
209 |
|
return true; |
214 |
|
* PSID file loaded and ready? |
215 |
|
*/ |
216 |
|
|
217 |
< |
bool IsPSIDLoaded(void) |
217 |
> |
bool IsPSIDLoaded() |
218 |
|
{ |
219 |
|
return psid_loaded; |
220 |
|
} |
243 |
|
// Execute init routine |
244 |
|
CPUExecute(init_adr, current_song, 0, 0, 1000000); |
245 |
|
} |
246 |
+ |
|
247 |
+ |
|
248 |
+ |
/* |
249 |
+ |
* Update play_adr from IRQ vector if necessary |
250 |
+ |
*/ |
251 |
+ |
|
252 |
+ |
void UpdatePlayAdr() |
253 |
+ |
{ |
254 |
+ |
if (play_adr_from_irq_vec) { |
255 |
+ |
if (ram[1] & 2) // Kernal ROM switched in |
256 |
+ |
play_adr = (ram[0x0315] << 8) | ram[0x0314]; |
257 |
+ |
else // Kernal ROM switched out |
258 |
+ |
play_adr = (ram[0xffff] << 8) | ram[0xfffe]; |
259 |
+ |
} |
260 |
+ |
} |