diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index b909d57c7..4f2488645 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -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 diff --git a/engine/events/mom_phone.asm b/engine/events/mom_phone.asm index 61ff5c698..11beb6625 100644 --- a/engine/events/mom_phone.asm +++ b/engine/events/mom_phone.asm @@ -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 diff --git a/engine/games/card_flip.asm b/engine/games/card_flip.asm index e503f11bd..002780750 100644 --- a/engine/games/card_flip.asm +++ b/engine/games/card_flip.asm @@ -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. diff --git a/macros/coords.asm b/macros/coords.asm index e899e68e7..a135f7d48 100644 --- a/macros/coords.asm +++ b/macros/coords.asm @@ -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] diff --git a/macros/gfx.asm b/macros/gfx.asm index 93b96a518..66b97a07a 100644 --- a/macros/gfx.asm +++ b/macros/gfx.asm @@ -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 diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index 1181ba543..fe487d1a5 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -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_\@" diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm index fac922b98..623fd9513 100644 --- a/macros/scripts/text.asm +++ b/macros/scripts/text.asm @@ -1,11 +1,34 @@ -DEF text EQUS "db TX_START," ; Start writing text. -DEF next EQUS "db \"\"," ; Move a line down. -DEF line EQUS "db \"\"," ; Start writing at the bottom line. -DEF page EQUS "db \"@\"," ; Start a new Pokédex page. -DEF para EQUS "db \"\"," ; Start a new paragraph. -DEF cont EQUS "db \"\"," ; Scroll to the next line. -DEF done EQUS "db \"\"" ; End a text box. -DEF prompt EQUS "db \"\"" ; Prompt the player to end a text box (initiating some other event). +MACRO text + db TX_START, \# ; Start writing text +ENDM + +MACRO next + db "", \# ; Move a line down +ENDM + +MACRO line + db "", \# ; Start writing at the bottom line +ENDM + +MACRO page + db "@", \# ; Start a new Pokédex page +ENDM + +MACRO para + db "", \# ; Start a new paragraph +ENDM + +MACRO cont + db "", \# ; Scroll to the next line +ENDM + +MACRO done + db "" ; End a text box +ENDM + +MACRO prompt + db "" ; Prompt the player to end a text box (initiating some other event) +ENDM ; TextCommands indexes (see home/text.asm) const_def diff --git a/ram/wram.asm b/ram/wram.asm index 28fd8b432..0cd335db9 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -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