From 6fe56af2cd63abaf30040cc5031e3db5358cf638 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 5 Nov 2020 10:51:02 -0500 Subject: [PATCH] Organize home and macro code --- audio.asm | 2 +- audio/music/meetjessiejames.asm | 1 - constants/gfx_constants.asm | 12 ------- constants/palette_constants.asm | 14 +++++--- engine/battle/animations.asm | 8 ++--- engine/battle/core.asm | 2 +- engine/battle/effects.asm | 4 +-- engine/gfx/sprite_oam.asm | 2 +- engine/items/inventory.asm | 2 +- engine/menus/pokedex.asm | 16 ++++----- engine/movie/intro.asm | 2 +- engine/overworld/map_sprites.asm | 2 +- engine/overworld/specific_script_flags.asm | 2 +- engine/pikachu/pikachu_pic_animation.asm | 2 +- engine/printer/printer2.asm | 10 +++--- audio/unknown_832b9.bin => garbage/bank20.bin | Bin 3398 -> 3399 bytes home.asm | 1 + home/cgb_palettes.asm | 8 +++-- home/hidden_objects.asm | 4 ++- home/item_price.asm | 4 ++- home/joypad.asm | 4 +-- home/overworld.asm | 29 ++++++++------- home/pics.asm | 4 --- home/pikachu.asm | 4 ++- home/pokemon.asm | 12 +++---- home/printer.asm | 34 ++++++++++++++++++ home/reload_tiles.asm | 34 ------------------ home/start.asm | 2 +- home/start_menu.asm | 3 +- home/text.asm | 4 +-- home/text_script.asm | 9 ++--- home/update_sprites.asm | 3 +- home/vblank.asm | 8 +++-- macros/code.asm | 2 +- macros/farcall.asm | 21 +++-------- macros/gfx.asm | 12 ------- 36 files changed, 131 insertions(+), 152 deletions(-) rename audio/unknown_832b9.bin => garbage/bank20.bin (50%) mode change 100755 => 100644 create mode 100644 home/printer.asm diff --git a/audio.asm b/audio.asm index bd5b390d9..2434bf077 100644 --- a/audio.asm +++ b/audio.asm @@ -539,7 +539,7 @@ INCLUDE "audio/music/surfingpikachu.asm" INCLUDE "audio/music/yellowunusedsong.asm" INCLUDE "audio/music/meetjessiejames.asm" -INCBIN "audio/unknown_832b9.bin" +INCBIN "garbage/bank20.bin" ; Pikachu cries are in different banks diff --git a/audio/music/meetjessiejames.asm b/audio/music/meetjessiejames.asm index 7f1f45984..d1f9f7954 100644 --- a/audio/music/meetjessiejames.asm +++ b/audio/music/meetjessiejames.asm @@ -306,4 +306,3 @@ Music_MeetJessieJames_branch_83235:: note E_, 1 rest 1 sound_loop 0, Music_MeetJessieJames_branch_83235 - sound_ret diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm index e6eb50db0..483bafa96 100644 --- a/constants/gfx_constants.asm +++ b/constants/gfx_constants.asm @@ -2,18 +2,6 @@ TILE_WIDTH EQU 8 ; pixels LEN_1BPP_TILE EQU 1 * TILE_WIDTH ; bytes LEN_2BPP_TILE EQU 2 * TILE_WIDTH ; bytes - const_def - const SHADE_WHITE ; %00 - const SHADE_LIGHT ; %01 - const SHADE_DARK ; %10 - const SHADE_BLACK ; %11 -NUM_PAL_COLORS EQU const_value - -PAL_COLOR_SIZE EQU 2 -PALETTE_SIZE EQU NUM_PAL_COLORS * PAL_COLOR_SIZE - -NUM_ACTIVE_PALS EQU 4 - SCREEN_WIDTH EQU 20 SCREEN_HEIGHT EQU 18 SCREEN_WIDTH_PX EQU SCREEN_WIDTH * TILE_WIDTH ; pixels diff --git a/constants/palette_constants.asm b/constants/palette_constants.asm index a16999e7d..00b5748d1 100755 --- a/constants/palette_constants.asm +++ b/constants/palette_constants.asm @@ -1,9 +1,15 @@ ; monochrome palette color ids const_def - const WHITE - const LIGHT_GRAY - const DARK_GRAY - const BLACK + const SHADE_WHITE ; %00 + const SHADE_LIGHT ; %01 + const SHADE_DARK ; %10 + const SHADE_BLACK ; %11 +NUM_PAL_COLORS EQU const_value + +PAL_COLOR_SIZE EQU 2 +PALETTE_SIZE EQU NUM_PAL_COLORS * PAL_COLOR_SIZE + +NUM_ACTIVE_PALS EQU 4 ; pal/blk packets ; SetPalFunctions indexes (see engine/gfx/palettes.asm) diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 3b0fd4ec9..98d85e02e 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -57,7 +57,7 @@ DrawFrameBlock: inc hl inc de ld a, [hli] - add a, $31 ; base tile ID for battle animations + add $31 ; base tile ID for battle animations ld [de], a ; store tile ID inc de ld a, [hli] @@ -91,7 +91,7 @@ DrawFrameBlock: inc hl inc de ld a, [hli] - add a, $31 ; base tile ID for battle animations + add $31 ; base tile ID for battle animations ld [de], a ; store tile ID inc de ; toggle horizontal and vertical flip @@ -99,10 +99,10 @@ DrawFrameBlock: and a ld b, OAM_VFLIP | OAM_HFLIP jr z, .storeFlags1 - cp a, OAM_HFLIP + cp OAM_HFLIP ld b, OAM_VFLIP jr z, .storeFlags1 - cp a, OAM_VFLIP + cp OAM_VFLIP ld b, OAM_HFLIP jr z, .storeFlags1 ld b, 0 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index f66f509fd..4b8d342ae 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -902,7 +902,7 @@ ReplaceFaintedEnemyMon: ld hl, wEnemyHPBarColor ld e, $30 call GetBattleHealthBarColor - setpal SHADE_BLACK, SHADE_DARK, SHADE_LIGHT, SHADE_WHITE + ldpal a, SHADE_BLACK, SHADE_DARK, SHADE_LIGHT, SHADE_WHITE ldh [rOBP0], a ldh [rOBP1], a call UpdateGBCPal_OBP0 diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index c4e818164..9e5ee19fc 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -231,7 +231,7 @@ FreezeBurnParalyzeEffect: ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance jr .next1 .asm_3f2c7 - cp a, PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those + cp PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance jr c, .next1 ; branch ahead if this is a 10% chance effect.. ld b, $4d ; else use 0x4D/0x100 or 77/256 = 30.1%~ chance @@ -293,7 +293,7 @@ FreezeBurnParalyzeEffect: ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance jr .next2 .asm_3f341 - cp a, PARALYZE_SIDE_EFFECT1 + 1 + cp PARALYZE_SIDE_EFFECT1 + 1 ld b, $1a jr c, .next2 ld b, $4d diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm index b62d9d4bf..136e3afbe 100644 --- a/engine/gfx/sprite_oam.asm +++ b/engine/gfx/sprite_oam.asm @@ -219,7 +219,7 @@ _IsTilePassable:: ld l, a ; hl now points to passable tiles .loop ld a, [hli] - cp a, $ff + cp $ff jr z, .tileNotPassable cp c jr nz, .loop diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm index c2e0b2b46..86003319b 100644 --- a/engine/items/inventory.asm +++ b/engine/items/inventory.asm @@ -36,7 +36,7 @@ AddItemToInventory_:: inc hl .loop ld a, [hl] - cp a, $ff ; is it the end of the table? + cp $ff ; is it the end of the table? jr nz, .notAtEndOfInventory .addNewItem ; add an item not yet in the inventory pop hl diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 874fe50f8..315e4805c 100755 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -205,9 +205,9 @@ HandlePokedexListMenu: jr z, .checkIfRightPressed .downPressed ; scroll down one row ld a, [wDexMaxSeenMon] - cp a, 7 + cp 7 jp c, .loop ; can't if the list is shorter than 7 - sub a, 7 + sub 7 ld b, a ld a, [wListScrollOffset] cp b @@ -221,12 +221,12 @@ HandlePokedexListMenu: jr z, .checkIfLeftPressed .rightPressed ; scroll down 7 rows ld a, [wDexMaxSeenMon] - cp a, 7 + cp 7 jp c, .loop ; can't if the list is shorter than 7 - sub a, 6 + sub 6 ld b, a ld a, [wListScrollOffset] - add a, 7 + add 7 ld [wListScrollOffset], a cp b jp c, .loop @@ -240,7 +240,7 @@ HandlePokedexListMenu: jr z, .buttonAPressed .leftPressed ld a, [wListScrollOffset] - sub a, 7 + sub 7 ld [wListScrollOffset], a jp nc, .loop xor a @@ -324,7 +324,7 @@ DrawPokedexVerticalLine: .loop ld [hl], a add hl, de - xor a, 1 ; toggle between vertical line tile and box tile + xor 1 ; toggle between vertical line tile and box tile dec c jr nz, .loop ret @@ -459,7 +459,7 @@ ShowPokedexDataInternal: .waitForButtonPress call JoypadLowSensitivity ldh a, [hJoy5] - and a, A_BUTTON | B_BUTTON + and A_BUTTON | B_BUTTON jr z, .waitForButtonPress pop af ldh [hTilesetType], a diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm index 9165113f2..a9774ff94 100755 --- a/engine/movie/intro.asm +++ b/engine/movie/intro.asm @@ -83,7 +83,7 @@ PlayShootingStar: ld b, SET_PAL_GAME_FREAK_INTRO call RunPaletteCommand farcall LoadCopyrightAndTextBoxTiles - ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE + ldpal a, SHADE_BLACK, SHADE_DARK, SHADE_LIGHT, SHADE_WHITE ldh [rBGP], a call UpdateGBCPal_BGP ld c, 180 diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index e31c0bd22..ba412ab2e 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -304,7 +304,7 @@ GetSplitMapSpriteSetID: ld hl, MapSpriteSets add hl, de ld a, [hl] ; a = spriteSetID - cp a, $f0 ; does the map have 2 sprite sets? + cp $f0 ; does the map have 2 sprite sets? ret c ; Chooses the correct sprite set ID depending on the player's position within ; the map for maps with two sprite sets. diff --git a/engine/overworld/specific_script_flags.asm b/engine/overworld/specific_script_flags.asm index d6f333ac2..b59aa9d05 100644 --- a/engine/overworld/specific_script_flags.asm +++ b/engine/overworld/specific_script_flags.asm @@ -8,7 +8,7 @@ SetMapSpecificScriptFlagsOnMapReload:: ld a, [hli] cp c jr z, .in_list - cp a, $ff + cp $ff jr nz, .search_loop ret diff --git a/engine/pikachu/pikachu_pic_animation.asm b/engine/pikachu/pikachu_pic_animation.asm index 33a3e504c..755395ba5 100755 --- a/engine/pikachu/pikachu_pic_animation.asm +++ b/engine/pikachu/pikachu_pic_animation.asm @@ -625,7 +625,7 @@ PikaPicAnimCommand_loadgfx: ld a, [wPikaPicAnimCurGraphicID] call LoadPikaPicAnimGFXHeader ld a, c - cp a, $ff + cp $ff jr z, .compressed call RequestPikaPicAnimGFX jr .done diff --git a/engine/printer/printer2.asm b/engine/printer/printer2.asm index 180f044ca..b257aff4c 100755 --- a/engine/printer/printer2.asm +++ b/engine/printer/printer2.asm @@ -356,7 +356,7 @@ Func_ea6af: ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] - cp a, $6 + cp $6 ret c xor a ld [hl], a @@ -381,17 +381,17 @@ Func_ea6d2: call Func_ea742 ret c ld a, [wPrinterHandshake] - cp a, $ff + cp $ff jr nz, .asm_ea6e4 ld a, [wPrinterStatusFlags] - cp a, $ff + cp $ff jr z, .asm_ea6fb .asm_ea6e4 ld a, [wPrinterHandshake] - cp a, $81 + cp $81 jr nz, .asm_ea6fb ld a, [wPrinterStatusFlags] - cp a, $0 + cp $0 jr nz, .asm_ea6fb ld hl, wPrinterConnectionOpen set 1, [hl] diff --git a/audio/unknown_832b9.bin b/garbage/bank20.bin old mode 100755 new mode 100644 similarity index 50% rename from audio/unknown_832b9.bin rename to garbage/bank20.bin index 1c14816af25157fec2804877b8351996fe25d0f7..96a64283c2ac60bcd6049fafb3e8a5177bb4cea4 GIT binary patch delta 10 RcmX>mbzEvubxdl4+d_9<02D+6jQ{`u diff --git a/home.asm b/home.asm index b21eb4b80..4ae08bc14 100644 --- a/home.asm +++ b/home.asm @@ -50,6 +50,7 @@ INCLUDE "home/inventory.asm" INCLUDE "home/list_menu.asm" INCLUDE "home/names.asm" INCLUDE "home/reload_tiles.asm" +INCLUDE "home/printer.asm" INCLUDE "home/item.asm" INCLUDE "home/textbox.asm" INCLUDE "home/cgb_palettes.asm" diff --git a/home/cgb_palettes.asm b/home/cgb_palettes.asm index 24738ae2c..b8cc92c64 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 40c49c3e0..0003022bb 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 d8c2068e1..39749ee98 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 15f10fe26..5eb2962fe 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 2909b01e9..68d506957 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 f3b3f1b5b..8fd9a26a8 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 c9c946352..ae6acfe3b 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 3e08906fd..8e304fd3e 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 000000000..6d9f145c0 --- /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 ae9f6544b..b596263ae 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 379436ae5..366806e99 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 bd1b24bff..8edccfe27 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 78d691383..adb814257 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 20cfb71d9..fe81cb519 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 0c32dad85..5bb9ee126 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 ed39714fc..3957639ad 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 diff --git a/macros/code.asm b/macros/code.asm index 8507b1ad2..e0b3e9c9d 100755 --- a/macros/code.asm +++ b/macros/code.asm @@ -4,7 +4,7 @@ lb: MACRO ; r, hi, lo ld \1, ((\2) & $ff) << 8 + ((\3) & $ff) ENDM -ldPal: MACRO +ldpal: MACRO ld \1, \2 << 6 | \3 << 4 | \4 << 2 | \5 ENDM diff --git a/macros/farcall.asm b/macros/farcall.asm index e6ecdaae0..f3fa07d40 100644 --- a/macros/farcall.asm +++ b/macros/farcall.asm @@ -32,7 +32,7 @@ homecall: MACRO call BankswitchCommon ENDM -homecall_jump: MACRO +homejp: MACRO ldh a, [hLoadedROMBank] push af ld a, BANK(\1) @@ -42,7 +42,7 @@ homecall_jump: MACRO jp BankswitchCommon ENDM -homecall_jump_sf: MACRO +homecall_sf: MACRO ; homecall but save flags by popping into bc instead of af ldh a, [hLoadedROMBank] push af ld a, BANK(\1) @@ -50,10 +50,10 @@ homecall_jump_sf: MACRO call \1 pop bc ld a, b - jp BankswitchCommon + call BankswitchCommon ENDM -homecall_sf: MACRO ; homecall but save flags by popping into bc instead of af +homejp_sf: MACRO ; homejp but save flags by popping into bc instead of af ldh a, [hLoadedROMBank] push af ld a, BANK(\1) @@ -61,18 +61,7 @@ homecall_sf: MACRO ; homecall but save flags by popping into bc instead of af call \1 pop bc ld a, b - call BankswitchCommon -ENDM - -switchbank: MACRO - ld a, BANK(\1) - call BankswitchCommon -ENDM - -callbs: MACRO - ld a, BANK(\1) - call BankswitchCommon - call \1 + jp BankswitchCommon ENDM calladb_ModifyPikachuHappiness: MACRO diff --git a/macros/gfx.asm b/macros/gfx.asm index ad428eb0e..98eabec44 100644 --- a/macros/gfx.asm +++ b/macros/gfx.asm @@ -16,18 +16,6 @@ color EQUS "+ PAL_COLOR_SIZE *" tiles EQUS "* LEN_2BPP_TILE" tile EQUS "+ LEN_2BPP_TILE *" -setpal: MACRO - ld a, \1 << 6 | \2 << 4 | \3 << 2 | \4 -ENDM - -setpalBGP: MACRO - setpal SHADE_BLACK, SHADE_DARK, SHADE_LIGHT, SHADE_WHITE -ENDM - -setpalOBP: MACRO - setpal SHADE_BLACK, SHADE_DARK, SHADE_WHITE, SHADE_WHITE -ENDM - dbsprite: MACRO ; x tile, y tile, x pixel, y pixel, vtile offset, attributes db (\2 * TILE_WIDTH) % $100 + \4, (\1 * TILE_WIDTH) % $100 + \3, \5, \6