RGBDS syntax updates (#358)

New MACRO and DEF syntax
This commit is contained in:
vulcandth 2022-06-06 16:25:31 -05:00 committed by GitHub
parent d7808d110f
commit 6b5be9129c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
101 changed files with 958 additions and 958 deletions

View file

@ -1,4 +1,4 @@
audio_header: MACRO
MACRO audio_header
db (_NARG - 2) << 6 | \2
dw \1_\2
IF _NARG > 2
@ -24,7 +24,7 @@ ENDM
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
const pitch_sweep_cmd ; $10
pitch_sweep: MACRO
MACRO pitch_sweep
db pitch_sweep_cmd
IF \2 < 0
db (\1 << 4) | (%1000 | (\2 * -1))
@ -41,8 +41,8 @@ ENDM
; fade: positive value means decrease in volume, negative value means increase in volume
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
square_note_cmd EQU sfx_note_cmd ; $20
square_note: MACRO
DEF square_note_cmd EQU sfx_note_cmd ; $20
MACRO square_note
db square_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@ -56,8 +56,8 @@ ENDM
; fade: positive value means decrease in volume, negative value means increase in volume
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
noise_note_cmd EQU sfx_note_cmd ; $20
noise_note: MACRO
DEF noise_note_cmd EQU sfx_note_cmd ; $20
MACRO noise_note
db noise_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@ -68,7 +68,7 @@ noise_note: MACRO
ENDM
; arguments: pitch, length [1, 16]
note: MACRO
MACRO note
db (\1 << 4) | (\2 - 1)
ENDM
@ -76,7 +76,7 @@ ENDM
; arguments: instrument [1, 19], length [1, 16]
const drum_note_cmd ; $b0
drum_note: MACRO
MACRO drum_note
db drum_note_cmd | (\2 - 1)
db \1
ENDM
@ -85,7 +85,7 @@ ENDM
; like drum_note but one 1 byte instead of 2
; can only be used with instruments 1-10, excluding 2
; unused
drum_note_short: MACRO
MACRO drum_note_short
db (\1 << 4) | (\2 - 1)
ENDM
@ -93,7 +93,7 @@ ENDM
; arguments: length [1, 16]
const rest_cmd ; $c0
rest: MACRO
MACRO rest
db rest_cmd | (\1 - 1)
ENDM
@ -104,7 +104,7 @@ ENDM
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
const note_type_cmd ; $d0
note_type: MACRO
MACRO note_type
db note_type_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@ -114,8 +114,8 @@ note_type: MACRO
ENDM
; arguments: speed [0, 15]
drum_speed_cmd EQU note_type_cmd ; $d0
drum_speed: MACRO
DEF drum_speed_cmd EQU note_type_cmd ; $d0
MACRO drum_speed
db drum_speed_cmd | \1
ENDM
@ -123,7 +123,7 @@ ENDM
; arguments: octave [1, 8]
const octave_cmd ; $e0
octave: MACRO
MACRO octave
db octave_cmd | (8 - \1)
ENDM
@ -131,7 +131,7 @@ ENDM
; when enabled, effective frequency used is incremented by 1
const toggle_perfect_pitch_cmd ; $e8
toggle_perfect_pitch: MACRO
MACRO toggle_perfect_pitch
db toggle_perfect_pitch_cmd
ENDM
@ -142,7 +142,7 @@ ENDM
; depth: amplitude of vibrato wave
; rate: frequency of vibrato wave
const vibrato_cmd ; $ea
vibrato: MACRO
MACRO vibrato
db vibrato_cmd
db \1
db (\2 << 4) | \3
@ -150,7 +150,7 @@ ENDM
; arguments: length [1, 256], octave [1, 8], pitch
const pitch_slide_cmd ; $eb
pitch_slide: MACRO
MACRO pitch_slide
db pitch_slide_cmd
db \1 - 1
db ((8 - \2) << 4) | \3
@ -158,7 +158,7 @@ ENDM
; arguments: duty cycle [0, 3] (12.5%, 25%, 50%, 75%)
const duty_cycle_cmd ; $ec
duty_cycle: MACRO
MACRO duty_cycle
db duty_cycle_cmd
db \1
ENDM
@ -170,27 +170,27 @@ ENDM
; if larger than $100, large note speed or note length values might cause overflow
; stored in big endian
const tempo_cmd ; $ed
tempo: MACRO
MACRO tempo
db tempo_cmd
db HIGH(\1), LOW(\1)
ENDM
; arguments: left output enable mask, right output enable mask
const stereo_panning_cmd ; $ee
stereo_panning: MACRO
MACRO stereo_panning
db stereo_panning_cmd
db (\1 << 4) | \2
ENDM
const unknownmusic0xef_cmd ; $ef
unknownmusic0xef: MACRO
MACRO unknownmusic0xef
db unknownmusic0xef_cmd
db \1
ENDM
; arguments: left master volume [0, 7], right master volume [0, 7]
const volume_cmd ; $f0
volume: MACRO
MACRO volume
db volume_cmd
db (\1 << 4) | \2
ENDM
@ -199,7 +199,7 @@ ENDM
; when enabled, the sfx data is interpreted as music data
const execute_music_cmd ; $f8
execute_music: MACRO
MACRO execute_music
db execute_music_cmd
ENDM
@ -207,27 +207,27 @@ ENDM
; arguments: duty cycle 1, duty cycle 2, duty cycle 3, duty cycle 4
const duty_cycle_pattern_cmd ; $fc
duty_cycle_pattern: MACRO
MACRO duty_cycle_pattern
db duty_cycle_pattern_cmd
db \1 << 6 | \2 << 4 | \3 << 2 | \4
ENDM
; arguments: address
const sound_call_cmd ; $fd
sound_call: MACRO
MACRO sound_call
db sound_call_cmd
dw \1
ENDM
; arguments: count, address
const sound_loop_cmd ; $fe
sound_loop: MACRO
MACRO sound_loop
db sound_loop_cmd
db \1
dw \2
ENDM
const sound_ret_cmd ; $ff
sound_ret: MACRO
MACRO sound_ret
db sound_ret_cmd
ENDM

View file

@ -1,7 +1,7 @@
;\1 = event index
;\2 = return result in carry instead of zero flag
CheckEvent: MACRO
event_byte = ((\1) / 8)
MACRO CheckEvent
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
IF _NARG > 1
@ -19,9 +19,9 @@ ENDM
;\1 = event index
CheckEventReuseA: MACRO
MACRO CheckEventReuseA
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDC
@ -31,10 +31,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
CheckEventAfterBranchReuseA: MACRO
event_byte = ((\2) / 8)
MACRO CheckEventAfterBranchReuseA
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDC
@ -45,7 +45,7 @@ ENDM
;\1 = reg
;\2 = event index
;\3 = event index this event is relative to (optional, this is needed when there is a fixed flag address)
EventFlagBit: MACRO
MACRO EventFlagBit
IF _NARG > 2
ld \1, ((\3) % 8) + ((\2) - (\3))
ELSE
@ -56,24 +56,24 @@ ENDM
;\1 = reg
;\2 = event index
EventFlagAddress: MACRO
event_byte = ((\2) / 8)
MACRO EventFlagAddress
DEF event_byte = ((\2) / 8)
ld \1, wEventFlags + event_byte
ENDM
;\1 = event index
CheckEventHL: MACRO
event_byte = ((\1) / 8)
MACRO CheckEventHL
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
ENDM
;\1 = event index
CheckEventReuseHL: MACRO
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO CheckEventReuseHL
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -83,18 +83,18 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
CheckEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
MACRO CheckEventForceReuseHL
DEF event_byte = ((\1) / 8)
bit (\1) % 8, [hl]
ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
CheckEventAfterBranchReuseHL: MACRO
event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO CheckEventAfterBranchReuseHL
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -103,8 +103,8 @@ ENDM
;\1 = event index
CheckAndSetEvent: MACRO
event_byte = ((\1) / 8)
MACRO CheckAndSetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
set (\1) % 8, [hl]
@ -112,8 +112,8 @@ ENDM
;\1 = event index
CheckAndResetEvent: MACRO
event_byte = ((\1) / 8)
MACRO CheckAndResetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
res (\1) % 8, [hl]
@ -121,7 +121,7 @@ ENDM
;\1 = event index
CheckAndSetEventA: MACRO
MACRO CheckAndSetEventA
ld a, [wEventFlags + ((\1) / 8)]
bit (\1) % 8, a
set (\1) % 8, a
@ -130,7 +130,7 @@ ENDM
;\1 = event index
CheckAndResetEventA: MACRO
MACRO CheckAndResetEventA
ld a, [wEventFlags + ((\1) / 8)]
bit (\1) % 8, a
res (\1) % 8, a
@ -139,17 +139,17 @@ ENDM
;\1 = event index
SetEvent: MACRO
event_byte = ((\1) / 8)
MACRO SetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
set (\1) % 8, [hl]
ENDM
;\1 = event index
SetEventReuseHL: MACRO
MACRO SetEventReuseHL
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -159,10 +159,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
SetEventAfterBranchReuseHL: MACRO
event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO SetEventAfterBranchReuseHL
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -172,8 +172,8 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
SetEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
MACRO SetEventForceReuseHL
DEF event_byte = ((\1) / 8)
set (\1) % 8, [hl]
ENDM
@ -181,7 +181,7 @@ ENDM
;\1 = event index
;\2 = event index
;\3, \4, ... = additional (optional) event indices
SetEvents: MACRO
MACRO SetEvents
SetEvent \1
REPT _NARG - 1
SetEventReuseHL \2
@ -191,17 +191,17 @@ ENDM
;\1 = event index
ResetEvent: MACRO
event_byte = ((\1) / 8)
MACRO ResetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
res (\1) % 8, [hl]
ENDM
;\1 = event index
ResetEventReuseHL: MACRO
MACRO ResetEventReuseHL
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -211,10 +211,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
ResetEventAfterBranchReuseHL: MACRO
event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO ResetEventAfterBranchReuseHL
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -224,8 +224,8 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
ResetEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
MACRO ResetEventForceReuseHL
DEF event_byte = ((\1) / 8)
res (\1) % 8, [hl]
ENDM
@ -233,7 +233,7 @@ ENDM
;\1 = event index
;\2 = event index
;\3 = event index (optional)
ResetEvents: MACRO
MACRO ResetEvents
ResetEvent \1
REPT _NARG - 1
ResetEventReuseHL \2
@ -244,9 +244,9 @@ ENDM
;\1 = start
;\2 = end
SetEventRange: MACRO
event_start_byte = ((\1) / 8)
event_end_byte = ((\2) / 8)
MACRO SetEventRange
DEF event_start_byte = ((\1) / 8)
DEF event_end_byte = ((\2) / 8)
IF event_end_byte < event_start_byte
FAIL "Incorrect argument order in SetEventRange."
@ -257,12 +257,12 @@ event_end_byte = ((\2) / 8)
or (1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))
ld [wEventFlags + event_start_byte], a
ELSE
event_fill_start = event_start_byte + 1
event_fill_count = event_end_byte - event_start_byte - 1
DEF event_fill_start = event_start_byte + 1
DEF event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
event_fill_start -= 1
event_fill_count += 1
DEF event_fill_start -= 1
DEF event_fill_count += 1
ELSE
ld a, [wEventFlags + event_start_byte]
or $ff - ((1 << ((\1) % 8)) - 1)
@ -270,7 +270,7 @@ event_fill_count += 1
ENDC
IF ((\2) % 8) == 7
event_fill_count += 1
DEF event_fill_count += 1
ENDC
IF event_fill_count == 1
@ -306,9 +306,9 @@ ENDM
;\1 = start
;\2 = end
;\3 = assume a is 0 if present
ResetEventRange: MACRO
event_start_byte = ((\1) / 8)
event_end_byte = ((\2) / 8)
MACRO ResetEventRange
DEF event_start_byte = ((\1) / 8)
DEF event_end_byte = ((\2) / 8)
IF event_end_byte < event_start_byte
FAIL "Incorrect argument order in ResetEventRange."
@ -319,12 +319,12 @@ event_end_byte = ((\2) / 8)
and ~((1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))) & $ff
ld [wEventFlags + event_start_byte], a
ELSE
event_fill_start = event_start_byte + 1
event_fill_count = event_end_byte - event_start_byte - 1
DEF event_fill_start = event_start_byte + 1
DEF event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
event_fill_start -= 1
event_fill_count += 1
DEF event_fill_start -= 1
DEF event_fill_count += 1
ELSE
ld a, [wEventFlags + event_start_byte]
and ~($ff - ((1 << ((\1) % 8)) - 1)) & $ff
@ -332,7 +332,7 @@ event_fill_count += 1
ENDC
IF ((\2) % 8) == 7
event_fill_count += 1
DEF event_fill_count += 1
ENDC
IF event_fill_count == 1
@ -375,10 +375,10 @@ ENDM
;\1 = event index 1
;\2 = event index 2
;\3 = try to reuse a (optional)
CheckBothEventsSet: MACRO
MACRO CheckBothEventsSet
IF ((\1) / 8) == ((\2) / 8)
IF (_NARG < 3) || (((\1) / 8) != event_byte)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + ((\1) / 8)]
ENDC
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
@ -411,7 +411,7 @@ ENDM
; returns the complement of whether either event is set in Z flag
;\1 = event index 1
;\2 = event index 2
CheckEitherEventSet: MACRO
MACRO CheckEitherEventSet
IF ((\1) / 8) == ((\2) / 8)
ld a, [wEventFlags + ((\1) / 8)]
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
@ -441,7 +441,7 @@ ENDM
; for handling fixed event bits when events are inserted/removed
;\1 = event index
;\2 = fixed flag bit
AdjustEventBit: MACRO
MACRO AdjustEventBit
IF ((\1) % 8) != (\2)
add ((\1) % 8) - (\2)
ENDC

