Skip to content

Commit

Permalink
Minor memory map improvements, add .gitignore.
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcons committed Jun 20, 2013
1 parent 725e362 commit 8e3dcaf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.fasl
roms/
28 changes: 27 additions & 1 deletion src/apu.lisp
Expand Up @@ -2,5 +2,31 @@

(defstruct apu
"The Nintendo Audio Processing Unit."
(regs (bytevector #x17)))
(pulse-1)
(pulse-2)
(triangle)
(noise)
(status))

;;; KLUDGE: The APU also currently handles input requests. Cheating!
(defun get-byte-apu% (addr)
(case addr
(#x4014 (format t "OAM DMA not yet implemented."))
(#x4016 (prog1 (get-state *pad*)
(next-state *pad*)))
(otherwise 0)))

(defun (setf get-byte-apu%) (new-val addr)
(cond ((= addr #x4014) (format t "OAM DMA not yet implemented."))
((= addr #x4016) (setf (pad-strobe *pad*) :a))
((< addr #x4004) (update-pulse addr new-val 0))
((< addr #x4008) (update-pulse addr new-val 1))
((< addr #x400c) (update-triangle addr new-val))
((< addr #x4010) (update-noise addr new-val))
((= addr #x4015) (update-status new-val))
(t 0)))

(defun update-pulse (addr val which))
(defun update-triangle (addr val))
(defun update-noise (addr val))
(defun update-status (val))
11 changes: 0 additions & 11 deletions src/input.lisp
Expand Up @@ -54,14 +54,3 @@ the keypress of the event if it is of type :key-down-event."
(:sdl-key-escape :quit)
(t (alexandria:when-let (index (%keymap key))
(setf (aref (pad-buttons pad) index) 1)))))

(defun get-byte-input% (addr)
(case addr
(#x4015 (format t "OAM DMA not yet implemented."))
(#x4016 (prog1 (get-state *pad*)
(next-state *pad*)))
(otherwise 0)))

(defun (setf get-byte-input%) (new-val addr)
(when (= addr #x4016)
(setf (pad-strobe *pad*) :a)))
4 changes: 2 additions & 2 deletions src/mem.lisp
Expand Up @@ -3,14 +3,14 @@
(defun 6502:get-byte (addr)
(cond ((< addr #x2000) (get-byte-ram% addr))
((< addr #x4000) (get-byte-ppu% addr))
((< addr #x4018) (get-byte-input% addr))
((= addr #x4016) (get-byte-input% addr))
((< addr #x8000) (format t "Cartridge RAM not yet implemented"))
(t (get-mapper (nes-mapper *nes*) addr))))

(defun (setf 6502:get-byte) (new-val addr)
(cond ((< addr #x2000) (setf (get-byte-ram% addr) new-val))
((< addr #x4000) (setf (get-byte-ppu% addr) new-val))
((< addr #x4018) (setf (get-byte-input% addr) new-val))
((< addr #x4020) (setf (get-byte-apu% addr) new-val))
((< addr #x8000) (format t "Cartridge RAM not yet implemented"))
(t (set-mapper (nes-mapper *nes*) addr new-val))))

Expand Down

0 comments on commit 8e3dcaf

Please sign in to comment.