Skip to content

Commit

Permalink
Talk to Surf water, Cut trees, and Strength boulders
Browse files Browse the repository at this point in the history
Show trainer names before after-battle text
  • Loading branch information
Rangi42 committed Jun 8, 2018
1 parent aeeb8a8 commit 050aae8
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 44 deletions.
2 changes: 1 addition & 1 deletion engine/display_text_id_init.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; function that performs initialization for DisplayTextID
DisplayTextIDInit:
DisplayTextIDInit::
xor a
ld [wListMenuID], a
ld a, [wAutoTextBoxDrawingControl]
Expand Down
4 changes: 4 additions & 0 deletions engine/overworld/cut.asm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ UsedCut:
call GBPalWhiteOutWithDelay3
call ClearSprites
call RestoreScreenTilesAndReloadTilePatterns
call ReloadMapData
ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
call Delay3
Expand All @@ -46,6 +47,9 @@ UsedCut:
call Delay3
xor a
ld [hWY], a
; fall through

Cut2::
ld hl, UsedCutText
call PrintText
call LoadScreenTilesFromBuffer2
Expand Down
172 changes: 172 additions & 0 deletions engine/overworld/field_moves.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
TryFieldMove:: ; predef
call GetPredefRegisters
call TrySurf
ret z
call TryCut
ret

TrySurf:
ld a, [wWalkBikeSurfState]
cp 2 ; is the player already surfing?
jr z, .no
callab IsNextTileShoreOrWater
jr c, .no
ld hl, TilePairCollisionsWater
call CheckForTilePairCollisions2
jr c, .no
ld d, SURF
call HasPartyMove
jr nz, .no
ld a, [wObtainedBadges]
bit 4, a ; SOUL BADGE
jr z, .no
callba IsSurfingAllowed
ld hl, wd728
bit 1, [hl]
res 1, [hl]
jr z, .no
call InitializeFieldMoveTextBox
ld hl, PromptToSurfText
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .no2
call GetPartyMonName2
ld a, SURFBOARD
ld [wcf91], a
ld [wPseudoItemID], a
call UseItem
.yes2
call CloseFieldMoveTextBox
.yes
xor a
ret
.no2
call CloseFieldMoveTextBox
.no
ld a, 1
and a
ret

TryCut:
call IsCutTile
jr nc, TrySurf.no
call InitializeFieldMoveTextBox
ld hl, ExplainCutText
call PrintText
call ManualTextScroll
ld d, CUT
call HasPartyMove
jr nz, TrySurf.no2
ld a, [wObtainedBadges]
bit 1, a ; CASCADE BADGE
jr z, TrySurf.no2
ld hl, PromptToCutText
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, TrySurf.no2
call GetPartyMonName2
callab Cut2
call CloseFieldMoveTextBox
jr TrySurf.yes2

IsCutTile:
; partial copy from UsedCut
ld a, [wCurMapTileset]
and a ; OVERWORLD
jr z, .overworld
cp GYM
jr nz, .no
ld a, [wTileInFrontOfPlayer]
cp $50 ; gym cut tree
jr nz, .no
jr .yes
.overworld
ld a, [wTileInFrontOfPlayer]
cp $3d ; cut tree
jr nz, .no
.yes
scf
ret
.no
and a
ret

HasPartyMove::
; Return z (optional: in wWhichTrade) if a PartyMon has move d.
; Updates wWhichPokemon.
push bc
push de
push hl

ld a, [wPartyCount]
and a
jr z, .no
ld b, a
ld c, 0
ld hl, wPartyMons + (wPartyMon1Moves - wPartyMon1)
.loop
ld e, NUM_MOVES
.check_move
ld a, [hli]
cp d
jr z, .yes
dec e
jr nz, .check_move

ld a, wPartyMon2 - wPartyMon1 - NUM_MOVES
add l
ld l, a
ld a, 0
adc h
ld h, a

inc c
ld a, c
cp b
jr c, .loop
jr .no

.yes
ld a, c
ld [wWhichPokemon], a
xor a ; probably redundant
ld [wWhichTrade], a
jr .done
.no
ld a, 1
and a
ld [wWhichTrade], a
.done
pop hl
pop de
pop bc
ret

InitializeFieldMoveTextBox:
call EnableAutoTextBoxDrawing
ld a, 1 ; not 0
ld [hSpriteIndexOrTextID], a
callab DisplayTextIDInit
ret

CloseFieldMoveTextBox:
ld a,[H_LOADEDROMBANK]
push af
jp CloseTextDisplay

PromptToSurfText:
text "The water is calm."
line "Would you like to"
cont "SURF?@@"

ExplainCutText:
text "This tree can be"
line "CUT!@@"

