dots: more progress

This commit is contained in:
Vince Weaver 2023-11-28 00:38:18 -05:00
parent 8145b7186c
commit e2c14813ed
2 changed files with 104 additions and 8 deletions

94
utils/gr-sim/dots/NOTES Normal file
View File

@ -0,0 +1,94 @@
Look reasonably well want at least 128 dots at 25Hz or so.
Hard to do. Each dot has 4 muls and 2 divides which is expensive on 6502.
Lookup tables? At some point they are so large you might as well just
do a movie.
Note even C64 version isn't accurate to the original.
Initial implementation:
512 dots, 2450 frames (35s when run at 70Hz which is what VGA does)
256 dots, 2450 frames is ~1MB of data
With this setup:
$FF = all done
$FE = new frame shadow
$FD = new frame balls
For X:
$0..$27 (0..39) 00XX XXXX
both
1100 0000 - 1110 0111
$C0-$E7
top 1000 0000 - 1010 0111
$80-$A7
bottom
0100 0000 - 0110 0111
$40-$67
new row
0000 0000 - 0001 0111
$00-$17
For Y:
$0..$17 (0..23) 000X XXXX
01XX XXXX = new row
specify top/bottom/both
256 dots/2450 frames = 709,134 bytes
skip factor 1 (none) = 41s
skip factor 2 OK = 37s
2450 frames @70Hz = 350 frames at 10Hz
70=7*5*2
without dot removal
70fps 35fps 14fps 10fps 7fps 5fps
256 dots: 709134 101304 70913 50652
128 dots: 462169 66024 46216 33012
64 dots: 290877 41533 29087 20776
with dot removal
70fps 35fps 14fps 10fps 7fps 5fps
256 dots: 677907
128 dots: 448966 44767
64 dots: 285486 40694
new compact format
70fps 35fps 14fps 10fps 7fps 5fps
256 dots: 76516 53447 38227
128 dots: 52456 36632
64 dots: 120183 34299
40k
zx02 version:
70fps 10fps 7fps 5fps
256 dots: 1.4MB
128 dots: 1.4MB
actual version:
requires 4 multiplies and 2 divides for each point
have a routine 250 cycles for multiply
250x6x256 = 384000 = 2 fps

View File

@ -28,7 +28,7 @@ static short rotcos=0;
static void drawdots(void) {
int temp32;
int transx,transz;
// int transx,transz;
unsigned short ball_x,ball_y,shadow_y;
unsigned short d,sc,newy;
unsigned short ax;
@ -39,26 +39,28 @@ static void drawdots(void) {
/* https://en.wikipedia.org/wiki/3D_projection */
transx=dot_x[d]*rotsin;
transz=dot_z[d]*rotcos;
temp32=transz-transx;
/* bx= (ez/dz)*dx + ex */
/* by= (ez/dz)*dy + ey */
temp32=((dot_z[d]*rotcos)-(dot_x[d]*rotsin));
sc=(temp32>>16)+9000;
if (sc==0) sc=1;
// printf("%d\n",sc-9000);
transx=dot_x[d]*rotcos;
transz=dot_z[d]*rotsin;
temp32=transx+transz;
temp32=((dot_x[d]*rotcos)+(dot_z[d]*rotsin));
temp32>>=8;
temp32=temp32+(temp32>>3);
ball_x=(temp32/sc)/8;
// printf("%x/%x/8=%x\n",temp32,sc,ball_x);
/* center */
ball_x+=20;
/* if off end of screen, no need for shadow */
if (ball_x>39) continue;
/**********/