annotate clojure/com/aurellem/experiments/items.clj @ 127:901ee6b648da

preliminary memory bootstrapping program complete.
author Robert McIntyre <rlm@mit.edu>
date Sat, 17 Mar 2012 03:43:42 -0500
parents 3a60bb14a64a
children
rev   line source
rlm@106 1 (ns com.aurellem.experiments.items
rlm@106 2 (:use (com.aurellem gb-driver vbm title items))
rlm@106 3 (:import [com.aurellem.gb_driver SaveState]))
rlm@106 4
rlm@99 5 ;; try just buying five potions in sequence and see what changes
rlm@99 6 ;; each time.
rlm@99 7
rlm@99 8 (defn common-differences [& seqs]
rlm@99 9 (let [backbone (range (count (first seqs)))]
rlm@99 10 (filter
rlm@99 11 (comp (partial apply distinct?) second)
rlm@99 12 (zipmap backbone
rlm@99 13 (apply (partial map list) seqs)))))
rlm@99 14
rlm@99 15 ;; trying to find how items are represented in memory
rlm@99 16
rlm@106 17 (def zero-potions (read-state "zero-potions"))
rlm@106 18
rlm@106 19 (def one-potion (read-state "one-potion"))
rlm@106 20
rlm@106 21 (def two-potions (read-state "two-potions"))
rlm@106 22
rlm@106 23 (def three-potions (read-state "three-potions"))
rlm@106 24
rlm@106 25 (def four-potions (read-state "four-potions"))
rlm@106 26
rlm@106 27 (def five-potions (read-state "five-potions"))
rlm@99 28
rlm@99 29
rlm@99 30 ;; result
rlm@106 31 (defn canidates []
rlm@106 32 (apply common-differences
rlm@106 33 (map (comp vec memory)
rlm@106 34 [zero-potions one-potion two-potions three-potions
rlm@106 35 four-potions five-potions])))
rlm@99 36
rlm@106 37 (comment [55875 (37 15 49 27 14 44)]
rlm@99 38 [55876 (30 1 49 56 55 23)]
rlm@99 39 [49158 (154 191 78 135 70 73)]
rlm@99 40 [54087 (49 40 37 34 25 22)]
rlm@99 41 [49160 (7 24 59 243 50 217)]
rlm@99 42 [49704 (31 14 72 33 84 27)]
rlm@99 43 [49162 (126 159 183 110 176 179)]
rlm@99 44 [39984 (0 254 251 248 127 252)]
rlm@99 45 [49904 (29 72 64 78 1 95)]
rlm@99 46 [65491 (222 127 149 132 226 38)]
rlm@99 47 [65492 (44 20 89 11 253 163)]
rlm@99 48 [49335 (52 15 6 14 3 17)]
rlm@99 49 [49720 (78 152 96 60 83 103)]
rlm@99 50 [65304 (19 89 214 33 18 113)]
rlm@99 51 [53561 (132 185 145 162 159 183)]
rlm@99 52 [54046 (0 1 2 3 4 5)])
rlm@99 53
rlm@99 54 ;;; hmmmmmm...... I guess that the potion quantities are at 54046,
rlm@99 55 ;;;huh?
rlm@99 56
rlm@99 57
rlm@99 58
rlm@99 59 (defn get-mem []
rlm@99 60 (subvec (vec (memory @current-state)) 54040 (+ 54046 100)))
rlm@99 61
rlm@99 62
rlm@99 63 ;; potion -- 99
rlm@99 64 [0 16 0 0 1 20 99 255 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10]
rlm@99 65
rlm@99 66 ;; potion -- 95
rlm@99 67 [0 16 0 0 1 20 95 255 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10]
rlm@99 68
rlm@99 69 ;; potion -- 95
rlm@99 70 ;; pokeball -- 1
rlm@99 71 [0 16 0 0 2 20 95 4 1 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10]
rlm@99 72
rlm@99 73 ;; potion -- 95
rlm@99 74 ;; pokeball -- 10
rlm@99 75 [0 16 0 0 2 20 95 4 10 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10]
rlm@99 76
rlm@99 77
rlm@99 78 ;; pokeball -- 10
rlm@99 79 ;; potion -- 95
rlm@99 80 [0 16 0 0 2 4 10 20 95 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10]
rlm@99 81
rlm@99 82 ;; pokeball -- 10
rlm@99 83 ;; potion -- 95
rlm@99 84 ;; antidote -- 1
rlm@99 85
rlm@99 86 ;;prediction
rlm@99 87 ;;[0 16 0 0 3 4 10 20 95 ?? 1 255 0 0 0 0 0 ....]
rlm@99 88 [0 16 0 0 3 4 10 20 95 11 1 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10]
rlm@99 89
rlm@99 90
rlm@99 91
rlm@99 92 ;; now it's time to learn the item codes
rlm@99 93
rlm@106 94 (def inventory-begin
rlm@106 95 (read-state "inventory-begin"))
rlm@106 96
rlm@99 97 (defn show-item
rlm@99 98 "Run a saved pokemon with the first item replaced by the item named
rlm@99 99 by n."
rlm@99 100 [n]
rlm@106 101 (set-state! inventory-begin)
rlm@99 102 (let [mem (memory)]
rlm@106 103 (aset mem 54044 1)
rlm@99 104 (aset mem 54045 n)
rlm@106 105 (aset mem 54046 1)
rlm@106 106 (aset mem 54047 255)
rlm@99 107 (write-memory! mem))
rlm@99 108 (step)
rlm@99 109 (->> [[] @current-state]
rlm@99 110 (play-moves
rlm@99 111 [[:a] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
rlm@99 112 [] [] [] [] []])))
rlm@99 113
rlm@99 114
rlm@99 115 (defn get-item-names []
rlm@99 116 (dorun (map (fn [n] (println n)
rlm@99 117 (show-item n)
rlm@99 118 (Thread/sleep 5000))
rlm@99 119 (range 0x00 0xFF))))
rlm@99 120
rlm@99 121 ;; results (took about 10 minutes to generate)
rlm@99 122
rlm@99 123 ;; 0 garbage
rlm@99 124 ;; 1 master-ball
rlm@99 125 ;; 2 ultra-ball
rlm@99 126 ;; 3 great-ball
rlm@99 127 ;; 4 poke-ball
rlm@99 128 ;; 5 town-map
rlm@99 129 ;; 6 bicycle
rlm@99 130 ;; 7 ?????
rlm@99 131 ;; 8 safari-ball
rlm@99 132 ;; 9 pokedex
rlm@99 133 ;; 10 moon-stone
rlm@99 134 ;; 11 antidote
rlm@99 135 ;; 12 burn-heal
rlm@99 136 ;; 13 ice-heal
rlm@99 137 ;; 14 awakening
rlm@99 138 ;; 15 parlyz-heal
rlm@99 139 ;; 16 full-restore
rlm@99 140 ;; 17 max-potion
rlm@99 141 ;; 18 hyper-potion
rlm@99 142 ;; 19 super-potion
rlm@99 143 ;; 20 potion
rlm@99 144 ;; 21 boulderbadge
rlm@99 145 ;; 22 cascadebadge
rlm@99 146 ;; 23 thunderbadge
rlm@99 147 ;; 24 rainbowbadge
rlm@99 148 ;; 25 soulbadge
rlm@99 149 ;; 26 marshbadge
rlm@99 150 ;; 27 volcanobadge
rlm@99 151 ;; 28 earthbadge
rlm@99 152 ;; 29 escape-rope
rlm@99 153 ;; 30 repel
rlm@99 154 ;; 31 old amber
rlm@99 155 ;; 32 fire-stone
rlm@99 156 ;; 33 thunderstone
rlm@99 157 ;; 34 water-stone
rlm@99 158 ;; 35 hp-up
rlm@99 159 ;; 36 protein
rlm@99 160 ;; 37 iron
rlm@99 161 ;; 38 carbos
rlm@99 162 ;; 39 calcium
rlm@99 163 ;; 40 rare-candy
rlm@99 164 ;; 41 dome-fossil
rlm@99 165 ;; 42 helix-fossil
rlm@99 166 ;; 43 secret-key
rlm@99 167 ;; 44 ?????
rlm@99 168 ;; 45 bike-voucher
rlm@99 169 ;; 46 x-accuracy
rlm@99 170 ;; 47 leaf-stone
rlm@99 171 ;; 48 card-key
rlm@99 172 ;; 49 nugget
rlm@99 173 ;; 50 pp-up
rlm@99 174 ;; 51 poke-doll
rlm@99 175 ;; 52 full-heal
rlm@99 176 ;; 53 revive
rlm@99 177 ;; 54 max-revive
rlm@99 178 ;; 55 guard-spec.
rlm@99 179 ;; 56 super-repel
rlm@99 180 ;; 57 max-repel
rlm@99 181 ;; 58 dire-hit
rlm@99 182 ;; 59 coin
rlm@99 183 ;; 60 fresh-water
rlm@99 184 ;; 61 soda-pop
rlm@99 185 ;; 62 lemonade
rlm@99 186 ;; 63 s.s.ticket
rlm@99 187 ;; 64 gold-teeth
rlm@99 188 ;; 65 x-attach
rlm@99 189 ;; 66 x-defend
rlm@99 190 ;; 67 x-speed
rlm@99 191 ;; 68 x-special
rlm@99 192 ;; 69 coin-case
rlm@99 193 ;; 70 oak's-parcel
rlm@99 194 ;; 71 itemfinder
rlm@99 195 ;; 72 silph-scope
rlm@99 196 ;; 73 poke-flute
rlm@99 197 ;; 74 lift-key
rlm@99 198 ;; 75 exp.all
rlm@99 199 ;; 76 old-rod
rlm@99 200 ;; 77 good-rod
rlm@99 201 ;; 78 super-rod
rlm@99 202 ;; 79 pp-up
rlm@99 203 ;; 80 ether
rlm@99 204 ;; 81 max-ether
rlm@99 205 ;; 82 elixer
rlm@99 206 ;; 83 max-elixer
rlm@99 207 ;; 84 B2F
rlm@99 208 ;; 85 B1F
rlm@99 209 ;; 86 1F
rlm@99 210 ;; 87 2F
rlm@99 211 ;; 88 3F
rlm@99 212 ;; 89 4F
rlm@99 213 ;; 90 5F
rlm@99 214 ;; 91 6F
rlm@99 215 ;; 92 7F
rlm@99 216 ;; 93 8F
rlm@99 217 ;; 94 9F
rlm@99 218 ;; 95 10F
rlm@99 219 ;; 96 11F
rlm@99 220 ;; 97 B4F
rlm@99 221 ;; 98 garbage
rlm@99 222 ;; 99 garbage
rlm@99 223 ;; 100 garbage
rlm@99 224 ;; 101 garbage
rlm@99 225 ;; 102 garbage
rlm@99 226 ;; 103 garbage
rlm@99 227 ;; 104 garbage
rlm@99 228 ;; 105 garbage
rlm@99 229 ;; 106 garbage
rlm@99 230 ;; 107 garbage
rlm@99 231 ;; 108 garbage
rlm@99 232 ;; 109 garbage
rlm@99 233 ;; 110 garbage
rlm@99 234 ;; 111 garbage
rlm@99 235 ;; 112 garbage
rlm@99 236 ;; 113 garbage
rlm@99 237 ;; 114 garbage
rlm@99 238 ;; 115 garbage
rlm@99 239 ;; 116 garbage
rlm@99 240 ;; 117 garbage
rlm@99 241 ;; 118 garbage
rlm@99 242 ;; 119 4
rlm@99 243 ;; 120 garbage
rlm@99 244 ;; 121 garbage
rlm@99 245 ;; 122 slow
rlm@99 246 ;; 123 garbage
rlm@99 247 ;; 124 garbage
rlm@99 248 ;; 125 garbage
rlm@99 249 ;; 126 garbage
rlm@99 250 ;; 127 garbage
rlm@99 251 ;; 128 garbage
rlm@99 252 ;; 129 garbage
rlm@99 253 ;; 130 garbage
rlm@99 254 ;; 131 slow
rlm@99 255 ;; 132 slow
rlm@99 256 ;; 133 garbage
rlm@99 257 ;; 134 slow
rlm@99 258 ;; 135 garbage
rlm@99 259 ;; 136 garbage
rlm@99 260 ;; 137 slow
rlm@99 261 ;; 138 garbage
rlm@99 262 ;; 139 garbage
rlm@99 263 ;; 140 garbage
rlm@99 264 ;; 141 slow
rlm@99 265 ;; 142 garbage
rlm@99 266 ;; 143 garbage
rlm@99 267 ;; 144 garbage
rlm@99 268 ;; 145 garbage
rlm@99 269 ;; 146 garbage
rlm@99 270 ;; 147 garbage
rlm@99 271 ;; 148 garbage
rlm@99 272 ;; 149 garbage
rlm@99 273 ;; 150 slow
rlm@99 274 ;; 151 garbage
rlm@99 275 ;; 152 Q
rlm@99 276 ;; 153 garbage
rlm@99 277 ;; 154 garbage
rlm@99 278 ;; 155 garbage
rlm@99 279 ;; 156 garbage
rlm@99 280 ;; 157 garbage
rlm@99 281 ;; 158 garbage
rlm@99 282 ;; 159 garbage
rlm@99 283 ;; 160 garbage (alaphabet)
rlm@99 284 ;; 161 garbage
rlm@99 285 ;; 162 garbage
rlm@99 286 ;; 163 garbage
rlm@99 287 ;; 164 rival's
rlm@99 288 ;; 165 name?
rlm@99 289 ;; 166 nickname?
rlm@99 290 ;; 167 slow
rlm@99 291 ;; 168 garbage
rlm@99 292 ;; 169 slow
rlm@99 293 ;; 170 garbage
rlm@99 294 ;; 171 garbage
rlm@99 295 ;; 172 garbage
rlm@99 296 ;; 173 garbage
rlm@99 297 ;; 174 garbage
rlm@99 298 ;; 175 yellow
rlm@99 299 ;; 176 ash
rlm@99 300 ;; 177 jack
rlm@99 301 ;; 178 new-name
rlm@99 302 ;; 179 blue
rlm@99 303 ;; 180 gary
rlm@99 304 ;; 181 john
rlm@99 305 ;; 182 garbage
rlm@99 306 ;; 183 garbage
rlm@99 307 ;; 184 garbage
rlm@99 308 ;; 185 garbage
rlm@99 309 ;; 186 slow
rlm@99 310 ;; 187 garbage
rlm@99 311 ;; 188 garbage
rlm@99 312 ;; 189 garbage
rlm@99 313 ;; 190 garbage
rlm@99 314 ;; 191 garbage
rlm@99 315 ;; 192 garbage
rlm@99 316 ;; 193 garbage
rlm@99 317 ;; 194 garbage
rlm@99 318 ;; 195 slow
rlm@99 319 ;; 196 HM01
rlm@99 320 ;; 197 HM02
rlm@99 321 ;; 198 HM03
rlm@99 322 ;; 199 HM04
rlm@99 323 ;; 200 HM05
rlm@99 324 ;; 201 TM01
rlm@99 325 ;; 202 TM02
rlm@99 326 ;; 203 TM03
rlm@99 327 ;; 204 TM04
rlm@99 328 ;; 205 TM05
rlm@99 329 ;; 206 TM06
rlm@99 330 ;; 207 TM07
rlm@99 331 ;; 208 TM08
rlm@99 332 ;; 209 TM09
rlm@99 333 ;; 210 TM10
rlm@99 334 ;; 211 TM11
rlm@99 335 ;; 212 TM12
rlm@99 336 ;; 213 TM13
rlm@99 337 ;; 214 TM13
rlm@99 338 ;; 215 TM15
rlm@99 339 ;; 216 TM16
rlm@99 340 ;; 217 TM17
rlm@99 341 ;; 218 TM18
rlm@99 342 ;; 219 TM19
rlm@99 343 ;; 220 TM20
rlm@99 344 ;; 221 TM21
rlm@99 345 ;; 222 TM22
rlm@99 346 ;; 223 TM23
rlm@99 347 ;; 224 TM24
rlm@99 348 ;; 225 TM25
rlm@99 349 ;; 226 TM26
rlm@99 350 ;; 227 TM27
rlm@99 351 ;; 228 TM28
rlm@99 352 ;; 229 TM29
rlm@99 353 ;; 230 TM30
rlm@99 354 ;; 231 TM31
rlm@99 355 ;; 232 TM32
rlm@99 356 ;; 233 TM33
rlm@99 357 ;; 234 TM34
rlm@99 358 ;; 235 TM35
rlm@99 359 ;; 236 TM36
rlm@99 360 ;; 237 TM37
rlm@99 361 ;; 238 TM38
rlm@99 362 ;; 239 TM39
rlm@99 363 ;; 240 TM40
rlm@99 364 ;; 241 TM41
rlm@99 365 ;; 242 TM42
rlm@99 366 ;; 243 TM43
rlm@99 367 ;; 244 TM44
rlm@99 368 ;; 245 TM45
rlm@99 369 ;; 246 TM46
rlm@99 370 ;; 247 TM47
rlm@99 371 ;; 248 TM48
rlm@99 372 ;; 249 TM49
rlm@99 373 ;; 250 TM50
rlm@99 374 ;; 251 TM51
rlm@99 375 ;; 252 TM52
rlm@99 376 ;; 253 TM53
rlm@99 377 ;; 254 TM54
rlm@99 378 ;; 255 end-of-list-sentinel
rlm@106 379
rlm@106 380
rlm@106 381
rlm@106 382 (defn run-item-program
rlm@106 383 "This is my first assembly/item program!
rlm@106 384 it just increments BC by one.
rlm@106 385
rlm@106 386 The code places a 3 'great balls' at the beginning of the
rlm@106 387 inventory, then directly sets the program counter to start
rlm@106 388 executing at the position of the 'great balls' in memory.
rlm@106 389
rlm@106 390 Since a 'great ball' is represented in memory as 0x03, which
rlm@106 391 corresponts to the opcode which increments BC by one, that is
rlm@106 392 what happens. Then the program counter to the 0x03 quantity entry
rlm@106 393 and BC is incremented again.
rlm@106 394
rlm@106 395 Obviously, the game crashes more or less immediately after the
rlm@106 396 program counter advances past the 'great balls' into the next items
rlm@106 397 in the inventory, thus I call shutdown! before anything bad happens."
rlm@106 398 []
rlm@106 399 (set-inventory (read-state "mid-game") [[:great-ball 3]])
rlm@106 400 (print-inventory)
rlm@106 401 (println "3 ticks") (tick) (tick) (tick)
rlm@106 402 (println "PC before:" (PC))
rlm@106 403 (println "BC before:" (BC))
rlm@106 404 (PC! (inc item-list-start))
rlm@106 405 (println "PC after setting:" (PC))
rlm@106 406 (println "data at PC:" (aget (memory) (PC)))
rlm@106 407 (println "one tick")
rlm@106 408 (tick)
rlm@106 409 (println "PC after one tick:" (PC))
rlm@106 410 (println "BC after one tick:" (BC))
rlm@106 411 (tick)
rlm@106 412 (println "PC after two ticks:" (PC))
rlm@106 413 (println "BC after two ticks:" (BC))
rlm@106 414
rlm@106 415 (shutdown!))
rlm@106 416
rlm@106 417
rlm@106 418
rlm@106 419
rlm@106 420 (defn test-opcodes-1
rlm@106 421 []
rlm@106 422 (let [final-state
rlm@106 423 (->
rlm@106 424 (read-state "mid-game")
rlm@106 425 (set-inv-mem
rlm@106 426 [20 0x02 0x00 0x00 0x02 0x00 0x00
rlm@106 427 0x00 0x0 0xFF])
rlm@106 428 (print-inventory)
rlm@106 429 ;;((fn [_] (println "3 ticks") _))
rlm@106 430 (tick) (tick) (tick)
rlm@106 431
rlm@106 432 ;;(println "PC before:" (PC))
rlm@106 433 ;;(println "BC before:" (BC))
rlm@106 434 ;;(println "AF:" (AF))
rlm@106 435 (PC! (inc item-list-start))
rlm@106 436 (BC! (+ 1 item-list-start))
rlm@106 437 ;;(println "PC after setting:" (PC))
rlm@106 438 ;;(println "data at PC:" (aget (memory) (PC)))
rlm@106 439 ;;(println "data at " (BC) "(BC):" (aget (memory) (BC)))
rlm@106 440
rlm@106 441 ;;(println "one tick")
rlm@106 442 (tick)
rlm@106 443 ;;(println "PC after one tick:" (PC))
rlm@106 444 ;;(println "BC after one tick:" (BC))
rlm@106 445 ;;(println "data at PC:" (aget (memory) (PC)))
rlm@106 446 ;;(println "data at " (BC) "(BC):" (aget (memory) (BC)))
rlm@106 447 (tick)
rlm@106 448 (AF! 0xFFFF)
rlm@106 449 ;;(println "PC after two ticks:" (PC))
rlm@106 450 ;;(println "BC after two ticks:" (BC))
rlm@106 451 ;;(println "data at PC:" (aget (memory) (PC)))
rlm@106 452 ;;(println "data at " (BC) "(BC):" (aget (memory) (BC)))
rlm@106 453 (tick)
rlm@106 454 ;;(println "PC after three ticks:" (PC))
rlm@106 455 ;;(println "BC after three ticks:" (BC))
rlm@106 456 ;;(println "data at PC:" (aget (memory) (PC)))
rlm@106 457 ;;(println "data at " (BC) "(BC):" (aget (memory) (BC)))
rlm@106 458 (tick)
rlm@106 459 ;;(println "PC after four ticks:" (PC))
rlm@106 460 ;;(println "BC after four ticks:" (BC))
rlm@106 461 ;;(println "data at PC:" (aget (memory) (PC)))
rlm@106 462 ;;(println "data at " (BC) "(BC):" (aget (memory) (BC)))
rlm@106 463 (tick)
rlm@106 464 ;;(println "PC after five ticks:" (PC))
rlm@106 465 ;;(println "BC after five ticks:" (BC))
rlm@106 466 ;;(println "data at PC:" (aget (memory) (PC)))
rlm@106 467 ;;(println "data at " (BC) "(BC):" (aget (memory) (BC)))
rlm@106 468 (print-inventory)
rlm@106 469 )]
rlm@106 470
rlm@106 471 (shutdown!)
rlm@106 472 final-state))
rlm@106 473
rlm@106 474
rlm@106 475
rlm@106 476 (defn test-opcodes-2
rlm@106 477 []
rlm@106 478 (set-inv-mem (read-state "mid-game")
rlm@106 479 [20 0x08 0x1D 0xD3 0x00 0x00 0x00
rlm@106 480 0x00 0x0 0xFF])
rlm@106 481 (print-inventory)
rlm@106 482 (println "3 ticks") (tick) (tick) (tick)
rlm@106 483 (println "PC before:" (PC))
rlm@106 484 (println "SP:" (SP))
rlm@106 485 (PC! (inc item-list-start))
rlm@106 486 (println "PC after setting:" (PC))
rlm@106 487 (println "SP:" (Integer/toBinaryString (SP)))
rlm@106 488 (println "data at PC:" (aget (memory) (PC)))
rlm@106 489 (println "data at 0xD31D:" (Integer/toBinaryString (aget (memory) 0xD31D)))
rlm@106 490 (println "data at 0xD31E:" (Integer/toBinaryString (aget (memory) 0xD31E)))
rlm@106 491 (println "one tick")
rlm@106 492 (tick)
rlm@106 493 (println "PC after one tick:" (PC))
rlm@106 494 (println "data at PC:" (aget (memory) (PC)))
rlm@106 495 (println "data at 0xD31D:" (Integer/toBinaryString (aget (memory) 0xD31D)))
rlm@106 496 (println "data at 0xD31E:" (Integer/toBinaryString (aget (memory) 0xD31E)))
rlm@106 497 (tick) (tick) (tick)
rlm@106 498 (println "PC aftter four tick:" (PC))
rlm@106 499 (println "data at PC:" (aget (memory) (PC)))
rlm@106 500 (println "data at 0xD31D:" (aget (memory) 0xD31D))
rlm@106 501
rlm@106 502 (print-inventory)
rlm@106 503 (shutdown!))