From 5b8bc29f5bfa5840dfdcbe4d3f26633b572ebaa5 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 17 May 2017 15:47:20 -0400 Subject: [PATCH] gr-sim: add soft-switch support --- gr-sim/gr-sim.c | 106 +++++++++++++++++++++++++++++++++++++++++++----- gr-sim/gr-sim.h | 5 +++ gr-sim/text.c | 8 ++++ 3 files changed, 109 insertions(+), 10 deletions(-) diff --git a/gr-sim/gr-sim.c b/gr-sim/gr-sim.c index 61abdbfb..677e9fb8 100644 --- a/gr-sim/gr-sim.c +++ b/gr-sim/gr-sim.c @@ -46,6 +46,52 @@ unsigned char a,y,x; #define TEMP 0xFA + +/* Soft Switches */ +#define TXTCLR 0xc050 +#define TXTSET 0xc051 +#define MIXCLR 0xc052 +#define MIXSET 0xc053 +#define LOWSCR 0xc054 +#define HISCR 0xc055 +#define LORES 0xc056 +#define HIRES 0xc057 + +static int text_mode=1; +static int text_page_1=1; +static int hires_on=0; +static int mixed_graphics=1; + +static void soft_switch(unsigned short address) { + + switch(address) { + case TXTCLR: // $c050 + text_mode=0; + break; + case TXTSET: // $c051 + text_mode=1; + break; + case MIXCLR: // $c052 + mixed_graphics=0; + break; + case MIXSET: // $c053 + mixed_graphics=1; + break; + case LOWSCR: // $c054 + text_page_1=1; + break; + case LORES: // $c056 + hires_on=0; + break; + case HIRES: // $c057 + hires_on=1; + break; + default: + fprintf(stderr,"Unknown soft switch %x\n",address); + break; + } +} + static SDL_Surface *sdl_screen=NULL; int grsim_input(void) { @@ -177,14 +223,28 @@ int grsim_update(void) { t_pointer=((Uint32 *)sdl_screen->pixels); - for(y=0;y