1RGBDS(5)                    BSD File Formats Manual                   RGBDS(5)
2

NAME

4     rgbds — object file format documentation
5

DESCRIPTION

7     This is the description of the object files used by rgbasm(1) and
8     rgblink(1).  Please, note that the specifications may change.  This
9     toolchain is in development and new features may require adding more
10     information to the current format, or modifying some fields, which would
11     break compatibility with older versions.
12

FILE STRUCTURE

14     The following types are used:
15
16     LONG is a 32‐bit integer stored in little‐endian format (Intel).  BYTE is
17     an 8‐bit integer.  STRING is a 0‐terminated string of BYTE.
18
19     ; Header
20
21     BYTE    ID[4]            ; "RGB4"
22     LONG    NumberOfSymbols  ; The number of symbols used in this file
23     LONG    NumberOfSections ; The number of sections used in this file
24
25     ; Symbols
26
27     REPT    NumberOfSymbols   ; Number of symbols defined in this object file.
28
29         STRING  Name          ; The name of this symbol. Local symbols are stored
30                               ; as "Scope.Symbol".
31
32         BYTE    Type          ; 0 = LOCAL symbol only used in this file.
33                               ; 1 = IMPORT this symbol from elsewhere (unused).
34                               ; 2 = EXPORT this symbol to other objects.
35
36         IF      Type != 1     ; If symbol is defined in this object file.
37
38             LONG    SectionID ; The section number (of this object file) in which
39                               ; this symbol is defined.
40
41             LONG    Value     ; The symbols value. It's the offset into that
42                               ; symbol's section.
43
44         ENDC
45
46     ENDR
47
48     ; Sections
49
50     REPT NumberOfSections
51         STRING  Name  ; Name of the section
52
53         LONG    Size  ; Size in bytes of this section
54
55         BYTE    Type  ; 0 = WRAM0
56                       ; 1 = VRAM
57                       ; 2 = ROMX
58                       ; 3 = ROM0
59                       ; 4 = HRAM
60                       ; 5 = WRAMX
61                       ; 6 = SRAM
62                       ; 7 = OAM
63
64         LONG    Org   ; Address to fix this section at. -1 if the linker should
65                       ; decide (floating address).
66
67         LONG    Bank  ; Bank to load this section into. -1 if the linker should
68                       ; decide (floating bank). This field is only valid for ROMX,
69                       ; VRAM, WRAMX and SRAM sections.
70
71         LONG    Align ; Alignment of this section (expressed as number of low bits
72                       ; to leave as 0). -1 if not defined.
73
74         IF      (Type == ROMX) || (Type == ROM0) ; Sections that can contain data.
75
76             BYTE    Data[Size]      ; Raw data of the section.
77
78             LONG    NumberOfPatches ; Number of patches to apply.
79
80             ; These types of sections may have patches
81
82             REPT    NumberOfPatches
83
84                 STRING  SourceFile   ; Name of the source file (for printing error
85                                      ; messages).
86
87                 LONG    Line         ; The line of the source file.
88
89                 LONG    Offset       ; Offset into the section where patch should
90                                      ; be applied (in bytes).
91
92                 BYTE    Type         ; 0 = BYTE patch.
93                                      ; 1 = little endian WORD patch.
94                                      ; 2 = little endian LONG patch.
95
96                 LONG    RPNSize      ; Size of the buffer with the RPN.
97                                      ; expression.
98
99                 BYTE    RPN[RPNSize] ; RPN expression. Definition below.
100
101             ENDR
102
103         ENDC
104
105     ENDR
106
107   RPN DATA
108     Expressions in the object file are stored as RPN.  This is an expression
109     of the form “2 5 +”.  This will first push the value “2” to the stack.
110     Then “5”.  The “+” operator pops two arguments from the stack, adds them,
111     and then pushes the result on the stack, effectively replacing the two
112     top arguments with their sum.  In the RGB format, RPN expressions are
113     stored as BYTEs with some bytes being special prefixes for integers and
114     symbols.
115
116           Value     Meaning
117           $00       + operator
118           $01       - operator
119           $02       * operator
120           $03       / operator
121           $04       % operator
122           $05       unary -
123           $06       | operator
124           $07       & operator
125           $08       ^ operator
126           $09       unary ~
127           $0A       && comparison
128           $0B       || comparison
129           $0C       unary!
130           $0D       == comparison
131           $0E       != comparison
132           $0F       > comparison
133           $10       < comparison
134           $11       >= comparison
135           $12       <= comparison
136           $13       << comparison
137           $14       >> comparison
138           $15       BANK() function.  A symbol ID follows.
139           $16       HRAMCheck. Check if the value is in HRAM, AND it with
140                               0xFF.
141           $80       LONG integer follows.
142           $81       LONG Symbol ID follows.
143

SEE ALSO

145     rgbasm(1), rgblink(1), rgbds(7), gbz80(7)
146

HISTORY

148     rgbds was originally written by Carsten Sørensen as part of the ASMotor
149     package, and was later packaged in RGBDS by Justin Lloyd.  It is now
150     maintained by a number of contributors at .:
151           https://github.com/rednex/rgbds
152
153RGBDS Manual                    April 17, 2017                    RGBDS Manual
Impressum