# HG changeset patch # User Robert McIntyre # Date 1333876249 18000 # Node ID dea7e476eba746e54fd8a7b3ba9cf3384b222b26 # Parent 93e74ed34305da8db1149c6270c2d2e07bf95580 preliminary item-writer complete diff -r 93e74ed34305 -r dea7e476eba7 clojure/com/aurellem/run/bootstrap_0.clj --- a/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 03:00:51 2012 -0500 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 04:10:49 2012 -0500 @@ -760,11 +760,7 @@ [return-high return-low] (disect-bytes-2 return-address)] (flatten [0xF3 ;; disable interrupts - ;;0xC5 ;; push junk onto stack - ;;0xD5 - ;;0xE5 - ;;0xF5 - + 0x1E ;; load limit into E limit @@ -776,7 +772,6 @@ 0x0E ;; C == 1 means input-first nybble 0x01 ;; C == 0 means input-second nybble - ;; Input Section 0x3E ;; load 0x20 into A, to measure dpad @@ -831,12 +826,6 @@ 0x20 ;; jump back to input section if not done 0xE4 ;; literal -28 - ;; cleanup - ;;0xF1 - ;;0xE1 - ;;0xD1 - ;;0xC1 - 0xFB ;; re-enable interrupts 0xC3 @@ -936,9 +925,12 @@ 0x3F ;; (item-hack) set carry flag no-op ;; load 1 into C. - 0x0E ;; C == 1 means input-first nybble - 0x01 ;; C == 0 means input-second nybble - + 0x0E ;; C == 0 means input-first nybble + 0x01 ;; C == 0xFF 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 @@ -976,45 +968,58 @@ 0x47 ;; load A into B 0x0D ;; dec C + 0x37 ;; (item-hack) set-carry flag ;; branch based on C: 0x20 ;; JR NZ - 0x07 ;; skip "input first nybble" below - + 0x08 ;; skip "input first nybble" below - ;; input first nybble - - 0xCB - 0x37 ;; swap nybbles on A - - 0x57 ;; A -> D - - 0x18 - 0xEC ;; literal -20 -- go back to input section - ;; input second nybble 0x0C ;; inc C - + 0x37 ;; (item-hack) set-carry flag no-op + + 0x00 ;; (item-hack) no-op 0xE6 ;; select bottom bits 0x0F + 0x37 ;; (item-hack) set-carry flag no-op + 0x00 ;; (item-hack) no-op 0xB2 ;; (OR A D) -> A 0x22 ;; (do (A -> (HL)) (INC HL)) 0x1D ;; (DEC E) + 0x00 ;; (item-hack) 0x20 ;; jump back to input section if not done - 0xE4 ;; literal -28 + 0xDA ;; literal -36 == TM 18 (counter) + 0x01 ;; (item-hack) will never reach this instruction + ;; input first nybble + 0x00 + 0xCB + 0x37 ;; swap nybbles on A + + 0x57 ;; A -> D + + 0x37 + 0x18 + 0xD5 ;; literal -20 == TM13; go back to input section + 0x01 + + 0x3A ;; (item-hack) these two bytes can be anything. + 0x01 ;; cleanup ;;0xF1 ;;0xE1 ;;0xD1 ;;0xC1 - - 0xFB ;; re-enable interrupts - - 0xC3 + 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 ]))) + return-high + + 0x01 ;; (item-hack) will never be reached. + ])))