mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
This touched a lot more code than initially expected, for two reasons. First, this broke a big RGBASM assumption: that sections are always being written to at their end. This plus other problems required touching basically the entirety of `section.c`. Second, I tried different solutions to solve the above problem, and along the way I cleaned up many things around. (I believe that keeping this to "cleanup" commits yields subpar results, and since it's boring they get postponed anyways.) RGBLINK support still needs to be added, but this will come next.
38 lines
675 B
NASM
38 lines
675 B
NASM
SECTION UNION "test", WRAM0
|
|
Base:
|
|
ds $1000
|
|
|
|
SECTION UNION "test", WRAM0,ALIGN[8]
|
|
ds 42
|
|
Plus42:
|
|
|
|
SECTION UNION "test", WRAM0,ALIGN[4]
|
|
|
|
SECTION UNION "test", WRAM0[$C000]
|
|
; Since the section's base address is known, the labels are constant now
|
|
ds $1000 ; This shouldn't overflow
|
|
End:
|
|
|
|
SECTION UNION "test", WRAM0,ALIGN[9]
|
|
|
|
|
|
check_label: MACRO
|
|
EXPECTED equ \2
|
|
IF \1 == EXPECTED
|
|
RESULT equs "OK!"
|
|
ELSE
|
|
RESULT equs "expected {EXPECTED}"
|
|
ENDC
|
|
PURGE EXPECTED
|
|
|
|
PRINTT "\1 is at {\1} ({RESULT})\n"
|
|
PURGE RESULT
|
|
ENDM
|
|
|
|
check_label Base, $C000
|
|
check_label Plus42, $C000 + 42
|
|
check_label End, $D000
|
|
|
|
|
|
SECTION "test", WRAM0 ; Don't allow creating a section that's not a union!
|