Commit Graph

1233 Commits

Author SHA1 Message Date
Eldred Habert
79f293c3d7 Merge pull request #529 from JL2210/cmake
Add CMake build system
2020-07-20 16:02:47 +02:00
Brayden Morris
83aa456d05 Fix error in documentation about unary not 2020-07-13 09:32:43 -06:00
James R Larrowe
819c36943e Add CMake build system
This should hopefully work torwards compatibility with more systems.
I've tried to make this as general as possible but some small assumptions
about the compiler are made. I've also tried to recreate the build process
as closely as possible, but I had to change some things slightly to work
with CMake (version strings, mainly).

For now, it doesn't allow in-source builds, as that could overwrite the
Makefile.

This adds:

- Support for more build systems
- Automatic dependency generation
- Performance gains (especially when using i.e. Ninja)

Defaults to Release build.
2020-07-03 15:10:18 -04:00
James Larrowe
240fca0861 Fix Clang warning in linkdefs
This one's really stupid; printing an int with %hhu gives a warning
even though a regular unsigned char is promoted to an int before
printing anyway. Silence it so the build with Clang works.

This is a regression introduced in 5c24de3
2020-06-23 23:29:49 -04:00
James Larrowe
69a41d8ef9 Fix indexing of banks array
When ROMX bank 1 is given, the banks array is indexed with an index
of 1 rather than an index of zero.
2020-06-17 13:33:48 -04:00
Jason Yuan
7624bd524c Fixed error in POP AF instruction reference
The "imaginary" equivalent instructions put the instructions in the wrong order (inc sp first).
2020-05-26 23:29:06 -04:00
James Larrowe
f88d9e728d Fix DJGPP build
GCC with the -std=c11 defines __STRICT_ANSI__. DJGPP checks if
__STRICT_ANSI__ is defined and if so doesn't define some things
mandated by POSIX such as struct stat, PATH_MAX, and others.
The -std=gnu11 option does not define this macro, so use it instead.

_DEFAULT_SOURCE isn't needed as no GNU nor BSD-specific functions
are used. Remove it.

Fix the last two occurrences of incorrect format specifiers for standard
fixed-width integer types.
2020-05-19 19:21:16 -04:00
ISSOtm
71fa62c9d1 Fix incorrectly spaced unary ! in RPN documentation 2020-05-13 01:20:34 +02:00
ISSOtm
5c6069dbe9 Add NULL and overflow checks to macro args 2020-05-13 01:17:58 +02:00
ISSOtm
d517d2d6b4 Change macro arg allocation to geometric growth array 2020-05-13 00:22:56 +02:00
ISSOtm
80218fa109 Fix array overflow on invalid macro arg evaluation
`macro_GetArg` had not been changed after the previous commit; however,
the old code relied on the `macroArgs->args` array being at least
`MAXMACROARGS` entries large (which was the case until the last commit).
The boundary against which it checked would have better been written as
`sizeof(macroArgs->args)/sizeof(macroArgs->args[0])`, I guess, but what's
done is done.
2020-05-12 16:44:23 +02:00
aaaaaa123456789
89fb372326 Set max macro arguments to 99,999 2020-05-12 06:46:17 -03:00
aaaaaa123456789
a828f82414 Remove fixed-size array for macro arguments 2020-05-12 06:46:07 -03:00
Eldred Habert
4d0d6664d7 Merge pull request #520 from JL2210/inttypes-stdint
Use inttypes for stdint types
2020-05-07 17:31:06 +02:00
James Larrowe
5c24de3dc4 Use inttypes for stdint types
This should help make RGBDS portable to systems with 16-bit integers,
like DOS.

For kicks, use the macros for 16-bit and 8-bit integers.

Fix other miscellaneous things, like #include ordering and other
printf-format related things.

Reduce repitition in math.c while I'm there.
2020-05-07 11:10:20 -04:00
ISSOtm
363458c3bc Fix semi-unused variable in lexer.c 2020-05-06 19:55:37 +02:00
ISSOtm
b299f6fb3b Fix uninitialized memory use with -MT and -MQ
This didn't break unless the first uninitialized byte was non-zero,
which happened to be the case on someone's Windows machine.

Would it be worth it setting up Valgrind in CI?
2020-05-06 19:19:10 +02:00
Eldred Habert
645473e336 Merge pull request #518 from JL2210/warn-parameterless-dx
Add empty data directive warning
2020-05-06 16:25:03 +02:00
James Larrowe
bdf397bba7 Add empty data directive warning
Fixes #516
2020-05-06 09:50:28 -04:00
ISSOtm
781a65ee49 Fix hashmap collisions sometimes hanging deletion 2020-05-03 19:13:12 +02:00
ISSOtm
c135e2c6a0 Fix local sym names not being expanded by PURGE
And an additional bug that broke the attached test
2020-05-03 19:06:48 +02:00
ISSOtm
12693081c9 Use colons for hour symbols 2020-04-28 13:05:06 +02:00
Eldred Habert
7c22954fd5 Merge pull request #513 from JL2210/disable-padding-option
Add option to disable padding in rgblink
2020-04-27 11:05:55 +02:00
ISSOtm
8958e352df Update documentation for new -x option 2020-04-27 11:04:29 +02:00
ISSOtm
573003113b Fix 0-byte sections incorrectly printed in map files
Fixes #515
2020-04-17 11:38:28 +02:00
JL2210
8b1351fc3e Add option to disable padding in rgblink
Fixes #307

