aboutsummaryrefslogtreecommitdiffstats
path: root/home
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-11-05 10:51:02 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2020-11-05 10:51:02 -0500
commit6fe56af2cd63abaf30040cc5031e3db5358cf638 (patch)
treeb024aa8480912ebf2667184068466ee7f354012c /home
parentMerge pull request #59 from Rangi42/master (diff)
downloadpokeyellow-6fe56af2cd63abaf30040cc5031e3db5358cf638.tar.gz
pokeyellow-6fe56af2cd63abaf30040cc5031e3db5358cf638.tar.xz
pokeyellow-6fe56af2cd63abaf30040cc5031e3db5358cf638.zip
Organize home and macro code
Diffstat (limited to 'home')
-rw-r--r--home/cgb_palettes.asm8
-rw-r--r--home/hidden_objects.asm4
-rw-r--r--home/item_price.asm4
-rw-r--r--home/joypad.asm4
-rw-r--r--home/overworld.asm29
-rw-r--r--home/pics.asm4
-rwxr-xr-xhome/pikachu.asm4
-rw-r--r--home/pokemon.asm12
-rw-r--r--home/printer.asm34
-rw-r--r--home/reload_tiles.asm34
-rw-r--r--home/start.asm2
-rwxr-xr-xhome/start_menu.asm3
-rw-r--r--home/text.asm4
-rw-r--r--home/text_script.asm9
-rw-r--r--home/update_sprites.asm3
-rw-r--r--home/vblank.asm8
16 files changed, 87 insertions, 79 deletions
diff --git a/home/cgb_palettes.asm b/home/cgb_palettes.asm
index 24738ae2..b8cc92c6 100644
--- a/home/cgb_palettes.asm
+++ b/home/cgb_palettes.asm
@@ -74,8 +74,12 @@ Func_3082::
ldh a, [hLoadedROMBank]
push af
call FadeOutAudio
- callbs Music_DoLowHealthAlarm
- callbs Audio1_UpdateMusic
+ ld a, BANK(Music_DoLowHealthAlarm)
+ call BankswitchCommon
+ call Music_DoLowHealthAlarm
+ ld a, BANK(Audio1_UpdateMusic)
+ call BankswitchCommon
+ call Audio1_UpdateMusic
pop af
call BankswitchCommon
ret
diff --git a/home/hidden_objects.asm b/home/hidden_objects.asm
index 40c49c3e..0003022b 100644
--- a/home/hidden_objects.asm
+++ b/home/hidden_objects.asm
@@ -9,7 +9,9 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor::
bit 0, a ; A button
jr z, .nothingFound
; A button is pressed
- callbs CheckForHiddenObject
+ ld a, BANK(CheckForHiddenObject)
+ call BankswitchCommon
+ call CheckForHiddenObject
ldh a, [hDidntFindAnyHiddenObject]
and a
jr nz, .hiddenObjectNotFound
diff --git a/home/item_price.asm b/home/item_price.asm
index d8c2068e..39749ee9 100644
--- a/home/item_price.asm
+++ b/home/item_price.asm
@@ -31,7 +31,9 @@ GetItemPrice::
ldh [hItemPrice], a
jr .done
.getTMPrice
- callbs GetMachinePrice
+ ld a, BANK(GetMachinePrice)
+ call BankswitchCommon
+ call GetMachinePrice
.done
ld de, hItemPrice
pop af
diff --git a/home/joypad.asm b/home/joypad.asm
index 15f10fe2..5eb2962f 100644
--- a/home/joypad.asm
+++ b/home/joypad.asm
@@ -1,5 +1,5 @@
Joypad::
- homecall_jump _Joypad
+ homejp _Joypad
ReadJoypad::
- homecall_jump ReadJoypad_
+ homejp ReadJoypad_
diff --git a/home/overworld.asm b/home/overworld.asm
index 2909b01e..68d50695 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -743,7 +743,8 @@ HandleBlackOut::
call StopMusic
ld hl, wd72e
res 5, [hl]
- switchbank SpecialWarpIn ; also Bank(SpecialEnterMap)
+ ld a, BANK(SpecialWarpIn) ; also BANK(SpecialEnterMap)
+ call BankswitchCommon
callfar ResetStatusAndHalveMoneyOnBlackout
call SpecialWarpIn
call PlayDefaultMusicFadeOutCurrent
@@ -770,7 +771,9 @@ HandleFlyWarpOrDungeonWarp::
res 5, [hl] ; forced to ride bike
call LeaveMapAnim
call Func_07c4
- callbs SpecialWarpIn
+ ld a, BANK(SpecialWarpIn)
+ call BankswitchCommon
+ call SpecialWarpIn
jp SpecialEnterMap
LeaveMapAnim::
@@ -1439,9 +1442,7 @@ AdvancePlayerSprite::
push af
ld a, $FF
ld [wUpdateSpritesEnabled], a
- ld hl, _AdvancePlayerSprite
- ld b, BANK(_AdvancePlayerSprite)
- call Bankswitch
+ callfar _AdvancePlayerSprite
pop af
ld [wUpdateSpritesEnabled], a
ret
@@ -1914,7 +1915,8 @@ asm_0dbd:
ld b, $00
ldh a, [hLoadedROMBank]
push af
- switchbank MapSongBanks
+ ld a, BANK(MapSongBanks)
+ call BankswitchCommon
ld hl, MapSongBanks
add hl, bc
add hl, bc
@@ -2041,16 +2043,16 @@ CopyMapViewToVRAM::
ld de, vBGMap0
CopyMapViewToVRAM2:
ld hl, wTileMap
- ld b, 18
+ ld b, SCREEN_HEIGHT
.vramCopyLoop
- ld c, 20
+ ld c, SCREEN_WIDTH
.vramCopyInnerLoop
ld a, [hli]
ld [de], a
inc e
dec c
jr nz, .vramCopyInnerLoop
- ld a, 32 - 20 ; total vram map width in tiles - screen width in tiles
+ ld a, BG_MAP_WIDTH - SCREEN_WIDTH
add e
ld e, a
jr nc, .noCarry
@@ -2068,11 +2070,11 @@ SwitchToMapRomBank::
ld c, a
ld b, $00
ld a, BANK(MapHeaderBanks)
- call BankswitchHome ; switch to ROM bank 3F
+ call BankswitchHome
ld hl, MapHeaderBanks
add hl, bc
ld a, [hl]
- ldh [hMapROMBank], a ; save map ROM bank
+ ldh [hMapROMBank], a
call BankswitchBack
ldh a, [hMapROMBank]
call BankswitchCommon
@@ -2083,7 +2085,8 @@ SwitchToMapRomBank::
GetMapHeaderPointer::
ldh a, [hLoadedROMBank]
push af
- switchbank MapHeaderPointers
+ ld a, BANK(MapHeaderPointers)
+ call BankswitchCommon
push de
ld a, [wCurMap]
ld e, a
@@ -2114,7 +2117,7 @@ ResetUsingStrengthOutOfBattleBit:
ForceBikeOrSurf::
ld b, BANK(RedSprite)
- ld hl, LoadPlayerSpriteGraphics
+ ld hl, LoadPlayerSpriteGraphics ; in bank 0
call Bankswitch
jp PlayDefaultMusic ; update map/player state?
diff --git a/home/pics.asm b/home/pics.asm
index f3b3f1b5..8fd9a26a 100644
--- a/home/pics.asm
+++ b/home/pics.asm
@@ -18,10 +18,6 @@ UncompressMonSprite::
; $99 ≤ index, bank $D
ld a, [wcf91] ; XXX name for this ram location
ld b, a
- ;cp MEW
- ;ld a, BANK(MewPicFront)
- ;jr z, .GotBank
- ;ld a, b
cp FOSSIL_KABUTOPS
ld a, BANK(FossilKabutopsPic)
jr z, .GotBank
diff --git a/home/pikachu.asm b/home/pikachu.asm
index c9c94635..ae6acfe3 100755
--- a/home/pikachu.asm
+++ b/home/pikachu.asm
@@ -108,7 +108,9 @@ ApplyPikachuMovementData::
ldh a, [hLoadedROMBank]
ld b, a
push af
- callbs ApplyPikachuMovementData_
+ ld a, BANK(ApplyPikachuMovementData_)
+ call BankswitchCommon
+ call ApplyPikachuMovementData_
pop af
call BankswitchCommon
ret
diff --git a/home/pokemon.asm b/home/pokemon.asm
index 3e08906f..8e304fd3 100644
--- a/home/pokemon.asm
+++ b/home/pokemon.asm
@@ -5,7 +5,6 @@ DrawHPBar::
push hl
push de
- ;push bc
; Left
ld a, $71 ; "HP:"
@@ -61,7 +60,6 @@ DrawHPBar::
add e
ld [hl], a
.done
- ;pop bc
pop de
pop hl
ret
@@ -124,7 +122,8 @@ LoadFrontSpriteByMonIndex::
pop hl
ldh a, [hLoadedROMBank]
push af
- switchbank CopyUncompressedPicToHL
+ ld a, BANK(CopyUncompressedPicToHL)
+ call BankswitchCommon
xor a
ldh [hStartTileID], a
call CopyUncompressedPicToHL
@@ -355,7 +354,7 @@ PrintStatusCondition::
ret
PrintStatusConditionNotFainted::
- homecall_jump_sf PrintStatusAilment
+ homejp_sf PrintStatusAilment
; function to print pokemon level, leaving off the ":L" if the level is at least 100
; INPUT:
@@ -404,7 +403,8 @@ GetwMoves::
GetMonHeader::
ldh a, [hLoadedROMBank]
push af
- switchbank BaseStats
+ ld a, BANK(BaseStats)
+ call BankswitchCommon
push bc
push de
push hl
@@ -423,8 +423,6 @@ GetMonHeader::
ld b, $77 ; size of Aerodactyl fossil sprite
cp FOSSIL_AERODACTYL ; Aerodactyl fossil
jr z, .specialID
- ;cp MEW
- ;jr z, .mew
predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number
ld a, [wd11e]
dec a
diff --git a/home/printer.asm b/home/printer.asm
new file mode 100644
index 00000000..6d9f145c
--- /dev/null
+++ b/home/printer.asm
@@ -0,0 +1,34 @@
+
+PrinterSerial::
+ homecall PrinterSerial_
+ ret
+
+SerialFunction::
+ ld a, [wPrinterConnectionOpen]
+ bit 0, a
+ ret z
+ ld a, [wPrinterOpcode]
+ and a
+ ret nz
+ ld hl, wOverworldMap + 650
+ inc [hl]
+ ld a, [hl]
+ cp $6
+ ret c
+ xor a
+ ld [hl], a
+ ld a, $0c
+ ld [wPrinterOpcode], a
+ ld a, $88
+ ldh [rSB], a
+ ld a, $1
+ ldh [rSC], a
+ ld a, START_TRANSFER_INTERNAL_CLOCK
+ ldh [rSC], a
+ ret
+
+; causes the text box to close without waiting for a button press after displaying text
+DisableWaitingAfterTextDisplay::
+ ld a, $01
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
+ ret
diff --git a/home/reload_tiles.asm b/home/reload_tiles.asm
index ae9f6544..b596263a 100644
--- a/home/reload_tiles.asm
+++ b/home/reload_tiles.asm
@@ -31,37 +31,3 @@ ChooseFlyDestination::
ld hl, wd72e
res 4, [hl]
farjp LoadTownMap_Fly
-
-PrinterSerial::
- homecall PrinterSerial_
- ret
-
-SerialFunction::
- ld a, [wPrinterConnectionOpen]
- bit 0, a
- ret z
- ld a, [wPrinterOpcode]
- and a
- ret nz
- ld hl, wOverworldMap + 650
- inc [hl]
- ld a, [hl]
- cp $6
- ret c
- xor a
- ld [hl], a
- ld a, $0c
- ld [wPrinterOpcode], a
- ld a, $88
- ldh [rSB], a
- ld a, $1
- ldh [rSC], a
- ld a, START_TRANSFER_INTERNAL_CLOCK
- ldh [rSC], a
- ret
-
-; causes the text box to close without waiting for a button press after displaying text
-DisableWaitingAfterTextDisplay::
- ld a, $01
- ld [wDoNotWaitForButtonPressAfterDisplayingText], a
- ret
diff --git a/home/start.asm b/home/start.asm
index 379436ae..366806e9 100644
--- a/home/start.asm
+++ b/home/start.asm
@@ -4,7 +4,7 @@ _Start::
xor a
jr .ok
.gbc
- ld a, 1
+ ld a, TRUE
.ok
ldh [hGBC], a
jp Init
diff --git a/home/start_menu.asm b/home/start_menu.asm
index bd1b24bf..8edccfe2 100755
--- a/home/start_menu.asm
+++ b/home/start_menu.asm
@@ -1,5 +1,6 @@
DisplayStartMenu::
- switchbank StartMenu_Pokedex ; also bank for other functions
+ ld a, BANK(StartMenu_Pokedex) ; also bank for other functions
+ call BankswitchCommon
ld a, [wWalkBikeSurfState] ; walking/biking/surfing
ld [wWalkBikeSurfStateCopy], a
ld a, SFX_START_MENU
diff --git a/home/text.asm b/home/text.asm
index 78d69138..adb81425 100644
--- a/home/text.asm
+++ b/home/text.asm
@@ -554,8 +554,8 @@ TextCommandSounds::
db TX_SOUND_GET_KEY_ITEM, SFX_GET_KEY_ITEM
db TX_SOUND_DEX_PAGE_ADDED, SFX_DEX_PAGE_ADDED
db TX_SOUND_CRY_PIKACHU, PIKACHU ; used in OakSpeech
- db TX_SOUND_CRY_PIDGEOT, PIDGEOT ; used in SaffronCityText12
- db TX_SOUND_CRY_DEWGONG, DEWGONG ; unused
+ db TX_SOUND_CRY_PIDGEOT, PIDGEOT ; used in SaffronCityText12
+ db TX_SOUND_CRY_DEWGONG, DEWGONG ; unused
TextCommand_DOTS::
; wait for button press or 30 frames while printing "…"s
diff --git a/home/text_script.asm b/home/text_script.asm
index 20cfb71d..fe81cb51 100644
--- a/home/text_script.asm
+++ b/home/text_script.asm
@@ -41,17 +41,12 @@ DisplayTextID::
.spriteHandling
; get the text ID of the sprite
push hl
- ;push de
- ;push bc
- ;farcall UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction)
- ;pop bc
- ;pop de
ld hl, wMapSpriteData ; NPC text entries
ldh a, [hSpriteIndexOrTextID]
dec a
add a
ld e, a
- ld d, $0
+ ld d, 0
add hl, de
inc hl
ld a, [hl] ; a = text ID of the sprite
@@ -60,7 +55,7 @@ DisplayTextID::
; look up the address of the text in the map's text entries
dec a
ld e, a
- ld d, $0
+ ld d, 0
add hl, de
add hl, de
ld a, [hli]
diff --git a/home/update_sprites.asm b/home/update_sprites.asm
index 0c32dad8..5bb9ee12 100644
--- a/home/update_sprites.asm
+++ b/home/update_sprites.asm
@@ -4,7 +4,8 @@ UpdateSprites::
ret nz
ldh a, [hLoadedROMBank]
push af
- switchbank _UpdateSprites
+ ld a, BANK(_UpdateSprites)
+ call BankswitchCommon
ld a, $ff
ld [wUpdateSpritesEnabled], a
call _UpdateSprites
diff --git a/home/vblank.asm b/home/vblank.asm
index ed39714f..3957639a 100644
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -59,8 +59,12 @@ VBlank::
.skipDec
call FadeOutAudio
- callbs Music_DoLowHealthAlarm
- callbs Audio1_UpdateMusic
+ ld a, BANK(Music_DoLowHealthAlarm)
+ call BankswitchCommon
+ call Music_DoLowHealthAlarm
+ ld a, BANK(Audio1_UpdateMusic)
+ call BankswitchCommon
+ call Audio1_UpdateMusic
call SerialFunction