shithub: pokered

Download patch

ref: a36e090d43de2f66b26616e3c46f0da8f7d52466
parent: 2e376fecabd5216d6358c03789e9903b7cb1bd19
author: IIMarckus <iimarckus@gmail.com>
date: Fri Oct 17 18:47:31 EDT 2014

Add parts of the Safari Zone entrance script from Yellow.

--- /dev/null
+++ b/scripts/safarizoneentrance-yellow.asm
@@ -1,0 +1,257 @@
+.xf1f77
+	ld hl,.ForJust500Text
+	call PrintText
+	ld a,$13
+	ld [wd125],a
+	call DisplayTextBoxID
+	call YesNoChoice
+	ld a,[wCurrentMenuItem]
+	and a
+	jp nz,.PleaseComeAgain
+	ld hl,$d346 ; yellow d346
+	ld a,[hli]
+	or [hl]
+	inc hl
+	or [hl]
+	jr nz,.xf1f9f
+.xf1f98
+	call .xf20ce
+	jr c,.CantPayWalkDown
+	jr .xf1ff2
+
+.xf1f9f
+	xor a
+	ld [$ff9f],a
+	ld a,$05
+	ld [$ffa0],a
+	ld a,$00
+	ld [$ffa1],a
+	call HasEnoughMoney
+	jr nc,.success
+	ld hl,.NotEnoughMoneyText
+	call PrintText
+	call .xf2077
+	jr c,.CantPayWalkDown
+	jr .xf1ff2
+
+.success
+	xor a
+	ld [wSubtrahend],a
+	ld a,$05
+	ld [wSubtrahend+1],a
+	ld a,$00
+	ld [wSubtrahend+2],a
+	ld hl,wTrainerFacingDirection
+	ld de,wPlayerMoney + 2
+	ld c,3
+	predef SubBCDPredef
+	ld a,$b2
+	call $3736
+	call $373e
+	ld a,$13
+	ld [wd125],a
+	call DisplayTextBoxID
+	ld hl,.MakePaymentText
+	call PrintText
+	ld a,30
+	ld hl,(502 / $100) << 8 | (502 % $100)
+.xf1ff2
+	ld [W_NUMSAFARIBALLS],a
+	ld a,h
+	ld [wSafariSteps],a
+	ld a,l
+	ld [wSafariSteps + 1],a
+	ld a,$40
+	ld c,3
+	call SafariZoneEntranceAutoWalk
+	ld hl,wd790
+	set 7,[hl]
+	res 6,[hl]
+	ld a,3
+	ld [W_SAFARIZONEENTRANCECURSCRIPT],a
+	jr .done
+
+.PleaseComeAgain
+	ld hl,.PleaseComeAgainText
+	call PrintText
+.CantPayWalkDown
+	ld a,$80
+	ld c,1
+	call SafariZoneEntranceAutoWalk
+	ld a,4
+	ld [W_SAFARIZONEENTRANCECURSCRIPT],a
+.done
+	ret
+
+.ForJust500Text
+	TX_FAR SafariZoneEntranceText_9e6e4
+	db "@"
+
+.MakePaymentText
+	TX_FAR SafariZoneEntranceText_9e747
+	db $b
+	TX_FAR _SafariZoneEntranceText_75360
+	db "@"
+
+.PleaseComeAgainText
+	TX_FAR _SafariZoneEntranceText_75365
+	db "@"
+
+.NotEnoughMoneyText
+	TX_FAR _SafariZoneEntranceText_7536a
+	db "@"
+
+.SafariZoneEntranceText2
+	ld hl,.FirstTimeQuestionText
+	call PrintText
+	call YesNoChoice
+	ld a,[wCurrentMenuItem]
+	and a
+	ld hl,.RegularText
+	jr nz,.Explanation
+	ld hl,.ExplanationText
+.Explanation
+	call PrintText
+	ret
+
+.FirstTimeQuestionText
+	TX_FAR _SafariZoneEntranceText_753e6
+	db "@"
+
+.ExplanationText
+	TX_FAR _SafariZoneEntranceText_753eb
+	db "@"
+
+.RegularText
+	TX_FAR _SafariZoneEntranceText_753f0
+	db "@"
+
+SafariZoneEntranceAutoWalk:
+	push af
+	ld b,0
+	ld a,c
+	ld [wSimulatedJoypadStatesIndex],a
+	ld hl,wSimulatedJoypadStatesEnd
+	pop af
+	call FillMemory
+	jp StartSimulatingJoypadStates
+
+.xf2077
+	ld hl,$d346
+	ld de,$ff9f
+	ld bc,3
+	call $1b
+	xor a
+	ld [$ffa2],a
+	ld [$ffa3],a
+	ld a,$17
+	ld [$ffa4],a
+	ld a,$d
+	call $3eb4
+	ld a,[$ffa4]
+	call .xf211e
+	pop af
+	ld hl,$d346
+	xor a
+	ld bc,3
+	call $166e
+	ld hl,.OhAllRightText
+	call $3c46
+	ld a,$13
+	ld a,[$d124]
+	call $3010
+	ld hl,.CantGive30BallsText
+	call PrintText
+	pop af
+	inc a
+	jr z,.xf20bd
+	cp $1d
+	jr c,.xf20bf
+.xf20bd
+	ld a,$1d
+.xf20bf
+	ld hl,$1f6
+	and a
+	ret
+
+.OhAllRightText
+	TX_FAR _SafariZoneLowCostText1
+	db "@"
+
+.CantGive30BallsText
+	TX_FAR _SafariZoneLowCostText2
+	db "@"
+
+.xf20ce
+	ld hl,$d70c
+	ld a,[hl]
+	push af
+	inc [hl]
+	ld e,a
+	ld d,0
+	ld hl,.lowcosttextpointers
+	add hl,de
+	add hl,de
+	ld a,[hli]
+	ld h,[hl]
+	ld l,a
+	call PrintText
+	pop af
+	cp 3
+	jr z,.next
+	scf
+	ret
+
+.next
+	ld hl,.xf20f6
+	call $3c46
+	ld a,1
+	ld hl,$01f6
+	and a
+	ret
+
+.xf20f6
+	TX_FAR _SafariZoneLowCostText3
+	db $b
+	TX_FAR _SafariZoneLowCostText4
+	db "@"
+
+.lowcosttextpointers
+	dw .xf210a
+	dw .xf210f
+	dw .xf2114
+	dw .xf2119
+	dw .xf2119
+
+.xf210a
+	TX_FAR _SafariZoneLowCostText5
+	db "@"
+
+.xf210f
+	TX_FAR _SafariZoneLowCostText6
+	db "@"
+
+.xf2114
+	TX_FAR _SafariZoneLowCostText7
+	db "@"
+
+.xf2119
+	TX_FAR _SafariZoneLowCostText8
+	db "@"
+
+.xf211e
+	push hl
+	ld c,a
+	and $f
+	ld l,a
+	ld h,0
+	ld a,c
+	and $f0
+	swap a
+	ld bc,$a
+	call $3a74
+	ld a,l
+	pop hl
+	ret
+
+.xf2133
--- a/scripts/safarizoneentrance.asm
+++ b/scripts/safarizoneentrance.asm
@@ -5,16 +5,16 @@
 	jp CallFunctionInTable
 
 SafariZoneEntranceScriptPointers: ; 751d9 (1d:51d9)