RGBFIX can handle padding, so there's no reason why
we can't add an option to disable padding in rgblink.

Signed-off-by: JL2210 <larrowe.semaj11@gmail.com>
2020-04-15 09:34:51 -04:00
JL2210
7f9bd12f76 Add error checking and fix memory leak in gfx/gb.c
It's possible that tile could be leaked, so free it.

Fix sizeof convention and check the result of malloc.

Signed-off-by: JL2210 <larrowe.semaj11@gmail.com>
2020-04-13 22:02:24 -04:00
ISSOtm
5fe3a0adb6 Remove non-OPT options from Options struct 2020-04-13 17:15:00 +02:00
Eldred Habert
cdb4c5f553 Merge pull request #509 from JL2210/zero-alloc-use-fix-3
Fix use of zero-allocated memory
2020-04-13 02:50:58 +02:00
ISSOtm
57639f3765 Change comment style and use errx instead of err 2020-04-13 02:50:11 +02:00
Eldred Habert
9bec983923 Merge pull request #511 from JL2210/memory-errors
Fix memory errors in makepng
2020-04-13 02:39:17 +02:00
ISSOtm
2220f19fa7 Fix use-after-free with include in linker scripts
Fixes #510, and further proves that you *really* should not entrust memory
ownership management to humans :P
2020-04-13 02:36:19 +02:00
JL2210
2a734ecba2 Fix memory errors
This includes not checking the result of malloc and
using the wrong type in sizeof. Only the latter was
caught by scan-build.

Also use more idiomatic sizeof().

Signed-off-by: JL2210 <larrowe.semaj11@gmail.com>
2020-04-12 19:45:37 -04:00
JL2210
d21015e34a Fix use of zero-allocated memory
It's possible that the unsigned integer may overflow to zero,
and then we might use zero-allocated memory.

This is incredibly unlikely, and I would even go so far as to say
that this is a false positive. Fix it anyway, to silence this warning:

src/link/patch.c:92:24: warning: Use of zero-allocated memory
        stack.buf[stack.size] = value;
        ~~~~~~~~~~~~~~~~~~~~~ ^

Deal with overflow, and check for zero to get rid of the warning.

Signed-off-by: JL2210 <larrowe.semaj11@gmail.com>
2020-04-12 19:36:47 -04:00
ISSOtm
023a3c037f Properly handle missing symbols
Fixes #512
2020-04-12 22:52:32 +02:00
ISSOtm
a034ce0478 Deprecate '*' for comments 2020-04-09 17:57:15 +02:00
Eldred Habert
d6cd5823e3 Merge pull request #508 from JL2210/mod-by-zero-fix-2
Fix modulo by zero
2020-04-09 14:52:12 +02:00
JL2210
5dd941b311 Fix modulo by zero
Yet another case caught by scan-build:

src/link/patch.c:188:21: warning: Division by zero
                        value = popRPN() % value;
                                ~~~~~~~~~^~~~~~~

Just copy over the code from the division case, with a few modifications.

Signed-off-by: JL2210 <larrowe.semaj11@gmail.com>
2020-04-09 08:50:23 -04:00
ISSOtm
f9f27d6f5a Clean up symbol system
Get rid of Hungarian notation
Improve encapsulation (the rest of the world should not touch PC directly)
2020-04-09 10:42:37 +02:00
JL2210
5863cd10b8 Fix possible null pointer dereference
It's possible that if the FILE passed to yy_create_buffer is at the
end-of file, there may be a null pointer dereference.

This should hopefully fix that.

Found with clang-tools' scan-build:

src/asm/lexer.c:281:25: warning: Array access (via field 'pBuffer')
 results in a null pointer dereference
        pBuffer->pBuffer[size] = 0;
                 ~~~~~~~       ^
1 warning generated.

Signed-off-by: JL2210 <larrowe.semaj11@gmail.com>
2020-04-08 17:30:43 -04:00
ISSOtm
40f8e33e6c Fix periods not being accepted as second char of label names 2020-04-08 15:14:07 +02:00
ISSOtm
0157ba63d3 Document whitespace before local labels 2020-04-08 15:08:29 +02:00
ISSOtm
9e3d8b22cb Document new intra-section align
Also sneak in two code style fixes forgotten in last commit
2020-04-08 15:01:36 +02:00
ISSOtm
665412c073 Implement mid-section alignment directive
Fixes #254.
2020-04-08 12:29:00 +02:00
ISSOtm
2b0c34ecb5 Fix a few code style errors 2020-04-08 00:44:41 +02:00
ISSOtm
b0ec8468e6 Allow specifying offset in addition to alignment 2020-04-08 00:40:41 +02:00
ISSOtm
e82ad21704 Use a single byte for alignment 2020-04-07 21:19:09 +02:00
ISSOtm
e098bf47ba Allow references to be overridden by constant symbols
RGBLINK is capable of handling it now.
Though it'd be ideal for RGBASM to directly catch it.

Fixes #496.
2020-04-07 20:57:20 +02:00
ISSOtm
190678107b Prevent RGBLINK from crashing when getting the bank of a constant 2020-04-07 20:41:29 +02:00
ISSOtm
9f82fa4cf7 Fix BANK(@) outside sections causing crashes 2020-04-07 15:51:17 +02:00