-
-#if 0
-
-//kludge...
-//This didn't work--it still acted like the old way (interrupt @ VC = 0)
-//gram[0xCB00] = 64*3;
-
- WriteLog("Entering main loop...\n");
- while (running)
- {
- SDL_PumpEvents(); // Force key events into the buffer.
- gram[0xC804] = gram[0xC806] = gram[0xC80C] = 0; // Reset PIA ports...
-
- if (keys[SDLK_ESCAPE])
- running = false; // ESC to exit...
-
- if (keys[SDLK_SEMICOLON])
- gram[0xC804] |= 0x01; // Fire (;)
- if (keys[SDLK_l])
- gram[0xC804] |= 0x02; // Thrust (L)
- if (keys[SDLK_SPACE])
- gram[0xC804] |= 0x04; // Smart Bomb (space)
- if (keys[SDLK_BACKSPACE])
- gram[0xC804] |= 0x08; // Hyperspace (BkSp)
- if (keys[SDLK_2])
- gram[0xC804] |= 0x10; // Two Player Start (2)
- if (keys[SDLK_1])
- gram[0xC804] |= 0x20; // One Player Start (1)
- if (keys[SDLK_RETURN])
- gram[0xC804] |= 0x40; // Reverse (Enter)
- if (keys[SDLK_f])
- gram[0xC804] |= 0x80; // Down (F)
-
- if (keys[SDLK_r])
- gram[0xC806] |= 0x01; // Up (R)
- if (keys[SDLK_a])
- gram[0xC806] |= 0x02; // Inviso (A)
-
- if (keys[SDLK_F1])
- gram[0xC80C] |= 0x01; // Auto up (F1)
- if (keys[SDLK_F2])
- gram[0xC80C] |= 0x02; // Advance (F2)
- if (keys[SDLK_5])
- gram[0xC80C] |= 0x04; // Right Coin (5)
- if (keys[SDLK_F3])
- gram[0xC80C] |= 0x08; // High Score Reset (F3)
- if (keys[SDLK_3])
- gram[0xC80C] |= 0x10; // Left Coin (3)
- if (keys[SDLK_4])
- gram[0xC80C] |= 0x20; // Center Coin (4)
- if (keys[SDLK_F4])
- gram[0xC80C] |= 0x40; // Slam Switch (F4)
-
- if (keys[SDLK_F5]) // Sound CPU self-test (F5)
- soundCPU.cpuFlags |= V6808_ASSERT_LINE_NMI;
- if (keys[SDLK_F6]) // Reset the 6808 (F6)
- soundCPU.cpuFlags |= V6808_ASSERT_LINE_RESET;
-
-/*
-$CB00 is scanline counter, bits 2-7 (1 frame/240 =69.44... usec)
-
-Some places of interest to look at:
-
-RdMem: Reading address C80E [=0C, PC=15C3] <- Inside interrupt (read, then discarded)...
-RdMem: Reading address CB00 [=43, PC=15C6] <- interrupt
-RdMem: Reading address C80C [=00, PC=0758] <- input (?)
-RdMem: Reading address C80C [=00, PC=07B9] <- input (?)
-RdMem: Reading address C806 [=00, PC=078C] <- input
-RdMem: Reading address C804 [=00, PC=2679] <- input
-*/
- uint32 startTicks = SDL_GetTicks();
-// long video_clk = 0;
-// gram[0xCB00] = 0;
-
-/*
-//This is where the interrupt mask is restored in CC... Hmm...
-//This enables interrupts *after* the previous interrupt has occurred... Hmm.
-//Could $C80F (rom_pia_ctrlb) be the IRQ inhibit? Yes, it is!
-
- // the IRQ signal comes into CB1, and is set to VA11
- pia_1_cb1_w(0, scanline & 0x20);
-...
- // the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13
- pia_1_ca1_w(0, 0);
-...
- // the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13
- pia_1_ca1_w(0, 1);
-*/
-
-//WriteLog("--> Start of frame...\n");
- for(int i=0; i<3; i++)
- {
-//Not sure, but this *might* fix IRQ problem...
-//Checking the PIA IRQ mask for an IRQ seems to work OK. Now if only the timing elsewhere was right...
- if (gram[0xC80F] & 0x01)
- mainCPU.cpuFlags |= V6809_ASSERT_LINE_IRQ;//*/
-
- Execute6809(&mainCPU, 4000);
- mainCPU.clock -= 4000; // Remove 4K ticks from clock (in case it overflowed)
-//Not sure, but this *might* fix IRQ problem...
-//Checking the PIA IRQ mask for an IRQ seems to work OK. Now if only the timing elsewhere was right...
-/* if (gram[0xC80F] & 0x01)
- mainCPU.cpuFlags |= V6809_ASSERT_LINE_IRQ;//*/
-
- gram[0xCB00] += 64; // Update video counter...
- }
-
-//Hmm.
-/*if (gram[0xC80E] & 0x01)
- mainCPU.cpuFlags |= V6809_ASSERT_LINE_IRQ;//*/
-//48 lines... (+ 16)
-//gram[0xCB00] = 0;
- Execute6809(&mainCPU, 3000);
- mainCPU.clock -= 3000; // Remove 3K ticks from clock (in case it overflowed)
-//Not sure, but this *might* fix IRQ problem...
-//if (gram[0xC80F] & 0x01)
-//This isn't the right port on the PIA, but it does seem to make it through the demo now...
-//Lesse if this works... Seems to!
- if (gram[0xC80D] & 0x01) // Do COUNT240 IRQ (if enabled!)
- mainCPU.cpuFlags |= V6809_ASSERT_LINE_IRQ;
-
-/*if (gram[0xC80F] & 0x01)
- mainCPU.cpuFlags |= V6809_ASSERT_LINE_IRQ;
-gram[0xCB00] = 0; //*/
-
- gram[0xCB00] += 48; // Update video counter...
-
- Execute6809(&mainCPU, 1000);
- mainCPU.clock -= 1000; // Remove 1K ticks from clock (in case it overflowed)
-//Eh?
-//Ok, this is the interrupt it's looking for, but still...
-//if (gram[0xC80F] & 0x01)
-// mainCPU.cpuFlags |= V6809_ASSERT_LINE_IRQ;
-
- gram[0xCB00] += 16; // Update video counter...
-
-// RenderScreenBuffer();
- RenderScreenBuffer2(); // 1 frame = 16667 cycles
-// WriteLog("Main: Rendered back buffer. [6809 PC=%04X]\n", pcr);
-
- Execute6809(&mainCPU, 667); // Do QnD VBLANK
-
- // 1/60 sec = ? ms (16.6 ms)
- while (SDL_GetTicks() - startTicks < 16); // Wait for next frame...
-
-//kludge, temp...
-//Very interesting! It's the palette rotation that's slowing it down!
-//Fixed now, but this allows the color rotation while the wrong timing is in effect...
-/*for(int i=0; i<16; i++)
- WrMem(0xC000 + i, gram[0x9C26 + i]);//*/
- }
-
-/*uint16 pc = 0x15BA;
-for(int i=0; i<200; i++)
-//while (pc < 0x9000)
- pc += Decode6809(pc);//*/
-
-#else
-