Capitalize rgbds control structures (EQU/EQUS, IF/ELIF/ELSE/ENDC, REPT/ENDR, MACRO/ENDM, etc)

This commit is contained in:
Rangi 2020-07-06 12:28:31 -04:00
parent d08eb86233
commit 8a79315635
13 changed files with 76 additions and 74 deletions

View file

@ -1,14 +1,14 @@
Moves: Moves:
; Characteristics of each move. ; Characteristics of each move.
move: macro move: MACRO
db \1 ; animation (interchangeable with move id) db \1 ; animation (interchangeable with move id)
db \2 ; effect db \2 ; effect
db \3 ; power db \3 ; power
db \4 ; type db \4 ; type
db \5 percent ; accuracy db \5 percent ; accuracy
db \6 ; pp db \6 ; pp
endm ENDM
move POUND, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 move POUND, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35
MoveEnd: MoveEnd:

View file

@ -89,9 +89,9 @@ FlashSprite8Times:
CopyHealingMachineOAM: CopyHealingMachineOAM:
; copy one OAM entry and advance the pointers ; copy one OAM entry and advance the pointers
rept 4 REPT 4
ld a, [de] ld a, [de]
inc de inc de
ld [hli], a ld [hli], a
endr ENDR
ret ret

View file

@ -7,9 +7,9 @@ ReadJoypad::
ld c, 0 ld c, 0
ld [rJOYP], a ld [rJOYP], a
rept 6 REPT 6
ld a, [rJOYP] ld a, [rJOYP]
endr ENDR
cpl cpl
and %1111 and %1111
swap a swap a
@ -17,9 +17,9 @@ ReadJoypad::
ld a, 1 << 4 ; select button keys ld a, 1 << 4 ; select button keys
ld [rJOYP], a ld [rJOYP], a
rept 10 REPT 10
ld a, [rJOYP] ld a, [rJOYP]
endr ENDR
cpl cpl
and %1111 and %1111
or b or b

View file

@ -59,18 +59,20 @@ PrintNumber::
cp 6 cp 6
jr z, .hundred_thousands jr z, .hundred_thousands
print_digit: macro print_digit: MACRO
if (\1) / $10000 IF (\1) / $10000
ld a, \1 / $10000 % $100 ld a, \1 / $10000 % $100
else xor a ELSE
endc xor a
ENDC
ld [hPowerOf10 + 0], a ld [hPowerOf10 + 0], a
if (\1) / $100 IF (\1) / $100
ld a, \1 / $100 % $100 ld a, \1 / $100 % $100
else xor a ELSE
endc xor a
ENDC
ld [hPowerOf10 + 1], a ld [hPowerOf10 + 1], a
ld a, \1 / $1 % $100 ld a, \1 / $1 % $100
@ -78,7 +80,7 @@ endc
call .PrintDigit call .PrintDigit
call .NextDigit call .NextDigit
endm ENDM
.millions print_digit 1000000 .millions print_digit 1000000
.hundred_thousands print_digit 100000 .hundred_thousands print_digit 100000

View file

@ -170,13 +170,13 @@ AutoBgMapTransfer::
TransferBgRows:: TransferBgRows::
; unrolled loop and using pop for speed ; unrolled loop and using pop for speed
rept 20 / 2 - 1 REPT 20 / 2 - 1
pop de pop de
ld [hl], e ld [hl], e
inc l inc l
ld [hl], d ld [hl], d
inc l inc l
endr ENDR
pop de pop de
ld [hl], e ld [hl], e
@ -261,7 +261,7 @@ VBlankCopyDouble::
ld [hVBlankCopyDoubleSize], a ld [hVBlankCopyDoubleSize], a
.loop .loop
rept 3 REPT 3
pop de pop de
ld [hl], e ld [hl], e
inc l inc l
@ -271,7 +271,7 @@ VBlankCopyDouble::
inc l inc l
ld [hl], d ld [hl], d
inc l inc l
endr ENDR
pop de pop de
ld [hl], e ld [hl], e
@ -339,13 +339,13 @@ VBlankCopy::
ld [hVBlankCopySize], a ld [hVBlankCopySize], a
.loop .loop
rept 7 REPT 7
pop de pop de
ld [hl], e ld [hl], e
inc l inc l
ld [hl], d ld [hl], d
inc l inc l
endr ENDR
pop de pop de
ld [hl], e ld [hl], e

View file

@ -11,10 +11,10 @@ ENDM
; Design patterns ; Design patterns
dict: MACRO dict: MACRO
if \1 == 0 IF \1 == 0
and a and a
else ELSE
cp \1 cp \1
endc ENDC
jp z, \2 jp z, \2
ENDM ENDM

