hgr: vertical lines getting closer

colors are wrong
This commit is contained in:
Vince Weaver 2018-07-02 13:39:24 -04:00
parent 91a0f23a04
commit 4f285a2391
4 changed files with 173 additions and 16 deletions

View File

@ -184,6 +184,21 @@ void asl(void) {
// printf("ASL A=%x\n",a);
}
void asl_mem(int addr) {
int temp_a;
temp_a=ram[addr];
temp_a&=0xff;
c=!!(temp_a&0x80);
temp_a=temp_a<<1;
ram[addr]=(temp_a&0xff);
z=(ram[addr]==0);
n=!!(ram[addr]&0x80);
// printf("ASL %x=%x\n",addr,ram[addr]);
}
void ror(void) {
int temp_a;
@ -290,6 +305,66 @@ void iny(void) {
n=!!(y&0x80);
}
void bit(int value) {
int temp_a;
temp_a=a&value;
temp_a&=0xff;
z=(temp_a==0);
n=(value&0x80);
v=(value&0x40);
}
void lda(int addr) {
a=ram[addr];
z=(a==0);
n=!!(a&0x80);
}
void lda_const(int value) {
a=value;
z=(a==0);
n=!!(a&0x80);
}
void ldx(int addr) {
x=ram[addr];
z=(x==0);
n=!!(x&0x80);
}
void ldx_const(int value) {
x=value;
z=(x==0);
n=!!(x&0x80);
}
void ldy(int addr) {
y=ram[addr];
z=(y==0);
n=!!(y&0x80);
}
void ldy_const(int value) {
y=value;
z=(y==0);
n=!!(y&0x80);
}
unsigned char high(int value) {
return (value>>8)&0xff;

View File

@ -17,6 +17,7 @@ void lsr(void);
void asl(void);
void ror(void);
void rol(void);
void asl_mem(int addr);
void ror_mem(int addr);
void rol_mem(int addr);
void dex(void);
@ -27,7 +28,14 @@ void tax(void);
void tay(void);
void txa(void);
void tya(void);
void bit(int value);
void bit_mem(int addr);
void lda(int addr);
void lda_const(int value);
void ldx(int addr);
void ldx_const(int value);
void ldy(int addr);
void ldy_const(int value);
unsigned char high(int value);
unsigned char low(int value);

View File

@ -226,6 +226,69 @@ move_right:
}
static void move_up_or_down(void) {
// F4D3
if (n==1) goto move_down;
c=0;
lda(GBASH);
bit(0x1c); // CON.1C
if (z!=1) goto mu_5;
asl_mem(GBASL);
if (c==1) goto mu_3;
bit(0x03); // CON.03
if (z==1) goto mu_1;
adc(0x1f);
c=1;
goto mu_4;
// F4Eb
mu_1:
adc(0x23);
pha();
lda(GBASL);
adc(0xb0);
if (c==1) goto mu_2;
adc(0xf0);
// f4f6
mu_2:
ram[GBASL]=a;
pla();
goto mu_4;
mu_3:
adc(0x1f);
mu_4:
ror_mem(GBASL);
mu_5:
adc(0xfc);
ud_1:
ram[GBASH]=a;
return;
// f505
move_down:
lda(GBASH);
adc(4);
bit(0x1c);
if (z!=1) goto ud_1;
asl_mem(GBASL);
if (c==0) goto md_2;
adc(0xe0);
c=0;
bit(0x4);
if (z==1) goto md_3;
lda(GBASL);
adc(0x50);
a=a^0xf0;
if (a==0) goto md_1;
a=a^0xf0;
md_1:
ram[GBASL]=a;
lda(HGR_PAGE);
goto md_3;
md_2:
adc(0xe0);
md_3:
ror_mem(GBASL);
goto ud_1;
}
@ -245,7 +308,7 @@ static void hglin(void) {
a=a^0xff;
adc(1);
pha();
a=0;
lda_const(0);
sbc(ram[HGR_QUADRANT]);
// F550
hglin_1:
@ -264,18 +327,18 @@ hglin_1:
a=a^0xff;
adc(0xfe);
hglin_2:
// F566
// F568
ram[HGR_DY]=a;
ram[HGR_Y]=y;
ror_mem(HGR_QUADRANT);
c=1;
sbc(ram[HGR_DX]);
x=a;
a=0xff;
lda_const(0xff);
sbc(ram[HGR_DX+1]);
ram[HGR_COUNT]=a;
y=ram[HGR_HORIZ];
if (c==1) goto movex2; // always?
ldy(HGR_HORIZ);
goto movex2; // always?
// f57c
movex:
asl();
@ -284,32 +347,32 @@ movex:
// f581
movex2:
a=ram[HGR_E];
lda(HGR_E);
adc(ram[HGR_DY]);
ram[HGR_E]=a;
a=ram[HGR_E+1];
lda(HGR_E+1);
sbc(0);
movex2_1:
ram[HGR_E+1]=a;
a=ram[y_indirect(GBASL,y)];
lda(y_indirect(GBASL,y));
a=a^ram[HGR_BITS];
a=a&ram[HMASK];
a=a^ram[y_indirect(GBASL,y)];
ram[y_indirect(GBASL,y)]=a;
x++;
if (x!=0) goto movex2_2;
inx();
if (z!=1) goto movex2_2;
ram[HGR_COUNT]++;
if (ram[HGR_COUNT]==0) return;
// F59e
movex2_2:
a=ram[HGR_QUADRANT];
lda(HGR_QUADRANT);
if (c==1) goto movex;
move_up_or_down();
c=0;
a=ram[HGR_E];
lda(HGR_E);
adc(ram[HGR_DX]);
ram[HGR_E]=a;
a=ram[HGR_E+1];
lda(HGR_E+1);
adc(ram[HGR_DX+1]);
goto movex2_1;
}

View File

@ -6,7 +6,7 @@
int main(int argc, char **argv) {
int yy,ch;
int xx,yy,ch;
grsim_init();
@ -15,13 +15,20 @@ int main(int argc, char **argv) {
hgr();
/* Put lines on screen */
/* Put horizontal lines on screen */
for(yy=0;yy<100;yy++) {
hcolor_equals(yy%8);
hplot(yy,yy);
hplot_to(200,yy);
}
/* Put vertical lines on screen */
for(xx=0;xx<100;xx+=2) {
hcolor_equals((xx%16)/2);
hplot(xx,159);
hplot_to(xx,100);
}
while(1) {
grsim_update();
@ -32,6 +39,10 @@ int main(int argc, char **argv) {
usleep(100000);
}
int i;
printf("20D0: ");
for(i=0;i<16;i++) printf("%x ",ram[0x20d0+i]);
printf("\n");
return 0;
}