The video code now writes out a bmp file per-frame. With this patch
applied, the Nintendo logo is rendered in each frame.
There is still plenty of work to be done. Pretty much everything is
hardcoded to make the bootrom work.
After doing a little reading about the way the memory banks are
mapped, it looks like this code is going to grow. Separate it into
it's own file.
While we're at it, make gb_mem_read() a proper function instead of a
callback. Because these functions are used so frequently, this
corresponds to a ~10-20% performance benefit (due to LTO).
Instead of calling cpu_cycle() and video_cycle() once per emulated
cycle, call cpu_cycle() once per emulated instruction. This should not
have any obvious effects on the emulation (as currently written),
because all of the memory reads and writes are done in the first
"cycle" of the instruction.
This patch results in a substantial performance gain (>100%, if I
recall correctly).
By reading directly from a "RAM" array, and copying in the cart data
over the old bootrom.
Also, some other fixups because I'm too lazy to properly split patches
for a personal project.
Previously, gbdb had to check several signals, including the current
PC, to determine when do_run() should stop. This code was hotpath and
unecessarily slow.
Instead, leverage a n undefined instruction (0xd3) as a breakpoint instruction.
When the CPU emulation encounters this instruction, it will call a callback
which is implemented by gbdb. This can set a simple flag which is less expensive to
query.
Finally, both the signal handler and the breakpoint callback set specific
"paused" flags and a generic "pause" flag. Now, do_run() can simply check
the generic "paused" flag, then use the specific flags to determine the
stop reason.
This change increased performance by ~10% on Raspberry Pi.
The Gameboy CPU runs at ~4MHz, but all the instructions take some
number of cycles divisible by 4.
This patch causes the cpu_cycle() to run a single 1MHz cycle, instead
of requiring 4 calls at 4MHz to perform the same emulation. Based on
the code in gbdb, the video controller now appears to run much slower,
and the timings needs to be verified.
This results in a large performance gain.
The conditions are hotpath, so pre-calcuate the end cycle count instead of doing it every loop.
I didn't verify that the compiler wasn't doing this anyway, but this won't hurt.
A previous patch changed the way tests are run by piping the output
into sed to indent the output. This broke checking the return code of
the test because the return code is really that of sed.
Fix this by taking a dependecy on bash and using PIPESTATUS to get
the return code fo the test.
Similar to gbasm, break the testing into different files for sanity's
sake. This patch also adds a "test" register state which is compared
to the state of the actual CPU registers at the end of the test.
Finally, break the inc and dec tests, but add "ld r8, r8" and "ld dr,
d8" tests.
It's not very good, but it supports all of the options by the
previous far-worse Makefile configure targets, and also now supports
out-of-tree builds.
Also include the relevent updates to the .buildbot script and
.gitignore.