X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fthunder.cpp;fp=src%2Fthunder.cpp;h=d1ebfde22f9e07fbac870ff4c933170210cba2cf;hb=be67039a7ed493081dd1503f94cdfae4dd4d965e;hp=521980578b027f8d9720e89cf9dd504a548f0d34;hpb=44a4bdffcaf520bc1681fcc0fd330460cd49129f;p=thunder diff --git a/src/thunder.cpp b/src/thunder.cpp index 5219805..d1ebfde 100644 --- a/src/thunder.cpp +++ b/src/thunder.cpp @@ -33,6 +33,8 @@ #include "v63701.h" #include "v6809.h" #include "video.h" +#include "ym2151.h" + using namespace std; @@ -98,8 +100,10 @@ uint8_t * psg_adrs[16]; //uint32_t voc_lens[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //uint8_t * voc_adrs[32]; -uint32_t fm_lens[14] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -uint8_t * fm_adrs[14]; +//uint32_t fm_lens[14] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +//uint8_t * fm_adrs[14]; + +Byte input1, input2, input3, input4, input5; fstream tr; // Tracelog hook uint16_t pcx; // Where we at? @@ -167,7 +171,10 @@ if (((addr >= 0x4180) && (addr <= 0x4191)) || (addr == 0x4380)) } #endif // if (addr < 0x423D || addr > 0x425C) // Protect writes to DSWs - +//if (addr == 0x4191) +//{ +// printf("V6809: Writing %02X to $4191...\n", b); +//} // Memory shared with MCU (CPU #1 only! CPU #2 does not) if ((addr >= 0x4000) && (addr <= 0x43FF)) mcuMem[addr - 0x3000] = b; @@ -279,34 +286,42 @@ if (((addr >= 0x0180) && (addr <= 0x0191)) || (addr == 0x0380)) uint8_t MCUReadMemory(uint16_t address) { -#if 1 if (address < 0x20) { // printf("V63701 read $%02X from $%02X...\n", memory[address], address); return InternalRegisterRead(address); } -#endif - -#if 0 - // Translate local reads @ $1000-$13FF to $4000-$43FF in shared RAM - if ((address >= 0x1000) && (address <= 0x13FF)) - return gram1[0x3000 + address]; - else -#endif - if ((address >= 0x2000) && (address <= 0x2001)) + else if ((address >= 0x2000) && (address <= 0x2001)) + { +// return 0; //for now + return YMReadReg(0); + } + // Various joystick + buttons; all are active low. + else if (address == 0x2020) + { +//printf("MCURead: Returning $%02X from $2020...\n", input1.byte); + return input1.byte; + } + else if (address == 0x2021) { - return 0; //for now -// return YMReadReg(0); +//extern bool V63701LogGo; +//if (input2.byte == 0xDF) +// V63701LogGo = true; + +//printf("MCURead: Returning $%02X from $2021...\n", input2.byte); + return input2.byte; } -// else if (address == 0x2020) -// return input_port_0_r(0); -// else if (address == 0x2021) -// return input_port_1_r(0); // This is DSW1 & 2. All switch settings are active low. else if (address == 0x2030) - return 0xFF; + { +//printf("MCURead: Returning $%02X from $2030...\n", input4.byte); + return input4.byte; + } else if (address == 0x2031) - return 0xFF; + { +//printf("MCURead: Returning $%02X from $2031...\n", input5.byte); + return input5.byte; + } return mcuMem[address]; } @@ -325,6 +340,10 @@ void MCUWriteMemory(uint16_t address, uint8_t data) } #endif +//if (address == 0x1191) +//{ +// printf("V63701: Writing $%02X to $1191...\n", data); +//} #if 0 // Translate local reads @ $1000-$13FF to $4000-$43FF in shared RAM if ((address >= 0x1000) && (address <= 0x13FF)) @@ -345,7 +364,7 @@ void MCUWriteMemory(uint16_t address, uint8_t data) else if (address == 0x2001) { //printf("Writing $%02X to YM2151 register $%02X...\n", data, ymRegister); -// YMWriteReg(0, ymRegister, data); + YMWriteReg(0, ymRegister, data); return; } @@ -354,6 +373,31 @@ void MCUWriteMemory(uint16_t address, uint8_t data) } +uint8_t V63701ReadPort1(void) +{ +// printf("V63701ReadPort1: Read $%02X...\n", input3.byte); + return input3.byte; +} + + +uint8_t V63701ReadPort2(void) +{ + return 0xFF; +} + + +void V63701WritePort1(uint8_t data) +{ +// printf("V63701WritePort1: Wrote $%02X...\n", data); +} + + +void V63701WritePort2(uint8_t data) +{ +// printf("V63701WritePort2: Wrote $%02X...\n", data); +} + + // // Generic Load file into image space // (No error checking performed! Responsibility of caller!) @@ -584,6 +628,7 @@ void LoadPSGs(void) } +#if 0 // // Load FM samples from disk // @@ -622,6 +667,7 @@ void LoadFMs(void) fp.close(); } } +#endif // @@ -743,7 +789,7 @@ extern bool disasm; // From 'V6809.CPP' // Load samples if they're there... LoadPSGs(); - LoadFMs(); +// LoadFMs(); // Set up V6809 execution contexts @@ -767,6 +813,10 @@ extern bool disasm; // From 'V6809.CPP' trace1 = false; SetRefreshRate(refresh2); // Tell GUI our refresh rate + // Set all inputs to inactive... + input1.byte = input2.byte = input3.byte = input4.byte = input5.byte = 0xFF; +// mcu.port1 = 0xFF; +// mcu.port2 = 0xFF; #if 0 // This is data that is supposed to come from the MCU... So that's why it hangs gram1[0x4182] = 0xA6; // Temp kludge @@ -860,53 +910,135 @@ WriteLog("About to enter main loop...\n"); SavePCXSnapshot(); // debounce = 10; } - else if (event.key.keysym.sym == SDLK_F10) - gram1[0x41A5]++; // Coin? (F10) - else if (event.key.keysym.sym == SDLK_c) - gram1[0x418C]++; // ? (C) Start +#if 1 + else if (event.key.keysym.sym == SDLK_5) + input1.bit.b5 = 0; + else if (event.key.keysym.sym == SDLK_1) + input1.bit.b6 = 0; else if (event.key.keysym.sym == SDLK_RIGHT) - { - // Disallow opposite directions @ same time - if (gram1[0x4281] == 0) - gram1[0x427F] = 1; // Stick right - } + input3.bit.b5 = 0; else if (event.key.keysym.sym == SDLK_LEFT) - { - // Disallow opposite directions@same time - if (gram1[0x427F] == 0) - gram1[0x4281] = 1; // Stick left - } + input3.bit.b4 = 0; else if (event.key.keysym.sym == SDLK_UP) - { - // Disallow opposite directions@same time - if (gram1[0x427D] == 0) - gram1[0x427B] = 1; // Stick up - } + input2.bit.b2 = 0; else if (event.key.keysym.sym == SDLK_DOWN) - { - // Disallow opposite directions@same time - if (gram1[0x427B] == 0) - gram1[0x427D] = 1; // Stick down - } - else if (event.key.keysym.sym == SDLK_q) - gram1[0x4276] = 1; // (Q) Jump + input1.bit.b2 = 0; + else if (event.key.keysym.sym == SDLK_q) // (Q) Jump + input1.bit.b1 = 0; else if (event.key.keysym.sym == SDLK_e) // (E) Fire - gram1[0x4278] = 1; + input3.bit.b3 = 0; +#else + else if (event.key.keysym.sym == SDLK_1) + input1.bit.b0 = 0; + else if (event.key.keysym.sym == SDLK_2) + input1.bit.b1 = 0; + else if (event.key.keysym.sym == SDLK_3) + input1.bit.b2 = 0; + else if (event.key.keysym.sym == SDLK_4) + input1.bit.b3 = 0; + else if (event.key.keysym.sym == SDLK_5) + input1.bit.b4 = 0; + else if (event.key.keysym.sym == SDLK_6) + input1.bit.b5 = 0; + else if (event.key.keysym.sym == SDLK_7) + input1.bit.b6 = 0; + else if (event.key.keysym.sym == SDLK_8) + input1.bit.b7 = 0; + + else if (event.key.keysym.sym == SDLK_q) + input2.bit.b0 = 0; + else if (event.key.keysym.sym == SDLK_w) + input2.bit.b1 = 0; + else if (event.key.keysym.sym == SDLK_e) + input2.bit.b2 = 0; + else if (event.key.keysym.sym == SDLK_r) + input2.bit.b3 = 0; + else if (event.key.keysym.sym == SDLK_t) + input2.bit.b4 = 0; + else if (event.key.keysym.sym == SDLK_y) + input2.bit.b5 = 0; + else if (event.key.keysym.sym == SDLK_u) + input2.bit.b6 = 0; + else if (event.key.keysym.sym == SDLK_i) + input2.bit.b7 = 0; + + else if (event.key.keysym.sym == SDLK_a) + input3.bit.b0 = 0; + else if (event.key.keysym.sym == SDLK_s) + input3.bit.b1 = 0; + else if (event.key.keysym.sym == SDLK_d) + input3.bit.b2 = 0; + else if (event.key.keysym.sym == SDLK_f) + input3.bit.b3 = 0; + else if (event.key.keysym.sym == SDLK_g) + input3.bit.b4 = 0; +#endif break; case SDL_KEYUP: - if (event.key.keysym.sym == SDLK_RIGHT) - gram1[0x427F] = 0; +#if 1 + if (event.key.keysym.sym == SDLK_5) + input1.bit.b5 = 1; + else if (event.key.keysym.sym == SDLK_1) + input1.bit.b6 = 1; + else if (event.key.keysym.sym == SDLK_RIGHT) + input3.bit.b5 = 1; else if (event.key.keysym.sym == SDLK_LEFT) - gram1[0x4281] = 0; + input3.bit.b4 = 1; else if (event.key.keysym.sym == SDLK_UP) - gram1[0x427B] = 0; + input2.bit.b2 = 1; else if (event.key.keysym.sym == SDLK_DOWN) - gram1[0x427D] = 0; - else if (event.key.keysym.sym == SDLK_q) - gram1[0x4276] = 0; // (Q) Jump + input1.bit.b2 = 1; + else if (event.key.keysym.sym == SDLK_q) // (Q) Jump + input1.bit.b1 = 1; else if (event.key.keysym.sym == SDLK_e) // (E) Fire - gram1[0x4278] = 0; + input3.bit.b3 = 1; +#else + if (event.key.keysym.sym == SDLK_1) + input1.bit.b0 = 1; + else if (event.key.keysym.sym == SDLK_2) + input1.bit.b1 = 1; + else if (event.key.keysym.sym == SDLK_3) + input1.bit.b2 = 1; + else if (event.key.keysym.sym == SDLK_4) + input1.bit.b3 = 1; + else if (event.key.keysym.sym == SDLK_5) + input1.bit.b4 = 1; + else if (event.key.keysym.sym == SDLK_6) + input1.bit.b5 = 1; + else if (event.key.keysym.sym == SDLK_7) + input1.bit.b6 = 1; + else if (event.key.keysym.sym == SDLK_8) + input1.bit.b7 = 1; + + else if (event.key.keysym.sym == SDLK_q) + input2.bit.b0 = 1; + else if (event.key.keysym.sym == SDLK_w) + input2.bit.b1 = 1; + else if (event.key.keysym.sym == SDLK_e) + input2.bit.b2 = 1; + else if (event.key.keysym.sym == SDLK_r) + input2.bit.b3 = 1; + else if (event.key.keysym.sym == SDLK_t) + input2.bit.b4 = 1; + else if (event.key.keysym.sym == SDLK_y) + input2.bit.b5 = 1; + else if (event.key.keysym.sym == SDLK_u) + input2.bit.b6 = 1; + else if (event.key.keysym.sym == SDLK_i) + input2.bit.b7 = 1; + + else if (event.key.keysym.sym == SDLK_a) + input3.bit.b0 = 1; + else if (event.key.keysym.sym == SDLK_s) + input3.bit.b1 = 1; + else if (event.key.keysym.sym == SDLK_d) + input3.bit.b2 = 1; + else if (event.key.keysym.sym == SDLK_f) + input3.bit.b3 = 1; + else if (event.key.keysym.sym == SDLK_g) + input3.bit.b4 = 1; +#endif break; } @@ -1131,6 +1263,7 @@ WriteLog("About to enter main loop...\n"); // We can do this here because we're not executing the cores yet. cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ; cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ; + mcu.cpuFlags |= V63701_ASSERT_LINE_IRQ; // while (cpu1.clock < 25000) // 1.538 MHz = 25633.333... cycles per frame (1/60 s) // 25600 cycles/frame @@ -1170,9 +1303,11 @@ WriteLog("About to enter main loop...\n"); if (psg_adrs[i]) delete[] psg_adrs[i]; +#if 0 for(int i=0; i<14; i++) if (fm_adrs[i]) delete[] fm_adrs[i]; +#endif LogDone();