-	dw SafariZoneEntranceScript0
-	dw SafariZoneEntranceScript1
-	dw SafariZoneEntranceScript2
-	dw SafariZoneEntranceScript3
-	dw SafariZoneEntranceScript4
-	dw SafariZoneEntranceScript5
-	dw SafariZoneEntranceScript6
+	dw .SafariZoneEntranceScript0
+	dw .SafariZoneEntranceScript1
+	dw .SafariZoneEntranceScript2
+	dw .SafariZoneEntranceScript3
+	dw .SafariZoneEntranceScript4
+	dw .SafariZoneEntranceScript5
+	dw .SafariZoneEntranceScript6
 
-SafariZoneEntranceScript0: ; 751e7 (1d:51e7)
-	ld hl, CoordsData_75221
+.SafariZoneEntranceScript0
+	ld hl, .CoordsData_75221
 	call ArePlayerCoordsInArray
 	ret nc
 	ld a, $3
@@ -35,7 +35,7 @@
 .asm_7520f
 	ld a, $10
 	ld c, $1
-	call SafariZoneEntranceScript_752a3
+	call SafariZoneEntranceAutoWalk
 	ld a, $f0
 	ld [wJoyIgnore], a
 	ld a, $1
@@ -42,15 +42,15 @@
 	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
 	ret
 
-CoordsData_75221: ; 75221 (1d:5221)
+.CoordsData_75221: ; 75221 (1d:5221)
 	db $02,$03
 	db $02,$04
 	db $FF
 
