Pasmo uses "0x" for binary? That prefix is a pretty solid standard for hex.
The c pre-processor does not do binary constants (see
https://stackoverflow.com/questions/261 ... -in-c-or-c for some really complicated solutions to this). However, m4 runs before cpp in z88dk and that can do binary and could change the binary constant to hex before cpp sees it.
But you can do the binary in asm just like you are doing for pasmo. Or you could just import an entire bin file as paintbrush outputs if you want to get away from copy and paste.
To do the byte definition in asm, you'd inform the c compiler of the block of data's presence with something like this:
Code: Select all
extern unsigned char bytes[]; // assuming there's more than one
And then in an asm file:
Code: Select all
SECTION data_user
PUBLIC _bytes
_bytes:
defb %10000000, %00001111
In c, "bytes[0]" would be the first byte and "bytes[1]" would be the second.
To compile, just add that asm file to the compile line.
If you want to use the entire binary file that zx paintbrush produces, the asm file would just import the binary:
Code: Select all
SECTION data_user
PUBLIC _bytes, _bytes_end
_bytes:
BINARY "paintbrush.bin"
_bytes_end:
"bytes[0]" would still return the first byte, etc. I added a second label "_bytes_end" so that you can find out how long the binary data is. In c you could "extern unsigned char bytes_end[];" and then "bytes_end - bytes" would be the length of that binary data.
I think z80asm will also accept a leading ""0b" for binary instead of "%" and possibly a trailing "b" but I'm not sure off the top of my head.
The other option I mentioned is using m4 to preprocess the file before cpp. You can do this by adding ".m4" to the end of your source file. "test.c" -> "test.c.m4" or "test.asm" -> "test.asm.m4". Then you give the m4 file to zcc and it will pass it though m4 to generate "test.c" or "test.asm" which is then processed like normal. These files "test.c" or "test.asm" are written to the same directory as "test.c.m4" or "test.asm.m4" so will overwrite any file of that name there. It has to be done this way to make sure include paths are properly resolved and it is really what you want done anyway. One of the options above is probably better then getting m4 to do something.