From 9903d4ffc5318177270df2957ee53404c8cb4c37 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 27 Nov 2023 16:22:06 -0500 Subject: [PATCH] dots: more work on 6502 --- utils/gr-sim/dots/dots_6502.c | 90 +++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/utils/gr-sim/dots/dots_6502.c b/utils/gr-sim/dots/dots_6502.c index 10b9ada1..715ba277 100644 --- a/utils/gr-sim/dots/dots_6502.c +++ b/utils/gr-sim/dots/dots_6502.c @@ -18,12 +18,10 @@ static short gravitybottom; static short gravity=0; static short gravityd=16; -static struct { - short x; // 0 - short y; // 2 - short z; // 4 - short yadd; // 14 -} dot[MAXDOTS]; +static short dot_x[MAXDOTS]; +static short dot_y[MAXDOTS]; +static short dot_z[MAXDOTS]; +static short dot_yadd[MAXDOTS]; static short rotsin=0; static short rotcos=0; @@ -38,21 +36,21 @@ static void drawdots(void) { for(d=0;d>16)+9000; if (sc==0) sc=1; - transx=dot[d].x*rotcos; - transz=dot[d].z*rotsin; + transx=dot_x[d]*rotcos; + transz=dot_z[d]*rotsin; temp32=transx+transz; temp32>>=8; - +#if 1 ax=temp32&0xffff; dx=(temp32>>16)&0xffff; - bx=ax; // mov bx,ax + bx=ax; cx=dx; // mov cx,dx ax=(ax>>3)|(dx<<13); // shrd ax,dx,3 @@ -60,16 +58,24 @@ static void drawdots(void) { signed_ax=dx; dx=signed_ax>>3; + temp32=temp32>>3; + ax=temp32&0xffff; + dx=(temp32>>16)&0xffff; + temp32=ax+bx; // add ax,bx ax=ax+bx; dx=dx+cx; // adc dx,cx if (temp32&(1<<16)) dx=dx+1; temp32=(dx<<16)|(ax&0xffff); +#else + temp32=temp32+(temp32>>3); +#endif ball_x=(temp32/sc)/8; ball_x+=20; + /* if off end of screen, no need for shadow */ if (ball_x>39) continue; @@ -94,24 +100,24 @@ static void drawdots(void) { /* ball */ /********/ - dot[d].yadd+=gravity; - newy=dot[d].y+dot[d].yadd; + dot_yadd[d]+=gravity; + newy=dot_y[d]+dot_yadd[d]; temp32=newy; if (temp32&0x8000) temp32|=0xffff0000; if (temp32>=gravitybottom) { - ax=-dot[d].yadd; - temp32=(-dot[d].yadd)*gravityd; + //ax=-dot_yadd[d]; + temp32=(-dot_yadd[d])*gravityd; ax=temp32&0xffff; signed_ax=ax; ax=signed_ax>>4; - dot[d].yadd=ax; - newy+=dot[d].yadd; + dot_yadd[d]=ax; + newy+=dot_yadd[d]; } - dot[d].y=newy; + dot_y[d]=newy; /* sign extend */ temp32=newy; @@ -181,18 +187,18 @@ int main(int argc,char **argv) { } for(a=0;a1357 && !(frame&31) && grav>0) grav--; }