diff options
| author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-03 16:37:47 -0400 |
|---|---|---|
| committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-03 16:37:47 -0400 |
| commit | 9878f01e29b1443d6c894c1332cbf381fa12646e (patch) | |
| tree | 8e763ca94f2b90faaa470416055c320dbdb89cbf /macros/scripts | |
| parent | Make suggested edits: (diff) | |
| download | pokeyellow-9878f01e29b1443d6c894c1332cbf381fa12646e.tar.gz pokeyellow-9878f01e29b1443d6c894c1332cbf381fa12646e.tar.xz pokeyellow-9878f01e29b1443d6c894c1332cbf381fa12646e.zip | |
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.
Diffstat (limited to '')
| -rwxr-xr-x | macros/scripts/audio.asm (renamed from macros/audio_macros.asm) | 28 | ||||
| -rwxr-xr-x | macros/scripts/events.asm (renamed from macros/event_macros.asm) | 90 | ||||
| -rw-r--r--[-rwxr-xr-x] | macros/scripts/maps.asm (renamed from macros/data_macros.asm) | 95 | ||||
| -rwxr-xr-x | macros/scripts/text.asm (renamed from macros/text_macros.asm) | 2 |
4 files changed, 73 insertions, 142 deletions
diff --git a/macros/audio_macros.asm b/macros/scripts/audio.asm index 95b9ecbc..8a250c63 100755 --- a/macros/audio_macros.asm +++ b/macros/scripts/audio.asm @@ -1,18 +1,3 @@ - -StopAllMusic: MACRO - ld a, $ff - call PlaySound -ENDM - -Ch1 EQU 0 -Ch2 EQU 1 -Ch3 EQU 2 -Ch4 EQU 3 -Ch5 EQU 4 -Ch6 EQU 5 -Ch7 EQU 6 -Ch8 EQU 7 - audio_header: MACRO db (_NARG - 2) << 6 | \2 dw \1_\2 @@ -73,19 +58,6 @@ noise_note: MACRO db \4 ENDM -C_ EQU $0 -C# EQU $1 -D_ EQU $2 -D# EQU $3 -E_ EQU $4 -F_ EQU $5 -F# EQU $6 -G_ EQU $7 -G# EQU $8 -A_ EQU $9 -A# EQU $A -B_ EQU $B - ; arguments: pitch, length [1, 16] note: MACRO db (\1 << 4) | (\2 - 1) diff --git a/macros/event_macros.asm b/macros/scripts/events.asm index 20027209..9be354e3 100755 --- a/macros/event_macros.asm +++ b/macros/scripts/events.asm @@ -15,7 +15,8 @@ event_byte = ((\1) / 8) ELSE bit (\1) % 8, a ENDC - ENDM +ENDM + ;\1 = event index CheckEventReuseA: MACRO @@ -25,7 +26,8 @@ event_byte = ((\1) / 8) ENDC bit (\1) % 8, a - ENDM +ENDM + ;\1 = event index ;\2 = event index of the last event used before the branch @@ -37,7 +39,8 @@ event_byte = ((\1) / 8) ENDC bit (\1) % 8, a - ENDM +ENDM + ;\1 = reg ;\2 = event index @@ -48,21 +51,24 @@ EventFlagBit: MACRO ELSE ld \1, (\2) % 8 ENDC - ENDM +ENDM + ;\1 = reg ;\2 = event index EventFlagAddress: MACRO event_byte = ((\2) / 8) ld \1, wEventFlags + event_byte - ENDM +ENDM + ;\1 = event index CheckEventHL: MACRO event_byte = ((\1) / 8) ld hl, wEventFlags + event_byte bit (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index CheckEventReuseHL: MACRO @@ -72,14 +78,16 @@ event_byte = ((\1) / 8) ENDC bit (\1) % 8, [hl] - ENDM +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 +ENDM + ;\1 = event index ;\2 = event index of the last event used before the branch @@ -91,7 +99,8 @@ event_byte = ((\1) / 8) ENDC bit (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index CheckAndSetEvent: MACRO @@ -99,7 +108,8 @@ event_byte = ((\1) / 8) ld hl, wEventFlags + event_byte bit (\1) % 8, [hl] set (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index CheckAndResetEvent: MACRO @@ -107,7 +117,8 @@ event_byte = ((\1) / 8) ld hl, wEventFlags + event_byte bit (\1) % 8, [hl] res (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index CheckAndSetEventA: MACRO @@ -115,7 +126,8 @@ CheckAndSetEventA: MACRO bit (\1) % 8, a set (\1) % 8, a ld [wEventFlags + ((\1) / 8)], a - ENDM +ENDM + ;\1 = event index CheckAndResetEventA: MACRO @@ -123,14 +135,16 @@ CheckAndResetEventA: MACRO bit (\1) % 8, a res (\1) % 8, a ld [wEventFlags + ((\1) / 8)], a - ENDM +ENDM + ;\1 = event index SetEvent: MACRO event_byte = ((\1) / 8) ld hl, wEventFlags + event_byte set (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index SetEventReuseHL: MACRO @@ -140,7 +154,8 @@ event_byte = ((\1) / 8) ENDC set (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index ;\2 = event index of the last event used before the branch @@ -152,14 +167,16 @@ event_byte = ((\1) / 8) ENDC set (\1) % 8, [hl] - ENDM +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 +ENDM + ;\1 = event index ;\2 = event index @@ -170,14 +187,16 @@ SetEvents: MACRO SetEventReuseHL \2 shift endr - ENDM +ENDM + ;\1 = event index ResetEvent: MACRO event_byte = ((\1) / 8) ld hl, wEventFlags + event_byte res (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index ResetEventReuseHL: MACRO @@ -187,7 +206,8 @@ event_byte = ((\1) / 8) ENDC res (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index ;\2 = event index of the last event used before the branch @@ -199,14 +219,16 @@ event_byte = ((\1) / 8) ENDC res (\1) % 8, [hl] - ENDM +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 +ENDM + ;\1 = event index ;\2 = event index @@ -217,7 +239,8 @@ ResetEvents: MACRO ResetEventReuseHL \2 shift endr - ENDM +ENDM + ;\1 = event index ;\2 = number of bytes away from the base address (optional, for matching the ROM) @@ -227,7 +250,8 @@ dbEventFlagBit: MACRO ELSE db ((\1) % 8) ENDC - ENDM +ENDM + ;\1 = event index ;\2 = number of bytes away from the base address (optional, for matching the ROM) @@ -237,7 +261,8 @@ dwEventFlagAddress: MACRO ELSE dw wEventFlags + ((\1) / 8) ENDC - ENDM +ENDM + ;\1 = start ;\2 = end @@ -297,7 +322,8 @@ event_fill_count = event_fill_count + 1 ENDC ENDC ENDC - ENDM +ENDM + ;\1 = start ;\2 = end @@ -362,7 +388,8 @@ event_fill_count = event_fill_count + 1 ENDC ENDC ENDC - ENDM +ENDM + ; returns whether both events are set in Z flag ; This is counter-intuitive because the other event checks set the Z flag when @@ -400,7 +427,8 @@ event_byte = ((\1) / 8) pop bc ENDC ENDC - ENDM +ENDM + ; returns the complement of whether either event is set in Z flag ;\1 = event index 1 @@ -429,7 +457,8 @@ CheckEitherEventSet: MACRO pop bc ENDC ENDC - ENDM +ENDM + ; for handling fixed event bits when events are inserted/removed ;\1 = event index @@ -438,4 +467,5 @@ AdjustEventBit: MACRO IF ((\1) % 8) != (\2) add ((\1) % 8) - (\2) ENDC - ENDM +ENDM + diff --git a/macros/data_macros.asm b/macros/scripts/maps.asm index 794b75f7..a30561b9 100755..100644 --- a/macros/data_macros.asm +++ b/macros/scripts/maps.asm @@ -1,39 +1,6 @@ - -; Constant enumeration is useful for monsters, items, moves, etc. -const_def: MACRO -if _NARG >= 1 -const_value = \1 -else -const_value = 0 -endc -ENDM - -const: MACRO -\1 EQU const_value -const_value = const_value + 1 -ENDM - -; data format macros - -percent EQUS "* $ff / 100" - -bcd2: MACRO - dn ((\1) / 1000) % 10, ((\1) / 100) % 10 - dn ((\1) / 10) % 10, (\1) % 10 -ENDM - -bcd3: MACRO - dn ((\1) / 100000) % 10, ((\1) / 10000) % 10 - dn ((\1) / 1000) % 10, ((\1) / 100) % 10 - dn ((\1) / 10) % 10, (\1) % 10 -ENDM - -coins equs "bcd2" -money equs "bcd3" - -;\1 = Map Width -;\2 = Rows above (Y-blocks) -;\3 = X movement (X-blocks) +;\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 @@ -67,32 +34,6 @@ IMAP: MACRO ; imap mapid_less_than,x-coordinate,y-coordinate,textpointer dw \4 ENDM -; tilesets' headers macro -tileset: MACRO - db BANK(\2) ; BANK(GFX) - dw \1, \2, \3 ; Block, GFX, Coll - db \4, \5, \6 ; counter tiles - db \7 ; grass tile - db \8 ; permission (indoor, cave, outdoor) -ENDM - -INDOOR EQU 0 -CAVE EQU 1 -OUTDOOR EQU 2 - -RGB: MACRO - dw (\3 << 10 | \2 << 5 | \1) -ENDM - -WALK EQU $FE -STAY EQU $FF - -DOWN EQU $D0 -UP EQU $D1 -LEFT EQU $D2 -RIGHT EQU $D3 -NONE EQU $FF - ;\1 sprite id ;\2 x position ;\3 y position @@ -144,11 +85,11 @@ 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 -;\1: map name -;\2: map id -;\3: tileset -;\4: connections: combo of NORTH, SOUTH, WEST, and/or EAST, or 0 for none CURRENT_MAP_WIDTH = \2_WIDTH CURRENT_MAP_HEIGHT = \2_HEIGHT CURRENT_MAP_OBJECT EQUS "\1_Object" @@ -161,6 +102,7 @@ CURRENT_MAP_OBJECT EQUS "\1_Object" db \4 ENDM +; Comes after map_header and connection macros end_map_header: MACRO dw CURRENT_MAP_OBJECT PURGE CURRENT_MAP_WIDTH @@ -169,12 +111,12 @@ 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 -;\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) ; Calculate tile offsets for source (current) and target maps _src = 0 @@ -240,14 +182,3 @@ endc db _y, _x dw wOverworldMap + _win ENDM - -tmlearn: MACRO -x = 0 - REPT _NARG -IF \1 != 0 -x = x | (1 << ((\1 - 1) % 8)) -ENDC - SHIFT - ENDR - db x -ENDM diff --git a/macros/text_macros.asm b/macros/scripts/text.asm index 21e02634..732a22d4 100755 --- a/macros/text_macros.asm +++ b/macros/scripts/text.asm @@ -1,5 +1,3 @@ - -; text macros 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. |
