Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions constants/ram_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ DEF BIT_NO_PREVIOUS_MAP EQU 7

; wCurrentBoxNum
DEF BIT_HAS_CHANGED_BOXES EQU 7
DEF BOX_NUM_MASK EQU %01111111

; wObtainedBadges, wBeatGymFlags
const_def
Expand Down Expand Up @@ -153,3 +154,14 @@ DEF NUM_BADGES EQU const_value
const_def
const BIT_PLAYER_LOWER_Y ; 0
const BIT_PLAYER_LOWER_X ; 1

; rLCDC
; * LCD enabled
; * Window tile map at $9C00
; * Window display enabled
; * BG and window tile data at $8800
; * BG tile map at $9800
; * 8x8 OBJ size
; * OBJ display enabled
; * BG display enabled
DEF LCDC_DEFAULT EQU LCDC_ON | LCDC_WIN_9C00 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9800 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
4 changes: 2 additions & 2 deletions data/maps/objects/Route2Gate.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object_const_def
const_export ROUTE2_OAKS_AIDE
const_export ROUTE2_YOUNGSTER
const_export ROUTE2GATE_OAKS_AIDE
const_export ROUTE2GATE_YOUNGSTER

Route2Gate_Object:
db $a ; border block
Expand Down
12 changes: 6 additions & 6 deletions data/predef_pointers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ PredefPointers::
add_predef DoubleOrHalveSelectedStats
add_predef ShowPokedexMenu
add_predef EvolutionAfterBattle
add_predef SaveSAVtoSRAM0
add_predef SaveMainData
add_predef InitOpponent
add_predef CableClub_Run
add_predef DrawBadges
Expand All @@ -73,7 +73,7 @@ PredefPointers::
add_predef UsedCut
add_predef ShowPokedexData
add_predef WriteMonMoves
add_predef SaveSAV
add_predef SaveMenu
add_predef LoadSGB
add_predef MarkTownVisitedAndLoadMissableObjects
add_predef SetPartyMonTypes
Expand All @@ -90,10 +90,10 @@ PredefPointers::
add_predef EmptyFunc ; return immediately
add_predef AskName
add_predef PewterGuys
add_predef SaveSAVtoSRAM2
add_predef LoadSAV2
add_predef LoadSAV
add_predef SaveSAVtoSRAM1
add_predef SavePartyAndDexData
add_predef LoadPartyAndDexData
add_predef TryLoadSaveFile
add_predef SaveCurrentBoxData
add_predef DoInGameTradeDialogue
add_predef HallOfFamePC
add_predef DisplayDexRating
Expand Down
48 changes: 24 additions & 24 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3137,30 +3137,30 @@ PlayerCalcMoveDamage:
jp c, .moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation
call CriticalHitTest
call HandleCounterMove
jr z, handleIfPlayerMoveMissed
jr z, HandleIfPlayerMoveMissed
call GetDamageVarsForPlayerAttack
call CalculateDamage
jp z, playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
jp z, PlayerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
; for these moves, accuracy tests will only occur if they are called as part of the effect itself
call AdjustDamageForMoveType
call RandomizeDamage
.moveHitTest
call MoveHitTest
handleIfPlayerMoveMissed:
HandleIfPlayerMoveMissed:
ld a, [wMoveMissed]
and a
jr z, getPlayerAnimationType
jr z, GetPlayerAnimationType
ld a, [wPlayerMoveEffect]
sub EXPLODE_EFFECT
jr z, playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr playerCheckIfFlyOrChargeEffect
getPlayerAnimationType:
jr z, PlayPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr PlayerCheckIfFlyOrChargeEffect
GetPlayerAnimationType:
ld a, [wPlayerMoveEffect]
and a
ld a, ANIMATIONTYPE_BLINK_ENEMY_MON_SPRITE ; move has no effect other than dealing damage
jr z, playPlayerMoveAnimation
jr z, PlayPlayerMoveAnimation
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_LIGHT ; move has effect
playPlayerMoveAnimation:
PlayPlayerMoveAnimation:
push af
ld a, [wPlayerBattleStatus2]
bit HAS_SUBSTITUTE_UP, a
Expand All @@ -3179,7 +3179,7 @@ playPlayerMoveAnimation:
ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch
jr MirrorMoveCheck
playerCheckIfFlyOrChargeEffect:
PlayerCheckIfFlyOrChargeEffect:
ld c, 30
call DelayFrames
ld a, [wPlayerMoveEffect]
Expand Down Expand Up @@ -3246,7 +3246,7 @@ MirrorMoveCheck:
ld a, [wPlayerNumAttacksLeft]
dec a
ld [wPlayerNumAttacksLeft], a
jp nz, getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
jp nz, GetPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
; damage calculation and accuracy tests only happen for the first hit
res ATTACKING_MULTIPLE_TIMES, [hl] ; clear attacking multiple times status when all attacks are over
ld hl, MultiHitText
Expand Down Expand Up @@ -3523,7 +3523,7 @@ CheckPlayerStatusConditions:
ld [hl], a
ld a, BIDE
ld [wPlayerMoveNum], a
ld hl, handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
ld hl, HandleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .returnToHL

