Use HIGH() and LOW()

This commit is contained in:
Rangi 2020-07-07 11:10:29 -04:00
parent bbc257476f
commit 45ed05decf
22 changed files with 89 additions and 87 deletions

View file

@ -25,10 +25,10 @@
const Ch8 ; 7 const Ch8 ; 7
; HW sound channel register base addresses ; HW sound channel register base addresses
HW_CH1_BASE EQU (rNR10 % $100) HW_CH1_BASE EQU LOW(rNR10)
HW_CH2_BASE EQU ((rNR21 % $100) - 1) HW_CH2_BASE EQU LOW(rNR21) - 1
HW_CH3_BASE EQU (rNR30 % $100) HW_CH3_BASE EQU LOW(rNR30)
HW_CH4_BASE EQU ((rNR41 % $100) - 1) HW_CH4_BASE EQU LOW(rNR41) - 1
; HW sound channel enable bit masks ; HW sound channel enable bit masks
HW_CH1_ENABLE_MASK EQU %00010001 HW_CH1_ENABLE_MASK EQU %00010001

View file

@ -35,6 +35,8 @@ BRN EQU 4
FRZ EQU 5 FRZ EQU 5
PAR EQU 6 PAR EQU 6
MAX_STAT_VALUE EQU 999
; volatile statuses 1 ; volatile statuses 1
STORING_ENERGY EQU 0 ; Bide STORING_ENERGY EQU 0 ; Bide
THRASHING_ABOUT EQU 1 ; e.g. Thrash THRASHING_ABOUT EQU 1 ; e.g. Thrash

View file

@ -4182,8 +4182,8 @@ GetDamageVarsForPlayerAttack:
; if the enemy has used Light Screen, double the enemy's special ; if the enemy has used Light Screen, double the enemy's special
sla c sla c
rl b rl b
; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if ; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling
; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen ; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck .specialAttackCritCheck
ld hl, wBattleMonSpecial ld hl, wBattleMonSpecial
ld a, [wCriticalHitOrOHKO] ld a, [wCriticalHitOrOHKO]
@ -4295,8 +4295,8 @@ GetDamageVarsForEnemyAttack:
; if the player has used Light Screen, double the player's special ; if the player has used Light Screen, double the player's special
sla c sla c
rl b rl b
; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if ; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling
; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen ; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck .specialAttackCritCheck
ld hl, wEnemyMonSpecial ld hl, wEnemyMonSpecial
ld a, [wCriticalHitOrOHKO] ld a, [wCriticalHitOrOHKO]
@ -4508,14 +4508,14 @@ CalculateDamage:
jr nz, .cap jr nz, .cap
ldh a, [hQuotient + 2] ldh a, [hQuotient + 2]
cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_2 jr c, .dont_cap_2
cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1 cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1
jr nc, .cap jr nc, .cap
ldh a, [hQuotient + 3] ldh a, [hQuotient + 3]
cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100 cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr nc, .cap jr nc, .cap
.dont_cap_2 .dont_cap_2
@ -4533,21 +4533,21 @@ CalculateDamage:
jr c, .cap jr c, .cap
ld a, [hl] ld a, [hl]
cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_3 jr c, .dont_cap_3
cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1 cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1
jr nc, .cap jr nc, .cap
inc hl inc hl
ld a, [hld] ld a, [hld]
cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100 cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_3 jr c, .dont_cap_3
.cap .cap
ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) / $100 ld a, HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
ld [hli], a ld [hli], a
ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) % $100 ld a, LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
ld [hld], a ld [hld], a
.dont_cap_3 .dont_cap_3
@ -6526,14 +6526,14 @@ CalculateModifiedStat:
call Divide call Divide
pop hl pop hl
ldh a, [hDividend + 3] ldh a, [hDividend + 3]
sub 999 % $100 sub LOW(MAX_STAT_VALUE)
ldh a, [hDividend + 2] ldh a, [hDividend + 2]
sbc 999 / $100 sbc HIGH(MAX_STAT_VALUE)
jp c, .storeNewStatValue jp c, .storeNewStatValue
; cap the stat at 999 ; cap the stat at MAX_STAT_VALUE (999)
ld a, 999 / $100 ld a, HIGH(MAX_STAT_VALUE)
ldh [hDividend + 2], a ldh [hDividend + 2], a
ld a, 999 % $100 ld a, LOW(MAX_STAT_VALUE)
ldh [hDividend + 3], a ldh [hDividend + 3], a
.storeNewStatValue .storeNewStatValue
ldh a, [hDividend + 2] ldh a, [hDividend + 2]
@ -6573,7 +6573,7 @@ ApplyBadgeStatBoosts:
ret ret
; multiply stat at hl by 1.125 ; multiply stat at hl by 1.125
; cap stat at 999 ; cap stat at MAX_STAT_VALUE
.applyBoostToStat .applyBoostToStat
ld a, [hli] ld a, [hli]
ld d, a ld d, a
@ -6591,13 +6591,13 @@ ApplyBadgeStatBoosts:
adc d adc d
ld [hli], a ld [hli], a
ld a, [hld] ld a, [hld]
sub 999 % $100 sub LOW(MAX_STAT_VALUE)
ld a, [hl] ld a, [hl]
sbc 999 / $100 sbc HIGH(MAX_STAT_VALUE)
ret c ret c
ld a, 999 / $100 ld a, HIGH(MAX_STAT_VALUE)
ld [hli], a ld [hli], a
ld a, 999 % $100 ld a, LOW(MAX_STAT_VALUE)
ld [hld], a ld [hld], a
ret ret

