Mercurial > vba-clojure
comparison clojure/com/aurellem/run/bootstrap_0.clj @ 340:dea7e476eba7
preliminary item-writer complete
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 08 Apr 2012 04:10:49 -0500 |
parents | 93e74ed34305 |
children | bf9b9777c3ce |
comparison
equal
deleted
inserted
replaced
339:93e74ed34305 | 340:dea7e476eba7 |
---|---|
758 (defn basic-writer [target-address limit return-address] | 758 (defn basic-writer [target-address limit return-address] |
759 (let [[target-high target-low] (disect-bytes-2 target-address) | 759 (let [[target-high target-low] (disect-bytes-2 target-address) |
760 [return-high return-low] (disect-bytes-2 return-address)] | 760 [return-high return-low] (disect-bytes-2 return-address)] |
761 (flatten | 761 (flatten |
762 [0xF3 ;; disable interrupts | 762 [0xF3 ;; disable interrupts |
763 ;;0xC5 ;; push junk onto stack | 763 |
764 ;;0xD5 | |
765 ;;0xE5 | |
766 ;;0xF5 | |
767 | |
768 0x1E ;; load limit into E | 764 0x1E ;; load limit into E |
769 limit | 765 limit |
770 | 766 |
771 0x21 ;; load target into HL | 767 0x21 ;; load target into HL |
772 target-low | 768 target-low |
774 | 770 |
775 ;; load 1 into C. | 771 ;; load 1 into C. |
776 0x0E ;; C == 1 means input-first nybble | 772 0x0E ;; C == 1 means input-first nybble |
777 0x01 ;; C == 0 means input-second nybble | 773 0x01 ;; C == 0 means input-second nybble |
778 | 774 |
779 | |
780 ;; Input Section | 775 ;; Input Section |
781 | 776 |
782 0x3E ;; load 0x20 into A, to measure dpad | 777 0x3E ;; load 0x20 into A, to measure dpad |
783 0x20 | 778 0x20 |
784 | 779 |
829 0x1D ;; (DEC E) | 824 0x1D ;; (DEC E) |
830 | 825 |
831 0x20 ;; jump back to input section if not done | 826 0x20 ;; jump back to input section if not done |
832 0xE4 ;; literal -28 | 827 0xE4 ;; literal -28 |
833 | 828 |
834 ;; cleanup | |
835 ;;0xF1 | |
836 ;;0xE1 | |
837 ;;0xD1 | |
838 ;;0xC1 | |
839 | |
840 0xFB ;; re-enable interrupts | 829 0xFB ;; re-enable interrupts |
841 | 830 |
842 0xC3 | 831 0xC3 |
843 return-low | 832 return-low |
844 return-high ]))) | 833 return-high ]))) |
934 0x1E ;; load limit into E | 923 0x1E ;; load limit into E |
935 limit | 924 limit |
936 0x3F ;; (item-hack) set carry flag no-op | 925 0x3F ;; (item-hack) set carry flag no-op |
937 | 926 |
938 ;; load 1 into C. | 927 ;; load 1 into C. |
939 0x0E ;; C == 1 means input-first nybble | 928 0x0E ;; C == 0 means input-first nybble |
940 0x01 ;; C == 0 means input-second nybble | 929 0x01 ;; C == 0xFF means input-second nybble |
941 | 930 |
931 0x0D ;; (item-hack) (dec C) | |
932 0x2B ;; (item-hack) (dec HL) no-op | |
933 | |
942 0x21 ;; load target into HL | 934 0x21 ;; load target into HL |
943 target-low | 935 target-low |
944 target-high | 936 target-high |
945 0x37 ;; (item-hack) set carry flag no-op | 937 0x37 ;; (item-hack) set carry flag no-op |
946 | 938 |
974 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) | 966 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) |
975 | 967 |
976 0x47 ;; load A into B | 968 0x47 ;; load A into B |
977 | 969 |
978 0x0D ;; dec C | 970 0x0D ;; dec C |
971 0x37 ;; (item-hack) set-carry flag | |
979 ;; branch based on C: | 972 ;; branch based on C: |
980 0x20 ;; JR NZ | 973 0x20 ;; JR NZ |
981 0x07 ;; skip "input first nybble" below | 974 0x08 ;; skip "input first nybble" below |
982 | |
983 | 975 |
976 ;; input second nybble | |
977 | |
978 0x0C ;; inc C | |
979 0x37 ;; (item-hack) set-carry flag no-op | |
980 | |
981 0x00 ;; (item-hack) no-op | |
982 0xE6 ;; select bottom bits | |
983 0x0F | |
984 0x37 ;; (item-hack) set-carry flag no-op | |
985 | |
986 0x00 ;; (item-hack) no-op | |
987 0xB2 ;; (OR A D) -> A | |
988 | |
989 0x22 ;; (do (A -> (HL)) (INC HL)) | |
990 | |
991 0x1D ;; (DEC E) | |
992 | |
993 0x00 ;; (item-hack) | |
994 0x20 ;; jump back to input section if not done | |
995 0xDA ;; literal -36 == TM 18 (counter) | |
996 0x01 ;; (item-hack) will never reach this instruction | |
997 | |
984 ;; input first nybble | 998 ;; input first nybble |
985 | 999 0x00 |
986 0xCB | 1000 0xCB |
987 0x37 ;; swap nybbles on A | 1001 0x37 ;; swap nybbles on A |
988 | 1002 |
989 0x57 ;; A -> D | 1003 0x57 ;; A -> D |
990 | 1004 |
1005 0x37 | |
991 0x18 | 1006 0x18 |
992 0xEC ;; literal -20 -- go back to input section | 1007 0xD5 ;; literal -20 == TM13; go back to input section |
993 | 1008 0x01 |
994 ;; input second nybble | 1009 |
995 | 1010 0x3A ;; (item-hack) these two bytes can be anything. |
996 0x0C ;; inc C | 1011 0x01 |
997 | |
998 0xE6 ;; select bottom bits | |
999 0x0F | |
1000 | |
1001 0xB2 ;; (OR A D) -> A | |
1002 | |
1003 0x22 ;; (do (A -> (HL)) (INC HL)) | |
1004 | |
1005 0x1D ;; (DEC E) | |
1006 | |
1007 0x20 ;; jump back to input section if not done | |
1008 0xE4 ;; literal -28 | |
1009 | |
1010 ;; cleanup | 1012 ;; cleanup |
1011 ;;0xF1 | 1013 ;;0xF1 |
1012 ;;0xE1 | 1014 ;;0xE1 |
1013 ;;0xD1 | 1015 ;;0xD1 |
1014 ;;0xC1 | 1016 ;;0xC1 |
1015 | 1017 0x00 ;; (item-hack) no-op |
1016 0xFB ;; re-enable interrupts | 1018 0xBF ;; (CP A A) ensures Z |
1017 | 1019 ;;0xFB ;; re-enable interrupts;; unnecessary |
1018 0xC3 | 1020 0xCA ;; (item-hack) jump if Z |
1019 return-low | 1021 return-low |
1020 return-high ]))) | 1022 return-high |
1023 | |
1024 0x01 ;; (item-hack) will never be reached. | |
1025 ]))) |