shithub: pokecrystal

Download patch

ref: 5635c2027a67be28b1d2ce077a5762989bec18b2
parent: 811ea2071d59e856bd2c4e7bd9d54ca4a30f46ee
author: padz <yenatch@github.com>
date: Thu Oct 11 16:35:22 EDT 2012

start sfx disasm

--- a/constants.asm
+++ b/constants.asm
@@ -3063,7 +3063,7 @@
 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
--- a/main.asm
+++ b/main.asm
@@ -1332,8 +1332,42 @@
 	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
 	ld [Volume], a
@@ -1352,8 +1386,31 @@
 	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]
 
 INCBIN "baserom.gbc",$4000,$617c - $4000
@@ -74295,9 +74352,9 @@
 	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,8 +74478,105 @@
 	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
 	; get pointer to current channel
@@ -74536,12 +74690,12 @@
 ; 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 @@
 	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]
 
--- a/wram.asm
+++ b/wram.asm
@@ -42,7 +42,7 @@
 Channel4: ; c197
 	ds 50
 
-StereoChannels:
+SFXChannels:
 Channel5: ; c1c9
 	ds 50
 Channel6: ; c1fb
@@ -84,6 +84,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
 
 
--