SDL_Surface * screen;
-uint8 * gram, * grom; // Allocate RAM & ROM pointers
-uint8 * gram1, * gram2, * grom1, * grom2; // Actual memory
-uint8 * grom3, * grom4, * data_rom, * spr_rom, * voice_rom;
-uint8 * chr_rom; // Character ROM pointer
+uint8 * gram, * grom; // Allocate RAM & ROM pointers
+uint8 gram1[0x10000], gram2[0x10000], grom1[0x10000], grom2[0x10000]; // Actual memory
+uint8 grom3[0x8000], grom4[0x8000], data_rom[0x40000], spr_rom[0x80000], voice_rom[0x20000];
+uint8 chr_rom[0x60000]; // Character ROM pointer
+/*
+ gram1 = new uint8[0x10000];
+ grom1 = new uint8[0x10000];
+ gram2 = new uint8[0x10000];
+ grom2 = new uint8[0x10000];
+ chr_rom = new uint8[0x60000];
+ grom3 = new uint8[0x8000];
+ grom4 = new uint8[0x8000];
+ data_rom = new uint8[0x40000];
+ spr_rom = new uint8[0x80000];
+ voice_rom = new uint8[0x20000];
+*/
V6809REGS cpu1, cpu2;
{
InitLog("thunder.log");
-/* extern uint16 cpu1.pc, cpu1.s, cpu1.u, cpu1.x, cpu1.y; // Pull in vars from '6809.cpp'
- extern uint8 cpu1.a, cpu1.b, cpu1.cc, cpu1.dp;
- extern long iclock;
- extern bool illegal;
- extern uint16 cpu2.pc, cpu2.s, cpu2.u, cpu2.x, cpu2.y; // Pull in vars from '6809B.cpp'
- extern uint8 cpu2.a, cpu2.b, cpu2.cc, cpu2.dp;
- extern long iclockB;
- extern bool illegalB;
- extern void (* exec_op0[256])(); // Array of page zero opcode functions...
- extern void (* exec_op1[256])(); // Array of page one opcode functions...
- extern void (* exec_op2[256])(); // Array of page two opcode functions...
- extern void (* exec_op0B[256])(); // Array of page zero opcode functions...
- extern void (* exec_op1B[256])(); // Array of page one opcode functions...
- extern void (* exec_op2B[256])(); // Array of page two opcode functions...*/
- extern bool charbase; // From 'SCREEN.CPP'
-// extern unsigned int vesa_memptr;
- charbase = false;
+ extern bool charbase; // From 'SCREEN.CPP'
+ charbase = false;
char lbuff[80];
fstream ff; // Declare fstream without file hooks...
uint16 fire_debounce = 0; // Fire button debounce counter
// bool refresh2 = true; // Default to 60 Hz...
uint8 x; // General placeholder...
- bool active = true; // Program running flag
+ bool active = true; // Program running flag
-// SDL_Surface * screen = NULL; // SDL screen pointer
- SDL_Event event; // SDL "event"
-// int keyPressed; // SDL key pressed...
- extern uint8 palette[768]; // Screen physical palette
+ SDL_Event event; // SDL "event"
+ extern uint8 palette[768]; // Screen physical palette
uint32 ticks, oldTicks;
-// tr.open("exe.log", ios::binary | ios::out); // Tracelog
+ cout << endl << "THUNDER v"THUNDER_VERSION" ";
+ cout << "by James Hammons" << endl;
+ cout << "Serial #20090723 / Prerelease" << endl;
+ cout << "(C) 2003, 2009 Underground Software" << endl << endl;
- cout << endl << "THUNDER v"THUNDER_VERSION" ";
- cout << "by James Hammons" << endl;
- cout << "Serial #20090723 / Prerelease" << endl;
- cout << "(C) 2003, 2009 Underground Software" << endl << endl;
+ cout << "This emulator is free software. If you paid for it you were RIPPED OFF"
+ << endl << endl;
- cout << "This emulator is free software. If you paid for it you were RIPPED OFF"
- << endl << endl;
+ cout << "Initializing SDL..." << endl;
- cout << "Initializing SDL..." << endl;
-
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
- {
- cout << "Couldn't initialize SDL: " << SDL_GetError() << endl;
- return -1;
- }
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
+ {
+ cout << "Couldn't initialize SDL: " << SDL_GetError() << endl;
+ return -1;
+ }
- SDL_WM_SetCaption("Thunder v"THUNDER_VERSION" ", "Thunder");
+ SDL_WM_SetCaption("Thunder v"THUNDER_VERSION" ", "Thunder");
keys = SDL_GetKeyState(NULL); // Get the SDL keyboard matrix
+#if 0
cout << "Allocating memory..." << endl;
//Does this anyway... set_new_handler(0); // Make 'new' return NULL on failure...
gram1 = new uint8[0x10000];
voice_rom = new uint8[0x20000];
if (voice_rom == NULL) { cout << "Could not allocate ROM voice data!" << endl
<< "Aborting!" << endl; return -1; }
+#endif
gram = gram1; grom = grom1; // Needed only for debugger
// SDL key handling...
-#warning "KEYS ARE FUCKED UP! !!! FIX !!!"
- SDL_PumpEvents(); // Force key events into the buffer.
-// keyPressed = 0; // Reset keypress
-// while (SDL_PollEvent(&event) != 0) // Bleed out all pending key events...
-// {
-// if (event.type == SDL_KEYDOWN)
-// keys[event.key.keysym.scancode] = 1;
-// if (event.type == SDL_KEYUP)
-// keys[event.key.keysym.scancode] = 0;
-// }
+ SDL_PumpEvents(); // Force key events into the buffer.
-// {
if (keys[SDLK_ESCAPE])
running = false; // ESC to exit...
}
}
if (keys[SDLK_1])
- gram1[0x427A] = 1; // (1)
+ gram1[0x427A] = 1; // (1)
if (keys[SDLK_2])
- gram1[0x427C] = 1; // (2)
+ gram1[0x427C] = 1; // (2)
if (keys[SDLK_3])
- gram1[0x427E] = 1; // (3)
+ gram1[0x427E] = 1; // (3)
if (keys[SDLK_5])
- gram1[0x4280] = 1; // (5)
- if (keys[0x10]|keys[29])
- gram1[0x4276] = 1; // (Q) Jump
- if (keys[0x11])
- gram1[0x426A] = 1; // (W)
+ gram1[0x4280] = 1; // (5)
+ if (keys[SDLK_q] | keys[29])
+ gram1[0x4276] = 1; // (Q) Jump
+ if (keys[SDLK_w])
+ gram1[0x426A] = 1; // (W)
if (fire_debounce)
fire_debounce--;
- if (keys[0x12]|keys[56]) // (E) Fire
+ if (keys[SDLK_e] | keys[56]) // (E) Fire
{
if (!fire_debounce)
{
gram1[0x4278] = 1;
+
if (gram1[0x3F08] == 0xFF) // Ugly kludge for debouncing gun
- {
fire_debounce = 8;
- }
else
- {
fire_debounce = 2;
- }
}
}
- if (keys[0x13])
- gram1[0x426C] = 1; // (R)
- if (keys[0x14])
- gram1[0x4262] = 1; // (T)
- if (keys[0x15])
- gram1[0x4260] = 1; // (Y)
+ if (keys[SDLK_r])
+ gram1[0x426C] = 1; // (R)
+ if (keys[SDLK_t])
+ gram1[0x4262] = 1; // (T)
+ if (keys[SDLK_y])
+ gram1[0x4260] = 1; // (Y)
if (keys[SDLK_F10])
- gram1[0x41A5]++; // Coin? (F10)
+ gram1[0x41A5]++; // Coin? (F10)
if (keys[SDLK_z])
- gram1[0x4189]++; // ? (Z) credits l dig
+ gram1[0x4189]++; // ? (Z) credits l dig
if (keys[SDLK_x])
- gram1[0x418A]++; // ? (X) credits r dig
+ gram1[0x418A]++; // ? (X) credits r dig
if (keys[SDLK_c])
- gram1[0x418C]++; // ? (C) Start
+ gram1[0x418C]++; // ? (C) Start
if (keys[SDLK_v])
- gram1[0x418D]++; // ? (V)
+ gram1[0x418D]++; // ? (V)
if (keys[SDLK_F7])
- SpawnSound(USERSOUND, 0); // Do user sound (F7)
-// if (keys[0x42])
+ SpawnSound(USERSOUND, 0); // Do user sound (F7)
+// if (keys[SDLK_F8])
// {
-// gram1[0x4380] = 0; // (F8) kill music (this worx)
-// charbase = false; // Switch chars out...
+// gram1[0x4380] = 0; // (F8) kill music (this worx)
+// charbase = false; // Switch chars out...
// }
-// if (keys[0x43]) gram1[0x4285] = 1; // (F9) strobe unknown loc
- if (keys[SDLK_F1]) // (F11)
+// if (keys[SDLK_F9]) gram1[0x4285] = 1; // (F9) strobe unknown loc
+ if (keys[SDLK_F11]) // (F11)
{
Execute6809(&cpu1, 10);
Execute6809(&cpu2, 10);
// if (enable_cpu)
if (true)
{
-/*// if (irqGoA)
+#if 0
+// if (irqGoA)
cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
Execute6809(&cpu1, 25000);
Execute6809(&cpu2, 25000);
cpu2.clock -= 25000; // Remove 25K ticks from clock (in case it overflowed)//*/
-
-// cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
-// cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ;
- while (cpu1.clock < 25000)
+#else
+ cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
+ cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ;
+// while (cpu1.clock < 25000)
+ for(uint32 i=0; i<250; i++)
{
// Gay, but what are ya gonna do?
- Execute6809(&cpu1, 5);
- Execute6809(&cpu2, 5);
+ // There's better ways, such as keeping track of when slave writes to master, etc...
+ Execute6809(&cpu1, 100);
+ Execute6809(&cpu2, 100);
}
cpu1.clock -= 25000; // Remove 25K ticks from clock (in case it overflowed)
cpu2.clock -= 25000; // Remove 25K ticks from clock (in case it overflowed)//*/
-
+#endif
} // END: enable_cpu
// if (refresh_++ == 1) // 30 Hz...
// BlitChar(screen, chr_rom, gram1);
// refresh_ = (refresh2 ? 1 : 0); // 60/30 Hz...
// }
+
//temp, for testing...
BlitChar(screen, chr_rom, gram1);
active = false; //break; // Quit
}
- SDL_Quit(); // Shut down SDL
+ SDL_Quit(); // Shut down SDL
+#if 0
delete[] gram1; // Deallocate RAM & ROM spaces
delete[] grom1;
delete[] gram2;
delete[] data_rom;
delete[] spr_rom;
delete[] voice_rom;
+#endif
for(int i=0; i<16; i++)
- if (psg_adrs[i] != NULL)
- delete[] psg_adrs[i]; // Deallocate if loaded
+ if (psg_adrs[i])
+ delete[] psg_adrs[i]; // Deallocate if loaded
for(int i=0; i<14; i++)
- if (fm_adrs[i] != NULL)
- delete[] fm_adrs[i]; // Deallocate if loaded
+ if (fm_adrs[i])
+ delete[] fm_adrs[i]; // Deallocate if loaded
-// tr.close(); // Close tracelog
LogDone();
return 1;