View file

@ -13,40 +13,40 @@ bcd3: MACRO
dn ((\1) / 10) % 10, (\1) % 10 dn ((\1) / 10) % 10, (\1) % 10
ENDM ENDM
coins equs "bcd2" coins EQUS "bcd2"
money equs "bcd3" money EQUS "bcd3"
tmhm: MACRO tmhm: MACRO
; used in data/pokemon/base_stats/*.asm ; used in data/pokemon/base_stats/*.asm
_tms1 = 0 ; TM01-TM24 (24) _tms1 = 0 ; TM01-TM24 (24)
_tms2 = 0 ; TM25-TM48 (24) _tms2 = 0 ; TM25-TM48 (24)
_tms3 = 0 ; TM49-TM50 + HM01-HM05 (7/24) _tms3 = 0 ; TM49-TM50 + HM01-HM05 (7/24)
rept _NARG REPT _NARG
if DEF(\1_TMNUM) if DEF(\1_TMNUM)
if \1_TMNUM < 24 + 1 if \1_TMNUM < 24 + 1
_tms1 = _tms1 | (1 << ((\1_TMNUM) - 1)) _tms1 = _tms1 | (1 << ((\1_TMNUM) - 1))
elif \1_TMNUM < 48 + 1 ELIF \1_TMNUM < 48 + 1
_tms2 = _tms2 | (1 << ((\1_TMNUM) - 1 - 24)) _tms2 = _tms2 | (1 << ((\1_TMNUM) - 1 - 24))
else else
_tms3 = _tms3 | (1 << ((\1_TMNUM) - 1 - 48)) _tms3 = _tms3 | (1 << ((\1_TMNUM) - 1 - 48))
endc ENDC
else else
fail "\1 is not a TM or HM move" fail "\1 is not a TM or HM move"
endc ENDC
shift shift
endr ENDR
rept 3 ; TM01-TM24 (24/24) REPT 3 ; TM01-TM24 (24/24)
db _tms1 & $ff db _tms1 & $ff
_tms1 = _tms1 >> 8 _tms1 = _tms1 >> 8
endr ENDR
rept 3 ; TM25-TM48 (24/24) REPT 3 ; TM25-TM48 (24/24)
db _tms2 & $ff db _tms2 & $ff
_tms2 = _tms2 >> 8 _tms2 = _tms2 >> 8
endr ENDR
rept 1 ; TM49-TM50 + HM01-HM05 (7/8) REPT 1 ; TM49-TM50 + HM01-HM05 (7/8)
db _tms3 & $ff db _tms3 & $ff
_tms3 = _tms3 >> 8 _tms3 = _tms3 >> 8
endr ENDR
ENDM ENDM

View file

@ -1,16 +1,16 @@
; Enumerate variables ; Enumerate variables
enum_start: MACRO enum_start: MACRO
if _NARG >= 1 IF _NARG >= 1
__enum__ = \1 __enum__ = \1
else ELSE
__enum__ = 0 __enum__ = 0
endc ENDC
if _NARG >= 2 IF _NARG >= 2
__enumdir__ = \2 __enumdir__ = \2
else ELSE
__enumdir__ = 1 __enumdir__ = 1
endc ENDC
ENDM ENDM
enum: MACRO enum: MACRO
@ -25,11 +25,11 @@ ENDM
; Enumerate constants ; Enumerate constants
const_def: MACRO const_def: MACRO
if _NARG >= 1 IF _NARG >= 1
const_value = \1 const_value = \1
else ELSE
const_value = 0 const_value = 0
endc ENDC
ENDM ENDM
const: MACRO const: MACRO

View file

@ -1,8 +1,8 @@
RGB: MACRO RGB: MACRO
rept _NARG / 3 REPT _NARG / 3
dw palred (\1) + palgreen (\2) + palblue (\3) dw palred (\1) + palgreen (\2) + palblue (\3)
shift 3 shift 3
endr ENDR
ENDM ENDM
palred EQUS "(1 << 0) *" palred EQUS "(1 << 0) *"

View file

@ -183,10 +183,10 @@ ENDM
;\3, \4, ... = additional (optional) event indices ;\3, \4, ... = additional (optional) event indices
SetEvents: MACRO SetEvents: MACRO
SetEvent \1 SetEvent \1
rept _NARG - 1 REPT _NARG - 1
SetEventReuseHL \2 SetEventReuseHL \2
shift shift
endr ENDR
ENDM ENDM
@ -235,10 +235,10 @@ ENDM
;\3 = event index (optional) ;\3 = event index (optional)
ResetEvents: MACRO ResetEvents: MACRO
ResetEvent \1 ResetEvent \1
rept _NARG - 1 REPT _NARG - 1
ResetEventReuseHL \2 ResetEventReuseHL \2
shift shift
endr ENDR
ENDM ENDM

View file

@ -121,58 +121,58 @@ connection: MACRO
; Calculate tile offsets for source (current) and target maps ; Calculate tile offsets for source (current) and target maps
_src = 0 _src = 0
_tgt = (\4) + 3 _tgt = (\4) + 3
if _tgt < 2 IF _tgt < 2
_src = -_tgt _src = -_tgt
_tgt = 0 _tgt = 0
endc ENDC
if "\1" == "north" IF "\1" == "north"
_blk = \3_WIDTH * (\3_HEIGHT - 3) + _src _blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
_map = _tgt _map = _tgt
_win = (\3_WIDTH + 6) * \3_HEIGHT + 1 _win = (\3_WIDTH + 6) * \3_HEIGHT + 1
_y = \3_HEIGHT * 2 - 1 _y = \3_HEIGHT * 2 - 1
_x = (\4) * -2 _x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4) _len = CURRENT_MAP_WIDTH + 3 - (\4)
if _len > \3_WIDTH IF _len > \3_WIDTH
_len = \3_WIDTH _len = \3_WIDTH
endc ENDC
elif "\1" == "south" ELIF "\1" == "south"
_blk = _src _blk = _src
_map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt _map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
_win = \3_WIDTH + 7 _win = \3_WIDTH + 7
_y = 0 _y = 0
_x = (\4) * -2 _x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4) _len = CURRENT_MAP_WIDTH + 3 - (\4)
if _len > \3_WIDTH IF _len > \3_WIDTH
_len = \3_WIDTH _len = \3_WIDTH
endc ENDC
elif "\1" == "west" ELIF "\1" == "west"
_blk = (\3_WIDTH * _src) + \3_WIDTH - 3 _blk = (\3_WIDTH * _src) + \3_WIDTH - 3
_map = (CURRENT_MAP_WIDTH + 6) * _tgt _map = (CURRENT_MAP_WIDTH + 6) * _tgt
_win = (\3_WIDTH + 6) * 2 - 6 _win = (\3_WIDTH + 6) * 2 - 6
_y = (\4) * -2 _y = (\4) * -2
_x = \3_WIDTH * 2 - 1 _x = \3_WIDTH * 2 - 1
_len = CURRENT_MAP_HEIGHT + 3 - (\4) _len = CURRENT_MAP_HEIGHT + 3 - (\4)
if _len > \3_HEIGHT IF _len > \3_HEIGHT
_len = \3_HEIGHT _len = \3_HEIGHT
endc ENDC
elif "\1" == "east" ELIF "\1" == "east"
_blk = (\3_WIDTH * _src) _blk = (\3_WIDTH * _src)
_map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3 _map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
_win = \3_WIDTH + 7 _win = \3_WIDTH + 7
_y = (\4) * -2 _y = (\4) * -2
_x = 0 _x = 0
_len = CURRENT_MAP_HEIGHT + 3 - (\4) _len = CURRENT_MAP_HEIGHT + 3 - (\4)
if _len > \3_HEIGHT IF _len > \3_HEIGHT
_len = \3_HEIGHT _len = \3_HEIGHT
endc ENDC
else ELSE
fail "Invalid direction for 'connection'." fail "Invalid direction for 'connection'."
endc ENDC
db \3 db \3
dw \2_Blocks + _blk dw \2_Blocks + _blk

View file

@ -198,10 +198,10 @@ ENDM
script_mart: MACRO script_mart: MACRO
db TX_SCRIPT_MART db TX_SCRIPT_MART
db _NARG ; number of items db _NARG ; number of items
rept _NARG REPT _NARG
db \1 ; item id db \1 ; item id
shift shift
endr ENDR
db -1 ; end db -1 ; end
ENDM ENDM

View file

@ -3,10 +3,10 @@ MAJOR EQU 0
MINOR EQU 4 MINOR EQU 4
PATCH EQU 0 PATCH EQU 0
if !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__) IF !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__)
fail "pokered requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer." fail "pokered requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer."
elif (__RGBDS_MAJOR__ < MAJOR) || \ ELIF (__RGBDS_MAJOR__ < MAJOR) || \
(__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ < MINOR) || \ (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ < MINOR) || \
(__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ < PATCH) (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ < PATCH)
fail "pokered requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer." fail "pokered requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer."
endc ENDC