Conflicts:
	engine/town_map.asm
This commit is contained in:
dannye 2015-07-14 00:58:09 -05:00
commit e25a7148d0
43 changed files with 1136 additions and 847 deletions

View file

@ -77,7 +77,7 @@ DisplayCreditsMon: ; 740cb (1d:40cb)
call Func_74164
call FillMiddleOfScreenWithWhite
ld a,$FC
ld [$FF47],a
ld [rBGP],a
ld bc,7
.next
call Func_74140
@ -94,7 +94,7 @@ DisplayCreditsMon: ; 740cb (1d:40cb)
xor a
ld [hWY],a
ld a,$C0
ld [$FF47],a
ld [rBGP],a
ret
INCLUDE "data/credit_mons.asm"
@ -133,7 +133,7 @@ Func_74164: ; 74164 (1d:4164)
ld a, l
ld [H_AUTOBGTRANSFERDEST], a
ld a, h
ld [$ffbd], a
ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
jp Delay3

View file

@ -336,14 +336,14 @@ LoadAnimationTileset: ; 781d2 (1e:41d2)
ld d,0
add hl,de
ld a,[hli]
ld [wd07d],a ; number of tiles
ld [wTempTilesetNumTiles],a ; number of tiles
ld a,[hli]
ld e,a
ld a,[hl]
ld d,a ; de = address of tileset
ld hl,vSprites + $310
ld b, BANK(AnimationTileset1) ; ROM bank
ld a,[wd07d]
ld a,[wTempTilesetNumTiles]
ld c,a ; number of tiles
jp CopyVideoData ; load tileset
@ -835,9 +835,9 @@ DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9)
; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically
.shakeScreen
ld b,1
predef Func_48125 ; shake horizontally
predef PredefShakeScreenHorizontally ; shake horizontally
ld b,1
predef_jump Func_480ff ; shake vertically
predef_jump PredefShakeScreenVertically ; shake vertically
FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7)
ld a,[W_SUBANIMCOUNTER]
@ -1225,14 +1225,14 @@ SetAnimationBGPalette: ; 791fc (1e:51fc)
ld b, $5
AnimationShakeScreenVertically: ; 79209 (1e:5209)
predef_jump Func_480ff
predef_jump PredefShakeScreenVertically
AnimationShakeScreen: ; 7920e (1e:520e)
; Shakes the screen for a while. Used in Earthquake/Fissure/etc. animations.
ld b, $8
AnimationShakeScreenHorizontallyFast: ; 79210 (1e:5210)
predef_jump Func_48125
predef_jump PredefShakeScreenHorizontally
AnimationWaterDropletsEverywhere: ; 79215 (1e:5215)
; Draws water droplets all over the screen and makes them
@ -1292,12 +1292,12 @@ AnimationSlideMonUp: ; 7927a (1e:527a)
ld c, $7
ld a, [H_WHOSETURN]
and a
ld hl, wTileMap + $79
ld de, wTileMap + $65
hlCoord 1, 6
deCoord 1, 5
ld a, $30
jr z, .asm_79291
ld hl, wTileMap + $20
ld de, wTileMap + $c
hlCoord 12, 1
deCoord 12, 0
ld a, $ff
.asm_79291
ld [wd09f], a
@ -1345,16 +1345,16 @@ _AnimationSlideMonUp: ; 792bf (1e:52bf)
call CopyData
pop de
pop hl
ld bc, $0028
ld bc, SCREEN_WIDTH * 2
add hl, bc
pop bc
dec b
jr nz, .asm_792c4
ld a, [H_WHOSETURN]
and a
ld hl, wTileMap + $dd
hlCoord 1, 11
jr z, .asm_792e2
ld hl, wTileMap + $84
hlCoord 12, 6
.asm_792e2
ld a, [wd09f]
inc a
@ -1513,11 +1513,11 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1)
; The mon's sprite disappears after this animation.
ld a, [H_WHOSETURN]
and a
ld hl, wTileMap + $64
ld de, wTileMap + $66
hlCoord 0, 5
deCoord 2, 5
jr z, .asm_793c2
ld hl, wTileMap + $b
ld de, wTileMap + $d
hlCoord 11, 0
deCoord 13, 0
.asm_793c2
xor a
@ -2061,23 +2061,24 @@ CopySlowbroSpriteData: ; 7973f (1e:573f)
ld a, BANK(SlowbroSprite)
jp FarCopyData2
Func_79747: ; 79747 (1e:5747)
HideSubstituteShowMonAnim: ; 79747 (1e:5747)
ld a, [H_WHOSETURN]
and a
ld hl, wccf7
ld hl, wPlayerMonMinimized
ld a, [W_PLAYERBATTSTATUS2]
jr z, .asm_79758
ld hl, wccf3
jr z, .next1
ld hl, wEnemyMonMinimized
ld a, [W_ENEMYBATTSTATUS2]
.asm_79758
.next1
push hl
bit 4, a
jr nz, .asm_79762
; if the substitute broke, slide it down, else slide it offscreen horizontally
bit HasSubstituteUp, a
jr nz, .substituteStillUp
call AnimationSlideMonDown
jr .asm_79765
.asm_79762
jr .next2
.substituteStillUp
call AnimationSlideMonOut
.asm_79765
.next2
pop hl
ld a, [hl]
and a
@ -2085,7 +2086,7 @@ Func_79747: ; 79747 (1e:5747)
call AnimationFlashMonPic
jp AnimationShowMonPic
Func_79771: ; 79771 (1e:5771)
ReshowSubstituteAnim: ; 79771 (1e:5771)
call AnimationSlideMonOut
call AnimationSubstitute
jp AnimationShowMonPic
@ -2644,16 +2645,16 @@ Unknown_79c50: ; 79c50 (1e:5c50)
AnimationLeavesFalling: ; 79c74 (1e:5c74)
; Makes leaves float down from the top of the screen. This is used
; in Razor Leaf's animation.
ld a, [$ff48]
ld a, [rOBP0]
push af
ld a, [wcc79]
ld [$ff48], a
ld [rOBP0], a
ld d, $37
ld a, $3
ld [W_SUBANIMTRANSFORM], a
call Func_79c97
pop af
ld [$ff48], a
ld [rOBP0], a
ret
AnimationPetalsFalling: ; 79c8a (1e:5c8a)
@ -2870,7 +2871,7 @@ Func_79de9: ; 79de9 (1e:5de9)
Func_79e0d: ; 79e0d (1e:5e0d)
ld a, h
ld [$ffbd], a
ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, l
ld [H_AUTOBGTRANSFERDEST], a
jp Delay3

View file

@ -53,29 +53,29 @@ FormatMovesString: ; 39b87 (e:5b87)
; XXX this is called in a few places, but it doesn't appear to do anything useful
InitList: ; 39bd5 (e:5bd5)
ld a, [wd11b]
cp $1
ld a, [wInitListType]
cp INIT_ENEMYOT_LIST
jr nz, .notEnemy
ld hl, wEnemyPartyCount
ld de, wEnemyMonOT
ld a, ENEMYOT_NAME
jr .done
.notEnemy
cp $4
cp INIT_PLAYEROT_LIST
jr nz, .notPlayer
ld hl, wPartyCount
ld de, wPartyMonOT
ld a, PLAYEROT_NAME
jr .done
.notPlayer
cp $5
cp INIT_MON_LIST
jr nz, .notMonster
ld hl, wStringBuffer2 + 11
ld de, MonsterNames
ld a, MONSTER_NAME
jr .done
.notMonster
cp $2
cp INIT_BAG_ITEM_LIST
jr nz, .notBag
ld hl, wNumBagItems
ld de, ItemNames

View file

@ -848,7 +848,7 @@ FaintEnemyPokemon: ; 0x3c567
ld [hl], a
ld [W_ENEMYDISABLEDMOVE], a
ld [wEnemyDisabledMoveNumber], a
ld [wccf3], a
ld [wEnemyMonMinimized], a
ld hl, wPlayerUsedMove
ld [hli], a
ld [hl], a
@ -1142,8 +1142,8 @@ DoUseNextMonDialogue: ; 3c79b (f:479b)
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID
ld a, [wd12e]
cp $2 ; did the player choose NO?
ld a, [wMenuExitMethod]
cp CHOSE_SECOND_ITEM ; did the player choose NO?
jr z, .tryRunning ; if the player chose NO, try running
and a ; reset carry
ret
@ -1162,8 +1162,8 @@ UseNextMonText: ; 3c7d3 (f:47d3)
; choose next player mon to send out
; stores whether enemy mon has no HP left in Z flag
ChooseNextMon: ; 3c7d8 (f:47d8)
ld a, $2
ld [wd07d], a
ld a, BATTLE_PARTY_MENU
ld [wPartyMenuTypeOrMessageID], a
call DisplayPartyMenu
.checkIfMonChosen
jr nc, .monChosen
@ -1376,7 +1376,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld [hl],a
ld [W_ENEMYDISABLEDMOVE],a
ld [wEnemyDisabledMoveNumber],a
ld [wccf3],a
ld [wEnemyMonMinimized],a
ld hl,wPlayerUsedMove
ld [hli],a
ld [hl],a
@ -1462,8 +1462,8 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld a,[wCurrentMenuItem]
and a
jr nz,.next4
ld a,2
ld [wd07d],a
ld a,BATTLE_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
.next9
ld a,1
@ -1826,7 +1826,7 @@ SendOutMon: ; 3cc91 (f:4c91)
ld [hl], a
ld [W_PLAYERDISABLEDMOVE], a
ld [wPlayerDisabledMoveNumber], a
ld [wccf7], a
ld [wPlayerMonMinimized], a
ld b, $1
call GoPAL_SET
ld hl, W_ENEMYBATTSTATUS1
@ -2296,7 +2296,7 @@ DisplayPlayerBag:
DisplayBagMenu:
xor a
ld [wcf93], a
ld [wPrintItemPrices], a
ld a, ITEMLISTMENU
ld [wListMenuID], a
ld a, [wcc2c]
@ -2305,7 +2305,7 @@ DisplayBagMenu:
ld a, [wCurrentMenuItem]
ld [wcc2c], a
ld a, $0
ld [wcc37], a
ld [wMenuWatchMovingOutOfBounds], a
ld [wMenuItemToSwap], a
jp c, DisplayBattleMenu ; go back to battle menu if an item was not selected
@ -2384,8 +2384,8 @@ PartyMenuOrRockOrRun:
jp UseBagItem
.partyMenuWasSelected
call LoadScreenTilesFromBuffer1
xor a
ld [wd07d], a
xor a ; NORMAL_PARTY_MENU
ld [wPartyMenuTypeOrMessageID], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
.checkIfPartyMonWasSelected
@ -2403,8 +2403,8 @@ PartyMenuOrRockOrRun:
ld bc, $81
ld a, $7f
call FillMemory
xor a
ld [wd07d], a
xor a ; NORMAL_PARTY_MENU
ld [wPartyMenuTypeOrMessageID], a
call GoBackToPartyMenu
jr .checkIfPartyMonWasSelected
.partyMonWasSelected
@ -2448,7 +2448,7 @@ PartyMenuOrRockOrRun:
ld hl, AnimationSubstitute
jr nz, .doEnemyMonAnimation
; enemy mon doesn't have substitute
ld a, [wccf3]
ld a, [wEnemyMonMinimized]
and a ; has the enemy mon used Minimise?
ld hl, AnimationMinimizeMon
jr nz, .doEnemyMonAnimation
@ -3215,9 +3215,9 @@ getPlayerAnimationType
playPlayerMoveAnimation
push af
ld a,[W_PLAYERBATTSTATUS2]
bit 4,a
ld hl,Func_79747
ld b,BANK(Func_79747)
bit HasSubstituteUp,a
ld hl,HideSubstituteShowMonAnim
ld b,BANK(HideSubstituteShowMonAnim)
call nz,Bankswitch
pop af
ld [wAnimationType],a
@ -3226,9 +3226,9 @@ playPlayerMoveAnimation
call HandleExplodingAnimation
call DrawPlayerHUDAndHPBar
ld a,[W_PLAYERBATTSTATUS2]
bit 4,a
ld hl,Func_79771
ld b,BANK(Func_79771)
bit HasSubstituteUp,a
ld hl,ReshowSubstituteAnim
ld b,BANK(ReshowSubstituteAnim)
call nz,Bankswitch
jr MirrorMoveCheck
playerCheckIfFlyOrChargeEffect
@ -3958,7 +3958,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2)
ld hl, KeptGoingAndCrashedText
call PrintText
ld b, $4
predef Func_48125
predef PredefShakeScreenHorizontally
ld a, [H_WHOSETURN]
and a
jr nz, .enemyTurn
@ -5089,7 +5089,7 @@ AttackSubstitute: ; 3e25e (f:625e)
ld a,[H_WHOSETURN]
xor a,$01
ld [H_WHOSETURN],a
callab Func_79747 ; animate the substitute breaking
callab HideSubstituteShowMonAnim ; animate the substitute breaking
; flip the turn back to the way it was
ld a,[H_WHOSETURN]
xor a,$01
@ -5767,8 +5767,8 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4)
push af
ld a, [W_ENEMYBATTSTATUS2]
bit HasSubstituteUp, a ; does mon have a substitute?
ld hl, Func_79747
ld b, BANK(Func_79747)
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
pop af
ld [wAnimationType], a
@ -5778,8 +5778,8 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4)
call DrawEnemyHUDAndHPBar
ld a, [W_ENEMYBATTSTATUS2]
bit HasSubstituteUp, a ; does mon have a substitute?
ld hl, Func_79771
ld b, BANK(Func_79771)
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch ; slide the substitute's sprite out
jr EnemyCheckIfMirrorMoveEffect
@ -6943,12 +6943,12 @@ InitBattle_Common: ; 3efeb (f:6feb)
call SaveScreenTilesToBuffer1
call ClearScreen
ld a, $98
ld [$ffbd], a
ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
ld a, $9c
ld [$ffbd], a
ld [H_AUTOBGTRANSFERDEST + 1], a
call LoadScreenTilesFromBuffer1
hlCoord 9, 7
ld bc, $50a
@ -7657,24 +7657,26 @@ UpdateStatDone: ; 3f4ca (f:74ca)
call PrintStatText
ld hl, W_PLAYERBATTSTATUS2
ld de, W_PLAYERMOVENUM
ld bc, wccf7
ld bc, wPlayerMonMinimized
ld a, [H_WHOSETURN]
and a
jr z, .asm_3f4e6
ld hl, W_ENEMYBATTSTATUS2
ld de, W_ENEMYMOVENUM
ld bc, wccf3
ld bc, wEnemyMonMinimized
.asm_3f4e6
ld a, [de]
cp MINIMIZE
jr nz, .asm_3f4f9
bit HasSubstituteUp, [hl] ; substitute
; if a substitute is up, slide off the substitute and show the mon pic before
; playing the minimize animation
bit HasSubstituteUp, [hl]
push af
push bc
ld hl, Func_79747
ld b, BANK(Func_79747)
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
push de
call nz, Bankswitch ; play Minimize animation unless there's Substitute involved
call nz, Bankswitch
pop de
.asm_3f4f9
call PlayCurrentMoveAnimation
@ -7684,8 +7686,8 @@ UpdateStatDone: ; 3f4ca (f:74ca)
pop bc
ld a, $1
ld [bc], a
ld hl, Func_79771
ld b, BANK(Func_79771)
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
pop af
call nz, Bankswitch
.applyBadgeBoostsAndStatusPenalties

