RGBDS syntax updates (#905)

New MACRO and DEF syntax
This commit is contained in:
vulcandth
2022-06-06 16:25:42 -05:00
committed by GitHub
parent a4d346cc8c
commit 3648afda16
179 changed files with 2546 additions and 2545 deletions

View File

@@ -19,42 +19,42 @@ Decompress::
; This function decompresses lz-compressed data from hl to de.
LZ_END EQU $ff ; Compressed data is terminated with $ff.
DEF LZ_END EQU $ff ; Compressed data is terminated with $ff.
; A typical control command consists of:
LZ_CMD EQU %11100000 ; command id (bits 5-7)
LZ_LEN EQU %00011111 ; length n (bits 0-4)
DEF LZ_CMD EQU %11100000 ; command id (bits 5-7)
DEF LZ_LEN EQU %00011111 ; length n (bits 0-4)
; Additional parameters are read during command execution.
; Commands:
LZ_LITERAL EQU 0 << 5 ; Read literal data for n bytes.
LZ_ITERATE EQU 1 << 5 ; Write the same byte for n bytes.
LZ_ALTERNATE EQU 2 << 5 ; Alternate two bytes for n bytes.
LZ_ZERO EQU 3 << 5 ; Write 0 for n bytes.
DEF LZ_LITERAL EQU 0 << 5 ; Read literal data for n bytes.
DEF LZ_ITERATE EQU 1 << 5 ; Write the same byte for n bytes.
DEF LZ_ALTERNATE EQU 2 << 5 ; Alternate two bytes for n bytes.
DEF LZ_ZERO EQU 3 << 5 ; Write 0 for n bytes.
; Another class of commands reuses data from the decompressed output.
LZ_RW EQU 2 + 5 ; bit
DEF LZ_RW EQU 2 + 5 ; bit
; These commands take a signed offset to start copying from.
; Wraparound is simulated.
; Positive offsets (15-bit) are added to the start address.
; Negative offsets (7-bit) are subtracted from the current position.
LZ_REPEAT EQU 4 << 5 ; Repeat n bytes from the offset.
LZ_FLIP EQU 5 << 5 ; Repeat n bitflipped bytes.
LZ_REVERSE EQU 6 << 5 ; Repeat n bytes in reverse.
DEF LZ_REPEAT EQU 4 << 5 ; Repeat n bytes from the offset.
DEF LZ_FLIP EQU 5 << 5 ; Repeat n bitflipped bytes.
DEF LZ_REVERSE EQU 6 << 5 ; Repeat n bytes in reverse.
; If the value in the count needs to be larger than 5 bits,
; LZ_LONG can be used to expand the count to 10 bits.
LZ_LONG EQU 7 << 5
DEF LZ_LONG EQU 7 << 5
; A new control command is read in bits 2-4.
; The top two bits of the length are bits 0-1.
; Another byte is read containing the bottom 8 bits.
LZ_LONG_HI EQU %00000011
DEF LZ_LONG_HI EQU %00000011
; In other words, the structure of the command becomes
; 111xxxyy yyyyyyyy

View File

@@ -1,5 +1,5 @@
TILES_PER_CYCLE EQU 8
MOBILE_TILES_PER_CYCLE EQU 6
DEF TILES_PER_CYCLE EQU 8
DEF MOBILE_TILES_PER_CYCLE EQU 6
Get2bppViaHDMA::
ldh a, [rLCDC]

View File

@@ -186,24 +186,24 @@ NextChar::
jp PlaceNextChar
CheckDict::
dict: MACRO
assert CHARLEN(\1) == 1
if \1 == 0
and a
else
cp \1
endc
if ISCONST(\2)
; Replace a character with another one
jr nz, .not\@
ld a, \2
.not\@:
elif STRSUB("\2", 1, 1) == "."
; Locals can use a short jump
jr z, \2
else
jp z, \2
endc
MACRO dict
assert CHARLEN(\1) == 1
if \1 == 0
and a
else
cp \1
endc
if ISCONST(\2)
; Replace a character with another one
jr nz, .not\@
ld a, \2
.not\@:
elif STRSUB("\2", 1, 1) == "."
; Locals can use a short jump
jr z, \2
else
jp z, \2
endc
ENDM
dict "<MOBILE>", MobileScriptChar
@@ -295,7 +295,7 @@ MobileScriptChar::
farcall RunMobileScript
jp PlaceNextChar
print_name: MACRO
MACRO print_name
push de
ld de, \1
jp PlaceCommandCharacter

View File

@@ -182,7 +182,7 @@ UpdateBGMap::
jr z, .middle
; 2
THIRD_HEIGHT EQU SCREEN_HEIGHT / 3
DEF THIRD_HEIGHT EQU SCREEN_HEIGHT / 3
; bottom
ld de, 2 * THIRD_HEIGHT * SCREEN_WIDTH