Mercurial > vba-clojure
comparison clojure/com/aurellem/exp/moves.clj @ 161:cd7979aa544e
emabled setting pokemon moves and PP
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 20 Mar 2012 17:13:12 -0500 |
parents | d92f7d68445a |
children | 34b518fc7404 |
comparison
equal
deleted
inserted
replaced
160:9ca350a476f0 | 161:cd7979aa544e |
---|---|
1 (ns com.aurellem.exp.moves | 1 (ns com.aurellem.exp.moves |
2 (:use (com.aurellem.gb gb-driver items util)) | 2 (:use (com.aurellem.gb gb-driver items util pokemon)) |
3 (:import [com.aurellem.gb.gb_driver SaveState])) | 3 (:import [com.aurellem.gb.gb_driver SaveState])) |
4 | 4 |
5 (defn move-state [] | 5 (defn move-state [] |
6 (read-state "view-pika-attacks")) | 6 (read-state "view-pika-attacks")) |
7 | 7 |
11 (concat [[:a]] | 11 (concat [[:a]] |
12 (repeat 200 []) | 12 (repeat 200 []) |
13 [[:a]] | 13 [[:a]] |
14 (repeat 200 [])))) | 14 (repeat 200 [])))) |
15 | 15 |
16 (defn give-move [pos n] | |
17 (continue! | |
18 (set-memory @current-state | |
19 (+ pos (- 0xD19E 44)) n))) | |
20 | |
21 (defn iterate-moves [] | 16 (defn iterate-moves [] |
22 (dorun | 17 (dorun |
23 (map (fn [n] (println n) | 18 (map (fn [n] (println n) |
24 (view-move n) | 19 (view-move n) |
25 (Thread/sleep 5000)) | 20 (Thread/sleep 5000)) |
26 (range (inc 0xFF))))) | 21 (range (inc 0xFF))))) |
27 | 22 |
23 (def moves-codes-pokemon-1 0xD172) | |
24 | |
25 (defn moves-codes-start [pokemon-num] | |
26 (assert (<= 0 pokemon-num 5)) | |
27 (+ moves-codes-pokemon-1 | |
28 (* pokemon-num pokemon-record-width))) | |
29 | |
28 | 30 |
29 ;; 000 00 : null | 31 ;; 000 00 : null |
30 ;; 001 01 : pound | 32 ;; 001 01 : pound |
31 ;; 002 02 : karate-chop | 33 ;; 002 02 : karate-chop |
32 ;; 003 03 : doubleslap | 34 ;; 003 03 : doubleslap |
282 ;; 253 FD : TM53 | 284 ;; 253 FD : TM53 |
283 ;; 254 FE : TM54 | 285 ;; 254 FE : TM54 |
284 ;; 255 FF : TM55 | 286 ;; 255 FF : TM55 |
285 | 287 |
286 | 288 |
287 | 289 (def move-code->move-name |
290 { | |
291 0x01 :pound | |
292 0x02 :karate-chop | |
293 0x03 :doubleslap | |
294 0x04 :comet-punch | |
295 0x05 :mega-punch | |
296 0x06 :pay-day | |
297 0x07 :fire-punch | |
298 0x08 :ice-punch | |
299 0x09 :thunderpunch | |
300 0x0A :scratch | |
301 0x0B :vicegrip | |
302 0x0C :guillotine | |
303 0x0D :razor-wind | |
304 0x0E :swords-dance | |
305 0x0F :cut | |
306 0x10 :gust | |
307 0x11 :wing-attack | |
308 0x12 :whirlwind | |
309 0x13 :fly | |
310 0x14 :bind | |
311 0x15 :slam | |
312 0x16 :vine-whip | |
313 0x17 :stomp | |
314 0x18 :double-kick | |
315 0x19 :mega-kick | |
316 0x1A :jump-kick | |
317 0x1B :rolling-kick | |
318 0x1C :sand-attack | |
319 0x1D :headbutt | |
320 0x1E :horn-attack | |
321 0x1F :fury-attack | |
322 0x20 :horn-drill | |
323 0x21 :tackle | |
324 0x22 :body-slam | |
325 0x23 :wrap | |
326 0x24 :take-down | |
327 0x25 :thrash | |
328 0x26 :double-edge | |
329 0x27 :tail-whip | |
330 0x28 :poison-sting | |
331 0x29 :twinneedle | |
332 0x2A :pin-missle | |
333 0x2B :leer | |
334 0x2C :bite | |
335 0x2D :growl | |
336 0x2E :roar | |
337 0x2F :sing | |
338 0x30 :supersonic | |
339 0x31 :sonicboom | |
340 0x32 :disable | |
341 0x33 :acid | |
342 0x34 :ember | |
343 0x35 :flamethrower | |
344 0x36 :mist | |
345 0x37 :water-gun | |
346 0x38 :hydro-pump | |
347 0x39 :surf | |
348 0x3A :ice-beam | |
349 0x3B :blizzard | |
350 0x3C :psybeam | |
351 0x3D :bubblebeam | |
352 0x3E :aurora-beam | |
353 0x3F :hyper-beam | |
354 0x40 :peck | |
355 0x41 :drill-peck | |
356 0x42 :submission | |
357 0x43 :low-kick | |
358 0x44 :counter | |
359 0x45 :seismic-toss | |
360 0x46 :strength | |
361 0x47 :absorb | |
362 0x48 :mega-drain | |
363 0x49 :leech-seed | |
364 0x4A :growth | |
365 0x4B :razor-leaf | |
366 0x4C :solarbeam | |
367 0x4D :poisonpowder | |
368 0x4E :stun-spore | |
369 0x4F :sleep-powder | |
370 0x50 :petal-dance | |
371 0x51 :string-shot | |
372 0x52 :dragon-rage | |
373 0x53 :fire-spin | |
374 0x54 :thundershock | |
375 0x55 :thunderbolt | |
376 0x56 :thunder-wave | |
377 0x57 :thunder | |
378 0x58 :rock-throw | |
379 0x59 :earthquake | |
380 0x5A :fissure | |
381 0x5B :dig | |
382 0x5C :toxic | |
383 0x5D :confusion | |
384 0x5E :psychic | |
385 0x5F :hypnosis | |
386 0x60 :meditate | |
387 0x61 :agility | |
388 0x62 :quick-attack | |
389 0x63 :rage | |
390 0x64 :teleport | |
391 0x65 :night-shade | |
392 0x66 :mimic | |
393 0x67 :screech | |
394 0x68 :double-team | |
395 0x69 :recover | |
396 0x6A :harden | |
397 0x6B :minimize | |
398 0x6C :smokescreen | |
399 0x6D :confuse-ray | |
400 0x6E :withdraw | |
401 0x6F :defense-curl | |
402 0x70 :barrier | |
403 0x71 :light-screen | |
404 0x72 :haze | |
405 0x73 :reflect | |
406 0x74 :focus-energy | |
407 0x75 :bide | |
408 0x76 :metronome | |
409 0x77 :mirror-move | |
410 0x78 :selfdestruct | |
411 0x79 :egg-bomb | |
412 0x7A :lick | |
413 0x7B :smog | |
414 0x7C :sludge | |
415 0x7D :bone-club | |
416 0x7E :fire-blast | |
417 0x7F :waterfall | |
418 0x80 :clamp | |
419 0x81 :swift | |
420 0x82 :skull-bash | |
421 0x83 :spike-cannon | |
422 0x84 :constrict | |
423 0x85 :amnesia | |
424 0x86 :kinesis | |
425 0x87 :softboiled | |
426 0x88 :hi-jump-kick | |
427 0x89 :glare | |
428 0x8A :dream-eater | |
429 0x8B :poison-gas | |
430 0x8C :barrage | |
431 0x8D :leech-life | |
432 0x8E :lovely-kiss | |
433 0x8F :sky-attack | |
434 0x90 :transform | |
435 0x91 :bubble | |
436 0x92 :dizzy-punch | |
437 0x93 :spore | |
438 0x94 :flash | |
439 0x95 :psywave | |
440 0x96 :splash | |
441 0x97 :acid-armor | |
442 0x98 :crabhammer | |
443 0x99 :explosion | |
444 0x9A :fury-swipes | |
445 0x9B :bonemerang | |
446 0x9C :rest | |
447 0x9D :rock-slide | |
448 0x9E :hyper-fang | |
449 0x9F :sharpen | |
450 0xA0 :conversion | |
451 0xA1 :tri-attack | |
452 0xA2 :super-fang | |
453 0xA3 :slash | |
454 0xA4 :substitute | |
455 0xA5 :struggle}) | |
456 | |
457 (def move-name->move-code | |
458 (zipmap (vals move-code->move-name) | |
459 (keys move-code->move-name))) | |
460 | |
461 (defn give-moves | |
462 ([^SaveState state pokemon-num moves] | |
463 (set-memory-range | |
464 state | |
465 (moves-codes-start pokemon-num) | |
466 (map #(move-name->move-code % %) moves))) | |
467 ([pokemon-num moves] | |
468 (give-moves @current-state pokemon-num moves)) | |
469 ([moves] | |
470 (give-moves 0 moves))) | |
288 | 471 |
289 ;; Note regarding PP of moves -- both the current PP and the | 472 ;; Note regarding PP of moves -- both the current PP and the |
290 ;; total PP are stored in the same value somehow! | 473 ;; total PP are stored in the same value. |
474 ;; they are bit-packed, with the first 2 bits containing the | |
475 ;; number of pp-ups that have been applied, and the next | |
476 ;; six bits containing the current pp of the move. | |
477 ;; thus, a move can have up to 63 current pp and up to | |
478 ;; three pp-ups applied. | |
479 | |
480 | |
481 (def pokemon-1-pp-start 0xD187) | |
482 | |
483 (defn moves-pp-start [pokemon-num] | |
484 (assert (<= 0 pokemon-num 5)) | |
485 (+ pokemon-1-pp-start (* pokemon-num pokemon-record-width))) | |
486 | |
487 (defn read-pp | |
488 ([^SaveState state pokemon-num move-num] | |
489 (assert (<= 0 move-num 3)) | |
490 (assert (<= 0 pokemon-num 5)) | |
491 (let [pp-raw | |
492 (aget (memory state) | |
493 (+ (moves-pp-start pokemon-num) | |
494 move-num)) | |
495 pp-up | |
496 (bit-shift-right | |
497 (bit-and | |
498 pp-raw | |
499 (Integer/parseInt "11000000" 2)) 6) | |
500 current-pp | |
501 (bit-and | |
502 pp-raw | |
503 (Integer/parseInt "00111111" 2))] | |
504 [pp-up current-pp])) | |
505 ([pokemon-num move-num] | |
506 (read-pp @current-state pokemon-num move-num))) | |
507 | |
508 (defn give-pp | |
509 ([^SaveState state pokemon-num move-num pp-ups current-pp] | |
510 (assert (<= 0 move-num 3)) | |
511 (assert (<= 0 pokemon-num 5)) | |
512 (assert (<= 0 pp-ups 3)) | |
513 (assert (<= 0 current-pp 63)) | |
514 | |
515 (set-memory | |
516 state | |
517 (+ (moves-pp-start pokemon-num) | |
518 move-num) | |
519 (+ | |
520 (bit-shift-left pp-ups 6) | |
521 (bit-and (Integer/parseInt | |
522 "00111111" 2) | |
523 current-pp)))) | |
524 ([pokemon-num move-num pp-ups current-pp] | |
525 (set-pp @current-state | |
526 pokemon-num move-num pp-ups current-pp))) | |
527 | |
528 | |
529 | |
530 |