PromptToCutText:
text "Would you like to"
line "use CUT?@@"
5 changes: 4 additions & 1 deletion engine/overworld/hidden_items.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ HiddenItems:
predef FlagActionPredef
ld a, c
and a
ret nz
jr nz, .nope
call EnableAutoTextBoxDrawing
ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wHiddenObjectFunctionArgument] ; item ID
ld [wd11e], a
call GetItemName
tx_pre_jump FoundHiddenItemText
.nope
predef TryFieldMove
ret

INCLUDE "data/hidden_item_coords.asm"

Expand Down
1 change: 1 addition & 0 deletions engine/predefs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,4 @@ PredefPointers::
add_predef DrawHP2
add_predef DisplayElevatorFloorMenu
add_predef OaksAideScript
add_predef TryFieldMove
57 changes: 19 additions & 38 deletions home.asm
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,6 @@ DrawHPBar::
LoadMonData::
jpab LoadMonData_

OverwritewMoves::
; Write c to [wMoves + b]. Unused.
ld hl, wMoves
ld e, b
ld d, 0
add hl, de
ld a, c
ld [hl], a
ret

LoadFlippedFrontSpriteByMonIndex::
ld a, 1
ld [wSpriteFlipped], a
Expand Down Expand Up @@ -540,15 +530,6 @@ PrintLevelCommon::
ld b, LEFT_ALIGN | 1 ; 1 byte
jp PrintNumber

GetwMoves::
; Unused. Returns the move at index a from wMoves in a
ld hl, wMoves
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
ret

; copies the base stat data of a pokemon to wMonHeader
; INPUT:
; [wd0b5] = pokemon ID
Expand Down Expand Up @@ -935,7 +916,24 @@ GroundRoseText::

BoulderText::
TX_FAR _BoulderText
db "@"
TX_ASM
ld a, [wObtainedBadges]
bit 3, a ; RAINBOW BADGE
jr z, .done
ld d, STRENGTH
callab HasPartyMove
ld a, [wWhichTrade]
and a
jr nz, .done
ld a, [wWhichPokemon]
push af
call ManualTextScroll
pop af
ld [wWhichPokemon], a
call GetPartyMonName2
predef PrintStrengthTxt
.done
jp TextScriptEnd

MartSignText::
TX_FAR _MartSignText
Expand Down Expand Up @@ -2554,22 +2552,12 @@ GetSavedEndBattleTextPointer::
ret

TrainerEndBattleText::
TX_FAR _TrainerNameText
TX_ASM
call GetSavedEndBattleTextPointer
call TextCommandProcessor
jp TextScriptEnd

; only engage withe trainer if the player is not already
; engaged with another trainer
; XXX unused?
CheckIfAlreadyEngaged::
ld a, [wFlags_0xcd60]
bit 0, a
ret nz
call EngageMapTrainer
xor a
ret

PlayTrainerMusic::
ld a, [wEngagedTrainerClass]
cp OPP_SONY1
Expand Down Expand Up @@ -2983,13 +2971,6 @@ YesNoChoicePokeCenter::
lb bc, 8, 12
jr DisplayYesNoChoice

WideYesNoChoice:: ; unused
call SaveScreenTilesToBuffer1
ld a, WIDE_YES_NO_MENU
ld [wTwoOptionMenuID], a
coord hl, 12, 7
lb bc, 8, 13

DisplayYesNoChoice::
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
Expand Down
4 changes: 3 additions & 1 deletion home/overworld.asm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ OverworldLoopLessDelay::
call IsSpriteOrSignInFrontOfPlayer
ld a, [hSpriteIndexOrTextID]
and a
jp z, OverworldLoop
jr nz, .displayDialogue
predef TryFieldMove
jp OverworldLoop
.displayDialogue
predef GetTileAndCoordsInFrontOfPlayer
call UpdateSprites
Expand Down
4 changes: 3 additions & 1 deletion main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2149,10 +2149,12 @@ INCLUDE "engine/overworld/elevator.asm"
INCLUDE "engine/items/tm_prices.asm"


SECTION "Pokemon Gender", ROMX
SECTION "Engine Spillover 1", ROMX

INCLUDE "engine/mon_gender.asm"

INCLUDE "engine/overworld/field_moves.asm"


SECTION "Trainer Parties", ROMX

Expand Down
4 changes: 3 additions & 1 deletion pokered.link
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ ROMX $35

ROMX $36
"Trainer Parties"
"Pokemon Gender"

ROMX $37
"Tileset Spillover 1"

ROMX $38
"Engine Spillover 1"

WRAM0
"WRAM Bank 0"

Expand Down
2 changes: 1 addition & 1 deletion text.asm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _CardKeyFailText::
done

_TrainerNameText::
TX_RAM wcd6d
TX_RAM wCurTrainerName
text ": @@"

_NoNibbleText::
Expand Down

0 comments on commit 050aae8

Please sign in to comment.