Mercurial > vba-clojure
comparison org/rom.org @ 471:5f87c3e46c22
Added interactive Pokemon cries.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Sun, 29 Apr 2012 20:35:58 -0500 |
parents | c02108ddcb35 |
children | 69d1787522c7 |
comparison
equal
deleted
inserted
replaced
470:c02108ddcb35 | 471:5f87c3e46c22 |
---|---|
4 #+description: A detailed explication of Pok\eacute{}mon Yellow, helped by Clojure. | 4 #+description: A detailed explication of Pok\eacute{}mon Yellow, helped by Clojure. |
5 #+keywords: pokemon, pokemon yellow, rom, gameboy, assembly, hex, pointers, clojure | 5 #+keywords: pokemon, pokemon yellow, rom, gameboy, assembly, hex, pointers, clojure |
6 #+SETUPFILE: ../../aurellem/org/setup.org | 6 #+SETUPFILE: ../../aurellem/org/setup.org |
7 #+INCLUDE: ../../aurellem/org/level-0.org | 7 #+INCLUDE: ../../aurellem/org/level-0.org |
8 #+BABEL: :exports both :noweb yes :cache no :mkdirp yes | 8 #+BABEL: :exports both :noweb yes :cache no :mkdirp yes |
9 #+OPTIONS: num:2 | |
10 | |
9 | 11 |
10 # about map headers http://datacrystal.romhacking.net/wiki/Pokemon_Red/Blue:Notes | 12 # about map headers http://datacrystal.romhacking.net/wiki/Pokemon_Red/Blue:Notes |
11 # map headers Yellow http://www.pokecommunity.com/archive/index.php/t-235311.html | 13 # map headers Yellow http://www.pokecommunity.com/archive/index.php/t-235311.html |
12 # pokedollar: U+20B1 | 14 # pokedollar: U+20B1 |
13 * Introduction | 15 * Introduction |
24 | 26 |
25 To orient yourself, you can look for a specific topic in the table of contents | 27 To orient yourself, you can look for a specific topic in the table of contents |
26 above, or browse the [[#sec-9-1][map of the ROM]], below. | 28 above, or browse the [[#sec-9-1][map of the ROM]], below. |
27 | 29 |
28 | 30 |
29 (If you have any questions or comments, please e-mail =rlm@mit.edu=) | 31 If you have any questions or comments, please e-mail =rlm@mit.edu=. |
30 | 32 |
31 | 33 |
32 ** COMMENT Getting linguistic data: names, words, etc. | 34 ** COMMENT Getting linguistic data: names, words, etc. |
33 | 35 |
34 Some of the simplest data | 36 Some of the simplest data |
525 (hxc-pokedex-text-raw rom))))) | 527 (hxc-pokedex-text-raw rom))))) |
526 #+end_src | 528 #+end_src |
527 | 529 |
528 | 530 |
529 ** Pok\eacute{}mon cries | 531 ** Pok\eacute{}mon cries |
532 *** See the data | |
533 | |
534 Here, you can see that each Pok\eacute{}mon's cry data consists of | |
535 three bytes: the =cry-id=, which is the basic sound byte to use, the | |
536 =pitch=, which determines how high or low to make the sound byte, and | |
537 the =length=, which is the amount of the sound byte to play. | |
538 | |
539 Even though there are only a few different basic sound bytes (cry | |
540 ids) to build from, by varying the pitch and length, | |
541 you can create a wide variety of different Pok\eacute{}mon cries. | |
542 | |
543 #+begin_src clojure :exports both :cache no :results output | |
544 (ns com.aurellem.gb.hxc | |
545 (:use (com.aurellem.gb assembly characters gb-driver util mem-util | |
546 constants)) | |
547 (:import [com.aurellem.gb.gb_driver SaveState])) | |
548 | |
549 (->> | |
550 (rom) | |
551 (drop 0x39462) | |
552 (take 12) | |
553 (println)) | |
554 | |
555 (->> | |
556 (rom) | |
557 (drop 0x39462) | |
558 (take 12) | |
559 (partition 3) | |
560 (map vec) | |
561 (println)) | |
562 | |
563 (->> | |
564 (rom) | |
565 (drop 0x39462) | |
566 (take 12) | |
567 (partition 3) | |
568 (map | |
569 (fn [[id pitch length]] | |
570 {:cry-id id :pitch pitch :length length})) | |
571 (println)) | |
572 | |
573 #+end_src | |
574 | |
575 #+results: | |
576 : (17 0 128 3 0 128 0 0 128 25 204 1) | |
577 : ([17 0 128] [3 0 128] [0 0 128] [25 204 1]) | |
578 : ({:cry-id 17, :pitch 0, :length 128} {:cry-id 3, :pitch 0, :length 128} {:cry-id 0, :pitch 0, :length 128} {:cry-id 25, :pitch 204, :length 1}) | |
579 | |
580 | |
581 It is interesting to note which Pok\eacute{}mon use the same basic | |
582 =cry-id= --- I call these /cry groups/. Here, you can see which | |
583 Pok\eacute{}mon belong to the same cry group. | |
584 | |
585 #+begin_src clojure :exports both :cache no :results output | |
586 (ns com.aurellem.gb.hxc | |
587 (:use (com.aurellem.gb assembly characters gb-driver util mem-util | |
588 constants)) | |
589 (:import [com.aurellem.gb.gb_driver SaveState])) | |
590 | |
591 (println "POKEMON CRY GROUPS") | |
592 (doall | |
593 (map println | |
594 (let [cry-id | |
595 (->> | |
596 (rom) | |
597 (drop 0x39462) ;; get the cry data | |
598 (partition 3) ;; partition it into groups of three | |
599 (map first) ;; keep only the first item, the cry-id | |
600 (zipmap (hxc-pokenames)) ;; associate each pokemon with its cry-id | |
601 )] | |
602 | |
603 (->> (hxc-pokenames) ;; start with the list of pokemon | |
604 (remove (partial = :missingno.)) ;; remove missingnos | |
605 (sort-by cry-id) | |
606 (partition-by cry-id) | |
607 (map vec))))) | |
608 | |
609 #+end_src | |
610 | |
611 #+results: | |
612 #+begin_example | |
613 POKEMON CRY GROUPS | |
614 [:nidoran♂ :sandshrew :sandslash :nidorino] | |
615 [:nidoran♀ :nidorina] | |
616 [:slowpoke] | |
617 [:kangaskhan] | |
618 [:rhyhorn :magmar :charmander :charmeleon :charizard] | |
619 [:grimer :snorlax] | |
620 [:voltorb :electabuzz :electrode] | |
621 [:gengar :muk] | |
622 [:marowak :oddish :gloom] | |
623 [:nidoking :moltres :articuno :raichu] | |
624 [:nidoqueen :mankey :primeape] | |
625 [:exeggcute :diglett :doduo :dodrio :dugtrio] | |
626 [:lickitung :hitmonchan :seel :dewgong] | |
627 [:exeggutor :drowzee :jynx :hypno] | |
628 [:pidgey :poliwag :ditto :jigglypuff :wigglytuff :poliwhirl :poliwrath] | |
629 [:ivysaur :dragonite :pikachu :dratini :dragonair :bulbasaur :venusaur] | |
630 [:spearow :farfetch'd] | |
631 [:rhydon] | |
632 [:tangela :hitmonlee :golem :koffing :weezing] | |
633 [:blastoise :kakuna :beedrill] | |
634 [:pinsir :chansey :pidgeotto :pidgeot] | |
635 [:arcanine :weedle] | |
636 [:scyther :kabuto :caterpie :butterfree :goldeen :seaking] | |
637 [:gyarados :onix :arbok :ekans :magikarp] | |
638 [:shellder :fearow :zapdos :kabutops :cloyster] | |
639 [:clefairy :cubone :meowth :horsea :seadra :clefable :persian] | |
640 [:tentacool :venonat :eevee :flareon :jolteon :vaporeon :venomoth :tentacruel] | |
641 [:lapras] | |
642 [:gastly :kadabra :magneton :metapod :haunter :abra :alakazam :magnemite] | |
643 [:tauros :zubat :golbat :squirtle :wartortle] | |
644 [:mew :staryu :parasect :paras :mewtwo :starmie] | |
645 [:slowbro :growlithe :machoke :omanyte :omastar :machop :machamp] | |
646 [:mr.mime :krabby :kingler] | |
647 [:psyduck :golduck :bellsprout] | |
648 [:rattata :raticate] | |
649 [:aerodactyl :vileplume] | |
650 [:graveler :vulpix :ninetales :geodude] | |
651 [:ponyta :rapidash :porygon :weepinbell :victreebel] | |
652 #+end_example | |
653 | |
654 | |
655 | |
656 | |
657 | |
658 | |
659 *** Automatically grab the data | |
530 #+name: pokecry | 660 #+name: pokecry |
531 #+begin_src clojure | 661 #+begin_src clojure |
532 (defn hxc-cry | 662 (defn hxc-cry |
533 "The pokemon cry data in internal order. List begins at ROM@39462" | 663 "The pokemon cry data in internal order. List begins at ROM@39462" |
534 ([](hxc-cry com.aurellem.gb.gb-driver/original-rom)) | 664 ([](hxc-cry com.aurellem.gb.gb-driver/original-rom)) |