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

View File

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

View File

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

View File

@@ -42,6 +42,18 @@ MACRO dbpixel
endc
ENDM
MACRO hlpixel
ldpixel hl, \#
ENDM
MACRO bcpixel
ldpixel bc, \#
ENDM
MACRO depixel
ldpixel de, \#
ENDM
MACRO ldpixel
if _NARG >= 5
; register, x tile, y tile, x pixel, y pixel
@@ -52,9 +64,6 @@ MACRO ldpixel
endc
ENDM
DEF depixel EQUS "ldpixel de,"
DEF bcpixel EQUS "ldpixel bc,"
MACRO dbsprite
; x tile, y tile, x pixel, y pixel, vtile offset, attributes
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
ENDM
DEF object_const_def EQUS "const_def 2"
MACRO object_const_def
const_def 2
ENDM
MACRO def_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.
DEF next EQUS "db \"<NEXT>\"," ; Move a line down.
DEF line EQUS "db \"<LINE>\"," ; Start writing at the bottom line.
DEF page EQUS "db \"@\"," ; Start a new Pokédex page.
DEF para EQUS "db \"<PARA>\"," ; Start a new paragraph.
DEF cont EQUS "db \"<CONT>\"," ; Scroll to the next line.
DEF done EQUS "db \"<DONE>\"" ; End a text box.
DEF prompt EQUS "db \"<PROMPT>\"" ; Prompt the player to end a text box (initiating some other event).
MACRO text
db TX_START, \# ; Start writing text
ENDM
MACRO next
db "<NEXT>", \# ; Move a line down
ENDM
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)
const_def

View File

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