Mercurial > vba-clojure
changeset 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 |
files | clojure/com/aurellem/gb/items.clj clojure/com/aurellem/run/bootstrap_0.clj |
diffstat | 2 files changed, 154 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/items.clj Sat Apr 07 12:31:12 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/items.clj Sun Apr 08 03:00:51 2012 -0500 1.3 @@ -142,7 +142,7 @@ 1.4 0xEA :TM34 ;; bide 1.5 0xEB :TM35 ;; metronome 1.6 0xEC :TM36 ;; self destruct 1.7 - 0xED :TM37 ;; eggbomb 1.8 + 0xED :TM37 ;; egg bomb 1.9 0xEE :TM38 ;; fire blast 1.10 0xEF :TM39 ;; swift 1.11 0xF0 :TM40 ;; skull bash 1.12 @@ -167,9 +167,9 @@ 1.13 (zipmap (vals item-code->item-name) 1.14 (keys item-code->item-name))) 1.15 1.16 -(defn inventory [^SaveState state] 1.17 - (let [items (item-list state)] 1.18 - (map 1.19 +(defn raw-inventory->inventory 1.20 + [raw-inventory] 1.21 + (map 1.22 (fn [[item-code quantity]] 1.23 [(item-code->item-name 1.24 item-code 1.25 @@ -177,7 +177,12 @@ 1.26 quantity]) 1.27 (partition 1.28 2 1.29 - (next (take-while (partial not= 255) items)))))) 1.30 + raw-inventory))) 1.31 + 1.32 +(defn inventory [^SaveState state] 1.33 + (let [items (item-list state)] 1.34 + (raw-inventory->inventory 1.35 + (next (take-while (partial not= 255) items))))) 1.36 1.37 (defn print-inventory 1.38 ([] (print-inventory @current-state))
2.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj Sat Apr 07 12:31:12 2012 -0500 2.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 03:00:51 2012 -0500 2.3 @@ -874,4 +874,147 @@ 2.4 (d-print "============== end") 2.5 (d-ticks 20))) 2.6 2.7 - 2.8 \ No newline at end of file 2.9 +;;TMs at celadon store --- 2.10 +;;01 (any-number) mega punch 2.11 +;;02 (any-number) razor wind 2.12 +;;05 (any-number) mega kick 2.13 +;;07 (any-number) hyper beam 2.14 +;;09 (any-number) take down 2.15 +;;13 (only 1) ice beam 2.16 +;;17 (any-number) submission 2.17 +;;18 (only 1) counter 2.18 +;;32 (any-number) double team 2.19 +;;33 (any-number) reflect 2.20 +;;37 (any-number) egg bomb 2.21 +;;48 (only 1) rock slide 2.22 +;;49 (only 1) tri attack 2.23 + 2.24 + 2.25 +;; no-ops 2.26 +;; 0x00 2.27 +;; 0xB8 - 0xBF (compares) :garbage 2.28 +;; 0x3F clear carry flag :s.s.ticket 2.29 +;; 0x37 set carry flag :guard-spec [!] 2.30 +;; 0x33 increment SP :poke-doll [!] 2.31 +;; 0x3B decrement SP :coin 2.32 + 2.33 +;;0x7F A->A :garbage 2.34 +;;0x40 B->B :gold-teeth 2.35 +;;0x49 C->C :poke-flute 2.36 +;;0x52 D->D :elixer 2.37 +;;0x5B E->E :garbage 2.38 +;;0x6D L->L :garbage 2.39 +;;0x64 H->H :garbage 2.40 + 2.41 + 2.42 +;;0xC5 push BC :HM02 2.43 +;;0xD5 push DE :TM13 (ice-beam) 2.44 +;;0xE5 push HL :TM29 (psychic) 2.45 +;;0xF5 push AF :TM45 (thunder-wave) 2.46 + 2.47 +;; 0xA7 (AND A A) :garbage 2.48 +;; 0xB7 (OR A A) :garbage 2.49 + 2.50 +;; 0x2F (CPL A) :leaf-stone 2.51 + 2.52 + 2.53 +(defn item-writer 2.54 + "This is the basic writer, optimized to be made of valid 2.55 + item-quantity pairs." 2.56 + [target-address limit return-address] 2.57 + (let [[target-high target-low] (disect-bytes-2 target-address) 2.58 + [return-high return-low] (disect-bytes-2 return-address)] 2.59 + (flatten 2.60 + [ 2.61 + ;;0xC5 ;; push junk onto stack 2.62 + ;;0xD5 2.63 + ;;0xE5 2.64 + ;;0xF5 2.65 + 0x37 ;; (item-hack) set cary flag no-op 2.66 + 0x1E ;; load limit into E 2.67 + limit 2.68 + 0x3F ;; (item-hack) set carry flag no-op 2.69 + 2.70 + ;; load 1 into C. 2.71 + 0x0E ;; C == 1 means input-first nybble 2.72 + 0x01 ;; C == 0 means input-second nybble 2.73 + 2.74 + 0x21 ;; load target into HL 2.75 + target-low 2.76 + target-high 2.77 + 0x37 ;; (item-hack) set carry flag no-op 2.78 + 2.79 + 0x2F ;; (item-hack) cpl A 2.80 + 0x2F ;; (item-hack) cpl A --together a spacer no-op 2.81 + 2.82 + 0x00 ;; (item-hack) no-op 2.83 + 0xF3 ;; disable interrupts 2.84 + ;; Input Section 2.85 + 2.86 + 0x3E ;; load 0x20 into A, to measure buttons 2.87 + 0x10 2.88 + 2.89 + 0x00 ;; (item-hack) no-op 2.90 + 0xE0 ;; load A into [FF00] 2.91 + 0x00 2.92 + 2.93 + 0xF0 ;; load 0xFF00 into A to get 2.94 + 0x00 ;; button presses 2.95 + 2.96 + 0xE6 2.97 + 0x0F ;; select bottom four bits of A 2.98 + 0x37 ;; (item-hack) set carry flag no-op 2.99 + 2.100 + 0x00 ;; (item-hack) no-op 2.101 + 0xB8 ;; see if input is different (CP A B) 2.102 + 2.103 + 0x33 ;; (item-hack) (INC SP) 2.104 + 0x28 ;; repeat above steps if input is not different 2.105 + ;; (jump relative backwards if B != A) 2.106 + 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) 2.107 + 2.108 + 0x47 ;; load A into B 2.109 + 2.110 + 0x0D ;; dec C 2.111 + ;; branch based on C: 2.112 + 0x20 ;; JR NZ 2.113 + 0x07 ;; skip "input first nybble" below 2.114 + 2.115 + 2.116 + ;; input first nybble 2.117 + 2.118 + 0xCB 2.119 + 0x37 ;; swap nybbles on A 2.120 + 2.121 + 0x57 ;; A -> D 2.122 + 2.123 + 0x18 2.124 + 0xEC ;; literal -20 -- go back to input section 2.125 + 2.126 + ;; input second nybble 2.127 + 2.128 + 0x0C ;; inc C 2.129 + 2.130 + 0xE6 ;; select bottom bits 2.131 + 0x0F 2.132 + 2.133 + 0xB2 ;; (OR A D) -> A 2.134 + 2.135 + 0x22 ;; (do (A -> (HL)) (INC HL)) 2.136 + 2.137 + 0x1D ;; (DEC E) 2.138 + 2.139 + 0x20 ;; jump back to input section if not done 2.140 + 0xE4 ;; literal -28 2.141 + 2.142 + ;; cleanup 2.143 + ;;0xF1 2.144 + ;;0xE1 2.145 + ;;0xD1 2.146 + ;;0xC1 2.147 + 2.148 + 0xFB ;; re-enable interrupts 2.149 + 2.150 + 0xC3 2.151 + return-low 2.152 + return-high ])))