From 99b86cdd8f2951cd540bf3563b7559e036e2c715 Mon Sep 17 00:00:00 2001 From: padz Date: Tue, 9 Oct 2012 02:16:36 -0400 Subject: [PATCH 1/7] flesh out bittable2 --- main.asm | 296 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 152 insertions(+), 144 deletions(-) diff --git a/main.asm b/main.asm index 1e4bcb772..33131fac9 100644 --- a/main.asm +++ b/main.asm @@ -211,7 +211,10 @@ GetJoypadState; 984 ld [$ff00+$a7], a ld [$ff00+$a8], a jr .quit - ld [$c2ca], a +; 9ee + +Function9ee: ; 9ee + ld [$c2ca], a ; bank? ld a, l ld [$c2c8], a ld a, h @@ -225,7 +228,7 @@ GetJoypadState; 984 ld a, $ff ld [$c2c7], a ret -;a0a +; a0a Functiona0a: ; a0a ; clears $c2c7-$c2cb @@ -236,7 +239,7 @@ Functiona0a: ; a0a ld [$c2cb], a ld [$c2c7], a ret -;a1b +; a1b INCBIN "baserom.gbc",$a1b,$e8d - $a1b @@ -1629,12 +1632,13 @@ PrintNumber_AdvancePointer: ; c64a INCBIN "baserom.gbc",$c658,$c721 - $c658 -CheckFlag: ; c721 +CheckFlag2: ; c721 +; uses bittable2 ; checks flag id in de ; returns carry if flag is not set ld b, $02 ; check flag - ld a, BANK(GetFlag) - ld hl, GetFlag + ld a, BANK(GetFlag2) + ld hl, GetFlag2 rst $08 ld a, c and a @@ -51338,8 +51342,8 @@ SECTION "bank20",DATA,BANK[$20] INCBIN "baserom.gbc",$80000,$80430-$80000 -GetFlag: ; 80430 -; engine flags, not script related +GetFlag2: ; 80430 +; uses bittable2 ; takes flag id in de, mode in b ; can either check, set or reset a flag ; check: stores flag in c @@ -51397,168 +51401,171 @@ GetFlag: ; 80430 ; 80462 Flags: ; 80462 +; bittable2 ; location, bit - dwb $d957, %00000010 - dwb $d957, %00000001 - dwb $d957, %00000100 - dwb $d957, %00001000 - dwb $d957, %10000000 + + ; pokegear + dwb $d957, %00000010 ; radio card + dwb $d957, %00000001 ; map card + dwb $d957, %00000100 ; phone card + dwb $d957, %00001000 ; expn card + dwb $d957, %10000000 ; on/off - dwb $def5, %01000000 - dwb $def5, %00000001 + ; $def5 %10000000 ; daycare 1 on + dwb $def5, %01000000 ; monster 1 and 2 are compatible + ; $def5 %???????? ; egg is ready + dwb $def5, %00000001 ; monster 1 in daycare - dwb $df2c, %00000001 + ; $df2c %10000000 = daycare 2 on + dwb $df2c, %00000001 ; monster 2 in daycare - dwb $d854, %00000001 - dwb $d854, %10000000 + dwb $d854, %00000001 ; mom saving money + dwb $d854, %10000000 ; dst dwb $dc39, %00000001 - dwb $d84c, %00000001 - dwb $d84c, %00000010 - dwb $d84c, %00001000 - dwb $d84c, %00010000 - dwb $d84c, %01000000 - dwb $d84c, %10000000 - - dwb $d84d, %00000100 ; bug catching contest timeup - dwb $d84d, %00000010 - dwb $d84d, %00000001 + dwb $d84c, %00000001 ; pokedex + dwb $d84c, %00000010 ; unown dex + dwb $d84c, %00001000 ; pokerus + dwb $d84c, %00010000 ; rocket signal on ch20 + dwb $d84c, %01000000 ; credits skip + dwb $d84c, %10000000 ; bug contest on + dwb $d84d, %00000100 ; bug contest timer + dwb $d84d, %00000010 ; rockets in radio tower + dwb $d84d, %00000001 ; bike shop call enabled (1024 bike steps reqd) dwb $d84d, %00010000 - dwb $d84d, %00100000 + dwb $d84d, %00100000 ; give pokerus; berry -> berry juice when trading? dwb $d84d, %01000000 - dwb $d84d, %10000000 + dwb $d84d, %10000000 ; rockets in mahogany - dwb $dbf5, %00000001 - dwb $dbf5, %00000010 + dwb $dbf5, %00000001 ; strength active + dwb $dbf5, %00000010 ; always on bike (cant surf) dwb $dbf5, %00000100 ; downhill (cycling road) - ; johto badges - dwb $d857, %00000001 ; $1b - dwb $d857, %00000010 ; $1c - dwb $d857, %00000100 ; $1d - dwb $d857, %00001000 ; $1e - dwb $d857, %00010000 ; $1f - dwb $d857, %00100000 ; $20 - dwb $d857, %01000000 ; $21 - dwb $d857, %10000000 ; $22 + dwb JohtoBadges, %00000001 ; zephyrbadge + dwb JohtoBadges, %00000010 ; hivebadge + dwb JohtoBadges, %00000100 ; plainbadge + dwb JohtoBadges, %00001000 ; fogbadge + dwb JohtoBadges, %00010000 ; mineralbadge + dwb JohtoBadges, %00100000 ; stormbadge + dwb JohtoBadges, %01000000 ; glacierbadge + dwb JohtoBadges, %10000000 ; risingbadge - ; kanto badges - dwb $d858, %00000001 ; $23 - dwb $d858, %00000010 ; $24 - dwb $d858, %00000100 ; $25 - dwb $d858, %00001000 ; $26 - dwb $d858, %00010000 ; $27 - dwb $d858, %00100000 ; $28 - dwb $d858, %01000000 ; $29 - dwb $d858, %10000000 ; $2a + dwb KantoBadges, %00000001 ; boulderbadge + dwb KantoBadges, %00000010 ; cascadebadge + dwb KantoBadges, %00000100 ; thunderbadge + dwb KantoBadges, %00001000 ; rainbowbadge + dwb KantoBadges, %00010000 ; soulbadge + dwb KantoBadges, %00100000 ; marshbadge + dwb KantoBadges, %01000000 ; volcanobadge + dwb KantoBadges, %10000000 ; earthbadge - dwb $def3, %00000001 - dwb $def3, %00000010 - dwb $def3, %00000100 - dwb $def3, %00001000 - dwb $def3, %00010000 - dwb $def3, %00100000 - dwb $def3, %01000000 - dwb $def3, %10000000 + ; unown sets + dwb $def3, %00000001 ; 1 + dwb $def3, %00000010 ; 2 + dwb $def3, %00000100 ; 3 + dwb $def3, %00001000 ; 4 + dwb $def3, %00010000 ; 5 + dwb $def3, %00100000 ; 6 + dwb $def3, %01000000 ; 7 + dwb $def3, %10000000 ; 8 - dwb $dca5, %00000001 - dwb $dca5, %00000010 - dwb $dca5, %00000100 - dwb $dca5, %00001000 - dwb $dca5, %00010000 - dwb $dca5, %00100000 - dwb $dca5, %01000000 - dwb $dca5, %10000000 + ; fly + dwb $dca5, %00000001 ; your house + dwb $dca5, %00000010 ; viridian pokecenter + dwb $dca5, %00000100 ; pallet + dwb $dca5, %00001000 ; viridian + dwb $dca5, %00010000 ; pewter + dwb $dca5, %00100000 ; cerulean + dwb $dca5, %01000000 ; rock tunnel + dwb $dca5, %10000000 ; vermilion + dwb $dca6, %00000001 ; lavender + dwb $dca6, %00000010 ; saffron + dwb $dca6, %00000100 ; celadon + dwb $dca6, %00001000 ; fuchsia + dwb $dca6, %00010000 ; cinnabar + dwb $dca6, %00100000 ; indigo plateau + dwb $dca6, %01000000 ; new bark + dwb $dca6, %10000000 ; cherrygrove + dwb $dca7, %00000001 ; violet + dwb $dca7, %00000100 ; azalea + dwb $dca7, %00001000 ; cianwood + dwb $dca7, %00010000 ; goldenrod + dwb $dca7, %00100000 ; olivine + dwb $dca7, %01000000 ; ecruteak + dwb $dca7, %10000000 ; mahogany + dwb $dca8, %00000001 ; lake of rage + dwb $dca8, %00000010 ; blackthorn + dwb $dca8, %00000100 ; silver cave + dwb $dca8, %00010000 ; unused - dwb $dca6, %00000001 - dwb $dca6, %00000010 - dwb $dca6, %00000100 - dwb $dca6, %00001000 - dwb $dca6, %00010000 - dwb $dca6, %00100000 - dwb $dca6, %01000000 - dwb $dca6, %10000000 - - dwb $dca7, %00000001 - dwb $dca7, %00000100 - dwb $dca7, %00001000 - dwb $dca7, %00010000 - dwb $dca7, %00100000 - dwb $dca7, %01000000 - dwb $dca7, %10000000 - - dwb $dca8, %00000001 - dwb $dca8, %00000010 - dwb $dca8, %00000100 - dwb $dca8, %00010000 - - dwb $dc9d, %00000001 + dwb $dc9d, %00000001 ; lucky number show dwb $d84d, %00001000 - dwb $dc1e, %00000001 + dwb $dc1e, %00000001 ; kurt making balls dwb $dc1e, %00000010 - dwb $dc1e, %00000100 - dwb $dc1e, %00001000 - dwb $dc1e, %00010000 - dwb $dc1e, %00100000 - dwb $dc1e, %01000000 - dwb $dc1e, %10000000 + dwb $dc1e, %00000100 ; special wilddata? + dwb $dc1e, %00001000 ; time capsule (24h wait) + dwb $dc1e, %00010000 ; all fruit trees + dwb $dc1e, %00100000 ; shuckle given + dwb $dc1e, %01000000 ; goldenrod underground merchant closed + dwb $dc1e, %10000000 ; fought in trainer hall today - dwb $dc1f, %00000001 - dwb $dc1f, %00000010 - dwb $dc1f, %00000100 - dwb $dc1f, %00001000 - dwb $dc1f, %00010000 - dwb $dc1f, %00100000 + dwb $dc1f, %00000001 ; mt moon square clefairy + dwb $dc1f, %00000010 ; union cave lapras + dwb $dc1f, %00000100 ; goldenrod underground haircut used + dwb $dc1f, %00001000 ; goldenrod mall happiness event floor05 person07 + dwb $dc1f, %00010000 ; tea in blues house + dwb $dc1f, %00100000 ; indigo plateau rival fight dwb $dc1f, %01000000 dwb $dc1f, %10000000 - dwb $dc20, %00000001 - dwb $dc20, %00000010 + dwb $dc20, %00000001 ; $60 + dwb $dc20, %00000010 ; goldenrod dept store sale is on - dwb $cfbc, %10000000 - dwb $d472, %00000001 ; 0 if boy, 1 if girl - dwb $dbf3, %00000100 + dwb $cfbc, %10000000 ; $62 - dwb $dc4c, %00000001 - dwb $dc4c, %00000010 - dwb $dc4c, %00000100 - dwb $dc4c, %00001000 - dwb $dc4c, %00010000 - dwb $dc4c, %00100000 - dwb $dc4c, %01000000 - dwb $dc4c, %10000000 + dwb $d472, %00000001 ; player is female - dwb $dc4d, %00000001 - dwb $dc4d, %00000010 - dwb $dc4d, %00000100 - dwb $dc4d, %00001000 - dwb $dc4d, %00010000 - dwb $dc4d, %00100000 - dwb $dc4d, %01000000 - dwb $dc4d, %10000000 + dwb $dbf3, %00000100 ; have gs ball after kurt examined it - dwb $dc4e, %00000001 - dwb $dc4e, %00000010 - dwb $dc4e, %00000100 - dwb $dc4e, %00001000 - dwb $dc4e, %00010000 - dwb $dc4e, %00100000 - dwb $dc4e, %01000000 - dwb $dc4e, %10000000 + ; rematches + dwb $dc4c, %00000001 ; jack + dwb $dc4c, %00000010 ; huey + dwb $dc4c, %00000100 ; gaven + dwb $dc4c, %00001000 ; beth + dwb $dc4c, %00010000 ; jose + dwb $dc4c, %00100000 ; reena + dwb $dc4c, %01000000 ; joey + dwb $dc4c, %10000000 ; wade + dwb $dc4d, %00000001 ; ralph + dwb $dc4d, %00000010 ; liz + dwb $dc4d, %00000100 ; anthony + dwb $dc4d, %00001000 ; todd + dwb $dc4d, %00010000 ; gina + dwb $dc4d, %00100000 ; arnie + dwb $dc4d, %01000000 ; alan + dwb $dc4d, %10000000 ; dana + dwb $dc4e, %00000001 ; chad + dwb $dc4e, %00000010 ; tully + dwb $dc4e, %00000100 ; brent + dwb $dc4e, %00001000 ; tiffany + dwb $dc4e, %00010000 ; vance + dwb $dc4e, %00100000 ; wilton + dwb $dc4e, %01000000 ; parry + dwb $dc4e, %10000000 ; erin - dwb $dc50, %00000001 - dwb $dc50, %00000010 - dwb $dc50, %00000100 - dwb $dc50, %00001000 - dwb $dc50, %00010000 - dwb $dc50, %00100000 - dwb $dc50, %01000000 - dwb $dc50, %10000000 + dwb $dc50, %00000001 ; beverly has nugget + dwb $dc50, %00000010 ; jose has star piece + dwb $dc50, %00000100 ; wade has item (see bittable1 $032b-e) + dwb $dc50, %00001000 ; gina has leaf stone + dwb $dc50, %00010000 ; alan has fire stone + dwb $dc50, %00100000 ; liz has thunderstone + dwb $dc50, %01000000 ; derek has nugget + dwb $dc50, %10000000 ; tully has water stone - dwb $dc51, %00000001 - dwb $dc51, %00000010 + dwb $dc51, %00000001 ; tiffany has pink bow + dwb $dc51, %00000010 ; wilton has item (see bittable1 $032f-31) dwb $dc54, %00000001 dwb $dc54, %00000010 @@ -51587,9 +51594,10 @@ Flags: ; 80462 dwb $dc56, %01000000 dwb $dc56, %10000000 - dwb $d45b, %00000100 - dwb $dc20, %00000100 - dwb $dc20, %00001000 ; $a1 + dwb $d45b, %00000100 ; female player has been transformed into male + + dwb $dc20, %00000100 ; dunsparce swarm + dwb $dc20, %00001000 ; yanma swarm ; 80648 INCBIN "baserom.gbc",$80648,$80730-$80648 From a7631774b41b7f87826668724bd6cc0951b64a48 Mon Sep 17 00:00:00 2001 From: padz Date: Tue, 9 Oct 2012 02:32:05 -0400 Subject: [PATCH 2/7] start work on audio engine --- constants.asm | 107 +++++++++- main.asm | 552 +++++++++++++++++++++++++++++++++++++++++++++++++- wram.asm | 126 ++++++++++++ 3 files changed, 782 insertions(+), 3 deletions(-) diff --git a/constants.asm b/constants.asm index 408cd884d..76d186b88 100644 --- a/constants.asm +++ b/constants.asm @@ -3005,4 +3005,109 @@ MOBILE_STUDIUM EQU 5 ; name length PLAYER_NAME_LENGTH EQU 8 -PKMN_NAME_LENGTH EQU 11 \ No newline at end of file +PKMN_NAME_LENGTH EQU 11 + +; music +MUSIC_NONE EQU 0 +MUSIC_TITLE EQU 1 +MUSIC_ROUTE_1 EQU 2 +MUSIC_ROUTE_3 EQU 3 +MUSIC_ROUTE_12 EQU 4 +MUSIC_MAGNET_TRAIN EQU 5 +MUSIC_KANTO_GYM_LEADER_BATTLE EQU 6 +MUSIC_KANTO_TRAINER_BATTLE EQU 7 +MUSIC_KANTO_WILD_BATTLE EQU 8 +MUSIC_POKEMON_CENTER EQU 9 +MUSIC_HIKER_ENCOUNTER EQU 10 +MUSIC_LASS_ENCOUNTER EQU 11 +MUSIC_OFFICER_ENCOUNTER EQU 12 +MUSIC_HEAL EQU 13 +MUSIC_LAVENDER_TOWN EQU 14 +MUSIC_ROUTE_2 EQU 15 +MUSIC_MT_MOON EQU 16 +MUSIC_SHOW_ME_AROUND EQU 17 +MUSIC_GAME_CORNER EQU 18 +MUSIC_BICYCLE EQU 19 +MUSIC_HALL_OF_FAME EQU 20 +MUSIC_VIRIDIAN_CITY EQU 21 +MUSIC_CELADON_CITY EQU 22 +MUSIC_TRAINER_VICTORY EQU 23 +MUSIC_WILD_VICTORY EQU 24 +MUSIC_GYM_VICTORY EQU 25 +MUSIC_MT_MOON_SQUARE EQU 26 +MUSIC_GYM EQU 27 +MUSIC_PALLET_TOWN EQU 28 +MUSIC_POKEMON_TALK EQU 29 +MUSIC_PROF_OAK EQU 30 +MUSIC_RIVAL_ENCOUNTER EQU 31 +MUSIC_RIVAL_AFTER EQU 32 +MUSIC_SURF EQU 33 +MUSIC_EVOLUTION EQU 34 +MUSIC_NATIONAL_PARK EQU 35 +MUSIC_CREDITS EQU 36 +MUSIC_AZALEA_TOWN EQU 37 +MUSIC_CHERRYGROVE_CITY EQU 38 +MUSIC_KIMONO_ENCOUNTER EQU 39 +MUSIC_UNION_CAVE EQU 40 +MUSIC_JOHTO_WILD_BATTLE EQU 41 +MUSIC_JOHTO_TRAINER_BATTLE EQU 42 +MUSIC_ROUTE_30 EQU 43 +MUSIC_ECRUTEAK_CITY EQU 44 +MUSIC_VIOLET_CITY EQU 45 +MUSIC_JOHTO_GYM_LEADER_BATTLE EQU 46 +MUSIC_CHAMPION_BATTLE EQU 47 +MUSIC_RIVAL_BATTLE EQU 48 +MUSIC_ROCKET_BATTLE EQU 49 +MUSIC_PROF_ELM EQU 50 +MUSIC_SLOWPOKE_WELL EQU 51 +MUSIC_ROUTE_29 EQU 52 +MUSIC_ROUTE_36 EQU 53 +MUSIC_SS_AQUA EQU 54 +MUSIC_YOUNGSTER_ENCOUNTER EQU 55 +MUSIC_BEAUTY_ENCOUNTER EQU 56 +MUSIC_ROCKET_ENCOUNTER EQU 57 +MUSIC_POKEMANIAC_ENCOUNTER EQU 58 +MUSIC_SAGE_ENCOUNTER EQU 59 +MUSIC_NEW_BARK_TOWN EQU 60 +MUSIC_GOLDENROD_CITY EQU 61 +MUSIC_VERMILION_CITY EQU 62 +MUSIC_POKEMON_CHANNEL EQU 63 +MUSIC_POKE_FLUTE_CHANNEL EQU 64 +MUSIC_TIN_TOWER EQU 65 +MUSIC_SPROUT_TOWER EQU 66 +MUSIC_BURNED_TOWER EQU 67 +MUSIC_LIGHTHOUSE EQU 68 +MUSIC_LAKE_OF_RAGE EQU 69 +MUSIC_INDIGO_PLATEAU EQU 70 +MUSIC_ROUTE_37 EQU 71 +MUSIC_ROCKET_HIDEOUT EQU 72 +MUSIC_DRAGONS_DEN EQU 73 +MUSIC_JOHTO_WILD_BATTLE_NIGHT EQU 74 +MUSIC_RUINS_OF_ALPH_RADIO EQU 75 +MUSIC_CAPTURE EQU 76 +MUSIC_ROUTE_26 EQU 77 +MUSIC_MOM EQU 78 +MUSIC_VICTORY_ROAD EQU 79 +MUSIC_POKEMON_LULLABY EQU 80 +MUSIC_POKEMON_MARCH EQU 81 +MUSIC_GS_OPENING EQU 82 +MUSIC_GS_OPENING_2 EQU 83 +MUSIC_MAIN_MENU EQU 84 +MUSIC_RUINS_OF_ALPH_INTERIOR EQU 85 +MUSIC_ROCKET_OVERTURE EQU 86 +MUSIC_DANCING_HALL EQU 87 +MUSIC_BUG_CATCHING_CONTEST_RANKING EQU 88 +MUSIC_BUG_CATCHING_CONTEST EQU 89 +MUSIC_LAKE_OF_RAGE_ROCKET_RADIO EQU 90 +MUSIC_PRINTER EQU 91 +MUSIC_POST_CREDITS EQU 92 +MUSIC_CLAIR EQU 93 +MUSIC_MOBILE_ADAPTER_MENU EQU 94 +MUSIC_MOBILE_ADAPTER EQU 95 +MUSIC_BUENAS_PASSWORD EQU 96 +MUSIC_MYSTICALMAN_ENCOUNTER EQU 97 +MUSIC_CRYSTAL_OPENING EQU 98 +MUSIC_BATTLE_TOWER_THEME EQU 99 +MUSIC_SUICUNE_BATTLE EQU 100 +MUSIC_BATTLE_TOWER_LOBBY EQU 101 +MUSIC_MOBILE_CENTER EQU 102 diff --git a/main.asm b/main.asm index 33131fac9..e77231e7a 100644 --- a/main.asm +++ b/main.asm @@ -1285,7 +1285,74 @@ Function3927: ; 3927 jp AddNTimes ; 392d -INCBIN "baserom.gbc",$392d,$4000 - $392d +INCBIN "baserom.gbc",$392d,$3b86 - $392d + +LoadMusicHeader: ; 3b86 +; store music header in ram +; input: +; a: bank +; de: address + ld [$ff00+$9d], a + ld [$2000], a ; bankswitch + ld a, [de] + ld [MusicHeaderBuffer], a + ld a, $3a ; manual bank restore + ld [$ff00+$9d], a + ld [$2000], a ; bankswitch + ret +; 3b97 + +StartMusic: ; 3b97 +; input: +; e = song number + push hl + push de + push bc + push af + ld a, [$ff00+$9d] ; save bank + push af + ld a, BANK(LoadMusic) + ld [$ff00+$9d], a + ld [$2000], a ; bankswitch + ld a, e ; song number + and a + jr z, .nomusic + call LoadMusic + jr .end +.nomusic + call SoundRestart +.end + pop af + ld [$ff00+$9d], a ; restore bank + ld [$2000], a + pop af + pop bc + pop de + pop hl + ret +; 3bbc + +INCBIN "baserom.gbc",$3bbc,$3c97 - $3bbc + +MaxVolume: ; 3c97 + ld a, $77 ; max + ld [Volume], a + ret +; 3c9d + +LowVolume: ; 3c9d + ld a, $33 ; 40% + ld [Volume], a + ret +; 3ca3 + +VolumeOff: ; 3ca3 + xor a + ld [Volume], a + ret +; 3ca8 + +INCBIN "baserom.gbc",$3ca8,$4000 - $3ca8 SECTION "bank1",DATA,BANK[$1] @@ -74217,7 +74284,488 @@ INCBIN "baserom.gbc",$E4000,$4000 SECTION "bank3A",DATA,BANK[$3A] -INCBIN "baserom.gbc",$E8000,$4000 +SoundRestart: ; e8000 +; restart sound operation +; clear all relevant registers + push hl + push de + push bc + push af + call MusicOff + ld hl, $ff24 ; channel control registers + xor a + ld [hli], a ; ff24 ; volume/vin + ld [hli], a ; ff25 ; stereo channels + ld a, $80 ; all channels on + ld [hli], a ; ff26 ; mono channels + + ld hl, $ff10 ; sound channel registers + ld e, $04 ; number of channels +.clearsound +; sound channel 1 2 3 4 + xor a + ld [hli], a ; $ff10, $ff15, $ff1a, $ff1f ; sweep = 0 + + ld [hli], a ; $ff11, $ff16, $ff1b, $ff20 ; length/wavepattern = 0 + ld a, $08 + ld [hli], a ; $ff12, $ff17, $ff1c, $ff21 ; envelope = 0 + xor a + ld [hli], a ; $ff13, $ff18, $ff1d, $ff22 ; frequency lo = 0 + ld a, $80 + ld [hli], a ; $ff14, $ff19, $ff1e, $ff23 ; restart sound (freq hi = 0) + dec e + jr nz, .clearsound + + ld hl, $c101 ; start of channel data + ld de, $01bf ; length ($ * 8 channels) +.clearchannels ; clear $c101-$c2bf + xor a + ld [hli], a + dec de + ld a, e + or d + jr nz, .clearchannels + ld a, $77 ; max + ld [Volume], a + call MusicOn + pop af + pop bc + pop de + pop hl + ret +; e803d + +INCBIN "baserom.gbc",$e803d,$e8051 - $e803d + +MusicOn: ; e8051 + ld a, $01 + ld [$c100], a + ret +; e8057 + +MusicOff: ; e8057 + xor a + ld [$c100], a + ret +; e805c + +INCBIN "baserom.gbc",$e805c,$e8b11 - $e805c + +StartChannel: ; e8b11 + call SetLRTracks + ld hl, $0003 + add hl, bc + set 0, [hl] ; channel on + ret +; e8b1b + +SetLRTracks: ; e8b1b +; input: +; bc = Channels ($c101) +; seems to be redundant since this is overwritten by stereo data later + push de + ld a, [CurMusicChannel] + and a, $03 ; bit 0-1 + ld e, a + ld d, $00 + call GetLRTracks ; hl = mono / stereo table + add hl, de ; + channel # + ld a, [hl] ; get result + ld hl, Channel1LR - Channel1 + add hl, bc + ld [hl], a ; set tracks + pop de + ret +; e8b30 + +LoadMusic: ; e8b30 +; load music + call MusicOff + ld hl, MusicID + ld [hl], e ; song number + inc hl + ld [hl], d ; MusicIDHi (always $00) + ld hl, Music + add hl, de ; three + add hl, de ; byte + add hl, de ; pointer + ld a, [hli] + ld [MusicBank], a + ld e, [hl] + inc hl + ld d, [hl] ; music header address + call GetByteFromMusicHeader ; store first byte of music header in [a] + rlca + rlca + and a, $03 ; get number of channels + inc a +.loop +; start playing channels + push af + call LoadChannel + call StartChannel + pop af + dec a + jr nz, .loop + xor a + ld [$c2b5], a + ld [$c2b8], a + ld [$c2b9], a + ld [$c2ba], a + ld [$c2bb], a + ld [$c2a0], a + ld [$c2a1], a + ld [$c2a2], a + ld [$c2a4], a + call MusicOn + ret +; e8b79 + +INCBIN "baserom.gbc",$e8b79,$e8d1b - $e8b79 + +LoadChannel: ; e8d1b +; prep channel for use + ; get pointer to current channel + call GetByteFromMusicHeader + inc de + and a, $07 ; bit 0-2 (current channel) + ld [CurMusicChannel], a + ld c, a + ld b, $00 + ld hl, ChannelPointers + add hl, bc + add hl, bc + ld c, [hl] + inc hl + ld b, [hl] ; bc = channel pointer + ld hl, $0003 + add hl, bc + res 0, [hl] ; channel off + call ChannelInit + ; load music pointer + ld hl, Channel1MusicAddress - Channel1 + add hl, bc + call GetByteFromMusicHeader + ld [hli], a + inc de + call GetByteFromMusicHeader + ld [hl], a + inc de + ; load music id + ld hl, Channel1MusicID - Channel1 + add hl, bc + ld a, [MusicIDLo] + ld [hli], a + ld a, [MusicIDHi] + ld [hl], a + ; load music bank + ld hl, Channel1MusicBank - Channel1 + add hl, bc + ld a, [MusicBank] + ld [hl], a + ret +; e8d5b + +ChannelInit: ; e8d5b +; make sure channel is clean +; set default tempo and note length in case nothing is loaded +; input: +; bc = channel struct pointer + push de + xor a + ld hl, $0000 + add hl, bc + ld e, $32 ; channel struct length +; clear channel struct +.loop + ld [hli], a + dec e + jr nz, .loop + ld hl, $0019 ; note length + add hl, bc + xor a + ld [hli], a + inc a + ld [hl], a ; default note length $100 + ld hl, $002d ; tempo + add hl, bc + ld [hl], a ; default tempo $01 (fast) + pop de + ret +; e8d76 + +GetByteFromMusicHeader: ; e8d76 +; input: +; de = address of current spot in music header +; output: +; a + ld a, [MusicBank] + call LoadMusicHeader + ld a, [MusicHeaderBuffer] + ret +; e8d80 + +INCBIN "baserom.gbc",$e8d80,$e8fc2 - $e8d80 + +GetLRTracks: ; e8fc2 +; gets the default sound l/r channels +; stores mono/stereo table in hl + ld a, [Options] + bit 5, a ; stereo + ; made redundant, could have had a purpose in gold + jr nz, .stereo + ld hl, MonoTracks + ret +.stereo + ld hl, StereoTracks + ret +; e8fd1 + +MonoTracks: ; e8fd1 +; bit corresponds to track # +; top nybble: right channel +; bottom nybble: left channel + db $11, $22, $44, $88 +; e8fd5 + +StereoTracks: ; e8fd5 +; seems to be wrong +; figure out what this is actually for +; might be default then clears one nybble based on song id + db $11, $22, $44, $88 +; e8fd9 + +ChannelPointers: ; e8fd9 +; mono channels + dw Channel1 + dw Channel2 + dw Channel3 + dw Channel4 +; stereo channels + dw Channel5 + dw Channel6 + dw Channel7 + dw Channel8 +; e8fe9 + +; identical in function to SoundRestart but cleaner +INCBIN "baserom.gbc",$e8fe9,$e900a - $e8fe9 + +PlayTrainerEncounterMusic: ; e900a +; input: e = trainer type + ; turn music off for one frame + xor a + ld [MusicLength], a ; $00 = infinite + push de + ld de, $0000 + call StartMusic + call DelayFrame + ; play new song + call MaxVolume + pop de + ld d, $00 + ld hl, TrainerEncounterMusic + add hl, de + ld e, [hl] + call StartMusic + ret +; e9027 + +TrainerEncounterMusic: ; e9027 + db MUSIC_HIKER_ENCOUNTER + db MUSIC_YOUNGSTER_ENCOUNTER ; falkner + db MUSIC_LASS_ENCOUNTER ; whitney + db MUSIC_YOUNGSTER_ENCOUNTER ; bugsy + db MUSIC_OFFICER_ENCOUNTER ; morty + db MUSIC_OFFICER_ENCOUNTER ; pryce + db MUSIC_LASS_ENCOUNTER ; jasmine + db MUSIC_OFFICER_ENCOUNTER ; chuck + db MUSIC_BEAUTY_ENCOUNTER ; clair + db MUSIC_RIVAL_ENCOUNTER ; rival1 + db MUSIC_HIKER_ENCOUNTER ; pokemon_prof + db MUSIC_HIKER_ENCOUNTER ; will + db MUSIC_HIKER_ENCOUNTER ; cal + db MUSIC_OFFICER_ENCOUNTER ; bruno + db MUSIC_HIKER_ENCOUNTER ; karen + db MUSIC_HIKER_ENCOUNTER ; koga + db MUSIC_OFFICER_ENCOUNTER ; champion + db MUSIC_YOUNGSTER_ENCOUNTER ; brock + db MUSIC_LASS_ENCOUNTER ; misty + db MUSIC_OFFICER_ENCOUNTER ; lt_surge + db MUSIC_ROCKET_ENCOUNTER ; scientist + db MUSIC_OFFICER_ENCOUNTER ; erika + db MUSIC_YOUNGSTER_ENCOUNTER ; youngster + db MUSIC_YOUNGSTER_ENCOUNTER ; schoolboy + db MUSIC_YOUNGSTER_ENCOUNTER ; bird_keeper + db MUSIC_LASS_ENCOUNTER ; lass + db MUSIC_LASS_ENCOUNTER ; janine + db MUSIC_HIKER_ENCOUNTER ; cooltrainerm + db MUSIC_BEAUTY_ENCOUNTER ; cooltrainerf + db MUSIC_BEAUTY_ENCOUNTER ; beauty + db MUSIC_POKEMANIAC_ENCOUNTER ; pokemaniac + db MUSIC_ROCKET_ENCOUNTER ; gruntm + db MUSIC_HIKER_ENCOUNTER ; gentleman + db MUSIC_BEAUTY_ENCOUNTER ; skier + db MUSIC_BEAUTY_ENCOUNTER ; teacher + db MUSIC_BEAUTY_ENCOUNTER ; sabrina + db MUSIC_YOUNGSTER_ENCOUNTER ; bug_catcher + db MUSIC_HIKER_ENCOUNTER ; fisher + db MUSIC_HIKER_ENCOUNTER ; swimmerm + db MUSIC_BEAUTY_ENCOUNTER ; swimmerf + db MUSIC_HIKER_ENCOUNTER ; sailor + db MUSIC_POKEMANIAC_ENCOUNTER ; super_nerd + db MUSIC_RIVAL_ENCOUNTER ; rival2 + db MUSIC_HIKER_ENCOUNTER ; guitarist + db MUSIC_HIKER_ENCOUNTER ; hiker + db MUSIC_HIKER_ENCOUNTER ; biker + db MUSIC_OFFICER_ENCOUNTER ; blaine + db MUSIC_POKEMANIAC_ENCOUNTER ; burglar + db MUSIC_HIKER_ENCOUNTER ; firebreather + db MUSIC_POKEMANIAC_ENCOUNTER ; juggler + db MUSIC_HIKER_ENCOUNTER ; blackbelt_t + db MUSIC_ROCKET_ENCOUNTER ; executivem + db MUSIC_YOUNGSTER_ENCOUNTER ; psychic_t + db MUSIC_LASS_ENCOUNTER ; picnicker + db MUSIC_YOUNGSTER_ENCOUNTER ; camper + db MUSIC_ROCKET_ENCOUNTER ; executivef + db MUSIC_SAGE_ENCOUNTER ; sage + db MUSIC_SAGE_ENCOUNTER ; medium + db MUSIC_HIKER_ENCOUNTER ; boarder + db MUSIC_HIKER_ENCOUNTER ; pokefanm + db MUSIC_KIMONO_ENCOUNTER ; kimono_girl + db MUSIC_LASS_ENCOUNTER ; twins + db MUSIC_BEAUTY_ENCOUNTER ; pokefanf + db MUSIC_HIKER_ENCOUNTER ; red + db MUSIC_RIVAL_ENCOUNTER ; blue + db MUSIC_HIKER_ENCOUNTER ; officer + db MUSIC_ROCKET_ENCOUNTER ; gruntf + db MUSIC_HIKER_ENCOUNTER ; mysticalman + db MUSIC_HIKER_ENCOUNTER + db MUSIC_HIKER_ENCOUNTER + db MUSIC_HIKER_ENCOUNTER +; e906e + +Music: ; e906e +; bank, address + dbw BANK(NoMusic), NoMusic + dbw $3a, $7808 + dbw $3b, $4000 + dbw $3b, $42ca + dbw $3b, $4506 + dbw $3b, $75f0 + dbw $3b, $4720 + dbw $3b, $49fa + dbw $3b, $506d + dbw $3b, $55c6 + dbw $3d, $7411 + dbw $3b, $579b + dbw $3b, $582d + dbw $3c, $4697 + dbw $3b, $772f + dbw $3b, $58dd + dbw $3b, $5b29 + dbw $3b, $5bd8 + dbw $3b, $5d6d + dbw $3b, $6119 + dbw $3c, $45bf + dbw $3d, $4000 + dbw $3d, $435b + dbw $3a, $7eab + dbw $3d, $4518 + dbw $3d, $462c + dbw $3d, $4815 + dbw $3d, $48ae + dbw $3d, $4b0c + dbw $3d, $4c9f + dbw $3d, $4dea + dbw $3d, $4f79 + dbw $3d, $5127 + dbw $3d, $518a + dbw $3c, $46e1 + dbw $3d, $54e8 + dbw $07, $731c + dbw $3d, $57e8 + dbw $3d, $5b03 + dbw $3d, $79b8 + dbw $3d, $5c60 + dbw $3d, $5dc5 + dbw $3d, $6096 + dbw $3b, $7c01 + dbw $3b, $72d0 + dbw $3c, $4000 + dbw $3a, $650d + dbw $3a, $69c1 + dbw $3a, $574f + dbw $3a, $5b6f + dbw $3a, $6040 + dbw $3a, $62be + dbw $3c, $4386 + dbw $3a, $54e9 + dbw $3a, $6d99 + dbw $3d, $66c3 + dbw $3b, $6e3e + dbw $3d, $74a2 + dbw $3a, $7de1 + dbw $3b, $635e + dbw $3a, $72d3 + dbw $3a, $7453 + dbw $3a, $7676 + dbw $3b, $645f + dbw $3d, $7b13 + dbw $3d, $6811 + dbw $3d, $6974 + dbw $3d, $6a99 + dbw $3b, $6569 + dbw $3b, $66c5 + dbw $3b, $6852 + dbw $3b, $694b + dbw $3b, $6b75 + dbw $3b, $6ce8 + dbw $3d, $605c + dbw $3b, $6dcb + dbw $3d, $4602 + dbw $3b, $6fb2 + dbw $3d, $6bf2 + dbw $3d, $6c72 + dbw $3d, $6d79 + dbw $3d, $6e23 + dbw $3d, $7055 + dbw $3d, $7308 + dbw $3d, $78fd + dbw $3a, $7d9e + dbw $3d, $766d + dbw $3b, $79bc + dbw $3b, $7b3e + dbw $3d, $7c16 + dbw $3b, $75b1 + dbw $3c, $47fd + dbw $33, $7d9e + dbw $07, $7a8d + dbw $5e, $401f + dbw $07, $7c87 + dbw $5e, $4153 + dbw $5e, $443b + dbw $5e, $46e8 + dbw $5e, $4889 + dbw $5e, $4b81 + dbw $5e, $548b + dbw $5e, $561d +; e91a3 + +NoMusic: ; e91a3 +; (nothing) + dbw $c0, NoMusic_Ch0 + dbw $01, NoMusic_Ch1 + dbw $02, NoMusic_Ch2 + dbw $03, NoMusic_Ch3 +NoMusic_Ch0: +NoMusic_Ch1: +NoMusic_Ch2: +NoMusic_Ch3: ; e91af + db $ff ; end +; e91b0 + +INCBIN "baserom.gbc",$e91b0,$ec000-$e91b0 SECTION "bank3B",DATA,BANK[$3B] diff --git a/wram.asm b/wram.asm index ef751a24c..bf6776f09 100644 --- a/wram.asm +++ b/wram.asm @@ -1,3 +1,87 @@ +SECTION "audio",BSS[$c100] +; channel structure: +; $00: music id lo +; $01: music id hi +; +; $03: channel flags? bit 0 = on/off +; +; $06: address of music data +; +; $19: note length lo +; $1a: note length hi +; $1b: lr tracks (bit corresponds to track #) +; +; $2d: tempo + +Channels: +Channel1: +Channel1MusicID: ; c101 + ds 2 +Channel1MusicBank: ; c103 + ds 1 +; $03 = channel flags? + ds 1 +; note/octave???? + ds 2 +Channel1MusicAddress: ; c107 + ds 2 + ds 17 +Channel1NoteLength: ; c11a + ds 2 +Channel1LR: ; c11c + ds 1 + ds 16 +Channel1Tempo: ; c12e + ds 1 + ds 3 + +Channel2: ; c133 + ds 50 +Channel3: ; c165 + ds 50 +Channel4: ; c197 + ds 50 + +StereoChannels: +Channel5: ; c1c9 + ds 50 +Channel6: ; c1fb + ds 50 +Channel7: ; c22d + ds 50 +Channel8: ; c25f + ds 50 + + +MusicHeaderBuffer: ; c298 + ds 1 +CurMusicChannel: ; c299 + ds 1 + +Volume: ; c29a +; corresponds to $ff24 +; Channel control / ON-OFF / Volume (R/W) +; bit 7 - Vin->SO2 ON/OFF +; bit 6-4 - SO2 output level (volume) (# 0-7) +; bit 3 - Vin->SO1 ON/OFF +; bit 2-0 - SO1 output level (volume) (# 0-7) + ds 1 + +MusicID: +MusicIDLo: ; c29d + ds 1 +MusicIDHi: ; c29e + ds 1 + +MusicBank: ; c29f + ds 1 + +MusicLength: ; c2a7 +; fades out when counter hits this value +; $00 = infinite + ds 1 + + SECTION "linkbattle",BSS[$c2dc] InLinkBattle: ; 0xc2dc @@ -63,6 +147,48 @@ BattleMonSpclAtk: ; c646 BattleMonSpclDef: ; c648 ds 2 +SECTION "Engine",BSS[$cfcc] +Options: ; cfcc +; bit 0-2: number of frames to delay when printing text +; fast 1; mid 3; slow 5 +; bit 3-4: unused +; bit 5: stereo off/on +; bit 6: battle style shift/set +; bit 7: battle scene off/on + ds 1 + +TextBoxFrame: ; cfce +; bits 0-2: textbox frame 0-7 + ds 1 + +GBPrinter: ; cfd0 +; bit 0-6: brightness +; lightest: $00 +; lighter: $20 +; normal: $40 (default) +; darker: $60 +; darkest: $7F + ds 1 + +Options2: ; cfd1 +; bit 1: menu account off/on + ds 1 + + +VramState: ; d0ed +; bit 0: overworld sprite updating on/off +; bit 6: something to do with text +; bit 7: on when surf initiates +; flickers when climbing waterfall + ds 1 + + +CurPartyMon: ; d109 +; contains which monster in your party +; is being dealt with at the moment +; 0-5 + ds 1 + SECTION "EnemyMon",BSS[$d204] EnemyMonSpecies: ; d204 From 5ba5a025c41f2cafdfd542c07f42de15b47a28aa Mon Sep 17 00:00:00 2001 From: padz Date: Tue, 9 Oct 2012 02:40:36 -0400 Subject: [PATCH 3/7] add breeding section to wram --- main.asm | 2 +- wram.asm | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/main.asm b/main.asm index e77231e7a..7752f9d01 100644 --- a/main.asm +++ b/main.asm @@ -51480,7 +51480,7 @@ Flags: ; 80462 ; $def5 %10000000 ; daycare 1 on dwb $def5, %01000000 ; monster 1 and 2 are compatible - ; $def5 %???????? ; egg is ready + ; $def5 %00100000 ; egg is ready dwb $def5, %00000001 ; monster 1 in daycare ; $df2c %10000000 = daycare 2 on diff --git a/wram.asm b/wram.asm index bf6776f09..55855461f 100644 --- a/wram.asm +++ b/wram.asm @@ -1378,3 +1378,52 @@ PartyMon5Nickname: ; 0xde6d ds 11 PartyMon6Nickname: ; 0xde78 ds 11 + +SECTION "Breeding",BSS[$def5] +BreedOssan: ; def5 +; bit 7: active +; bit 6: monsters are compatible +; bit 0: monster 1 in daycare + ds 1 + +BreedMon1: +BreedMon1Nick: ; def6 + ds 11 +BreedMon1OT: ; df01 + ds 11 +BreedMon1Stats: +Breedmon1Species: ; df0c + ds 1 + ds 31 + +BreedObasan: ; df2c +; bit 7: active +; bit 0: monster 2 in daycare + ds 1 + +StepsToEgg: ; df2d + ds 1 +DittoInDaycare: ; df2e +; z: yes +; nz: no + ds 1 + +BreedMon2: +BreedMon2Nick: ; df2f + ds 11 +BreedMon2OT: ; df3a + ds 11 +BreedMon2Stats: +BreedMon1Species: ; df45 + ds 1 + ds 31 + +EggNick: ; df65 +; EGG@ + ds 11 +EggOT: ; df70 + ds 11 +EggStats: +EggSpecies: ; df7b + ds 1 + ds 31 From 3383c45c2706c0a47b697f4e59583e03183b3ff8 Mon Sep 17 00:00:00 2001 From: padz Date: Tue, 9 Oct 2012 04:43:45 -0400 Subject: [PATCH 4/7] fixed problems with wram.asm, compiles now --- wram.asm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/wram.asm b/wram.asm index 55855461f..e27e9cf2b 100644 --- a/wram.asm +++ b/wram.asm @@ -1,4 +1,4 @@ -SECTION "audio",BSS[$c100] +SECTION "audio",BSS[$c101] ; channel structure: ; $00: music id lo ; $01: music id hi @@ -30,10 +30,10 @@ Channel1NoteLength: ; c11a ds 2 Channel1LR: ; c11c ds 1 - ds 16 + ds 17 Channel1Tempo: ; c12e ds 1 - ds 3 + ds 4 Channel2: ; c133 ds 50 @@ -52,6 +52,7 @@ Channel7: ; c22d Channel8: ; c25f ds 50 + ds 7 MusicHeaderBuffer: ; c298 ds 1 @@ -67,6 +68,8 @@ Volume: ; c29a ; bit 2-0 - SO1 output level (volume) (# 0-7) ds 1 + ds 2 + MusicID: MusicIDLo: ; c29d ds 1 @@ -76,6 +79,8 @@ MusicIDHi: ; c29e MusicBank: ; c29f ds 1 + ds 7 + MusicLength: ; c2a7 ; fades out when counter hits this value ; $00 = infinite @@ -832,6 +837,8 @@ SECTION "Status",BSS[$d84e] Money: ; d84e ds 3 + ds 6 + Badges: JohtoBadges: ; d857 ds 1 @@ -1380,9 +1387,10 @@ PartyMon6Nickname: ; 0xde78 ds 11 SECTION "Breeding",BSS[$def5] -BreedOssan: ; def5 +DaycareMan: ; def5 ; bit 7: active ; bit 6: monsters are compatible +; bit 5: egg ready ; bit 0: monster 1 in daycare ds 1 @@ -1396,7 +1404,7 @@ Breedmon1Species: ; df0c ds 1 ds 31 -BreedObasan: ; df2c +DaycareLady: ; df2c ; bit 7: active ; bit 0: monster 2 in daycare ds 1 From 811ea2071d59e856bd2c4e7bd9d54ca4a30f46ee Mon Sep 17 00:00:00 2001 From: padz Date: Tue, 9 Oct 2012 14:54:39 -0400 Subject: [PATCH 5/7] add dn macro --- constants.asm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/constants.asm b/constants.asm index 76d186b88..41f713b54 100644 --- a/constants.asm +++ b/constants.asm @@ -5,6 +5,10 @@ dwb: MACRO db \2 ENDM +dn: MACRO + db \1 << 4 + \2 + ENDM + callab: MACRO ld hl, \1 ld a, BANK(\1) From 5635c2027a67be28b1d2ce077a5762989bec18b2 Mon Sep 17 00:00:00 2001 From: padz Date: Thu, 11 Oct 2012 20:35:22 -0400 Subject: [PATCH 6/7] start sfx disasm --- constants.asm | 2 +- main.asm | 382 ++++++++++++++++++++++++++++++++++++++++++++++++-- wram.asm | 8 +- 3 files changed, 382 insertions(+), 10 deletions(-) diff --git a/constants.asm b/constants.asm index 41f713b54..616fbc586 100644 --- a/constants.asm +++ b/constants.asm @@ -3063,7 +3063,7 @@ MUSIC_CHAMPION_BATTLE EQU 47 MUSIC_RIVAL_BATTLE EQU 48 MUSIC_ROCKET_BATTLE EQU 49 MUSIC_PROF_ELM EQU 50 -MUSIC_SLOWPOKE_WELL EQU 51 +MUSIC_DARK_CAVE EQU 51 MUSIC_ROUTE_29 EQU 52 MUSIC_ROUTE_36 EQU 53 MUSIC_SS_AQUA EQU 54 diff --git a/main.asm b/main.asm index 7752f9d01..d132640b2 100644 --- a/main.asm +++ b/main.asm @@ -1332,7 +1332,41 @@ StartMusic: ; 3b97 ret ; 3bbc -INCBIN "baserom.gbc",$3bbc,$3c97 - $3bbc +INCBIN "baserom.gbc",$3bbc,$3c23 - $3bbc + +StartSFX: ; 3c23 +; not sure why this was written differently from StartMusic +; input: de = sfx id + push hl + push de + push bc + push af + call CheckSFX ; is something already playing? + jr nc, .asm_3c32 + ld a, [CurSFX] ; i guess sfx order is by priority + cp e + jr c, .quit +.asm_3c32 + ld a, [$ff00+$9d] ; save bank + push af + ld a, $3a ; music bank + ld [$ff00+$9d], a + ld [$2000], a ; bankswitch + ld a, e + ld [CurSFX], a + call LoadSFX + pop af + ld [$ff00+$9d], a ; restore bank + ld [$2000], a ; bankswitch +.quit + pop af + pop bc + pop de + pop hl + ret +; 3c4e + +INCBIN "baserom.gbc",$3c4e,$3c97-$3c4e MaxVolume: ; 3c97 ld a, $77 ; max @@ -1352,7 +1386,30 @@ VolumeOff: ; 3ca3 ret ; 3ca8 -INCBIN "baserom.gbc",$3ca8,$4000 - $3ca8 +INCBIN "baserom.gbc",$3ca8,$3dde - $3ca8 + +CheckSFX: ; 3dde +; returns carry if sfx channels are active + ld a, [$c1cc] ; 1 + bit 0, a + jr nz, .quit + ld a, [$c1fe] ; 2 + bit 0, a + jr nz, .quit + ld a, [$c230] ; 3 + bit 0, a + jr nz, .quit + ld a, [$c262] ; 4 + bit 0, a + jr nz, .quit + and a + ret +.quit + scf + ret +; 3dfe + +INCBIN "baserom.gbc",$3dfe,$4000 - $3dfe SECTION "bank1",DATA,BANK[$1] @@ -74295,9 +74352,9 @@ SoundRestart: ; e8000 ld hl, $ff24 ; channel control registers xor a ld [hli], a ; ff24 ; volume/vin - ld [hli], a ; ff25 ; stereo channels + ld [hli], a ; ff25 ; sfx channels ld a, $80 ; all channels on - ld [hli], a ; ff26 ; mono channels + ld [hli], a ; ff26 ; music channels ld hl, $ff10 ; sound channel registers ld e, $04 ; number of channels @@ -74421,7 +74478,104 @@ LoadMusic: ; e8b30 ret ; e8b79 -INCBIN "baserom.gbc",$e8b79,$e8d1b - $e8b79 +INCBIN "baserom.gbc",$e8b79,$e8c04 - $e8b79 + +LoadSFX: ; e8c04 +; clear channels if they aren't already + call MusicOff + ld hl, $c1cc ; ch5 on + bit 0, [hl] + jr z, .ch6 + res 0, [hl] + xor a + ld [$ff00+$11], a ; length/wavepattern = 0 + ld a, $08 + ld [$ff00+$12], a ; envelope = 0 + xor a + ld [$ff00+$13], a ; frequency lo = 0 + ld a, $80 + ld [$ff00+$14], a ; restart sound (freq hi = 0) + xor a + ld [$c29c], a ; ???? +.ch6 + ld hl, $c1fe ; ch6 on + bit 0, [hl] + jr z, .ch7 + res 0, [hl] + xor a + ld [$ff00+$16], a ; length/wavepattern = 0 + ld a, $08 + ld [$ff00+$17], a ; envelope = 0 + xor a + ld [$ff00+$18], a ; frequency lo = 0 + ld a, $80 + ld [$ff00+$19], a ; restart sound (freq hi = 0) +.ch7 + ld hl, $c230 ; ch7 on + bit 0, [hl] + jr z, .ch8 + res 0, [hl] + xor a + ld [$ff00+$1b], a ; length/wavepattern = 0 + ld a, $08 + ld [$ff00+$1c], a ; envelope = 0 + xor a + ld [$ff00+$1d], a ; frequency lo = 0 + ld a, $80 + ld [$ff00+$1e], a ; restart sound (freq hi = 0) +.ch8 + ld hl, $c262 ; ch8 on + bit 0, [hl] + jr z, .chscleared + res 0, [hl] + xor a + ld [$ff00+$20], a ; length/wavepattern = 0 + ld a, $08 + ld [$ff00+$21], a ; envelope = 0 + xor a + ld [$ff00+$22], a ; frequency lo = 0 + ld a, $80 + ld [$ff00+$23], a ; restart sound (freq hi = 0) + xor a + ld [$c2a0], a + ld [$c2a1], a +.chscleared +; start reading sfx header for # chs + ld hl, MusicID + ld [hl], e + inc hl + ld [hl], d + ld hl, SFX + add hl, de ; three + add hl, de ; byte + add hl, de ; pointers + ld a, [hli] + ld [MusicBank], a ; get bank + ld e, [hl] ; get address + inc hl + ld d, [hl] + call GetByteFromMusicHeader ; get # channels + rlca + rlca + and a, $03 ; bit 0-1 + inc a ; # channels -> # loops +.startchannels + push af + call LoadChannel ; bc = current channel + ld hl, $0003 + add hl, bc + set 3, [hl] ; not sure what bit 3 does + call StartChannel + pop af + dec a + jr nz, .startchannels + call MusicOn + xor a + ld [$c2b6], a + ret +; e8ca6 + +INCBIN "baserom.gbc",$e8ca6,$e8d1b - $e8ca6 LoadChannel: ; e8d1b ; prep channel for use @@ -74536,12 +74690,12 @@ StereoTracks: ; e8fd5 ; e8fd9 ChannelPointers: ; e8fd9 -; mono channels +; music channels dw Channel1 dw Channel2 dw Channel3 dw Channel4 -; stereo channels +; sfx channels dw Channel5 dw Channel6 dw Channel7 @@ -74765,7 +74919,219 @@ NoMusic_Ch3: ; e91af db $ff ; end ; e91b0 -INCBIN "baserom.gbc",$e91b0,$ec000-$e91b0 +INCBIN "baserom.gbc",$e91b0,$e927c-$e91b0 + +SFX: ; e927c + dbw $3c, $4b3f ; dex fanfare 50-79 + dbw $3c, $4c2f ; item + dbw $3c, $4c89 ; caught mon + dbw $3c, $4941 ; pokeballs placed on table + dbw $3c, $4947 ; potion + dbw $3c, $494a ; full heal + dbw $3c, $494d ; menu + dbw $3c, $4950 ; read text + dbw $3c, $4950 ; read text + dbw $3c, $4bd5 ; dex fanfare 20-49 + dbw $3c, $4cea ; dex fanfare 80-109 + dbw $3c, $4953 ; poison + dbw $3c, $4956 ; got safari balls + dbw $3c, $4959 ; boot pc + dbw $3c, $495c ; shut down pc + dbw $3c, $495f ; choose pc option + dbw $3c, $4962 ; bide / escape rope + dbw $3c, $4965 ; push button + dbw $3c, $4968 ; second part of itemfinder + dbw $3c, $496b ; warp to + dbw $3c, $496e ; warp from + dbw $3c, $4971 ; change dex mode + dbw $3c, $4974 ; jump over ledge + dbw $3c, $4977 ; grass rustle + dbw $3c, $497a ; fly + dbw $3c, $497d ; wrong + dbw $3c, $4983 ; squeak + dbw $3c, $4986 ; strength + dbw $3c, $4989 ; boat + dbw $3c, $498f ; wall open + dbw $3c, $4992 ; place puzzle piece down + dbw $3c, $4995 ; enter door + dbw $3c, $4998 ; switch pokemon + dbw $3c, $499e ; score tally? ; sounds like something out of game corner + dbw $3c, $49a4 ; buy/sell + dbw $3c, $49ad ; exit building + dbw $3c, $49aa ; bump + dbw $3c, $49b0 ; save + dbw $3c, $49f8 ; pokeflute + dbw $3c, $49fb ; elevator end + dbw $3c, $49fe ; throw ball + dbw $3c, $4a04 ; smokescreen + dbw $3c, $4a0a ; ; something skidding on water? + dbw $3c, $4a10 ; run + dbw $3c, $4a13 ; slot machine start + dbw $3c, $4dbe ; fanfare + dbw $3c, $4a3d ; peck + dbw $3c, $4a40 ; kinesis + dbw $3c, $4a43 ; lick + dbw $3c, $4a46 ; pound + dbw $3c, $4a49 ; move puzzle piece + dbw $3c, $4a4c ; comet punch + dbw $3c, $4a4f ; mega punch + dbw $3c, $4a52 ; scratch + dbw $3c, $4a55 ; vicegrip + dbw $3c, $4a58 ; razor wind + dbw $3c, $4a5b ; cut + dbw $3c, $4a5e ; wing attack + dbw $3c, $4a61 ; whirlwind + dbw $3c, $4a64 ; bind + dbw $3c, $4a67 ; vine whip + dbw $3c, $4a6a ; double kick + dbw $3c, $4a6d ; mega kick + dbw $3c, $4a70 ; headbutt + dbw $3c, $4a73 ; horn attack + dbw $3c, $4a76 ; tackle + dbw $3c, $4a79 ; poison sting + dbw $3c, $4a7c ; poisonpowder + dbw $3c, $4a7f ; doubleslap + dbw $3c, $4a82 ; bite + dbw $3c, $4a88 ; jump kick + dbw $3c, $4a8b ; stomp + dbw $3c, $4a8e ; tail whip + dbw $3c, $4a91 ; karate chop + dbw $3c, $4a94 ; submission + dbw $3c, $4a97 ; water gun + dbw $3c, $4a9d ; swords dance + dbw $3c, $4aa0 ; thunder + dbw $3c, $4aa3 ; supersonic + dbw $3c, $4aac ; leer + dbw $3c, $4ab5 ; ember + dbw $3c, $4abb ; bubblebeam + dbw $3c, $4ac4 ; hydro pump + dbw $3c, $4aca ; surf + dbw $3c, $4ad3 ; psybeam + dbw $3c, $4adc ; leech seed + dbw $3c, $4ae5 ; thundershock + dbw $3c, $4aee ; psychic + dbw $3c, $4af7 ; screech + dbw $3c, $4afd ; bone club + dbw $3c, $4b03 ; sharpen + dbw $3c, $4b09 ; egg bomb + dbw $3c, $4b12 ; sing + dbw $3c, $4b18 ; sky attack + dbw $3c, $4b21 ; hyper beam + dbw $3c, $4b24 ; shine + dbw $3c, $4a1c ; + dbw $3c, $4a1f ; $60 + dbw $3c, $4a22 ; tap + dbw $3c, $4a25 ; tap + dbw $3c, $4a28 ; burn ; that is not a burn + dbw $3c, $4a2b ; + dbw $3c, $4a2e ; similar to $60 + dbw $3c, $4a31 ; get coin from slots + dbw $3c, $4a34 ; pay day + dbw $3c, $4a3a ; metronome + dbw $3c, $4a19 ; call + dbw $3c, $4b2d ; hang up + dbw $3c, $4b30 ; no signal + dbw $3c, $4b2a ; sandstorm + dbw $3c, $4b33 ; elevator + dbw $3c, $52b4 ; protect + dbw $3c, $52f6 ; sketch + dbw $3c, $5314 ; rain dance + dbw $3c, $5334 ; aeroblast + dbw $3c, $5352 ; spark + dbw $3c, $5360 ; curse + dbw $3c, $537d ; rage + dbw $3c, $539c ; thief + dbw $3c, $53b0 ; thief + dbw $3c, $53ca ; spider web + dbw $3c, $53f7 ; mind reader + dbw $3c, $541d ; nighmare + dbw $3c, $5453 ; snore + dbw $3c, $5469 ; sweet kiss + dbw $3c, $547f ; sweet kiss + dbw $3c, $54a5 ; belly drum + dbw $3c, $54ba ; + dbw $3c, $54d0 ; sludge bomb + dbw $3c, $54f5 ; foresight + dbw $3c, $5515 ; spite + dbw $3c, $553a ; outrage + dbw $3c, $554d ; perish song + dbw $3c, $5570 ; giga drain + dbw $3c, $55b4 ; attract + dbw $3c, $55cc ; kinesis + dbw $3c, $55de ; zap cannon + dbw $3c, $55ef ; mean look + dbw $3c, $5621 ; heal bell + dbw $3c, $5637 ; return + dbw $3c, $5653 ; exp bar + dbw $3c, $567f ; milk drink + dbw $3c, $569f ; present + dbw $3c, $56b9 ; morning sun + dbw $3c, $4b3f ; level up + dbw $3c, $4b86 ; key item + dbw $3c, $4d56 ; fanfare + dbw $3c, $4dc7 ; register phone # + dbw $3c, $4e26 ; 3rd place + dbw $3c, $4e66 ; get egg from daycare man + dbw $3c, $4e66 ; get egg from daycare lady + dbw $3c, $4edc ; move deleted + dbw $3c, $4f5e ; 2nd place + dbw $3c, $4fe2 ; 1st place + dbw $3c, $5069 ; choose a card + dbw $3c, $5104 ; get tm + dbw $3c, $517d ; get badge + dbw $3c, $5236 ; quit slots + dbw $3c, $5775 ; nothing + dbw $3c, $5878 ; dex fanfare <20 + dbw $3c, $58d2 ; dex fanfare 140-169 + dbw $3c, $5951 ; dex fanfare 170-199 + dbw $3c, $59d6 ; dex fanfare 200-229 + dbw $3c, $5a66 ; dex fanfare >=230 + dbw $3c, $5784 ; evolved + dbw $3c, $579b ; master ball + dbw $3c, $57c0 ; egg crack + dbw $3c, $57d9 ; charizard fireball (gs intro) + dbw $3c, $57ff ; pokemon appears (gs intro) + dbw $3c, $5818 ; flash + dbw $3c, $5846 ; game freak logo + dbw $3c, $5b33 ; not very effective + dbw $3c, $5b40 ; damage + dbw $3c, $5b50 ; super effective + dbw $3c, $5b63 ; ball bounce + dbw $3c, $56df ; moonlight + dbw $3c, $56fd ; encore + dbw $3c, $5721 ; beat up + dbw $3c, $574c ; batom pass + dbw $3c, $4944 ; ball wiggle + dbw $3c, $5734 ; sweet scent + dbw $3c, $5bb3 ; sweet scent + dbw $3c, $5bec ; hit end of exp bar + dbw $3c, $5c10 ; give trademon + dbw $3c, $5c3e ; get trademon + dbw $3c, $5c6c ; train arrived + dbw $3c, $675b ; stop slot + dbw $3c, $5cb4 ; 2 boops + dbw $3c, $6769 ; glass ting + dbw $3c, $6773 ; 2 glass ting + dbw $5e, $582d ; intro unown 1 + dbw $5e, $583e ; intro unown 2 + dbw $5e, $584f ; intro unown 3 + dbw $5e, $586e ; boop + dbw $5e, $5888 ; game freak ditto transform + dbw $5e, $58a0 ; intro suicune 1 + dbw $5e, $58aa ; intro pichu + dbw $5e, $58c0 ; intro suicune 2 + dbw $5e, $58f4 ; intro suicune 3 + dbw $5e, $5907 ; game freak ditto bounce + dbw $5e, $591d ; intro suicune 4 + dbw $5e, $5942 ; game freak presents + dbw $5e, $5961 ; tingle + dbw $3c, $5cd0 ; sand? + dbw $5e, $597c ; two pc beeps + dbw $5e, $5992 ; 4 note ditty + dbw $5e, $59cb ; twinkle +; e94e9 + +INCBIN "baserom.gbc",$e94e9,$ebfc3 - $e94e9 SECTION "bank3B",DATA,BANK[$3B] diff --git a/wram.asm b/wram.asm index e27e9cf2b..1a215ead1 100644 --- a/wram.asm +++ b/wram.asm @@ -42,7 +42,7 @@ Channel3: ; c165 Channel4: ; c197 ds 50 -StereoChannels: +SFXChannels: Channel5: ; c1c9 ds 50 Channel6: ; c1fb @@ -85,6 +85,12 @@ MusicLength: ; c2a7 ; fades out when counter hits this value ; $00 = infinite ds 1 + + ds 24 + +CurSFX: ; c2bf +; id of sfx currently playing + ds 1 SECTION "linkbattle",BSS[$c2dc] From 2369bd7ed255e92d8b925e5d8cc07215f0a279ee Mon Sep 17 00:00:00 2001 From: padz Date: Thu, 11 Oct 2012 23:12:42 -0400 Subject: [PATCH 7/7] add missing instruction --- main.asm | 8 +++++--- wram.asm | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/main.asm b/main.asm index d132640b2..bc9f50141 100644 --- a/main.asm +++ b/main.asm @@ -74497,6 +74497,7 @@ LoadSFX: ; e8c04 ld [$ff00+$14], a ; restart sound (freq hi = 0) xor a ld [$c29c], a ; ???? + ld [$ff00+$10], a ; sweep = 0 .ch6 ld hl, $c1fe ; ch6 on bit 0, [hl] @@ -74516,6 +74517,7 @@ LoadSFX: ; e8c04 jr z, .ch8 res 0, [hl] xor a + ld [$ff00+$1a], a ; sound mode #3 off ld [$ff00+$1b], a ; length/wavepattern = 0 ld a, $08 ld [$ff00+$1c], a ; envelope = 0 @@ -74629,19 +74631,19 @@ ChannelInit: ; e8d5b xor a ld hl, $0000 add hl, bc - ld e, $32 ; channel struct length + ld e, Channel2 - Channel1 ; channel struct length ; clear channel struct .loop ld [hli], a dec e jr nz, .loop - ld hl, $0019 ; note length + ld hl, Channel1NoteLength - Channel1 add hl, bc xor a ld [hli], a inc a ld [hl], a ; default note length $100 - ld hl, $002d ; tempo + ld hl, Channel1Tempo - Channel1 add hl, bc ld [hl], a ; default tempo $01 (fast) pop de diff --git a/wram.asm b/wram.asm index 1a215ead1..7eb8d7044 100644 --- a/wram.asm +++ b/wram.asm @@ -86,7 +86,7 @@ MusicLength: ; c2a7 ; $00 = infinite ds 1 - ds 24 + ds 23 CurSFX: ; c2bf ; id of sfx currently playing