View file

@ -399,11 +399,12 @@ StatModifierUpEffect:
inc d ; de = unmodified (original) stat inc d ; de = unmodified (original) stat
.checkIf999 .checkIf999
pop bc pop bc
; check if stat is already 999
ld a, [hld] ld a, [hld]
sub 999 % $100 ; check if stat is already 999 sub LOW(MAX_STAT_VALUE)
jr nz, .recalculateStat jr nz, .recalculateStat
ld a, [hl] ld a, [hl]
sbc 999 / $100 sbc HIGH(MAX_STAT_VALUE)
jp z, RestoreOriginalStatModifier jp z, RestoreOriginalStatModifier
.recalculateStat ; recalculate affected stat .recalculateStat ; recalculate affected stat
; paralysis and burn penalties, as well as badge boosts are ignored ; paralysis and burn penalties, as well as badge boosts are ignored
@ -431,15 +432,15 @@ StatModifierUpEffect:
ld b, $4 ld b, $4
call Divide call Divide
pop hl pop hl
; cap at 999 ; cap at MAX_STAT_VALUE (999)
ldh a, [hProduct + 3] ldh a, [hProduct + 3]
sub 999 % $100 sub LOW(MAX_STAT_VALUE)
ldh a, [hProduct + 2] ldh a, [hProduct + 2]
sbc 999 / $100 sbc HIGH(MAX_STAT_VALUE)
jp c, UpdateStat jp c, UpdateStat
ld a, 999 / $100 ld a, HIGH(MAX_STAT_VALUE)
ldh [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, 999 % $100 ld a, LOW(MAX_STAT_VALUE)
ldh [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
UpdateStat: UpdateStat:

View file

@ -236,7 +236,7 @@ WriteMonPartySpriteOAM:
; make a copy at wMonPartySpritesSavedOAM. ; make a copy at wMonPartySpritesSavedOAM.
push af push af
ld c, $10 ld c, $10
ld h, wOAMBuffer / $100 ld h, HIGH(wOAMBuffer)
ldh a, [hPartyMonIndex] ldh a, [hPartyMonIndex]
swap a swap a
ld l, a ld l, a

View file

@ -1,7 +1,7 @@
WriteDMACodeToHRAM:: WriteDMACodeToHRAM::
; Since no other memory is available during OAM DMA, ; Since no other memory is available during OAM DMA,
; DMARoutine is copied to HRAM and executed there. ; DMARoutine is copied to HRAM and executed there.
ld c, hDMARoutine % $100 ld c, LOW(hDMARoutine)
ld b, DMARoutineEnd - DMARoutine ld b, DMARoutineEnd - DMARoutine
ld hl, DMARoutine ld hl, DMARoutine
.copy .copy
@ -14,7 +14,7 @@ WriteDMACodeToHRAM::
DMARoutine: DMARoutine:
; initiate DMA ; initiate DMA
ld a, wOAMBuffer / $100 ld a, HIGH(wOAMBuffer)
ldh [rDMA], a ldh [rDMA], a
; wait for DMA to finish ; wait for DMA to finish

View file

@ -18,7 +18,7 @@ PrepareOAMData::
.spriteLoop .spriteLoop
ldh [hSpriteOffset2], a ldh [hSpriteOffset2], a
ld d, wSpriteStateData1 / $100 ld d, HIGH(wSpriteStateData1)
ldh a, [hSpriteOffset2] ldh a, [hSpriteOffset2]
ld e, a ld e, a
ld a, [de] ; c1x0 ld a, [de] ; c1x0
@ -79,7 +79,7 @@ PrepareOAMData::
ldh a, [hOAMBufferOffset] ldh a, [hOAMBufferOffset]
ld e, a ld e, a
ld d, wOAMBuffer / $100 ld d, HIGH(wOAMBuffer)
.tileLoop .tileLoop
ldh a, [hSpriteScreenY] ; temp for sprite Y position ldh a, [hSpriteScreenY] ; temp for sprite Y position
@ -141,13 +141,13 @@ PrepareOAMData::
.nextSprite .nextSprite
ldh a, [hSpriteOffset2] ldh a, [hSpriteOffset2]
add $10 add $10
cp $100 % $100 cp LOW($100)
jp nz, .spriteLoop jp nz, .spriteLoop
; Clear unused OAM. ; Clear unused OAM.
ldh a, [hOAMBufferOffset] ldh a, [hOAMBufferOffset]
ld l, a ld l, a
ld h, wOAMBuffer / $100 ld h, HIGH(wOAMBuffer)
ld de, $4 ld de, $4
ld b, $a0 ld b, $a0
ld a, [wd736] ld a, [wd736]

View file

@ -12,10 +12,10 @@ AddItemToInventory_::
push hl push hl
push hl push hl
ld d, PC_ITEM_CAPACITY ; how many items the PC can hold ld d, PC_ITEM_CAPACITY ; how many items the PC can hold
ld a, wNumBagItems & $FF ld a, LOW(wNumBagItems)
cp l cp l
jr nz, .checkIfInventoryFull jr nz, .checkIfInventoryFull
ld a, wNumBagItems >> 8 ld a, HIGH(wNumBagItems)
cp h cp h
jr nz, .checkIfInventoryFull jr nz, .checkIfInventoryFull
; if the destination is the bag ; if the destination is the bag

View file

@ -255,9 +255,9 @@ CableClub_DoBattleOrTradeAgain:
ld hl, wEnemyMons + (SERIAL_PREAMBLE_BYTE - 1) ld hl, wEnemyMons + (SERIAL_PREAMBLE_BYTE - 1)
dec c dec c
jr nz, .unpatchEnemyMonsLoop jr nz, .unpatchEnemyMonsLoop
ld a, wEnemyMonOT % $100 ld a, LOW(wEnemyMonOT)
ld [wUnusedCF8D], a ld [wUnusedCF8D], a
ld a, wEnemyMonOT / $100 ld a, HIGH(wEnemyMonOT)
ld [wUnusedCF8D + 1], a ld [wUnusedCF8D + 1], a
xor a xor a
ld [wTradeCenterPointerTableIndex], a ld [wTradeCenterPointerTableIndex], a

View file

@ -23,9 +23,9 @@ InitPlayerData2:
START_MONEY EQU $3000 START_MONEY EQU $3000
ld hl, wPlayerMoney + 1 ld hl, wPlayerMoney + 1
ld a, START_MONEY / $100 ld a, HIGH(START_MONEY)
ld [hld], a ld [hld], a
xor a xor a ; LOW(START_MONEY)
ld [hli], a ld [hli], a
inc hl inc hl
ld [hl], a ld [hl], a

View file

@ -126,13 +126,13 @@ ENDC
ld [wTitleMonSpecies], a ld [wTitleMonSpecies], a
call LoadTitleMonSprite call LoadTitleMonSprite
ld a, (vBGMap0 + $300) / $100 ld a, HIGH(vBGMap0 + $300)
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
ld a, $40 ld a, $40
ldh [hWY], a ldh [hWY], a
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
ld a, vBGMap0 / $100 ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
ld b, SET_PAL_TITLE_SCREEN ld b, SET_PAL_TITLE_SCREEN
call RunPaletteCommand call RunPaletteCommand
@ -205,7 +205,7 @@ ENDC
and a and a
jr nz, .scrollTitleScreenGameVersionLoop jr nz, .scrollTitleScreenGameVersionLoop
ld a, vBGMap1 / $100 ld a, HIGH(vBGMap1)
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
call PrintGameVersionOnTitleScreen call PrintGameVersionOnTitleScreen
@ -241,9 +241,9 @@ ENDC
inc a inc a
ldh [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
ld a, vBGMap0 / $100 ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
ld a, vBGMap1 / $100 ld a, HIGH(vBGMap1)
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
call Delay3 call Delay3
call LoadGBPal call LoadGBPal
@ -258,7 +258,7 @@ ENDC
farjp DoClearSaveDialogue farjp DoClearSaveDialogue
TitleScreenPickNewMon: TitleScreenPickNewMon:
ld a, vBGMap0 / $100 ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
.loop .loop

View file

@ -237,7 +237,7 @@ Trade_ShowPlayerMon:
ld c, 10 ld c, 10
call TextBoxBorder call TextBoxBorder
call Trade_PrintPlayerMonInfoText call Trade_PrintPlayerMonInfoText
ld b, vBGMap0 / $100 ld b, HIGH(vBGMap0)
call CopyScreenTileBufferToVRAM call CopyScreenTileBufferToVRAM
call ClearScreen call ClearScreen
ld a, [wTradedPlayerMonSpecies] ld a, [wTradedPlayerMonSpecies]
@ -266,7 +266,7 @@ Trade_ShowPlayerMon:
Trade_DrawOpenEndOfLinkCable: Trade_DrawOpenEndOfLinkCable:
call Trade_ClearTileMap call Trade_ClearTileMap
ld b, vBGMap0 / $100 ld b, HIGH(vBGMap0)
call CopyScreenTileBufferToVRAM call CopyScreenTileBufferToVRAM
ld b, SET_PAL_GENERIC ld b, SET_PAL_GENERIC
call RunPaletteCommand call RunPaletteCommand

View file

@ -56,7 +56,7 @@ ShakeElevatorRedrawRow:
add hl, de add hl, de
ld a, h ld a, h
and $3 and $3
or vBGMap0 / $100 or HIGH(vBGMap0)
ld d, a ld d, a
ld a, l ld a, l
pop hl pop hl

View file

@ -23,7 +23,7 @@ UpdatePlayerSprite:
ret ret
.lowerLeftTileIsMapTile .lowerLeftTileIsMapTile
call DetectCollisionBetweenSprites call DetectCollisionBetweenSprites
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ld a, [wWalkCounter] ld a, [wWalkCounter]
and a and a
jr nz, .moving jr nz, .moving
@ -395,7 +395,7 @@ UpdateSpriteMovementDelay:
ld l, a ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move) ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
notYetMoving: notYetMoving:
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1 add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1
ld l, a ld l, a
@ -450,7 +450,7 @@ InitializeSpriteStatus:
; calculates the sprite's screen position form its map position and the player position ; calculates the sprite's screen position form its map position and the player position
InitializeSpriteScreenPosition: InitializeSpriteScreenPosition:
ld h, wSpriteStateData2 / $100 ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MapY - wSpritePlayerStateData2 add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
ld l, a ld l, a
@ -478,7 +478,7 @@ CheckSpriteAvailability:
ldh a, [hIsHiddenMissableObject] ldh a, [hIsHiddenMissableObject]
and a and a
jp nz, .spriteInvisible jp nz, .spriteInvisible
ld h, wSpriteStateData2 / $100 ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2 add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
ld l, a ld l, a
@ -526,7 +526,7 @@ CheckSpriteAvailability:
cp d cp d
jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile) jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile)
.spriteInvisible .spriteInvisible
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1 add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld l, a ld l, a
@ -580,7 +580,7 @@ UpdateSpriteImage:
; e: X movement delta (-1, 0 or 1) ; e: X movement delta (-1, 0 or 1)
; set carry on failure, clears carry on success ; set carry on failure, clears carry on success
CanWalkOntoTile: CanWalkOntoTile:
ld h, wSpriteStateData2 / $100 ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2 add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
ld l, a ld l, a
@ -608,7 +608,7 @@ CanWalkOntoTile:
ld a, [hl] ; $c2x6 (movement byte 1) ld a, [hl] ; $c2x6 (movement byte 1)
inc a inc a
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is) jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a ld l, a
@ -627,14 +627,14 @@ CanWalkOntoTile:
call DetectCollisionBetweenSprites call DetectCollisionBetweenSprites
pop bc pop bc
pop de pop de
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $c add $c
ld l, a ld l, a
ld a, [hl] ; c1xc (directions in which sprite collision would occur) ld a, [hl] ; c1xc (directions in which sprite collision would occur)
and b ; check against chosen direction (1,2,4 or 8) and b ; check against chosen direction (1,2,4 or 8)
jr nz, .impassable ; collision between sprites, don't go there jr nz, .impassable ; collision between sprites, don't go there
ld h, wSpriteStateData2 / $100 ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2 add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2
ld l, a ld l, a
@ -665,7 +665,7 @@ CanWalkOntoTile:
and a ; clear carry (marking success) and a ; clear carry (marking success)
ret ret
.impassable .impassable
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
@ -691,7 +691,7 @@ CanWalkOntoTile:
; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to ; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to
; hl: output pointer ; hl: output pointer
GetTileSpriteStandsOn: GetTileSpriteStandsOn:
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a ld l, a

