dots: more work on 6502 dots

This commit is contained in:
Vince Weaver 2023-11-27 16:49:43 -05:00
parent 9903d4ffc5
commit 8145b7186c
1 changed files with 8 additions and 27 deletions

View File

@ -12,8 +12,6 @@
#define MAXDOTS 256
//#define SKIP 2
static short gravitybottom;
static short gravity=0;
static short gravityd=16;
@ -26,16 +24,21 @@ static short dot_yadd[MAXDOTS];
static short rotsin=0;
static short rotcos=0;
static void drawdots(void) {
int temp32;
int transx,transz;
unsigned short ball_x,ball_y,shadow_y;
unsigned short d,sc,newy;
unsigned short ax,bx,cx,dx;
unsigned short ax;
short signed_ax;
for(d=0;d<MAXDOTS;d++) {
/* https://en.wikipedia.org/wiki/3D_projection */
transx=dot_x[d]*rotsin;
transz=dot_z[d]*rotcos;
temp32=transz-transx;
@ -46,36 +49,14 @@ static void drawdots(void) {
transz=dot_z[d]*rotsin;
temp32=transx+transz;
temp32>>=8;
#if 1
ax=temp32&0xffff;
dx=(temp32>>16)&0xffff;
bx=ax;
cx=dx; // mov cx,dx
ax=(ax>>3)|(dx<<13); // shrd ax,dx,3
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;
/* center */
ball_x+=20;
/* if off end of screen, no need for shadow */
if (ball_x>39) continue;