1
0
mirror of https://github.com/pevans/erc-c.git synced 2026-04-21 15:16:45 +00:00

Rework screen display logic for more efficiency

This commit is contained in:
Peter Evans
2018-01-23 14:52:16 -06:00
parent b5e1e09a35
commit 775a145480
9 changed files with 32 additions and 19 deletions
+7
View File
@@ -38,9 +38,16 @@ typedef struct {
vm_8bit last_key;
bool key_pressed;
/*
* Is the screen dirty? That is to say, has something about it
* changed that now requires we redraw the screen?
*/
bool dirty;
} vm_screen;
extern bool vm_screen_active(vm_screen *);
extern bool vm_screen_dirty(vm_screen *);
extern bool vm_screen_key_pressed(vm_screen *);
extern char vm_screen_last_key(vm_screen *);
extern int vm_screen_add_window(vm_screen *, int, int);
-3
View File
@@ -223,7 +223,6 @@ SEGMENT_READER(apple2_bank_switch_read)
: 0x00;
}
log_critical("; bank_switch = %x", mach->bank_switch);
return 0;
}
@@ -248,6 +247,4 @@ SEGMENT_WRITER(apple2_bank_switch_write)
mach->bank_switch & ~BANK_ALTZP);
break;
}
log_critical("; bank_switch = %x", mach->bank_switch);
}
+5 -3
View File
@@ -322,10 +322,12 @@ apple2_run_loop(apple2 *mach)
}
while (vm_screen_active(mach->screen)) {
mos6502_dis_opcode(mach->cpu, stdout, mach->cpu->PC);
//mos6502_dis_opcode(mach->cpu, stdout, mach->cpu->PC);
mos6502_execute(mach->cpu);
// apple2_draw_40col(mach);
// vm_screen_refresh(mach->screen);
if (vm_screen_dirty(mach->screen)) {
vm_screen_refresh(mach->screen);
}
}
}
+7 -4
View File
@@ -3,6 +3,7 @@
*/
#include "apple2.dbuf.h"
#include "apple2.draw.h"
static size_t switch_reads[] = {
0xC01A,
@@ -91,6 +92,12 @@ SEGMENT_WRITER(apple2_dbuf_write)
// Again, segment is allowed to be that which was passed in if
// 80STORE is low.
segment->memory[addr] = value;
if (mach->display_mode & DISPLAY_TEXT) {
apple2_draw_40col(mach);
} else {
apple2_draw_40col(mach);
}
}
/*
@@ -213,8 +220,6 @@ SEGMENT_READER(apple2_dbuf_switch_read)
break;
}
log_critical("; display_mode = %x", mach->display_mode);
// ???
return 0;
}
@@ -288,6 +293,4 @@ SEGMENT_WRITER(apple2_dbuf_switch_write)
mach->display_mode & ~DISPLAY_DHIRES);
break;
}
log_critical("; display_mode = %x", mach->display_mode);
}
+2 -3
View File
@@ -88,10 +88,9 @@ apple2_draw_pixel_lores(apple2 *mach, vm_16bit addr)
void
apple2_draw_text(apple2 *mach, vm_16bit addr)
{
vm_8bit lsb;
vm_8bit lsb, ch;
vm_16bit page_base;
vm_area dest;
char ch;
// The text display buffers are located at "Page 1" and "Page 2",
// which are at byte 1024-2047 (0x0400-0x07FF) and byte 2048-3071
@@ -151,7 +150,7 @@ apple2_draw_text(apple2 *mach, vm_16bit addr)
dest.height = mach->sysfont->height;
// And...lastly...what's in the address?
ch = (char)vm_segment_get(mach->main, addr);
ch = mos6502_get(mach->cpu, addr);
// Let's firstly blank out that space on screen.
vm_bitfont_render(mach->sysfont, mach->screen, &dest, ' ');
-4
View File
@@ -214,8 +214,6 @@ SEGMENT_READER(apple2_mem_switch_read)
break;
}
log_critical("; memory_mode = %x", mach->memory_mode);
// ???
return 0;
}
@@ -286,6 +284,4 @@ SEGMENT_WRITER(apple2_mem_switch_write)
break;
}
log_critical("; memory_mode = %x", mach->memory_mode);
}
-2
View File
@@ -187,6 +187,4 @@ SEGMENT_WRITER(apple2_pc_switch_write)
mach->memory_mode & ~MEMORY_SLOTCXROM);
break;
}
log_critical("; memory_mode = %x", mach->memory_mode);
}
+1
View File
@@ -123,5 +123,6 @@ vm_bitfont_render(vm_bitfont *font,
return ERR_GFXOP;
}
screen->dirty = true;
return OK;
}
+10
View File
@@ -61,6 +61,7 @@ vm_screen_create()
screen->ycoords = 0;
screen->last_key = '\0';
screen->key_pressed = false;
screen->dirty = false;
screen->window = NULL;
screen->render = NULL;
@@ -209,6 +210,7 @@ vm_screen_active(vm_screen *screen)
return true;
}
SDL_Delay(2000);
return false;
}
@@ -220,6 +222,7 @@ void
vm_screen_refresh(vm_screen *screen)
{
SDL_RenderPresent(screen->render);
screen->dirty = false;
}
/*
@@ -249,6 +252,7 @@ vm_screen_draw_rect(vm_screen *screen, vm_area *area)
MAKE_SDL_RECT(rect, *area);
SDL_RenderFillRect(screen->render, &rect);
screen->dirty = true;
}
/*
@@ -271,3 +275,9 @@ vm_screen_last_key(vm_screen *scr)
{
return scr->last_key;
}
bool
vm_screen_dirty(vm_screen *scr)
{
return scr->dirty;
}