.ThrashingAboutCheck
Expand Down Expand Up @@ -3557,7 +3557,7 @@ CheckPlayerStatusConditions:
ld a, [wPlayerNumAttacksLeft]
dec a ; did multi-turn move end?
ld [wPlayerNumAttacksLeft], a
ld hl, getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
ld hl, GetPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest
jp nz, .returnToHL
jp .returnToHL
Expand Down Expand Up @@ -5567,7 +5567,7 @@ RandomizeDamage:
.loop
call BattleRandom
rrca
cp 217
cp 85 percent + 1
jr c, .loop
ldh [hMultiplier], a
call Multiply ; multiply damage by the random number, which is in the range [217, 255]
Expand Down Expand Up @@ -5660,7 +5660,7 @@ EnemyCalcMoveDamage:
jp c, EnemyMoveHitTest
call CriticalHitTest
call HandleCounterMove
jr z, handleIfEnemyMoveMissed
jr z, HandleIfEnemyMoveMissed
call SwapPlayerAndEnemyLevels
call GetDamageVarsForEnemyAttack
call SwapPlayerAndEnemyLevels
Expand All @@ -5671,13 +5671,13 @@ EnemyCalcMoveDamage:

EnemyMoveHitTest:
call MoveHitTest
handleIfEnemyMoveMissed:
HandleIfEnemyMoveMissed:
ld a, [wMoveMissed]
and a
jr z, .moveDidNotMiss
ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
jr z, handleExplosionMiss
jr z, HandleExplosionMiss
jr EnemyCheckIfFlyOrChargeEffect
.moveDidNotMiss
call SwapPlayerAndEnemyLevels
Expand All @@ -5686,13 +5686,13 @@ GetEnemyAnimationType:
ld a, [wEnemyMoveEffect]
and a
ld a, ANIMATIONTYPE_SHAKE_SCREEN_VERTICALLY
jr z, playEnemyMoveAnimation
jr z, PlayEnemyMoveAnimation
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_HEAVY
jr playEnemyMoveAnimation
handleExplosionMiss:
jr PlayEnemyMoveAnimation
HandleExplosionMiss:
call SwapPlayerAndEnemyLevels
xor a
playEnemyMoveAnimation:
PlayEnemyMoveAnimation:
push af
ld a, [wEnemyBattleStatus2]
bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute?
Expand Down Expand Up @@ -6031,7 +6031,7 @@ CheckEnemyStatusConditions:
ld a, BIDE
ld [wEnemyMoveNum], a
call SwapPlayerAndEnemyLevels
ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
ld hl, HandleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .enemyReturnToHL
.checkIfThrashingAbout
bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance?
Expand Down Expand Up @@ -6881,12 +6881,12 @@ _InitBattleCommon:
call PrintText
call SaveScreenTilesToBuffer1
call ClearScreen
ld a, $98
ld a, HIGH(vBGMap0)
ldh [hAutoBGTransferDest + 1], a
ld a, $1
ldh [hAutoBGTransferEnabled], a
call Delay3
ld a, $9c
ld a, HIGH(vBGMap1)
ldh [hAutoBGTransferDest + 1], a
call LoadScreenTilesFromBuffer1
hlcoord 9, 7
Expand Down
12 changes: 6 additions & 6 deletions engine/battle/effects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ _JumpMoveEffect:
ldh a, [hWhoseTurn]
and a
ld a, [wPlayerMoveEffect]
jr z, .next1
jr z, .next
ld a, [wEnemyMoveEffect]
.next1
.next
dec a ; subtract 1, there is no special effect for 00
add a ; x2, 16bit pointers
ld hl, MoveEffectPointerTable
Expand Down Expand Up @@ -680,14 +680,14 @@ UpdateLoweredStatDone:
call PrintStatText
pop de
ld a, [de]
cp $44
cp ATTACK_DOWN_SIDE_EFFECT ; for all side effects, move animation has already played, skip it
jr nc, .ApplyBadgeBoostsAndStatusPenalties
call PlayCurrentMoveAnimation2
.ApplyBadgeBoostsAndStatusPenalties
ldh a, [hWhoseTurn]
and a
call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat,
; even to those not affected by the stat-up move (will be boosted further)
; even to those not affected by the stat-down move (will be boosted further)
ld hl, MonsStatsFellText
call PrintText