-SafariZoneEntranceScript1: ; 75226 (1d:5226)
+.SafariZoneEntranceScript1
 	call SafariZoneEntranceScript_752b4
 	ret nz
-SafariZoneEntranceScript2: ; 7522a (1d:522a)
+.SafariZoneEntranceScript2
 	xor a
 	ld [hJoyHeld], a
 	ld [wJoyIgnore], a
@@ -62,7 +62,7 @@
 	ld [wJoyIgnore], a
 	ret
 
-SafariZoneEntranceScript3: ; 75240 (1d:5240)
+.SafariZoneEntranceScript3
 	call SafariZoneEntranceScript_752b4
 	ret nz
 	xor a
@@ -71,7 +71,7 @@
 	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
 	ret
 
-SafariZoneEntranceScript5: ; 7524e (1d:524e)
+.SafariZoneEntranceScript5
 	ld a, $4
 	ld [wd528], a
 	ld hl, wd790
@@ -89,7 +89,7 @@
 	ld [W_NUMSAFARIBALLS], a
 	ld a, $80
 	ld c, $3
-	call SafariZoneEntranceScript_752a3
+	call SafariZoneEntranceAutoWalk
 	ld a, $4
 	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
 	jr .asm_75286 ; 0x7527d $7
@@ -100,7 +100,7 @@
 .asm_75286
 	ret
 
-SafariZoneEntranceScript4: ; 75287 (1d:5287)
+.SafariZoneEntranceScript4
 	call SafariZoneEntranceScript_752b4
 	ret nz
 	xor a
@@ -109,7 +109,7 @@
 	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
 	ret
 
-SafariZoneEntranceScript6: ; 75295 (1d:5295)
+.SafariZoneEntranceScript6
 	call SafariZoneEntranceScript_752b4
 	ret nz
 	call Delay3
@@ -117,128 +117,127 @@
 	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
 	ret
 
-SafariZoneEntranceScript_752a3: ; 752a3 (1d:52a3)
+SafariZoneEntranceAutoWalk:
 	push af
-	ld b, $0
-	ld a, c
-	ld [wSimulatedJoypadStatesIndex], a
-	ld hl, wSimulatedJoypadStatesEnd
+	ld b,0
+	ld a,c
+	ld [wSimulatedJoypadStatesIndex],a
+	ld hl,wSimulatedJoypadStatesEnd
 	pop af
 	call FillMemory
 	jp StartSimulatingJoypadStates
 
-SafariZoneEntranceScript_752b4: ; 752b4 (1d:52b4)
+SafariZoneEntranceScript_752b4:
 	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret
 
 SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9)
-	dw SafariZoneEntranceText1
-	dw SafariZoneEntranceText2
-	dw SafariZoneEntranceText3
-	dw SafariZoneEntranceText4
-	dw SafariZoneEntranceText5
-	dw SafariZoneEntranceText6
+	dw .SafariZoneEntranceText1
+	dw .SafariZoneEntranceText2
+	dw .SafariZoneEntranceText1
+	dw .SafariZoneEntranceText4
+	dw .SafariZoneEntranceText5
+	dw .SafariZoneEntranceText6
 
-SafariZoneEntranceText3: ; 752c5 (1d:52c5)
-SafariZoneEntranceText1: ; 752c5 (1d:52c5)
+.SafariZoneEntranceText1
 	TX_FAR _SafariZoneEntranceText1
 	db "@"
 
-SafariZoneEntranceText4: ; 752ca (1d:52ca)
+.SafariZoneEntranceText4
 	TX_FAR SafariZoneEntranceText_9e6e4 ; 0x9e6e4
 	db $8
 	ld a, $13
-	ld [wd125], a
+	ld [wd125],a
 	call DisplayTextBoxID
 	call YesNoChoice
-	ld a, [wCurrentMenuItem]
+	ld a,[wCurrentMenuItem]
 	and a
-	jp nz, .asm_75346
+	jp nz,.PleaseComeAgain
 	xor a
-	ld [$ff9f], a
-	ld a, $5
-	ld [$ffa0], a
-	ld a, $0
-	ld [$ffa1], a
+	ld [$ff9f],a
+	ld a,$05
+	ld [$ffa0],a
+	ld a,$00
+	ld [$ffa1],a
 	call HasEnoughMoney
