Avoid using EQUS when EQU or MACRO will do (#1166)

This commit is contained in:
Rangi
2025-02-27 13:07:12 -05:00
committed by GitHub
parent 7a7a06289c
commit 4d6c3e2975
8 changed files with 91 additions and 34 deletions

View File

@@ -47,3 +47,6 @@ DEF MAX_DAY_CARE_EXP EQU $500000
; hall of fame ; hall of fame
DEF HOF_MASTER_COUNT EQU 200 DEF HOF_MASTER_COUNT EQU 200
; card flip
DEF CARDFLIP_DECK_SIZE EQU 4 * 6

View File

@@ -1,6 +1,12 @@
DEF NUM_MOM_ITEMS_1 EQUS "((MomItems_1.End - MomItems_1) / 8)" ; Constants for momitem offsets (see data/items/mom_phone.asm)
DEF NUM_MOM_ITEMS_2 EQUS "((MomItems_2.End - MomItems_2) / 8)" rsreset
DEF MOMITEM_TRIGGER rb 3 ; 0
DEF MOMITEM_COST rb 3 ; 3
DEF MOMITEM_KIND rb ; 6
DEF MOMITEM_ITEM rb ; 7
DEF MOMITEM_SIZE EQU _RS ; 8
; momitem kind values
const_def 1 const_def 1
const MOM_ITEM const MOM_ITEM
const MOM_DOLL const MOM_DOLL
@@ -57,9 +63,10 @@ MomTriesToBuySomething::
CheckBalance_MomItem2: CheckBalance_MomItem2:
ld a, [wWhichMomItem] ld a, [wWhichMomItem]
cp NUM_MOM_ITEMS_2 cp (MomItems_2.End - MomItems_2) / MOMITEM_SIZE
jr nc, .nope jr nc, .nope
call GetItemFromMom call GetItemFromMom
assert MOMITEM_TRIGGER == 0
ld a, [hli] ld a, [hli]
ldh [hMoneyTemp], a ldh [hMoneyTemp], a
ld a, [hli] ld a, [hli]
@@ -100,7 +107,7 @@ CheckBalance_MomItem2:
.exact .exact
call .AddMoney call .AddMoney
ld a, NUM_MOM_ITEMS_1 ld a, (MomItems_1.End - MomItems_1) / MOMITEM_SIZE
call RandomRange call RandomRange
inc a inc a
ld [wWhichMomItemSet], a ld [wWhichMomItemSet], a
@@ -115,7 +122,7 @@ CheckBalance_MomItem2:
MomBuysItem_DeductFunds: MomBuysItem_DeductFunds:
call GetItemFromMom call GetItemFromMom
ld de, 3 ; cost ld de, MOMITEM_COST
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ldh [hMoneyTemp], a ldh [hMoneyTemp], a
@@ -130,11 +137,12 @@ MomBuysItem_DeductFunds:
Mom_GiveItemOrDoll: Mom_GiveItemOrDoll:
call GetItemFromMom call GetItemFromMom
ld de, 6 ; item type ld de, MOMITEM_KIND
add hl, de add hl, de
ld a, [hli] ld a, [hli]
cp MOM_ITEM cp MOM_ITEM
jr z, .not_doll jr z, .not_doll
assert MOMITEM_KIND + 1 == MOMITEM_ITEM
ld a, [hl] ld a, [hl]
ld c, a ld c, a
ld b, 1 ld b, 1
@@ -153,7 +161,7 @@ Mom_GiveItemOrDoll:
Mom_GetScriptPointer: Mom_GetScriptPointer:
call GetItemFromMom call GetItemFromMom
ld de, 6 ; item type ld de, MOMITEM_KIND
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld de, .ItemScript ld de, .ItemScript
@@ -186,7 +194,7 @@ GetItemFromMom:
.zero .zero
ld a, [wWhichMomItem] ld a, [wWhichMomItem]
cp NUM_MOM_ITEMS_2 cp (MomItems_2.End - MomItems_2) / MOMITEM_SIZE
jr c, .ok jr c, .ok
xor a xor a
@@ -196,7 +204,8 @@ GetItemFromMom:
.GetFromList1: .GetFromList1:
ld l, a ld l, a
ld h, 0 ld h, 0
rept 3 ; multiply hl by 8 assert MOMITEM_SIZE == 8
rept 3 ; multiply hl by MOMITEM_SIZE
add hl, hl add hl, hl
endr endr
add hl, de add hl, de

View File

@@ -1,9 +1,6 @@
DEF CARDFLIP_LIGHT_OFF EQU "♂" ; $ef DEF CARDFLIP_LIGHT_OFF EQU "♂" ; $ef
DEF CARDFLIP_LIGHT_ON EQU "♀" ; $f5 DEF CARDFLIP_LIGHT_ON EQU "♀" ; $f5
DEF CARDFLIP_DECK_SIZE EQUS "(wDeckEnd - wDeck)"
assert wDiscardPileEnd - wDiscardPile == wDeckEnd - wDeck
MemoryGameGFX: MemoryGameGFX:
; Graphics for an unused Game Corner ; Graphics for an unused Game Corner
; game were meant to be here. ; game were meant to be here.

View File

@@ -1,8 +1,16 @@
; Coordinate macros ; Coordinate macros
DEF hlcoord EQUS "coord hl," MACRO hlcoord
DEF bccoord EQUS "coord bc," coord hl, \#
DEF decoord EQUS "coord de," ENDM
MACRO bccoord
coord bc, \#
ENDM
MACRO decoord
coord de, \#
ENDM
MACRO coord MACRO coord
; register, x, y[, origin] ; register, x, y[, origin]
@@ -13,9 +21,17 @@ MACRO coord
endc endc
ENDM ENDM
DEF hlbgcoord EQUS "bgcoord hl," MACRO hlbgcoord
DEF bcbgcoord EQUS "bgcoord bc," bgcoord hl, \#
DEF debgcoord EQUS "bgcoord de," ENDM
MACRO bcbgcoord
bgcoord bc, \#
ENDM
MACRO debgcoord
bgcoord de, \#
ENDM
MACRO bgcoord MACRO bgcoord
; register, x, y[, origin] ; register, x, y[, origin]

View File

@@ -42,6 +42,18 @@ MACRO dbpixel
endc endc
ENDM ENDM
MACRO hlpixel
ldpixel hl, \#
ENDM
MACRO bcpixel
ldpixel bc, \#
ENDM
MACRO depixel
ldpixel de, \#
ENDM
MACRO ldpixel MACRO ldpixel
if _NARG >= 5 if _NARG >= 5
; register, x tile, y tile, x pixel, y pixel ; register, x tile, y tile, x pixel, y pixel
@@ -52,9 +64,6 @@ MACRO ldpixel
endc endc
ENDM ENDM
DEF depixel EQUS "ldpixel de,"
DEF bcpixel EQUS "ldpixel bc,"
MACRO dbsprite MACRO dbsprite
; x tile, y tile, x pixel, y pixel, vtile offset, attributes ; x tile, y tile, x pixel, y pixel, vtile offset, attributes
db (\2 * TILE_WIDTH) % $100 + \4, (\1 * TILE_WIDTH) % $100 + \3, \5, \6 db (\2 * TILE_WIDTH) % $100 + \4, (\1 * TILE_WIDTH) % $100 + \3, \5, \6

View File

@@ -5,7 +5,9 @@ MACRO map_id
db GROUP_\1, MAP_\1 db GROUP_\1, MAP_\1
ENDM ENDM
DEF object_const_def EQUS "const_def 2" MACRO object_const_def
const_def 2
ENDM
MACRO def_scene_scripts MACRO def_scene_scripts
REDEF _NUM_SCENE_SCRIPTS EQUS "_NUM_SCENE_SCRIPTS_\@" REDEF _NUM_SCENE_SCRIPTS EQUS "_NUM_SCENE_SCRIPTS_\@"

View File

@@ -1,11 +1,34 @@
DEF text EQUS "db TX_START," ; Start writing text. MACRO text
DEF next EQUS "db \"<NEXT>\"," ; Move a line down. db TX_START, \# ; Start writing text
DEF line EQUS "db \"<LINE>\"," ; Start writing at the bottom line. ENDM
DEF page EQUS "db \"@\"," ; Start a new Pokédex page.
DEF para EQUS "db \"<PARA>\"," ; Start a new paragraph. MACRO next
DEF cont EQUS "db \"<CONT>\"," ; Scroll to the next line. db "<NEXT>", \# ; Move a line down
DEF done EQUS "db \"<DONE>\"" ; End a text box. ENDM
DEF prompt EQUS "db \"<PROMPT>\"" ; Prompt the player to end a text box (initiating some other event).
MACRO line
db "<LINE>", \# ; Start writing at the bottom line
ENDM
MACRO page
db "@", \# ; Start a new Pokédex page
ENDM
MACRO para
db "<PARA>", \# ; Start a new paragraph
ENDM
MACRO cont
db "<CONT>", \# ; Scroll to the next line
ENDM
MACRO done
db "<DONE>" ; End a text box
ENDM
MACRO prompt
db "<PROMPT>" ; Prompt the player to end a text box (initiating some other event)
ENDM
; TextCommands indexes (see home/text.asm) ; TextCommands indexes (see home/text.asm)
const_def const_def

View File

@@ -809,12 +809,10 @@ wSlotsEnd::
NEXTU NEXTU
; card flip ; card flip
wDeck:: ds 4 * 6 wDeck:: ds CARDFLIP_DECK_SIZE
wDeckEnd::
wCardFlipNumCardsPlayed:: db wCardFlipNumCardsPlayed:: db
wCardFlipFaceUpCard:: db wCardFlipFaceUpCard:: db
wDiscardPile:: ds 4 * 6 wDiscardPile:: ds CARDFLIP_DECK_SIZE
wDiscardPileEnd::
; beta poker game ; beta poker game
wBetaPokerSGBPals:: dw wBetaPokerSGBPals:: dw