twist: work on lookup

This commit is contained in:
Vince Weaver 2023-12-13 01:28:31 -05:00
parent 0642baaf70
commit 227db7acb8
2 changed files with 124 additions and 2 deletions

View File

@ -6,7 +6,7 @@ SDL_LIBS= `sdl-config --libs`
SDL_INCLUDE= `sdl-config --cflags`
all: generate_sines \
twist_6502
twist_6502 twist_dump
###
@ -24,9 +24,17 @@ twist_6502: twist_6502.o ../gr-sim.a
twist_6502.o: twist_6502.c
$(CC) $(CFLAGS) $(SDL_INCLUDE) -c twist_6502.c
###
twist_dump: twist_dump.o ../gr-sim.a
$(CC) -o twist_dump twist_dump.o ../gr-sim.a $(LFLAGS) $(SDL_LIBS)
twist_dump.o: twist_dump.c
$(CC) $(CFLAGS) $(SDL_INCLUDE) -c twist_dump.c
###
clean:
rm -f *~ *.o dots dots_dump dots_play dots_minimal dots_6502 dots_play2
rm -f *~ *.o twist_6502 twist_dump

View File

@ -0,0 +1,114 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
#include <math.h>
//#include "../gr-sim.h"
//#include "../tfv_zp.h"
unsigned char ram[40][48];
int hlin(int color,int x1, int x2, int y) {
int j;
for(j=x1;j<x2;j++) ram[j][y]=color;
return 0;
}
int main(int argc,char **argv) {
int xx,yy,temp;
int total_bytes=0;
int y,j,color,old,run;
double pi=3.14,f,e,m,n,s,t,q,r;
double a[64*48],b[64*48];
// grsim_init();
// gr();
j=0;
for(e=0;e<pi*2.0;e+=0.1) {
m=15.0+cos(e)*12.0;
n=pi-sin(e)*pi;
for(y=0;y<48;y++) {
f=(double)y*0.5/m-n;
a[j]=8.0*cos(f);
b[j]=8.0*sin(f);
j++;
}
}
// clear_screens();
// soft_switch(MIXCLR);
// ram[DRAW_PAGE]=0;
// while(1) {
j=0;
for(e=0;e<63;e++) {
for(y=0;y<48;y++) {
s=20-a[j];
t=20-b[j];
q=20+a[j];
r=20+b[j];
/* re-draw background */
color=0;
hlin(color,12,27,y);
color=1;
m=s; n=t;
if (q<r) { m=q; n=r;}
hlin(color,m,n,y);
color=2;
if (r<s) { t=r; q=s;}
hlin(color,t,q,y);
j++;
}
// grsim_update();
printf("; Frame %d\n",(int)e);
for(yy=0;yy<24;yy++) {
old=0xff; run=0;
printf(".byte ");
for(xx=12;xx<27;xx++) {
temp=(ram[xx][(yy*2)+1]<<4)+
(ram[xx][(yy*2)]);
if (temp!=old) {
if (xx!=12) printf(",");
printf("$%02X",temp);
total_bytes++;
old=temp;
}
}
printf("\n");
}
/* approximate 50Hz sleep */
// usleep(20000);
// usleep(40000);
// ch=grsim_input();
// if (ch==27) {
// return 0;
// }
}
printf("; Total bytes = %d\n",total_bytes);
// }
return 0;
}