-	jr nc, .asm_752f9 ; 0x752ef $8
-	ld hl, SafariZoneEntranceText_7536a
+	jr nc,.success
+	ld hl,.NotEnoughMoneyText
 	call PrintText
-	jr .asm_7534c ; 0x752f7 $53
-.asm_752f9
+	jr .CantPayWalkDown
+
+.success
 	xor a
-	ld [wWhichTrade], a
-	ld a, $5
-	ld [wTrainerEngageDistance], a
-	ld a, $0
-	ld [wTrainerFacingDirection], a
-	ld hl, wTrainerFacingDirection
-	ld de, wPlayerMoney + 2
-	ld c, $3
+	ld [wSubtrahend],a
+	ld a,$05
+	ld [wSubtrahend+1],a
+	ld a,$00
+	ld [wSubtrahend+2],a
+	ld hl,wTrainerFacingDirection
+	ld de,wPlayerMoney + 2
+	ld c,3
 	predef SubBCDPredef
-	ld a, $13
-	ld [wd125], a
+	ld a,$13
+	ld [wd125],a
 	call DisplayTextBoxID
-	ld hl, SafariZoneEntranceText_7535b
+	ld hl,.MakePaymentText
 	call PrintText
-	ld a, $1e
-	ld [W_NUMSAFARIBALLS], a
-	ld a, 502 / $100
-	ld [wSafariSteps], a
+	ld a,30
+	ld [W_NUMSAFARIBALLS],a
+	ld a,502 / $100
+	ld [wSafariSteps],a
 	ld a, 502 % $100
-	ld [wSafariSteps + 1], a
-	ld a, $40
-	ld c, $3
-	call SafariZoneEntranceScript_752a3
-	ld hl, wd790
-	set 7, [hl]
-	res 6, [hl]
-	ld a, $3
-	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
-	jr .asm_75358 ; 0x75344 $12
-.asm_75346
-	ld hl, SafariZoneEntranceText_75365
+	ld [wSafariSteps + 1],a
+	ld a,$40
+	ld c,3
+	call SafariZoneEntranceAutoWalk
+	ld hl,wd790
+	set 7,[hl]
+	res 6,[hl]
+	ld a,3
+	ld [W_SAFARIZONEENTRANCECURSCRIPT],a
+	jr .done
+
+.PleaseComeAgain
+	ld hl,.PleaseComeAgainText
 	call PrintText
-.asm_7534c
-	ld a, $80
-	ld c, $1
-	call SafariZoneEntranceScript_752a3
-	ld a, $4
-	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
-.asm_75358
+.CantPayWalkDown
+	ld a,$80
+	ld c,1
+	call SafariZoneEntranceAutoWalk
+	ld a,4
+	ld [W_SAFARIZONEENTRANCECURSCRIPT],a
+.done
 	jp TextScriptEnd
 
-SafariZoneEntranceText_7535b: ; 7535b (1d:535b)
-	TX_FAR SafariZoneEntranceText_9e747 ; 0x9e747
-	db $0B
-
-SafariZoneEntranceText_75360: ; 75360 (1d:5360)
+.MakePaymentText
+	TX_FAR SafariZoneEntranceText_9e747
+	db $b
 	TX_FAR _SafariZoneEntranceText_75360
 	db "@"
 
-SafariZoneEntranceText_75365: ; 75365 (1d:5365)
+.PleaseComeAgainText
 	TX_FAR _SafariZoneEntranceText_75365
 	db "@"
 
-SafariZoneEntranceText_7536a: ; 7536a (1d:536a)
+.NotEnoughMoneyText
 	TX_FAR _SafariZoneEntranceText_7536a
 	db "@"
 
-SafariZoneEntranceText5: ; 7536f (1d:536f)
+.SafariZoneEntranceText5
 	TX_FAR SafariZoneEntranceText_9e814 ; 0x9e814
 	db $8
 	call YesNoChoice
-	ld a, [wCurrentMenuItem]
+	ld a,[wCurrentMenuItem]
 	and a
 	jr nz, .asm_7539c ; 0x7537b $1f
-	ld hl, SafariZoneEntranceText_753bb
+	ld hl, .SafariZoneEntranceText_753bb
 	call PrintText
 	xor a
 	ld [wSpriteStateData1 + 9], a
 	ld a, $80
 	ld c, $3
-	call SafariZoneEntranceScript_752a3
+	call SafariZoneEntranceAutoWalk
 	ld hl, wd790
 	res 6, [hl]
 	res 7, [hl]
