It seems the Arduino IDE picks the position of the first definition to
insert all auto-generated forward declarations. This fails to compile if
any of these generated forward declarations references a type included
later.
So, reorder the code a bit so the first definition happens strictly after
the last inclusion.
This code was removed as part of
a555f21 ("All: Resolve all compiler and linker warnings")
because it was filling a 1kB buffer which was never read from.
While I expect reading values from PINC should be invisible from the
cartridge's perspective, writing to PORTL, PORTF and PORTK is definitely
visible.
I have currently no way of testing if this code is required, so in doubt
restore the parts which have effects visible from the cartridge.
I am not sure why I changed some variables from 16 bit types to 8 bit types
when the warnings being resolved were only about signedness.
Fixes: a555f21 ("All: Resolve all compiler and linker warnings")
Also, make print_FatalError(*) independent from print_Error(*).
Also, factorise common parts of print_Error(*).
Frees 2336 bytes of program space and 5 bytes of global ram space.
IMPORTANT: with this change, the Adafruit clock generator becomes a hard
requirement to read and write gamecart eeproms.
This is a large patch, partly because JoyBus is used a lot:
- controller
- controller pak
- gamecart eeprom
and partly because of the further simplifications it allows.
Also, implement low-level bit shift functions in assembly in order to get
complete control of the timings: there can be just a few cycles of slack.
Also, use the time waiting for the input line to go high to pack received
bits into bytes on-the-fly, as there is now plenty of time.
This saves about 2080 bytes of program space, and 369 bytes of global ram
space.
More sizeof() use, avoiding high-level loops when a callee can do it
without the call overhead on every iteration, a bit of source code
factorisation, avoiding initializers for large variables.
These variables are set but never read. Removing them removes a non-trivial
amount of code, which I am not comfortable deleting: it contains knowledge
about cart data structure, even though it is currently not being used for
anything. So comment it out until someone who know this architecture better
comes around.
Frees 146 bytes of program space and 16 bytes of global ram space.