View file

@ -1,7 +1,7 @@
def_object_events: MACRO
REDEF _NUM_OBJECT_EVENTS EQUS "_NUM_OBJECT_EVENTS_\@"
MACRO def_object_events
REDEF _NUM_OBJECT_EVENTS EQUS "_NUM_OBJECT_EVENTS_\@"
db {_NUM_OBJECT_EVENTS}
{_NUM_OBJECT_EVENTS} = 0
DEF {_NUM_OBJECT_EVENTS} = 0
ENDM
;\1 x position
@ -13,7 +13,7 @@ ENDM
;\7 items only: item id
;\7 trainers only: trainer class/pokemon id
;\8 trainers only: trainer number/pokemon level
object_event: MACRO
MACRO object_event
db \3
db \2 + 4
db \1 + 4
@ -29,42 +29,42 @@ object_event: MACRO
ELSE
db \6
ENDC
{_NUM_OBJECT_EVENTS} += 1
DEF {_NUM_OBJECT_EVENTS} += 1
ENDM
def_warp_events: MACRO
REDEF _NUM_WARP_EVENTS EQUS "_NUM_WARP_EVENTS_\@"
MACRO def_warp_events
REDEF _NUM_WARP_EVENTS EQUS "_NUM_WARP_EVENTS_\@"
db {_NUM_WARP_EVENTS}
{_NUM_WARP_EVENTS} = 0
DEF {_NUM_WARP_EVENTS} = 0
ENDM
;\1 x position
;\2 y position
;\3 destination map (-1 = wLastMap)
;\4 destination warp id; starts at 1 (internally at 0)
warp_event: MACRO
MACRO warp_event
db \2, \1, \4 - 1, \3
_WARP_{d:{_NUM_WARP_EVENTS}}_X = \1
_WARP_{d:{_NUM_WARP_EVENTS}}_Y = \2
{_NUM_WARP_EVENTS} += 1
DEF _WARP_{d:{_NUM_WARP_EVENTS}}_X = \1
DEF _WARP_{d:{_NUM_WARP_EVENTS}}_Y = \2
DEF {_NUM_WARP_EVENTS} += 1
ENDM
def_bg_events: MACRO
REDEF _NUM_BG_EVENTS EQUS "_NUM_BG_EVENTS_\@"
MACRO def_bg_events
REDEF _NUM_BG_EVENTS EQUS "_NUM_BG_EVENTS_\@"
db {_NUM_BG_EVENTS}
{_NUM_BG_EVENTS} = 0
DEF {_NUM_BG_EVENTS} = 0
ENDM
;\1 x position
;\2 y position
;\3 sign id
bg_event: MACRO
MACRO bg_event
db \2, \1, \3
{_NUM_BG_EVENTS} += 1
DEF {_NUM_BG_EVENTS} += 1
ENDM
;\1 source map
def_warps_to: MACRO
MACRO def_warps_to
FOR n, _NUM_WARP_EVENTS
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
@ -73,18 +73,18 @@ ENDM
;\1 x position
;\2 y position
;\3 map width
warp_to: MACRO
MACRO warp_to
event_displacement \3, \1, \2
ENDM
;\1 first bit offset / first object id
def_trainers: MACRO
IF _NARG == 1
CURRENT_TRAINER_BIT = \1
ELSE
CURRENT_TRAINER_BIT = 1
ENDC
MACRO def_trainers
IF _NARG == 1
DEF CURRENT_TRAINER_BIT = \1
ELSE
DEF CURRENT_TRAINER_BIT = 1
ENDC
ENDM
;\1 event flag
@ -92,22 +92,22 @@ ENDM
;\3 TextBeforeBattle
;\4 TextAfterBattle
;\5 TextEndBattle
trainer: MACRO
_ev_bit = \1 % 8
_cur_bit = CURRENT_TRAINER_BIT % 8
MACRO trainer
DEF _ev_bit = \1 % 8
DEF _cur_bit = CURRENT_TRAINER_BIT % 8
ASSERT _ev_bit == _cur_bit, \
"Expected \1 to be bit {d:_cur_bit}, got {d:_ev_bit}"
db CURRENT_TRAINER_BIT
db \2 << 4
dw wEventFlags + (\1 - CURRENT_TRAINER_BIT) / 8
dw \3, \5, \4, \4
CURRENT_TRAINER_BIT += 1
DEF CURRENT_TRAINER_BIT += 1
ENDM
;\1 x position
;\2 y position
;\3 movement data
map_coord_movement: MACRO
MACRO map_coord_movement
dbmapcoord \1, \2
dw \3
ENDM
@ -117,10 +117,10 @@ ENDM
;\2 map id
;\3 tileset
;\4 connections: combo of NORTH, SOUTH, WEST, and/or EAST, or 0 for none
map_header: MACRO
CURRENT_MAP_WIDTH = \2_WIDTH
CURRENT_MAP_HEIGHT = \2_HEIGHT
CURRENT_MAP_OBJECT EQUS "\1_Object"
MACRO map_header
DEF CURRENT_MAP_WIDTH = \2_WIDTH
DEF CURRENT_MAP_HEIGHT = \2_HEIGHT
DEF CURRENT_MAP_OBJECT EQUS "\1_Object"
\1_h::
db \3
db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH
@ -131,7 +131,7 @@ CURRENT_MAP_OBJECT EQUS "\1_Object"
ENDM
; Comes after map_header and connection macros
end_map_header: MACRO
MACRO end_map_header
dw {CURRENT_MAP_OBJECT}
PURGE CURRENT_MAP_WIDTH, CURRENT_MAP_HEIGHT, CURRENT_MAP_OBJECT
ENDM
@ -142,63 +142,63 @@ ENDM
;\3 map id
;\4 offset of the target map relative to the current map
; (x offset for east/west, y offset for north/south)
connection: MACRO
MACRO connection
; Calculate tile offsets for source (current) and target maps
_src = 0
_tgt = (\4) + 3
IF _tgt < 2
_src = -_tgt
_tgt = 0
ENDC
; Calculate tile offsets for source (current) and target maps
DEF _src = 0
DEF _tgt = (\4) + 3
IF _tgt < 2
DEF _src = -_tgt
DEF _tgt = 0
ENDC
IF !STRCMP("\1", "north")
_blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
_map = _tgt
_win = (\3_WIDTH + 6) * \3_HEIGHT + 1
_y = \3_HEIGHT * 2 - 1
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
_len = \3_WIDTH
ENDC
IF !STRCMP("\1", "north")
DEF _blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
DEF _map = _tgt
DEF _win = (\3_WIDTH + 6) * \3_HEIGHT + 1
DEF _y = \3_HEIGHT * 2 - 1
DEF _x = (\4) * -2
DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
DEF _len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "south")
_blk = _src
_map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
_win = \3_WIDTH + 7
_y = 0
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
_len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "south")
DEF _blk = _src
DEF _map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
DEF _win = \3_WIDTH + 7
DEF _y = 0
DEF _x = (\4) * -2
DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
DEF _len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "west")
_blk = (\3_WIDTH * _src) + \3_WIDTH - 3
_map = (CURRENT_MAP_WIDTH + 6) * _tgt
_win = (\3_WIDTH + 6) * 2 - 6
_y = (\4) * -2
_x = \3_WIDTH * 2 - 1
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
_len = \3_HEIGHT
ENDC
ELIF !STRCMP("\1", "west")
DEF _blk = (\3_WIDTH * _src) + \3_WIDTH - 3
DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt
DEF _win = (\3_WIDTH + 6) * 2 - 6
DEF _y = (\4) * -2
DEF _x = \3_WIDTH * 2 - 1
DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
DEF _len = \3_HEIGHT
ENDC
ELIF !STRCMP("\1", "east")
_blk = (\3_WIDTH * _src)
_map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
_win = \3_WIDTH + 7
_y = (\4) * -2
_x = 0
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
_len = \3_HEIGHT
ENDC
ELIF !STRCMP("\1", "east")
DEF _blk = (\3_WIDTH * _src)
DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
DEF _win = \3_WIDTH + 7
DEF _y = (\4) * -2
DEF _x = 0
DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
DEF _len = \3_HEIGHT
ENDC
ELSE
fail "Invalid direction for 'connection'."
ENDC
ELSE
fail "Invalid direction for 'connection'."
ENDC
db \3
dw \2_Blocks + _blk

