We no longer assume that the test repos don’t exist when we run
run-tests.sh. This allows developers to choose to keep them, to allow
them to run the tests more quickly.
- Add the test repos to the .gitignore.
- Check if the directory for each repo already exists, before trying to
clone it.
- Do a git pull for each repo, to ensure that existing copies of repos
are up-to-date.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This ensures that build breaks to any of the test projects don’t immediately cause rgbds tests to fail.
On clone, I’ve set it up to pull the commits since the day before the desired commit. Sadly, this will clone more recent commits that we’re not testing, but at least it ensures that the desired commit can be checked out. This is hopefully a good enough replacement for —depth=1.
Signed-off-by: Ben10do <Ben10do@users.noreply.github.com>
Two variables, pSection->Data and tSymbols, were previously set to ‘dummymem’, a global variable that was otherwise not used.
As this can potentially cause alignment warnings on Clang, this commit replaces that mechanism with a plain old NULL pointer, which is more generally used as a dummy pointer value.
Signed-off-by: Ben10do <Ben10do@users.noreply.github.com>
We no longer assume that the test repos don’t exist when we run run-tests.sh. This allows developers to choose to keep them, to allow them to run the tests more quickly.
- Add the test repos to the .gitignore.
- Check if the directory for each repo already exists, before trying to clone it.
- Do a `git pull` for each repo, to ensure that existing copies of repos are up-to-date.
Signed-off-by: Ben10do <Ben10do@users.noreply.github.com>
A regression was spotted in rgbfix 0.3.7, where we would accidentally include the first byte of the existing checksum when calculating a global checksum. We now correctly ignore both of the existing checksum bytes.
This was spotted when running rgbfix on the Pokémon Gold/Silver betas, as they have a non-zero global checksum.
Fixes#280.
Signed-off-by: Ben10do <Ben10do@users.noreply.github.com>
The following mnemonics are now valid:
- ld
- ldh
- ldio
The following are valid as operands:
- [$ff00+c]
- [$ff00 + c]
- [c]
This is done for consistency with 'ld [$FF00+n],a' and variations of it.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
The tests are not exhaustive, there are some conditions that aren't
checked. The tests are based in the C standard rules about undefined
behaviour.
This is a compatibility break but, hopefully, all projects are using
sane values. If not, there is no guarantee that the projects will build
in any platform where RGBDS can be compiled, so it would be better to
fix them.
Even though, technically, the left shift of a negative value is always
undefined, some projects rely on its current behaviour. This is the
reason why this doesn't cause a fatal error.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
GCC has an Undefined Behavior Sanitizer (ubsan), which enables run-time
checks of undefined behaviour. It has been enabled for the `develop`
build target.
A small bug detected with it has been fixed.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
The Linux kernel expects the SPDX license tag to be in the first line of
all source code files. The reason is that they have many different
license headers, and this simplifies the work for any tool that has to
determine the license of each file.
In this project, the license headers follow the same pattern, so it
isn't useful.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Previously, the output file was opened before trying to open the
overlay. Because of this, rgblink generated an empty output file if the
overlay couldn't be opened.
Now the overlay is opened (and checked) before the output file, so the
output file is only generated if the overlay is found.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Rewrite rgbfix to perform most actions in memory.
Limit file operations to a small number that can be reasonably checked,
and do the majority of the actual work on a buffered header in memory
where operations won't fail.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Limit file operations to a small number that can be reasonably checked,
and do the majority of the actual work on a buffered header in memory
where operations won't fail.
Enable a lot of GCC warnings and cleanup Makefile and compiler macros
Most of the warnings in the GCC documentation have been enabled. As the
build system was using `-Werror`, this made the new builds very
susceptible to any minor change in the compiler. To fix that, this
option has been removed from the default Makefile target and it is only
used when the code is compiled through `make develop`.
The file `stdnoreturn.h` has been modified to remove support for
compilers that aren't actually tested. It now has defines for
`__attribute__((unused))` and it has been renamed to `helpers.h`.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Added define 'unused_' for '__attribute__((unused))'. The oldest version
of GCC with online docs (GCC 2.95.3, released in March 16, 2001 [1])
already has support for this attribute, so it doesn't make sense to
check the version.
Renamed 'noreturn' to 'noreturn_' for consistency.
[1] https://gcc.gnu.org/onlinedocs/
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
`__attribute__((noreturn))` has been supported since GCC 2.5, that was
released October 22, 1993. It doesn't make sense to check if the version
is at least that one, we are compiling for C99, that is more modern. [1]
Also, remove the MSVC check. This code is never compiled with it so
there may be problems that need to be solved to make it compile. All
releases cross-compiled from linux. If there is an actual need to
support MSVC, the compiler definitions can be added again.
Also, if the compiler is not supported, the compiler helpers default to
nothing, so the code can still compile.
[1] https://gcc.gnu.org/onlinedocs/
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Remove '-Werror' from the default make target to make it easy for
regular users of RGBDS to compile the source code. Only a few basic
warnings are left in that target.
All the warnings have been moved to a new target called 'develop'. This
target is now the one used in Travis CI to check for problems during
compilation.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
-Wformat-truncation is set to 1 instead of 2 because in some cases the
return value of snprintf is used to warn about truncations but GCC still
creates a warning for it, preventing the compilation from continuing.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
-Wsign-compare has been disabled because flex generates a comparison
that triggers a warning and cannot be fixed in the code.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Fix a few warnings related needed to build the source with this option.
Add new exception to .checkpatch.conf.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
When '@' is used as argument of any instruction (LD, JR, JP, etc), the
address it refers to is the address of the first byte of the
instruction. When '@' is used with DB/DW/DL, it refers to the same
address it is being placed at. This means that instructions need an
offset of 1 byte and others need an offset of 0 bytes.
The assembler doesn't evaluate anything related to '@' because it would
only work in sections with a fixed base address. It is left to the
linker. This means that the offset needs to be added to the RPN
expression of the patch that is saved in the linker. It isn't enough by
adding an offset to the final expresion. The following value wouldn't be
calculated correctly (even if it doesn't make sense):
JP @ * @
The correct patch is `(@ - 1) * (@ - 1)`, not `(@ * @) - 1`.
This patch introduces an offset on 1 byte by default in every line, and
sets it to 0 only if a DB/DW/DL is detected.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This change removes 2 reduce/reduce conflicts in the parser while
preserving the behaviour of the rules.
Note that now each list with empty elements will only print a warning
per line.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Previously, JR was only allowed to labels (in the same section, or
different sections). When trying to JR to an address specified as a
numeric value, rgbasm would fail to calculate the JR offset (as it
doesn't know the final address of the JR so it can't calculate the
difference).
This patch makes rgblink calculate the offset whenever there is a JR.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Images are allowed to have any arbitrary height if the width is 8. If
the height is not a multiple of 8, the number of tiles calculated won't
be an exact number and it will be rounded down. This patch increases the
number of tiles allocated in this case to prevent rgbgfx from accessing
memory that hasn't been allocated.
The buffers are now initialized to 0 with calloc instead of being
created with malloc.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>