@@ -246,13 +245,13 @@
 	ld [wcf0d], a
 	jr .asm_753b3 ; 0x7539a $17
 .asm_7539c
-	ld hl, SafariZoneEntranceText_753c0
+	ld hl, .SafariZoneEntranceText_753c0
 	call PrintText
 	ld a, $4
 	ld [wSpriteStateData1 + 9], a
 	ld a, $40
 	ld c, $1
-	call SafariZoneEntranceScript_752a3
+	call SafariZoneEntranceAutoWalk
 	ld a, $5
 	ld [wcf0d], a
 .asm_753b3
@@ -260,40 +259,40 @@
 	ld [W_SAFARIZONEENTRANCECURSCRIPT], a
 	jp TextScriptEnd
 
-SafariZoneEntranceText_753bb: ; 753bb (1d:53bb)
+.SafariZoneEntranceText_753bb
 	TX_FAR _SafariZoneEntranceText_753bb
 	db "@"
 
-SafariZoneEntranceText_753c0: ; 753c0 (1d:53c0)
+.SafariZoneEntranceText_753c0
 	TX_FAR _SafariZoneEntranceText_753c0
 	db "@"
 
-SafariZoneEntranceText6: ; 753c5 (1d:53c5)
+.SafariZoneEntranceText6
 	TX_FAR _SafariZoneEntranceText_753c5
 	db "@"
 
-SafariZoneEntranceText2: ; 753ca (1d:53ca)
+.SafariZoneEntranceText2
 	db $08 ; asm
-	ld hl, SafariZoneEntranceText_753e6
+	ld hl,.FirstTimeQuestionText
 	call PrintText
 	call YesNoChoice
-	ld a, [wCurrentMenuItem]
+	ld a,[wCurrentMenuItem]
 	and a
-	ld hl, SafariZoneEntranceText_753f0
-	jr nz, .asm_278a6 ; 0x753db
-	ld hl, SafariZoneEntranceText_753eb
-.asm_278a6 ; 0x753e0
+	ld hl,.RegularText
+	jr nz,.Explanation
+	ld hl,.ExplanationText
+.Explanation
 	call PrintText
 	jp TextScriptEnd
 
-SafariZoneEntranceText_753e6: ; 753e6 (1d:53e6)
+.FirstTimeQuestionText
 	TX_FAR _SafariZoneEntranceText_753e6
 	db "@"
 
-SafariZoneEntranceText_753eb: ; 753eb (1d:53eb)
+.ExplanationText
 	TX_FAR _SafariZoneEntranceText_753eb
 	db "@"
 
-SafariZoneEntranceText_753f0: ; 753f0 (1d:53f0)
+.RegularText
 	TX_FAR _SafariZoneEntranceText_753f0
 	db "@"
--- a/text/maps/safari_zone_entrance.asm
+++ b/text/maps/safari_zone_entrance.asm
@@ -92,3 +92,49 @@
 	line "regular here!"
 	done
 
+IF DEF(_OPTION_LOWCOST_SAFARI)
+_SafariZoneLowCostText1::
+	db 0
+	para "Oh, all right, pay"
+	line "me what you have."
+	prompt
+
+_SafariZoneLowCostText2::
+	text "But, I can't give"
+	line "you all 30 BALLs."
+	done
+
+_SafariZoneLowCostText3::
+	db 0
+	para "You're persistent,"
+	line "aren't you?"
+
+	para "OK, you can go in"
+	line "for free, but"
+	cont "just this once!@@"
+
+_SafariZoneLowCostText4::
+	db 0
+	done
+
+_SafariZoneLowCostText5::
+	text "I'm sorry, but you"
+	line "have to pay to"
+	cont "enter."
+	done
+
+_SafariZoneLowCostText6::
+	text "You can't enter"
+	line "without paying!"
+	done
+
+_SafariZoneLowCostText7::
+	text "I said, no money,"
+	line "no entry!"
+	done
+
+_SafariZoneLowCostText8::
+	text "Read my lips, NO!"
+	line "Get it?"
+	done
+ENDC
--- a/wram.asm
+++ b/wram.asm
@@ -510,6 +510,9 @@
 
 wHiddenObjectFunctionArgument:: ; cd3d
 
+wSubtrahend:: ; cd3d
+; subtract (BCD) wSubtrahend, wSubtrahend+1, wSubtrahend+2
+
 wWhichTrade:: ; cd3d
 ; which entry from TradeMons to select