Mercurial > vba-clojure
diff clojure/com/aurellem/run/bootstrap_0.clj @ 339:93e74ed34305
rewriting basic-writer assemly so that it is valid items
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 08 Apr 2012 03:00:51 -0500 |
parents | 92f0011925d2 |
children | dea7e476eba7 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj Sat Apr 07 12:31:12 2012 -0500 1.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 03:00:51 2012 -0500 1.3 @@ -874,4 +874,147 @@ 1.4 (d-print "============== end") 1.5 (d-ticks 20))) 1.6 1.7 - 1.8 \ No newline at end of file 1.9 +;;TMs at celadon store --- 1.10 +;;01 (any-number) mega punch 1.11 +;;02 (any-number) razor wind 1.12 +;;05 (any-number) mega kick 1.13 +;;07 (any-number) hyper beam 1.14 +;;09 (any-number) take down 1.15 +;;13 (only 1) ice beam 1.16 +;;17 (any-number) submission 1.17 +;;18 (only 1) counter 1.18 +;;32 (any-number) double team 1.19 +;;33 (any-number) reflect 1.20 +;;37 (any-number) egg bomb 1.21 +;;48 (only 1) rock slide 1.22 +;;49 (only 1) tri attack 1.23 + 1.24 + 1.25 +;; no-ops 1.26 +;; 0x00 1.27 +;; 0xB8 - 0xBF (compares) :garbage 1.28 +;; 0x3F clear carry flag :s.s.ticket 1.29 +;; 0x37 set carry flag :guard-spec [!] 1.30 +;; 0x33 increment SP :poke-doll [!] 1.31 +;; 0x3B decrement SP :coin 1.32 + 1.33 +;;0x7F A->A :garbage 1.34 +;;0x40 B->B :gold-teeth 1.35 +;;0x49 C->C :poke-flute 1.36 +;;0x52 D->D :elixer 1.37 +;;0x5B E->E :garbage 1.38 +;;0x6D L->L :garbage 1.39 +;;0x64 H->H :garbage 1.40 + 1.41 + 1.42 +;;0xC5 push BC :HM02 1.43 +;;0xD5 push DE :TM13 (ice-beam) 1.44 +;;0xE5 push HL :TM29 (psychic) 1.45 +;;0xF5 push AF :TM45 (thunder-wave) 1.46 + 1.47 +;; 0xA7 (AND A A) :garbage 1.48 +;; 0xB7 (OR A A) :garbage 1.49 + 1.50 +;; 0x2F (CPL A) :leaf-stone 1.51 + 1.52 + 1.53 +(defn item-writer 1.54 + "This is the basic writer, optimized to be made of valid 1.55 + item-quantity pairs." 1.56 + [target-address limit return-address] 1.57 + (let [[target-high target-low] (disect-bytes-2 target-address) 1.58 + [return-high return-low] (disect-bytes-2 return-address)] 1.59 + (flatten 1.60 + [ 1.61 + ;;0xC5 ;; push junk onto stack 1.62 + ;;0xD5 1.63 + ;;0xE5 1.64 + ;;0xF5 1.65 + 0x37 ;; (item-hack) set cary flag no-op 1.66 + 0x1E ;; load limit into E 1.67 + limit 1.68 + 0x3F ;; (item-hack) set carry flag no-op 1.69 + 1.70 + ;; load 1 into C. 1.71 + 0x0E ;; C == 1 means input-first nybble 1.72 + 0x01 ;; C == 0 means input-second nybble 1.73 + 1.74 + 0x21 ;; load target into HL 1.75 + target-low 1.76 + target-high 1.77 + 0x37 ;; (item-hack) set carry flag no-op 1.78 + 1.79 + 0x2F ;; (item-hack) cpl A 1.80 + 0x2F ;; (item-hack) cpl A --together a spacer no-op 1.81 + 1.82 + 0x00 ;; (item-hack) no-op 1.83 + 0xF3 ;; disable interrupts 1.84 + ;; Input Section 1.85 + 1.86 + 0x3E ;; load 0x20 into A, to measure buttons 1.87 + 0x10 1.88 + 1.89 + 0x00 ;; (item-hack) no-op 1.90 + 0xE0 ;; load A into [FF00] 1.91 + 0x00 1.92 + 1.93 + 0xF0 ;; load 0xFF00 into A to get 1.94 + 0x00 ;; button presses 1.95 + 1.96 + 0xE6 1.97 + 0x0F ;; select bottom four bits of A 1.98 + 0x37 ;; (item-hack) set carry flag no-op 1.99 + 1.100 + 0x00 ;; (item-hack) no-op 1.101 + 0xB8 ;; see if input is different (CP A B) 1.102 + 1.103 + 0x33 ;; (item-hack) (INC SP) 1.104 + 0x28 ;; repeat above steps if input is not different 1.105 + ;; (jump relative backwards if B != A) 1.106 + 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) 1.107 + 1.108 + 0x47 ;; load A into B 1.109 + 1.110 + 0x0D ;; dec C 1.111 + ;; branch based on C: 1.112 + 0x20 ;; JR NZ 1.113 + 0x07 ;; skip "input first nybble" below 1.114 + 1.115 + 1.116 + ;; input first nybble 1.117 + 1.118 + 0xCB 1.119 + 0x37 ;; swap nybbles on A 1.120 + 1.121 + 0x57 ;; A -> D 1.122 + 1.123 + 0x18 1.124 + 0xEC ;; literal -20 -- go back to input section 1.125 + 1.126 + ;; input second nybble 1.127 + 1.128 + 0x0C ;; inc C 1.129 + 1.130 + 0xE6 ;; select bottom bits 1.131 + 0x0F 1.132 + 1.133 + 0xB2 ;; (OR A D) -> A 1.134 + 1.135 + 0x22 ;; (do (A -> (HL)) (INC HL)) 1.136 + 1.137 + 0x1D ;; (DEC E) 1.138 + 1.139 + 0x20 ;; jump back to input section if not done 1.140 + 0xE4 ;; literal -28 1.141 + 1.142 + ;; cleanup 1.143 + ;;0xF1 1.144 + ;;0xE1 1.145 + ;;0xD1 1.146 + ;;0xC1 1.147 + 1.148 + 0xFB ;; re-enable interrupts 1.149 + 1.150 + 0xC3 1.151 + return-low 1.152 + return-high ])))