EWM Update: Optimizing Memory Access

I landed a little patch to optimize memory access to the first two pages of memory: the zero page and the stack.

The struct cpu_t now keeps pointers to the memory areas where these pages are kept, so operations on them can access the memory directly instead of going through the memory abstraction.

The speedup is specially noticable on the Raspberry Pi Zero:

Before

pi@raspberrypi:~/Projects/ewm/src $ ./cpu_test
TEST Running 6502 tests
TEST   Success; executed 88957316 cycles in 8.7700 at 10.1434 MHz
TEST Running 65C02 tests
TEST   Success; executed 65094140 cycles in 6.2140 at 10.4754 MHz

After

pi@raspberrypi:~/Projects/ewm/src $ ./cpu_test
TEST Running 6502 tests
TEST   Success; executed 88957316 cycles in 6.0150 at 14.7892 MHz
TEST Running 65C02 tests
TEST   Success; executed 65094140 cycles in 4.2930 at 15.1629 MHz

That is a pretty big jump in unthrottled CPU speed. I think this patch, together with the Software Renderer that I still have in progress will make EWM run pretty well on the Raspberry Pi Zero.

If you are interested in playing around with my emulator, you can find the project at github.com/st3fan/ewm.

Most of my professional and personal work is Open Source. You can find many projects at github.com/st3fan - feel free to leave a bug report or open a feature request.