View file

@ -26,8 +26,8 @@ TransformEffect_: ; 3bab1 (e:7ab1)
; animation(s) played are different if target has Substitute up
bit HasSubstituteUp, [hl]
push af
ld hl, Func_79747
ld b, BANK(Func_79747)
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
ld a, [W_OPTIONS]
add a
@ -38,8 +38,8 @@ TransformEffect_: ; 3bab1 (e:7ab1)
ld b, BANK(AnimationTransformMon)
.gotAnimToPlay
call Bankswitch
ld hl, Func_79771
ld b, BANK(Func_79771)
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
pop af
call nz, Bankswitch
pop bc

View file

@ -317,7 +317,7 @@ TradeCenter_SelectMon:
ld [hli], a
ld [hli], a
ld [hl], a
ld [wcc37], a
ld [wMenuWatchMovingOutOfBounds], a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
ld [wMenuJoypadPollCount], a
@ -326,7 +326,7 @@ TradeCenter_SelectMon:
jp .playerMonMenu
.enemyMonMenu
xor a
ld [wcc37], a
ld [wMenuWatchMovingOutOfBounds], a
inc a
ld [wWhichTradeMonSelectionMenu], a
ld a, D_DOWN | D_LEFT | A_BUTTON
@ -357,9 +357,9 @@ TradeCenter_SelectMon:
dec a
ld [wCurrentMenuItem], a
.displayEnemyMonStats
ld a, $1
ld [wd11b], a
callab InitList
ld a, INIT_ENEMYOT_LIST
ld [wInitListType], a
callab InitList ; the list isn't used
ld hl, wEnemyMons
call TradeCenter_DisplayStats
jp .getNewInput
@ -390,7 +390,7 @@ TradeCenter_SelectMon:
.playerMonMenu
xor a ; player mon menu
ld [wWhichTradeMonSelectionMenu], a
ld [wcc37], a
ld [wMenuWatchMovingOutOfBounds], a
ld a, D_DOWN | D_RIGHT | A_BUTTON
ld [wMenuWatchedKeys], a
ld a, [wPartyCount]
@ -416,9 +416,9 @@ TradeCenter_SelectMon:
jr z, .playerMonMenu_ANotPressed
jp .chosePlayerMon ; jump if A button pressed
; unreachable code
ld a, $4
ld [wd11b], a
callab InitList
ld a, INIT_PLAYEROT_LIST
ld [wInitListType], a
callab InitList ; the list isn't used
call TradeCenter_DisplayStats
jp .getNewInput
.playerMonMenu_ANotPressed
@ -511,9 +511,9 @@ TradeCenter_SelectMon:
.displayPlayerMonStats
pop af
ld [wCurrentMenuItem], a
ld a, $4
ld [wd11b], a
callab InitList
ld a, INIT_PLAYEROT_LIST
ld [wInitListType], a
callab InitList ; the list isn't used
call TradeCenter_DisplayStats
call LoadScreenTilesFromBuffer1
jp .playerMonMenu
@ -682,7 +682,7 @@ TradeCenter_Trade:
xor a
ld [wSerialExchangeNybbleSendData + 1], a ; unnecessary
ld [wSerialExchangeNybbleReceiveData], a
ld [wcc37], a
ld [wMenuWatchMovingOutOfBounds], a
ld [wMenuJoypadPollCount], a
hlCoord 0, 12
ld b, 4
@ -793,7 +793,7 @@ TradeCenter_Trade:
ld a, [hl]
ld [wTradedPlayerMonSpecies], a
xor a
ld [wcf95], a
ld [wRemoveMonFromBox], a
call RemovePokemon
ld a, [wTradingWhichEnemyMon]
ld c, a

View file

@ -1,5 +1,5 @@
StartSlotMachine: ; 37e2d (d:7e2d)
ld a, [wTrainerSpriteOffset]
ld a, [wHiddenObjectFunctionArgument]
cp $fd
jr z, .printOutOfOrder
cp $fe
@ -7,23 +7,23 @@ StartSlotMachine: ; 37e2d (d:7e2d)
cp $ff
jr z, .printSomeonesKeys
callba AbleToPlaySlotsCheck
ld a, [wTrainerSpriteOffset]
ld a, [wHiddenObjectFunctionArgument]
and a
ret z
ld a, [wUnknownSlotVar]
ld a, [wLuckySlotHiddenObjectIndex]
ld b, a
ld a, [wTrainerFacingDirection]
ld a, [wHiddenObjectIndex]
inc a
cp b
jr z, .asm_37e58
ld a, $fd
jr .asm_37e5a
.asm_37e58
ld a, $fa
.asm_37e5a
ld [wcc5b], a
jr z, .match
ld a, 253
jr .next
.match
ld a, 250
.next
ld [wSlotMachineSevenAndBarModeChance], a
ld a, [H_LOADEDROMBANK]
ld [wcc5e], a
ld [wSlotMachineSavedROMBank], a
call PromptUserToPlaySlots
ret
.printOutOfOrder

View file

@ -87,8 +87,8 @@ InGameTrade_GetMonName: ; 71b6a (1c:5b6a)
INCLUDE "data/trades.asm"
InGameTrade_DoTrade: ; 71c07 (1c:5c07)
xor a
ld [wd07d],a
xor a ; NORMAL_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
dec a
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
@ -131,7 +131,7 @@ InGameTrade_DoTrade: ; 71c07 (1c:5c07)
ld [wcf91],a
xor a
ld [wcc49],a
ld [wcf95],a
ld [wRemoveMonFromBox],a
call RemovePokemon
ld a,$80
ld [wcc49],a

View file

@ -450,7 +450,7 @@ ItemUseBall: ; d687 (3:5687)
ret nz
ld hl,wNumBagItems
inc a
ld [wcf96],a
ld [wItemQuantity],a
jp RemoveItemFromInventory
ItemUseBallText00: ; d937 (3:5937)
;"It dodged the thrown ball!"
@ -633,8 +633,8 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,[wcf91]
ld [wd156],a
push af
ld a,$05 ; evolution stone party menu
ld [wd07d],a
ld a,EVO_STONE_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
@ -655,7 +655,7 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld [wWhichPokemon],a
ld hl,wNumBagItems
ld a,1 ; remove 1 stone
ld [wcf96],a
ld [wItemQuantity],a
jp RemoveItemFromInventory
.noEffect
call ItemUseNoEffect
@ -678,8 +678,8 @@ ItemUseMedicine: ; dabb (3:5abb)
push af
ld a,[wcf91]
push af
ld a,$01
ld [wd07d],a ; item use party menu
ld a,USE_ITEM_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
ld a,[wd152]
@ -737,22 +737,22 @@ ItemUseMedicine: ; dabb (3:5abb)
ld bc,4
add hl,bc ; hl now points to status
ld a,[wcf91]
ld bc,$f008
ld bc, (ANTIDOTE_MSG << 8) | (1 << PSN)
cp a,ANTIDOTE
jr z,.checkMonStatus
ld bc,$f110
ld bc, (BURN_HEAL_MSG << 8) | (1 << BRN)
cp a,BURN_HEAL
jr z,.checkMonStatus
ld bc,$f220
ld bc, (ICE_HEAL_MSG << 8) | (1 << FRZ)
cp a,ICE_HEAL
jr z,.checkMonStatus
ld bc,$f307
ld bc, (AWAKENING_MSG << 8) | SLP
cp a,AWAKENING
jr z,.checkMonStatus
ld bc,$f440
ld bc, (PARALYZ_HEAL_MSG << 8) | (1 << PAR)
cp a,PARLYZ_HEAL
jr z,.checkMonStatus
ld bc,$f6ff ; Full Heal
ld bc, (FULL_HEAL_MSG << 8) | $ff ; Full Heal
.checkMonStatus
ld a,[hl] ; pokemon's status
and c ; does the pokemon have a status ailment the item can cure?
@ -761,7 +761,7 @@ ItemUseMedicine: ; dabb (3:5abb)
xor a
ld [hl],a ; remove the status ailment in the party data
ld a,b
ld [wd07d],a ; the message to display for the item used
ld [wPartyMenuTypeOrMessageID],a ; the message to display for the item used
ld a,[wPlayerMonNumber]
cp d ; is pokemon the item was used on active in battle?
jp nz,.doneHealing
@ -1078,15 +1078,15 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
ld a,$f7 ; revived message
ld [wd07d],a
ld a,REVIVE_MSG
ld [wPartyMenuTypeOrMessageID],a
ld a,[wcf91]
cp a,REVIVE
jr z,.showHealingItemMessage
cp a,MAX_REVIVE
jr z,.showHealingItemMessage
ld a,$f5 ; standard HP healed message
ld [wd07d],a
ld a,POTION_MSG
ld [wPartyMenuTypeOrMessageID],a
jr .showHealingItemMessage
.playStatusAilmentCuringSound
ld a,(SFX_02_3e - SFX_Headers_02) / 3 ; status ailment curing sound
@ -1257,8 +1257,8 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,[hl]
adc b
ld [hl],a
ld a,$f8 ; level up message
ld [wd07d],a
ld a,RARE_CANDY_MSG
ld [wPartyMenuTypeOrMessageID],a
call RedrawPartyMenu
pop de
ld a,d
@ -1878,8 +1878,8 @@ ItemUsePPRestore: ; e31e (3:631e)
.chooseMon
xor a
ld [wUpdateSpritesEnabled],a
ld a,$01 ; item use party menu
ld [wd07d],a
ld a,USE_ITEM_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
jr nc,.chooseMove
jp .itemNotUsed
@ -2118,8 +2118,8 @@ ItemUseTMHM: ; e479 (3:6479)
call CopyData
ld a,$ff
ld [wUpdateSpritesEnabled],a
ld a,$03 ; teach TM/HM party menu
ld [wd07d],a
ld a,TMHM_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
push af
ld hl,wd036
@ -2193,7 +2193,7 @@ PrintItemUseTextAndRemoveItem: ; e563 (3:6563)
RemoveUsedItem: ; e571 (3:6571)
ld hl,wNumBagItems
ld a,1 ; one item
ld [wcf96],a ; store quantity
ld [wItemQuantity],a
jp RemoveItemFromInventory
ItemUseNoEffect: ; e57c (3:657c)
@ -2464,7 +2464,7 @@ GetSelectedMoveOffset2: ; e6e9 (3:66e9)
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
; [wWhichPokemon] = index of item within inventory
; [wcf96] = quantity to toss
; [wItemQuantity] = quantity to toss
; OUTPUT:
; clears carry flag if the item is tossed, sets carry flag if not
TossItem_: ; e6f1 (3:66f1)
@ -2475,7 +2475,7 @@ TossItem_: ; e6f1 (3:66f1)
jr c,.tooImportantToToss
push hl
call IsKeyItem_
ld a,[wd124]
ld a,[wIsKeyItem]
pop hl
and a
jr nz,.tooImportantToToss
@ -2491,11 +2491,11 @@ TossItem_: ; e6f1 (3:66f1)
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
ld a,[wd12e]
cp a,2
ld a,[wMenuExitMethod]
cp a,CHOSE_SECOND_ITEM
pop hl
scf
ret z
ret z ; return if the player chose No
; if the player chose Yes
push hl
ld a,[wWhichPokemon]
@ -2533,12 +2533,12 @@ TooImportantToTossText: ; e75f (3:675f)
; INPUT:
; [wcf91] = item ID
; OUTPUT:
; [wd124] = result
; [wIsKeyItem] = result
; 00: item is not key item
; 01: item is key item
IsKeyItem_: ; e764 (3:6764)
ld a,$01
ld [wd124],a
ld [wIsKeyItem],a
ld a,[wcf91]
cp a,HM_01 ; is the item an HM or TM?
jr nc,.checkIfItemIsHM
@ -2562,7 +2562,7 @@ IsKeyItem_: ; e764 (3:6764)
call IsItemHM
ret c
xor a
ld [wd124],a
ld [wIsKeyItem],a
ret
INCLUDE "data/key_items.asm"
@ -2650,8 +2650,8 @@ SendNewMonToBox: ; e7a4 (3:67a4)
jr nz, .asm_e817
.asm_e82a
ld hl, wBoxMonNicks
ld a, $2
ld [wd07d], a
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
predef AskName
ld a, [W_NUMINBOX]
dec a

