Skip to content

Commit

Permalink
Improve some RAM formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed May 31, 2021
1 parent ce62dca commit 8701ef4
Show file tree
Hide file tree
Showing 10 changed files with 463 additions and 812 deletions.
2 changes: 1 addition & 1 deletion constants/item_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ TM01 EQU const_value
add_tm ROCK_SLIDE ; $F8
add_tm TRI_ATTACK ; $F9
add_tm SUBSTITUTE ; $FA
assert NUM_TMS == const_value - TM01, "NUM_TMS ({d:NUM_TMS}) does not match the number of add_tm definitions"
ASSERT NUM_TMS == const_value - TM01, "NUM_TMS ({d:NUM_TMS}) does not match the number of add_tm definitions"

NUM_TM_HM EQU NUM_TMS + NUM_HMS

Expand Down
2 changes: 1 addition & 1 deletion data/battle_anims/subanimations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ SubanimationPointers:
; subanim type, count
; REPT count
; db frame block id, base coordinate id, frame block mode
; endr
; ENDR

subanim: MACRO
db (\1 << 5) | \2
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6308,7 +6308,7 @@ LoadPlayerBackPic:
ld de, OldManPicBack
.next
ld a, BANK(RedPicBack)
assert BANK(RedPicBack) == BANK(OldManPicBack)
ASSERT BANK(RedPicBack) == BANK(OldManPicBack)
call UncompressSpriteFromDE
predef ScaleSpriteByTwo
ld hl, wOAMBuffer
Expand Down
2 changes: 1 addition & 1 deletion engine/items/item_effects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,7 @@ IsKeyItem_::
ld hl, KeyItemFlags
ld de, wBuffer
ld bc, 15 ; only 11 bytes are actually used
assert 15 >= (NUM_ITEMS + 7) / 8
ASSERT 15 >= (NUM_ITEMS + 7) / 8
call CopyData
pop af
dec a
Expand Down
6 changes: 3 additions & 3 deletions home/names2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ GetName::

; TM names are separate from item names.
; BUG: This applies to all names instead of just items.
assert NUM_POKEMON_INDEXES < HM01, \
ASSERT NUM_POKEMON_INDEXES < HM01, \
"A bug in GetName will get TM/HM names for Pokémon above ${x:HM01}."
assert NUM_ATTACKS < HM01, \
ASSERT NUM_ATTACKS < HM01, \
"A bug in GetName will get TM/HM names for moves above ${x:HM01}."
assert NUM_TRAINERS < HM01, \
ASSERT NUM_TRAINERS < HM01, \
"A bug in GetName will get TM/HM names for trainers above ${x:HM01}."
cp HM01
jp nc, GetMachineName
Expand Down
2 changes: 1 addition & 1 deletion layout.link
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ WRAM0
org $c100
"Sprite State Data"
"OAM Buffer"
org $dfff
org $df00
"Stack"
VRAM
"VRAM"
Expand Down
8 changes: 4 additions & 4 deletions macros/asserts.asm
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ 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
Expand All @@ -136,10 +136,10 @@ 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
51 changes: 29 additions & 22 deletions macros/wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,44 @@ battle_struct: MACRO
ENDM

spritestatedata1: MACRO
\1PictureID:: db
\1MovementStatus:: db
\1ImageIndex:: db
\1YStepVector:: db
\1YPixels:: db
\1XStepVector:: db
\1XPixels:: db
\1PictureID:: db
\1MovementStatus:: db
\1ImageIndex:: db
\1YStepVector:: db
\1YPixels:: db
\1XStepVector:: db
\1XPixels:: db
\1IntraAnimFrameCounter:: db
\1AnimFrameCounter:: db
\1FacingDirection:: db
\1YAdjusted:: db
\1XAdjusted:: db
\1CollisionData:: db
\1AnimFrameCounter:: db
\1FacingDirection:: db
\1YAdjusted:: db
\1XAdjusted:: db
\1CollisionData:: db
ds 3
\1End::
ENDM

spritestatedata2: MACRO
\1WalkAnimationCounter:: db
ds 1
\1YDisplacement:: db
\1XDisplacement:: db
\1MapY:: db
\1MapX:: db
\1MovementByte1:: db
\1GrassPriority:: db
\1MovementDelay:: db
\1OrigFacingDirection:: db
\1YDisplacement:: db
\1XDisplacement:: db
\1MapY:: db
\1MapX:: db
\1MovementByte1:: db
\1GrassPriority:: db
\1MovementDelay:: db
\1OrigFacingDirection:: db
ds 3
\1PictureID:: db
\1ImageBaseOffset:: db
\1PictureID:: db
\1ImageBaseOffset:: db
ds 1
\1End::
ENDM

sprite_oam_struct: MACRO
\1YCoord:: db
\1XCoord:: db
\1TileID:: db
\1Attributes:: db
ENDM
29 changes: 15 additions & 14 deletions sram.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SECTION "Sprite Buffers", SRAM ; BANK 0
SECTION "Sprite Buffers", SRAM

sSpriteBuffer0:: ds SPRITEBUFFERSIZE
sSpriteBuffer1:: ds SPRITEBUFFERSIZE
Expand All @@ -9,42 +9,43 @@ sSpriteBuffer2:: ds SPRITEBUFFERSIZE
sHallOfFame:: ds HOF_TEAM * HOF_TEAM_CAPACITY


SECTION "Save Data", SRAM ; BANK 1
SECTION "Save Data", SRAM

ds $598

sPlayerName:: ds NAME_LENGTH
sMainData:: ds wMainDataEnd - wMainDataStart
sMainData:: ds wMainDataEnd - wMainDataStart
sSpriteData:: ds wSpriteDataEnd - wSpriteDataStart
sPartyData:: ds wPartyDataEnd - wPartyDataStart
sCurBoxData:: ds wBoxDataEnd - wBoxDataStart
sTileAnimations:: ds 1
sMainDataCheckSum:: ds 1
sPartyData:: ds wPartyDataEnd - wPartyDataStart
sCurBoxData:: ds wBoxDataEnd - wBoxDataStart
sTileAnimations:: db
sMainDataCheckSum:: db


; The PC boxes will not fit into one SRAM bank,
; so they use multiple SECTIONs
box_n = 0
boxes: MACRO
rept \1
REPT \1
box_n = box_n + 1
sBox{d:box_n}:: ds wBoxDataEnd - wBoxDataStart
endr
ENDR
ENDM

SECTION "Saved Boxes 1", SRAM ; BANK 2
SECTION "Saved Boxes 1", SRAM

; sBox1 - sBox6
boxes 6
sBank2AllBoxesChecksum:: ds 1
sBank2AllBoxesChecksum:: db
sBank2IndividualBoxChecksums:: ds 6

SECTION "Saved Boxes 2", SRAM ; BANK 3
SECTION "Saved Boxes 2", SRAM

; sBox7 - sBox12
boxes 6
sBank3AllBoxesChecksum:: ds 1
sBank3AllBoxesChecksum:: db
sBank3IndividualBoxChecksums:: ds 6

; All 12 boxes fit within 2 SRAM banks
assert box_n == NUM_BOXES, \
ASSERT box_n == NUM_BOXES, \
"boxes: Expected {d:NUM_BOXES} total boxes, got {d:box_n}"
Loading

0 comments on commit 8701ef4

Please sign in to comment.