summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2010-02-03 20:36:23 +0100
committerSegher Boessenkool <segher@kernel.crashing.org>2010-02-03 20:36:23 +0100
commit98e301c1331cd2203d9464c9c6a73e9a15c2ebe3 (patch)
treec0ed4f231422d73805ac8e8f12b18a188916147b
parentc5fbdaf3a181db33ce29e5c54b984424ac4ae9f4 (diff)
Big interrupt handling improvement
-rw-r--r--emu.c65
-rw-r--r--io.c2
2 files changed, 59 insertions, 8 deletions
diff --git a/emu.c b/emu.c
index 549cbce..90c1958 100644
--- a/emu.c
+++ b/emu.c
@@ -764,25 +764,76 @@ static void run(void)
if (now - last_retrace_time >= PERIOD) {
// video
+ // FIXME: make this better
static u32 which = 1;
- mem[0x2863] |= mem[0x2862] & which;
+ mem[0x2863] |= which;
which ^= 3;
- if (mem[0x2863])
- do_irq(0);
-
last_retrace_time = now;
do_controller();
- // controller
- if (mem[0x3d21])
- do_irq(3);
+ mem[0x3d22] |= 2; // TMB2 FIXME: freq
+
+ // controller FIXME
+mem[0x3d22] |= 0x0100;
+ //if (mem[0x3d21])
+ // do_irq(3);
// sound
//do_irq(4); // XXX: gate me
+//mem[0x3d22] |= mem[0x3d21] & (1 << (random() % 16));
+//do_irq(random() % 8);
+
+ // XXX: handle FIQ
+
+ for (;;) {
+ // video
+ if (mem[0x2862] & mem[0x2863]) {
+ do_irq(0);
+ continue;
+ }
+
+ // XXX audio, IRQ1
+
+ // timerA, timerB
+ if (mem[0x3d21] & mem[0x3d22] & 0x0c00) {
+ do_irq(2);
+ continue;
+ }
+
+ // UART, ADC XXX: also SPI
+ if (mem[0x3d21] & mem[0x3d22] & 0x2100) {
+ do_irq(3);
+ continue;
+ }
+
+ // XXX audio, IRQ4
+
+ // extint1, extint2
+ if (mem[0x3d21] & mem[0x3d22] & 0x1200) {
+ do_irq(5);
+ continue;
+ }
+
+ // 1024Hz, 2048HZ, 4096HZ
+ if (mem[0x3d21] & mem[0x3d22] & 0x0070) { // 1024Hz
+ do_irq(6);
+ continue;
+ }
+
+ // TMB1, TMB2, 4Hz, key change
+ if (mem[0x3d21] & mem[0x3d22] & 0x008b) {
+ do_irq(7);
+ continue;
+ }
+
+ break;
+ }
+
+
if (pause_after_every_frame) {
printf("*** paused, press a key to continue\n");
diff --git a/io.c b/io.c
index 5921601..2b030db 100644
--- a/io.c
+++ b/io.c
@@ -398,7 +398,7 @@ u16 io_load(u32 addr)
break;
case 0x3d22: // IRQ status
- return mem[0x3d21]; // FIXME
+ break;
case 0x3d2b: // PAL/NTSC
break;