mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-13 07:29:54 +00:00
tfv: add initial page flip support
This commit is contained in:
parent
66d08376f9
commit
13119609e1
127
gr-sim/gr-sim.c
127
gr-sim/gr-sim.c
@ -60,45 +60,37 @@ unsigned char a,y,x;
|
||||
#define FLASH 0xF3
|
||||
#define TEMP 0xFA
|
||||
|
||||
static int text_mode=0xff;
|
||||
static int text_page_1=0x00;
|
||||
static int hires_on=0x00;
|
||||
static int mixed_graphics=0xff;
|
||||
|
||||
/* 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) {
|
||||
void soft_switch(unsigned short address) {
|
||||
|
||||
switch(address) {
|
||||
case TXTCLR: // $c050
|
||||
text_mode=0;
|
||||
text_mode=0x00;
|
||||
break;
|
||||
case TXTSET: // $c051
|
||||
text_mode=1;
|
||||
text_mode=0xff;
|
||||
break;
|
||||
case MIXCLR: // $c052
|
||||
mixed_graphics=0;
|
||||
mixed_graphics=0x00;
|
||||
break;
|
||||
case MIXSET: // $c053
|
||||
mixed_graphics=1;
|
||||
mixed_graphics=0xff;
|
||||
break;
|
||||
case LOWSCR: // $c054
|
||||
text_page_1=1;
|
||||
text_page_1=0x00;
|
||||
break;
|
||||
case HISCR: // $c055
|
||||
text_page_1=0xff;
|
||||
break;
|
||||
case LORES: // $c056
|
||||
hires_on=0;
|
||||
hires_on=0x00;
|
||||
break;
|
||||
case HIRES: // $c057
|
||||
hires_on=1;
|
||||
hires_on=0xff;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Unknown soft switch %x\n",address);
|
||||
@ -106,6 +98,24 @@ static void soft_switch(unsigned short address) {
|
||||
}
|
||||
}
|
||||
|
||||
int soft_switch_read(unsigned short address) {
|
||||
|
||||
switch(address) {
|
||||
case TEXT_RD: // $c01a
|
||||
return text_mode;
|
||||
case MIXED_RD: // $c01b
|
||||
return mixed_graphics;
|
||||
case PAGE2_RD: // $c01c
|
||||
return text_page_1;
|
||||
case HIRES_RD: // $c01d
|
||||
return hires_on;
|
||||
default:
|
||||
fprintf(stderr,"Unknown soft switch read %x\n",address);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SDL_Surface *sdl_screen=NULL;
|
||||
|
||||
int grsim_input(void) {
|
||||
@ -258,11 +268,16 @@ int grsim_update(void) {
|
||||
unsigned int *t_pointer;
|
||||
int text_start,text_end,gr_start,gr_end;
|
||||
|
||||
int gr_addr,gr_addr_hi;
|
||||
int temp_col;
|
||||
|
||||
/* point to SDL output pixels */
|
||||
t_pointer=((Uint32 *)sdl_screen->pixels);
|
||||
|
||||
text_start=0; text_end=0;
|
||||
gr_start=0;gr_end=GR_YSIZE;
|
||||
|
||||
/* get the proper modes */
|
||||
if (text_mode) {
|
||||
text_start=0; text_end=TEXT_YSIZE;
|
||||
gr_start=0; gr_end=0;
|
||||
@ -272,23 +287,50 @@ int grsim_update(void) {
|
||||
gr_start=0; gr_end=40;
|
||||
}
|
||||
|
||||
/* do the top 40/48 if in graphics mode */
|
||||
for(y=gr_start;y<gr_end;y++) {
|
||||
|
||||
for(j=0;j<PIXEL_Y_SCALE;j++) {
|
||||
|
||||
gr_addr=gr_addr_lookup[y/2];
|
||||
gr_addr_hi=y%2;
|
||||
|
||||
/* adjust for page */
|
||||
if (text_page_1) {
|
||||
gr_addr+=0x400;
|
||||
}
|
||||
|
||||
for(x=0;x<GR_XSIZE;x++) {
|
||||
|
||||
if (gr_addr_hi) {
|
||||
temp_col=(ram[gr_addr]&0xf0)>>4;
|
||||
}
|
||||
else {
|
||||
temp_col=ram[gr_addr]&0x0f;
|
||||
}
|
||||
|
||||
for(i=0;i<PIXEL_X_SCALE;i++) {
|
||||
*t_pointer=color[scrn(x,y)];
|
||||
*t_pointer=color[temp_col];
|
||||
t_pointer++;
|
||||
}
|
||||
gr_addr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Do the remaining text */
|
||||
for(y=text_start;y<text_end;y++) {
|
||||
for(j=0;j<TEXT_Y_SCALE;j++) {
|
||||
for(x=0;x<TEXT_XSIZE;x++) {
|
||||
ch=ram[gr_addr_lookup[y]+x];
|
||||
// printf("%x ",ch);
|
||||
|
||||
gr_addr=gr_addr_lookup[y];
|
||||
|
||||
/* adjust for page */
|
||||
if (text_page_1) {
|
||||
gr_addr+=0x400;
|
||||
}
|
||||
|
||||
ch=ram[gr_addr+x];
|
||||
|
||||
if (ch&0x80) {
|
||||
flash=0;
|
||||
@ -311,9 +353,6 @@ int grsim_update(void) {
|
||||
/* 14 x 16 */
|
||||
/* but font is 5x7 */
|
||||
|
||||
/* FIXME: handle page2 */
|
||||
|
||||
|
||||
if (j>13) bit_set=0;
|
||||
else if (i>11) bit_set=0;
|
||||
else bit_set=(a2_font[ch][j/2])&(1<<(5-(i/2)));
|
||||
@ -1147,6 +1186,8 @@ void basic_normal(void) {
|
||||
|
||||
static unsigned short hlin_addr;
|
||||
static unsigned short hlin_hi;
|
||||
static unsigned short vlin_addr;
|
||||
static unsigned short vlin_hi;
|
||||
|
||||
int hlin_continue(int width) {
|
||||
|
||||
@ -1181,6 +1222,32 @@ int hlin(int page, int x1, int x2, int at) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlin(int page, int y1, int y2, int at) {
|
||||
|
||||
int i;
|
||||
|
||||
for(i=y1;i<y2;i++) {
|
||||
|
||||
vlin_addr=gr_addr_lookup[i/2];
|
||||
vlin_hi=i&1;
|
||||
|
||||
vlin_addr+=(page*4)<<8;
|
||||
|
||||
vlin_addr+=at;
|
||||
|
||||
if (vlin_hi) {
|
||||
ram[vlin_addr]=ram[vlin_addr]&0x0f;
|
||||
ram[vlin_addr]|=ram[COLOR]&0xf0;
|
||||
}
|
||||
else {
|
||||
ram[vlin_addr]=ram[vlin_addr]&0xf0;
|
||||
ram[vlin_addr]|=ram[COLOR]&0x0f;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hlin_double_continue(int width) {
|
||||
|
||||
int i;
|
||||
|
@ -25,7 +25,9 @@ int hlin(int page, int x1, int x2, int at);
|
||||
int hlin_continue(int width);
|
||||
int hlin_double_continue(int width);
|
||||
int hlin_double(int page, int x1, int x2, int at);
|
||||
|
||||
void soft_switch(unsigned short address);
|
||||
int soft_switch_read(unsigned short address);
|
||||
int vlin(int page, int y1, int y2, int at);
|
||||
int collision(int xx, int yy, int ground_color);
|
||||
|
||||
#define APPLE_UP 11
|
||||
@ -49,3 +51,37 @@ int collision(int xx, int yy, int ground_color);
|
||||
#define COLOR_YELLOW 13
|
||||
#define COLOR_AQUA 14
|
||||
#define COLOR_WHITE 15
|
||||
|
||||
/* Soft Switches */
|
||||
#define EIGHTYSTORE_OFF 0xc000 // page2 selects AUX ram
|
||||
#define EIGHTYSTORE_ON 0xc001 // page2 selects MAIN ram
|
||||
#define EIGHTYCOL_OFF 0xc00c // Display 40 columns
|
||||
#define EIGHTYCOLO_ON 0xc00d // Display 80 columns
|
||||
#define ALTCHAR_OFF 0xc00e // Use primary charset
|
||||
#define ALTCHAR_ON 0xc00f // Use alternate charset
|
||||
#define EIGHTYSTORE_RD 0xc018 // Read 80stor switch (R7)
|
||||
#define TEXT_RD 0xc01a // Read text switch (R7)
|
||||
#define MIXED_RD 0xc01b // Read mixed switch (R7)
|
||||
#define PAGE2_RD 0xc01c // Read Page2 (R7)
|
||||
#define HIRES_RD 0xc01d // Read HIRES (R7)
|
||||
#define ALTCHAR_RD 0xc01e // Read ALTCHAR switch (R7)
|
||||
#define EIGHTYCOL_RD 0xc01f // Read 80col switch (1==on) (R7)
|
||||
#define TXTCLR 0xc050 // Display GR
|
||||
#define TEXT_OFF 0xc050 // Display GR
|
||||
#define TXTSET 0xc051 // Display Text
|
||||
#define TEXT_ON 0xc051 // Display Text
|
||||
#define MIXED_OFF 0xc052 // Mixed Text Off
|
||||
#define MIXCLR 0xc052 // Mixed Text Off
|
||||
#define MIXED_ON 0xc053 // Mixed Text On
|
||||
#define MIXSET 0xc053 // Mixed Text On
|
||||
#define PAGE2_OFF 0xc054 // Use Page 1
|
||||
#define LOWSCR 0xc054 // Use Page 1
|
||||
#define PAGE2_ON 0xc055 // Use Page 2
|
||||
#define HISCR 0xc055 // Use Page 2
|
||||
#define HIRES_OFF 0xc056 // lowres mode
|
||||
#define LORES 0xc056 // lowres mode
|
||||
#define HIRES_ON 0xc057 // hires mode
|
||||
#define HIRES 0xc057 // hires mode
|
||||
#define DHIRES_ON 0xc05e // double-hires on
|
||||
#define DHIRES_OFF 0xc05f // double-hires off
|
||||
#define DHIRES_RD 0xc07f // double-hires read
|
||||
|
25
gr-sim/tfv.c
25
gr-sim/tfv.c
@ -19,6 +19,8 @@
|
||||
#define LOOP 0x06
|
||||
#define MEMPTRL 0x07
|
||||
#define MEMPTRH 0x08
|
||||
#define DISP_PAGE 0x09
|
||||
#define DRAW_PAGE 0x0a
|
||||
|
||||
/* stats */
|
||||
static unsigned char level=0;
|
||||
@ -34,16 +36,30 @@ static unsigned char map_x=5;
|
||||
static char tfv_x=15,tfv_y=19;
|
||||
static unsigned char ground_color;
|
||||
|
||||
static void page_flip(void) {
|
||||
|
||||
if (ram[DISP_PAGE]==0) {
|
||||
soft_switch(HISCR);
|
||||
ram[DISP_PAGE]=1;
|
||||
ram[DRAW_PAGE]=0;
|
||||
}
|
||||
else {
|
||||
soft_switch(LOWSCR);
|
||||
ram[DISP_PAGE]=0;
|
||||
ram[DRAW_PAGE]=1;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_segment(void) {
|
||||
|
||||
for(ram[LOOP]=0;ram[LOOP]<4;ram[LOOP]++) {
|
||||
ram[YY]=ram[YY]+ram[YADD];
|
||||
if (ram[XX]==ram[MATCH]) color_equals(ram[COLOR1]*3);
|
||||
else color_equals(ram[COLOR1]);
|
||||
basic_vlin(10,ram[YY],9+ram[XX]);
|
||||
vlin(ram[DRAW_PAGE],10,ram[YY],9+ram[XX]);
|
||||
if (ram[XX]==ram[MATCH]) color_equals(ram[COLOR2]*3);
|
||||
else color_equals(ram[COLOR2]);
|
||||
if (ram[YY]!=34) basic_vlin(ram[YY],34,9+ram[XX]);
|
||||
if (ram[YY]!=34) vlin(ram[DRAW_PAGE],ram[YY],34,9+ram[XX]);
|
||||
ram[XX]++;
|
||||
}
|
||||
ram[YADD]=-ram[YADD];
|
||||
@ -66,6 +82,8 @@ static void draw_logo(void) {
|
||||
ram[COLOR2]=0;
|
||||
draw_segment();
|
||||
|
||||
page_flip();
|
||||
|
||||
grsim_update();
|
||||
}
|
||||
|
||||
@ -1111,6 +1129,9 @@ int main(int argc, char **argv) {
|
||||
|
||||
grsim_init();
|
||||
|
||||
ram[DISP_PAGE]=0;
|
||||
ram[DRAW_PAGE]=0;
|
||||
|
||||
home();
|
||||
gr();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user