diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-06 19:03:05 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-06 19:03:05 -0400 |
commit | 772fcc7588a4e1fbe146a02b429cf64282c81dcb (patch) | |
tree | f491fa1d38e37ab10534b3f18422e0149ad0deca /home | |
parent | c480632d5494d04f7f5f0298a31877a2293b564e (diff) |
Specify the ldh instruction, don't turn ld into ldh
Diffstat (limited to 'home')
-rw-r--r-- | home/audio.asm | 10 | ||||
-rw-r--r-- | home/bankswitch.asm | 12 | ||||
-rw-r--r-- | home/copy.asm | 6 | ||||
-rw-r--r-- | home/copy2.asm | 96 | ||||
-rw-r--r-- | home/fade.asm | 18 | ||||
-rw-r--r-- | home/init.asm | 60 | ||||
-rw-r--r-- | home/joypad.asm | 12 | ||||
-rw-r--r-- | home/lcd.asm | 18 | ||||
-rw-r--r-- | home/list_menu.asm | 34 | ||||
-rw-r--r-- | home/move_mon.asm | 74 | ||||
-rw-r--r-- | home/names.asm | 6 | ||||
-rw-r--r-- | home/names2.asm | 14 | ||||
-rw-r--r-- | home/overworld.asm | 180 | ||||
-rw-r--r-- | home/pics.asm | 24 | ||||
-rw-r--r-- | home/pokemon.asm | 30 | ||||
-rw-r--r-- | home/predef.asm | 8 | ||||
-rw-r--r-- | home/print_num.asm | 84 | ||||
-rw-r--r-- | home/serial.asm | 96 | ||||
-rwxr-xr-x | home/start_menu.asm | 4 | ||||
-rw-r--r-- | home/text.asm | 18 | ||||
-rw-r--r-- | home/text_script.asm | 38 | ||||
-rw-r--r-- | home/trainers.asm | 18 | ||||
-rw-r--r-- | home/uncompress.asm | 6 | ||||
-rw-r--r-- | home/vblank.asm | 34 | ||||
-rw-r--r-- | home/vcopy.asm | 130 |
25 files changed, 515 insertions, 515 deletions
diff --git a/home/audio.asm b/home/audio.asm index 04f0276d..426506bf 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -170,10 +170,10 @@ PlaySound:: .noFadeOut xor a ld [wNewSoundID], a - ld a, [hLoadedROMBank] - ld [hSavedROMBank], a + ldh a, [hLoadedROMBank] + ldh [hSavedROMBank], a ld a, [wAudioROMBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a cp BANK(Audio1_PlaySound) jr nz, .checkForAudio2 @@ -197,8 +197,8 @@ PlaySound:: call Audio3_PlaySound .next2 - ld a, [hSavedROMBank] - ld [hLoadedROMBank], a + ldh a, [hSavedROMBank] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jr .done diff --git a/home/bankswitch.asm b/home/bankswitch.asm index 086ca2f3..52c8a45c 100644 --- a/home/bankswitch.asm +++ b/home/bankswitch.asm @@ -2,27 +2,27 @@ BankswitchHome:: ; switches to bank # in a ; Only use this when in the home bank! ld [wBankswitchHomeTemp], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wBankswitchHomeSavedROMBank], a ld a, [wBankswitchHomeTemp] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret BankswitchBack:: ; returns from BankswitchHome ld a, [wBankswitchHomeSavedROMBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret Bankswitch:: ; self-contained bankswitch, use this when not in the home bank ; switches to the bank in b - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld bc, .Return push bc @@ -30,6 +30,6 @@ Bankswitch:: .Return pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/copy.asm b/home/copy.asm index 910f508b..880d1fb7 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -1,14 +1,14 @@ FarCopyData:: ; Copy bc bytes from a:hl to de. ld [wBuffer], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [wBuffer] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call CopyData pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/copy2.asm b/home/copy2.asm index 521223b6..01417201 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -1,25 +1,25 @@ FarCopyData2:: ; Identical to FarCopyData, but uses hROMBankTemp ; as temp space instead of wBuffer. - ld [hROMBankTemp], a - ld a, [hLoadedROMBank] + ldh [hROMBankTemp], a + ldh a, [hLoadedROMBank] push af - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call CopyData pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret FarCopyData3:: ; Copy bc bytes from a:de to hl. - ld [hROMBankTemp], a - ld a, [hLoadedROMBank] + ldh [hROMBankTemp], a + ldh a, [hLoadedROMBank] push af - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push hl push de @@ -31,18 +31,18 @@ FarCopyData3:: pop de pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret FarCopyDataDouble:: ; Expand bc bytes of 1bpp image data ; from a:hl to 2bpp data at de. - ld [hROMBankTemp], a - ld a, [hLoadedROMBank] + ldh [hROMBankTemp], a + ldh a, [hLoadedROMBank] push af - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a .loop ld a, [hli] @@ -55,7 +55,7 @@ FarCopyDataDouble:: or b jr nz, .loop pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -64,27 +64,27 @@ CopyVideoData:: ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] push af xor a ; disable auto-transfer while copying - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a - ld a, [hLoadedROMBank] - ld [hROMBankTemp], a + ldh a, [hLoadedROMBank] + ldh [hROMBankTemp], a ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, e - ld [hVBlankCopySource], a + ldh [hVBlankCopySource], a ld a, d - ld [hVBlankCopySource + 1], a + ldh [hVBlankCopySource + 1], a ld a, l - ld [hVBlankCopyDest], a + ldh [hVBlankCopyDest], a ld a, h - ld [hVBlankCopyDest + 1], a + ldh [hVBlankCopyDest + 1], a .loop ld a, c @@ -92,18 +92,18 @@ CopyVideoData:: jr nc, .keepgoing .done - ld [hVBlankCopySize], a + ldh [hVBlankCopySize], a call DelayFrame - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop af - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret .keepgoing ld a, 8 - ld [hVBlankCopySize], a + ldh [hVBlankCopySize], a call DelayFrame ld a, c sub 8 @@ -114,26 +114,26 @@ CopyVideoDataDouble:: ; Wait for the next VBlank, then copy c 1bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] push af xor a ; disable auto-transfer while copying - ld [hAutoBGTransferEnabled], a - ld a, [hLoadedROMBank] - ld [hROMBankTemp], a + ldh [hAutoBGTransferEnabled], a + ldh a, [hLoadedROMBank] + ldh [hROMBankTemp], a ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, e - ld [hVBlankCopyDoubleSource], a + ldh [hVBlankCopyDoubleSource], a ld a, d - ld [hVBlankCopyDoubleSource + 1], a + ldh [hVBlankCopyDoubleSource + 1], a ld a, l - ld [hVBlankCopyDoubleDest], a + ldh [hVBlankCopyDoubleDest], a ld a, h - ld [hVBlankCopyDoubleDest + 1], a + ldh [hVBlankCopyDoubleDest + 1], a .loop ld a, c @@ -141,18 +141,18 @@ CopyVideoDataDouble:: jr nc, .keepgoing .done - ld [hVBlankCopyDoubleSize], a + ldh [hVBlankCopyDoubleSize], a call DelayFrame - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop af - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret .keepgoing ld a, 8 - ld [hVBlankCopyDoubleSize], a + ldh [hVBlankCopyDoubleSize], a call DelayFrame ld a, c sub 8 @@ -200,16 +200,16 @@ CopyScreenTileBufferToVRAM:: .setup ld a, d - ld [hVBlankCopyBGSource+1], a + ldh [hVBlankCopyBGSource+1], a call GetRowColAddressBgMap ld a, l - ld [hVBlankCopyBGDest], a + ldh [hVBlankCopyBGDest], a ld a, h - ld [hVBlankCopyBGDest+1], a + ldh [hVBlankCopyBGDest+1], a ld a, c - ld [hVBlankCopyBGNumRows], a + ldh [hVBlankCopyBGNumRows], a ld a, e - ld [hVBlankCopyBGSource], a + ldh [hVBlankCopyBGSource], a ret ClearScreen:: diff --git a/home/fade.asm b/home/fade.asm index 9482fcb0..32175e16 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -11,11 +11,11 @@ LoadGBPal:: dec h .ok ld a, [hli] - ld [rBGP], a + ldh [rBGP], a ld a, [hli] - ld [rOBP0], a + ldh [rOBP0], a ld a, [hli] - ld [rOBP1], a + ldh [rOBP1], a ret GBFadeInFromBlack:: @@ -29,11 +29,11 @@ GBFadeOutToWhite:: GBFadeIncCommon: ld a, [hli] - ld [rBGP], a + ldh [rBGP], a ld a, [hli] - ld [rOBP0], a + ldh [rOBP0], a ld a, [hli] - ld [rOBP1], a + ldh [rOBP1], a ld c, 8 call DelayFrames dec b @@ -51,11 +51,11 @@ GBFadeInFromWhite:: GBFadeDecCommon: ld a, [hld] - ld [rOBP1], a + ldh [rOBP1], a ld a, [hld] - ld [rOBP0], a + ldh [rOBP0], a ld a, [hld] - ld [rBGP], a + ldh [rBGP], a ld c, 8 call DelayFrames dec b diff --git a/home/init.asm b/home/init.asm index 83238bad..f18216ff 100644 --- a/home/init.asm +++ b/home/init.asm @@ -21,22 +21,22 @@ rLCDC_DEFAULT EQU %11100011 di xor a - ld [rIF], a - ld [rIE], a - ld [rSCX], a - ld [rSCY], a - ld [rSB], a - ld [rSC], a - ld [rWX], a - ld [rWY], a - ld [rTMA], a - ld [rTAC], a - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a + ldh [rIF], a + ldh [rIE], a + ldh [rSCX], a + ldh [rSCY], a + ldh [rSB], a + ldh [rSC], a + ldh [rWX], a + ldh [rWY], a + ldh [rTMA], a + ldh [rTAC], a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a ld a, rLCDC_ENABLE_MASK - ld [rLCDC], a + ldh [rLCDC], a call DisableLCD ld sp, wStack @@ -60,27 +60,27 @@ rLCDC_DEFAULT EQU %11100011 call ClearSprites ld a, BANK(WriteDMACodeToHRAM) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call WriteDMACodeToHRAM xor a - ld [hTilesetType], a - ld [rSTAT], a - ld [hSCX], a - ld [hSCY], a - ld [rIF], a + ldh [hTilesetType], a + ldh [rSTAT], a + ldh [hSCX], a + ldh [hSCY], a + ldh [rIF], a ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL - ld [rIE], a + ldh [rIE], a ld a, 144 ; move the window off-screen - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a ld a, 7 - ld [rWX], a + ldh [rWX], a ld a, CONNECTION_NOT_ESTABLISHED - ld [hSerialConnectionStatus], a + ldh [hSerialConnectionStatus], a ld h, vBGMap0 / $100 call ClearBgMap @@ -88,9 +88,9 @@ rLCDC_DEFAULT EQU %11100011 call ClearBgMap ld a, rLCDC_DEFAULT - ld [rLCDC], a + ldh [rLCDC], a ld a, 16 - ld [hSoftReset], a + ldh [hSoftReset], a call StopAllSounds ei @@ -101,9 +101,9 @@ rLCDC_DEFAULT EQU %11100011 ld [wAudioROMBank], a ld [wAudioSavedROMBank], a ld a, $9c - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a xor a - ld [hAutoBGTransferDest], a + ldh [hAutoBGTransferDest], a dec a ld [wUpdateSpritesEnabled], a @@ -114,7 +114,7 @@ rLCDC_DEFAULT EQU %11100011 call GBPalNormal call ClearSprites ld a, rLCDC_DEFAULT - ld [rLCDC], a + ldh [rLCDC], a jp SetDefaultNamesBeforeTitlescreen diff --git a/home/joypad.asm b/home/joypad.asm index 9948b6e7..51a77fcc 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -6,9 +6,9 @@ ReadJoypad:: ld a, 1 << 5 ; select direction keys ld c, 0 - ld [rJOYP], a + ldh [rJOYP], a REPT 6 - ld a, [rJOYP] + ldh a, [rJOYP] ENDR cpl and %1111 @@ -16,18 +16,18 @@ ReadJoypad:: ld b, a ld a, 1 << 4 ; select button keys - ld [rJOYP], a + ldh [rJOYP], a REPT 10 - ld a, [rJOYP] + ldh a, [rJOYP] ENDR cpl and %1111 or b - ld [hJoyInput], a + ldh [hJoyInput], a ld a, 1 << 4 + 1 << 5 ; deselect keys - ld [rJOYP], a + ldh [rJOYP], a ret Joypad:: diff --git a/home/lcd.asm b/home/lcd.asm index e88a42b3..72fc70ed 100644 --- a/home/lcd.asm +++ b/home/lcd.asm @@ -1,25 +1,25 @@ DisableLCD:: xor a - ld [rIF], a - ld a, [rIE] + ldh [rIF], a + ldh a, [rIE] ld b, a res 0, a - ld [rIE], a + ldh [rIE], a .wait - ld a, [rLY] + ldh a, [rLY] cp LY_VBLANK jr nz, .wait - ld a, [rLCDC] + ldh a, [rLCDC] and $ff ^ rLCDC_ENABLE_MASK - ld [rLCDC], a + ldh [rLCDC], a ld a, b - ld [rIE], a + ldh [rIE], a ret EnableLCD:: - ld a, [rLCDC] + ldh a, [rLCDC] set rLCDC_ENABLE, a - ld [rLCDC], a + ldh [rLCDC], a ret diff --git a/home/list_menu.asm b/home/list_menu.asm index 4ce973b2..9c567d0d 100644 --- a/home/list_menu.asm +++ b/home/list_menu.asm @@ -3,9 +3,9 @@ ; [wListPointer] = address of the list (2 bytes) DisplayListMenuID:: xor a - ld [hAutoBGTransferEnabled], a ; disable auto-transfer + ldh [hAutoBGTransferEnabled], a ; disable auto-transfer ld a, 1 - ld [hJoy7], a ; joypad state update flag + ldh [hJoy7], a ; joypad state update flag ld a, [wBattleType] and a ; is it the Old Man battle? jr nz, .specialBattleType @@ -57,10 +57,10 @@ DisplayListMenuID:: DisplayListMenuIDLoop:: xor a - ld [hAutoBGTransferEnabled], a ; disable transfer + ldh [hAutoBGTransferEnabled], a ; disable transfer call PrintListMenuEntries ld a, 1 - ld [hAutoBGTransferEnabled], a ; enable transfer + ldh [hAutoBGTransferEnabled], a ; enable transfer call Delay3 ld a, [wBattleType] and a ; is it the Old Man battle? @@ -163,7 +163,7 @@ DisplayListMenuIDLoop:: ld a, [wCurrentMenuItem] ld [wChosenMenuItem], a xor a - ld [hJoy7], a ; joypad state update flag + ldh [hJoy7], a ; joypad state update flag ld hl, wd730 res 6, [hl] ; turn on letter printing delay jp BankswitchBack @@ -219,7 +219,7 @@ DisplayChooseQuantityMenu:: jp .incrementQuantity .waitForKeyPressLoop call JoypadLowSensitivity - ld a, [hJoyPressed] ; newly pressed buttons + ldh a, [hJoyPressed] ; newly pressed buttons bit 0, a ; was the A button pressed? jp nz, .buttonAPressed bit 1, a ; was the B button pressed? @@ -272,22 +272,22 @@ DisplayChooseQuantityMenu:: pop bc dec b jr nz, .addLoop - ld a, [hHalveItemPrices] + ldh a, [hHalveItemPrices] and a ; should the price be halved (for selling items)? jr z, .skipHalvingPrice xor a - ld [hDivideBCDDivisor], a - ld [hDivideBCDDivisor + 1], a + ldh [hDivideBCDDivisor], a + ldh [hDivideBCDDivisor + 1], a ld a, $02 - ld [hDivideBCDDivisor + 2], a + ldh [hDivideBCDDivisor + 2], a predef DivideBCDPredef3 ; halves the price ; store the halved price - ld a, [hDivideBCDQuotient] - ld [hMoney], a - ld a, [hDivideBCDQuotient + 1] - ld [hMoney + 1], a - ld a, [hDivideBCDQuotient + 2] - ld [hMoney + 2], a + ldh a, [hDivideBCDQuotient] + ldh [hMoney], a + ldh a, [hDivideBCDQuotient + 1] + ldh [hMoney + 1], a + ldh a, [hDivideBCDQuotient + 2] + ldh [hMoney + 2], a .skipHalvingPrice coord hl, 12, 10 ld de, SpacesBetweenQuantityAndPriceText @@ -324,7 +324,7 @@ ExitListMenu:: ld [wMenuExitMethod], a ld [wMenuWatchMovingOutOfBounds], a xor a - ld [hJoy7], a + ldh [hJoy7], a ld hl, wd730 res 6, [hl] call BankswitchBack diff --git a/home/move_mon.asm b/home/move_mon.asm index e13ebf4e..7be8eaf5 100644 --- a/home/move_mon.asm +++ b/home/move_mon.asm @@ -21,10 +21,10 @@ CalcStats:: .statsLoop inc c call CalcStat - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] ld [de], a inc de - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] ld [de], a inc de ld a, c @@ -57,22 +57,22 @@ CalcStat:: add hl, bc ; skip to corresponding stat exp value .statExpLoop ; calculates ceil(Sqrt(stat exp)) in b xor a - ld [hMultiplicand], a - ld [hMultiplicand+1], a + ldh [hMultiplicand], a + ldh [hMultiplicand+1], a inc b ; increment current stat exp bonus ld a, b cp $ff jr z, .statExpDone - ld [hMultiplicand+2], a - ld [hMultiplier], a + ldh [hMultiplicand+2], a + ldh [hMultiplier], a call Multiply ld a, [hld] ld d, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] sub d ld a, [hli] ld d, a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] sbc d ; test if (current stat exp bonus)^2 < stat exp jr c, .statExpLoop .statExpDone @@ -152,22 +152,22 @@ CalcStat:: jr nc, .noCarry2 inc d ; de = (Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4 .noCarry2 - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a ld a, d - ld [hMultiplicand+1], a + ldh [hMultiplicand+1], a xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [wCurEnemyLVL] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; ((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level - ld a, [hMultiplicand] - ld [hDividend], a - ld a, [hMultiplicand+1] - ld [hDividend+1], a - ld a, [hMultiplicand+2] - ld [hDividend+2], a + ldh a, [hMultiplicand] + ldh [hDividend], a + ldh a, [hMultiplicand+1] + ldh [hDividend+1], a + ldh a, [hMultiplicand+2] + ldh [hDividend+2], a ld a, $64 - ld [hDivisor], a + ldh [hDivisor], a ld a, $3 ld b, a call Divide ; (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 @@ -177,38 +177,38 @@ CalcStat:: jr nz, .notHPStat ld a, [wCurEnemyLVL] ld b, a - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] add b - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a jr nc, .noCarry3 - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] inc a - ld [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + ldh [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level .noCarry3 ld a, 10 ; +10 for HP stat .notHPStat ld b, a - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] add b - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a jr nc, .noCarry4 - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] inc a ; non-HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + 5 - ld [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 + ldh [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 .noCarry4 - ld a, [hMultiplicand+1] ; check for overflow (>999) + ldh a, [hMultiplicand+1] ; check for overflow (>999) cp 999 / $100 + 1 jr nc, .overflow cp 999 / $100 jr c, .noOverflow - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] cp 999 % $100 + 1 jr c, .noOverflow .overflow ld a, 999 / $100 ; overflow: cap at 999 - ld [hMultiplicand+1], a + ldh [hMultiplicand+1], a ld a, 999 % $100 - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a .noOverflow pop bc pop de @@ -216,27 +216,27 @@ CalcStat:: ret AddEnemyMonToPlayerParty:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(_AddEnemyMonToPlayerParty) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call _AddEnemyMonToPlayerParty pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret MoveMon:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(_MoveMon) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call _MoveMon pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/names.asm b/home/names.asm index 489bd040..f7751fa0 100644 --- a/home/names.asm +++ b/home/names.asm @@ -1,9 +1,9 @@ GetMonName:: push hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(MonsterNames) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, [wd11e] dec a @@ -19,7 +19,7 @@ GetMonName:: ld [hl], "@" pop de pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop hl ret diff --git a/home/names2.asm b/home/names2.asm index ecf6ae63..8f539c31 100644 --- a/home/names2.asm +++ b/home/names2.asm @@ -22,7 +22,7 @@ GetName:: cp HM01 jp nc, GetMachineName - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af push hl push bc @@ -40,7 +40,7 @@ GetName:: .otherEntries ;2-7 = OTHER ENTRIES ld a, [wPredefBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, [wNameListType] ;VariousNames' entryID dec a @@ -53,12 +53,12 @@ GetName:: ld hl, NamePointers add hl, de ld a, [hli] - ld [hSwapTemp + 1], a + ldh [hSwapTemp + 1], a ld a, [hl] - ld [hSwapTemp], a - ld a, [hSwapTemp] + ldh [hSwapTemp], a + ldh a, [hSwapTemp] ld h, a - ld a, [hSwapTemp + 1] + ldh a, [hSwapTemp + 1] ld l, a ld a, [wd0b5] ld b, a @@ -88,6 +88,6 @@ GetName:: pop bc pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/overworld.asm b/home/overworld.asm index be4af6ee..18c7977e 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -67,16 +67,16 @@ OverworldLoopLessDelay:: ld a, [wd730] bit 7, a ; are we simulating button presses? jr z, .notSimulating - ld a, [hJoyHeld] + ldh a, [hJoyHeld] jr .checkIfStartIsPressed .notSimulating - ld a, [hJoyPressed] + ldh a, [hJoyPressed] .checkIfStartIsPressed bit 3, a ; start button jr z, .startButtonNotPressed ; if START is pressed xor a ; TEXT_START_MENU - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp .displayDialogue .startButtonNotPressed bit 0, a ; A button @@ -88,11 +88,11 @@ OverworldLoopLessDelay:: call IsPlayerCharacterBeingControlledByGame jr nz, .checkForOpponent call CheckForHiddenObjectOrBookshelfOrCardKeyDoor - ld a, [hItemAlreadyFound] + ldh a, [hItemAlreadyFound] and a jp z, OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found call IsSpriteOrSignInFrontOfPlayer - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] and a jp z, OverworldLoop .displayDialogue @@ -145,7 +145,7 @@ OverworldLoopLessDelay:: jp OverworldLoop .checkIfDownButtonIsPressed - ld a, [hJoyHeld] ; current joypad state + ldh a, [hJoyHeld] ; current joypad state bit 7, a ; down button jr z, .checkIfUpButtonIsPressed ld a, 1 @@ -332,7 +332,7 @@ OverworldLoopLessDelay:: set 5, [hl] set 6, [hl] xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, [wCurMap] cp CINNABAR_GYM jr nz, .notCinnabarGym @@ -381,7 +381,7 @@ DoBikeSpeedup:: ld a, [wCurMap] cp ROUTE_17 ; Cycling Road jr nz, .goFaster - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_UP | D_LEFT | D_RIGHT ret nz .goFaster @@ -431,7 +431,7 @@ CheckWarpsNoCollisionLoop:: call Joypad pop bc pop de - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_DOWN | D_UP | D_LEFT | D_RIGHT jr z, CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp jr WarpFound1 @@ -455,7 +455,7 @@ CheckWarpsCollision:: ld a, [hli] ld [wDestinationWarpID], a ld a, [hl] - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a jr WarpFound2 .retry1 inc hl @@ -477,7 +477,7 @@ WarpFound1:: ld a, [hli] ld [wDestinationWarpID], a ld a, [hli] - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a WarpFound2:: ld a, [wNumberOfWarps] @@ -492,7 +492,7 @@ WarpFound2:: ld [wLastMap], a ld a, [wCurMapWidth] ld [wUnusedD366], a ; not read - ld a, [hWarpDestinationMap] + ldh a, [hWarpDestinationMap] ld [wCurMap], a cp ROCK_TUNNEL_1F jr nz, .notRockTunnel @@ -506,7 +506,7 @@ WarpFound2:: ; for maps that can have the 0xFF destination map, which means to return to the outside map ; not all these maps are necessarily indoors, though .indoorMaps - ld a, [hWarpDestinationMap] ; destination map + ldh a, [hWarpDestinationMap] ; destination map cp $ff jr z, .goBackOutside ; if not going back to the previous map @@ -763,7 +763,7 @@ HandleBlackOut:: ld hl, wd72e res 5, [hl] ld a, BANK(ResetStatusAndHalveMoneyOnBlackout) ; also BANK(SpecialWarpIn) and BANK(SpecialEnterMap) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call ResetStatusAndHalveMoneyOnBlackout call SpecialWarpIn @@ -794,7 +794,7 @@ HandleFlyWarpOrDungeonWarp:: res 5, [hl] ; forced to ride bike call LeaveMapAnim ld a, BANK(SpecialWarpIn) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call SpecialWarpIn jp SpecialEnterMap @@ -813,7 +813,7 @@ LoadPlayerSpriteGraphics:: dec a jr z, .ridingBike - ld a, [hTilesetType] + ldh a, [hTilesetType] and a jr nz, .determineGraphics jr .startWalking @@ -899,9 +899,9 @@ LoadTileBlockMap:: ; a 3-byte border at the edges of the map is kept so that there is space for map connections ld hl, wOverworldMap ld a, [wCurMapWidth] - ld [hMapWidth], a + ldh [hMapWidth], a add MAP_BORDER * 2 ; east and west - ld [hMapStride], a ; map width + border + ldh [hMapStride], a ; map width + border ld b, 0 ld c, a ; make space for north border (next 3 lines) @@ -918,7 +918,7 @@ LoadTileBlockMap:: ld b, a .rowLoop ; copy one row each iteration push hl - ld a, [hMapWidth] ; map width (without border) + ldh a, [hMapWidth] ; map width (without border) ld c, a .rowInnerLoop ld a, [de] @@ -928,7 +928,7 @@ LoadTileBlockMap:: jr nz, .rowInnerLoop ; add the map width plus the border to the base address of the current row to get the next row's address pop hl - ld a, [hMapStride] ; map width + border + ldh a, [hMapStride] ; map width + border add l ld l, a jr nc, .noCarry @@ -950,9 +950,9 @@ LoadTileBlockMap:: ld a, [wNorthConnectionStripDest + 1] ld d, a ld a, [wNorthConnectionStripWidth] - ld [hNorthSouthConnectionStripWidth], a + ldh [hNorthSouthConnectionStripWidth], a ld a, [wNorthConnectedMapWidth] - ld [hNorthSouthConnectedMapWidth], a + ldh [hNorthSouthConnectedMapWidth], a call LoadNorthSouthConnectionsTileMap .southConnection ld a, [wMapConn2Ptr] @@ -968,9 +968,9 @@ LoadTileBlockMap:: ld a, [wSouthConnectionStripDest + 1] ld d, a ld a, [wSouthConnectionStripWidth] - ld [hNorthSouthConnectionStripWidth], a + ldh [hNorthSouthConnectionStripWidth], a ld a, [wSouthConnectedMapWidth] - ld [hNorthSouthConnectedMapWidth], a + ldh [hNorthSouthConnectedMapWidth], a call LoadNorthSouthConnectionsTileMap .westConnection ld a, [wMapConn3Ptr] @@ -988,7 +988,7 @@ LoadTileBlockMap:: ld a, [wWestConnectionStripHeight] ld b, a ld a, [wWestConnectedMapWidth] - ld [hEastWestConnectedMapWidth], a + ldh [hEastWestConnectedMapWidth], a call LoadEastWestConnectionsTileMap .eastConnection ld a, [wMapConn4Ptr] @@ -1006,7 +1006,7 @@ LoadTileBlockMap:: ld a, [wEastConnectionStripHeight] ld b, a ld a, [wEastConnectedMapWidth] - ld [hEastWestConnectedMapWidth], a + ldh [hEastWestConnectedMapWidth], a call LoadEastWestConnectionsTileMap .done ret @@ -1016,7 +1016,7 @@ LoadNorthSouthConnectionsTileMap:: .loop push de push hl - ld a, [hNorthSouthConnectionStripWidth] + ldh a, [hNorthSouthConnectionStripWidth] ld b, a .innerLoop ld a, [hli] @@ -1026,7 +1026,7 @@ LoadNorthSouthConnectionsTileMap:: jr nz, .innerLoop pop hl pop de - ld a, [hNorthSouthConnectedMapWidth] + ldh a, [hNorthSouthConnectedMapWidth] add l ld l, a jr nc, .noCarry1 @@ -1055,7 +1055,7 @@ LoadEastWestConnectionsTileMap:: jr nz, .innerLoop pop de pop hl - ld a, [hEastWestConnectedMapWidth] + ldh a, [hEastWestConnectedMapWidth] add l ld l, a jr nc, .noCarry1 @@ -1077,7 +1077,7 @@ LoadEastWestConnectionsTileMap:: ; if not, [hSpriteIndexOrTextID] is set to 0 IsSpriteOrSignInFrontOfPlayer:: xor a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a ld a, [wNumSigns] and a jr z, .extendRangeOverCounter @@ -1107,7 +1107,7 @@ IsSpriteOrSignInFrontOfPlayer:: dec c add hl, bc ld a, [hl] - ld [hSpriteIndexOrTextID], a ; store sign text ID + ldh [hSpriteIndexOrTextID], a ; store sign text ID pop bc pop hl ret @@ -1213,7 +1213,7 @@ IsSpriteInFrontOfPlayer2:: ld l, a ; hl = $c1x1 set 7, [hl] ; set flag to make the sprite face the player ld a, e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a ret ; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing) @@ -1232,9 +1232,9 @@ CollisionCheckOnLand:: and d ; check if a sprite is in the direction the player is trying to go jr nz, .collision xor a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call IsSpriteInFrontOfPlayer ; check for sprite collisions again? when does the above check fail to detect a sprite collision? - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] and a ; was there a sprite collision? jr nz, .collision ; if no sprite collision @@ -1372,10 +1372,10 @@ TilePairCollisionsWater:: ; this builds a tile map from the tile block map based on the current X/Y coordinates of the player's character LoadCurrentMapView:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [wTilesetBank] ; tile data ROM bank - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ; switch to ROM bank that contains tile data ld a, [wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view ld e, a @@ -1457,7 +1457,7 @@ LoadCurrentMapView:: dec b jr nz, .rowLoop2 pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ; restore previous ROM bank ret @@ -1627,12 +1627,12 @@ AdvancePlayerSprite:: ld c, a sla b sla c - ld a, [hSCY] + ldh a, [hSCY] add b - ld [hSCY], a ; update background scroll Y - ld a, [hSCX] + ldh [hSCY], a ; update background scroll Y + ldh a, [hSCX] add c - ld [hSCX], a ; update background scroll X + ldh [hSCX], a ; update background scroll X ; shift all the sprites in the direction opposite of the player's motion ; so that the player appears to move relative to them ld hl, wSprite01StateData1YPixels @@ -1714,11 +1714,11 @@ ScheduleNorthRowRedraw:: coord hl, 0, 0 call CopyToRedrawRowOrColumnSrcTiles ld a, [wMapViewVRAMPointer] - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, [wMapViewVRAMPointer + 1] - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, REDRAW_ROW - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret CopyToRedrawRowOrColumnSrcTiles:: @@ -1744,11 +1744,11 @@ ScheduleSouthRowRedraw:: ld a, h and $03 or $98 - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, l - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, REDRAW_ROW - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret ScheduleEastColumnRedraw:: @@ -1762,11 +1762,11 @@ ScheduleEastColumnRedraw:: add 18 and $1f or b - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, [wMapViewVRAMPointer + 1] - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, REDRAW_COL - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret ScheduleColumnRedrawHelper:: @@ -1793,11 +1793,11 @@ ScheduleWestColumnRedraw:: coord hl, 0, 0 call ScheduleColumnRedrawHelper ld a, [wMapViewVRAMPointer] - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, [wMapViewVRAMPointer + 1] - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, REDRAW_COL - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret ; function to write the tiles that make up a tile block to memory @@ -1855,17 +1855,17 @@ JoypadOverworld:: ld a, [wCurMap] cp ROUTE_17 ; Cycling Road jr nz, .notForcedDownwards - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON jr nz, .notForcedDownwards ld a, D_DOWN - ld [hJoyHeld], a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press + ldh [hJoyHeld], a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press .notForcedDownwards ld a, [wd730] bit 7, a ret z ; if simulating button presses - ld a, [hJoyHeld] + ldh a, [hJoyHeld] ld b, a ld a, [wOverrideSimulatedJoypadStatesMask] ; bit mask for button presses that override simulated ones and b @@ -1882,11 +1882,11 @@ JoypadOverworld:: inc h .noCarry ld a, [hl] - ld [hJoyHeld], a ; store simulated button press in joypad state + ldh [hJoyHeld], a ; store simulated button press in joypad state and a ret nz - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ret ; if done simulating button presses @@ -1896,7 +1896,7 @@ JoypadOverworld:: ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesEnd], a ld [wJoyIgnore], a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld hl, wd736 ld a, [hl] and $f8 @@ -2041,7 +2041,7 @@ LoadMapHeader:: ld b, a res 7, a ld [wCurMapTileset], a - ld [hPreviousTileset], a + ldh [hPreviousTileset], a bit 7, b ret nz ld hl, MapHeaderPointers @@ -2134,9 +2134,9 @@ LoadMapHeader:: ld c, a ld de, wSignTextIDs ld a, d - ld [hSignCoordPointer], a + ldh [hSignCoordPointer], a ld a, e - ld [hSignCoordPointer + 1], a + ldh [hSignCoordPointer + 1], a ld de, wSignCoords .signLoop ld a, [hli] @@ -2146,17 +2146,17 @@ LoadMapHeader:: ld [de], a inc de push de - ld a, [hSignCoordPointer] + ldh a, [hSignCoordPointer] ld d, a - ld a, [hSignCoordPointer + 1] + ldh a, [hSignCoordPointer + 1] ld e, a ld a, [hli] ld [de], a inc de ld a, d - ld [hSignCoordPointer], a + ldh [hSignCoordPointer], a ld a, e - ld [hSignCoordPointer + 1], a + ldh [hSignCoordPointer + 1], a pop de dec c jr nz, .signLoop @@ -2210,24 +2210,24 @@ LoadMapHeader:: ld a, [hli] ld [de], a ; store movement byte 1 at C2X6 ld a, [hli] - ld [hLoadSpriteTemp1], a ; save movement byte 2 + ldh [hLoadSpriteTemp1], a ; save movement byte 2 ld a, [hli] - ld [hLoadSpriteTemp2], a ; save text ID and flags byte + ldh [hLoadSpriteTemp2], a ; save text ID and flags byte push bc push hl ld b, $00 ld hl, wMapSpriteData add hl, bc - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] ld [hli], a ; store movement byte 2 in byte 0 of sprite entry - ld a, [hLoadSpriteTemp2] + ldh a, [hLoadSpriteTemp2] ld [hl], a ; this appears pointless, since the value is overwritten immediately after - ld a, [hLoadSpriteTemp2] - ld [hLoadSpriteTemp1], a + ldh a, [hLoadSpriteTemp2] + ldh [hLoadSpriteTemp1], a and $3f ld [hl], a ; store text ID in byte 1 of sprite entry pop hl - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] bit 6, a jr nz, .trainerSprite bit 7, a @@ -2235,25 +2235,25 @@ LoadMapHeader:: jr .regularSprite .trainerSprite ld a, [hli] - ld [hLoadSpriteTemp1], a ; save trainer class + ldh [hLoadSpriteTemp1], a ; save trainer class ld a, [hli] - ld [hLoadSpriteTemp2], a ; save trainer number (within class) + ldh [hLoadSpriteTemp2], a ; save trainer number (within class) push hl ld hl, wMapSpriteExtraData add hl, bc - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] ld [hli], a ; store trainer class in byte 0 of the entry - ld a, [hLoadSpriteTemp2] + ldh a, [hLoadSpriteTemp2] ld [hl], a ; store trainer number in byte 1 of the entry pop hl jr .nextSprite .itemBallSprite ld a, [hli] - ld [hLoadSpriteTemp1], a ; save item number + ldh [hLoadSpriteTemp1], a ; save item number push hl ld hl, wMapSpriteExtraData add hl, bc - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] ld [hli], a ; store item number in byte 0 of the entry xor a ld [hl], a ; zero byte 1, since it is not used @@ -2291,10 +2291,10 @@ LoadMapHeader:: ld a, [wCurMap] ld c, a ld b, $00 - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(MapSongBanks) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld hl, MapSongBanks add hl, bc @@ -2304,7 +2304,7 @@ LoadMapHeader:: ld a, [hl] ld [wMapMusicROMBank], a ; music 2 pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -2322,15 +2322,15 @@ CopyMapConnectionHeader:: ; function to load map data LoadMapData:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af call DisableLCD ld a, $98 ld [wMapViewVRAMPointer + 1], a xor a ld [wMapViewVRAMPointer], a - ld [hSCY], a - ld [hSCX], a + ldh [hSCY], a + ldh [hSCX], a ld [wWalkCounter], a ld [wUnusedD119], a ld [wWalkBikeSurfStateCopy], a @@ -2377,7 +2377,7 @@ LoadMapData:: call PlayDefaultMusicFadeOutCurrent .restoreRomBank pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -2393,10 +2393,10 @@ SwitchToMapRomBank:: ld hl, MapHeaderBanks add hl, bc ld a, [hl] - ld [hMapROMBank], a ; save map ROM bank + ldh [hMapROMBank], a ; save map ROM bank call BankswitchBack - ld a, [hMapROMBank] - ld [hLoadedROMBank], a + ldh a, [hMapROMBank] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ; switch to map ROM bank pop bc pop hl diff --git a/home/pics.asm b/home/pics.asm index c6d99cbb..ef668620 100644 --- a/home/pics.asm +++ b/home/pics.asm @@ -63,7 +63,7 @@ LoadMonFrontSprite:: LoadUncompressedSpriteData:: push de and $f - ld [hSpriteWidth], a ; each byte contains 8 pixels (in 1bpp), so tiles=bytes for width + ldh [hSpriteWidth], a ; each byte contains 8 pixels (in 1bpp), so tiles=bytes for width ld b, a ld a, $7 sub b ; 7-w @@ -74,7 +74,7 @@ LoadUncompressedSpriteData:: add a add a sub b ; 7*((8-w)/2) ; skip for horizontal center (in tiles) - ld [hSpriteOffset], a + ldh [hSpriteOffset], a ld a, c swap a and $f @@ -82,16 +82,16 @@ LoadUncompressedSpriteData:: add a add a add a ; 8*tiles is height in bytes - ld [hSpriteHeight], a + ldh [hSpriteHeight], a ld a, $7 sub b ; 7-h ; skip for vertical center (in tiles, relative to current column) ld b, a - ld a, [hSpriteOffset] + ldh a, [hSpriteOffset] add b ; 7*((8-w)/2) + 7-h ; combined overall offset (in tiles) add a add a add a ; 8*(7*((8-w)/2) + 7-h) ; combined overall offset (in bytes) - ld [hSpriteOffset], a + ldh [hSpriteOffset], a xor a ld [MBC1SRamBank], a ld hl, sSpriteBuffer0 @@ -110,15 +110,15 @@ LoadUncompressedSpriteData:: ; copies and aligns the sprite data properly inside the sprite buffer ; sprite buffers are 7*7 tiles in size, the loaded sprite is centered within this area AlignSpriteDataCentered:: - ld a, [hSpriteOffset] + ldh a, [hSpriteOffset] ld b, $0 ld c, a add hl, bc - ld a, [hSpriteWidth] + ldh a, [hSpriteWidth] .columnLoop push af push hl - ld a, [hSpriteHeight] + ldh a, [hSpriteHeight] ld c, a .columnInnerLoop ld a, [de] @@ -157,7 +157,7 @@ InterlaceMergeSpriteBuffers:: ld de, sSpriteBuffer1 + (SPRITEBUFFERSIZE - 1) ; source 2: end of buffer 1 ld bc, sSpriteBuffer0 + (SPRITEBUFFERSIZE - 1) ; source 1: end of buffer 0 ld a, SPRITEBUFFERSIZE/2 ; $c4 - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], a .interlaceLoop ld a, [de] dec de @@ -171,9 +171,9 @@ InterlaceMergeSpriteBuffers:: ld a, [bc] dec bc ld [hld], a ; write byte of source 1 - ld a, [hSpriteInterlaceCounter] + ldh a, [hSpriteInterlaceCounter] dec a - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], a jr nz, .interlaceLoop ld a, [wSpriteFlipped] and a @@ -191,6 +191,6 @@ InterlaceMergeSpriteBuffers:: pop hl ld de, sSpriteBuffer1 ld c, (2*SPRITEBUFFERSIZE)/16 ; $31, number of 16 byte chunks to be copied - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld b, a jp CopyVideoData diff --git a/home/pokemon.asm b/home/pokemon.asm index 539632d4..6c5442c4 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -122,18 +122,18 @@ LoadFrontSpriteByMonIndex:: ld de, vFrontPic call LoadMonFrontSprite pop hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(CopyUncompressedPicToHL) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a xor a - ld [hStartTileID], a + ldh [hStartTileID], a call CopyUncompressedPicToHL xor a ld [wSpriteFlipped], a pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -175,10 +175,10 @@ GetCryData:: ret DisplayPartyMenu:: - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a + ldh [hTilesetType], a call GBPalWhiteOutWithDelay3 call ClearSprites call PartyMenuInit @@ -186,10 +186,10 @@ DisplayPartyMenu:: jp HandlePartyMenuInput GoBackToPartyMenu:: - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a + ldh [hTilesetType], a call PartyMenuInit call RedrawPartyMenu jp HandlePartyMenuInput @@ -251,7 +251,7 @@ HandlePartyMenuInput:: and a jp nz, .swappingPokemon pop af - ld [hTilesetType], a + ldh [hTilesetType], a bit 1, b jr nz, .noPokemonChosen ld a, [wPartyCount] @@ -325,15 +325,15 @@ PrintStatusCondition:: ret PrintStatusConditionNotFainted:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(PrintStatusAilment) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call PrintStatusAilment ; print status condition pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -382,10 +382,10 @@ GetwMoves:: ; INPUT: ; [wd0b5] = pokemon ID GetMonHeader:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(BaseStats) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push bc push de @@ -440,7 +440,7 @@ GetMonHeader:: pop de pop bc pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/predef.asm b/home/predef.asm index 4f0c37d9..69aa7347 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -8,18 +8,18 @@ Predef:: ; A hack for LoadDestinationWarpPosition. ; See LoadTilesetHeader (predef $19). - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wPredefParentBank], a push af ld a, BANK(GetPredefPointer) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call GetPredefPointer ld a, [wPredefBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld de, .done @@ -28,7 +28,7 @@ Predef:: .done pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/print_num.asm b/home/print_num.asm index f7ea2174..e2628b1f 100644 --- a/home/print_num.asm +++ b/home/print_num.asm @@ -6,9 +6,9 @@ PrintNumber:: ; in bits 7 and 6 of b respectively. push bc xor a - ld [hPastLeadingZeros], a - ld [hNumToPrint], a - ld [hNumToPrint + 1], a + ldh [hPastLeadingZeros], a + ldh [hNumToPrint], a + ldh [hNumToPrint + 1], a ld a, b and $f cp 1 @@ -17,26 +17,26 @@ PrintNumber:: jr z, .word .long ld a, [de] - ld [hNumToPrint], a + ldh [hNumToPrint], a inc de ld a, [de] - ld [hNumToPrint + 1], a + ldh [hNumToPrint + 1], a inc de ld a, [de] - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a jr .start .word ld a, [de] - ld [hNumToPrint + 1], a + ldh [hNumToPrint + 1], a inc de ld a, [de] - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a jr .start .byte ld a, [de] - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a .start push de @@ -66,17 +66,17 @@ IF (\1) / $10000 ELSE xor a ENDC - ld [hPowerOf10 + 0], a + ldh [hPowerOf10 + 0], a IF (\1) / $100 ld a, \1 / $100 % $100 ELSE xor a ENDC - ld [hPowerOf10 + 1], a + ldh [hPowerOf10 + 1], a ld a, \1 / $1 % $100 - ld [hPowerOf10 + 2], a + ldh [hPowerOf10 + 2], a call .PrintDigit call .NextDigit @@ -90,7 +90,7 @@ ENDM .tens ld c, 0 - ld a, [hNumToPrint + 2] + ldh a, [hNumToPrint + 2] .mod cp 10 jr c, .ok @@ -100,9 +100,9 @@ ENDM .ok ld b, a - ld a, [hPastLeadingZeros] + ldh a, [hPastLeadingZeros] or c - ld [hPastLeadingZeros], a + ldh [hPastLeadingZeros], a jr nz, .past call .PrintLeadingZero jr .next @@ -127,74 +127,74 @@ ENDM ; Print the quotient, and keep the modulus. ld c, 0 .loop - ld a, [hPowerOf10] + ldh a, [hPowerOf10] ld b, a - ld a, [hNumToPrint] - ld [hSavedNumToPrint], a + ldh a, [hNumToPrint] + ldh [hSavedNumToPrint], a cp b jr c, .underflow0 sub b - ld [hNumToPrint], a - ld a, [hPowerOf10 + 1] + ldh [hNumToPrint], a + ldh a, [hPowerOf10 + 1] ld b, a - ld a, [hNumToPrint + 1] - ld [hSavedNumToPrint + 1], a + ldh a, [hNumToPrint + 1] + ldh [hSavedNumToPrint + 1], a cp b jr nc, .noborrow1 - ld a, [hNumToPrint] + ldh a, [hNumToPrint] or 0 jr z, .underflow1 dec a - ld [hNumToPrint], a - ld a, [hNumToPrint + 1] + ldh [hNumToPrint], a + ldh a, [hNumToPrint + 1] .noborrow1 sub b - ld [hNumToPrint + 1], a - ld a, [hPowerOf10 + 2] + ldh [hNumToPrint + 1], a + ldh a, [hPowerOf10 + 2] ld b, a - ld a, [hNumToPrint + 2] - ld [hSavedNumToPrint + 2], a + ldh a, [hNumToPrint + 2] + ldh [hSavedNumToPrint + 2], a cp b jr nc, .noborrow2 - ld a, [hNumToPrint + 1] + ldh a, [hNumToPrint + 1] and a jr nz, .borrowed - ld a, [hNumToPrint] + ldh a, [hNumToPrint] and a jr z, .underflow2 dec a - ld [hNumToPrint], a + ldh [hNumToPrint], a xor a .borrowed dec a - ld [hNumToPrint + 1], a - ld a, [hNumToPrint + 2] + ldh [hNumToPrint + 1], a + ldh a, [hNumToPrint + 2] .noborrow2 sub b - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a inc c jr .loop .underflow2 - ld a, [hSavedNumToPrint + 1] - ld [hNumToPrint + 1], a + ldh a, [hSavedNumToPrint + 1] + ldh [hNumToPrint + 1], a .underflow1 - ld a, [hSavedNumToPrint] - ld [hNumToPrint], a + ldh a, [hSavedNumToPrint] + ldh [hNumToPrint], a .underflow0 - ld a, [hPastLeadingZeros] + ldh a, [hPastLeadingZeros] or c jr z, .PrintLeadingZero ld a, "0" add c ld [hl], a - ld [hPastLeadingZeros], a + ldh [hPastLeadingZeros], a ret .PrintLeadingZero: @@ -211,7 +211,7 @@ ENDM jr nz, .inc bit BIT_LEFT_ALIGN, d jr z, .inc - ld a, [hPastLeadingZeros] + ldh a, [hPastLeadingZeros] and a ret z .inc diff --git a/home/serial.asm b/home/serial.asm index 6c412239..27ac97d4 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -3,46 +3,46 @@ Serial:: push bc push de push hl - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] inc a jr z, .connectionNotYetEstablished - ld a, [rSB] - ld [hSerialReceiveData], a - ld a, [hSerialSendData] - ld [rSB], a - ld a, [hSerialConnectionStatus] + ldh a, [rSB] + ldh [hSerialReceiveData], a + ldh a, [hSerialSendData] + ldh [rSB], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .done ; using external clock ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a jr .done .connectionNotYetEstablished - ld a, [rSB] - ld [hSerialReceiveData], a - ld [hSerialConnectionStatus], a + ldh a, [rSB] + ldh [hSerialReceiveData], a + ldh [hSerialConnectionStatus], a cp USING_INTERNAL_CLOCK jr z, .usingInternalClock ; using external clock xor a - ld [rSB], a + ldh [rSB], a ld a, $3 - ld [rDIV], a + ldh [rDIV], a .waitLoop - ld a, [rDIV] + ldh a, [rDIV] bit 7, a jr nz, .waitLoop ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a jr .done .usingInternalClock xor a - ld [rSB], a + ldh [rSB], a .done ld a, $1 - ld [hSerialReceivedNewData], a + ldh [hSerialReceivedNewData], a ld a, SERIAL_NO_DATA_BYTE - ld [hSerialSendData], a + ldh [hSerialSendData], a pop hl pop de pop bc @@ -54,10 +54,10 @@ Serial:: ; bc = length of data Serial_ExchangeBytes:: ld a, 1 - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a .loop ld a, [hl] - ld [hSerialSendData], a + ldh [hSerialSendData], a call Serial_ExchangeByte push bc ld b, a @@ -66,7 +66,7 @@ Serial_ExchangeBytes:: .waitLoop dec a jr nz, .waitLoop - ld a, [hSerialIgnoringInitialData] + ldh a, [hSerialIgnoringInitialData] and a ld a, b pop bc @@ -75,7 +75,7 @@ Serial_ExchangeBytes:: cp SERIAL_PREAMBLE_BYTE jr nz, .loop xor a - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a jr .loop .storeReceivedByte ld [de], a @@ -88,17 +88,17 @@ Serial_ExchangeBytes:: Serial_ExchangeByte:: xor a - ld [hSerialReceivedNewData], a - ld a, [hSerialConnectionStatus] + ldh [hSerialReceivedNewData], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .loop ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a .loop - ld a, [hSerialReceivedNewData] + ldh a, [hSerialReceivedNewData] and a jr nz, .ok - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr nz, .doNotIncrementUnknownCounter call IsUnknownCounterZero @@ -116,7 +116,7 @@ Serial_ExchangeByte:: jr nz, .loop jp SetUnknownCounterToFFFF .doNotIncrementUnknownCounter - ld a, [rIE] + ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp (1 << SERIAL) jr nz, .loop @@ -128,7 +128,7 @@ Serial_ExchangeByte:: dec a ld [wUnknownSerialCounter2 + 1], a jr nz, .loop - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .ok ld a, 255 @@ -137,8 +137,8 @@ Serial_ExchangeByte:: jr nz, .waitLoop .ok xor a - ld [hSerialReceivedNewData], a - ld a, [rIE] + ldh [hSerialReceivedNewData], a + ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) sub (1 << SERIAL) jr nz, .skipReloadingUnknownCounter2 @@ -146,7 +146,7 @@ Serial_ExchangeByte:: ld a, $50 ld [wUnknownSerialCounter2 + 1], a .skipReloadingUnknownCounter2 - ld a, [hSerialReceiveData] + ldh a, [hSerialReceiveData] cp SERIAL_NO_DATA_BYTE ret nz call IsUnknownCounterZero @@ -164,13 +164,13 @@ Serial_ExchangeByte:: call IsUnknownCounterZero jr z, SetUnknownCounterToFFFF .done - ld a, [rIE] + ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp (1 << SERIAL) ld a, SERIAL_NO_DATA_BYTE ret z ld a, [hl] - ld [hSerialSendData], a + ldh [hSerialSendData], a call DelayFrame jp Serial_ExchangeByte @@ -203,18 +203,18 @@ Serial_ExchangeLinkMenuSelection:: ld de, wLinkMenuSelectionReceiveBuffer ld c, 2 ; number of bytes to save ld a, 1 - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a .loop call DelayFrame ld a, [hl] - ld [hSerialSendData], a + ldh [hSerialSendData], a call Serial_ExchangeByte ld b, a inc hl - ld a, [hSerialIgnoringInitialData] + ldh a, [hSerialIgnoringInitialData] and a ld a, 0 - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a jr nz, .loop ld a, b ld [de], a @@ -273,20 +273,20 @@ Serial_ExchangeNybble:: call .doExchange ld a, [wSerialExchangeNybbleSendData] add $60 - ld [hSerialSendData], a - ld a, [hSerialConnectionStatus] + ldh [hSerialSendData], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .doExchange ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a .doExchange - ld a, [hSerialReceiveData] + ldh a, [hSerialReceiveData] ld [wSerialExchangeNybbleTempReceiveData], a and $f0 cp $60 ret nz xor a - ld [hSerialReceiveData], a + ldh [hSerialReceiveData], a ld a, [wSerialExchangeNybbleTempReceiveData] and $f ld [wSerialExchangeNybbleReceiveData], a @@ -294,19 +294,19 @@ Serial_ExchangeNybble:: Serial_SendZeroByte:: xor a - ld [hSerialSendData], a - ld a, [hSerialConnectionStatus] + ldh [hSerialSendData], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret nz ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a ret Serial_TryEstablishingExternallyClockedConnection:: ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK - ld [rSB], a + ldh [rSB], a xor a - ld [hSerialReceiveData], a + ldh [hSerialReceiveData], a ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a ret diff --git a/home/start_menu.asm b/home/start_menu.asm index 38333644..a692f007 100755 --- a/home/start_menu.asm +++ b/home/start_menu.asm @@ -1,6 +1,6 @@ DisplayStartMenu:: ld a, BANK(StartMenu_Pokedex) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, [wWalkBikeSurfState] ; walking/biking/surfing ld [wWalkBikeSurfStateCopy], a @@ -78,7 +78,7 @@ RedisplayStartMenu:: ; EXIT falls through to here CloseStartMenu:: call Joypad - ld a, [hJoyPressed] + ldh a, [hJoyPressed] bit 0, a ; was A button newly pressed? jr nz, CloseStartMenu call LoadTextBoxTilePatterns diff --git a/home/text.asm b/home/text.asm index 2047eaaa..5bbad00b 100644 --- a/home/text.asm +++ b/home/text.asm @@ -62,7 +62,7 @@ PlaceNextChar:: cp "<NEXT>" jr nz, .NotNext ld bc, 2 * SCREEN_WIDTH - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] bit 2, a jr z, .ok ld bc, SCREEN_WIDTH @@ -141,12 +141,12 @@ SixDotsChar:: print_name SixDotsCharText PlacePKMN:: print_name PlacePKMNText PlaceMoveTargetsName:: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor 1 jr PlaceMoveUsersName.place PlaceMoveUsersName:: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] .place: push de @@ -313,7 +313,7 @@ TextCommandProcessor:: push af set 1, a ld e, a - ld a, [hClearLetterPrintingDelayFlags] + ldh a, [hClearLetterPrintingDelayFlags] xor e ld [wLetterPrintingDelayFlags], a ld a, c @@ -489,7 +489,7 @@ TextCommand_PAUSE:: ; wait for button press or 30 frames push bc call Joypad - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and A_BUTTON | B_BUTTON jr nz, .done ld c, 30 ; half a second @@ -565,7 +565,7 @@ TextCommand_DOTS:: push de call Joypad pop de - ld a, [hJoyHeld] ; joypad state + ldh a, [hJoyHeld] ; joypad state and A_BUTTON | B_BUTTON jr nz, .next ; if so, skip the delay ld c, 10 @@ -590,7 +590,7 @@ TextCommand_WAIT_BUTTON:: TextCommand_FAR:: ; write text from a different bank (little endian) pop hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [hli] @@ -599,7 +599,7 @@ TextCommand_FAR:: ld d, a ld a, [hli] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push hl @@ -609,7 +609,7 @@ TextCommand_FAR:: pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp NextTextCommand diff --git a/home/text_script.asm b/home/text_script.asm index 2dd2dbde..89f4d286 100644 --- a/home/text_script.asm +++ b/home/text_script.asm @@ -1,7 +1,7 @@ ; this function is used to display sign messages, sprite dialog, etc. ; INPUT: [hSpriteIndexOrTextID] = sprite ID or text ID DisplayTextID:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af callba DisplayTextIDInit ; initialization ld hl, wTextPredefFlag @@ -12,13 +12,13 @@ DisplayTextID:: call SwitchToMapRomBank .skipSwitchToMapBank ld a, 30 ; half a second - ld [hFrameCounter], a ; used as joypad poll timer + ldh [hFrameCounter], a ; used as joypad poll timer ld hl, wMapTextPtr ld a, [hli] ld h, [hl] ld l, a ; hl = map text pointer ld d, $00 - ld a, [hSpriteIndexOrTextID] ; text ID + ldh a, [hSpriteIndexOrTextID] ; text ID ld [wSpriteIndex], a dict TEXT_START_MENU, DisplayStartMenu @@ -29,7 +29,7 @@ DisplayTextID:: ld a, [wNumSprites] ld e, a - ld a, [hSpriteIndexOrTextID] ; sprite ID + ldh a, [hSpriteIndexOrTextID] ; sprite ID cp e jr z, .spriteHandling jr nc, .skipSpriteHandling @@ -42,7 +42,7 @@ DisplayTextID:: pop bc pop de ld hl, wMapSpriteData ; NPC text entries - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] dec a add a add l @@ -97,7 +97,7 @@ AfterDisplayingTextID:: ; loop to hold the dialogue box open as long as the player keeps holding down the A button HoldTextDisplayOpen:: call Joypad - ld a, [hJoyHeld] + ldh a, [hJoyHeld] bit 0, a ; is the A button being pressed? jr nz, HoldTextDisplayOpen @@ -105,11 +105,11 @@ CloseTextDisplay:: ld a, [wCurMap] call SwitchToMapRomBank ld a, $90 - ld [hWY], a ; move the window off the screen + ldh [hWY], a ; move the window off the screen call DelayFrame call LoadGBPal xor a - ld [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank + ldh [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank ; loop to make sprites face the directions they originally faced before the dialogue ld hl, wSprite01StateData2 + 9 ; should be wSprite01StateData1FacingDirection? ld c, $0f @@ -123,7 +123,7 @@ CloseTextDisplay:: dec c jr nz, .restoreSpriteFacingDirectionLoop ld a, BANK(InitMapSprites) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns) ld hl, wFontLoaded @@ -133,7 +133,7 @@ CloseTextDisplay:: call z, LoadPlayerSpriteGraphics call LoadCurrentMapView pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp UpdateSprites @@ -146,14 +146,14 @@ DisplayPokemartDialogue:: call LoadItemList ld a, PRICEDITEMLISTMENU ld [wListMenuID], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(DisplayPokemartDialogue_) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call DisplayPokemartDialogue_ pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp AfterDisplayingTextID @@ -180,19 +180,19 @@ LoadItemList:: DisplayPokemonCenterDialogue:: ; zeroing these doesn't appear to serve any purpose xor a - ld [hItemPrice], a - ld [hItemPrice + 1], a - ld [hItemPrice + 2], a + ldh [hItemPrice], a + ldh [hItemPrice + 1], a + ldh [hItemPrice + 2], a inc hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(DisplayPokemonCenterDialogue_) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call DisplayPokemonCenterDialogue_ pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp AfterDisplayingTextID diff --git a/home/trainers.asm b/home/trainers.asm index 22601db8..66108af6 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -144,7 +144,7 @@ CheckFightingMapTrainers:: ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a call TrainerWalkUpToPlayer_Bank0 ld hl, wCurMapScript inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle) @@ -157,7 +157,7 @@ DisplayEnemyTrainerTextAndStartBattle:: ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite ld [wJoyIgnore], a ld a, [wSpriteIndex] - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ; fall through @@ -211,9 +211,9 @@ EndTrainerBattle:: ResetButtonPressedAndMapScript:: xor a ld [wJoyIgnore], a - ld [hJoyHeld], a - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ld [wCurMapScript], a ; reset battle status ret @@ -302,7 +302,7 @@ CheckForEngagingTrainers:: ; hl = text if the player wins ; de = text if the player loses SaveEndBattleTextPointers:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wEndBattleTextRomBank], a ld a, h ld [wEndBattleWinTextPointer], a @@ -337,10 +337,10 @@ PrintEndBattleText:: res 7, [hl] pop hl ret z - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [wEndBattleTextRomBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push hl callba SaveTrainerName @@ -348,7 +348,7 @@ PrintEndBattleText:: call PrintText pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a callba FreezeEnemyTrainerSprite jp WaitForSoundToFinish diff --git a/home/uncompress.asm b/home/uncompress.asm index cfc39f0f..69d94cb0 100644 --- a/home/uncompress.asm +++ b/home/uncompress.asm @@ -2,10 +2,10 @@ ; bank is given in a, sprite input stream is pointed to in wSpriteInputPtr UncompressSpriteData:: ld b, a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, SRAM_ENABLE ld [MBC1SRamEnable], a @@ -13,7 +13,7 @@ UncompressSpriteData:: ld [MBC1SRamBank], a call _UncompressSpriteData pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/vblank.asm b/home/vblank.asm index 78f5f69d..06b45b82 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -5,19 +5,19 @@ VBlank:: push de push hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wVBlankSavedROMBank], a - ld a, [hSCX] - ld [rSCX], a - ld a, [hSCY] - ld [rSCY], a + ldh a, [hSCX] + ldh [rSCX], a + ldh a, [hSCY] + ldh [rSCY], a ld a, [wDisableVBlankWYUpdate] and a jr nz, .ok - ld a, [hWY] - ld [rWY], a + ldh a, [hWY] + ldh [rWY], a .ok call AutoBgMapTransfer @@ -28,7 +28,7 @@ VBlank:: call UpdateMovingBgTiles call hDMARoutine ld a, BANK(PrepareOAMData) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call PrepareOAMData @@ -36,24 +36,24 @@ VBlank:: call Random - ld a, [hVBlankOccurred] + ldh a, [hVBlankOccurred] and a jr z, .skipZeroing xor a - ld [hVBlankOccurred], a + ldh [hVBlankOccurred], a .skipZeroing - ld a, [hFrameCounter] + ldh a, [hFrameCounter] and a jr z, .skipDec dec a - ld [hFrameCounter], a + ldh [hFrameCounter], a .skipDec call FadeOutAudio ld a, [wAudioROMBank] ; music ROM bank - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a cp BANK(Audio1_UpdateMusic) @@ -74,12 +74,12 @@ VBlank:: callba TrackPlayTime ; keep track of time played - ld a, [hDisableJoypadPolling] + ldh a, [hDisableJoypadPolling] and a call z, ReadJoypad ld a, [wVBlankSavedROMBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop hl @@ -96,10 +96,10 @@ DelayFrame:: NOT_VBLANKED EQU 1 ld a, NOT_VBLANKED - ld [hVBlankOccurred], a + ldh [hVBlankOccurred], a .halt halt - ld a, [hVBlankOccurred] + ldh a, [hVBlankOccurred] and a jr nz, .halt ret diff --git a/home/vcopy.asm b/home/vcopy.asm index e2325d5c..d2340b7c 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -40,19 +40,19 @@ ClearBgMap:: ; However, this function is also called repeatedly to redraw the whole screen ; when necessary. It is also used in trade animation and elevator code. RedrawRowOrColumn:: - ld a, [hRedrawRowOrColumnMode] + ldh a, [hRedrawRowOrColumnMode] and a ret z ld b, a xor a - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a dec b jr nz, .redrawRow .redrawColumn ld hl, wRedrawRowOrColumnSrcTiles - ld a, [hRedrawRowOrColumnDest] + ldh a, [hRedrawRowOrColumnDest] ld e, a - ld a, [hRedrawRowOrColumnDest + 1] + ldh a, [hRedrawRowOrColumnDest + 1] ld d, a ld c, SCREEN_HEIGHT .loop1 @@ -75,13 +75,13 @@ RedrawRowOrColumn:: dec c jr nz, .loop1 xor a - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret .redrawRow ld hl, wRedrawRowOrColumnSrcTiles - ld a, [hRedrawRowOrColumnDest] + ldh a, [hRedrawRowOrColumnDest] ld e, a - ld a, [hRedrawRowOrColumnDest + 1] + ldh a, [hRedrawRowOrColumnDest + 1] ld d, a push de call .DrawHalf ; draw upper half @@ -120,15 +120,15 @@ RedrawRowOrColumn:: ; the above function, RedrawRowOrColumn, is used when walking to ; improve efficiency. AutoBgMapTransfer:: - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a ; save stack pinter - ld a, [hAutoBGTransferPortion] + ldh [hSPTemp + 1], a ; save stack pinter + ldh a, [hAutoBGTransferPortion] and a jr z, .transferTopThird dec a @@ -136,9 +136,9 @@ AutoBgMapTransfer:: .transferBottomThird coord hl, 0, 12 ld sp, hl - ld a, [hAutoBGTransferDest + 1] + ldh a, [hAutoBGTransferDest + 1] ld h, a - ld a, [hAutoBGTransferDest] + ldh a, [hAutoBGTransferDest] ld l, a ld de, (12 * 32) add hl, de @@ -147,24 +147,24 @@ AutoBgMapTransfer:: .transferTopThird coord hl, 0, 0 ld sp, hl - ld a, [hAutoBGTransferDest + 1] + ldh a, [hAutoBGTransferDest + 1] ld h, a - ld a, [hAutoBGTransferDest] + ldh a, [hAutoBGTransferDest] ld l, a ld a, TRANSFERMIDDLE jr .doTransfer .transferMiddleThird coord hl, 0, 6 ld sp, hl - ld a, [hAutoBGTransferDest + 1] + ldh a, [hAutoBGTransferDest + 1] ld h, a - ld a, [hAutoBGTransferDest] + ldh a, [hAutoBGTransferDest] ld l, a ld de, (6 * 32) add hl, de ld a, TRANSFERBOTTOM .doTransfer - ld [hAutoBGTransferPortion], a ; store next portion + ldh [hAutoBGTransferPortion], a ; store next portion ld b, 6 TransferBgRows:: @@ -192,9 +192,9 @@ TransferBgRows:: dec b jr nz, TransferBgRows - ld a, [hSPTemp] + ldh a, [hSPTemp] ld h, a - ld a, [hSPTemp + 1] + ldh a, [hSPTemp + 1] ld l, a ld sp, hl ret @@ -202,27 +202,27 @@ TransferBgRows:: ; Copies [hVBlankCopyBGNumRows] rows from hVBlankCopyBGSource to hVBlankCopyBGDest. ; If hVBlankCopyBGSource is XX00, the transfer is disabled. VBlankCopyBgMap:: - ld a, [hVBlankCopyBGSource] ; doubles as enabling byte + ldh a, [hVBlankCopyBGSource] ; doubles as enabling byte and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a ; save stack pointer - ld a, [hVBlankCopyBGSource] + ldh [hSPTemp + 1], a ; save stack pointer + ldh a, [hVBlankCopyBGSource] ld l, a - ld a, [hVBlankCopyBGSource + 1] + ldh a, [hVBlankCopyBGSource + 1] ld h, a ld sp, hl - ld a, [hVBlankCopyBGDest] + ldh a, [hVBlankCopyBGDest] ld l, a - ld a, [hVBlankCopyBGDest + 1] + ldh a, [hVBlankCopyBGDest + 1] ld h, a - ld a, [hVBlankCopyBGNumRows] + ldh a, [hVBlankCopyBGNumRows] ld b, a xor a - ld [hVBlankCopyBGSource], a ; disable transfer so it doesn't continue next V-blank + ldh [hVBlankCopyBGSource], a ; disable transfer so it doesn't continue next V-blank jr TransferBgRows @@ -234,31 +234,31 @@ VBlankCopyDouble:: ; The process is straightforward: ; copy each byte twice. - ld a, [hVBlankCopyDoubleSize] + ldh a, [hVBlankCopyDoubleSize] and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a + ldh [hSPTemp + 1], a - ld a, [hVBlankCopyDoubleSource] + ldh a, [hVBlankCopyDoubleSource] ld l, a - ld a, [hVBlankCopyDoubleSource + 1] + ldh a, [hVBlankCopyDoubleSource + 1] ld h, a ld sp, hl - ld a, [hVBlankCopyDoubleDest] + ldh a, [hVBlankCopyDoubleDest] ld l, a - ld a, [hVBlankCopyDoubleDest + 1] + ldh a, [hVBlankCopyDoubleDest + 1] ld h, a - ld a, [hVBlankCopyDoubleSize] + ldh a, [hVBlankCopyDoubleSize] ld b, a xor a ; transferred - ld [hVBlankCopyDoubleSize], a + ldh [hVBlankCopyDoubleSize], a .loop REPT 3 @@ -286,19 +286,19 @@ VBlankCopyDouble:: jr nz, .loop ld a, l - ld [hVBlankCopyDoubleDest], a + ldh [hVBlankCopyDoubleDest], a ld a, h - ld [hVBlankCopyDoubleDest + 1], a + ldh [hVBlankCopyDoubleDest + 1], a ld hl, sp + 0 ld a, l - ld [hVBlankCopyDoubleSource], a + ldh [hVBlankCopyDoubleSource], a ld a, h - ld [hVBlankCopyDoubleSource + 1], a + ldh [hVBlankCopyDoubleSource + 1], a - ld a, [hSPTemp] + ldh a, [hSPTemp] ld h, a - ld a, [hSPTemp + 1] + ldh a, [hSPTemp + 1] ld l, a ld sp, hl @@ -312,31 +312,31 @@ VBlankCopy:: ; Source and destination addresses are updated, ; so transfer can continue in subsequent calls. - ld a, [hVBlankCopySize] + ldh a, [hVBlankCopySize] and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a + ldh [hSPTemp + 1], a - ld a, [hVBlankCopySource] + ldh a, [hVBlankCopySource] ld l, a - ld a, [hVBlankCopySource + 1] + ldh a, [hVBlankCopySource + 1] ld h, a ld sp, hl - ld a, [hVBlankCopyDest] + ldh a, [hVBlankCopyDest] ld l, a - ld a, [hVBlankCopyDest + 1] + ldh a, [hVBlankCopyDest + 1] ld h, a - ld a, [hVBlankCopySize] + ldh a, [hVBlankCopySize] ld b, a xor a ; transferred - ld [hVBlankCopySize], a + ldh [hVBlankCopySize], a .loop REPT 7 @@ -356,19 +356,19 @@ VBlankCopy:: jr nz, .loop ld a, l - ld [hVBlankCopyDest], a + ldh [hVBlankCopyDest], a ld a, h - ld [hVBlankCopyDest + 1], a + ldh [hVBlankCopyDest + 1], a ld hl, sp + 0 ld a, l - ld [hVBlankCopySource], a + ldh [hVBlankCopySource], a ld a, h - ld [hVBlankCopySource + 1], a + ldh [hVBlankCopySource + 1], a - ld a, [hSPTemp] + ldh a, [hSPTemp] ld h, a - ld a, [hSPTemp + 1] + ldh a, [hSPTemp + 1] ld l, a ld sp, hl @@ -379,13 +379,13 @@ UpdateMovingBgTiles:: ; Animate water and flower ; tiles in the overworld. - ld a, [hTilesetType] + ldh a, [hTilesetType] and a ret z ; no animations if indoors (or if a menu set this to 0) - ld a, [hMovingBGTilesCounter1] + ldh a, [hMovingBGTilesCounter1] inc a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a cp 20 ret c cp 21 @@ -417,17 +417,17 @@ UpdateMovingBgTiles:: dec c jr nz, .left .done - ld a, [hTilesetType] + ldh a, [hTilesetType] rrca ret nc ; if in a cave, no flower animations xor a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a ret .flower xor a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a ld a, [wMovingBGTilesCounter2] and 3 |