summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2021-04-17 21:00:28 -0500
committerdannye <33dannye@gmail.com>2021-04-17 21:00:28 -0500
commitd4154b289176647ff20e19879de70073bd6d9a30 (patch)
treef4175a9303dd0e1430f4c42e79a4d5ffb1f32c00
parenta1081856200cec52ba881fc6f878f5ce0328ab0a (diff)
parent2fdcb1a3d6919f378b2f83f14d3b3822a19fcc33 (diff)
Merge branch 'master' of https://github.com/pret/pokered
-rw-r--r--.travis.yml2
-rw-r--r--constants/item_constants.asm23
-rw-r--r--data/moves/tmhm_moves.asm24
-rw-r--r--data/tilesets/collision_tile_ids.asm7
-rw-r--r--data/tilesets/door_tile_ids.asm7
-rw-r--r--data/tilesets/warp_carpet_tile_ids.asm7
-rw-r--r--data/tilesets/warp_tile_ids.asm7
-rw-r--r--data/trainers/move_choices.asm7
-rw-r--r--engine/overworld/healing_machine.asm4
-rw-r--r--home/vcopy.asm22
-rw-r--r--macros/asserts.asm42
-rw-r--r--macros/data.asm20
-rw-r--r--macros/scripts/events.asm8
-rw-r--r--macros/scripts/maps.asm52
-rw-r--r--macros/scripts/text.asm7
-rw-r--r--rgbdscheck.asm16
-rw-r--r--tools/Makefile2
-rwxr-xr-xtools/unnamed.py6
18 files changed, 95 insertions, 168 deletions
diff --git a/.travis.yml b/.travis.yml
index 0d3b9f7a..a0b965f7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ os:
install:
- |-
( cd
- git clone -b v0.4.2 --depth=1 https://github.com/gbdev/rgbds
+ git clone -b v0.5.0 --depth=1 https://github.com/gbdev/rgbds
sudo make -C rgbds install
rm -rf rgbds
)
diff --git a/constants/item_constants.asm b/constants/item_constants.asm
index e7cea725..d117443c 100644
--- a/constants/item_constants.asm
+++ b/constants/item_constants.asm
@@ -29,8 +29,8 @@
const POTION ; $14
const BOULDERBADGE ; $15
const CASCADEBADGE ; $16
-SAFARI_BAIT EQU $15 ; overload
-SAFARI_ROCK EQU $16 ; overload
+SAFARI_BAIT EQU $15 ; overload
+SAFARI_ROCK EQU $16 ; overload
const THUNDERBADGE ; $17
const RAINBOWBADGE ; $18
const SOULBADGE ; $19
@@ -128,17 +128,10 @@ IF !DEF(HM01)
HM01 EQU const_value
__tmhm_value__ = NUM_TMS + 1
ENDC
-HM_VALUE EQU __tmhm_value__ - NUM_TMS
-IF HM_VALUE < 10
-MOVE_FOR_HM EQUS "HM0{d:HM_VALUE}_MOVE"
-ELSE
-MOVE_FOR_HM EQUS "HM{d:HM_VALUE}_MOVE"
-ENDC
-MOVE_FOR_HM = \1
-PURGE MOVE_FOR_HM
-PURGE HM_VALUE
const HM_\1
\1_TMNUM EQU __tmhm_value__
+__HM_VALUE = __tmhm_value__ - NUM_TMS
+HM{02d:__HM_VALUE}_MOVE EQU \1
__tmhm_value__ = __tmhm_value__ + 1
ENDM
@@ -159,15 +152,9 @@ IF !DEF(TM01)
TM01 EQU const_value
__tmhm_value__ = 1
ENDC
-IF __tmhm_value__ < 10
-MOVE_FOR_TM EQUS "TM0{d:__tmhm_value__}_MOVE"
-ELSE
-MOVE_FOR_TM EQUS "TM{d:__tmhm_value__}_MOVE"
-ENDC
-MOVE_FOR_TM = \1
-PURGE MOVE_FOR_TM
const TM_\1
\1_TMNUM EQU __tmhm_value__
+TM{02d:__tmhm_value__}_MOVE EQU \1
__tmhm_value__ = __tmhm_value__ + 1
ENDM
diff --git a/data/moves/tmhm_moves.asm b/data/moves/tmhm_moves.asm
index 850b24b4..0e4a79af 100644
--- a/data/moves/tmhm_moves.asm
+++ b/data/moves/tmhm_moves.asm
@@ -4,29 +4,13 @@
TechnicalMachines:
table_width 1, TechnicalMachines
-n = 1
-REPT NUM_TMS
-IF n < 10
-MOVE_FOR_TM EQUS "TM0{d:n}_MOVE"
-ELSE
-MOVE_FOR_TM EQUS "TM{d:n}_MOVE"
-ENDC
- db MOVE_FOR_TM
-PURGE MOVE_FOR_TM
-n = n + 1
+FOR n, 1, NUM_TMS + 1
+ db TM{02d:n}_MOVE
ENDR
assert_table_length NUM_TMS
-n = 1
-REPT NUM_HMS
-IF n < 10
-MOVE_FOR_HM EQUS "HM0{d:n}_MOVE"
-ELSE
-MOVE_FOR_HM EQUS "HM{d:n}_MOVE"
-ENDC
- db MOVE_FOR_HM
-PURGE MOVE_FOR_HM
-n = n + 1
+FOR n, 1, NUM_HMS + 1
+ db HM{02d:n}_MOVE
ENDR
assert_table_length NUM_TM_HM
diff --git a/data/tilesets/collision_tile_ids.asm b/data/tilesets/collision_tile_ids.asm
index 058a815c..eb09f4fb 100644
--- a/data/tilesets/collision_tile_ids.asm
+++ b/data/tilesets/collision_tile_ids.asm
@@ -1,8 +1,7 @@
coll_tiles: MACRO
-REPT _NARG
- db \1
- shift
-ENDR
+ IF _NARG
+ db \# ; all args
+ ENDC
db -1 ; end
ENDM
diff --git a/data/tilesets/door_tile_ids.asm b/data/tilesets/door_tile_ids.asm
index 5fca7114..950115e0 100644
--- a/data/tilesets/door_tile_ids.asm
+++ b/data/tilesets/door_tile_ids.asm
@@ -16,10 +16,9 @@ DoorTileIDPointers:
db -1 ; end
door_tiles: MACRO
-REPT _NARG
- db \1
- shift
-ENDR
+ IF _NARG
+ db \# ; all args
+ ENDC
db 0 ; end
ENDM
diff --git a/data/tilesets/warp_carpet_tile_ids.asm b/data/tilesets/warp_carpet_tile_ids.asm
index be327599..a8a19011 100644
--- a/data/tilesets/warp_carpet_tile_ids.asm
+++ b/data/tilesets/warp_carpet_tile_ids.asm
@@ -5,10 +5,9 @@ WarpTileListPointers:
dw .FacingRightWarpTiles
warp_carpet_tiles: MACRO
-REPT _NARG
- db \1
- shift
-ENDR
+ IF _NARG
+ db \# ; all args
+ ENDC
db -1 ; end
ENDM
diff --git a/data/tilesets/warp_tile_ids.asm b/data/tilesets/warp_tile_ids.asm
index bba7787a..b30a731d 100644
--- a/data/tilesets/warp_tile_ids.asm
+++ b/data/tilesets/warp_tile_ids.asm
@@ -28,10 +28,9 @@ WarpTileIDPointers:
assert_table_length NUM_TILESETS
warp_tiles: MACRO
-REPT _NARG
- db \1
- shift
-ENDR
+ IF _NARG
+ db \# ; all args
+ ENDC
db -1 ; end
ENDM
diff --git a/data/trainers/move_choices.asm b/data/trainers/move_choices.asm
index 2950e515..d80722b1 100644
--- a/data/trainers/move_choices.asm
+++ b/data/trainers/move_choices.asm
@@ -1,8 +1,7 @@
move_choices: MACRO
-REPT _NARG
- db \1
- shift
-ENDR
+ IF _NARG
+ db \# ; all args
+ ENDC
db 0 ; end
list_index = list_index + 1
ENDM
diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm
index a081811b..451ea001 100644
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -90,9 +90,9 @@ FlashSprite8Times:
CopyHealingMachineOAM:
; copy one OAM entry and advance the pointers
- REPT 4
+REPT 4
ld a, [de]
inc de
ld [hli], a
- ENDR
+ENDR
ret
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 2b68eb09..4a80d261 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -23,7 +23,7 @@ ClearBgMap::
jr .next
ld a, l
.next
- ld de, $400 ; size of VRAM background map
+ ld de, BG_MAP_WIDTH * BG_MAP_HEIGHT
ld l, e
.loop
ld [hli], a
@@ -69,7 +69,7 @@ RedrawRowOrColumn::
.noCarry
; the following 4 lines wrap us from bottom to top if necessary
ld a, d
- and $03
+ and $3
or $98
ld d, a
dec c
@@ -165,21 +165,19 @@ AutoBgMapTransfer::
TransferBgRows::
; unrolled loop and using pop for speed
-
- REPT 20 / 2 - 1
+REPT SCREEN_WIDTH / 2 - 1
pop de
ld [hl], e
inc l
ld [hl], d
inc l
- ENDR
-
+ENDR
pop de
ld [hl], e
inc l
ld [hl], d
- ld a, 32 - (20 - 1)
+ ld a, BG_MAP_WIDTH - (SCREEN_WIDTH - 1)
add l
ld l, a
jr nc, .ok
@@ -249,7 +247,7 @@ VBlankCopyDouble::
ldh [hVBlankCopyDoubleSize], a
.loop
- REPT 3
+REPT LEN_2BPP_TILE / 4 - 1
pop de
ld [hl], e
inc l
@@ -259,8 +257,7 @@ VBlankCopyDouble::
inc l
ld [hl], d
inc l
- ENDR
-
+ENDR
pop de
ld [hl], e
inc l
@@ -316,14 +313,13 @@ VBlankCopy::
ldh [hVBlankCopySize], a
.loop
- REPT 7
+REPT LEN_2BPP_TILE / 2 - 1
pop de
ld [hl], e
inc l
ld [hl], d
inc l
- ENDR
-
+ENDR
pop de
ld [hl], e
inc l
diff --git a/macros/asserts.asm b/macros/asserts.asm
index d04c7942..a07bc553 100644
--- a/macros/asserts.asm
+++ b/macros/asserts.asm
@@ -2,33 +2,27 @@
table_width: MACRO
CURRENT_TABLE_WIDTH = \1
-IF DEF(CURRENT_TABLE_START)
-PURGE CURRENT_TABLE_START
-ENDC
IF _NARG == 2
-CURRENT_TABLE_START EQUS "\2"
+REDEF CURRENT_TABLE_START EQUS "\2"
ELSE
-CURRENT_TABLE_START EQUS "._table_width\@"
-CURRENT_TABLE_START:
+REDEF CURRENT_TABLE_START EQUS "._table_width\@"
+{CURRENT_TABLE_START}:
ENDC
ENDM
assert_table_length: MACRO
x = \1
- ASSERT x * CURRENT_TABLE_WIDTH == @ - CURRENT_TABLE_START, \
+ ASSERT x * CURRENT_TABLE_WIDTH == @ - {CURRENT_TABLE_START}, \
"{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
ENDM
list_start: MACRO
list_index = 0
-IF DEF(CURRENT_LIST_START)
-PURGE CURRENT_LIST_START
-ENDC
IF _NARG == 1
-CURRENT_LIST_START EQUS "\1"
+REDEF CURRENT_LIST_START EQUS "\1"
ELSE
-CURRENT_LIST_START EQUS "._list_start\@"
-CURRENT_LIST_START:
+REDEF CURRENT_LIST_START EQUS "._list_start\@"
+{CURRENT_LIST_START}:
ENDC
ENDM
@@ -46,42 +40,36 @@ ENDM
def_grass_wildmons: MACRO
;\1: encounter rate
-if DEF(CURRENT_GRASS_WILDMONS_LABEL)
-PURGE CURRENT_GRASS_WILDMONS_LABEL
-endc
CURRENT_GRASS_WILDMONS_RATE = \1
-CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1"
-CURRENT_GRASS_WILDMONS_LABEL:
+REDEF CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1"
+{CURRENT_GRASS_WILDMONS_LABEL}:
db \1
ENDM
end_grass_wildmons: MACRO
IF CURRENT_GRASS_WILDMONS_RATE == 0
- assert 1 == @ - CURRENT_GRASS_WILDMONS_LABEL, \
+ assert 1 == @ - {CURRENT_GRASS_WILDMONS_LABEL}, \
"def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected 1 byte"
ELSE
- assert WILDDATA_LENGTH == @ - CURRENT_GRASS_WILDMONS_LABEL, \
+ assert WILDDATA_LENGTH == @ - {CURRENT_GRASS_WILDMONS_LABEL}, \
"def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected {d:WILDDATA_LENGTH} bytes"
ENDC
ENDM
def_water_wildmons: MACRO
;\1: encounter rate
-if DEF(CURRENT_WATER_WILDMONS_LABEL)
-PURGE CURRENT_WATER_WILDMONS_LABEL
-endc
CURRENT_WATER_WILDMONS_RATE = \1
-CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1"
-CURRENT_WATER_WILDMONS_LABEL:
+REDEF CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1"
+{CURRENT_WATER_WILDMONS_LABEL}:
db \1
ENDM
end_water_wildmons: MACRO
IF CURRENT_WATER_WILDMONS_RATE == 0
- assert 1 == @ - CURRENT_WATER_WILDMONS_LABEL, \
+ assert 1 == @ - {CURRENT_WATER_WILDMONS_LABEL}, \
"def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected 1 byte"
ELSE
- assert WILDDATA_LENGTH == @ - CURRENT_WATER_WILDMONS_LABEL, \
+ assert WILDDATA_LENGTH == @ - {CURRENT_WATER_WILDMONS_LABEL}, \
"def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected {d:WILDDATA_LENGTH} bytes"
ENDC
ENDM
diff --git a/macros/data.asm b/macros/data.asm
index 486d23a6..f9274392 100644
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -19,33 +19,23 @@ money EQUS "bcd3"
; used in data/pokemon/base_stats/*.asm
tmhm: MACRO
; initialize bytes to 0
-n = 0
-REPT (NUM_TM_HM + 7) / 8
-_TM_BYTE EQUS "_tm{d:n}"
-_TM_BYTE = 0
-PURGE _TM_BYTE
-n = n + 1
+FOR n, (NUM_TM_HM + 7) / 8
+_tm{d:n} = 0
ENDR
; set bits of bytes
REPT _NARG
IF DEF(\1_TMNUM)
n = (\1_TMNUM - 1) / 8
i = (\1_TMNUM - 1) % 8
-_TM_BYTE EQUS "_tm{d:n}"
-_TM_BYTE = _TM_BYTE | (1 << i)
-PURGE _TM_BYTE
+_tm{d:n} = _tm{d:n} | (1 << i)
ELSE
FAIL "\1 is not a TM or HM move"
ENDC
SHIFT
ENDR
; output bytes
-n = 0
-REPT (NUM_TM_HM + 7) / 8
-_TM_BYTE EQUS "_tm{d:n}"
- db _TM_BYTE
-PURGE _TM_BYTE
-n = n + 1
+FOR n, (NUM_TM_HM + 7) / 8
+ db _tm{d:n}
ENDR
ENDM
diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm
index 83c938c0..a5f7113d 100644
--- a/macros/scripts/events.asm
+++ b/macros/scripts/events.asm
@@ -215,8 +215,8 @@ ENDM
SetEvents: MACRO
SetEvent \1
REPT _NARG - 1
- SetEventReuseHL \2
- SHIFT
+ SetEventReuseHL \2
+ SHIFT
ENDR
ENDM
@@ -267,8 +267,8 @@ ENDM
ResetEvents: MACRO
ResetEvent \1
REPT _NARG - 1
- ResetEventReuseHL \2
- SHIFT
+ ResetEventReuseHL \2
+ SHIFT
ENDR
ENDM
diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm
index 204098ad..8ab5c46d 100644
--- a/macros/scripts/maps.asm
+++ b/macros/scripts/maps.asm
@@ -1,10 +1,7 @@
def_objects: MACRO
- IF DEF(_NUM_OBJECTS)
- PURGE _NUM_OBJECTS
- ENDC
-_NUM_OBJECTS EQUS "_NUM_OBJECTS_\@"
- db _NUM_OBJECTS
-_NUM_OBJECTS = 0
+REDEF _NUM_OBJECTS EQUS "_NUM_OBJECTS_\@"
+ db {_NUM_OBJECTS}
+{_NUM_OBJECTS} = 0
ENDM
;\1 sprite id
@@ -32,16 +29,13 @@ object: MACRO
ELSE
db \6
ENDC
-_NUM_OBJECTS = _NUM_OBJECTS + 1
+{_NUM_OBJECTS} = {_NUM_OBJECTS} + 1
ENDM
def_warps: MACRO
- IF DEF(_NUM_WARPS)
- PURGE _NUM_WARPS
- ENDC
-_NUM_WARPS EQUS "_NUM_WARPS_\@"
- db _NUM_WARPS
-_NUM_WARPS = 0
+REDEF _NUM_WARPS EQUS "_NUM_WARPS_\@"
+ db {_NUM_WARPS}
+{_NUM_WARPS} = 0
ENDM
;\1 x position
@@ -50,19 +44,15 @@ ENDM
;\4 destination map (-1 = wLastMap)
warp: MACRO
db \2, \1, \3, \4
-_TMP EQUS "\n_WARP_{d:{_NUM_WARPS}}_X = \1\n_WARP_{d:{_NUM_WARPS}}_Y = \2"
- _TMP
- PURGE _TMP
-_NUM_WARPS = _NUM_WARPS + 1
+_WARP_{d:{_NUM_WARPS}}_X = \1
+_WARP_{d:{_NUM_WARPS}}_Y = \2
+{_NUM_WARPS} = {_NUM_WARPS} + 1
ENDM
def_signs: MACRO
- IF DEF(_NUM_SIGNS)
- PURGE _NUM_SIGNS
- ENDC
-_NUM_SIGNS EQUS "_NUM_SIGNS_\@"
- db _NUM_SIGNS
-_NUM_SIGNS = 0
+REDEF _NUM_SIGNS EQUS "_NUM_SIGNS_\@"
+ db {_NUM_SIGNS}
+{_NUM_SIGNS} = 0
ENDM
;\1 x position
@@ -70,17 +60,13 @@ ENDM
;\3 sign id
sign: MACRO
db \2, \1, \3
-_NUM_SIGNS = _NUM_SIGNS + 1
+{_NUM_SIGNS} = {_NUM_SIGNS} + 1
ENDM
;\1 source map
def_warps_to: MACRO
-N = 0
- REPT _NUM_WARPS
-_TMP EQUS "warp_to _WARP_{d:N}_X, _WARP_{d:N}_Y, \1_WIDTH"
- _TMP
- PURGE _TMP
-N = N + 1
+ FOR n, _NUM_WARPS
+ warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
ENDM
@@ -146,10 +132,8 @@ ENDM
; Comes after map_header and connection macros
end_map_header: MACRO
- dw CURRENT_MAP_OBJECT
- PURGE CURRENT_MAP_WIDTH
- PURGE CURRENT_MAP_HEIGHT
- PURGE CURRENT_MAP_OBJECT
+ dw {CURRENT_MAP_OBJECT}
+ PURGE CURRENT_MAP_WIDTH, CURRENT_MAP_HEIGHT, CURRENT_MAP_OBJECT
ENDM
; Connections go in order: north, south, west, east
diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm
index 2ec1de43..38e56b77 100644
--- a/macros/scripts/text.asm
+++ b/macros/scripts/text.asm
@@ -169,10 +169,9 @@ ENDM
script_mart: MACRO
db TX_SCRIPT_MART
db _NARG ; number of items
-REPT _NARG
- db \1 ; item id
- SHIFT
-ENDR
+ IF _NARG
+ db \# ; all item ids
+ ENDC
db -1 ; end
ENDM
diff --git a/rgbdscheck.asm b/rgbdscheck.asm
index 63df3575..59810eac 100644
--- a/rgbdscheck.asm
+++ b/rgbdscheck.asm
@@ -1,14 +1,18 @@
-; pokered requires rgbds 0.4.2 or newer.
MAJOR EQU 0
-MINOR EQU 4
-PATCH EQU 2
+MINOR EQU 5
+PATCH EQU 0
+
+wrong_rgbds: MACRO
+ fail "pokered requires rgbds v0.5.0 or newer."
+ENDM
IF !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__)
- fail "pokered requires rgbds 0.4.2 or newer."
+ wrong_rgbds
ELSE
IF (__RGBDS_MAJOR__ < MAJOR) || \
(__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ < MINOR) || \
- (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ < PATCH)
- fail "pokered requires rgbds 0.4.2 or newer."
+ (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ < PATCH) || \
+ (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ == PATCH && DEF(__RGBDS_RC__))
+ wrong_rgbds
ENDC
ENDC
diff --git a/tools/Makefile b/tools/Makefile
index f8dceb1a..6bea053d 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,7 +1,7 @@
.PHONY: all clean
CC := gcc
-CFLAGS := -O3 -std=c99 -Wall -Wextra -pedantic
+CFLAGS := -O3 -std=c99 -Wall -Wextra -Wno-missing-field-initializers
tools := scan_includes gfx pkmncompress pcm
diff --git a/tools/unnamed.py b/tools/unnamed.py
index bee4e29b..db743051 100755
--- a/tools/unnamed.py
+++ b/tools/unnamed.py
@@ -82,14 +82,14 @@ for objfile in objects:
elif magic == b'RGB9':
obj_ver = 10 + unpack_file("<I", f)[0]
- if obj_ver not in [6, 10, 11, 12, 13, 15, 16]:
+ if obj_ver not in [6, 10, 11, 12, 13, 15, 16, 17]:
print("Error: File '%s' is of an unknown format." % objfile, file=stderr)
exit(1)
num_symbols = unpack_file("<I", f)[0]
unpack_file("<I", f) # skip num sections
- if obj_ver in [16]:
+ if obj_ver in [16, 17]:
node_filenames = []
num_nodes = unpack_file("<I", f)[0]
for x in range(num_nodes):
@@ -109,7 +109,7 @@ for objfile in objects:
sym_type = symtype(unpack_file("<B", f)[0] & 0x7f)
if sym_type == symtype.IMPORT:
continue
- if obj_ver in [16]:
+ if obj_ver in [16, 17]:
sym_fileno = unpack_file("<I", f)[0]
sym_filename = node_filenames[sym_fileno]
else: