# HG changeset patch # User Robert McIntyre # Date 1333882093 18000 # Node ID bf9b9777c3ce2115020c6a5ab178d7e0b53c1ae9 # Parent dea7e476eba746e54fd8a7b3ba9cf3384b222b26 brought item-writer down to 20 items. diff -r dea7e476eba7 -r bf9b9777c3ce clojure/com/aurellem/run/bootstrap_0.clj --- a/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 04:10:49 2012 -0500 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 05:48:13 2012 -0500 @@ -919,18 +919,15 @@ ;;0xD5 ;;0xE5 ;;0xF5 - 0x37 ;; (item-hack) set cary flag no-op + 0x33 ;; (item-hack) set increment stack pointer no-op 0x1E ;; load limit into E limit 0x3F ;; (item-hack) set carry flag no-op - ;; load 1 into C. - 0x0E ;; C == 0 means input-first nybble - 0x01 ;; C == 0xFF means input-second nybble + ;; load 2 into C. + 0x0E ;; C == 1 means input-first nybble + 0x04 ;; C == 0 means input-second nybble - 0x0D ;; (item-hack) (dec C) - 0x2B ;; (item-hack) (dec HL) no-op - 0x21 ;; load target into HL target-low target-high @@ -960,7 +957,7 @@ 0x00 ;; (item-hack) no-op 0xB8 ;; see if input is different (CP A B) - 0x33 ;; (item-hack) (INC SP) + 0x00 ;; (item-hack) (INC SP) 0x28 ;; repeat above steps if input is not different ;; (jump relative backwards if B != A) 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) @@ -971,7 +968,7 @@ 0x37 ;; (item-hack) set-carry flag ;; branch based on C: 0x20 ;; JR NZ - 0x08 ;; skip "input first nybble" below + 23 ;; skip "input second nybble" and "jump to target" below ;; input second nybble @@ -993,8 +990,22 @@ 0x00 ;; (item-hack) 0x20 ;; jump back to input section if not done 0xDA ;; literal -36 == TM 18 (counter) - 0x01 ;; (item-hack) will never reach this instruction + 0x01 ;; (item-hack) set BC to literal (no-op) + ;; jump to target + 0x00 ;; (item-hack) these two bytes can be anything. + 0x01 + + 0x00 ;; (item-hack) no-op + 0xBF ;; (CP A A) ensures Z + + 0xCA ;; (item-hack) jump if Z + return-low + return-high + 0x01 ;; (item-hack) will never be reached. + + + ;; input first nybble 0x00 0xCB @@ -1002,24 +1013,21 @@ 0x57 ;; A -> D - 0x37 - 0x18 - 0xD5 ;; literal -20 == TM13; go back to input section - 0x01 + 0x37 ;; (item-hack) set carry flag no-op + 0x18 ;; relative jump backwards + 0xCD ;; literal -51 == TM05; go back to input section + 0x01 ;; (item-hack) will never reach this instruction - 0x3A ;; (item-hack) these two bytes can be anything. - 0x01 - ;; cleanup - ;;0xF1 - ;;0xE1 - ;;0xD1 - ;;0xC1 - 0x00 ;; (item-hack) no-op - 0xBF ;; (CP A A) ensures Z - ;;0xFB ;; re-enable interrupts;; unnecessary - 0xCA ;; (item-hack) jump if Z - return-low - return-high + ]))) - 0x01 ;; (item-hack) will never be reached. - ]))) + + +(defn test-item-writer [] + (-> (read-state "bootstrap-init") + (set-memory pc-item-list-start 50) + (set-memory-range + map-function-address-start + (reverse (disect-bytes-2 (inc pc-item-list-start)))) + (set-memory-range + (inc pc-item-list-start) + (item-writer 0xD162 201 0xD162))))