View file

@ -229,11 +229,11 @@ BillsPCDeposit:
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
ld a, $1
ld [wcf95], a
call Func_3a68
ld a, PARTY_TO_BOX
ld [wMoveMonType], a
call MoveMon
xor a
ld [wcf95], a
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld hl, wWhichTrade
@ -281,11 +281,11 @@ Func_21618: ; 21618 (8:5618)
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
xor a
ld [wcf95], a
call Func_3a68
ld a, $1
ld [wcf95], a
xor a ; BOX_TO_PARTY
ld [wMoveMonType], a
call MoveMon
ld a, 1
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld hl, MonIsTakenOutText
@ -310,7 +310,7 @@ Func_21673: ; 21673 (8:5673)
and a
jr nz, .asm_21682
inc a
ld [wcf95], a
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld a, [wcf91]
@ -329,7 +329,7 @@ Func_216be: ; 216be (8:56be)
ld a, h
ld [wList + 1], a
xor a
ld [wcf93], a
ld [wPrintItemPrices], a
ld [wListMenuID], a
inc a ; MONSTER_NAME
ld [wNameListType], a

View file

@ -56,7 +56,7 @@ DisplayDiploma: ; 566e2 (15:66e2)
call Delay3
call GBPalNormal
ld a, $90
ld [$ff48], a
ld [rOBP0], a
call WaitForTextScrollButtonPress
ld hl, wd730
res 6, [hl]

View file

@ -27,8 +27,8 @@ AskName: ; 64eb (1:64eb)
xor a
ld [wUpdateSpritesEnabled], a
push hl
ld a, $2
ld [wd07d], a
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [W_ISINBATTLE]
and a
@ -53,12 +53,12 @@ DoYouWantToNicknameText: ; 0x6557
TX_FAR _DoYouWantToNicknameText
db "@"
Func_655c: ; 655c (1:655c)
DisplayNameRaterScreen: ; 655c (1:655c)
ld hl, wHPBarMaxHP
xor a
ld [wUpdateSpritesEnabled], a
ld a, $2
ld [wd07d], a
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
@ -114,7 +114,7 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld hl, wHPBarMaxHP + 1
ld [hli], a
ld [hli], a
ld [wPartyMonAnimCounter], a
ld [wAnimCounter], a
.asm_65ed
call PrintAlphabet
call GBPalNormal
@ -236,8 +236,8 @@ DisplayNamingScreen: ; 6596 (1:6596)
cp $e4
ld de, Handakutens
jr z, .asm_66e3
ld a, [wd07d]
cp $2
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
jr nc, .checkMonNameLength
ld a, [wHPBarMaxHP]
cp $7 ; max length of player/rival names
@ -377,8 +377,8 @@ Func_680e: ; 680e (1:680e)
ld de, wcf4b
call PlaceString
hlCoord 10, 3
ld a, [wd07d]
cp $2
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
jr nc, .asm_6835
ld b, $7
jr .asm_6837
@ -390,8 +390,8 @@ Func_680e: ; 680e (1:680e)
ld [hli], a
dec b
jr nz, .asm_6839
ld a, [wd07d]
cp $2
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
ld a, [wHPBarMaxHP]
jr nc, .asm_684b
cp $7
@ -405,8 +405,8 @@ Func_680e: ; 680e (1:680e)
ld [wTopMenuItemX], a
ld a, $5
ld [wCurrentMenuItem], a
ld a, [wd07d]
cp $2
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
ld a, $9
jr nc, .asm_6867
ld a, $6
@ -462,7 +462,7 @@ CalcStringLength: ; 68eb (1:68eb)
PrintNamingText: ; 68f8 (1:68f8)
hlCoord 0, 1
ld a, [wd07d]
ld a, [wNamingScreenType]
ld de, YourTextString
and a
jr z, .notNickname

View file

@ -1,4 +1,4 @@
; [wd07d] = menu type / message ID
; [wPartyMenuTypeOrMessageID] = menu type / message ID
; if less than $F0, it is a menu type
; menu types:
; 00: normal pokemon menu (e.g. Start menu)
@ -25,11 +25,11 @@ DrawPartyMenu_: ; 12cd2 (4:6cd2)
callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld a,[wd07d]
cp a,$04
ld a,[wPartyMenuTypeOrMessageID]
cp a,SWAP_MONS_PARTY_MENU
jp z,.printMessage
call ErasePartyMenuCursors
callba SendBlkPacket_PartyMenu ; loads some data to wcf2e
callba SendBlkPacket_PartyMenu
hlCoord 3, 0
ld de,wPartySpecies
xor a
@ -75,10 +75,10 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
inc hl
inc hl
.skipUnfilledRightArrow
ld a,[wd07d] ; menu type
cp a,$03
ld a,[wPartyMenuTypeOrMessageID] ; menu type
cp a,TMHM_PARTY_MENU
jr z,.teachMoveMenu
cp a,$05
cp a,EVO_STONE_PARTY_MENU
jr z,.evolutionStoneMenu
push hl
ld bc,14 ; 14 columns to the right
@ -196,7 +196,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
push af
push hl
set 6,[hl] ; turn off letter printing delay
ld a,[wd07d] ; message ID
ld a,[wPartyMenuTypeOrMessageID] ; message ID
cp a,$F0
jr nc,.printItemUseMessage
add a

View file

@ -135,7 +135,7 @@ RemoveItemByID: ; 17f37 (5:7f37)
jr .asm_17f40
.asm_17f4f
ld a, $1
ld [wcf96], a
ld [wItemQuantity], a
ld a, [$ffdc]
ld [wWhichPokemon], a
ld hl, wNumBagItems

View file

@ -101,15 +101,15 @@ Func_79ab: ; 79ab (1:79ab)
ld a, h
ld [wList + 1], a
xor a
ld [wcf93], a
ld [wPrintItemPrices], a
ld a, $3
ld [wListMenuID], a
call DisplayListMenuID
jp c, Func_790c
call IsKeyItem
ld a, $1
ld [wcf96], a
ld a, [wd124]
ld [wItemQuantity], a
ld a, [wIsKeyItem]
and a
jr nz, .asm_79e7
ld hl, DepositHowManyText
@ -155,15 +155,15 @@ Func_7a28: ; 7a28 (1:7a28)
ld a, h
ld [wList + 1], a
xor a
ld [wcf93], a
ld [wPrintItemPrices], a
ld a, $3
ld [wListMenuID], a
call DisplayListMenuID
jp c, Func_790c
call IsKeyItem
ld a, $1
ld [wcf96], a
ld a, [wd124]
ld [wItemQuantity], a
ld a, [wIsKeyItem]
and a
jr nz, .asm_7a64
ld hl, WithdrawHowManyText
@ -209,7 +209,7 @@ Func_7aa5: ; 7aa5 (1:7aa5)
ld a, h
ld [wList + 1], a
xor a
ld [wcf93], a
ld [wPrintItemPrices], a
ld a, $3
ld [wListMenuID], a
push hl
@ -220,8 +220,8 @@ Func_7aa5: ; 7aa5 (1:7aa5)
call IsKeyItem
pop hl
ld a, $1
ld [wcf96], a
ld a, [wd124]
ld [wItemQuantity], a
ld a, [wIsKeyItem]
and a
jr nz, .asm_7aef
ld a, [wcf91]

View file

@ -22,7 +22,7 @@ ShowPokedexMenu: ; 40000 (10:4000)
xor a
ld [hli],a ; top menu item X
inc a
ld [wcc37],a
ld [wMenuWatchMovingOutOfBounds],a
inc hl
inc hl
ld a,6
@ -32,7 +32,7 @@ ShowPokedexMenu: ; 40000 (10:4000)
jr c,.goToSideMenu ; if the player chose a pokemon from the list
.exitPokedex
xor a
ld [wcc37],a
ld [wMenuWatchMovingOutOfBounds],a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
ld [hJoy7],a
@ -91,7 +91,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
ld [hli],a ; menu watched keys (A button and B button)
xor a
ld [hli],a ; old menu item ID
ld [wcc37],a
ld [wMenuWatchMovingOutOfBounds],a
.handleMenuInput
call HandleMenuInput
bit 1,a ; was the B button pressed?

View file

