Skip to content

Commit

Permalink
Port some changes from pret/pokecrystal#1105
Browse files Browse the repository at this point in the history
  • Loading branch information
vulcandth committed Apr 14, 2024
1 parent 9e6ae84 commit a8a99a9
Show file tree
Hide file tree
Showing 111 changed files with 442 additions and 435 deletions.
2 changes: 1 addition & 1 deletion constants/collision_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DEF WATER_TILE EQU %01 ; 'dec a' checks
DEF WALL_TILE EQU %10

; collision data types (see data/tilesets/*_collision.asm)
; TileCollisionTable indexes (see data/collision/collision_permissions.asm)
; CollisionPermissionTable indexes (see data/collision/collision_permissions.asm)
DEF COLL_FLOOR EQU $00
DEF COLL_VOID EQU $01
DEF COLL_COAST_SAND EQU $02
Expand Down
2 changes: 1 addition & 1 deletion constants/map_object_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DEF OBJECT_STEP_DURATION rb ; 0a
DEF OBJECT_ACTION rb ; 0b
DEF OBJECT_STEP_FRAME rb ; 0c
DEF OBJECT_FACING rb ; 0d
DEF OBJECT_TILE rb ; 0e
DEF OBJECT_TILE_COLLISION rb ; 0e
DEF OBJECT_LAST_TILE rb ; 0f
DEF OBJECT_MAP_X rb ; 10
DEF OBJECT_MAP_Y rb ; 11
Expand Down
8 changes: 7 additions & 1 deletion constants/wram_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DEF NUM_FRAMES EQU const_value
; wTextboxFlags::
const_def
const FAST_TEXT_DELAY_F ; 0
const NO_TEXT_DELAY_F ; 1
const TEXT_DELAY_F ; 1
const NO_LINE_SPACING_F ; 2
const USE_BG_MAP_WIDTH_F ; 3

Expand Down Expand Up @@ -142,6 +142,12 @@ DEF FACE_UP EQU 4
DEF FACE_LEFT EQU 2
DEF FACE_RIGHT EQU 1

; wStateFlags
DEF SPRITE_UPDATES_DISABLED_F EQU 0
DEF LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F EQU 1
DEF TEXT_STATE_F EQU 6
DEF SCRIPTED_MOVEMENT_STATE_F EQU 7

; wPokemonWithdrawDepositParameter::
DEF PC_WITHDRAW EQU 0
DEF PC_DEPOSIT EQU 1
Expand Down
4 changes: 2 additions & 2 deletions data/collision/collision_permissions.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TileCollisionTable::
table_width 1, TileCollisionTable
CollisionPermissionTable::
table_width 1, CollisionPermissionTable
db LAND_TILE ; COLL_FLOOR
db WALL_TILE ; COLL_VOID
db LAND_TILE ; COLL_COAST_SAND
Expand Down
42 changes: 21 additions & 21 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ ParsePlayerAction:
ld de, wBGPals1 palette PAL_BATTLE_BG_TYPE_CAT
ld bc, 1 palettes
call FarCopyColorWRAM
call SetPalettes
call SetDefaultBGPAndOBP
ld a, [wCurPlayerMove]
inc a ; cp STRUGGLE
call nz, PlayClickSFX
Expand Down Expand Up @@ -1017,7 +1017,7 @@ GetPlayerSwitchTarget:
call ClearSprites
ld a, CGB_BATTLE_COLORS
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
ld a, [wCurPartyMon]
inc a
ld [wPlayerSwitchTarget], a
Expand Down Expand Up @@ -1322,7 +1322,7 @@ endr

ld a, CGB_BATTLE_COLORS
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP

.wild
; For enemy, we need to mark as seen and set base exp unless link/BT
Expand Down Expand Up @@ -2434,9 +2434,9 @@ SetUpBattlePartyMenu: ; switch to fullscreen menu?

JumpToPartyMenuAndPrintText:
farcall WritePartyMenuTilemap
farcall PrintPartyMenuText
farcall PlacePartyMenuText
call ApplyTilemapInVBlank
call SetPalettes
call SetDefaultBGPAndOBP
jmp DelayFrame

SelectBattleMon:
Expand Down Expand Up @@ -2561,7 +2561,7 @@ LostBattle:
; Greyscale
ld a, CGB_BATTLE_GRAYSCALE
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
jr .end

.LostLinkBattle:
Expand Down Expand Up @@ -2825,7 +2825,7 @@ OfferSwitch:
call _LoadStatusIcons
call DelayFrame
call GetMemCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
call SafeLoadTempTileMapToTileMap
pop af
jr c, OfferSwitch
Expand Down Expand Up @@ -4374,7 +4374,7 @@ BattleMenu_SafariBall:
and BATTLERESULT_BITMASK
ld [wBattleResult], a
call ClearWindowData
call SetPalettes
call SetDefaultBGPAndOBP
scf
ret

Expand Down Expand Up @@ -4438,7 +4438,7 @@ BattleMenuPKMN_Loop:
call CloseWindow
call LoadTileMapToTempTileMap
call GetMemCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
jmp BattleMenu

.GetMenu:
Expand Down Expand Up @@ -4610,7 +4610,7 @@ TryPlayerSwitch:
call GetMonBackpic
call CloseWindow
call GetMemCGBLayout
jmp SetPalettes
jmp SetDefaultBGPAndOBP

BattleMenu_Run:
call ClearSprites
Expand Down Expand Up @@ -5445,7 +5445,7 @@ MoveInfoBox:

.icons
farcall LoadBattleCategoryAndTypePals
call SetPalettes
call SetDefaultBGPAndOBP
ld hl, CategoryIconGFX
ld bc, 2 tiles
ld a, [wPlayerMoveStruct + MOVE_CATEGORY]
Expand Down Expand Up @@ -6366,7 +6366,7 @@ FinishBattleAnim:
push af
ld a, CGB_BATTLE_COLORS
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
call DelayFrame
jmp PopAFBCDEHL

Expand Down Expand Up @@ -8095,7 +8095,7 @@ DisplayLinkRecord:
call ApplyAttrAndTilemapInVBlank
ld a, CGB_PLAIN
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
ld c, 8
call DelayFrames
jmp WaitPressAorB_BlinkCursor
Expand Down Expand Up @@ -8535,7 +8535,7 @@ InitBattleDisplay:
call HideSprites
ld a, CGB_BATTLE_COLORS
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
xor a
ldh [hSCX], a
ret
Expand Down Expand Up @@ -8660,9 +8660,9 @@ BattleStartMessage:

ld hl, WantToBattleText
call CheckPluralTrainer
jr nz, .PlaceBattleStartText
jr nz, .PrintBattleStartText
ld hl, WantsToBattleText
jr .PlaceBattleStartText
jr .PrintBattleStartText

.wild
call BattleCheckEnemyShininess
Expand Down Expand Up @@ -8705,20 +8705,20 @@ BattleStartMessage:
cp BATTLETYPE_FISH
jr nz, .NotFishing
ld hl, HookedPokemonAttackedText
jr .PlaceBattleStartText
jr .PrintBattleStartText

.NotFishing:
ld hl, PokemonFellFromTreeText
cp BATTLETYPE_TREE
jr z, .PlaceBattleStartText
jr z, .PrintBattleStartText
ld hl, LegendaryAppearedText
cp BATTLETYPE_ROAMING
jr z, .PlaceBattleStartText
jr z, .PrintBattleStartText
cp BATTLETYPE_RED_GYARADOS ; or BATTLETYPE_LEGENDARY
jr nc, .PlaceBattleStartText
jr nc, .PrintBattleStartText
ld hl, WildPokemonAppearedText

.PlaceBattleStartText:
.PrintBattleStartText:
push hl
farcall BattleStart_TrainerHuds
pop hl
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/returntobattle_useball.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _ReturnToBattle_UseBall:
call CloseWindow
call LoadStandardMenuHeader
call ApplyTilemapInVBlank
call SetPalettes
call SetDefaultBGPAndOBP
farcall LoadPlayerStatusIcon
farcall LoadEnemyStatusIcon
farjp FinishBattleAnim
2 changes: 1 addition & 1 deletion engine/battle/trainer_huds.asm
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ _ShowLinkBattleParticipants:
call LinkBattle_TrainerHuds
ld a, CGB_PLAIN
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
ld a, $e4
ldh [rOBP0], a
ret
Expand Down
2 changes: 1 addition & 1 deletion engine/battle_anims/anim_commands.asm
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ SetBattleAnimPal:
ld b, a
.finish
call .SetPaletteData
jmp SetPalettes
jmp SetDefaultBGPAndOBP

.UserPal:
ldh a, [hBattleTurn]
Expand Down
2 changes: 1 addition & 1 deletion engine/events/bug_contest/display_stats.asm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ DisplayCaughtContestMonStats:
call ApplyTilemapInVBlank
ld a, CGB_PLAIN
call GetCGBLayout
jmp SetPalettes
jmp SetDefaultBGPAndOBP

.Health:
db "Health@"
Expand Down
6 changes: 3 additions & 3 deletions engine/events/celebi.asm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Special_CelebiShrineEvent:
call DelayFrame
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a

ld a, PAL_OW_GREEN
farcall CopySpritePalToOBPal7
Expand Down Expand Up @@ -51,7 +51,7 @@ Special_CelebiShrineEvent:

.done
pop af
ld [wVramState], a
ld [wStateFlags], a

ld hl, wShadowOAM + 2
xor a
Expand Down
2 changes: 1 addition & 1 deletion engine/events/diploma.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _Diploma:
call ApplyTilemapInVBlank
ld a, CGB_NEW_DIPLOMA
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
call DelayFrame
call WaitPressAorB_BlinkCursor

Expand Down
12 changes: 6 additions & 6 deletions engine/events/field_moves.asm
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ Cut_Headbutt_GetPixelFacing:

FlyFromAnim:
call DelayFrame
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
call FlyFunction_InitGFX
depixel 10, 10, 4, 0
ld a, SPRITE_ANIM_INDEX_RED_WALK
Expand All @@ -287,15 +287,15 @@ FlyFromAnim:

.exit
pop af
ld [wVramState], a
ld [wStateFlags], a
ret

FlyToAnim:
call DelayFrame
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
call FlyFunction_InitGFX
depixel 31, 10, 4, 0
ld a, SPRITE_ANIM_INDEX_RED_WALK
Expand Down Expand Up @@ -324,7 +324,7 @@ FlyToAnim:

.exit
pop af
ld [wVramState], a
ld [wStateFlags], a
ld hl, wShadowOAM + 2 ; Tile ID
xor a
ld c, $4
Expand Down
8 changes: 4 additions & 4 deletions engine/events/halloffame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ HallOfFame_FadeOutMusic:
ld [wMusicFade], a
farcall FadeOutPalettes
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh [hMapAnims], a
ret

Expand Down Expand Up @@ -242,7 +242,7 @@ AnimateHOFMonEntrance:
ldh [hBGMapMode], a
ld a, CGB_PLAYER_OR_MON_FRONTPIC_PALS
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
call HOF_SlideBackpic
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
Expand Down Expand Up @@ -371,7 +371,7 @@ _HallOfFamePC:
call ApplyTilemapInVBlank
ld a, CGB_PLAYER_OR_MON_FRONTPIC_PALS
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
decoord 6, 5
ld c, $6
predef HOF_AnimateFrontpic
Expand Down Expand Up @@ -523,7 +523,7 @@ HOF_AnimatePlayerPic:
ld [wCurPartySpecies], a
ld a, CGB_PLAYER_OR_MON_FRONTPIC_PALS
call GetCGBLayout
call SetPalettes
call SetDefaultBGPAndOBP
call HOF_SlideBackpic
xor a
ld [wBoxAlignment], a
Expand Down
8 changes: 4 additions & 4 deletions engine/events/itemfinder.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ ItemFinder:
rrca
rrca
ld e, a
farjp ApplyPersonFacing
farjp ApplyObjectFacing

.Script_FoundSomething:
reloadmappart
refreshmap
special UpdateTimePals
callasm .ItemfinderEffect
iffalse_jumpopenedtext .UnderfootText
Expand All @@ -64,7 +64,7 @@ ItemFinder:
done

.Script_FoundNothingNearby:
reloadmappart
refreshmap
special UpdateTimePals
jumpthisopenedtext

Expand All @@ -73,7 +73,7 @@ ItemFinder:
done

.Script_FoundNothingAtAll:
reloadmappart
refreshmap
special UpdateTimePals
jumpthisopenedtext

Expand Down
2 changes: 1 addition & 1 deletion engine/events/map_name_sign.asm
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ LoadMapNameSignGFX:
rst AddNTimes ; preserves bc
ld de, wBGPals1 palette PAL_BG_TEXT
call FarCopyColorWRAM
jmp SetPalettes
jmp SetDefaultBGPAndOBP

.continue
; save position in landmark name
Expand Down
2 changes: 1 addition & 1 deletion engine/events/mom_phone.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MomTriesToBuySomething::
ret nc
ld b, BANK(.Script)
ld de, .Script
farcall LoadScriptBDE
farcall LoadMemScript
scf
ret

Expand Down
Loading

0 comments on commit a8a99a9

Please sign in to comment.