NROM mapper support for controllers
authorAlyssa Rosenzweig <alyssa@backtick.town>
Sat, 2 Jul 2016 17:17:32 +0000 (10:17 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Sat, 2 Jul 2016 17:17:32 +0000 (10:17 -0700)
src/CPU/common.tosh

index e04d31a..c363d5c 100644 (file)
@@ -4,13 +4,17 @@ define-atomic mapper read (addr)
 if addr < 8192 then
        set M to item (addr mod 2048 + 1) of RAM
 else
-        if addr > 8192 and addr < 8200 then
-                read PPU register (addr - 8192)
-        else
-               if addr > 32767 then
-                       set M to (join "0x" (item ((addr - 32768) mod 16384 + 1) of PRG-ROM))
-               end
-        end
+       if addr > 8192 and addr < 8200 then
+               read PPU register (addr - 8192)
+   else
+               if addr = 16405 then
+                       read controller 1
+               else
+                       if addr > 32767 then
+                               set M to (join "0x" (item ((addr - 32768) mod 16384 + 1) of PRG-ROM))
+                       end
+               end
+   end
 end
 
 define-atomic mapper write (addr) (value)
@@ -20,13 +24,16 @@ else
        if addr > 8191 and addr < 8200 then
                write PPU register (addr - 8192) value: (value)
        else
-                if addr = 16404 then
-                        OAM DMA (value)
-                else
-                       if addr > 32768 then
-                               say "Writing to ROM isn't very nice, you know..."
-                       end
-                end
+               if addr = 16405 then
+                       controller strobe (value)
+               else
+                       if addr = 16404 then
+                               OAM DMA (value)
+         else
+                     if addr > 32768 then
+                                       say "Writing to ROM isn't very nice, you know..."
+                     end
+      end
        end
 end
 
@@ -82,4 +89,4 @@ end
 define-atomic step CPU
 mapper read (PC)
 set opcode to M
-change line by 1
+change line by 1
\ No newline at end of file
This page took 0.024475 seconds and 4 git commands to generate.