;;;
;;; mapper2.lisp
;;;
;;; Implementation of iNES mapper 2 (UNROM)
;;;

(in-package :neth)

(defstruct mapper2)

(defun mapper2-write (address data)
  (declare (ignore address))
  (prg-map-16k 0 data))

(defmethod mapper-init ((mapper mapper2))
  (prg-map-16k 0 0)
  (prg-map-16k 1 -1)
  (chr-map-8k 0 0)
  (setf (aref *cpu-write-handlers* 4) #'mapper2-write)
  (setf (aref *cpu-write-handlers* 5) #'mapper2-write)
  (setf (aref *cpu-write-handlers* 6) #'mapper2-write)
  (setf (aref *cpu-write-handlers* 7) #'mapper2-write))

(defmapper 2 #'make-mapper2 "UNROM")

;;; EOF
