From 9878f01e29b1443d6c894c1332cbf381fa12646e Mon Sep 17 00:00:00 2001 From: Rangi Date: Fri, 3 Jul 2020 16:37:47 -0400 Subject: Organize macros/ like pokecrystal While doing so I replaced the StopAllMusic macro with a SFX_STOP_ALL_MUSIC constant and applied it throughout the code. --- macros/scripts/audio.asm | 186 ++++++++++++++++++ macros/scripts/events.asm | 471 ++++++++++++++++++++++++++++++++++++++++++++++ macros/scripts/maps.asm | 184 ++++++++++++++++++ macros/scripts/text.asm | 78 ++++++++ 4 files changed, 919 insertions(+) create mode 100755 macros/scripts/audio.asm create mode 100755 macros/scripts/events.asm create mode 100644 macros/scripts/maps.asm create mode 100755 macros/scripts/text.asm (limited to 'macros/scripts') diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm new file mode 100755 index 00000000..8a250c63 --- /dev/null +++ b/macros/scripts/audio.asm @@ -0,0 +1,186 @@ +audio_header: MACRO + db (_NARG - 2) << 6 | \2 + dw \1_\2 + IF _NARG > 2 + db \3 + dw \1_\3 + ENDC + IF _NARG > 3 + db \4 + dw \1_\4 + ENDC + IF _NARG > 4 + db \5 + dw \1_\5 + ENDC +ENDM + +; arguments: length [0, 7], pitch change [-7, 7] +; length: length of time between pitch shifts +; sometimes used with a value >7 in which case the MSB is ignored +; pitch change: positive value means increase in pitch, negative value means decrease in pitch +; 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 +pitch_sweep: MACRO + db $10 + IF \2 < 0 + db (\1 << 4) | (%1000 | (\2 * -1)) + ELSE + db (\1 << 4) | \2 + ENDC +ENDM + +; arguments: length [0, 15], volume [0, 15], fade [-7, 7], frequency +; 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: MACRO + db $20 | \1 + IF \3 < 0 + db (\2 << 4) | (%1000 | (\3 * -1)) + ELSE + db (\2 << 4) | \3 + ENDC + dw \4 +ENDM + +; arguments: length [0, 15], volume [0, 15], fade [-7, 7], frequency +; 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: MACRO + db $20 | \1 + IF \3 < 0 + db (\2 << 4) | (%1000 | (\3 * -1)) + ELSE + db (\2 << 4) | \3 + ENDC + db \4 +ENDM + +; arguments: pitch, length [1, 16] +note: MACRO + db (\1 << 4) | (\2 - 1) +ENDM + +; arguments: instrument [1, 19], length [1, 16] +drum_note: MACRO + db $B0 | (\2 - 1) + db \1 +ENDM + +; arguments: instrument, length [1, 16] +; 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 + db (\1 << 4) | (\2 - 1) +ENDM + +; arguments: length [1, 16] +rest: MACRO + db $C0 | (\1 - 1) +ENDM + +; arguments: speed [0, 15], volume [0, 15], fade [-7, 7] +; 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 +note_type: MACRO + db $D0 | \1 + IF \3 < 0 + db (\2 << 4) | (%1000 | (\3 * -1)) + ELSE + db (\2 << 4) | \3 + ENDC +ENDM + +; arguments: speed [0, 15] +drum_speed: MACRO + db $D0 | \1 +ENDM + +; arguments: octave [1, 8] +octave: MACRO + db $E8 - \1 +ENDM + +; when enabled, effective frequency used is incremented by 1 +toggle_perfect_pitch: MACRO + db $E8 +ENDM + +; arguments: delay [0, 255], depth [0, 15], rate [0, 15] +; delay: time delay until vibrato effect begins +; depth: amplitude of vibrato wave +; rate: frequency of vibrato wave +vibrato: MACRO + db $EA + db \1 + db (\2 << 4) | \3 +ENDM + +; arguments: length [1, 256], octave [1, 8], pitch +pitch_slide: MACRO + db $EB + db \1 - 1 + db ((8 - \2) << 4) | \3 +ENDM + +; arguments: duty cycle [0, 3] (12.5%, 25%, 50%, 75%) +duty_cycle: MACRO + db $EC + db \1 +ENDM + +; arguments: tempo [0, $ffff] +; used to calculate note delay counters +; so a smaller value means music plays faster +; ideally should be set to $100 or less to guarantee no overflow +; if larger than $100, large note speed or note length values might cause overflow +; stored in big endian +tempo: MACRO + db $ED + db \1 / $100 + db \1 % $100 +ENDM + +; arguments: left output enable mask, right output enable mask +stereo_panning: MACRO + db $EE + db (\1 << 4) | \2 +ENDM + +; arguments: left master volume [0, 7], right master volume [0, 7] +volume: MACRO + db $F0 + db (\1 << 4) | \2 +ENDM + +; when enabled, the sfx data is interpreted as music data +execute_music: MACRO + db $F8 +ENDM + +; arguments: duty cycle 1, duty cycle 2, duty cycle 3, duty cycle 4 +duty_cycle_pattern: MACRO + db $FC + db \1 << 6 | \2 << 4 | \3 << 2 | \4 +ENDM + +; arguments: address +sound_call: MACRO + db $FD + dw \1 +ENDM + +; arguments: count, address +sound_loop: MACRO + db $FE + db \1 + dw \2 +ENDM + +sound_ret: MACRO + db $FF +ENDM diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm new file mode 100755 index 00000000..9be354e3 --- /dev/null +++ b/macros/scripts/events.asm @@ -0,0 +1,471 @@ +;\1 = event index +;\2 = return result in carry instead of zero flag +CheckEvent: MACRO +event_byte = ((\1) / 8) + ld a, [wEventFlags + event_byte] + + IF _NARG > 1 + IF ((\1) % 8) == 7 + add a + ELSE + REPT ((\1) % 8) + 1 + rrca + ENDR + ENDC + ELSE + bit (\1) % 8, a + ENDC +ENDM + + +;\1 = event index +CheckEventReuseA: MACRO + IF event_byte != ((\1) / 8) +event_byte = ((\1) / 8) + ld a, [wEventFlags + event_byte] + ENDC + + bit (\1) % 8, a +ENDM + + +;\1 = event index +;\2 = event index of the last event used before the branch +CheckEventAfterBranchReuseA: MACRO +event_byte = ((\2) / 8) + IF event_byte != ((\1) / 8) +event_byte = ((\1) / 8) + ld a, [wEventFlags + event_byte] + ENDC + + bit (\1) % 8, a +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 + IF _NARG > 2 + ld \1, ((\3) % 8) + ((\2) - (\3)) + ELSE + ld \1, (\2) % 8 + ENDC +ENDM + + +;\1 = reg +;\2 = event index +EventFlagAddress: MACRO +event_byte = ((\2) / 8) + ld \1, wEventFlags + event_byte +ENDM + + +;\1 = event index +CheckEventHL: MACRO +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) + ld hl, wEventFlags + event_byte + ENDC + + bit (\1) % 8, [hl] +ENDM + + +; dangerous, only use when HL is guaranteed to be the desired value +;\1 = event index +CheckEventForceReuseHL: MACRO +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) + ld hl, wEventFlags + event_byte + ENDC + + bit (\1) % 8, [hl] +ENDM + + +;\1 = event index +CheckAndSetEvent: MACRO +event_byte = ((\1) / 8) + ld hl, wEventFlags + event_byte + bit (\1) % 8, [hl] + set (\1) % 8, [hl] +ENDM + + +;\1 = event index +CheckAndResetEvent: MACRO +event_byte = ((\1) / 8) + ld hl, wEventFlags + event_byte + bit (\1) % 8, [hl] + res (\1) % 8, [hl] +ENDM + + +;\1 = event index +CheckAndSetEventA: MACRO + ld a, [wEventFlags + ((\1) / 8)] + bit (\1) % 8, a + set (\1) % 8, a + ld [wEventFlags + ((\1) / 8)], a +ENDM + + +;\1 = event index +CheckAndResetEventA: MACRO + ld a, [wEventFlags + ((\1) / 8)] + bit (\1) % 8, a + res (\1) % 8, a + ld [wEventFlags + ((\1) / 8)], a +ENDM + + +;\1 = event index +SetEvent: MACRO +event_byte = ((\1) / 8) + ld hl, wEventFlags + event_byte + set (\1) % 8, [hl] +ENDM + + +;\1 = event index +SetEventReuseHL: MACRO + IF event_byte != ((\1) / 8) +event_byte = ((\1) / 8) + ld hl, wEventFlags + event_byte + ENDC + + set (\1) % 8, [hl] +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) + ld hl, wEventFlags + event_byte + ENDC + + set (\1) % 8, [hl] +ENDM + + +; dangerous, only use when HL is guaranteed to be the desired value +;\1 = event index +SetEventForceReuseHL: MACRO +event_byte = ((\1) / 8) + set (\1) % 8, [hl] +ENDM + + +;\1 = event index +;\2 = event index +;\3, \4, ... = additional (optional) event indices +SetEvents: MACRO + SetEvent \1 + rept (_NARG + -1) + SetEventReuseHL \2 + shift + endr +ENDM + + +;\1 = event index +ResetEvent: MACRO +event_byte = ((\1) / 8) + ld hl, wEventFlags + event_byte + res (\1) % 8, [hl] +ENDM + + +;\1 = event index +ResetEventReuseHL: MACRO + IF event_byte != ((\1) / 8) +event_byte = ((\1) / 8) + ld hl, wEventFlags + event_byte + ENDC + + res (\1) % 8, [hl] +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) + ld hl, wEventFlags + event_byte + ENDC + + res (\1) % 8, [hl] +ENDM + + +; dangerous, only use when HL is guaranteed to be the desired value +;\1 = event index +ResetEventForceReuseHL: MACRO +event_byte = ((\1) / 8) + res (\1) % 8, [hl] +ENDM + + +;\1 = event index +;\2 = event index +;\3 = event index (optional) +ResetEvents: MACRO + ResetEvent \1 + rept (_NARG + -1) + ResetEventReuseHL \2 + shift + endr +ENDM + + +;\1 = event index +;\2 = number of bytes away from the base address (optional, for matching the ROM) +dbEventFlagBit: MACRO + IF _NARG > 1 + db ((\1) % 8) + ((\2) * 8) + ELSE + db ((\1) % 8) + ENDC +ENDM + + +;\1 = event index +;\2 = number of bytes away from the base address (optional, for matching the ROM) +dwEventFlagAddress: MACRO + IF _NARG > 1 + dw wEventFlags + ((\1) / 8) - (\2) + ELSE + dw wEventFlags + ((\1) / 8) + ENDC +ENDM + + +;\1 = start +;\2 = end +SetEventRange: MACRO +event_start_byte = ((\1) / 8) +event_end_byte = ((\2) / 8) + + IF event_end_byte < event_start_byte + FAIL "Incorrect argument order in SetEventRange." + ENDC + + IF event_start_byte == event_end_byte + ld a, [wEventFlags + event_start_byte] + 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 + + IF ((\1) % 8) == 0 +event_fill_start = event_fill_start + -1 +event_fill_count = event_fill_count + 1 + ELSE + ld a, [wEventFlags + event_start_byte] + or $ff - ((1 << ((\1) % 8)) - 1) + ld [wEventFlags + event_start_byte], a + ENDC + + IF ((\2) % 8) == 7 +event_fill_count = event_fill_count + 1 + ENDC + + IF event_fill_count == 1 + ld hl, wEventFlags + event_fill_start + ld [hl], $ff + ENDC + + IF event_fill_count > 1 + ld a, $ff + ld hl, wEventFlags + event_fill_start + + REPT event_fill_count + -1 + ld [hli], a + ENDR + + ld [hl], a + ENDC + + IF ((\2) % 8) == 0 + ld hl, wEventFlags + event_end_byte + set 0, [hl] + ELSE + IF ((\2) % 8) != 7 + ld a, [wEventFlags + event_end_byte] + or (1 << (((\2) % 8) + 1)) - 1 + ld [wEventFlags + event_end_byte], a + ENDC + ENDC + ENDC +ENDM + + +;\1 = start +;\2 = end +;\3 = assume a is 0 if present +ResetEventRange: MACRO +event_start_byte = ((\1) / 8) +event_end_byte = ((\2) / 8) + + IF event_end_byte < event_start_byte + FAIL "Incorrect argument order in ResetEventRange." + ENDC + + IF event_start_byte == event_end_byte + ld a, [wEventFlags + event_start_byte] + 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 + + IF ((\1) % 8) == 0 +event_fill_start = event_fill_start + -1 +event_fill_count = event_fill_count + 1 + ELSE + ld a, [wEventFlags + event_start_byte] + and ~($ff - ((1 << ((\1) % 8)) - 1)) & $ff + ld [wEventFlags + event_start_byte], a + ENDC + + IF ((\2) % 8) == 7 +event_fill_count = event_fill_count + 1 + ENDC + + IF event_fill_count == 1 + ld hl, wEventFlags + event_fill_start + ld [hl], 0 + ENDC + + IF event_fill_count > 1 + ld hl, wEventFlags + event_fill_start + + ; force xor a if we just to wrote to it above + IF (_NARG < 3) || (((\1) % 8) != 0) + xor a + ENDC + + REPT event_fill_count + -1 + ld [hli], a + ENDR + + ld [hl], a + ENDC + + IF ((\2) % 8) == 0 + ld hl, wEventFlags + event_end_byte + res 0, [hl] + ELSE + IF ((\2) % 8) != 7 + ld a, [wEventFlags + event_end_byte] + and ~((1 << (((\2) % 8) + 1)) - 1) & $ff + ld [wEventFlags + event_end_byte], a + ENDC + ENDC + ENDC +ENDM + + +; returns whether both events are set in Z flag +; This is counter-intuitive because the other event checks set the Z flag when +; the event is not set, but this sets the Z flag when the event is set. +;\1 = event index 1 +;\2 = event index 2 +;\3 = try to reuse a (optional) +CheckBothEventsSet: MACRO + IF ((\1) / 8) == ((\2) / 8) + IF (_NARG < 3) || (((\1) / 8) != event_byte) +event_byte = ((\1) / 8) + ld a, [wEventFlags + ((\1) / 8)] + ENDC + and (1 << ((\1) % 8)) | (1 << ((\2) % 8)) + cp (1 << ((\1) % 8)) | (1 << ((\2) % 8)) + ELSE + ; This case doesn't happen in the original ROM. + IF ((\1) % 8) == ((\2) % 8) + push hl + ld a, [wEventFlags + ((\1) / 8)] + ld hl, wEventFlags + ((\2) / 8) + and [hl] + cpl + bit ((\1) % 8), a + pop hl + ELSE + push bc + ld a, [wEventFlags + ((\1) / 8)] + and (1 << ((\1) % 8)) + ld b, a + ld a, [wEventFlags + ((\2) / 8)] + and (1 << ((\2) % 8)) + or b + cp (1 << ((\1) % 8)) | (1 << ((\2) % 8)) + pop bc + ENDC + ENDC +ENDM + + +; returns the complement of whether either event is set in Z flag +;\1 = event index 1 +;\2 = event index 2 +CheckEitherEventSet: MACRO + IF ((\1) / 8) == ((\2) / 8) + ld a, [wEventFlags + ((\1) / 8)] + and (1 << ((\1) % 8)) | (1 << ((\2) % 8)) + ELSE + ; This case doesn't happen in the original ROM. + IF ((\1) % 8) == ((\2) % 8) + push hl + ld a, [wEventFlags + ((\1) / 8)] + ld hl, wEventFlags + ((\2) / 8) + or [hl] + bit ((\1) % 8), a + pop hl + ELSE + push bc + ld a, [wEventFlags + ((\1) / 8)] + and (1 << ((\1) % 8)) + ld b, a + ld a, [wEventFlags + ((\2) / 8)] + and (1 << ((\2) % 8)) + or b + pop bc + ENDC + ENDC +ENDM + + +; for handling fixed event bits when events are inserted/removed +;\1 = event index +;\2 = fixed flag bit +AdjustEventBit: MACRO + IF ((\1) % 8) != (\2) + add ((\1) % 8) - (\2) + ENDC +ENDM + diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm new file mode 100644 index 00000000..a30561b9 --- /dev/null +++ b/macros/scripts/maps.asm @@ -0,0 +1,184 @@ +;\1 map width +;\2 Rows above (Y-blocks) +;\3 X movement (X-blocks) +EVENT_DISP: MACRO + dw (wOverworldMap + 7 + (\1) + ((\1) + 6) * ((\2) >> 1) + ((\3) >> 1)) ; Ev.Disp + db \2,\3 ;Y,X +ENDM + +FLYWARP_DATA: MACRO + EVENT_DISP \1,\2,\3 + db ((\2) & $01) ;sub-block Y + db ((\3) & $01) ;sub-block X +ENDM + +; external map entry macro +EMAP: MACRO ; emap x-coordinate,y-coordinate,textpointer +; the appearance of towns and routes in the town map, indexed by map id + ; nybble: y-coordinate + ; nybble: x-coordinate + ; word : pointer to map name + dn \2, \1 + dw \3 +ENDM + +; internal map entry macro +IMAP: MACRO ; imap mapid_less_than,x-coordinate,y-coordinate,textpointer +; the appearance of buildings and dungeons in the town map + ; byte : maximum map id subject to this rule + ; nybble: y-coordinate + ; nybble: x-coordinate + ; word : pointer to map name + db \1 + 1 + dn \3, \2 + dw \4 +ENDM + +;\1 sprite id +;\2 x position +;\3 y position +;\4 movement (WALK/STAY) +;\5 range or direction +;\6 text id +;\7 items only: item id +;\7 trainers only: trainer class/pokemon id +;\8 trainers only: trainer number/pokemon level +object: MACRO + db \1 + db \3 + 4 + db \2 + 4 + db \4 + db \5 + IF (_NARG > 7) + db TRAINER | \6 + db \7 + db \8 + ELSE + IF (_NARG > 6) + db ITEM | \6 + db \7 + ELSE + db \6 + ENDC + ENDC +ENDM + +;\1 x position +;\2 y position +;\3 destination warp id +;\4 destination map (-1 = wLastMap) +warp: MACRO + db \2, \1, \3, \4 +ENDM + +;\1 x position +;\2 y position +;\3 sign id +sign: MACRO + db \2, \1, \3 +ENDM + +;\1 x position +;\2 y position +;\3 map width +warp_to: MACRO + EVENT_DISP \3, \2, \1 +ENDM + +;\1 map name +;\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" +\1_h:: + db \3 + db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH + dw \1_Blocks + dw \1_TextPointers + dw \1_Script + db \4 +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 +ENDM + +; Connections go in order: north, south, west, east +;\1 direction +;\2 map name +;\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 + +; Calculate tile offsets for source (current) and target maps +_src = 0 +_tgt = (\4) + 3 +if _tgt < 2 +_src = -_tgt +_tgt = 0 +endc + +if "\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 + +elif "\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 "\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 "\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 + +else +fail "Invalid direction for 'connection'." +endc + + db \3 + dw \2_Blocks + _blk + dw wOverworldMap + _map + db _len - _src + db \3_WIDTH + db _y, _x + dw wOverworldMap + _win +ENDM diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm new file mode 100755 index 00000000..732a22d4 --- /dev/null +++ b/macros/scripts/text.asm @@ -0,0 +1,78 @@ +text EQUS "db $00," ; Start writing text. +next EQUS "db $4e," ; Move a line down. +line EQUS "db $4f," ; Start writing at the bottom line. +para EQUS "db $51," ; Start a new paragraph. +cont EQUS "db $55," ; Scroll to the next line. +done EQUS "db $57" ; End a text box. +prompt EQUS "db $58" ; Prompt the player to end a text box (initiating some other event). + +page EQUS "db $49," ; Start a new Pokedex page. +dex EQUS "db $5f, $50" ; End a Pokedex entry. + +TX_RAM: MACRO +; prints text to screen +; \1: RAM address to read from + db $1 + dw \1 +ENDM + +TX_BCD: MACRO +; \1: RAM address to read from +; \2: number of bytes + print flags + db $2 + dw \1 + db \2 +ENDM + +TX_LINE EQUS "db $05" +TX_BLINK EQUS "db $06" +;TX_SCROLL EQUS "db $07" +TX_ASM EQUS "db $08" + +TX_NUM: MACRO +; print a big-endian decimal number. +; \1: address to read from +; \2: number of bytes to read +; \3: number of digits to display + db $09 + dw \1 + db \2 << 4 | \3 +ENDM + +TX_DELAY EQUS "db $0a" +TX_SFX_ITEM_1 EQUS "db $0b" +TX_SFX_LEVEL_UP EQUS "db $0b" +;TX_ELLIPSES EQUS "db $0c" +TX_WAIT EQUS "db $0d" +;TX_SFX_DEX_RATING EQUS "db $0e" +TX_SFX_ITEM_2 EQUS "db $10" +TX_SFX_KEY_ITEM EQUS "db $11" +TX_SFX_CAUGHT_MON EQUS "db $12" +TX_SFX_DEX_PAGE_ADDED EQUS "db $13" +TX_CRY_NIDORINA EQUS "db $14" +TX_CRY_PIDGEOT EQUS "db $15" +;TX_CRY_DEWGONG EQUS "db $16" + +TX_FAR: MACRO + db $17 + dw \1 + db BANK(\1) +ENDM + +TX_VENDING_MACHINE EQUS "db $f5" +TX_CABLE_CLUB_RECEPTIONIST EQUS "db $f6" +TX_PRIZE_VENDOR EQUS "db $f7" +TX_POKECENTER_PC EQUS "db $f9" +TX_PLAYERS_PC EQUS "db $fc" +TX_BILLS_PC EQUS "db $fd" + +TX_MART: MACRO + db $FE, _NARG + REPT _NARG + db \1 + SHIFT + ENDR + db $FF +ENDM + +TX_POKECENTER_NURSE EQUS "db $ff" -- cgit v1.3.1-sl0p From e4e0af4d6713161d46cc0a1d580645ca40d6fa81 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 4 Jul 2020 01:00:45 -0400 Subject: Remove remaining raw $xxxx values, and replace "+ -1" with "- 1" (supported by rgbds 0.4.0) --- constants/hardware_constants.asm | 13 +++++ constants/move_constants.asm | 2 +- constants/pokedex_constants.asm | 2 +- constants/pokemon_constants.asm | 2 +- data/moves/effects_pointers.asm | 14 +++--- engine/battle/animations.asm | 6 +-- engine/battle/core.asm | 12 ++--- engine/battle/trainer_ai.asm | 2 +- engine/events/diploma.asm | 2 +- engine/events/prize_menu.asm | 4 +- engine/menus/display_text_id_init.asm | 4 +- engine/menus/save.asm | 4 +- engine/menus/start_sub_menus.asm | 10 ++-- engine/movie/title.asm | 2 +- engine/overworld/map_sprites.asm | 3 +- engine/overworld/wild_mons.asm | 6 +-- engine/pokemon/status_screen.asm | 4 +- engine/slots/slot_machine.asm | 2 +- home/init.asm | 12 ++--- home/list_menu.asm | 2 +- home/names2.asm | 2 +- home/overworld.asm | 12 ++--- home/pics.asm | 4 +- home/predef_text.asm | 2 +- macros/scripts/events.asm | 12 ++--- macros/wram.asm | 92 ++++++++++++++++++++++++++++++++++ scripts/OaksLab.asm | 2 +- scripts/VermilionDock.asm | 2 +- wram.asm | 94 ++--------------------------------- 29 files changed, 172 insertions(+), 158 deletions(-) create mode 100644 macros/wram.asm (limited to 'macros/scripts') diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index 59ec6170..993a02f5 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -2,6 +2,19 @@ GBC EQU $11 +; memory map +VRAM_Begin EQU $8000 +VRAM_End EQU $a000 +SRAM_Begin EQU $a000 +SRAM_End EQU $c000 +WRAM0_Begin EQU $c000 +WRAM0_End EQU $d000 +WRAM1_Begin EQU $d000 +WRAM1_End EQU $e000 +; hardware registers $ff00-$ff80 (see below) +HRAM_Begin EQU $ff80 +HRAM_End EQU $ffff + ; MBC1 MBC1SRamEnable EQU $0000 MBC1RomBank EQU $2000 diff --git a/constants/move_constants.asm b/constants/move_constants.asm index 850662de..5dd06a41 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -165,7 +165,7 @@ const SLASH ; a3 const SUBSTITUTE ; a4 -NUM_ATTACKS EQU const_value + -1 +NUM_ATTACKS EQU const_value - 1 const STRUGGLE ; a5 diff --git a/constants/pokedex_constants.asm b/constants/pokedex_constants.asm index c8605852..e462586e 100644 --- a/constants/pokedex_constants.asm +++ b/constants/pokedex_constants.asm @@ -151,4 +151,4 @@ const DEX_MEWTWO ; 150 const DEX_MEW ; 151 -NUM_POKEMON EQU const_value + -1 +NUM_POKEMON EQU const_value - 1 diff --git a/constants/pokemon_constants.asm b/constants/pokemon_constants.asm index 5484a65d..7abdd4d3 100644 --- a/constants/pokemon_constants.asm +++ b/constants/pokemon_constants.asm @@ -191,4 +191,4 @@ const WEEPINBELL ; $BD const VICTREEBEL ; $BE -NUM_POKEMON_INDEXES EQU const_value + -1 +NUM_POKEMON_INDEXES EQU const_value - 1 diff --git a/data/moves/effects_pointers.asm b/data/moves/effects_pointers.asm index 0d36e887..02f6e5c6 100644 --- a/data/moves/effects_pointers.asm +++ b/data/moves/effects_pointers.asm @@ -7,7 +7,7 @@ MoveEffectPointerTable: dw FreezeBurnParalyzeEffect ; PARALYZE_SIDE_EFFECT1 dw ExplodeEffect ; EXPLODE_EFFECT dw DrainHPEffect ; DREAM_EATER_EFFECT - dw $0000 ; MIRROR_MOVE_EFFECT + dw NULL ; MIRROR_MOVE_EFFECT dw StatModifierUpEffect ; ATTACK_UP1_EFFECT dw StatModifierUpEffect ; DEFENSE_UP1_EFFECT dw StatModifierUpEffect ; SPEED_UP1_EFFECT @@ -15,7 +15,7 @@ MoveEffectPointerTable: dw StatModifierUpEffect ; ACCURACY_UP1_EFFECT dw StatModifierUpEffect ; EVASION_UP1_EFFECT dw PayDayEffect ; PAY_DAY_EFFECT - dw $0000 ; SWIFT_EFFECT + dw NULL ; SWIFT_EFFECT dw StatModifierDownEffect ; ATTACK_DOWN1_EFFECT dw StatModifierDownEffect ; DEFENSE_DOWN1_EFFECT dw StatModifierDownEffect ; SPEED_DOWN1_EFFECT @@ -38,12 +38,12 @@ MoveEffectPointerTable: dw FlinchSideEffect ; FLINCH_SIDE_EFFECT2 dw OneHitKOEffect ; OHKO_EFFECT dw ChargeEffect ; CHARGE_EFFECT - dw $0000 ; SUPER_FANG_EFFECT - dw $0000 ; SPECIAL_DAMAGE_EFFECT + dw NULL ; SUPER_FANG_EFFECT + dw NULL ; SPECIAL_DAMAGE_EFFECT dw TrappingEffect ; TRAPPING_EFFECT dw ChargeEffect ; FLY_EFFECT dw TwoToFiveAttacksEffect ; ATTACK_TWICE_EFFECT - dw $0000 ; JUMP_KICK_EFFECT + dw NULL ; JUMP_KICK_EFFECT dw MistEffect ; MIST_EFFECT dw FocusEnergyEffect ; FOCUS_ENERGY_EFFECT dw RecoilEffect ; RECOIL_EFFECT @@ -76,12 +76,12 @@ MoveEffectPointerTable: dw StatModifierDownEffect ; unused effect dw ConfusionSideEffect ; CONFUSION_SIDE_EFFECT dw TwoToFiveAttacksEffect ; TWINEEDLE_EFFECT - dw $0000 ; unused effect + dw NULL ; unused effect dw SubstituteEffect ; SUBSTITUTE_EFFECT dw HyperBeamEffect ; HYPER_BEAM_EFFECT dw RageEffect ; RAGE_EFFECT dw MimicEffect ; MIMIC_EFFECT - dw $0000 ; METRONOME_EFFECT + dw NULL ; METRONOME_EFFECT dw LeechSeedEffect ; LEECH_SEED_EFFECT dw SplashEffect ; SPLASH_EFFECT dw DisableEffect ; DISABLE_EFFECT diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index d858e066..ee476ce9 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -1735,7 +1735,7 @@ AnimationSlideMonDownAndHide: jr nz, .loop call AnimationHideMonPic ld hl, wTempPic - ld bc, $0310 + ld bc, $310 xor a call FillMemory jp CopyTempPicToMonPic @@ -1896,7 +1896,7 @@ AnimationSubstitute: ; Changes the pokemon's sprite to the mini sprite ld hl, wTempPic xor a - ld bc, $0310 + ld bc, $310 call FillMemory ld a, [hWhoseTurn] and a @@ -1932,7 +1932,7 @@ AnimationSubstitute: jp AnimationShowMonPic CopySlowbroSpriteData: - ld bc, $0010 + ld bc, $10 ld a, BANK(SlowbroSprite) jp FarCopyData2 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 00852b2b..6881aef5 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -582,7 +582,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ld a, [de] ; increment toxic counter inc a ld [de], a - ld hl, $0000 + ld hl, 0 .toxicTicksLoop add hl, bc dec a @@ -5345,8 +5345,8 @@ MoveHitTest: ret z ; Swift never misses (interestingly, Azure Heights lists this is a myth, but it appears to be true) call CheckTargetSubstitute ; substitute check (note that this overwrites a) jr z, .checkForDigOrFlyStatus -; this code is buggy. it's supposed to prevent HP draining moves from working on substitutes. -; since $7b79 overwrites a with either $00 or $01, it never works. +; This code is buggy. It's supposed to prevent HP draining moves from working on substitutes. +; Since CheckTargetSubstitute overwrites a with either $00 or $01, it never works. cp DRAIN_HP_EFFECT jp z, .moveMissed cp DREAM_EATER_EFFECT @@ -6335,9 +6335,9 @@ LoadPlayerBackPic: ld de, vBackPic call InterlaceMergeSpriteBuffers ld a, $a - ld [$0], a + ld [MBC1SRamEnable], a xor a - ld [$4000], a + ld [MBC1SRamBank], a ld hl, vSprites ld de, sSpriteBuffer1 ld a, [hLoadedROMBank] @@ -6345,7 +6345,7 @@ LoadPlayerBackPic: ld c, 7 * 7 call CopyVideoData xor a - ld [$0], a + ld [MBC1SRamEnable], a ld a, $31 ld [hStartTileID], a coord hl, 1, 5 diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 2178be38..d61b44f8 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -134,7 +134,7 @@ AIMoveChoiceModification1: push de push bc ld hl, StatusAilmentMoveEffects - ld de, $0001 + ld de, 1 call IsInArray pop bc pop de diff --git a/engine/events/diploma.asm b/engine/events/diploma.asm index 24bd2f22..53d78e57 100755 --- a/engine/events/diploma.asm +++ b/engine/events/diploma.asm @@ -9,7 +9,7 @@ DisplayDiploma:: call DisableLCD ld hl, CircleTile ld de, vChars2 + $700 - ld bc, $0010 + ld bc, $10 ld a, BANK(CircleTile) call FarCopyData2 coord hl, 0, 0 diff --git a/engine/events/prize_menu.asm b/engine/events/prize_menu.asm index aa86f828..5a00a89e 100755 --- a/engine/events/prize_menu.asm +++ b/engine/events/prize_menu.asm @@ -131,10 +131,8 @@ GetPrizeMenuId: coord hl, 13, 5 ; reg. c: ; [low nybble] number of bytes -; [bit 765 = %100] space-padding (not zero-padding) +; [bits 765 = %100] space-padding (not zero-padding) ld c, (1 << 7 | 2) -; Function $15CD displays BCD value (same routine -; used by text-command $02) call PrintBCDNumber ld de, wPrize2Price coord hl, 13, 7 diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm index e1f6c678..45c76f9c 100644 --- a/engine/menus/display_text_id_init.asm +++ b/engine/menus/display_text_id_init.asm @@ -43,7 +43,7 @@ DisplayTextIDInit:: ; the original direction they were facing must be restored after the dialogue is over ld hl, wSpriteStateData1 + $19 ld c, $0f - ld de, $0010 + ld de, $10 .spriteFacingDirectionCopyLoop ld a, [hl] inc h @@ -55,7 +55,7 @@ DisplayTextIDInit:: ; loop to force all the sprites in the middle of animation to stand still ; (so that they don't like they're frozen mid-step during the dialogue) ld hl, wSpriteStateData1 + 2 - ld de, $0010 + ld de, $10 ld c, e .spriteStandStillLoop ld a, [hl] diff --git a/engine/menus/save.asm b/engine/menus/save.asm index f2ecc3aa..ee73c850 100755 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -702,7 +702,7 @@ ClearSAV: PadSRAM_FF: ld [MBC1SRamBank], a - ld hl, $a000 ; start of SRAM - ld bc, $2000 ; size of SRAM + ld hl, SRAM_Begin + ld bc, SRAM_End - SRAM_Begin ld a, $ff jp FillMemory diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm index 43c767e2..526540df 100755 --- a/engine/menus/start_sub_menus.asm +++ b/engine/menus/start_sub_menus.asm @@ -491,12 +491,12 @@ DrawTrainerInfo: call CopyData ld hl, TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns ld de, vChars2 + $770 - ld bc, $0080 + ld bc, $80 push bc call TrainerInfo_FarCopyData ld hl, BlankLeaderNames ld de, vChars2 + $600 - ld bc, $0170 + ld bc, $170 call TrainerInfo_FarCopyData pop bc ld hl, BadgeNumbersTileGraphics ; badge number tile patterns @@ -504,14 +504,14 @@ DrawTrainerInfo: call TrainerInfo_FarCopyData ld hl, GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns ld de, vChars2 + $200 - ld bc, $0400 + ld bc, $400 ld a, $03 call FarCopyData2 ld hl, TextBoxGraphics - ld de, $00d0 + ld de, $d0 add hl, de ; hl = colon tile pattern ld de, vChars1 + $560 - ld bc, $0010 + ld bc, $10 ld a, $04 push bc call FarCopyData2 diff --git a/engine/movie/title.asm b/engine/movie/title.asm index 1a2d16a0..9cbe5494 100755 --- a/engine/movie/title.asm +++ b/engine/movie/title.asm @@ -317,7 +317,7 @@ DrawPlayerCharacter: xor a ld [wPlayerCharacterOAMTile], a ld hl, wOAMBuffer - ld de, $605a + lb de, $60, $5a ld b, 7 .loop push de diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index eb8edb10..904e9b04 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -133,8 +133,7 @@ LoadMapSpriteTilePatterns: jr nc, .fourTileSpriteVRAMAddr ld d, a dec d -; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM -; slot and adding the result to $8000 (the VRAM base address). +; vSprites += [hVRAMSlot] * $C0 (the number of bytes in 12 tiles) .calculateVRAMAddrLoop add hl, bc dec d diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm index 24dc7681..2593e0ec 100644 --- a/engine/overworld/wild_mons.asm +++ b/engine/overworld/wild_mons.asm @@ -16,10 +16,10 @@ LoadWildData:: jr z, .NoGrassData ; if no grass data, skip to surfing data push hl ld de, wGrassMons ; otherwise, load grass data - ld bc, $0014 + ld bc, $14 call CopyData pop hl - ld bc, $0014 + ld bc, $14 add hl, bc .NoGrassData ld a, [hli] @@ -27,7 +27,7 @@ LoadWildData:: and a ret z ; if no water data, we're done ld de, wWaterMons ; otherwise, load surfing data - ld bc, $0014 + ld bc, $14 jp CopyData INCLUDE "data/wild/grass_water.asm" diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index f66cdf5a..b262a8b7 100755 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -254,7 +254,7 @@ PrintStatsBox: ld c, 8 call TextBoxBorder ; Draws the box coord hl, 1, 9 ; Start printing stats from here - ld bc, $0019 ; Number offset + ld bc, $19 ; Number offset jr .PrintStats .DifferentBox coord hl, 9, 2 @@ -262,7 +262,7 @@ PrintStatsBox: ld c, 9 call TextBoxBorder coord hl, 11, 3 - ld bc, $0018 + ld bc, $18 .PrintStats push bc push hl diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm index 16696713..c3de5dd2 100755 --- a/engine/slots/slot_machine.asm +++ b/engine/slots/slot_machine.asm @@ -31,7 +31,7 @@ PromptUserToPlaySlots: xor a ld [wSlotMachineAllowMatchesCounter], a ld hl, wStoppingWhichSlotMachineWheel - ld bc, $0014 + ld bc, $14 call FillMemory call MainSlotMachineLoop ld hl, wd730 diff --git a/home/init.asm b/home/init.asm index 48294fa6..83238bad 100644 --- a/home/init.asm +++ b/home/init.asm @@ -41,8 +41,8 @@ rLCDC_DEFAULT EQU %11100011 ld sp, wStack - ld hl, $c000 ; start of WRAM - ld bc, $2000 ; size of WRAM + ld hl, WRAM0_Begin + ld bc, WRAM1_End - WRAM0_Begin .loop ld [hl], 0 inc hl @@ -53,8 +53,8 @@ rLCDC_DEFAULT EQU %11100011 call ClearVram - ld hl, $ff80 ; start of HRAM - ld bc, $ffff - $ff80 ; size of HRAM + ld hl, HRAM_Begin + ld bc, HRAM_End - HRAM_Begin call FillMemory call ClearSprites @@ -119,8 +119,8 @@ rLCDC_DEFAULT EQU %11100011 jp SetDefaultNamesBeforeTitlescreen ClearVram:: - ld hl, $8000 - ld bc, $2000 + ld hl, VRAM_Begin + ld bc, VRAM_End - VRAM_Begin xor a jp FillMemory diff --git a/home/list_menu.asm b/home/list_menu.asm index 68335ed5..4ce973b2 100644 --- a/home/list_menu.asm +++ b/home/list_menu.asm @@ -454,7 +454,7 @@ PrintListMenuEntries:: ld [wLoadedMonLevel], a .skipCopyingLevel pop hl - ld bc, $001c + ld bc, $1c add hl, bc call PrintLevel pop af diff --git a/home/names2.asm b/home/names2.asm index 178a0780..319febd3 100644 --- a/home/names2.asm +++ b/home/names2.asm @@ -77,7 +77,7 @@ GetName:: ld h, d ld l, e ld de, wcd6d - ld bc, $0014 + ld bc, $14 call CopyData .gotPtr ld a, e diff --git a/home/overworld.asm b/home/overworld.asm index c959beb6..79e4ea97 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1424,18 +1424,18 @@ LoadCurrentMapView:: dec b jr nz, .rowLoop ld hl, wTileMapBackup - ld bc, $0000 + ld bc, $0 .adjustForYCoordWithinTileBlock ld a, [wYBlockCoord] and a jr z, .adjustForXCoordWithinTileBlock - ld bc, $0030 + ld bc, $30 add hl, bc .adjustForXCoordWithinTileBlock ld a, [wXBlockCoord] and a jr z, .copyToVisibleAreaBuffer - ld bc, $0002 + ld bc, $2 add hl, bc .copyToVisibleAreaBuffer coord de, 0, 0 ; base address for the tiles that are directly transferred to VRAM during V-blank @@ -1739,7 +1739,7 @@ ScheduleSouthRowRedraw:: ld l, a ld a, [wMapViewVRAMPointer + 1] ld h, a - ld bc, $0200 + ld bc, $200 add hl, bc ld a, h and $03 @@ -1835,7 +1835,7 @@ DrawTileBlock:: ld a, [de] ld [hl], a inc de - ld bc, $0015 + ld bc, $15 add hl, bc pop bc dec c @@ -2180,7 +2180,7 @@ LoadMapHeader:: jr nz, .zeroSpriteDataLoop ; initialize all C100-C1FF sprite entries to disabled (other than player's) ld hl, wSpriteStateData1 + $12 - ld de, $0010 + ld de, $10 ld c, $0f .disableSpriteEntriesLoop ld [hl], $ff diff --git a/home/pics.asm b/home/pics.asm index 02683db7..c6d99cbb 100644 --- a/home/pics.asm +++ b/home/pics.asm @@ -93,7 +93,7 @@ LoadUncompressedSpriteData:: add a ; 8*(7*((8-w)/2) + 7-h) ; combined overall offset (in bytes) ld [hSpriteOffset], a xor a - ld [$4000], a + ld [MBC1SRamBank], a ld hl, sSpriteBuffer0 call ZeroSpriteBuffer ; zero buffer 0 ld de, sSpriteBuffer1 @@ -151,7 +151,7 @@ ZeroSpriteBuffer:: ; de: output address InterlaceMergeSpriteBuffers:: xor a - ld [$4000], a + ld [MBC1SRamBank], a push de ld hl, sSpriteBuffer2 + (SPRITEBUFFERSIZE - 1) ; destination: end of buffer 2 ld de, sSpriteBuffer1 + (SPRITEBUFFERSIZE - 1) ; source 2: end of buffer 1 diff --git a/home/predef_text.asm b/home/predef_text.asm index 24001c24..059e23ab 100644 --- a/home/predef_text.asm +++ b/home/predef_text.asm @@ -119,7 +119,7 @@ CloseTextDisplay:: ; loop to make sprites face the directions they originally faced before the dialogue ld hl, wSpriteStateData2 + $19 ld c, $0f - ld de, $0010 + ld de, $10 .restoreSpriteFacingDirectionLoop ld a, [hl] dec h diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm index 9be354e3..c5f90107 100755 --- a/macros/scripts/events.asm +++ b/macros/scripts/events.asm @@ -183,7 +183,7 @@ ENDM ;\3, \4, ... = additional (optional) event indices SetEvents: MACRO SetEvent \1 - rept (_NARG + -1) + rept _NARG - 1 SetEventReuseHL \2 shift endr @@ -235,7 +235,7 @@ ENDM ;\3 = event index (optional) ResetEvents: MACRO ResetEvent \1 - rept (_NARG + -1) + rept _NARG - 1 ResetEventReuseHL \2 shift endr @@ -283,7 +283,7 @@ event_fill_start = event_start_byte + 1 event_fill_count = event_end_byte - event_start_byte - 1 IF ((\1) % 8) == 0 -event_fill_start = event_fill_start + -1 +event_fill_start = event_fill_start - 1 event_fill_count = event_fill_count + 1 ELSE ld a, [wEventFlags + event_start_byte] @@ -304,7 +304,7 @@ event_fill_count = event_fill_count + 1 ld a, $ff ld hl, wEventFlags + event_fill_start - REPT event_fill_count + -1 + REPT event_fill_count - 1 ld [hli], a ENDR @@ -345,7 +345,7 @@ event_fill_start = event_start_byte + 1 event_fill_count = event_end_byte - event_start_byte - 1 IF ((\1) % 8) == 0 -event_fill_start = event_fill_start + -1 +event_fill_start = event_fill_start - 1 event_fill_count = event_fill_count + 1 ELSE ld a, [wEventFlags + event_start_byte] @@ -370,7 +370,7 @@ event_fill_count = event_fill_count + 1 xor a ENDC - REPT event_fill_count + -1 + REPT event_fill_count - 1 ld [hli], a ENDR diff --git a/macros/wram.asm b/macros/wram.asm new file mode 100644 index 00000000..7a9b4a6a --- /dev/null +++ b/macros/wram.asm @@ -0,0 +1,92 @@ +; Used in wram.asm + +flag_array: MACRO + ds ((\1) + 7) / 8 +ENDM + +BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2 + +box_struct: MACRO +\1Species:: db +\1HP:: dw +\1BoxLevel:: db +\1Status:: db +\1Type:: +\1Type1:: db +\1Type2:: db +\1CatchRate:: db +\1Moves:: ds NUM_MOVES +\1OTID:: dw +\1Exp:: ds 3 +\1HPExp:: dw +\1AttackExp:: dw +\1DefenseExp:: dw +\1SpeedExp:: dw +\1SpecialExp:: dw +\1DVs:: ds 2 +\1PP:: ds NUM_MOVES +ENDM + +party_struct: MACRO + box_struct \1 +\1Level:: db +\1Stats:: +\1MaxHP:: dw +\1Attack:: dw +\1Defense:: dw +\1Speed:: dw +\1Special:: dw +ENDM + +battle_struct: MACRO +\1Species:: db +\1HP:: dw +\1PartyPos:: +\1BoxLevel:: db +\1Status:: db +\1Type:: +\1Type1:: db +\1Type2:: db +\1CatchRate:: db +\1Moves:: ds NUM_MOVES +\1DVs:: ds 2 +\1Level:: db +\1Stats:: +\1MaxHP:: dw +\1Attack:: dw +\1Defense:: dw +\1Speed:: dw +\1Special:: dw +\1PP:: ds NUM_MOVES +ENDM + +spritestatedata1: MACRO +\1PictureID:: db +\1MovementStatus:: db +\1ImageIndex:: db +\1YStepVector:: db +\1YPixels:: db +\1XStepVector:: db +\1XPixels:: db +\1IntraAnimFrameCounter:: db +\1AnimFrameCounter:: db +\1FacingDirection:: db + ds 6 +\1End:: +ENDM + +spritestatedata2: MACRO +\1WalkAnimationCounter:: db + ds 1 +\1YDisplacement:: db +\1XDisplacement:: db +\1MapY:: db +\1MapX:: db +\1MovementByte1:: db +\1GrassPriority:: db +\1MovementDelay:: db + ds 5 +\1ImageBaseOffset:: db + ds 1 +\1End:: +ENDM diff --git a/scripts/OaksLab.asm b/scripts/OaksLab.asm index 9bb84923..b3347849 100755 --- a/scripts/OaksLab.asm +++ b/scripts/OaksLab.asm @@ -652,7 +652,7 @@ OaksLabScript18: OaksLabScript_RemoveParcel: ld hl, wBagItems - ld bc, $0000 + ld bc, 0 .loop ld a, [hli] cp $ff diff --git a/scripts/VermilionDock.asm b/scripts/VermilionDock.asm index 4b0cf439..90fef6b2 100755 --- a/scripts/VermilionDock.asm +++ b/scripts/VermilionDock.asm @@ -78,7 +78,7 @@ VermilionDock_1db9b: ld d, $0 ld e, $8 .asm_1dbfa - ld hl, $0002 + ld hl, $2 add hl, bc ld a, l ld [wMapViewVRAMPointer], a diff --git a/wram.asm b/wram.asm index 9c37b3db..e2fa05a6 100755 --- a/wram.asm +++ b/wram.asm @@ -1,63 +1,6 @@ INCLUDE "constants.asm" -flag_array: MACRO - ds ((\1) + 7) / 8 -ENDM - -box_struct_length EQU 25 + NUM_MOVES * 2 -box_struct: MACRO -\1Species:: db -\1HP:: dw -\1BoxLevel:: db -\1Status:: db -\1Type:: -\1Type1:: db -\1Type2:: db -\1CatchRate:: db -\1Moves:: ds NUM_MOVES -\1OTID:: dw -\1Exp:: ds 3 -\1HPExp:: dw -\1AttackExp:: dw -\1DefenseExp:: dw -\1SpeedExp:: dw -\1SpecialExp:: dw -\1DVs:: ds 2 -\1PP:: ds NUM_MOVES -ENDM - -party_struct: MACRO - box_struct \1 -\1Level:: db -\1Stats:: -\1MaxHP:: dw -\1Attack:: dw -\1Defense:: dw -\1Speed:: dw -\1Special:: dw -ENDM - -battle_struct: MACRO -\1Species:: db -\1HP:: dw -\1PartyPos:: -\1BoxLevel:: db -\1Status:: db -\1Type:: -\1Type1:: db -\1Type2:: db -\1CatchRate:: db -\1Moves:: ds NUM_MOVES -\1DVs:: ds 2 -\1Level:: db -\1Stats:: -\1MaxHP:: dw -\1Attack:: dw -\1Defense:: dw -\1Speed:: dw -\1Special:: dw -\1PP:: ds NUM_MOVES -ENDM +INCLUDE "macros/wram.asm" SECTION "WRAM Bank 0", WRAM0 @@ -228,21 +171,6 @@ wSpriteStateData1:: ; C1xD ; C1xE ; C1xF -spritestatedata1: MACRO -\1PictureID:: db -\1MovementStatus:: db -\1ImageIndex:: db -\1YStepVector:: db -\1YPixels:: db -\1XStepVector:: db -\1XPixels:: db -\1IntraAnimFrameCounter:: db -\1AnimFrameCounter:: db -\1FacingDirection:: db - ds 6 -\1End:: -endm - wSpritePlayerStateData1:: spritestatedata1 wSpritePlayerStateData1 wSprite01StateData1:: spritestatedata1 wSprite01StateData1 wSprite02StateData1:: spritestatedata1 wSprite02StateData1 @@ -280,22 +208,6 @@ wSpriteStateData2:: ; C2xD ; C2xE: sprite image base offset (in video ram, player always has value 1, used to compute c1x2) ; C2xF -spritestatedata2: MACRO -\1WalkAnimationCounter:: db - ds 1 -\1YDisplacement:: db -\1XDisplacement:: db -\1MapY:: db -\1MapX:: db -\1MovementByte1:: db -\1GrassPriority:: db -\1MovementDelay:: db - ds 5 -\1ImageBaseOffset:: db - ds 1 -\1End:: -endm - wSpritePlayerStateData2:: spritestatedata2 wSpritePlayerStateData2 wSprite01StateData2:: spritestatedata2 wSprite01StateData2 wSprite02StateData2:: spritestatedata2 wSprite02StateData2 @@ -1050,7 +962,7 @@ wOptionsCancelCursorX:: ds 1 wDayCarePerLevelCost:: -; 2-byte BCD number (always set to $0100) +; 2-byte BCD number (always set to $100) wHoFTeamIndex2:: @@ -3185,7 +3097,7 @@ wBoxSpecies:: ds MONS_PER_BOX + 1 wBoxMons:: wBoxMon1:: box_struct wBoxMon1 -wBoxMon2:: ds box_struct_length * (MONS_PER_BOX + -1) +wBoxMon2:: ds BOX_STRUCT_LENGTH * (MONS_PER_BOX - 1) wBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX wBoxMonNicks:: ds NAME_LENGTH * MONS_PER_BOX -- cgit v1.3.1-sl0p