View file

@ -1,44 +1,44 @@
text EQUS "db TX_START," ; Start writing text.
next EQUS "db \"<NEXT>\"," ; Move a line down.
line EQUS "db \"<LINE>\"," ; Start writing at the bottom line.
para EQUS "db \"<PARA>\"," ; Start a new paragraph.
cont EQUS "db \"<CONT>\"," ; Scroll to the next line.
done EQUS "db \"<DONE>\"" ; End a text box.
prompt EQUS "db \"<PROMPT>\"" ; Prompt the player to end a text box (initiating some other event).
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 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).
page EQUS "db \"<PAGE>\"," ; Start a new Pokédex page.
dex EQUS "db \"<DEXEND>\", \"@\"" ; End a Pokédex entry.
DEF page EQUS "db \"<PAGE>\"," ; Start a new Pokédex page.
DEF dex EQUS "db \"<DEXEND>\", \"@\"" ; End a Pokédex entry.
; TextCommandJumpTable indexes (see home/text.asm)
const_def
const TX_START ; $00
text_start: MACRO
MACRO text_start
db TX_START
ENDM
const TX_RAM ; $01
text_ram: MACRO
MACRO text_ram
db TX_RAM
dw \1 ; address to read from
ENDM
const TX_BCD ; $02
text_bcd: MACRO
MACRO text_bcd
db TX_BCD
dw \1 ; address to read from
db \2 ; number of bytes + print flags
ENDM
const TX_MOVE ; $03
text_move: MACRO
MACRO text_move
db TX_MOVE
dw \1 ; address of the new location
ENDM
const TX_BOX ; $04
text_box: MACRO
MACRO text_box
; draw box
db TX_BOX
dw \1 ; address of upper left corner
@ -46,27 +46,27 @@ text_box: MACRO
ENDM
const TX_LOW ; $05
text_low: MACRO
MACRO text_low
db TX_LOW
ENDM
const TX_PROMPT_BUTTON ; $06
text_promptbutton: MACRO
MACRO text_promptbutton
db TX_PROMPT_BUTTON
ENDM
const TX_SCROLL ; $07
text_scroll: MACRO
MACRO text_scroll
db TX_SCROLL
ENDM
const TX_START_ASM ; $08
text_asm: MACRO
MACRO text_asm
db TX_START_ASM
ENDM
const TX_NUM ; $09
text_decimal: MACRO
MACRO text_decimal
; print a big-endian decimal number.
db TX_NUM
dw \1 ; address to read from
@ -74,76 +74,76 @@ text_decimal: MACRO
ENDM
const TX_PAUSE ; $0a
text_pause: MACRO
MACRO text_pause
db TX_PAUSE
ENDM
const TX_SOUND_GET_ITEM_1 ; $0b
sound_get_item_1: MACRO
MACRO sound_get_item_1
db TX_SOUND_GET_ITEM_1
ENDM
TX_SOUND_LEVEL_UP EQU TX_SOUND_GET_ITEM_1
sound_level_up EQUS "sound_get_item_1"
DEF TX_SOUND_LEVEL_UP EQU TX_SOUND_GET_ITEM_1
DEF sound_level_up EQUS "sound_get_item_1"
const TX_DOTS ; $0c
text_dots: MACRO
MACRO text_dots
db TX_DOTS
db \1 ; number of ellipses to draw
ENDM
const TX_WAIT_BUTTON ; $0d
text_waitbutton: MACRO
MACRO text_waitbutton
db TX_WAIT_BUTTON
ENDM
const TX_SOUND_POKEDEX_RATING ; $0e
sound_pokedex_rating: MACRO
MACRO sound_pokedex_rating
db TX_SOUND_POKEDEX_RATING
ENDM
const TX_SOUND_GET_ITEM_1_DUPLICATE ; $0f
sound_get_item_1_duplicate: MACRO
MACRO sound_get_item_1_duplicate
db TX_SOUND_GET_ITEM_1_DUPLICATE
ENDM
const TX_SOUND_GET_ITEM_2 ; $10
sound_get_item_2: MACRO
MACRO sound_get_item_2
db TX_SOUND_GET_ITEM_2
ENDM
const TX_SOUND_GET_KEY_ITEM ; $11
sound_get_key_item: MACRO
MACRO sound_get_key_item
db TX_SOUND_GET_KEY_ITEM
ENDM
const TX_SOUND_CAUGHT_MON ; $12
sound_caught_mon: MACRO
MACRO sound_caught_mon
db TX_SOUND_CAUGHT_MON
ENDM
const TX_SOUND_DEX_PAGE_ADDED ; $13
sound_dex_page_added: MACRO
MACRO sound_dex_page_added
db TX_SOUND_DEX_PAGE_ADDED
ENDM
const TX_SOUND_CRY_NIDORINA ; $14
sound_cry_nidorina: MACRO
MACRO sound_cry_nidorina
db TX_SOUND_CRY_NIDORINA
ENDM
const TX_SOUND_CRY_PIDGEOT ; $15
sound_cry_pidgeot: MACRO
MACRO sound_cry_pidgeot
db TX_SOUND_CRY_PIDGEOT
ENDM
const TX_SOUND_CRY_DEWGONG ; $16
sound_cry_dewgong: MACRO
MACRO sound_cry_dewgong
db TX_SOUND_CRY_DEWGONG
ENDM
const TX_FAR ; $17
text_far: MACRO
MACRO text_far
db TX_FAR
dab \1 ; address of text commands
ENDM
@ -152,7 +152,7 @@ ENDM
const_next $50
const TX_END ; $50
text_end: MACRO
MACRO text_end
db TX_END
ENDM
@ -161,12 +161,12 @@ ENDM
const_def -1, -1
const TX_SCRIPT_POKECENTER_NURSE ; $ff
script_pokecenter_nurse: MACRO
MACRO script_pokecenter_nurse
db TX_SCRIPT_POKECENTER_NURSE
ENDM
const TX_SCRIPT_MART ; $fe
script_mart: MACRO
MACRO script_mart
db TX_SCRIPT_MART
db _NARG ; number of items
IF _NARG
@ -176,12 +176,12 @@ script_mart: MACRO
ENDM
const TX_SCRIPT_BILLS_PC ; $fd
script_bills_pc: MACRO
MACRO script_bills_pc
db TX_SCRIPT_BILLS_PC
ENDM
const TX_SCRIPT_PLAYERS_PC ; $fc
script_players_pc: MACRO
MACRO script_players_pc
db TX_SCRIPT_PLAYERS_PC
ENDM
@ -190,23 +190,23 @@ ENDM
const_skip ; $fa
const TX_SCRIPT_POKECENTER_PC ; $f9
script_pokecenter_pc: MACRO
MACRO script_pokecenter_pc
db TX_SCRIPT_POKECENTER_PC
ENDM
const_skip ; $f8
const TX_SCRIPT_PRIZE_VENDOR ; $f7
script_prize_vendor: MACRO
MACRO script_prize_vendor
db TX_SCRIPT_PRIZE_VENDOR
ENDM
const TX_SCRIPT_CABLE_CLUB_RECEPTIONIST ; $f6
script_cable_club_receptionist: MACRO
MACRO script_cable_club_receptionist
db TX_SCRIPT_CABLE_CLUB_RECEPTIONIST
ENDM
const TX_SCRIPT_VENDING_MACHINE ; $f5
script_vending_machine: MACRO
MACRO script_vending_machine
db TX_SCRIPT_VENDING_MACHINE
ENDM