@ -12,14 +12,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
jp z,RedisplayStartMenu
xor a
ld [wMenuItemToSwap],a
ld [wd07d],a
ld [wPartyMenuTypeOrMessageID],a
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
jr .checkIfPokemonChosen
.loop
xor a
ld [wMenuItemToSwap],a
ld [wd07d],a
ld [wPartyMenuTypeOrMessageID],a
call GoBackToPartyMenu
.checkIfPokemonChosen
jr nc,.chosePokemon
@ -89,8 +89,8 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
cp a,2 ; is there more than one pokemon in the party?
jp c,StartMenu_Pokemon ; if not, no switching
call SwitchPartyMon_Stats
ld a,$04 ; swap pokemon positions menu
ld [wd07d],a
ld a,SWAP_MONS_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
call GoBackToPartyMenu
jp .checkIfPokemonChosen
.choseStats
@ -313,7 +313,7 @@ StartMenu_Item: ; 13302 (4:7302)
ld [hli],a
ld [hl],b ; store item bag pointer at wList (for DisplayListMenuID)
xor a
ld [wcf93],a
ld [wPrintItemPrices],a
ld a,ITEMLISTMENU
ld [wListMenuID],a
ld a,[wcc2c]
@ -423,7 +423,7 @@ StartMenu_Item: ; 13302 (4:7302)
jp ItemMenuLoop
.tossItem
call IsKeyItem
ld a,[wd124]
ld a,[wIsKeyItem]
and a
jr nz,.skipAskingQuantity
ld a,[wcf91]
@ -747,7 +747,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653)
ret
.asm_13661
xor a
ld [wd07d], a
ld [wPartyMenuTypeOrMessageID], a
ld a, [wMenuItemToSwap]
dec a
ld b, a
@ -757,7 +757,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653)
jr nz, .asm_1367b
xor a
ld [wMenuItemToSwap], a
ld [wd07d], a
ld [wPartyMenuTypeOrMessageID], a
ret
.asm_1367b
ld a, b
@ -845,7 +845,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653)
ld [wWhichTrade], a
xor a
ld [wMenuItemToSwap], a
ld [wd07d], a
ld [wPartyMenuTypeOrMessageID], a
pop de
pop hl
ret

View file

@ -27,7 +27,7 @@ GetAnimationSpeed: ; 7170a (1c:570a)
ld c, a
add a
ld b, a
ld a, [wPartyMonAnimCounter]
ld a, [wAnimCounter]
and a
jr z, .resetSprites
cp c
@ -38,7 +38,7 @@ GetAnimationSpeed: ; 7170a (1c:570a)
jr nz, .skipResetTimer
xor a ; reset timer
.skipResetTimer
ld [wPartyMonAnimCounter], a
ld [wAnimCounter], a
jp DelayFrame
.resetSprites
push bc
@ -315,7 +315,7 @@ WriteMonPartySpriteOAMByPartyIndex: ; 71868 (1c:5868)
add hl, de
ld a, [hl]
call GetPartyMonSpriteID
ld [wcd5b], a
ld [wOAMBaseTile], a
call WriteMonPartySpriteOAM
pop bc
pop de
@ -329,7 +329,7 @@ WriteMonPartySpriteOAMBySpecies: ; 71882 (1c:5882)
ld [hPartyMonIndex], a
ld a, [wMonPartySpriteSpecies]
call GetPartyMonSpriteID
ld [wcd5b], a
ld [wOAMBaseTile], a
jr WriteMonPartySpriteOAM
UnusedPartyMonSpriteFunction: ; 71890 (1c:5890)

View file

@ -46,7 +46,7 @@ OakSpeech: ; 6115 (1:6115)
ld a,POTION
ld [wcf91],a
ld a,1
ld [wcf96],a
ld [wItemQuantity],a
call AddItemToInventory ; give one potion
ld a,[W_ANIMATIONID]
ld [wDestinationMap],a

View file

@ -12,8 +12,8 @@ LoadDefaultNamesPlayer: ; 695d (1:695d)
jr .asm_6999
.asm_697a
ld hl, wPlayerName
xor a
ld [wd07d], a
xor a ; NAME_PLAYER_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [wcf4b]
cp $50
@ -45,8 +45,8 @@ LoadDefaultNamesRival: ; 69a4 (1:69a4)
jr .asm_69e1
.asm_69c1
ld hl, W_RIVALNAME
ld a, $1
ld [wd07d], a
ld a, NAME_RIVAL_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [wcf4b]
cp $50

View file

@ -1,30 +1,34 @@
DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld a,[wListScrollOffset]
ld [wd07e],a
ld [wSavedListScrollOffset],a
call UpdateSprites
xor a
ld [wcf0a],a ; flag that is set if something is sold or bought
ld [wBoughtOrSoldItemInMart],a
.loop
xor a
ld [wListScrollOffset],a
ld [wCurrentMenuItem],a
ld [wPlayerMonNumber],a
inc a
ld [wcf93],a
ld [wPrintItemPrices],a
ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID ; draw money text box
call DisplayTextBoxID
ld a,BUY_SELL_QUIT_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; do buy/sell/quit menu
ld hl,wd128 ; pointer to this pokemart's inventory
call DisplayTextBoxID
; This code is useless. It copies the address of the pokemart's inventory to hl,
; but the address is never used.
ld hl,wItemListPointer
ld a,[hli]
ld l,[hl]
ld h,a ; hl = address of inventory
ld a,[wd12e]
cp a,$02
ld h,a
ld a,[wMenuExitMethod]
cp a,CANCELLED_MENU
jp z,.done
ld a,[wd12d] ; ID of the chosen menu item
ld a,[wChosenMenuItem]
and a ; buying?
jp z,.buyMenu
dec a ; selling?
@ -32,11 +36,14 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
dec a ; quitting?
jp z,.done
.sellMenu
; the same variables are set again below, so this code has no effect
xor a
ld [wcf93],a
ld a,$02
ld [wd11b],a
ld [wPrintItemPrices],a
ld a,INIT_BAG_ITEM_LIST
ld [wInitListType],a
callab InitList
ld a,[wNumBagItems]
and a
jp z,.bagEmpty
@ -54,15 +61,15 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld a,h
ld [wList + 1],a
xor a
ld [wcf93],a
ld [wPrintItemPrices],a
ld [wCurrentMenuItem],a
ld a,ITEMLISTMENU
ld [wListMenuID],a
call DisplayListMenuID
jp c,.returnToMainPokemartMenu ; if the player closed the menu
.confirmItemSale ; if the player is trying to sell a specific item
call IsKeyItem ; check if item is unsellable
ld a,[wd124]
call IsKeyItem
ld a,[wIsKeyItem]
and a
jr nz,.unsellableItem
ld a,[wcf91]
@ -70,7 +77,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
jr c,.unsellableItem
ld a,PRICEDITEMLISTMENU
ld [wListMenuID],a
ld [$ff8e],a ; halve prices when selling
ld [hHalveItemPrices],a ; halve prices when selling
call DisplayChooseQuantityMenu
inc a
jr z,.sellMenuLoop ; if the player closed the choose quantity menu with the B button
@ -82,18 +89,22 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
ld a,[wd12e]
cp a,$02
jr z,.sellMenuLoop ; if the player pressed the B button
ld a,[wd12d] ; ID of the chosen menu item
ld a,[wMenuExitMethod]
cp a,CHOSE_SECOND_ITEM
jr z,.sellMenuLoop ; if the player chose No or pressed the B button
; The following code is supposed to check if the player chose No, but the above
; check already catches it.
ld a,[wChosenMenuItem]
dec a
jr z,.sellMenuLoop ; if the player chose No
jr z,.sellMenuLoop
.sellItem
ld a,[wcf0a] ; flag that is set if something is sold or bought
ld a,[wBoughtOrSoldItemInMart]
and a
jr nz,.skipSettingFlag1
inc a
ld [wcf0a],a
ld [wBoughtOrSoldItemInMart],a
.skipSettingFlag1
call AddAmountSoldToMoney
ld hl,wNumBagItems
@ -106,22 +117,25 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
.bagEmpty
ld hl,PokemartItemBagEmptyText
call PrintText
call SaveScreenTilesToBuffer1 ; save screen
call SaveScreenTilesToBuffer1
jp .returnToMainPokemartMenu
.buyMenu
ld a,$01
ld [wcf93],a
ld a,$03
ld [wd11b],a
; the same variables are set again below, so this code has no effect
ld a,1
ld [wPrintItemPrices],a
ld a,INIT_OTHER_ITEM_LIST
ld [wInitListType],a
callab InitList
ld hl,PokemartBuyingGreetingText
call PrintText
call SaveScreenTilesToBuffer1 ; save screen
call SaveScreenTilesToBuffer1
.buyMenuLoop
call LoadScreenTilesFromBuffer1 ; restore saved screen
call LoadScreenTilesFromBuffer1
ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID ; draw money text box
call DisplayTextBoxID
ld hl,wStringBuffer2 + 11
ld a,l
ld [wList],a
@ -130,15 +144,15 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
xor a
ld [wCurrentMenuItem],a
inc a
ld [wcf93],a
ld [wPrintItemPrices],a
inc a ; a = 2 (PRICEDITEMLISTMENU)
ld [wListMenuID],a
call DisplayListMenuID
jr c,.returnToMainPokemartMenu ; if the player closed the menu
ld a,$63
ld [wcf97],a
ld a,99
ld [wMaxItemQuantity],a
xor a
ld [$ff8e],a
ld [hHalveItemPrices],a ; don't halve item prices when buying
call DisplayChooseQuantityMenu
inc a
jr z,.buyMenuLoop ; if the player closed the choose quantity menu with the B button
@ -153,12 +167,16 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
ld a,[wd12e]
cp a,$02
jp z,.buyMenuLoop ; if the player pressed the B button
ld a,[wd12d] ; ID of the chosen menu item
ld a,[wMenuExitMethod]
cp a,CHOSE_SECOND_ITEM
jp z,.buyMenuLoop ; if the player chose No or pressed the B button
; The following code is supposed to check if the player chose No, but the above
; check already catches it.
ld a,[wChosenMenuItem]
dec a
jr z,.buyMenuLoop ; if the player chose No
jr z,.buyMenuLoop
.buyItem
call .isThereEnoughMoney
jr c,.notEnoughMoney
@ -166,11 +184,11 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
call AddItemToInventory
jr nc,.bagFull
call SubtractAmountPaidFromMoney
ld a,[wcf0a] ; flag that is set if something is sold or bought
ld a,[wBoughtOrSoldItemInMart]
and a
jr nz,.skipSettingFlag2
ld a,$01
ld [wcf0a],a
ld a,1
ld [wBoughtOrSoldItemInMart],a
.skipSettingFlag2
ld a,(SFX_02_5a - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent
@ -182,7 +200,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
call LoadScreenTilesFromBuffer1
ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID ; draw money text box
call DisplayTextBoxID
ld hl,PokemartAnythingElseText
call PrintText
jp .loop
@ -202,10 +220,10 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
.done
ld hl,PokemartThankYouText
call PrintText
ld a,$01
ld a,1
ld [wUpdateSpritesEnabled],a
call UpdateSprites
ld a,[wd07e]
ld a,[wSavedListScrollOffset]
ld [wListScrollOffset],a
ret

View file

@ -85,10 +85,10 @@ PredefPointers:: ; 4fe79 (13:7e79)
dbw $03,GiveItem
add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
add_predef Func_480ff
add_predef PredefShakeScreenVertically
add_predef CalcPositionOfPlayerRelativeToNPC
add_predef ConvertNPCMovementDirectionsToJoypadMasks
add_predef Func_48125
add_predef PredefShakeScreenHorizontally
add_predef UpdateHPBar
add_predef HPBarLength
add_predef Diploma_TextBoxBorder

View file

@ -11,55 +11,61 @@ ChangeBGPalColor0_4Frames: ; 480eb (12:40eb)
ld [rBGP], a
ret
Func_480ff: ; 480ff (12:40ff)
PredefShakeScreenVertically: ; 480ff (12:40ff)
; Moves the window down and then back in a sequence of progressively smaller
; numbers of pixels, starting at b.
call GetPredefRegisters
ld a, $1
ld [wd0a0], a
ld a, 1
ld [wDisableVBlankWYUpdate], a
xor a
.asm_48108
ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND)
call Func_48119
call Func_48119
.loop
ld [$ff96], a
call .MutateWY
call .MutateWY
dec b
ld a, b
jr nz, .asm_48108
jr nz, .loop
xor a
ld [wd0a0], a
ld [wDisableVBlankWYUpdate], a
ret
Func_48119: ; 48119 (12:4119)
ld a, [H_NUMTOPRINT] ; (aliases: H_MULTIPLICAND)
.MutateWY ; 48119 (12:4119)
ld a, [$ff96]
xor b
ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND)
ld [$ff96], a
ld [rWY], a
ld c, 3
jp DelayFrames
Func_48125: ; 48125 (12:4125)
PredefShakeScreenHorizontally: ; 48125 (12:4125)
; Moves the window right and then back in a sequence of progressively smaller
; numbers of pixels, starting at b.
call GetPredefRegisters
xor a
.asm_48129
.loop
ld [$ff97], a
call Func_4813f
call .MutateWX
ld c, 1
call DelayFrames
call Func_4813f
call .MutateWX
dec b
ld a, b
jr nz, .asm_48129
ld a, $7
jr nz, .loop
; restore normal WX
ld a, 7
ld [rWX], a
ret
Func_4813f: ; 4813f (12:413f)
.MutateWX ; 4813f (12:413f)
ld a, [$ff97]
xor b
ld [$ff97], a
bit 7, a
jr z, .asm_48149
xor a
.asm_48149
add $7
jr z, .skipZeroing
xor a ; zero a if it's negative
.skipZeroing
add 7
ld [rWX], a
ld c, 4
jp DelayFrames

View file

@ -11,7 +11,7 @@ Func_1c9c6: ; 1c9c6 (7:49c6)
xor a
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld [wcf93], a
ld [wPrintItemPrices], a
ld a, $4
ld [wListMenuID], a
call DisplayListMenuID

View file

@ -421,7 +421,7 @@ Func_7393f: ; 7393f (1c:793f)
ld a, $c
ld [wTopMenuItemX], a
xor a
ld [wcc37], a
ld [wMenuWatchMovingOutOfBounds], a
ld a, [wd5a0]
and $7f
ld [wCurrentMenuItem], a

View file

@ -10,13 +10,13 @@ PromptUserToPlaySlots: ; 3730e (d:730e)
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .skip
jr nz, .done ; if player chose No
dec a
ld [wUpdateSpritesEnabled], a
ld hl, wcd4f
ld hl, wSlotMachineRerollCounter
xor a
ld [hli], a
ld [hl], $2
ld [hl], SMILE_BUBBLE
predef EmotionBubble
call GBPalWhiteOutWithDelay3
call LoadSlotMachineTiles
@ -25,30 +25,30 @@ PromptUserToPlaySlots: ; 3730e (d:730e)
call GoPAL_SET
call GBPalNormal
ld a, $e4
ld [$ff48], a
ld [rOBP0], a
ld hl, wd730
set 6, [hl]
xor a
ld [W_SUBANIMSUBENTRYADDR], a
ld hl, wTrainerSpriteOffset
ld [wSlotMachineAllowMatchesCounter], a
ld hl, wStoppingWhichSlotMachineWheel
ld bc, $0014
call FillMemory
call MainSlotMachineLoop
ld hl, wd730
res 6, [hl]
xor a
ld [W_SUBANIMSUBENTRYADDR], a
ld [wSlotMachineAllowMatchesCounter], a
call GBPalWhiteOutWithDelay3
ld a, $1
ld [wUpdateSpritesEnabled], a
call GoPAL_SET_CF1C
call ReloadMapSpriteTilePatterns
call ReloadTilesetTilePatterns
.skip
.done
call LoadScreenTilesFromBuffer2
call Delay3
call GBPalNormal
ld a, [wcc5e]
ld a, [wSlotMachineSavedROMBank]
push af
jp CloseTextDisplay
@ -57,43 +57,43 @@ PlaySlotMachineText: ; 37390 (d:7390)
db "@"
MainSlotMachineLoop: ; 37395 (d:7395)
call SlotMachine_37754
call SlotMachine_PrintCreditCoins
xor a
ld hl, wcd4a
ld hl, wPayoutCoins
ld [hli], a
ld [hl], a
call SlotMachine_3775f
call SlotMachine_PrintPayoutCoins
ld hl, BetHowManySlotMachineText
call PrintText
call SaveScreenTilesToBuffer1
.loop
ld a, $3
ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
ld a, $2
ld a, 2
ld [wMaxMenuItem], a
ld a, $c
ld a, 12
ld [wTopMenuItemY], a
ld a, $f
ld a, 15
ld [wTopMenuItemX], a
xor a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
ld [wcc37], a
ld hl, wTileMap + $ea
ld b, $5
ld c, $4
ld [wMenuWatchMovingOutOfBounds], a
hlCoord 14, 11
ld b, 5
ld c, 4
call TextBoxBorder
ld hl, wTileMap + $100
hlCoord 16, 12
ld de, CoinMultiplierSlotMachineText
call PlaceString
call HandleMenuInput
and $2
and B_BUTTON
jp nz, LoadScreenTilesFromBuffer1
ld a, [wCurrentMenuItem]
ld b, a
ld a, $3
ld a, 3
sub b
ld [wcd50], a
ld [wSlotMachineBet], a
ld hl, wPlayerCoins
ld c, a
ld a, [hli]
@ -107,11 +107,11 @@ MainSlotMachineLoop: ; 37395 (d:7395)
jr .loop
.skip1
call LoadScreenTilesFromBuffer1
call SlotMachine_37741
call SlotMachine_377d5
call SlotMachine_37480
ld a, $4
ld hl, wcd4d
call SlotMachine_SubtractBetFromPlayerCoins
call SlotMachine_LightBalls
call SlotMachine_SetFlags
ld a, 4
ld hl, wSlotMachineWheel1SlipCounter
ld [hli], a
ld [hli], a
ld [hl], a
@ -120,8 +120,8 @@ MainSlotMachineLoop: ; 37395 (d:7395)
call PlaySound
ld hl, StartSlotMachineText
call PrintText
call SlotMachine_374ad
call SlotMachine_37588
call SlotMachine_SpinWheels
call SlotMachine_CheckForMatches
ld hl, wPlayerCoins
ld a, [hli]
or [hl]
@ -143,7 +143,7 @@ MainSlotMachineLoop: ; 37395 (d:7395)
ld a, [wCurrentMenuItem]
and a
ret nz
call SlotMachine_377ce
call SlotMachine_PutOutLitBalls
jp MainSlotMachineLoop
CoinMultiplierSlotMachineText: ; 3745e (d:745e)
@ -171,55 +171,55 @@ OneMoreGoSlotMachineText: ; 3747b (d:747b)
TX_FAR _OneMoreGoSlotMachineText
db "@"
SlotMachine_37480: ; 37480 (d:7480)
ld hl, wcd4c
SlotMachine_SetFlags: ; 37480 (d:7480)
ld hl, wSlotMachineFlags
bit 7, [hl]
ret nz
ld a, [W_SUBANIMSUBENTRYADDR]
ld a, [wSlotMachineAllowMatchesCounter]
and a
jr nz, .skip1
jr nz, .allowMatches
call Random
and a
jr z, .skip2
jr z, .setAllowMatchesCounter ; 1/256 (~0.4%) chance
ld b, a
ld a, [wcc5b]
ld a, [wSlotMachineSevenAndBarModeChance]
cp b
jr c, .skip3
ld a, $d2
jr c, .allowSevenAndBarMatches
ld a, 210
cp b
jr c, .skip1
ld [hl], $0
jr c, .allowMatches ; 55/256 (~21.5%) chance
ld [hl], 0
ret
.skip1
.allowMatches
set 6, [hl]
ret
.skip2
ld a, $3c
ld [W_SUBANIMSUBENTRYADDR], a
.setAllowMatchesCounter
ld a, 60
ld [wSlotMachineAllowMatchesCounter], a
ret
.skip3
.allowSevenAndBarMatches
set 7, [hl]
ret
SlotMachine_374ad: ; 374ad (d:74ad)
SlotMachine_SpinWheels: ; 374ad (d:74ad)
ld c, 20
.loop1
push bc
call SlotMachine_37813
call SlotMachine_37823
call SlotMachine_37833
call SlotMachine_AnimWheel1
call SlotMachine_AnimWheel2
call SlotMachine_AnimWheel3
ld c, 2
call DelayFrames
pop bc
dec c
jr nz, .loop1
xor a
ld [wTrainerSpriteOffset], a
ld [wStoppingWhichSlotMachineWheel], a
.loop2
call SlotMachine_37882
call SlotMachine_374df
call SlotMachine_374fb
call SlotMachine_37517
call SlotMachine_HandleInputWhileWheelsSpin
call SlotMachine_StopOrAnimWheel1
call SlotMachine_StopOrAnimWheel2
call SlotMachine_StopOrAnimWheel3
ret c
ld a, [wOnSGB]
xor $1
@ -228,194 +228,214 @@ SlotMachine_374ad: ; 374ad (d:74ad)
call DelayFrames
jr .loop2
SlotMachine_374df: ; 374df (d:74df)
ld a, [wTrainerSpriteOffset]
cp $1
jr c, .skip
ld de, wTrainerEngageDistance
; Note that the wheels can only stop when a symbol is centred in the wheel
; and thus 3 full symbols rather than 2 full symbols and 2 half symbols are
; visible. The 3 functions below ensure this by checking if the wheel offset
; is even before stopping the wheel.
SlotMachine_StopOrAnimWheel1: ; 374df (d:74df)
ld a, [wStoppingWhichSlotMachineWheel]
cp 1
jr c, .animWheel
ld de, wSlotMachineWheel1Offset
ld a, [de]
rra
jr nc, .skip
ld hl, wcd4d
jr nc, .animWheel ; check that a symbol is centred in the wheel
ld hl, wSlotMachineWheel1SlipCounter
ld a, [hl]
and a
ret z
dec [hl]
call SlotMachine_3752c
call SlotMachine_StopWheel1Early
ret nz
.skip
jp SlotMachine_37813
.animWheel
jp SlotMachine_AnimWheel1
SlotMachine_374fb: ; 374fb (d:74fb)
ld a, [wTrainerSpriteOffset]
cp $2
jr c, .skip
ld de, wTrainerFacingDirection
SlotMachine_StopOrAnimWheel2: ; 374fb (d:74fb)
ld a, [wStoppingWhichSlotMachineWheel]
cp 2
jr c, .animWheel
ld de, wSlotMachineWheel2Offset
ld a, [de]
rra
jr nc, .skip
ld hl, wcd4e
jr nc, .animWheel ; check that a symbol is centred in the wheel
ld hl, wSlotMachineWheel2SlipCounter
ld a, [hl]
and a
ret z
dec [hl]
call SlotMachine_37552
call SlotMachine_StopWheel2Early
ret z
.skip
jp SlotMachine_37823
.animWheel
jp SlotMachine_AnimWheel2
SlotMachine_37517: ; 37517 (d:7517)
ld a, [wTrainerSpriteOffset]
cp $3
jr c, .skip
ld de, wTrainerScreenY
SlotMachine_StopOrAnimWheel3: ; 37517 (d:7517)
ld a, [wStoppingWhichSlotMachineWheel]
cp 3
jr c, .animWheel
ld de, wSlotMachineWheel3Offset
ld a, [de]
rra
jr nc, .skip
jr nc, .animWheel ; check that a symbol is centred in the wheel
; wheel 3 stops as soon as possible
scf
ret
.skip
call SlotMachine_37833
.animWheel
call SlotMachine_AnimWheel3
and a
ret
SlotMachine_3752c: ; 3752c (d:752c)
call SlotMachine_GetWheelOneTile
ld hl, wTrainerScreenX
ld a, [wcd4c]
SlotMachine_StopWheel1Early: ; 3752c (d:752c)
call SlotMachine_GetWheel1Tiles
ld hl, wSlotMachineWheel1BottomTile
ld a, [wSlotMachineFlags]
and $80
jr nz, .skip1
jr nz, .sevenAndBarMode
; Stop early if the middle symbol is not a cherry.
inc hl
ld a, [hl]
cp $a
jr nz, .skip2
cp SLOTSCHERRY >> 8
jr nz, .stopWheel
ret
.skip1
; It looks like this was intended to make the wheel stop when a 7 symbol was
; visible, but it has a bug and so the wheel stops randomly.
.sevenAndBarMode
ld c, $3
.loop
ld a, [hli]
cp $2
jr c, .skip2
cp SLOTS7 >> 8
jr c, .stopWheel ; condition never true
dec c
jr nz, .loop
ret
.skip2
.stopWheel
inc a
ld hl, wcd4d
ld [hl], $0
ld hl, wSlotMachineWheel1SlipCounter
ld [hl], 0
ret
SlotMachine_37552: ; 37552 (d:7552)
call SlotMachine_GetWheelTwoTile
ld a, [wcd4c]
SlotMachine_StopWheel2Early: ; 37552 (d:7552)
call SlotMachine_GetWheel2Tiles
ld a, [wSlotMachineFlags]
and $80
jr nz, .skip1
call SlotMachine_3756e
jr nz, .sevenAndBarMode
; Stop early if any symbols are lined up in the first two wheels.
call SlotMachine_FindWheel1Wheel2Matches
ret nz
jr .skip2
.skip1
call SlotMachine_3756e
jr .stopWheel
; Stop early if two 7 symbols or two bar symbols are lined up in the first two
; wheels OR if no symbols are lined up and the bottom symbol in wheel 2 is a
; 7 symbol or bar symbol. The second part could be a bug or a way to reduce the
; player's odds.
.sevenAndBarMode
call SlotMachine_FindWheel1Wheel2Matches
ld a, [de]
cp $7
cp (SLOTSBAR >> 8) + 1
ret nc
.skip2
.stopWheel
xor a
ld [wcd4e], a
ld [wSlotMachineWheel2SlipCounter], a
ret
SlotMachine_3756e: ; 3756e (d:756e)
ld hl, wTrainerScreenX
ld de, wcd44
SlotMachine_FindWheel1Wheel2Matches: ; 3756e (d:756e)
; return whether wheel 1 and wheel 2's current positions allow a match (given
; that wheel 3 stops in a good position) in Z
ld hl, wSlotMachineWheel1BottomTile
ld de, wSlotMachineWheel2BottomTile
ld a, [de]
cp [hl]
cp [hl] ; wheel 1 bottom, wheel 2 bottom
ret z
inc de
ld a, [de]
cp [hl]
cp [hl] ; wheel 1 bottom, wheel 2 middle
ret z
inc hl
cp [hl]
cp [hl] ; wheel 1 middle, wheel 2 middle
ret z
inc hl
cp [hl]
cp [hl] ; wheel 1 top, wheel 2 middle
ret z
inc de
ld a, [de]
cp [hl]
cp [hl] ; wheel 1 top, wheel 2 top
ret z
dec de
dec de
ret
SlotMachine_37588: ; 37588 (d:7588)
call SlotMachine_GetWheelThreeTile
ld a, [wcd50]
cp $2
jr z, .skip1
cp $1
jr z, .skip2
ld hl, wTrainerScreenX
ld de, wcd45
ld bc, wcd49
SlotMachine_CheckForMatches: ; 37588 (d:7588)
call SlotMachine_GetWheel3Tiles
ld a, [wSlotMachineBet]
cp 2
jr z, .checkMatchesFor2CoinBet
cp 1
jr z, .checkMatchFor1CoinBet
; 3 coin bet allows diagonal matches (plus the matches for 1/2 coin bets)
ld hl, wSlotMachineWheel1BottomTile
ld de, wSlotMachineWheel2MiddleTile
ld bc, wSlotMachineWheel3TopTile
call SlotMachine_CheckForMatch
jp z, .skip5
ld hl, wcd43
ld de, wcd45
ld bc, wcd47
jp z, .foundMatch
ld hl, wSlotMachineWheel1TopTile
ld de, wSlotMachineWheel2MiddleTile
ld bc, wSlotMachineWheel3BottomTile
call SlotMachine_CheckForMatch
jr z, .skip5
.skip1
ld hl, wcd43
ld de, wcd46
ld bc, wcd49
jr z, .foundMatch
; 2 coin bet allows top/bottom horizontal matches (plus the match for a 1 coin bet)
.checkMatchesFor2CoinBet
ld hl, wSlotMachineWheel1TopTile
ld de, wSlotMachineWheel2TopTile
ld bc, wSlotMachineWheel3TopTile
call SlotMachine_CheckForMatch
jr z, .skip5
ld hl, wTrainerScreenX
ld de, wcd44
ld bc, wcd47
jr z, .foundMatch
ld hl, wSlotMachineWheel1BottomTile
ld de, wSlotMachineWheel2BottomTile
ld bc, wSlotMachineWheel3BottomTile
call SlotMachine_CheckForMatch
jr z, .skip5
.skip2
ld hl, wcd42
ld de, wcd45
ld bc, wcd48
jr z, .foundMatch
; 1 coin bet only allows a middle horizontal match
.checkMatchFor1CoinBet
ld hl, wSlotMachineWheel1MiddleTile
ld de, wSlotMachineWheel2MiddleTile
ld bc, wSlotMachineWheel3MiddleTile
call SlotMachine_CheckForMatch
jr z, .skip5
ld a, [wcd4c]
jr z, .foundMatch
ld a, [wSlotMachineFlags]
and $c0
jr z, .skip3
ld hl, wcd4f
jr z, .noMatch
ld hl, wSlotMachineRerollCounter
dec [hl]
jr nz, .skip4
.skip3
jr nz, .rollWheel3DownByOneSymbol
.noMatch
ld hl, NotThisTimeText
call PrintText
.loop
.done
xor a
ld [wc002], a
ret
.skip4
call SlotMachine_37833
.rollWheel3DownByOneSymbol
call SlotMachine_AnimWheel3
call DelayFrame
call SlotMachine_37833
call SlotMachine_AnimWheel3
call DelayFrame
jp SlotMachine_37588
.skip5
ld a, [wcd4c]
jp SlotMachine_CheckForMatches
.foundMatch
ld a, [wSlotMachineFlags]
and $c0
jr z, .skip4
jr z, .rollWheel3DownByOneSymbol ; roll wheel if player isn't allowed to win
and $80
jr nz, .skip6
jr nz, .acceptMatch
; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel
ld a, [hl]
cp $7
jr c, .skip4
.skip6
cp (SLOTSBAR >> 8) + 1
jr c, .rollWheel3DownByOneSymbol
.acceptMatch
ld a, [hl]
sub $2
ld [wTrainerScreenX], a
ld [wSlotMachineWinningSymbol], a
ld hl, SlotRewardPointers
ld c, a
ld b, $0
ld b, 0
add hl, bc
ld a, [hli]
ld e, a
@ -426,39 +446,39 @@ SlotMachine_37588: ; 37588 (d:7588)
ld h, [hl]
ld l, a
ld de, wcf4b
ld bc, $0004
ld bc, 4
call CopyData
pop hl
ld de, .asm_37638
ld de, .flashScreenLoop
push de
jp [hl]
.asm_37638
ld a, [$ff47]
.flashScreenLoop
ld a, [rBGP]
xor $40
ld [$ff47], a
ld [rBGP], a
ld c, 5
call DelayFrames
dec b
jr nz, .asm_37638
ld hl, wcd4a
jr nz, .flashScreenLoop
ld hl, wPayoutCoins
ld [hl], d
inc hl
ld [hl], e
call SlotMachine_3775f
ld hl, SlotsMachineText_37665
call SlotMachine_PrintPayoutCoins
ld hl, SymbolLinedUpSlotMachineText
call PrintText
call WaitForTextScrollButtonPress
call SlotMachine_3776b
call SlotMachine_3775f
call SlotMachine_PayCoinsToPlayer
call SlotMachine_PrintPayoutCoins
ld a, $e4
ld [$ff48], a
jp .loop
ld [rOBP0], a
jp .done
SlotsMachineText_37665: ; 37665 (d:7665)
SymbolLinedUpSlotMachineText: ; 37665 (d:7665)
TX_ASM
push bc
call SlotMachine_37728
call SlotMachine_PrintWinningSymbol
ld hl, LinedUpText
pop bc
inc bc
@ -510,28 +530,28 @@ SlotMachine_CheckForMatch: ; 376a2 (d:76a2)
cp [hl]
ret
SlotMachine_GetWheelThreeTile: ; 376a8 (d:76a8)
ld de, wcd47
SlotMachine_GetWheel3Tiles: ; 376a8 (d:76a8)
ld de, wSlotMachineWheel3BottomTile
ld hl, SlotMachineWheel3
ld a, [wTrainerScreenY]
call SlotMachine_GetWheelTile
ld a, [wSlotMachineWheel3Offset]
call SlotMachine_GetWheelTiles
SlotMachine_GetWheelTwoTile: ; 376b4 (d:76b4)
ld de, wcd44
SlotMachine_GetWheel2Tiles: ; 376b4 (d:76b4)
ld de, wSlotMachineWheel2BottomTile
ld hl, SlotMachineWheel2
ld a, [wTrainerFacingDirection]
call SlotMachine_GetWheelTile
ld a, [wSlotMachineWheel2Offset]
call SlotMachine_GetWheelTiles
SlotMachine_GetWheelOneTile: ; 376c0 (d:76c0)
ld de, wTrainerScreenX
SlotMachine_GetWheel1Tiles: ; 376c0 (d:76c0)
ld de, wSlotMachineWheel1BottomTile
ld hl, SlotMachineWheel1
ld a, [wTrainerEngageDistance]
ld a, [wSlotMachineWheel1Offset]
SlotMachine_GetWheelTile: ; 376c9 (d:76c9)
SlotMachine_GetWheelTiles: ; 376c9 (d:76c9)
ld c, a
ld b, $0
ld b, 0
add hl, bc
ld c, $3
ld c, 3
.loop
ld a, [hli]
ld [de], a
@ -542,7 +562,7 @@ SlotMachine_GetWheelTile: ; 376c9 (d:76c9)
ret
SlotReward8Func: ; 376d7 (d:76d7)
ld hl, W_SUBANIMSUBENTRYADDR
ld hl, wSlotMachineAllowMatchesCounter
ld a, [hl]
and a
jr z, .skip
@ -553,7 +573,7 @@ SlotReward8Func: ; 376d7 (d:76d7)
ret
SlotReward15Func: ; 376e5 (d:76e5)
ld hl, W_SUBANIMSUBENTRYADDR
ld hl, wSlotMachineAllowMatchesCounter
ld a, [hl]
and a
jr z, .skip
@ -567,7 +587,7 @@ SlotReward100Func: ; 376f3 (d:76f3)
ld a, (SFX_1f_42 - SFX_Headers_1f) / 3
call PlaySound
xor a
ld [wcd4c], a
ld [wSlotMachineFlags], a
ld b, $8
ld de, 100
ret
@ -581,9 +601,9 @@ SlotReward300Func: ; 37702 (d:7702)
cp $80
ld a, $0
jr c, .skip
ld [wcd4c], a
ld [wSlotMachineFlags], a
.skip
ld [W_SUBANIMSUBENTRYADDR], a
ld [wSlotMachineAllowMatchesCounter], a
ld b, $14
ld de, 300
ret
@ -592,26 +612,27 @@ YeahText: ; 37722 (d:7722)
TX_FAR _YeahText
db $0a, "@"
SlotMachine_37728: ; 37728 (d:7728)
ld hl, wTileMap + $11a
ld a, [wTrainerScreenX]
SlotMachine_PrintWinningSymbol: ; 37728 (d:7728)
; prints winning symbol and down arrow in text box
hlCoord 2, 14
ld a, [wSlotMachineWinningSymbol]
add $25
ld [hli], a
inc a
ld [hld], a
inc a
ld de, $ffec
ld de, -SCREEN_WIDTH
add hl, de
ld [hli], a
inc a
ld [hl], a
ld hl, wTileMap + $152
ld [hl], $ee
hlCoord 18, 16
ld [hl], $ee ; down arrow
ret
SlotMachine_37741: ; 37741 (d:7741)
ld hl, wcd4b
ld a, [wcd50]
SlotMachine_SubtractBetFromPlayerCoins: ; 37741 (d:7741)
ld hl, wTempCoins2 + 1
ld a, [wSlotMachineBet]
ld [hld], a
xor a
ld [hli], a
@ -619,136 +640,143 @@ SlotMachine_37741: ; 37741 (d:7741)
ld c, $2
predef SubBCDPredef
SlotMachine_37754: ; 37754 (d:7754)
ld hl, wTileMap + $19
SlotMachine_PrintCreditCoins: ; 37754 (d:7754)
hlCoord 5, 1
ld de, wPlayerCoins
ld c, $2
jp PrintBCDNumber
SlotMachine_3775f: ; 3775f (d:775f)
ld hl, wTileMap + $1f
ld de, wcd4a
ld bc, $8204
SlotMachine_PrintPayoutCoins: ; 3775f (d:775f)
hlCoord 11, 1
ld de, wPayoutCoins
ld bc, $8204 ; 2 bytes, 4 digits, leading zeroes
jp PrintNumber
SlotMachine_3776b: ; 3776b (d:776b)
SlotMachine_PayCoinsToPlayer: ; 3776b (d:776b)
ld a, $1
ld [wc002], a
call WaitForSoundToFinish
ld hl, wcd46
; Put 1 in the temp coins variable. This value is added to the player's coins
; repeatedly so the player can watch the value go up 1 coin at a time.
ld hl, wTempCoins1
xor a
ld [hli], a
inc a
ld [hl], a
ld a, $5
ld [W_SUBANIMTRANSFORM], a
ld a, 5
ld [wAnimCounter], a
; Subtract 1 from the payout amount and add 1 to the player's coins each
; iteration until the payout amount reaches 0.
.loop
ld a, [wcd4b]
ld a, [wPayoutCoins + 1]
ld l, a
ld a, [wcd4a]
ld a, [wPayoutCoins]
ld h, a
or l
ret z
ld de, $ffff
ld de, -1
add hl, de
ld a, l
ld [wcd4b], a
ld [wPayoutCoins + 1], a
ld a, h
ld [wcd4a], a
ld hl, wcd47
ld [wPayoutCoins], a
ld hl, wTempCoins1 + 1
ld de, wPlayerCoins + 1
ld c, $2
predef AddBCDPredef
call SlotMachine_37754
call SlotMachine_3775f
call SlotMachine_PrintCreditCoins
call SlotMachine_PrintPayoutCoins
ld a, (SFX_1f_65 - SFX_Headers_1f) / 3
call PlaySound
ld a, [W_SUBANIMTRANSFORM]
ld a, [wAnimCounter]
dec a
jr nz, .skip1
ld a, [$ff48]
xor $40
ld [$ff48], a
ld a, $5
ld a, [rOBP0]
xor $40 ; make the slot wheel symbols flash
ld [rOBP0], a
ld a, 5
.skip1
ld [W_SUBANIMTRANSFORM], a
ld a, [wTrainerScreenX]
cp $7
ld [wAnimCounter], a
ld a, [wSlotMachineWinningSymbol]
cp (SLOTSBAR >> 8) + 1
ld c, 8
jr nc, .skip2
srl c
srl c ; c = 4 (make the the coins transfer faster if the symbol was 7 or bar)
.skip2
call DelayFrames
jr .loop
SlotMachine_377ce: ; 377ce (d:77ce)
SlotMachine_PutOutLitBalls: ; 377ce (d:77ce)
ld a, $23
ld [wd08a], a
jr SlotMachine_377e3
jr SlotMachine_UpdateThreeCoinBallTiles
SlotMachine_377d5: ; 377d5 (d:77d5)
SlotMachine_LightBalls: ; 377d5 (d:77d5)
ld a, $14
ld [wd08a], a
ld a, [wcd50]
ld a, [wSlotMachineBet]
dec a
jr z, SlotMachine_377fb
jr z, SlotMachine_UpdateOneCoinBallTiles
dec a
jr z, SlotMachine_377ef
jr z, SlotMachine_UpdateTwoCoinBallTiles
SlotMachine_377e3: ; 377e3 (d:77e3)
ld hl, wTileMap + $2b
call SlotMachine_377fe
ld hl, wTileMap + $cb
call SlotMachine_377fe
SlotMachine_UpdateThreeCoinBallTiles: ; 377e3 (d:77e3)
hlCoord 3, 2
call SlotMachine_UpdateBallTiles
hlCoord 3, 10
call SlotMachine_UpdateBallTiles
SlotMachine_377ef: ; 377ef (d:77ef)
ld hl, wTileMap + $53
call SlotMachine_377fe
ld hl, wTileMap + $a3
call SlotMachine_377fe
SlotMachine_UpdateTwoCoinBallTiles: ; 377ef (d:77ef)
hlCoord 3, 4
call SlotMachine_UpdateBallTiles
hlCoord 3, 8
call SlotMachine_UpdateBallTiles
SlotMachine_377fb: ; 377fb (d:77fb)
ld hl, wTileMap + $7b
SlotMachine_UpdateOneCoinBallTiles: ; 377fb (d:77fb)
hlCoord 3, 6
SlotMachine_377fe: ; 377fe (d:77fe)
SlotMachine_UpdateBallTiles: ; 377fe (d:77fe)
ld a, [wd08a]
ld [hl], a
ld bc, $000d
ld bc, 13
add hl, bc
ld [hl], a
ld bc, $0007
ld bc, 7
add hl, bc
inc a
ld [hl], a
ld bc, $000d
ld bc, 13
add hl, bc
ld [hl], a
ret
SlotMachine_37813: ; 37813 (d:7813)
SlotMachine_AnimWheel1: ; 37813 (d:7813)
ld bc, SlotMachineWheel1
ld de, wTrainerEngageDistance
ld de, wSlotMachineWheel1Offset
ld hl, wOAMBuffer
ld a, $30
ld [W_BASECOORDX], a
jr SlotMachine_37841
jr SlotMachine_AnimWheel
SlotMachine_37823: ; 37823 (d:7823)
SlotMachine_AnimWheel2: ; 37823 (d:7823)
ld bc, SlotMachineWheel2
ld de, wTrainerFacingDirection
ld de, wSlotMachineWheel2Offset
ld hl, wOAMBuffer + $30
ld a, $50
ld [W_BASECOORDX], a
jr SlotMachine_37841
jr SlotMachine_AnimWheel
SlotMachine_37833: ; 37833 (d:7833)
SlotMachine_AnimWheel3: ; 37833 (d:7833)
ld bc, SlotMachineWheel3
ld de, wTrainerScreenY
ld de, wSlotMachineWheel3Offset
ld hl, wOAMBuffer + $60
ld a, $70
ld [W_BASECOORDX], a
SlotMachine_37841: ; 37841 (d:7841)
SlotMachine_AnimWheel: ; 37841 (d:7841)
ld a, $58
ld [W_BASECOORDY], a
push de
@ -756,10 +784,9 @@ SlotMachine_37841: ; 37841 (d:7841)
ld d, b
add c
ld e, a
jr nc, SlotMachine_3784e
jr nc, .loop
inc d
SlotMachine_3784e: ; 3784e (d:784e)
.loop
ld a, [W_BASECOORDY]
ld [hli], a
ld a, [W_BASECOORDX]
@ -783,30 +810,30 @@ SlotMachine_3784e: ; 3784e (d:784e)
sub $8
ld [W_BASECOORDY], a
cp $28
jr nz, SlotMachine_3784e
jr nz, .loop
pop de
ld a, [de]
inc a
cp $1e
inc a ; advance the offset so that the wheel animates
cp 30
jr nz, .skip
xor a
xor a ; wrap around to 0 when the offset reaches 30
.skip
ld [de], a
ret
SlotMachine_37882: ; 37882 (d:7882)
SlotMachine_HandleInputWhileWheelsSpin: ; 37882 (d:7882)
call DelayFrame
call JoypadLowSensitivity
ld a, [hJoy5]
and $1
and A_BUTTON
ret z
ld hl, wTrainerSpriteOffset
ld hl, wStoppingWhichSlotMachineWheel
ld a, [hl]
dec a
ld de, wcd4d
ld de, wSlotMachineWheel1SlipCounter
jr z, .skip
dec a
ld de, wcd4e
ld de, wSlotMachineWheel2SlipCounter
jr z, .skip
.loop
inc [hl]
@ -845,20 +872,13 @@ LoadSlotMachineTiles: ; 378a8 (d:78a8)
ld [hli], a
ld [hli], a
ld [hl], a
call SlotMachine_37813
call SlotMachine_37823
jp SlotMachine_37833
call SlotMachine_AnimWheel1
call SlotMachine_AnimWheel2
jp SlotMachine_AnimWheel3
SlotMachineMap: ; 378f5 (d:78f5)
INCBIN "gfx/tilemaps/slotmachine.map"
SLOTS7 EQU $0200
SLOTSBAR EQU $0604
SLOTSCHERRY EQU $0A08
SLOTSFISH EQU $0E0C
SLOTSBIRD EQU $1210
SLOTSMOUSE EQU $1614
INCLUDE "data/slot_machine_wheels.asm"
SlotMachineTiles1: ; 37a51 (d:7a51)

