Last active
August 29, 2015 14:25
-
-
Save Stewmath/a8f2d7473eb16f254aea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Macro which allows data to cross over banks, used for map layout data. | |
; Doesn't support more than 1 bank crossing at a time | |
; Must have DATA_ADDR and DATA_BANK defined before use. | |
; ARG 1: name | |
.macro m_RoomLayoutData | |
.FOPEN "build/maps/\1.cmp" m_DataFile | |
.FSIZE m_DataFile SIZE | |
.FCLOSE m_DataFile | |
.REDEFINE SIZE SIZE-1 | |
.IF DATA_ADDR + SIZE >= $8000 | |
.REDEFINE DATA_READAMOUNT $8000-DATA_ADDR | |
\1: .incbin "build/maps/\1.cmp" SKIP 1 READ DATA_READAMOUNT | |
.REDEFINE DATA_BANK DATA_BANK+1 | |
.BANK DATA_BANK SLOT 1 | |
.ORGA $4000 | |
.IF DATA_READAMOUNT < SIZE | |
.incbin "build/maps/\1.cmp" SKIP DATA_READAMOUNT+1 | |
.ENDIF | |
.REDEFINE DATA_ADDR $4000 + SIZE-DATA_READAMOUNT | |
.ELSE | |
\1: .incbin "build/maps/\1.cmp" SKIP 1 | |
.REDEFINE DATA_ADDR DATA_ADDR + SIZE | |
.ENDIF | |
.UNDEFINE SIZE | |
.endm | |
; Usage: | |
.DEFINE DATA_ADDR $4000 | |
.DEFINE DATA_BANK $1d | |
m_RoomLayoutData room0100 | |
m_RoomLayoutData room0101 | |
m_RoomLayoutData room0102 | |
m_RoomLayoutData room0103 | |
; ... | |
; Envisioned alternative using INTERBANK sections: | |
.MACRO m_RoomLayoutDataWithSections | |
\1: .incbin "build/maps/\1.cmp" SKIP 1 | |
.ENDM | |
.SECTION "Room Layout Data" INTERBANK | |
m_RoomLayoutDataWithSections room0100 | |
m_RoomLayoutDataWithSections room0101 | |
m_RoomLayoutDataWithSections room0102 | |
m_RoomLayoutDataWithSections room0103 | |
.ENDS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment