xmas2018: more work on scroll

This commit is contained in:
Vince Weaver 2018-12-19 16:49:05 -05:00
parent 03df7bf20a
commit d7c3915acb
3 changed files with 100 additions and 54 deletions

View File

@ -41,6 +41,10 @@ unsigned short y_indirect(unsigned char base, unsigned char y) {
} }
void clc(void) {
c=0;
}
void adc(int value) { void adc(int value) {
int temp_a; int temp_a;

View File

@ -6,6 +6,7 @@ extern unsigned int n,z,c,v;
unsigned short y_indirect(unsigned char base, unsigned char y); unsigned short y_indirect(unsigned char base, unsigned char y);
int init_6502(void); int init_6502(void);
void clc(void);
void adc(int value); void adc(int value);
void sbc(int value); void sbc(int value);
void and(int value); void and(int value);

View File

@ -75,73 +75,114 @@ int main(int argc, char **argv) {
*/ */
int xx,addr,count=0; int count=0;
int current,next;
#define HIGH 0 #define HIGH 0x00
#define CURRENT 1 #define CURRENT 0x01
#define NEXT 2 #define NEXT 0x02
#define INL 0xfc
#define INH 0xfd
#define OUTL 0xfe
#define OUTH 0xff
while(1) { //ram[y_indirect(OUTL,y)]
for(addr=0x4000;addr<0x6000;addr+=0x80) {
for(xx=0;xx<40;xx++) {
ram[CURRENT]=ram[addr+xx];
ram[NEXT]=ram[addr+xx+1];
if ((count%7==2) || (count%7==6)) {
ram[HIGH]=ram[NEXT]&0x80;
}
else {
ram[HIGH]=ram[CURRENT]&0x80;
}
if (xx==39) ram[NEXT]=ram[addr+0x2000]; scroll_loop:
a=ram[NEXT]; ram[OUTH]=0x40;
and(0x3); ram[OUTL]=0x00;
asl(); ram[INH]=0x60;
asl(); ram[INL]=0x00;
asl(); left_one_loop:
asl(); // printf("%d %02x:%02x\n",count,ram[OUTH],ram[OUTL]);
asl();
ram[NEXT]=a;
a=ram[CURRENT]; for(y=0;y<40;y++) {
lsr(); ram[CURRENT]=ram[y_indirect(OUTL,y)];
lsr(); // current>>=2; ram[NEXT]=ram[y_indirect(OUTL,y+1)];
and(0x1f); // current&=0x1f; if ((count%7==2) || (count%7==6)) {
ora_mem(HIGH); ram[HIGH]=ram[NEXT]&0x80;
ora_mem(NEXT); }
else {
ram[HIGH]=ram[CURRENT]&0x80;
}
if (y==39) ram[NEXT]=ram[y_indirect(INL,0)];
ram[addr+xx]=a; a=ram[NEXT];
} and(0x3);
asl();
asl();
asl();
asl();
asl();
ram[NEXT]=a;
for(xx=0;xx<40;xx++) { a=ram[CURRENT];
current=ram[addr+0x2000+xx]; lsr();
next=ram[addr+0x2000+xx+1]; lsr(); // current>>=2;
if ((count%7==2) ||(count%7==6)) { and(0x1f); // current&=0x1f;
ram[HIGH]=next&0x80; ora_mem(HIGH);
} ora_mem(NEXT);
else { ram[y_indirect(OUTL,y)]=a;
ram[HIGH]=current&0x80; }
} for(y=0;y<40;y++) {
current>>=2; ram[CURRENT]=ram[y_indirect(INL,y)];
current&=0x1f; ram[NEXT]=ram[y_indirect(INL,y+1)];
current|=ram[HIGH]; if ((count%7==2) ||(count%7==6)) {
current|=(next&3)<<5; ram[HIGH]=ram[NEXT]&0x80;
ram[addr+0x2000+xx]=current; }
} else {
ram[HIGH]=ram[CURRENT]&0x80;
} }
a=ram[NEXT];
and(0x3);
asl();
asl();
asl();
asl();
asl();
ram[NEXT]=a;
grsim_update(); a=ram[CURRENT];
ch=grsim_input(); lsr();
if (ch) break; lsr(); // current>>=2;
usleep(17000); // 60Hz = 17ms and(0x1f); // current&=0x1f;
count++; ora_mem(HIGH);
if (count==140) break; ora_mem(NEXT);
ram[y_indirect(INL,y)]=a;
} }
clc();
a=ram[INL];
adc(0x80);
ram[INL]=a;
a=ram[INH];
adc(0x0);
ram[INH]=a;
clc();
a=ram[OUTL];
adc(0x80);
ram[OUTL]=a;
a=ram[OUTH];
adc(0x0);
ram[OUTH]=a;
if (a!=0x60) goto left_one_loop;
grsim_update();
ch=grsim_input();
if (ch) goto scroll_done;
usleep(17000); // 60Hz = 17ms
count++;
if (count==140) goto scroll_done;
goto scroll_loop;
scroll_done:
while(1) { while(1) {
ch=grsim_input(); ch=grsim_input();
if (ch) break; if (ch) break;