View file

@ -348,7 +348,7 @@ Func_4524: ; 4524 (1:4524)
jp LoadFrontSpriteByMonIndex
Func_4533: ; 4533 (1:4533)
ld [$ffbd], a
ld [H_AUTOBGTRANSFERDEST + 1], a
jp Delay3
LoadCopyrightAndTextBoxTiles: ; 4538 (1:4538)

View file

@ -10,7 +10,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e)
ld a, [W_CURMAP]
push af
ld b, $0
call Func_711c4
call DrawPlayerOrBirdSprite ; player sprite
hlCoord 1, 0
ld de, wcd6d
call PlaceString
@ -23,7 +23,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e)
ld bc, (BANK(TownMapCursor) << 8) + $04
call CopyVideoDataDouble
xor a
ld [wWhichTrade], a
ld [wWhichTownMapLocation], a
pop af
jr .enterLoop
@ -32,29 +32,29 @@ DisplayTownMap: ; 70e3e (1c:4e3e)
ld bc, $114
call ClearScreenArea
ld hl, TownMapOrder
ld a, [wWhichTrade]
ld a, [wWhichTownMapLocation]
ld c, a
ld b, $0
ld b, 0
add hl, bc
ld a, [hl]
.enterLoop
ld de, wHPBarMaxHP
call FindTownMapCoords
ld de, wTownMapCoords
call LoadTownMapEntry
ld a, [de]
push hl
call SetTownMapOAMCoords
call TownMapCoordsToOAMCoords
ld a, $4
ld [wcd5b], a
ld [wOAMBaseTile], a
ld hl, wOAMBuffer + $10
call Func_71279
call WriteTownMapSpriteOAM ; town map cursor sprite
pop hl
ld de, wcd6d
.asm_70eac
.copyMapName
ld a, [hli]
ld [de], a
inc de
cp $50
jr nz, .asm_70eac
jr nz, .copyMapName
hlCoord 1, 0
ld de, wcd6d
call PlaceString
@ -72,35 +72,35 @@ DisplayTownMap: ; 70e3e (1c:4e3e)
ld a, (SFX_02_3c - SFX_Headers_02) / 3
call PlaySound
bit 6, b
jr nz, .upPressed
jr nz, .pressedUp
bit 7, b
jr nz, .downPressed
jr nz, .pressedDown
xor a
ld [wTownMapSpriteBlinkingEnabled], a
ld [hJoy7], a
ld [wTownMapSpriteBlinkingCounter], a
ld [wAnimCounter], a
call ExitTownMap
pop hl
pop af
ld [hl], a
ret
.upPressed
ld a, [wWhichTrade]
.pressedUp
ld a, [wWhichTownMapLocation]
inc a
cp TownMapOrderEnd - TownMapOrder ; number of list items + 1
jr nz, .noOverflow
xor a
.noOverflow
ld [wWhichTrade], a
ld [wWhichTownMapLocation], a
jp .townMapLoop
.downPressed
ld a, [wWhichTrade]
.pressedDown
ld a, [wWhichTownMapLocation]
dec a
cp $ff
cp -1
jr nz, .noUnderflow
ld a, TownMapOrderEnd - TownMapOrder - 1 ; number of list items
.noUnderflow
ld [wWhichTrade], a
ld [wWhichTownMapLocation], a
jp .townMapLoop
INCLUDE "data/town_map_order.asm"
@ -146,7 +146,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
ld hl, vChars1 + $6d0
ld bc, (BANK(TownMapUpArrow) << 8) + $01
call CopyVideoDataDouble
call SetupVisitedTownsList
call BuildFlyLocationsList
ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
@ -157,10 +157,9 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
call PlaceString
ld a, [W_CURMAP]
ld b, $0
call Func_711c4
ld hl, wTrainerEngageDistance
call DrawPlayerOrBirdSprite
ld hl, wFlyLocationsList
deCoord 18, 0
.townMapFlyLoop
ld a, $7f
ld [de], a
@ -172,7 +171,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
pop hl
ld a, [hl]
ld b, $4
call Func_711c4
call DrawPlayerOrBirdSprite ; draw bird sprite
hlCoord 3, 0
ld de, wcd6d
call PlaceString
@ -193,15 +192,15 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
and A_BUTTON | B_BUTTON | D_UP | D_DOWN
jr z, .inputLoop
bit 0, b
jr nz, .aButtonPressed
jr nz, .pressedA
ld a, (SFX_02_3c - SFX_Headers_02) / 3
call PlaySound
bit 6, b
jr nz, .upPressed
jr nz, .pressedUp
bit 7, b
jr nz, .downPressed
jr .bButtonPressed
.aButtonPressed
jr nz, .pressedDown
jr .pressedB
.pressedA
ld a, (SFX_02_3e - SFX_Headers_02) / 3
call PlaySound
ld a, [hl]
@ -210,7 +209,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
set 3, [hl]
inc hl
set 7, [hl]
.bButtonPressed
.pressedB
xor a
ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOutWithDelay3
@ -218,36 +217,36 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
pop af
ld [hl], a
ret
.upPressed
.pressedUp
deCoord 18, 0
inc hl
ld a, [hl]
cp $ff
jr z, .asm_71052
jr z, .wrapToStartOfList
cp $fe
jr z, .upPressed
jr z, .pressedUp ; skip past unvisited towns
jp .townMapFlyLoop
.asm_71052
ld hl, wTrainerEngageDistance
.wrapToStartOfList
ld hl, wFlyLocationsList
jp .townMapFlyLoop
.downPressed
.pressedDown
deCoord 19, 0
dec hl
ld a, [hl]
cp $ff
jr z, .asm_71068
jr z, .wrapToEndOfList
cp $fe
jr z, .downPressed
jr z, .pressedDown ; skip past unvisited towns
jp .townMapFlyLoop
.asm_71068
ld hl, wcd49
jr .downPressed
.wrapToEndOfList
ld hl, wFlyLocationsList + 11
jr .pressedDown
ToText: ; 7106d (1c:506d)
db "To@"
SetupVisitedTownsList: ; 71070 (1c:5070)
ld hl, wWhichTrade
BuildFlyLocationsList: ; 71070 (1c:5070)
ld hl, wFlyLocationsList - 1
ld [hl], $ff
inc hl
ld a, [W_TOWNVISITEDFLAG]
@ -258,9 +257,9 @@ SetupVisitedTownsList: ; 71070 (1c:5070)
.loop
srl d
rr e
ld a, $fe
ld a, $fe ; store $fe if the town hasn't been visited
jr nc, .notVisited
ld a, b
ld a, b ; store the map number of the town if it has been visited
.notVisited
ld [hl], a
inc hl
@ -305,10 +304,10 @@ LoadTownMap: ; 7109b (1c:509b)
swap a
and $f
add $60
.uncompressTile
.writeRunLoop
ld [hli], a
dec c
jr nz, .uncompressTile
jr nz, .writeRunLoop
inc de
jr .nextTile
.done
@ -318,7 +317,7 @@ LoadTownMap: ; 7109b (1c:509b)
call Delay3
call GBPalNormal
xor a
ld [wTownMapSpriteBlinkingCounter], a
ld [wAnimCounter], a
inc a
ld [wTownMapSpriteBlinkingEnabled], a
ret
@ -328,6 +327,7 @@ CompressedMap: ; 71100 (1c:5100)
INCBIN "gfx/town_map.rle"
ExitTownMap: ; 711ab (1c:51ab)
; clear town map graphics data and load usual graphics data
xor a
ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOut
@ -338,17 +338,19 @@ ExitTownMap: ; 711ab (1c:51ab)
call UpdateSprites
jp GoPAL_SET_CF1C
Func_711c4: ; 711c4 (1c:51c4)
DrawPlayerOrBirdSprite: ; 711c4 (1c:51c4)
; a = map number
; b = OAM base tile
push af
ld a, b
ld [wcd5b], a
ld [wOAMBaseTile], a
pop af
ld de, wHPBarMaxHP
call FindTownMapCoords
ld de, wTownMapCoords
call LoadTownMapEntry
ld a, [de]
push hl
call SetTownMapOAMCoords
call Func_7126d
call TownMapCoordsToOAMCoords
call WritePlayerOrBirdSpriteOAM
pop hl
ld de, wcd6d
.asm_711dc
@ -364,33 +366,34 @@ Func_711c4: ; 711c4 (1c:51c4)
DisplayWildLocations: ; 711ef (1c:51ef)
callba FindWildLocationsOfMon
call Func_712d9
call ZeroOutDuplicatesInList
ld hl, wOAMBuffer
ld de, wBuffer
ld de, wTownMapCoords
.loop
ld a, [de]
cp $ff
jr z, .exitLoop
and a
jr z, .next
jr z, .nextEntry
push hl
call FindTownMapCoords
call LoadTownMapEntry
pop hl
ld a, [de]
cp $19
jr z, .next
call SetTownMapOAMCoords
cp $19 ; Cerulean Cave's coordinates
jr z, .nextEntry ; skip Cerulean Cave
call TownMapCoordsToOAMCoords
ld a, $4 ; nest icon tile no.
ld [hli], a
xor a
ld [hli], a
.next
.nextEntry
inc de
jr .loop
.exitLoop
ld a, l
and a
jr nz, .locationKnown
and a ; were any OAM entries written?
jr nz, .drawPlayerSprite
; if no OAM entries were written, print area unknown text
hlCoord 1, 7
ld b, $2
ld c, $f
@ -399,10 +402,10 @@ DisplayWildLocations: ; 711ef (1c:51ef)
ld de, AreaUnknownText
call PlaceString
jr .done
.locationKnown
.drawPlayerSprite
ld a, [W_CURMAP]
ld b, $0
call Func_711c4
call DrawPlayerOrBirdSprite
.done
ld hl, wOAMBuffer
ld de, wTileMapBackup
@ -412,39 +415,41 @@ DisplayWildLocations: ; 711ef (1c:51ef)
AreaUnknownText: ; 7124a (1c:524a)
db " AREA UNKNOWN@"
SetTownMapOAMCoords: ; 71258 (1c:5258)
TownMapCoordsToOAMCoords: ; 71258 (1c:5258)
; in: lower nybble of a = x, upper nybble of a = y
; out: b and [hl] = (y * 8) + 24, c and [hl+1] = (x * 8) + 24
push af
and $f0
srl a
add $18
add 24
ld b, a
ld [hli], a
pop af
and $f
swap a
srl a
add $18
add 24
ld c, a
ld [hli], a
ret
Func_7126d: ; 7126d (1c:526d)
ld a, [wcd5b]
WritePlayerOrBirdSpriteOAM: ; 7126d (1c:526d)
ld a, [wOAMBaseTile]
and a
ld hl, wOAMBuffer + $90
jr z, Func_71279
ld hl, wOAMBuffer + $80
ld hl, wOAMBuffer + $90 ; for player sprite
jr z, WriteTownMapSpriteOAM
ld hl, wOAMBuffer + $80 ; for bird sprite
Func_71279: ; 71279 (1c:5279)
WriteTownMapSpriteOAM: ; 71279 (1c:5279)
push hl
ld hl, $fcfc
add hl, bc
add hl, bc ; subtract 4 from c (X coord) and 3 from b (Y coord)
ld b, h
ld c, l
pop hl
WriteAsymmetricMonPartySpriteOAM: ; 71281 (1c:5281)
; Writes 4 OAM blocks for a helix mon party sprite, since is does not have
; Writes 4 OAM blocks for a helix mon party sprite, since it does not have
; a vertical line of symmetry.
ld de, $202
.loop
@ -455,10 +460,10 @@ WriteAsymmetricMonPartySpriteOAM: ; 71281 (1c:5281)
ld [hli], a
ld a, c
ld [hli], a
ld a, [wcd5b]
ld a, [wOAMBaseTile]
ld [hli], a
inc a
ld [wcd5b], a
ld [wOAMBaseTile], a
xor a
ld [hli], a
inc d
@ -492,7 +497,7 @@ WriteSymmetricMonPartySpriteOAM: ; 712a6 (1c:52a6)
ld [hli], a
ld a, c
ld [hli], a
ld a, [wcd5b]
ld a, [wOAMBaseTile]
ld [hli], a
ld a, [wcd5c]
ld [hli], a
@ -507,7 +512,7 @@ WriteSymmetricMonPartySpriteOAM: ; 712a6 (1c:52a6)
pop bc
pop de
push hl
ld hl, wcd5b
ld hl, wOAMBaseTile
inc [hl]
inc [hl]
pop hl
@ -518,9 +523,10 @@ WriteSymmetricMonPartySpriteOAM: ; 712a6 (1c:52a6)
jr nz, .loop
ret
Func_712d9: ; 712d9 (1c:52d9)
ld de, wHPBarMaxHP
.asm_712dc
ZeroOutDuplicatesInList: ; 712d9 (1c:52d9)
; replace duplicate bytes in the list of wild pokemon locations with 0
ld de, wBuffer
.loop
ld a, [de]
inc de
cp $ff
@ -528,39 +534,41 @@ Func_712d9: ; 712d9 (1c:52d9)
ld c, a
ld l, e
ld h, d
.asm_712e4
.zeroDuplicatesLoop
ld a, [hl]
cp $ff
jr z, .asm_712dc
jr z, .loop
cp c
jr nz, .asm_712ee
jr nz, .skipZeroing
xor a
ld [hl], a
.asm_712ee
.skipZeroing
inc hl
jr .asm_712e4
jr .zeroDuplicatesLoop
FindTownMapCoords: ; 712f1 (1c:52f1)
LoadTownMapEntry: ; 712f1 (1c:52f1)
; in: a = map number
; out: lower nybble of [de] = x, upper nybble of [de] = y, hl = address of name
cp REDS_HOUSE_1F
jr c, .townOrRoute
ld bc, $4
jr c, .external
ld bc, 4
ld hl, InternalMapEntries
.loop
cp [hl]
jr c, .match
jr c, .foundEntry
add hl, bc
jr .loop
.match
.foundEntry
inc hl
jr .done
.townOrRoute
jr .readEntry
.external
ld hl, ExternalMapEntries
ld c, a
ld b, $0
ld b, 0
add hl, bc
add hl, bc
add hl, bc
.done
.readEntry
ld a, [hli]
ld [de], a
ld a, [hli]
@ -576,7 +584,7 @@ MonNestIcon: ; 716be (1c:56be)
INCBIN "gfx/mon_nest_icon.1bpp"
TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6)
ld a, [wTownMapSpriteBlinkingCounter]
ld a, [wAnimCounter]
inc a
cp 25
jr z, .hideSprites
@ -600,5 +608,5 @@ TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6)
jr nz, .hideSpritesLoop
ld a, 25
.done
ld [wTownMapSpriteBlinkingCounter], a
ld [wAnimCounter], a
jp DelayFrame

