ref: 4d0797bc3a6ae0ea4b44e8b6463339d662f5d669
parent: 21caa525cc9bd5b8431c117102cebc788cca5574
author: KuroiIeWa5Da <tyuki@adu.me>
date: Sun Jan 22 20:41:05 EST 2012
made changes in repo hg-commit-id: 1145e088ee27
--- a/.hgignore
+++ b/.hgignore
@@ -24,3 +24,5 @@
#for vim configuration
#url: http://www.vim.org/scripts/script.php?script_id=441
.lvimrc
+
+*.exe
\ No newline at end of file
--- /dev/null
+++ b/music.asm
@@ -1,0 +1,299 @@
+; Music Data
+; The start and stop of these byte ranges were based off the theory they're lined
+; consecutively (Right up against each other).
+
+INCBIN "baserom.gbc",$82FD,$9ba3 - $82FD
+
+;Pokemon Healed Music
+PkmnHealed_md_1: ;9BA3 - 9BC3
+
+;Setup
+ mus_tempo 0, 144
+ mus_volume 119
+ mus_duty duty50
+ db $E8 ;??
+ mus_vel 8, 1
+
+;Music
+ ;Piece 1
+ mus_note noteRst, note8
+ db $EB, $00
+ mus_note noteE, note2_4
+ mus_note noteB, note8
+ db $EB, $00
+ mus_note noteF, note4_16
+ mus_note noteB, note8
+ db $EB, $00
+ mus_note noteE, note4_16
+ mus_note noteE, note8
+ mus_note noteRst, note4
+ db $EB, $00
+ mus_note noteD#, note2_4
+ mus_note noteE, note4
+ db $EB, $00
+ mus_note noteE, note2_4
+ mus_note noteB, note4
+
+ mus_end ;End
+
+PkmnHealed_md_2: ;9BC4 - 9BD1
+;Setup
+ mus_duty duty50
+
+;Music
+ ;Octave Switch
+ db dNormSpd
+ mus_note noteRst, note4
+ db oct3
+
+ ;Piece 1
+ mus_note noteB, note4
+ mus_note noteB, note4
+ mus_note noteB, note8
+ mus_note noteG#, note8
+
+ ;Octave Switch
+ db dNormSpd
+ mus_note noteRst, note4_16
+ db oct4
+
+ ;Piece 2
+ mus_note noteE, note2
+
+ mus_end ;End
+
+PkmnHealed_md_3: ;9BD2 - 9BDD
+;Music
+ ;Octave Switch
+ db dNormSpd
+ mus_note noteC#, note16
+ db oct3
+
+ ;Piece 1
+ mus_note noteE, note8
+ mus_note noteRst, note8
+ mus_note noteE, note8
+ mus_note noteRst, note8
+ mus_note noteE, note8
+ mus_note noteG#, note8
+ mus_note noteE, note4_8
+ mus_note noteRst, note8
+
+ mus_end ;End
+
+;Routes 1 and 2
+Routes1_md_1: ;9BDE - 9C50
+INCBIN "baserom.gbc",$9bde,$9c51 - $9bde
+
+Routes1_md_2: ;9C51 - 9CD7
+INCBIN "baserom.gbc",$9c51,$9cd8 - $9c51
+
+Routes1_md_3: ;9CD8 - 9D23
+INCBIN "baserom.gbc",$9cd8,$9d24 - $9cd8
+
+Routes1_md_4: ;9D24 - 9DB8
+INCBIN "baserom.gbc",$9d24,$9db9 - $9d24
+
+;Routes 24 and 25
+Routes2_md_1: ;9BD9 - 9E4E
+INCBIN "baserom.gbc",$9db9,$9e4f - $9db9
+
+Routes2_md_2: ;9E4F - 9E9A
+INCBIN "baserom.gbc",$9e4f,$9e9b - $9e4f
+
+Routes2_md_3: ;9E9B - 9F07
+INCBIN "baserom.gbc",$9e9b,$9f08 - $9e9b
+
+Routes2_md_4: ;9F08 - 9FAC
+INCBIN "baserom.gbc",$9f08,$9fad - $9f08
+
+;Routes 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22
+Routes3_md_1: ;9FAD - A008
+INCBIN "baserom.gbc",$9fad,$a009 - $9fad
+
+Routes3_md_2: ;A009 - A07E
+INCBIN "baserom.gbc",$a009,$a07f - $a009
+
+Routes3_md_3: ;A07F - 6130
+INCBIN "baserom.gbc",$a07f,$a131 - $a07f
+
+Routes3_md_4: ;A131 -A26A
+INCBIN "baserom.gbc",$a131,$a26a - $a131
+
+;Routes 11, 12, 13, 14, 15
+Routes4_md_1: ;a26a - a303
+INCBIN "baserom.gbc",$a26a,$a304 - $a26a
+
+Routes4_md_2: ;a304 - a3c3
+INCBIN "baserom.gbc",$a304,$a3c4 - $a304
+
+Routes4_md_3: ;a3c4 - a49c
+INCBIN "baserom.gbc",$a3c4,$a49d - $a3c4
+
+Routes4_md_4: ;a49d - a5ef
+INCBIN "baserom.gbc",$a49d,$a5f0 - $a49d
+
+;Indigo Plateau
+IndigoPlateau_md_1: ;a5f0 - a663
+INCBIN "baserom.gbc",$a5f0,$a664 - $a5f0
+
+IndigoPlateau_md_2: ;a664 - a6b9
+INCBIN "baserom.gbc",$a664,$a6ba - $a664
+
+IndigoPlateau_md_3: ;a6ba - a70e
+INCBIN "baserom.gbc",$a6ba,$a70f - $a6ba
+
+IndigoPlateau_md_4: ;a70f - a7c4
+INCBIN "baserom.gbc",$a70f,$a7c5 - $a70f
+
+;Pallet Town
+PalletTown_md_1: ; a7c5 - a85e (154 bytes)
+INCBIN "baserom.gbc",$a7c5,$a85f - $a7c5
+
+PalletTown_md_2: ; a85f - a8dd (127 bytes)
+INCBIN "baserom.gbc",$a85f,$a8de - $a85f
+
+PalletTown_md_3: ; a8de - aa75 (408 bytes)
+INCBIN "baserom.gbc",$a8de,$aa76 - $a8de
+
+;Viridian City, Pewter City, Saffron City
+Cities1_md_1: ;AA76 - AB91
+INCBIN "baserom.gbc",$aa76,$ab92 - $aa76
+
+Cities1_md_2: ;AB92 - AC02
+INCBIN "baserom.gbc",$ab92,$ac32 - $ab92
+
+Cities1_md_3: ;AC32 - AC7F
+INCBIN "baserom.gbc",$ac32,$acef - $ac32
+
+Cities1_md_4: ;ACEF - ADAD
+INCBIN "baserom.gbc",$acef,$adae - $acef
+
+;Guy walks you to museum
+MuseumGuy_md_1: ;ADAE - ADF0
+INCBIN "baserom.gbc",$adae,$adf1 - $adae
+
+MuseumGuy_md_2: ;ADF1 - AE6D
+INCBIN "baserom.gbc",$adf1,$ae6e - $adf1
+
+MuseumGuy_md_3: ;AE6E - AED0
+INCBIN "baserom.gbc",$ae6e,$aed1 - $ae6e
+
+MuseumGuy_md_4: ;AED1 - AF58
+INCBIN "baserom.gbc",$aed1,$af59 - $aed1
+
+;Meet Prof. Oak
+MeetProfOak_md_1: ;AF59 - AFA8
+INCBIN "baserom.gbc",$af59,$afa9 - $af59
+
+MeetProfOak_md_2: ;AFA9 - B03D
+INCBIN "baserom.gbc",$afa9,$b03d - $afa9
+
+MeetProfOak_md_3: ;B03D - B11F
+INCBIN "baserom.gbc",$b03d,$b120 - $b03d
+
+;Meet Rival
+MeetRival_md_1: ;B120 - B1BA
+INCBIN "baserom.gbc",$b120,$b1bb - $b120
+
+MeetRival_md_2: ;B1BB - B232
+INCBIN "baserom.gbc",$b1bb,$b233 - $b1bb
+
+MeetRival_md_3: ;B233 - B3A6
+INCBIN "baserom.gbc",$b233,$b3a7 - $b233
+
+;SS Anne
+SSAnne_md_1: ;B3A7 - B418
+INCBIN "baserom.gbc",$b3a7,$b419 - $b3a7
+
+SSAnne_md_2: ;B419 - B4CA
+INCBIN "baserom.gbc",$b419,$b4cb - $b419
+
+SSAnne_md_3: ;B4CB - B503
+INCBIN "baserom.gbc",$b4cb,$b504 - $b4cb
+
+;Cerulean City, Fuchsia City
+Cities2_md_1: ;B504 - B568
+INCBIN "baserom.gbc",$b504,$b569 - $b504
+
+Cities2_md_2: ;B569 - B63F
+INCBIN "baserom.gbc",$b569,$b640 - $b569
+
+Cities2_md_3: ;B640 - B6C6
+INCBIN "baserom.gbc",$b640,$b6c7 - $b640
+
+;Celadon City
+Celadon_md_1: ;B6C7 - B739
+INCBIN "baserom.gbc",$b6c7,$b73a - $b6c7
+
+Celadon_md_2: ;B73A - B7B4
+INCBIN "baserom.gbc",$b73a,$b7b5 - $b73a
+
+Celadon_md_3: ;B7B5 - B86C
+INCBIN "baserom.gbc",$b7b5,$b86d - $b7b5
+
+;Cinnabar Island
+Cinnabar_md_1: ;B86D - B8D3
+INCBIN "baserom.gbc",$b86d,$b8d4 - $b86d
+
+Cinnabar_md_2: ;B8D4 - B93C
+INCBIN "baserom.gbc",$b8d4,$b93d - $b8d4
+
+Cinnabar_md_3: ;B93D - B9EA
+INCBIN "baserom.gbc",$b93d,$b9eb - $b93d
+
+;Vermilion City
+Vermilion_md_1: ;B9EB - BA60
+INCBIN "baserom.gbc",$b9eb,$ba61 - $b9eb
+
+Vermilion_md_2: ;BA61 - BAA5
+INCBIN "baserom.gbc",$ba61,$baa6 - $ba61
+
+Vermilion_md_3: ;BAA6 - BB0C
+INCBIN "baserom.gbc",$baa6,$bb0d - $baa6
+
+Vermilion_md_4: ;BB0D - BB57
+INCBIN "baserom.gbc",$bb0d,$bb58 - $bb0d
+
+;Lavender Town
+Lavender_md_1: ;BB58 - BB9D
+INCBIN "baserom.gbc",$bb58,$bb9e - $bb58
+
+Lavender_md_2: ;BB9E - BBAD
+INCBIN "baserom.gbc",$bb9e,$bbae - $bb9e
+
+Lavender_md_3: ;BBAE - BC20
+INCBIN "baserom.gbc",$bbae,$bc21 - $bbae
+
+Lavender_md_4: ;BC21 - BC2D
+INCBIN "baserom.gbc",$bc21,$bc2e - $bc21
+
+;Safari Zone
+SafariZone_md_1: ;BC2E - BC69
+INCBIN "baserom.gbc",$bc2e,$bc6a - $bc2e
+
+SafariZone_md_2: ;BC6A - BC93
+INCBIN "baserom.gbc",$bc6a,$bc94 - $bc6a
+
+SafariZone_md_3: ;BC94 - BCBA
+INCBIN "baserom.gbc",$bc94,$bcbb - $bc94
+
+;Gyms
+Gym_md_1: ;bcbb - bd6a (175 bytes)
+INCBIN "baserom.gbc",$bcbb,$bd6b - $bcbb
+
+Gym_md_2: ;bd6b - bdf9 (142 bytes)
+INCBIN "baserom.gbc",$bd6b,$bdfa - $bd6b
+
+Gym_md_3: ;bdfa - be55 (91 bytes)
+INCBIN "baserom.gbc",$bdfa,$be56 - $bdfa
+
+;Pokemon Center
+Pokecenter_md_1: ;be56 - bef8 (162 bytes)
+INCBIN "baserom.gbc",$be56,$bef9 - $be56
+
+Pokecenter_md_2: ;0xbef9 - bf6f (118 bytes)
+INCBIN "baserom.gbc",$bef9,$bf70 - $bef9
+
+Pokecenter_md_3: ;0xbf70 - bfff (143 bytes)
+INCBIN "baserom.gbc",$bf70,$c000 - $bf70
\ No newline at end of file
--- a/music/music.asm
+++ /dev/null
@@ -1,299 +1,0 @@
-; Music Data
-; The start and stop of these byte ranges were based off the theory they're lined
-; consecutively (Right up against each other).
-
-INCBIN "baserom.gbc",$82FD,$9ba3 - $82FD
-
-;Pokemon Healed Music
-PkmnHealed_md_1: ;9BA3 - 9BC3
-
-;Setup
- mus_tempo 0, 144
- mus_volume 119
- mus_duty duty50
- db $E8 ;??
- mus_vel 8, 1
-
-;Music
- ;Piece 1
- mus_note noteRst, note8
- db $EB, $00
- mus_note noteE, note2_4
- mus_note noteB, note8
- db $EB, $00
- mus_note noteF, note4_16
- mus_note noteB, note8
- db $EB, $00
- mus_note noteE, note4_16
- mus_note noteE, note8
- mus_note noteRst, note4
- db $EB, $00
- mus_note noteD#, note2_4
- mus_note noteE, note4
- db $EB, $00
- mus_note noteE, note2_4
- mus_note noteB, note4
-
- mus_end ;End
-
-PkmnHealed_md_2: ;9BC4 - 9BD1
-;Setup
- mus_duty duty50
-
-;Music
- ;Octave Switch
- db dNormSpd
- mus_note noteRst, note4
- db oct3
-
- ;Piece 1
- mus_note noteB, note4
- mus_note noteB, note4
- mus_note noteB, note8
- mus_note noteG#, note8
-
- ;Octave Switch
- db dNormSpd
- mus_note noteRst, note4_16
- db oct4
-
- ;Piece 2
- mus_note noteE, note2
-
- mus_end ;End
-
-PkmnHealed_md_3: ;9BD2 - 9BDD
-;Music
- ;Octave Switch
- db dNormSpd
- mus_note noteC#, note16
- db oct3
-
- ;Piece 1
- mus_note noteE, note8
- mus_note noteRst, note8
- mus_note noteE, note8
- mus_note noteRst, note8
- mus_note noteE, note8
- mus_note noteG#, note8
- mus_note noteE, note4_8
- mus_note noteRst, note8
-
- mus_end ;End
-
-;Routes 1 and 2
-Routes1_md_1: ;9BDE - 9C50
-INCBIN "baserom.gbc",$9bde,$9c51 - $9bde
-
-Routes1_md_2: ;9C51 - 9CD7
-INCBIN "baserom.gbc",$9c51,$9cd8 - $9c51
-
-Routes1_md_3: ;9CD8 - 9D23
-INCBIN "baserom.gbc",$9cd8,$9d24 - $9cd8
-
-Routes1_md_4: ;9D24 - 9DB8
-INCBIN "baserom.gbc",$9d24,$9db9 - $9d24
-
-;Routes 24 and 25
-Routes2_md_1: ;9BD9 - 9E4E
-INCBIN "baserom.gbc",$9db9,$9e4f - $9db9
-
-Routes2_md_2: ;9E4F - 9E9A
-INCBIN "baserom.gbc",$9e4f,$9e9b - $9e4f
-
-Routes2_md_3: ;9E9B - 9F07
-INCBIN "baserom.gbc",$9e9b,$9f08 - $9e9b
-
-Routes2_md_4: ;9F08 - 9FAC
-INCBIN "baserom.gbc",$9f08,$9fad - $9f08
-
-;Routes 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22
-Routes3_md_1: ;9FAD - A008
-INCBIN "baserom.gbc",$9fad,$a009 - $9fad
-
-Routes3_md_2: ;A009 - A07E
-INCBIN "baserom.gbc",$a009,$a07f - $a009
-
-Routes3_md_3: ;A07F - 6130
-INCBIN "baserom.gbc",$a07f,$a131 - $a07f
-
-Routes3_md_4: ;A131 -A26A
-INCBIN "baserom.gbc",$a131,$a26a - $a131
-
-;Routes 11, 12, 13, 14, 15
-Routes4_md_1: ;a26a - a303
-INCBIN "baserom.gbc",$a26a,$a304 - $a26a
-
-Routes4_md_2: ;a304 - a3c3
-INCBIN "baserom.gbc",$a304,$a3c4 - $a304
-
-Routes4_md_3: ;a3c4 - a49c
-INCBIN "baserom.gbc",$a3c4,$a49d - $a3c4
-
-Routes4_md_4: ;a49d - a5ef
-INCBIN "baserom.gbc",$a49d,$a5f0 - $a49d
-
-;Indigo Plateau
-IndigoPlateau_md_1: ;a5f0 - a663
-INCBIN "baserom.gbc",$a5f0,$a664 - $a5f0
-
-IndigoPlateau_md_2: ;a664 - a6b9
-INCBIN "baserom.gbc",$a664,$a6ba - $a664
-
-IndigoPlateau_md_3: ;a6ba - a70e
-INCBIN "baserom.gbc",$a6ba,$a70f - $a6ba
-
-IndigoPlateau_md_4: ;a70f - a7c4
-INCBIN "baserom.gbc",$a70f,$a7c5 - $a70f
-
-;Pallet Town
-PalletTown_md_1: ; a7c5 - a85e (154 bytes)
-INCBIN "baserom.gbc",$a7c5,$a85f - $a7c5
-
-PalletTown_md_2: ; a85f - a8dd (127 bytes)
-INCBIN "baserom.gbc",$a85f,$a8de - $a85f
-
-PalletTown_md_3: ; a8de - aa75 (408 bytes)
-INCBIN "baserom.gbc",$a8de,$aa76 - $a8de
-
-;Viridian City, Pewter City, Saffron City
-Cities1_md_1: ;AA76 - AB91
-INCBIN "baserom.gbc",$aa76,$ab92 - $aa76
-
-Cities1_md_2: ;AB92 - AC02
-INCBIN "baserom.gbc",$ab92,$ac32 - $ab92
-
-Cities1_md_3: ;AC32 - AC7F
-INCBIN "baserom.gbc",$ac32,$acef - $ac32
-
-Cities1_md_4: ;ACEF - ADAD
-INCBIN "baserom.gbc",$acef,$adae - $acef
-
-;Guy walks you to museum
-MuseumGuy_md_1: ;ADAE - ADF0
-INCBIN "baserom.gbc",$adae,$adf1 - $adae
-
-MuseumGuy_md_2: ;ADF1 - AE6D
-INCBIN "baserom.gbc",$adf1,$ae6e - $adf1
-
-MuseumGuy_md_3: ;AE6E - AED0
-INCBIN "baserom.gbc",$ae6e,$aed1 - $ae6e
-
-MuseumGuy_md_4: ;AED1 - AF58
-INCBIN "baserom.gbc",$aed1,$af59 - $aed1
-
-;Meet Prof. Oak
-MeetProfOak_md_1: ;AF59 - AFA8
-INCBIN "baserom.gbc",$af59,$afa9 - $af59
-
-MeetProfOak_md_2: ;AFA9 - B03D
-INCBIN "baserom.gbc",$afa9,$b03d - $afa9
-
-MeetProfOak_md_3: ;B03D - B11F
-INCBIN "baserom.gbc",$b03d,$b120 - $b03d
-
-;Meet Rival
-MeetRival_md_1: ;B120 - B1BA
-INCBIN "baserom.gbc",$b120,$b1bb - $b120
-
-MeetRival_md_2: ;B1BB - B232
-INCBIN "baserom.gbc",$b1bb,$b233 - $b1bb
-
-MeetRival_md_3: ;B233 - B3A6
-INCBIN "baserom.gbc",$b233,$b3a7 - $b233
-
-;SS Anne
-SSAnne_md_1: ;B3A7 - B418
-INCBIN "baserom.gbc",$b3a7,$b419 - $b3a7
-
-SSAnne_md_2: ;B419 - B4CA
-INCBIN "baserom.gbc",$b419,$b4cb - $b419
-
-SSAnne_md_3: ;B4CB - B503
-INCBIN "baserom.gbc",$b4cb,$b504 - $b4cb
-
-;Cerulean City, Fuchsia City
-Cities2_md_1: ;B504 - B568
-INCBIN "baserom.gbc",$b504,$b569 - $b504
-
-Cities2_md_2: ;B569 - B63F
-INCBIN "baserom.gbc",$b569,$b640 - $b569
-
-Cities2_md_3: ;B640 - B6C6
-INCBIN "baserom.gbc",$b640,$b6c7 - $b640
-
-;Celadon City
-Celadon_md_1: ;B6C7 - B739
-INCBIN "baserom.gbc",$b6c7,$b73a - $b6c7
-
-Celadon_md_2: ;B73A - B7B4
-INCBIN "baserom.gbc",$b73a,$b7b5 - $b73a
-
-Celadon_md_3: ;B7B5 - B86C
-INCBIN "baserom.gbc",$b7b5,$b86d - $b7b5
-
-;Cinnabar Island
-Cinnabar_md_1: ;B86D - B8D3
-INCBIN "baserom.gbc",$b86d,$b8d4 - $b86d
-
-Cinnabar_md_2: ;B8D4 - B93C
-INCBIN "baserom.gbc",$b8d4,$b93d - $b8d4
-
-Cinnabar_md_3: ;B93D - B9EA
-INCBIN "baserom.gbc",$b93d,$b9eb - $b93d
-
-;Vermilion City
-Vermilion_md_1: ;B9EB - BA60
-INCBIN "baserom.gbc",$b9eb,$ba61 - $b9eb
-
-Vermilion_md_2: ;BA61 - BAA5
-INCBIN "baserom.gbc",$ba61,$baa6 - $ba61
-
-Vermilion_md_3: ;BAA6 - BB0C
-INCBIN "baserom.gbc",$baa6,$bb0d - $baa6
-
-Vermilion_md_4: ;BB0D - BB57
-INCBIN "baserom.gbc",$bb0d,$bb58 - $bb0d
-
-;Lavender Town
-Lavender_md_1: ;BB58 - BB9D
-INCBIN "baserom.gbc",$bb58,$bb9e - $bb58
-
-Lavender_md_2: ;BB9E - BBAD
-INCBIN "baserom.gbc",$bb9e,$bbae - $bb9e
-
-Lavender_md_3: ;BBAE - BC20
-INCBIN "baserom.gbc",$bbae,$bc21 - $bbae
-
-Lavender_md_4: ;BC21 - BC2D
-INCBIN "baserom.gbc",$bc21,$bc2e - $bc21
-
-;Safari Zone
-SafariZone_md_1: ;BC2E - BC69
-INCBIN "baserom.gbc",$bc2e,$bc6a - $bc2e
-
-SafariZone_md_2: ;BC6A - BC93
-INCBIN "baserom.gbc",$bc6a,$bc94 - $bc6a
-
-SafariZone_md_3: ;BC94 - BCBA
-INCBIN "baserom.gbc",$bc94,$bcbb - $bc94
-
-;Gyms
-Gym_md_1: ;bcbb - bd6a (175 bytes)
-INCBIN "baserom.gbc",$bcbb,$bd6b - $bcbb
-
-Gym_md_2: ;bd6b - bdf9 (142 bytes)
-INCBIN "baserom.gbc",$bd6b,$bdfa - $bd6b
-
-Gym_md_3: ;bdfa - be55 (91 bytes)
-INCBIN "baserom.gbc",$bdfa,$be56 - $bdfa
-
-;Pokemon Center
-Pokecenter_md_1: ;be56 - bef8 (162 bytes)
-INCBIN "baserom.gbc",$be56,$bef9 - $be56
-
-Pokecenter_md_2: ;0xbef9 - bf6f (118 bytes)
-INCBIN "baserom.gbc",$bef9,$bf70 - $bef9
-
-Pokecenter_md_3: ;0xbf70 - bfff (143 bytes)
-INCBIN "baserom.gbc",$bf70,$c000 - $bf70
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/AbstractData.cpp
@@ -1,0 +1,37 @@
+#include "AbstractData.h"
+using namespace std;
+
+AbstractData::AbstractData()
+{
+ error = false;
+}
+
+// This method must always return "" if true but can return
+// any other value for false
+string AbstractData::GenAsm()
+{
+ if(error) return ";#Error";
+ else return "";
+}
+
+bool AbstractData::IsValid(unsigned char* byte)
+{
+ return true;
+}
+
+bool AbstractData::Parse(unsigned char* byte)
+{
+ // If it's not valid, don't even bother parsing
+ if(!IsValid(byte)) return false;
+ return true;
+}
+
+unsigned int AbstractData::Arguments()
+{
+ return 0;
+}
+
+bool AbstractData::GetError()
+{
+ return error;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/AbstractData.h
@@ -1,0 +1,23 @@
+#ifndef ABSTRACTDATA_H
+#define ABSTRACTDATA_H
+
+#include <string>
+
+// All information types inherit from here
+class AbstractData
+{
+public:
+ AbstractData();
+
+ virtual std::string GenAsm(); // Generate Assembly Output
+ virtual bool IsValid(unsigned char* byte); // Check for byte validity
+ virtual bool Parse(unsigned char* byte); // Parse Given Data
+ virtual unsigned int Arguments(); // Number of arguments taken
+
+ virtual bool GetError(); // Get Error (No Write, Error is read only)
+
+protected:
+ bool error; // Whether there's an error in parsing or not
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Call.cpp
@@ -1,0 +1,71 @@
+#include <sstream>
+#include "Call.h"
+using namespace std;
+
+Call::Call()
+{
+ error = false;
+ address = 0;
+}
+
+Call::Call(unsigned char* byte)
+{
+ Parse(byte);
+}
+
+Call::Call(unsigned short value, bool)
+{
+ SetAddress(value);
+}
+
+unsigned short Call::GetAddress()
+{
+ return address;
+}
+
+void Call::SetAddress(unsigned short value)
+{
+ address = value;
+}
+
+string Call::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return tmpRet;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_call" << " $" << hex << uppercase << address;
+ return tmpAsmOut.str();
+}
+
+bool Call::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xFD)
+ {
+ error = false;
+ return true;
+ }
+ else
+ {
+ error = true;
+ return false;
+ }
+}
+
+bool Call::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ // Get Address
+ address = byte[2];
+ address <<= 8;
+ address |= byte[1];
+
+ return true;
+}
+
+unsigned int Call::Arguments()
+{
+ // 1 2-byte argument = 2 bytes
+ return 2;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Call.h
@@ -1,0 +1,34 @@
+#ifndef CALL_H
+#define CALL_H
+
+#include "AbstractData.h"
+
+// Represents 1 call
+class Call : public AbstractData
+{
+public:
+ // Constructors
+ Call(); // Default
+ Call(unsigned char* byte); // Parse Immidiately
+ Call(unsigned short value, bool); // Set value
+
+ // Direct Getter/Setter Functions
+ unsigned short GetAddress();
+ void SetAddress(unsigned short value);
+
+ // The standard re-implementations from AbstractData
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+private:
+ unsigned short address;
+};
+
+#endif
+
+// Rqandom Notes
+//ED Speed of song
+//EC Instrument
+//DC Volume
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Console.cpp
@@ -1,0 +1,54 @@
+#include "console.h"
+
+using namespace std;
+
+// Basic
+void Console::Get(char* value)
+{
+ cin >> value;
+}
+void Console::Get(string& value)
+{
+ cin >> value;
+}
+void Console::Print(const char* value)
+{
+ cout << value;
+}
+void Console::Error(const char* value)
+{
+ cerr << value;
+}
+
+// Upper-Basic
+void Console::PrintLn(const char* value)
+{
+ Print(value);
+ cout << endl;
+}
+void Console::ErrorLn(const char* value)
+{
+ Error(value);
+ cerr << endl;
+}
+
+// Higher
+void Console::Ask(const char* question, char* answer)
+{
+ Print(question);
+ Get(answer);
+}
+void Console::Ask(const char* question, string& answer)
+{
+ Print(question);
+ Get(answer);
+}
+
+// Better Error Handling
+int Console::atoi_ex(const char* input, bool supress)
+{
+ int convInp = atoi(input);
+ if((supress == false) && (convInp == 0))
+ PrintLn("Warning: the converted integer input is 0, this may not be what you intended");
+ return convInp;
+}
--- /dev/null
+++ b/music/pokeredmusicdisasm/Console.h
@@ -1,0 +1,29 @@
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include <iostream>
+#include <string>
+
+// Just a Console Utility Library
+class Console
+{
+public:
+ // Basic
+ static void Get(char* value);
+ static void Get(std::string& value);
+ static void Print(const char* value);
+ static void Error(const char* value);
+
+ // Upper-Basic
+ static void PrintLn(const char* value);
+ static void ErrorLn(const char* value);
+
+ // Higher
+ static void Ask(const char* question, char* answer);
+ static void Ask(const char* question, std::string& answer);
+
+ // Better Error Handling
+ static int atoi_ex(const char* input, bool supress = false);
+};
+
+#endif // CONSOLE_H
--- /dev/null
+++ b/music/pokeredmusicdisasm/Duty.cpp
@@ -1,0 +1,93 @@
+#include <sstream>
+#include "Duty.h"
+using namespace std;
+
+Duty::Duty()
+{
+ duty = 0;
+}
+
+Duty::Duty(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Duty::Duty(unsigned char value, bool) // Set value
+{
+ SetDuty(value);
+}
+
+unsigned char Duty::GetDuty()
+{
+ return duty;
+}
+
+void Duty::SetDuty(unsigned char value)
+{
+ // Clamp duty to 3 since that's the highest possible
+ duty = value;
+ if(duty >= 3) duty = 3;
+}
+
+// Byte 0 - The Command Code
+// Byte 1 - The Value
+bool Duty::IsValid(unsigned char* byte)
+{
+ if((byte[0] == 0xEC) &&
+ (byte[1] >= 0x0) &&
+ (byte[1] <= 0x3))
+ {
+ error = false; // Unblock assembling
+ return true;
+ }
+ else
+ {
+ error = true; // Block assembling
+ return false;
+ }
+}
+
+string Duty::GenAsm()
+{
+ string ret = AbstractData::GenAsm();
+ if(ret != "") return ret;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_duty " << LookupDutyString();
+ return tmpAsmOut.str();
+}
+
+bool Duty::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ duty = byte[1];
+ return true;
+}
+
+string Duty::LookupDutyString()
+{
+ // In case some error happens and the values doesn't match the list below
+ stringstream defTmp;
+
+ switch(duty)
+ {
+ case duty12_5:
+ return "duty12_5";
+ case duty25:
+ return "duty25";
+ case duty50:
+ return "duty50";
+ case duty75:
+ return "duty75";
+ default:
+ defTmp << "$" << uppercase << hex << (short)duty;
+ return defTmp.str();
+ }
+}
+
+unsigned int Duty::Arguments()
+{
+ //1 1-byte argument = 1
+ return 1;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Duty.h
@@ -1,0 +1,40 @@
+#ifndef DUTY_H
+#define DUTY_H
+
+#include "AbstractData.h"
+
+//Represents 1 Duty data
+class Duty : public AbstractData
+{
+public:
+ // Constructors
+ Duty();
+ Duty(unsigned char* byte); // Parse Immidiately
+ Duty(unsigned char value, bool); // Set value
+
+ // Re-Implementations from Parent
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+ // Direct Getters and Setters
+ unsigned char GetDuty();
+ void SetDuty(unsigned char value);
+
+ // Custom Functions
+ std::string LookupDutyString();
+
+ const enum dutyList : unsigned char
+ {
+ duty12_5 = 0x0,
+ duty25 = 0x1,
+ duty50 = 0x2,
+ duty75 = 0x3
+ };
+
+private:
+ unsigned char duty;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/File.h
@@ -1,0 +1,26 @@
+#ifndef FILE_H
+#define FILE_H
+
+#include <string>
+#include <vector>
+#include <fstream>
+
+class File
+{
+public:
+ File();
+ File(std::string filename, unsigned int offset = 0, unsigned int length = 0);
+
+ string GetFileName();
+ void SetFilename(string value);
+
+private:
+ std::string filename;
+ std::vector<unsigned char> fileBuffer;
+ std::fstream fileHandle;
+
+ std::vector<unsigned char>::iterator start;
+ std::vector<unsigned char>::iterator cur;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Jump.cpp
@@ -1,0 +1,83 @@
+#include <sstream>
+#include "Jump.h"
+using namespace std;
+
+Jump::Jump()
+{
+ address = 0x0000;
+ loop = 0;
+}
+
+Jump::Jump(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Jump::Jump(unsigned short value, unsigned char loop, bool) // Set value
+{
+ SetAddress(value);
+ SetLoop(loop);
+}
+
+unsigned short Jump::GetAddress()
+{
+ return address;
+}
+
+void Jump::SetAddress(unsigned short value)
+{
+ address = value;
+}
+
+unsigned char Jump::GetLoop()
+{
+ return loop;
+}
+
+void Jump::SetLoop(unsigned char value)
+{
+ loop = value;
+}
+
+string Jump::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return tmpRet;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_jump" << " " << (short)loop << ", $" << hex << uppercase << address;
+ return tmpAsmOut.str();
+}
+
+bool Jump::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xFE)
+ {
+ error = false;
+ return true;
+ }
+ else
+ {
+ error = true;
+ return false;
+ }
+}
+
+bool Jump::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ loop = byte[1];
+
+ address = byte[3];
+ address <<= 8;
+ address |= byte[2];
+
+ return true;
+}
+
+unsigned int Jump::Arguments()
+{
+ // 1 1-byte command, 1 1-byte loop, 1 2-byte pointer = 4 bytes
+ return 3;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Jump.h
@@ -1,0 +1,33 @@
+#ifndef JUMP_H
+#define JUMP_H
+
+#include "AbstractData.h"
+
+// Represents 1 Jump Class
+class Jump : public AbstractData
+{
+public:
+ // Constructors
+ Jump(); // Default
+ Jump(unsigned char* byte); // Parse Immidiately
+ Jump(unsigned short value, unsigned char loop, bool); // Set value
+
+ // Direct Getter/Setter Functions
+ unsigned short GetAddress();
+ void SetAddress(unsigned short value);
+
+ unsigned char GetLoop();
+ void SetLoop(unsigned char value);
+
+ // The standard re-implementations from AbstractData
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+private:
+ unsigned short address;
+ unsigned char loop;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Modulation.cpp
@@ -1,0 +1,96 @@
+#include <sstream>
+#include "Modulation.h"
+using namespace std;
+
+Modulation::Modulation()
+{
+ delay = 0;
+ depth = 0;
+ rate = 0;
+}
+
+Modulation::Modulation(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Modulation::Modulation(unsigned char delay, unsigned char depth, unsigned char rate, bool) // Set value
+{
+ SetDelay(delay);
+ SetDepth(depth);
+ SetRate(rate);
+}
+
+// Direct Getter/Setter Functions
+unsigned char Modulation::GetDelay()
+{
+ return delay;
+}
+
+void Modulation::SetDelay(unsigned char value)
+{
+ delay = value;
+}
+
+unsigned char Modulation::GetDepth()
+{
+ return depth;
+}
+
+void Modulation::SetDepth(unsigned char value)
+{
+ depth = value;
+}
+
+unsigned char Modulation::GetRate()
+{
+ return rate;
+}
+
+void Modulation::SetRate(unsigned char value)
+{
+ rate = value;
+}
+
+bool Modulation::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xEA)
+ {
+ error = false; // Unblock assembling
+ return true;
+ }
+ else
+ {
+ error = true; // Block assembling
+ return false;
+ }
+}
+
+string Modulation::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return tmpRet;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_mod " << hex << (short)delay << ", " << (short)depth << ", " << (short)rate;
+ return tmpAsmOut.str();
+}
+
+bool Modulation::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ delay = byte[1];
+
+ depth = byte[2] & 0xF0;
+ depth >>= 4;
+
+ rate = byte[2] & 0x0F;
+ return true;
+}
+
+unsigned int Modulation::Arguments()
+{
+ // 2 1-byte arguments = 2
+ return 2;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Modulation.h
@@ -1,0 +1,37 @@
+#ifndef MODULATION_H
+#define MODULATION_H
+
+#include "AbstractData.h"
+
+//Represents 1 modulation value
+class Modulation : public AbstractData
+{
+public:
+ // Constructors
+ Modulation();
+ Modulation(unsigned char* byte); // Parse Immidiately
+ Modulation(unsigned char delay, unsigned char depth, unsigned char rate, bool); // Set value
+
+ // Direct Getter/Setter Functions
+ unsigned char GetDelay();
+ void SetDelay(unsigned char value);
+
+ unsigned char GetDepth();
+ void SetDepth(unsigned char value);
+
+ unsigned char GetRate();
+ void SetRate(unsigned char value);
+
+ // Re-implemented
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+private:
+ unsigned char delay;
+ unsigned char depth;
+ unsigned char rate;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Note.cpp
@@ -1,0 +1,174 @@
+#include <sstream>
+#include "Note.h"
+
+using namespace std;
+
+Note::Note()
+{
+ pitch = 0x0;
+ delay = 0x0;
+}
+
+Note::Note(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Note::Note(unsigned char pitch, unsigned char delay,bool) // Set value
+{
+ SetPitch(pitch);
+ SetDelay(delay);
+}
+
+unsigned char Note::GetPitch()
+{
+ return pitch;
+}
+
+void Note::SetPitch(unsigned char value)
+{
+ pitch = value;
+}
+
+unsigned char Note::GetDelay()
+{
+ return delay;
+}
+
+void Note::SetDelay(unsigned char value)
+{
+ delay = value;
+}
+
+bool Note::IsValid(unsigned char* byte)
+{
+ // A Note is a byte that is between 0x00 and 0xCF
+ if((byte[0] >= 0x00) &&
+ (byte[0] <= 0xCF))
+ {
+ error = false; // Unblock assembling
+ return true;
+ }
+ else
+ {
+ error = true; // Block assembling
+ return false;
+ }
+}
+
+// Generates the assembly for this note
+string Note::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return tmpRet;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_note" << " " << LookupPitchStr() << ", " << LookupDelayStr();
+ return tmpAsmOut.str();
+}
+
+// Takes the raw byte and parses it's data, storing it
+bool Note::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ pitch = byte[0] & 0xF0;
+ pitch >>= 4;
+
+ delay = byte[0] & 0x0F;
+ return true;
+}
+
+// Fetches the asm string name for the pitch
+string Note::LookupPitchStr()
+{
+ // In case some error happens and the values doesn't match the list below
+ stringstream defTmp;
+
+ switch(pitch)
+ {
+ case noteC:
+ return "noteC";
+ case noteCS:
+ return "noteC#";
+ case noteD:
+ return "noteD";
+ case noteDS:
+ return "noteD#";
+ case noteE:
+ return "noteE";
+ case noteF:
+ return "noteF";
+ case noteFS:
+ return "noteF#";
+ case noteG:
+ return "noteG";
+ case noteGS:
+ return "noteG#";
+ case noteA:
+ return "noteA";
+ case noteAS:
+ return "noteA#";
+ case noteB:
+ return "noteB";
+ case noteRst:
+ return "noteRst";
+ default:
+ defTmp.setf(ios_base::uppercase | ios_base::hex);
+ defTmp << "$" << pitch;
+ return defTmp.str();
+ }
+}
+
+// Fetches the asm string name for the delay
+string Note::LookupDelayStr()
+{
+ // In case some error happens and the values doesn't match the list below
+ stringstream defTmp;
+
+ switch(delay)
+ {
+ case note16:
+ return "note16";
+ case note8:
+ return "note8";
+ case note8_16:
+ return "note8_16";
+ case note4:
+ return "note4";
+ case note4_16:
+ return "note4_16";
+ case note4_8:
+ return "note4_8";
+ case note4_8_16:
+ return "note4_8_16";
+ case note2:
+ return "note2";
+ case note2_16:
+ return "note2_16";
+ case note2_8:
+ return "note2_8";
+ case note2_8_16:
+ return "note2_8_16";
+ case note2_4:
+ return "note2_4";
+ case note2_4_16:
+ return "note2_4_16";
+ case note2_4_8:
+ return "note2_4_8";
+ case note2_4_8_16:
+ return "note2_4_8_16";
+ case note1:
+ return "note1";
+ default:
+ defTmp.setf(ios_base::uppercase | ios_base::hex);
+ defTmp << "$" << (short)pitch;
+ return defTmp.str();
+ }
+}
+
+unsigned int Note::Arguments()
+{
+ // No Arguments
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Note.h
@@ -1,0 +1,73 @@
+#ifndef NOTE_H
+#define NOTE_H
+
+#include "AbstractData.h"
+
+// Holds a single note
+class Note : public AbstractData
+{
+public:
+ // Constructors
+ Note();
+ Note(unsigned char* byte); // Parse Immidiately
+ Note(unsigned char pitch, unsigned char delay,bool); // Set value
+
+ // Reimplementations
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+ // Getters and Setters
+ unsigned char GetPitch();
+ void SetPitch(unsigned char value);
+
+ unsigned char GetDelay();
+ void SetDelay(unsigned char value);
+
+ // Specific Methods
+ std::string LookupPitchStr();
+ std::string LookupDelayStr();
+
+ const enum pitch_code : unsigned char
+ {
+ noteC = 0x0,
+ noteCS = 0x1,
+ noteD = 0x2,
+ noteDS = 0x3,
+ noteE = 0x4,
+ noteF = 0x5,
+ noteFS = 0x6,
+ noteG = 0x7,
+ noteGS = 0x8,
+ noteA = 0x9,
+ noteAS = 0xA,
+ noteB = 0xB,
+ noteRst = 0xC
+ };
+
+ const enum delay_code : unsigned char
+ {
+ note16 = 0x0,
+ note8 = 0x1,
+ note8_16 = 0x2,
+ note4 = 0x3,
+ note4_16 = 0x4,
+ note4_8 = 0x5,
+ note4_8_16 = 0x6,
+ note2 = 0x7,
+ note2_16 = 0x8,
+ note2_8 = 0x9,
+ note2_8_16 = 0xA,
+ note2_4 = 0xB,
+ note2_4_16 = 0xC,
+ note2_4_8 = 0xD,
+ note2_4_8_16 = 0xE,
+ note1 = 0xF
+ };
+private:
+ unsigned char pitch;
+ unsigned char delay;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Octave.cpp
@@ -1,0 +1,97 @@
+#include <sstream>
+#include "Octave.h"
+using namespace std;
+
+Octave::Octave()
+{
+ octave = 0;
+}
+
+Octave::Octave(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Octave::Octave(unsigned char octave, bool) // Set value
+{
+ SetOctave(octave);
+}
+
+unsigned char Octave::GetOctave()
+{
+ return octave;
+}
+
+void Octave::SetOctave(unsigned char value)
+{
+ octave = value;
+}
+
+bool Octave::IsValid(unsigned char* byte)
+{
+ if((byte[0] >= 0xE0) &&
+ (byte[0] <= 0xE7))
+ {
+ error = false; // Unblock assembling
+ return true;
+ }
+ else
+ {
+ error = true; // Block assembling
+ return false;
+ }
+}
+
+string Octave::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return tmpRet;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_octave" << " " << LookupOctString();
+ return tmpAsmOut.str();
+}
+
+bool Octave::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ octave = byte[0];
+ return true;
+}
+
+string Octave::LookupOctString()
+{
+ // In case some error happens and the values doesn't match the list below
+ stringstream defTmp;
+
+ switch(octave)
+ {
+ case oct0:
+ return "oct0";
+ case oct1:
+ return "oct1";
+ case oct2:
+ return "oct2";
+ case oct3:
+ return "oct3";
+ case oct4:
+ return "oct4";
+ case oct5:
+ return "oct5";
+ case oct6:
+ return "oct6";
+ case oct7:
+ return "oct7";
+ default:
+ defTmp.setf(ios_base::uppercase | ios_base::hex);
+ defTmp << "$" << (short)octave;
+ return defTmp.str();
+ }
+}
+
+unsigned int Octave::Arguments()
+{
+ // No Arguments
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Octave.h
@@ -1,0 +1,43 @@
+#ifndef OCTAVE_H
+#define OCTAVE_H
+
+#include "AbstractData.h"
+
+//Represents 1 octave value
+class Octave : public AbstractData
+{
+public:
+ // Constructors
+ Octave();
+ Octave(unsigned char* byte); // Parse Immidiately
+ Octave(unsigned char octave, bool); // Set value
+
+ // Direct Getters / Setters
+ unsigned char GetOctave();
+ void SetOctave(unsigned char value);
+
+ // Overides
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+ std::string LookupOctString();
+
+ const enum OctaveCode : unsigned char
+ {
+ oct0 = 0xE7,
+ oct1 = 0xE6,
+ oct2 = 0xE5,
+ oct3 = 0xE4,
+ oct4 = 0xE3,
+ oct5 = 0xE2,
+ oct6 = 0xE1,
+ oct7 = 0xE0,
+ };
+
+private:
+ unsigned char octave;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Parser.cpp
@@ -1,0 +1,203 @@
+#include <sstream>
+#include "Parser.h"
+using namespace std;
+
+// Constructors
+Parser::Parser()
+{
+ rawBytes = 0;
+ fileLength = 0;
+ filePos = 0;
+ stop = false;
+}
+
+Parser::Parser(std::string filename)
+{
+ rawBytes = 0;
+ fileLength = 0;
+ filePos = 0;
+ stop = false;
+
+ SetFilename(filename);
+}
+
+// Deconstructors
+Parser::~Parser()
+{
+ // Clear out temporary buffer
+ delete[] rawBytes;
+
+ // Clear out parsed buffer
+ for(unsigned int i = 0; i < parsedBytes.size(); i++)
+ {
+ delete parsedBytes[i];
+ }
+}
+
+// Getters / Setters
+string Parser::GetFilename()
+{
+ return filename;
+}
+
+void Parser::SetFilename(std::string value)
+{
+ filename = value;
+ Read();
+}
+
+string Parser::GetParsedAsm()
+{
+ string tmpStr;
+
+ for(unsigned int i = 0; i < parsedString.size(); i++)
+ {
+ tmpStr += parsedString[i] + "\n";
+ }
+
+ return tmpStr;
+}
+
+// File Operations
+// Absolutely no error checking at all - likely needs to be done at somepoint
+void Parser::Read()
+{
+ // open File
+ fstream tmpFile(filename, ios_base::in | ios_base::binary);
+
+ // Get Length
+ tmpFile.seekg(0, ios::end);
+ fileLength = tmpFile.tellg();
+ tmpFile.seekg(0, ios::beg);
+
+ // Allocate proper memory
+ rawBytes = new char[fileLength];
+
+ // Read filedata
+ tmpFile.read(rawBytes, fileLength);
+ tmpFile.close();
+}
+
+// Code Operations
+void Parser::Parse(unsigned int offset)
+{
+ filePos = offset;
+ ParseNext();
+}
+
+void Parser::ParseNext() // Parses the block immidiately following
+{
+ stringstream tmpStr;
+ unsigned char* rawBytesFixed = (unsigned char*)rawBytes;
+ stop = false;
+
+ // Smart generation
+ bool indent = false;
+ bool firstNonNote = false; // First byte wasn't a note or octacve switch, add ";Setup" comment
+ bool firstNote = false; // First note or octave
+
+ stringstream pos;
+ pos << "; " << hex << uppercase << (unsigned int)filePos;
+ parsedString.push_back(pos.str());
+
+ for(unsigned int i = filePos; (i <= fileLength) && (stop == false); i++)
+ {
+ // There's a way to make this block shorter but for now it does it's job
+ filePos = i;
+
+ // Check to see if it's the correct data type and if so then use it
+ if(tmpCall.IsValid(&rawBytesFixed[i])) // Should have made IsValid static
+ {
+ // Call data type
+
+ // Create data type then move the increment pointer further up as needed
+ parsedBytes.push_back(new Call(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpCall.Arguments(); // should have made Arguments static
+
+ Call* _tmp = (Call*)parsedBytes[parsedBytes.size() - 1];
+ }
+ else if(tmpDuty.IsValid(&rawBytesFixed[i]))
+ {
+ // Duty data type
+ parsedBytes.push_back(new Duty(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpDuty.Arguments();
+ }
+ else if(tmpJump.IsValid(&rawBytesFixed[i]))
+ {
+ // Jump data type
+ parsedBytes.push_back(new Jump(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpJump.Arguments();
+
+ Jump* _tmp = (Jump*)parsedBytes[parsedBytes.size() - 1];
+ }
+ else if(tmpModulation.IsValid(&rawBytesFixed[i]))
+ {
+ // Modulation data type
+ parsedBytes.push_back(new Modulation(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpModulation.Arguments();
+ }
+ else if(tmpNote.IsValid(&rawBytesFixed[i]))
+ {
+ // Note data type
+ parsedBytes.push_back(new Note(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpNote.Arguments();
+ }
+ else if(tmpOctave.IsValid(&rawBytesFixed[i]))
+ {
+ // Octave data type
+ parsedBytes.push_back(new Octave(&rawBytesFixed[i]));
+ parsedString.push_back("\n" + parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpOctave.Arguments();
+ }
+ else if(tmpStop.IsValid(&rawBytesFixed[i]))
+ {
+ // Stop data type
+ parsedBytes.push_back(new Stop(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpStop.Arguments();
+
+ stop = true; // Stop all further processing, we've reached the end of the song
+ }
+ else if(tmpTempo.IsValid(&rawBytesFixed[i]))
+ {
+ // Tempo data type
+ parsedBytes.push_back(new Tempo(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpTempo.Arguments();
+ }
+ else if(tmpVelocity.IsValid(&rawBytesFixed[i]))
+ {
+ // Velocity data type
+ parsedBytes.push_back(new Velocity(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpVelocity.Arguments();
+ }
+ else if(tmpVolume.IsValid(&rawBytesFixed[i]))
+ {
+ // Volume data type
+ parsedBytes.push_back(new Volume(&rawBytesFixed[i]));
+ parsedString.push_back(parsedBytes[parsedBytes.size() - 1]->GenAsm());
+ i += tmpVolume.Arguments();
+ }
+ else
+ {
+ // Unknown code
+ stringstream unkCode;
+ short tmpByte = (short)rawBytesFixed[i];
+ unkCode << "db $" << hex << uppercase << (short)rawBytesFixed[i];
+ parsedString.push_back(unkCode.str());
+ }
+ }
+
+ // Now record the postion we left off
+ pos.str("");
+ pos << "; " << hex << uppercase << (unsigned int)filePos;
+ parsedString.push_back(pos.str());
+
+ filePos += 1; // increment 1 for the start of the next possible song
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Parser.h
@@ -1,0 +1,72 @@
+#ifndef PARSER_H
+#define PARSER_H
+
+#include <fstream>
+#include <string>
+#include <vector>
+
+#include "AbstractData.h"
+#include "Call.h"
+#include "Console.h"
+#include "Duty.h"
+#include "Jump.h"
+#include "Modulation.h"
+#include "Note.h"
+#include "Octave.h"
+#include "Parser.h"
+#include "Stop.h"
+#include "Tempo.h"
+#include "Velocity.h"
+#include "Volume.h"
+
+// This is the final class, it takes all of the data types, abstract class, and helper functions and uses them
+// for parsing
+
+// the final decided plan was to read the whole file into memory (a rom isn't exactly a big memory breaker)
+class Parser
+{
+public:
+ // Constructors
+ Parser();
+ Parser(std::string filename);
+
+ // Deconstructors
+ ~Parser();
+
+ // Getters / Setters
+ std::string GetFilename();
+ void SetFilename(std::string value);
+
+ std::string GetParsedAsm();
+
+ // File Operations
+ void Read();
+
+ // Code Operations
+ void Parse(unsigned int offset);
+ void ParseNext(); // Parses the block immidiately following
+
+private:
+ std::string filename;
+ std::vector<AbstractData*> parsedBytes;
+ std::vector<std::string> parsedString;
+
+ char* rawBytes;
+ unsigned int fileLength;
+ unsigned int filePos;
+ bool stop;
+
+ // A lot of tmp classes
+ Call tmpCall;
+ Duty tmpDuty;
+ Jump tmpJump;
+ Modulation tmpModulation;
+ Note tmpNote;
+ Octave tmpOctave;
+ Stop tmpStop;
+ Tempo tmpTempo;
+ Velocity tmpVelocity;
+ Volume tmpVolume;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Stop.cpp
@@ -1,0 +1,47 @@
+#include <sstream>
+#include "Stop.h"
+using namespace std;
+
+Stop::Stop()
+{}
+
+Stop::Stop(unsigned char* byte)
+{
+ Parse(byte);
+}
+
+bool Stop::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xFF)
+ {
+ error = false; // Unblock assembling
+ return true;
+ }
+ else
+ {
+ error = true; // Block assembling
+ return false;
+ }
+}
+
+string Stop::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return false;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_end";
+ return tmpAsmOut.str();
+}
+
+bool Stop::Parse(unsigned char* byte)
+{
+ if(AbstractData::Parse(byte)) return false;
+ return true;
+}
+
+unsigned int Stop::Arguments()
+{
+ // No Arguments
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Stop.h
@@ -1,0 +1,21 @@
+#ifndef STOP_H
+#define STOP_H
+
+#include "AbstractData.h"
+
+//Represents 1 end music data
+class Stop : public AbstractData
+{
+public:
+ // Constructors
+ Stop();
+ Stop(unsigned char* byte); // Parse Immidiately
+
+ // Re-Implementations
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Tempo.cpp
@@ -1,0 +1,80 @@
+#include <sstream>
+#include "Tempo.h"
+using namespace std;
+
+Tempo::Tempo()
+{
+ divider = 0;
+ modifier = 0;
+}
+
+Tempo::Tempo(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Tempo::Tempo(unsigned char divider, unsigned char modifier, bool) // Set value
+{
+ SetDivider(divider);
+ SetModifier(modifier);
+}
+
+unsigned char Tempo::GetDivider()
+{
+ return divider;
+}
+
+void Tempo::SetDivider(unsigned char value)
+{
+ divider = value;
+}
+
+unsigned char Tempo::Getmodifier()
+{
+ return modifier;
+}
+
+void Tempo::SetModifier(unsigned char value)
+{
+ modifier = value;
+}
+
+bool Tempo::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xED)
+ {
+ error = false;
+ return true;
+ }
+ else
+ {
+ error = true;
+ return false;
+ }
+}
+
+string Tempo::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return false;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_tempo" << " " << (short)divider << ", " << (short)modifier;
+ return tmpAsmOut.str();
+}
+
+bool Tempo::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ divider = byte[1];
+ modifier = byte[2];
+
+ return true;
+}
+
+unsigned int Tempo::Arguments()
+{
+ // 2 1-byte arguments = 2
+ return 2;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Tempo.h
@@ -1,0 +1,32 @@
+#ifndef TEMPO_H
+#define TEMPO_H
+
+#include "AbstractData.h"
+
+class Tempo : public AbstractData
+{
+public:
+ // Constructors
+ Tempo();
+ Tempo(unsigned char* byte); // Parse Immidiately
+ Tempo(unsigned char divider, unsigned char modifier, bool); // Set value
+
+ // Direct Getters and Setters
+ unsigned char GetDivider();
+ void SetDivider(unsigned char value);
+
+ unsigned char Getmodifier();
+ void SetModifier(unsigned char value);
+
+ // Overides
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+private:
+ unsigned char divider;
+ unsigned char modifier;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Velocity.cpp
@@ -1,0 +1,82 @@
+#include <sstream>
+#include "Velocity.h"
+using namespace std;
+
+Velocity::Velocity()
+{
+ velocity = 0;
+ length = 0;
+}
+
+Velocity::Velocity(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Velocity::Velocity(unsigned char velocity, unsigned char length, bool) // Set value
+{
+ SetVelocity(velocity);
+ SetLength(length);
+}
+
+// Direct Getters/Setters
+unsigned char Velocity::GetVelocity()
+{
+ return velocity;
+}
+
+void Velocity::SetVelocity(unsigned char value)
+{
+ velocity = value;
+}
+
+unsigned char Velocity::GetLength()
+{
+ return length;
+}
+
+void Velocity::SetLength(unsigned char value)
+{
+ length = value;
+}
+
+bool Velocity::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xDC)
+ {
+ error = false;
+ return true;
+ }
+ else
+ {
+ error = true;
+ return false;
+ }
+}
+
+string Velocity::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return tmpRet;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_vel" << " " << (short)velocity << ", " << (short)length;
+ return tmpAsmOut.str();
+}
+
+bool Velocity::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ velocity = byte[1] & 0xF0;
+ velocity >>= 4;
+
+ length = byte[1] & 0x0F;
+ return true;
+}
+
+unsigned int Velocity::Arguments()
+{
+ // 1 1-byte argument
+ return 1;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Velocity.h
@@ -1,0 +1,32 @@
+#ifndef VELOCITY_H
+#define VELOCITY_H
+
+#include "AbstractData.h"
+
+class Velocity : public AbstractData
+{
+public:
+ // Constructors
+ Velocity();
+ Velocity(unsigned char* byte); // Parse Immidiately
+ Velocity(unsigned char velocity, unsigned char length, bool); // Set value
+
+ // Direct Getters/Setters
+ unsigned char GetVelocity();
+ void SetVelocity(unsigned char value);
+
+ unsigned char GetLength();
+ void SetLength(unsigned char value);
+
+ // Overides
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+private:
+ unsigned char velocity;
+ unsigned char length;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Volume.cpp
@@ -1,0 +1,67 @@
+#include <sstream>
+#include "Volume.h"
+using namespace std;
+
+Volume::Volume()
+{
+ volume = 0;
+}
+
+Volume::Volume(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Volume::Volume(unsigned char volume, bool) // Set value
+{
+ SetVolume(volume);
+}
+
+unsigned char Volume::GetVolume()
+{
+ return volume;
+}
+
+void Volume::SetVolume(unsigned char value)
+{
+ volume = value;
+}
+
+bool Volume::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xF0)
+ {
+ error = false;
+ return true;
+ }
+ else
+ {
+ error = true;
+ return false;
+ }
+}
+
+string Volume::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return false;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_volume" << " " << (short)volume;
+ return tmpAsmOut.str();
+}
+
+bool Volume::Parse(unsigned char* byte)
+{
+ // If it's not a Note, don't even bother parsing
+ if(!AbstractData::Parse(byte)) return false;
+
+ volume = byte[1];
+ return true;
+}
+
+unsigned int Volume::Arguments()
+{
+ // 1 1-byte argument = 1
+ return 1;
+}
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/Volume.h
@@ -1,0 +1,28 @@
+#ifndef VOLUME_H
+#define VOLUME_H
+
+#include "AbstractData.h"
+
+class Volume : public AbstractData
+{
+public:
+ // Constructors
+ Volume();
+ Volume(unsigned char* byte); // Parse Immidiately
+ Volume(unsigned char volume, bool); // Set value
+
+ // Direct Getters / Setters
+ unsigned char GetVolume();
+ void SetVolume(unsigned char value);
+
+ // Re-implementations
+ virtual std::string GenAsm();
+ virtual bool IsValid(unsigned char* byte);
+ virtual bool Parse(unsigned char* byte);
+ virtual unsigned int Arguments();
+
+private:
+ unsigned char volume;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/music/pokeredmusicdisasm/main.cpp
@@ -1,0 +1,39 @@
+#include "Console.h"
+#include "Parser.h"
+#include <sstream>
+#include <string>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ string arg1; // Offset
+ string arg2; // File
+
+ if(argc >= 3)
+ {
+ arg1 = argv[1];
+ arg2 = argv[2];
+ }
+ else if(argc == 2)
+ {
+ arg1 = argv[1];
+ arg2 = "../baserom.gbc";
+ }
+
+ if(arg1 == "") Console::Ask("What offset in the file in hex (0x----): ", arg1);
+ if(arg2 == "") Console::Ask("What file: ", arg2);
+
+ // Weird way of converting arg1 to an unsigned integer
+ stringstream arg1Conv;
+ unsigned int arg1ConvNum;
+ arg1Conv << arg1;
+ arg1Conv << hex;
+ arg1Conv >> arg1ConvNum;
+
+ Parser p(arg2);
+ p.Parse(arg1ConvNum);
+ Console::PrintLn(p.GetParsedAsm().c_str());
+
+ return 0;
+}
\ No newline at end of file