View file

@ -53,9 +53,9 @@ UpdateNonPlayerSprite:
DetectCollisionBetweenSprites: DetectCollisionBetweenSprites:
nop nop
ld h, wSpriteStateData1 / $100 ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpriteStateData1 % $100 add LOW(wSpriteStateData1)
ld l, a ld l, a
ld a, [hl] ; a = [$c1i0] (picture) (0 if slot is unused) ld a, [hl] ; a = [$c1i0] (picture) (0 if slot is unused)

View file

@ -294,7 +294,7 @@ SlotMachine_StopWheel1Early:
; Stop early if the middle symbol is not a cherry. ; Stop early if the middle symbol is not a cherry.
inc hl inc hl
ld a, [hl] ld a, [hl]
cp SLOTSCHERRY >> 8 cp HIGH(SLOTSCHERRY)
jr nz, .stopWheel jr nz, .stopWheel
ret ret
; It looks like this was intended to make the wheel stop when a 7 symbol was ; It looks like this was intended to make the wheel stop when a 7 symbol was
@ -303,7 +303,7 @@ SlotMachine_StopWheel1Early:
ld c, $3 ld c, $3
.loop .loop
ld a, [hli] ld a, [hli]
cp SLOTS7 >> 8 cp HIGH(SLOTS7)
jr c, .stopWheel ; condition never true jr c, .stopWheel ; condition never true
dec c dec c
jr nz, .loop jr nz, .loop
@ -330,7 +330,7 @@ SlotMachine_StopWheel2Early:
.sevenAndBarMode .sevenAndBarMode
call SlotMachine_FindWheel1Wheel2Matches call SlotMachine_FindWheel1Wheel2Matches
ld a, [de] ld a, [de]
cp (SLOTSBAR >> 8) + 1 cp HIGH(SLOTSBAR) + 1
ret nc ret nc
.stopWheel .stopWheel
xor a xor a
@ -427,7 +427,7 @@ SlotMachine_CheckForMatches:
jr nz, .acceptMatch jr nz, .acceptMatch
; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel ; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel
ld a, [hl] ld a, [hl]
cp (SLOTSBAR >> 8) + 1 cp HIGH(SLOTSBAR) + 1
jr c, .rollWheel3DownByOneSymbol jr c, .rollWheel3DownByOneSymbol
.acceptMatch .acceptMatch
ld a, [hl] ld a, [hl]
@ -702,7 +702,7 @@ SlotMachine_PayCoinsToPlayer:
.skip1 .skip1
ld [wAnimCounter], a ld [wAnimCounter], a
ld a, [wSlotMachineWinningSymbol] ld a, [wSlotMachineWinningSymbol]
cp (SLOTSBAR >> 8) + 1 cp HIGH(SLOTSBAR) + 1
ld c, 8 ld c, 8
jr nc, .skip2 jr nc, .skip2
srl c ; c = 4 (make the the coins transfer faster if the symbol was 7 or bar) srl c ; c = 4 (make the the coins transfer faster if the symbol was 7 or bar)

