1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-06-12 11:29:36 +00:00

Implement (true? better?) framerate cycle

This commit is contained in:
Peter Evans 2018-03-07 16:20:29 -06:00
parent f1c0716313
commit 9f09be93a9
5 changed files with 31 additions and 3 deletions

View File

@ -4,7 +4,8 @@
#include "apple2.h"
#include "vm_bits.h"
extern void apple2_draw_pixel(apple2 *, vm_16bit);
extern void apple2_draw(apple2 *);
extern void apple2_draw_40col(apple2 *);
extern void apple2_draw_pixel(apple2 *, vm_16bit);
#endif

View File

@ -350,13 +350,14 @@ extern bool apple2_is_double_video(apple2 *);
extern int apple2_boot(apple2 *);
extern void apple2_clear_strobe(apple2 *);
extern void apple2_free(apple2 *);
extern void apple2_notify_refresh(apple2 *);
extern void apple2_press_key(apple2 *, vm_8bit);
extern void apple2_release_key(apple2 *);
extern void apple2_reset(apple2 *);
extern void apple2_run_loop(apple2 *);
extern void apple2_set_bank_switch(apple2 *, vm_8bit);
extern void apple2_set_color(apple2 *, int);
extern void apple2_set_memory_mode(apple2 *, vm_8bit);
extern void apple2_set_display(apple2 *, vm_8bit);
extern void apple2_set_memory_mode(apple2 *, vm_8bit);
#endif

View File

@ -391,6 +391,7 @@ apple2_run_loop(apple2 *mach)
mos6502_execute(mach->cpu);
if (vm_screen_dirty(mach->screen)) {
apple2_draw(mach);
vm_screen_refresh(mach->screen);
}
}

View File

@ -100,7 +100,7 @@ SEGMENT_WRITER(apple2_dbuf_write)
segment->memory[addr] = value;
if (mach->display_mode & DISPLAY_TEXT) {
apple2_draw_40col(mach);
apple2_notify_refresh(mach);
}
}

View File

@ -102,3 +102,28 @@ apple2_draw_40col(apple2 *mach)
apple2_text_draw(mach, addr);
}
}
/*
* Find the right draw method for the machine, based on its display
* mode, and use that to refresh the screen.
*/
void
apple2_draw(apple2 *mach)
{
if (mach->display_mode & DISPLAY_TEXT) {
apple2_draw_40col(mach);
}
}
/*
* Tell the screen that it has a change ready to be displayed. This
* function will not immediately redraw the screen, and when the screen
* is redrawn is up to our framerate cycle.
*/
void
apple2_notify_refresh(apple2 *mach)
{
if (mach && mach->screen) {
mach->screen->dirty = true;
}
}