Expand Down Expand Up @@ -1438,9 +1438,9 @@ CheckTargetSubstitute:
ld hl, wEnemyBattleStatus2
ldh a, [hWhoseTurn]
and a
jr z, .next1
jr z, .next
ld hl, wPlayerBattleStatus2
.next1
.next
bit HAS_SUBSTITUTE_UP, [hl]
pop hl
ret
Expand Down
2 changes: 1 addition & 1 deletion engine/events/give_pokemon.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _GivePokemon::
callfar SendNewMonToBox
ld hl, wStringBuffer
ld a, [wCurrentBoxNum]
and $7f
and BOX_NUM_MASK
cp 9
jr c, .singleDigitBoxNum
sub 9
Expand Down
12 changes: 6 additions & 6 deletions engine/events/prize_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ CeladonPrizeMenu::
ld b, COIN_CASE
call IsItemInBag
jr nz, .havingCoinCase
ld hl, RequireCoinCaseTextPtr
ld hl, RequireCoinCaseText
jp PrintText
.havingCoinCase
ld hl, wStatusFlags5
set BIT_NO_TEXT_DELAY, [hl]
ld hl, ExchangeCoinsForPrizesTextPtr
ld hl, ExchangeCoinsForPrizesText
call PrintText
; the following are the menu settings
xor a
Expand All @@ -28,7 +28,7 @@ CeladonPrizeMenu::
call TextBoxBorder
call GetPrizeMenuId
call UpdateSprites
ld hl, WhichPrizeTextPtr
ld hl, WhichPrizeText
call PrintText
call HandleMenuInput ; menu choice handler
bit B_PAD_B, a
Expand All @@ -42,16 +42,16 @@ CeladonPrizeMenu::
res BIT_NO_TEXT_DELAY, [hl]
ret

RequireCoinCaseTextPtr:
RequireCoinCaseText:
text_far _RequireCoinCaseText
text_waitbutton
text_end

ExchangeCoinsForPrizesTextPtr:
ExchangeCoinsForPrizesText:
text_far _ExchangeCoinsForPrizesText
text_end

WhichPrizeTextPtr:
WhichPrizeText:
text_far _WhichPrizeText
text_end

Expand Down
10 changes: 5 additions & 5 deletions engine/gfx/palettes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,15 @@ CopyGfxToSuperNintendoVRAM:
call CopySGBBorderTiles
jr .next
.notCopyingTileData
ld bc, $1000
ld bc, 256 tiles
call CopyData
.next
ld hl, vBGMap0
ld de, $c
ld de, TILEMAP_WIDTH - SCREEN_WIDTH
ld a, $80
ld c, $d
ld c, (256 + SCREEN_WIDTH - 1) / SCREEN_WIDTH ; enough rows to fit 256 tiles
.loop
ld b, $14
ld b, SCREEN_WIDTH
.innerLoop
ld [hli], a
inc a
Expand All @@ -540,7 +540,7 @@ CopyGfxToSuperNintendoVRAM:
add hl, de
dec c
jr nz, .loop
ld a, $e3
ld a, LCDC_DEFAULT
ldh [rLCDC], a
pop hl
call SendSGBPacket
Expand Down
2 changes: 1 addition & 1 deletion engine/link/cable_club.asm
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ TradeCenter_Trade:
hlcoord 1, 14
ld de, TradeCompleted
call PlaceString
predef SaveSAVtoSRAM2
predef SavePartyAndDexData ; this allows reset into Pokecenter
vc_hook Trade_save_game_end
ld c, 50
call DelayFrames
Expand Down
2 changes: 1 addition & 1 deletion engine/link/cable_club_npc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CableClubNPC::
and a
jr nz, .choseNo
vc_hook Wireless_TryQuickSave_block_input
callfar SaveSAVtoSRAM
callfar SaveGameData
call WaitForSoundToFinish
ld a, SFX_SAVE
call PlaySoundWaitForCurrent
Expand Down
2 changes: 1 addition & 1 deletion engine/menus/display_text_id_init.asm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ DisplayTextIDInit::
add hl, de
dec c
jr nz, .spriteStandStillLoop
ld b, $9c ; window background address
ld b, HIGH(vBGMap1)
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
xor a
ldh [hWY], a ; put the window on the screen
Expand Down
5 changes: 3 additions & 2 deletions engine/menus/main_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MainMenu:
call CheckForPlayerNameInSRAM
jr nc, .mainMenuLoop

predef LoadSAV
predef TryLoadSaveFile

.mainMenuLoop
ld c, 20
Expand Down Expand Up @@ -701,8 +701,9 @@ CheckForPlayerNameInSRAM:
; in carry.
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
ld a, $1
ld a, BMODE_ADVANCED
ld [rBMODE], a
ASSERT BANK(sPlayerName) == BMODE_ADVANCED
ld [rRAMB], a
ld b, NAME_LENGTH
ld hl, sPlayerName
Expand Down
Loading