Commit Graph

9 Commits

Author SHA1 Message Date
cd66ad8a89 memory: separate the memory-related code into it's own file
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).
2018-07-09 05:28:14 +00:00
ea2ea1e293 gbdb,cpu,video: reduce number of calls to cycle functions
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).
2018-07-09 02:38:50 +00:00
1bb3d8512a cpu,gbdb: implement better breakpoints
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.
2018-07-01 23:59:50 +00:00
25e26804a9 cpu: correct some print formats and use more "native" types
These were found while running on a Raspberry Pi (ARM).
2018-07-01 21:43:49 +00:00
d62a8d3f0e cpu: implement enought to make bootrom use display hardware 2018-01-01 16:51:56 -08:00
3f11a3a167 cpu: rewrite to a single switch-based dispatch
This will make it easier to experiment with direct-threading in the future.
2017-11-19 18:39:12 -08:00
30df5164d6 cpu: add missing header guards 2017-05-31 22:03:27 -07:00
f76d384e6d cpu: define get_reg functions as const
This will be useful in the future when we want to reference the CPU
state in a const-way.
2017-05-31 22:03:26 -07:00
e5acc3088c treewide: restucture source tree per project
Signed-off-by: Max Regan <mgregan2@gmail.com>
2017-05-10 22:40:12 -07:00