Skip to content

Commit 65d408e

Browse files
authored
Document more about the RGBDS architecture (#1809)
1 parent 3677ab2 commit 65d408e

File tree

6 files changed

+318
-69
lines changed

6 files changed

+318
-69
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
root = true
33
indent_style = tab
44
indent_size = tab
5-
tab_width = 8
5+
tab_width = 4
66
charset = utf-8
77
insert_final_newline = true
88
trim_trailing_whitespace = true

ARCHITECTURE.md

Lines changed: 233 additions & 28 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 80 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ but doesn't know that there's someone working on it.
5151

5252
Note that you must contribute all your changes under the MIT License. If you are
5353
just modifying a file, you don't need to do anything (maybe update the copyright
54-
years). If you are adding new files, you need to use the `SPDX-License-Identifier: MIT`
55-
header.
54+
years). If you are adding new files, you need to use the
55+
`SPDX-License-Identifier: MIT` header.
5656

5757
1. Fork this repository.
5858
2. Checkout the `master` branch.
@@ -63,71 +63,97 @@ header.
6363
new warning (but it may be possible to remove some warning checks if it makes
6464
the code much easier).
6565
5. Test your changes by running `./run-tests.sh` in the `test` directory.
66-
(You must run `./fetch-test-deps.sh` first; if you forget to, the test suite will fail and remind you mid-way.)
66+
(You must run `./fetch-test-deps.sh` first; if you forget to, the test suite
67+
will fail and remind you mid-way.)
6768
5. Format your changes according to `clang-format`, which will reformat the
6869
coding style according to our standards defined in `.clang-format`.
6970
6. Create a pull request against the branch `master`.
70-
7. Be prepared to get some comments about your code and to modify it. Tip: Use
71+
7. Check the results of the GitHub Actions CI jobs for your pull request. The
72+
"Code format checking" and "Regression testing" jobs should all succeed.
73+
The "Diff completeness check" and "Static analysis" jobs should be manually
74+
checked, as they may output warnings which do not count as failure errors.
75+
The "Code coverage report" provides an
76+
[LCOV](https://github.com/linux-test-project/lcov)-generated report which
77+
can be downloaded and checked to see if your new code has full test coverage.
78+
8. Be prepared to get some comments about your code and to modify it. Tip: Use
7179
`git rebase -i origin/master` to modify chains of commits.
7280

7381
## Adding a test
7482

75-
The test suite is a little ad-hoc, so the way tests work is different for each program being tested.
83+
The test suite is a little ad-hoc, so the way tests work is different for each
84+
program being tested.
7685

77-
Feel free to modify how the test scripts work, if the thing you want to test doesn't fit the existing scheme(s).
86+
Feel free to modify how the test scripts work, if the thing you want to test
87+
doesn't fit the existing scheme(s).
7888

7989
### RGBASM
8090

8191
Each `.asm` file corresponds to one test.
8292
RGBASM will be invoked on the `.asm` file with all warnings enabled.
8393

84-
If a `.out` file exists, RGBASM's output (`print`, `println`, etc.) must match its contents.
85-
If a `.err` file exists, RGBASM's error output (`warn`, errors, etc.) must match its contents.
94+
If a `.out` file exists, RGBASM's output (`print`, `println`, etc.) must match
95+
its contents.
96+
If a `.err` file exists, RGBASM's error output (`warn`, errors, etc.) must match
97+
its contents.
8698

87-
If a `.out.bin` file exists, the object file will be linked, and the generated ROM truncated to the length of the `.out.bin` file.
99+
If a `.out.bin` file exists, the object file will be linked, and the generated
100+
ROM truncated to the length of the `.out.bin` file.
88101
After that, the ROM must match the `.out.bin` file.
89102

90103
### RGBLINK
91104

92105
Each `.asm` file corresponds to one test, or one *set* of tests.
93106

94-
All tests begin by assembling the `.asm` file into an object file, which will be linked in various ways depending on the test.
107+
All tests begin by assembling the `.asm` file into an object file, which will be
108+
linked in various ways depending on the test.
95109

96110
#### Simple tests
97111

98112
These simply check that RGBLINK's output matches some expected output.
99113

100-
A `.out` file **must** exist, and RGBLINK's total output must match that file's contents.
114+
A `.out` file **must** exist, and RGBLINK's total output must match that file's
115+
contents.
101116

102-
Additionally, if a `.out.bin` file exists, the `.gb` file generated by RGBLINK must match it.
117+
Additionally, if a `.out.bin` file exists, the `.gb` file generated by RGBLINK
118+
must match it.
103119

104120
#### Linker script tests
105121

106122
These allow applying various linker scripts to the same object file.
107-
If one or more `.link` files exist, whose names start the same as the `.asm` file, then each of those files correspond to one test.
123+
If one or more `.link` files exist, whose names start the same as the `.asm`
124+
file, then each of those files correspond to one test.
108125

109-
Each `.link` linker script **must** be accompanied by a `.out` file, and RGBLINK's total output must match that file's contents when passed the corresponding linker script.
126+
Each `.link` linker script **must** be accompanied by a `.out` file, and
127+
RGBLINK's total output must match that file's contents when passed the
128+
corresponding linker script.
110129

111130
#### Variant tests
112131

113132
These allow testing RGBLINK's `-d`, `-t`, and `-w` flags.
114-
If one or more <code>-<var>&lt;flag&gt;</var>.out</code> or <code>-no-<var>&lt;flag&gt;</var>.out</code> files exist, then each of them corresponds to one test.
133+
If one or more
134+
<code>-<var>&lt;flag&gt;</var>.out</code> or <code>-no-<var>&lt;flag&gt;</var>.out</code>
135+
files exist, then each of them corresponds to one test.
115136

116-
The object file will be linked with and without said flag, respectively; and in each case, RGBLINK's total output must match the `.out` file's contents.
137+
The object file will be linked with and without said flag, respectively; and in
138+
each case, RGBLINK's total output must match the `.out` file's contents.
117139

118140
### RGBFIX
119141

120142
Each `.flags` file corresponds to one test.
121143
Each one is a text file whose first line contains flags to pass to RGBFIX.
122-
(There may be more lines, which will be ignored; they can serve as comments to explain what the test is about.)
144+
(There may be more lines, which will be ignored; they can serve as comments to
145+
explain what the test is about.)
123146

124-
RGBFIX will be invoked on the `.bin` file if it exists, or else on default-input.bin.
147+
RGBFIX will be invoked on the `.bin` file if it exists, or else on
148+
default-input.bin.
125149

126150
If no `.out` file exist, RGBFIX is not expected to output anything.
127151
If one *does* exist, RGBFIX's output **must** match the `.out` file's contents.
128152

129-
If no `.err` file exists, RGBFIX is simply expected to be able to process the file normally.
130-
If one *does* exist, RGBFIX's return status is ignored, but its error output **must** match the `.err` file's contents.
153+
If no `.err` file exists, RGBFIX is simply expected to be able to process the
154+
file normally.
155+
If one *does* exist, RGBFIX's return status is ignored, but its error output
156+
**must** match the `.err` file's contents.
131157

132158
Additionally, if a `.gb` file exists, the output of RGBFIX must match the `.gb`.
133159

@@ -139,20 +165,27 @@ There are three kinds of test.
139165

140166
Each `.png` file corresponds to one test.
141167
RGBGFX will be invoked on the file.
142-
If a `.flags` file exists, it will be used as part of the RGBGFX invocation (<code>@<var>&lt;file&gt;</var>.flags</code>).
168+
If a `.flags` file exists, it will be used as part of the RGBGFX invocation
169+
(<code>@<var>&lt;file&gt;</var>.flags</code>).
143170

144-
If `.out.1bpp`, `.out.2bpp`, `.out.pal`, `.out.tilemap`, `.out.attrmap`, or `.out.palmap` files exist, RGBGFX will create the corresponding kind of output, which must match the file's contents.
171+
If `.out.1bpp`, `.out.2bpp`, `.out.pal`, `.out.tilemap`, `.out.attrmap`, or
172+
`.out.palmap` files exist, RGBGFX will create the corresponding kind of output,
173+
which must match the file's contents.
145174
Multiple kinds of output may be tested for the same input.
146175

147-
If no `.err` file exists, RGBGFX is simply expected to be able to process the file normally.
148-
If one *does* exist, RGBGFX's return status is ignored, but its output **must** match the `.err` file's contents.
176+
If no `.err` file exists, RGBGFX is simply expected to be able to process the
177+
file normally.
178+
If one *does* exist, RGBGFX's return status is ignored, but its output **must**
179+
match the `.err` file's contents.
149180

150181
#### Reverse tests
151182

152183
Each `.1bpp` or `.2bpp` file corresponds to one test.
153-
RGBGFX will be invoked on the file with `-r 1` for reverse mode, then invoked on the output without `-r 1`.
184+
RGBGFX will be invoked on the file with `-r 1` for reverse mode, then invoked on
185+
the output without `-r 1`.
154186
The round-trip output must match the input file's contents.
155-
If a `.flags` file exists, it will be used as part of the RGBGFX invocation (<code>@<var>&lt;file&gt;</var>.flags</code>).
187+
If a `.flags` file exists, it will be used as part of the RGBGFX invocation
188+
(<code>@<var>&lt;file&gt;</var>.flags</code>).
156189

157190
#### Random seed tests
158191

@@ -161,30 +194,41 @@ Each one is a binary RNG file which is passed to the `rgbgfx_test` program.
161194

162195
### Downstream projects
163196

164-
1. Make sure the downstream project supports <code>make <var>&lt;target&gt;</var> RGBDS=<var>&lt;path/to/RGBDS/&gt;</var></code>.
165-
While the test suite supports any Make target name, only [Make](//gnu.org/software/make) is currently supported, and the Makefile must support a `RGBDS` variable to use a non-system RGBDS directory.
166-
197+
1. Make sure the downstream project supports
198+
<code>make <var>&lt;target&gt;</var> RGBDS=<var>&lt;path/to/RGBDS/&gt;</var></code>.
199+
While the test suite supports any Make target name, only
200+
[Make](//gnu.org/software/make) is currently supported, and the Makefile must
201+
support a `RGBDS` variable to use a non-system RGBDS directory.
202+
167203
Also, only projects hosted on GitHub are currently supported.
168-
2. Add the project to `test/fetch-test-deps.sh`: add a new `action` line at the bottom, following the existing pattern:
204+
2. Add the project to `test/fetch-test-deps.sh`: add a new `action` line at the
205+
bottom, following the existing pattern:
169206

170207
```sh
171208
action <owner> <repo> <date of last commit> <hash of last commit>
172209
```
173-
174-
(The date is used to avoid fetching too much history when cloning the repositories.)
175-
3. Add the project to `test/run-tests.sh`: add a new `test_downstream` line at the bottom, following the existing pattern:
176-
210+
211+
(The date is used to avoid fetching too much history when cloning the
212+
repositories.)
213+
3. Add the project to `test/run-tests.sh`: add a new `test_downstream` line at
214+
the bottom, following the existing pattern:
215+
177216
```sh
178217
test_downstream <owner> <repo> <makefile target> <build file> <sha1 hash of build file>
179218
```
180219

181220
## Container images
182221

183-
The CI will [take care](https://github.com/gbdev/rgbds/blob/master/.github/workflows/build-container.yml) of updating the [rgbds container](https://github.com/gbdev/rgbds/pkgs/container/rgbds) image tagged `master`.
222+
The CI will
223+
[take care](https://github.com/gbdev/rgbds/blob/master/.github/workflows/build-container.yml)
224+
of updating the
225+
[rgbds container](https://github.com/gbdev/rgbds/pkgs/container/rgbds) image
226+
tagged `master`.
184227

185228
When a git tag is pushed, the image is also tagged with that tag.
186229

187-
The image can be built locally and pushed to the GitHub container registry by manually running:
230+
The image can be built locally and pushed to the GitHub container registry by
231+
manually running:
188232

189233
```bash
190234
# e.g. to build and tag as 'master'

CONTRIBUTORS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ RGBGFX generates palettes using algorithms found in the paper
4444
([GitHub](https://github.com/pagination-problem/pagination), MIT license),
4545
by Aristide Grange, Imed Kacem, and Sébastien Martin.
4646

47-
RGBGFX's color palette was taken from [SameBoy](https://sameboy.github.io), with permission and help
48-
by [LIJI](https://github.com/LIJI32).
47+
RGBGFX's color palette was taken from [SameBoy](https://sameboy.github.io), with
48+
permission and help by [LIJI](https://github.com/LIJI32).

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN apt-get update && \
1212
RUN ./.github/scripts/install_deps.sh ubuntu-22.04
1313
RUN make -j CXXFLAGS="-O3 -flto -DNDEBUG -static" PKG_CONFIG="pkg-config --static" Q=
1414

15-
# Create an archive with the compiled executables and all the necessary to install it,
15+
# Create an archive with the compiled executables and all the necessary to install it,
1616
# so it can be copied outside of the container and installed/used in another system
1717
RUN tar caf rgbds-linux-x86_64.tar.xz --transform='s#.*/##' rgbasm rgblink rgbfix rgbgfx man/* .github/scripts/install.sh
1818

man/gbz80.7

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ Flags: See
573573
ComPLement accumulator
574574
.Po Sy A
575575
=
576-
.Sy ~A
576+
.Sy ~A
577577
.Pc ;
578578
also called bitwise NOT.
579579
.Pp

0 commit comments

Comments
 (0)