shithub: pokecrystal

Download patch

ref: a7631774b41b7f87826668724bd6cc0951b64a48
parent: 99b86cdd8f2951cd540bf3563b7559e036e2c715
author: padz <yenatch@github.com>
date: Mon Oct 8 22:32:05 EDT 2012

start work on audio engine

--- a/constants.asm
+++ b/constants.asm
@@ -3005,4 +3005,109 @@
 
 ; 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
--- a/main.asm
+++ b/main.asm
@@ -1285,8 +1285,75 @@
 	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]
 
 INCBIN "baserom.gbc",$4000,$617c - $4000
@@ -74217,7 +74284,488 @@
 
 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]
 
--- 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
@@ -62,6 +146,48 @@
 	ds 2
 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]
 
--