View file

@ -13,7 +13,7 @@ ExternalClockTradeAnim: ; 410f3 (10:50f3)
; Externally clocked link cable trades use this.
ld a, [wTradedEnemyMonSpecies]
ld [wLeftGBMonSpecies], a
ld a, [wTrainerSpriteOffset]
ld a, [wTradedPlayerMonSpecies]
ld [wRightGBMonSpecies], a
ld de, ExternalClockTradeFuncSequence
@ -259,7 +259,7 @@ Trade_ShowPlayerMon: ; 41245 (10:5245)
ld a, TRADE_BALL_POOF_ANIM
call Trade_ShowAnimation
ld a, TRADE_BALL_DROP_ANIM
call Trade_ShowAnimation
call Trade_ShowAnimation ; clears mon pic
ld a, [wTradedPlayerMonSpecies]
call PlayCry
xor a
@ -272,8 +272,12 @@ Trade_DrawOpenEndOfLinkCable: ; 41298 (10:5298)
call CopyScreenTileBufferToVRAM
ld b, $8
call GoPAL_SET
; This function call is pointless. It just copies blank tiles to VRAM that was
; already filled with blank tiles.
ld hl, vBGMap1 + $8c
call Trade_CopyCableTilesOffScreen
ld a, $a0
ld [hSCX], a
call DelayFrame
@ -754,7 +758,10 @@ Trade_ShowClearedWindow: ; 415c8 (10:55c8)
ret
Trade_SlideTextBoxOffScreen: ; 415df (10:55df)
; Slides the window right until it's off screen.
; Slides the window right until it's off screen. The window usually just has
; a text box at the bottom when this is called. However, when this is called
; after Trade_ShowEnemyMon in the external clock sequence, there is a mon pic
; above the text box and it is also scrolled off the screen.
ld c, 50
call DelayFrames
.loop