RGBDS "data" segment

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
User avatar
slembcke
Posts: 170
Joined: Fri Nov 24, 2017 2:40 pm

RGBDS "data" segment

Post by slembcke » Sun Oct 21, 2018 9:48 am

Is there any way to implement something like a "data" segment using RGBDS? Specificall, it would be really nice to define and declare data once and end up with a block in the ROM I can just memcpy into place. Not really a big deal, I'm just coming to a realization how handy that is in more sophisticated assemblers.

tepples
Posts: 21746
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: RGBDS "data" segment

Post by tepples » Sun Oct 21, 2018 10:06 am

Upvote issue #274.

User avatar
slembcke
Posts: 170
Joined: Fri Nov 24, 2017 2:40 pm

Re: RGBDS "data" segment

Post by slembcke » Sun Oct 21, 2018 4:58 pm

Hmm. Ok. Good to know I'm not the only one.

nitro2k01
Posts: 228
Joined: Sat Aug 28, 2010 9:01 am

Re: RGBDS "data" segment

Post by nitro2k01 » Sun Nov 18, 2018 2:17 pm

I've solved this by having a bunch of macros that cover all relevant instructions.

Code: Select all

;; Relocated code macros
JPR:	MACRO		; Relocated jump absolute
	jp	\1+(RCODE-RCODE_S)
	ENDM

JPRC:	MACRO		; Relocated jump absolute conditional
	jp	\1,\2+(RCODE-RCODE_S)
	ENDM

CALLR:	MACRO		; Relocated call
	call	\1+(RCODE-RCODE_S)
	ENDM

CALLRC:	MACRO		; Relocated call conditional
	call	\1,\2+(RCODE-RCODE_S)
	ENDM

LDHLR:	MACRO		; Relocated ld	HL,addr
	ld	HL,\1+(RCODE-RCODE_S)
	ENDM

LDBCR:	MACRO		; Relocated ld	BC,addr
	ld	BC,\1+(RCODE-RCODE_S)
	ENDM

LDDER:	MACRO		; Relocated ld	DE,addr
	ld	DE,\1+(RCODE-RCODE_S)
	ENDM

LDAR:	MACRO		; Relocated ld	A,[addr]
	ld	A,[\1+(RCODE-RCODE_S)]
	ENDM

DWR:	MACRO		; Relocated dw	addr
	DW	\1+(RCODE-RCODE_S)
	ENDM


STAR:	MACRO		; Relocated ld	[addr],A
	ld	[\1+(RCODE-RCODE_S)],A
	ENDM

PREPRELOCATE:	MACRO
        ld      HL,RCODE_S    ; Src
        ld      BC,(RCODE_S_END-RCODE_S)    ; Size
        ld      DE,RCODE        ; Dest
        
        call    COPYPROC


	ENDM

RCODE_AREA_START:	MACRO
RCODE_S::
	ENDM
	
RCODE_AREA_FINISH:	MACRO
RCODE_S_END::
	ENDM

RCODE_RAM_ALLOC:	MACRO
SECTION	"RAMCODE",BSS;;[\1-(RCODE_S_END-RCODE_S)]
RCODE::
	ds	RCODE_S_END-RCODE_S
RCODE_END::
	ENDM

Post Reply