Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2008-09-04 07:50:04

Lai
New member
Registered: 2008-03-17
Posts: 5

RGBDS-Lmod

Hey, I started patching the RGBDS source code a couple of weeks ago for my own amusement, but I think it turned out quite nice so why not share it right? Some features, especially what I call 'contained' sections, are a bit hard to explain (and has a very limited use) but
I did my best to describe it in the documentation.

Anyways, if people use it and find bugs or want some features added you're most welcome to post in this thread.

---> source-code + documentation <---

change-log for this version:
1.10-Lmod-00 (2008-09-03):
rgbasm:
- Separated output between stdout and stderr.
- Assembly will insterrupt infinite loop of errors.
- Improved error messages.
- DQ and RQ directives added for 32-bit data structure.
- Allow only a part of a binary file to be included instead of the whole thing. Syntax: INCBIN "stuff.dat", start_pos, length
- Added output of file dependency information for each file included/assembled. Enabled with a command line option.
- Added a command line option -q to for quiet mode (suppress messages except errors).
- Changed default fillchar to 0xFF.
- Added STRTRIM, STRLTRIM, STRRTRIM directives to allow trimming of white space from strings in macro arguments.
- Allow PC-relative jumps out of section as long as source and destination section/address is fixed.
- Allow PC-relative jumps from $00xx to $FFxx.
- Fixed seg. fault when running with options but no input file.
- Added section types ALIGNED_HOME, ALIGNED_CODE and ALIGNED_DATA.
- Updated to RGB3 object format with section names and new section types.
- Added section types CONTAINED_HOME, CONTAINED_CODE and CONTAINED_DATA.

xlink:
- Separated output between stdout and stderr.
- Changed default fillchar to 0xFF.
- Fixed seg. fault when running with options but no input file.
- Added functionality for ALIGNED_HOME, ALIGNED_CODE, ALIGNED_DATA.
- Updated RGB3 object format with section names and new section types.
- Print section names in mapfile.
- Added functionality for CONTAINED_HOME, CONTAINED_CODE and CONTAINED_DATA.

xlib:
- Separated output between stdout and stderr.

rgbfix:
- Separated output between stdout and stderr.
- Added a command line option -q to for quiet mode (suppress messages except errors).
- Fixed seg. fault when running with options but no input file.
- Added optional argument for command line option -p for setting byte value with which the ROM should be padded and changed default to 0xFF.
- Added command line option -m for setting RAM size.
- Added command line option -b for setting MBC type.
- If romsize > 32kB, MBC type is 0x00 and the filename has gbc extension, '-v' will now change MBC type to 0x19 (ROM+MBC5) instead of 0x01 (ROM+MBC1).
- Added command line options -c and -o for setting byte 0x143 to 0x80 or 0xC0.
- Added names for different MBC types.
- Added warning when using -c or -o option on file that does not have gbc extension.
- Added warning when -c or -o option overwrites last character of 16 character long title set by -t option.
- A title added with the -t option that is shorter than 16 chars is now extended with spaces.

Offline

 

#2 2008-09-07 23:49:05

Shiny
Member
Registered: 2008-03-17
Posts: 21

Re: RGBDS-Lmod

Very nice edits you've made there (: I'll definitely put this to good use!
I especially like the inclusion of aligned sections and partial binary inclusion; two features that I've been wanting for a long while (doing this kind of stuff manually is aggravating), and cross-section JRs! Wanted that one too, kekeke (;

One last thing; Do you have an example of a circumstance where a contained section might be useful? I'm not quite following the description in the documentation.

Thanks for your hard work!

Offline

 

#3 2008-09-08 01:09:42

Lai
New member
Registered: 2008-03-17
Posts: 5

Re: RGBDS-Lmod

OK, I'll try to elaborate on contained sections.
So you want to copy, say, an ASCII string then you might have a situation like this without contained sections:

Code:

SECTION "CopyRoutine1",HOME
CopyStringToHL:
    ld    de,StringStart
    ld    c,StringEnd - StringStart     ;We know that the string is shorter than 256 chars
.copy:
    ld    a,[de]
    ld    [hl+],a
    inc   de                           ;<-----------------
    dec   c
    jr    nz,.copy

SECTION "StringToCopy",DATA
StringStart:
    db "Hello there! I'm an ASCII string"
StringEnd:

However by putting this in a contained section we can do this.

Code:

SECTION "CopyRoutine2",HOME
CopyStringToHL:
    ld    de,StringStart
    ld    c,StringEnd - StringStart     ;We know that the string is shorter than 256 chars
.copy:
    ld    a,[de]
    ld    [hl+],a
    inc   e                            ;<----- less cycles OMGWTF
    dec   c
    jr    nz,.copy

SECTION "StringToCopy",CONTAINED_DATA[$100]
StringStart:
    db "Hello there! I'm an ASCII string"
StringEnd:

That's basically it. In this example CONTAINED_DATA[$100] guarantees that you won't have to increment the d register when copying by putting the section at a safe start address. In other words the section is contained in the address interval where d is constant.

Offline

 

#4 2009-01-05 04:48:09

dalton
New member
Registered: 2009-01-05
Posts: 6

Re: RGBDS-Lmod

finally a fix!

Offline

 

#5 2014-09-01 02:28:42

dalton
New member
Registered: 2009-01-05
Posts: 6

Re: RGBDS-Lmod

I use this a lot now, and for me the single most useful new feature in this version is the dependency file generation. It makes it so much easier to work with a makefile!

If there is ever an update, there are two features I would really like to see:
1) Something like the ORG directive, so that I can compile code which is designed to run from ram. Currently it's very difficult to run anything other than code with only relative jumps from RAM.
2) Compile to binary. So that I can write for instance a very long unrolled loop (designed to run from RAM). I want to compile it to a binary file and then crunch it. On the game boy I want to unpack the crunched binary data to RAM and run it.

Cheers
Dalton

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson