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).
This commit is contained in:
@@ -12,12 +12,11 @@ void gb_video_init(struct gb_video *video)
|
||||
memset(video, 0, sizeof(*video));
|
||||
}
|
||||
|
||||
void gb_video_cycle(struct gb_video *video)
|
||||
void gb_video_cycle(struct gb_video *video, int cycles)
|
||||
{
|
||||
if (video->line_counter < CYCLES_PER_LINE - 1) {
|
||||
video->line_counter++;
|
||||
} else {
|
||||
video->line_counter = 0;
|
||||
video->line_counter += cycles;
|
||||
if (video->line_counter >= CYCLES_PER_LINE) {
|
||||
video->line_counter -= CYCLES_PER_LINE;
|
||||
video->curline += 1;
|
||||
if (video->curline > LCD_Y_MAX) {
|
||||
video->curline = 0;
|
||||
|
||||
Reference in New Issue
Block a user