View file

@ -1242,7 +1242,7 @@ StringCmp::
; c = X coordinate of upper left corner of sprite ; c = X coordinate of upper left corner of sprite
; de = base address of 4 tile number and attribute pairs ; de = base address of 4 tile number and attribute pairs
WriteOAMBlock:: WriteOAMBlock::
ld h, wOAMBuffer / $100 ld h, HIGH(wOAMBuffer)
swap a ; multiply by 16 swap a ; multiply by 16
ld l, a ld l, a
call .writeOneEntry ; upper left call .writeOneEntry ; upper left

View file

@ -82,9 +82,9 @@ rLCDC_DEFAULT EQU %11100011
ld a, CONNECTION_NOT_ESTABLISHED ld a, CONNECTION_NOT_ESTABLISHED
ldh [hSerialConnectionStatus], a ldh [hSerialConnectionStatus], a
ld h, vBGMap0 / $100 ld h, HIGH(vBGMap0)
call ClearBgMap call ClearBgMap
ld h, vBGMap1 / $100 ld h, HIGH(vBGMap1)
call ClearBgMap call ClearBgMap
ld a, rLCDC_DEFAULT ld a, rLCDC_DEFAULT

View file

@ -197,17 +197,17 @@ CalcStat::
ldh [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 .noCarry4
ldh a, [hMultiplicand+1] ; check for overflow (>999) ldh a, [hMultiplicand+1] ; check for overflow (>999)
cp 999 / $100 + 1 cp HIGH(MAX_STAT_VALUE) + 1
jr nc, .overflow jr nc, .overflow
cp 999 / $100 cp HIGH(MAX_STAT_VALUE)
jr c, .noOverflow jr c, .noOverflow
ldh a, [hMultiplicand+2] ldh a, [hMultiplicand+2]
cp 999 % $100 + 1 cp LOW(MAX_STAT_VALUE) + 1
jr c, .noOverflow jr c, .noOverflow
.overflow .overflow
ld a, 999 / $100 ; overflow: cap at 999 ld a, HIGH(MAX_STAT_VALUE) ; overflow: cap at 999
ldh [hMultiplicand+1], a ldh [hMultiplicand+1], a
ld a, 999 % $100 ld a, LOW(MAX_STAT_VALUE)
ldh [hMultiplicand+2], a ldh [hMultiplicand+2], a
.noOverflow .noOverflow
pop bc pop bc

View file

@ -20,8 +20,8 @@ UncompressSpriteData::
; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop ; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop
_UncompressSpriteData:: _UncompressSpriteData::
ld hl, sSpriteBuffer1 ld hl, sSpriteBuffer1
ld c, (2*SPRITEBUFFERSIZE) % $100 ld c, LOW(2 * SPRITEBUFFERSIZE)
ld b, (2*SPRITEBUFFERSIZE) / $100 ld b, HIGH(2 * SPRITEBUFFERSIZE)
xor a xor a
call FillMemory ; clear sprite buffer 1 and 2 call FillMemory ; clear sprite buffer 1 and 2
ld a, $1 ld a, $1

View file

@ -141,8 +141,7 @@ ENDM
; stored in big endian ; stored in big endian
tempo: MACRO tempo: MACRO
db $ED db $ED
db \1 / $100 db HIGH(\1), LOW(\1)
db \1 % $100
ENDM ENDM
; arguments: left output enable mask, right output enable mask ; arguments: left output enable mask, right output enable mask

View file

@ -182,9 +182,9 @@ SafariZoneGate_TextPointers:
call PrintText call PrintText
ld a, 30 ld a, 30
ld [wNumSafariBalls], a ld [wNumSafariBalls], a
ld a, 502 / $100 ld a, HIGH(502)
ld [wSafariSteps], a ld [wSafariSteps], a
ld a, 502 % $100 ld a, LOW(502)
ld [wSafariSteps + 1], a ld [wSafariSteps + 1], a
ld a, D_UP ld a, D_UP
ld c, 3 ld c, 3