gr-sim: add hplot support

This commit is contained in:
Vince Weaver 2018-07-01 23:06:35 -04:00
parent 337f29a79b
commit af458a7fd8
2 changed files with 115 additions and 0 deletions

View File

@ -85,9 +85,100 @@ int hgr2(void) {
return 0;
}
static void hposn(void) {
unsigned char s;
unsigned char msktbl[]={0x81,0x82,0x84,0x88,0x90,0xA0,0xC0};
// F411
ram[HGR_Y]=a;
ram[HGR_X]=x;
ram[HGR_X+1]=y;
s=a; // pha
a=a&0xC0;
ram[GBASL]=a;
lsr();
lsr();
a=a|ram[GBASL];
ram[GBASL]=a;
a=s;
// F423
ram[GBASH]=a;
asl();
asl();
asl();
rol_mem(GBASH);
asl();
rol_mem(GBASH);
asl();
ror_mem(GBASL);
a=ram[GBASH];
a=a&0x1f;
a=a|ram[HGR_PAGE];
ram[GBASH]=a;
// F438
a=x;
if (y==0) {
goto hposn_2;
}
y=35;
adc(4);
hposn_1:
y++;
// f442
hposn_2:
sbc(7);
if (c==1) goto hposn_1;
ram[HGR_HORIZ]=y;
x=a;
a=msktbl[(x-0x100)+7]; // LDA MSKTBL-$100+7,X BIT MASK
// MSKTBL=F5B8
ram[HMASK]=a;
a=y;
c=a&1;
a=a>>1;
a=ram[HGR_COLOR];
ram[HGR_BITS]=a;
if (c) color_shift();
}
static void hplot0(void) {
// F457
hposn();
a=ram[HGR_BITS];
a=a^ram[y_indirect(GBASL,y)];
a=a&ram[HMASK];
a=a^ram[y_indirect(GBASL,y)];
ram[y_indirect(GBASL,y)]=a;
}
static void hfns(int xx, int yy) {
// (y,x) = x co-ord
// (a) = y co-ord
if (xx>=280) {
printf("X-coord out of range!\n");
return;
}
if (yy>192) {
printf("Y-coord out of range!\n");
return;
}
x=(xx&0xff);
y=(xx>>8);
a=yy;
}
int hplot(int xx, int yy) {
// F6FE
hfns(xx,yy);
hplot0();
return 0;
}
@ -98,6 +189,18 @@ int hplot_to(int xx, int yy) {
int hcolor_equals(int color) {
unsigned char colortbl[8]={0x00,0x2A,0x55,0x7F,0x80,0xAA,0xD5,0xFF};
// F6E9
x=color;
if (x>7) {
printf("HCOLOR out of range!\n");
return -1;
}
a=colortbl[x];
ram[HGR_COLOR]=a;
return 0;
}

View File

@ -32,12 +32,24 @@
#define V2 0x2D
#define MASK 0x2E
#define COLOR 0x30
#define HMASK 0x30
#define INVFLG 0x32
#define YSAV 0x34
#define YSAV1 0x35
#define CSWL 0x36
#define CSWH 0x37
#define HGR_SHAPE 0x1A
#define HGR_SHAPE_H 0x1B
#define HGR_BITS 0x1C
#define HGR_X 0xE0
#define HGR_X_H 0xE1
#define HGR_Y 0xE2
#define HGR_COLOR 0xE4
#define HGR_HORIZ 0xE5
#define HGR_PAGE 0xE6
/* stats */