diff --git a/gr-sim/starfield.c b/gr-sim/starfield.c index 3fc042e3..e5b04210 100644 --- a/gr-sim/starfield.c +++ b/gr-sim/starfield.c @@ -118,8 +118,6 @@ int main(int argc, char **argv) { // int spready=256; int spreadz=16; struct fixed_type speedz; - - for(i=0;i<256;i++) { random_table[i]=rand()%256; diff --git a/gr-sim/starfield_fixed.c b/gr-sim/starfield_fixed.c index 37c02828..ccb849e4 100644 --- a/gr-sim/starfield_fixed.c +++ b/gr-sim/starfield_fixed.c @@ -82,6 +82,7 @@ static void random_star(int i) { /* Should we xor? */ stars[i].x.i=random_table[random_pointer++]; if (random_pointer>255) random_pointer=0; + stars[i].x.f=0; // stars[i].x.f=random_table[random_pointer++]; // if (random_pointer>255) random_pointer=0; @@ -90,6 +91,7 @@ static void random_star(int i) { if (random_pointer>255) random_pointer=0; // stars[i].y.f=random_table[random_pointer++]; // if (random_pointer>255) random_pointer=0; + stars[i].y.f=0; // double_to_fixed( (drand48()-0.5)*spreadx,&stars[i].x); // double_to_fixed( (drand48()-0.5)*spready,&stars[i].y); @@ -167,7 +169,7 @@ int main(int argc, char **argv) { /* Should NUMSTARS be prime to help with randomness */ - for(i=0;i=0;i--) { random_star(i); } gr(); @@ -175,14 +177,8 @@ int main(int argc, char **argv) { while(1) { gr(); - /* Set color */ - for(i=0;i=0;i--) { struct fixed_type dx,dy,temp; @@ -225,6 +221,8 @@ int main(int argc, char **argv) { if ((dx.i<0) || (dy.i<0) || (dx.i>=40) || (dy.i>=40)) { + printf("%i: out of range %d,%d\n", + i,dx.i,dy.i); random_star(i); } else { @@ -233,6 +231,13 @@ int main(int argc, char **argv) { // stars[i].z,stars[i].z); // } color_equals(color); + + printf("plot %i: (%d,%d,%d) %d,%d = %d\n", + i, + stars[i].x.i,stars[i].y.i, + stars[i].z, + dx.i,dy.i,color); + basic_plot(dx.i,dy.i); } @@ -249,7 +254,18 @@ int main(int argc, char **argv) { ch=grsim_input(); if (ch=='q') exit(0); usleep(10000); + + sleep(25); + exit(1); + } return 0; } + +/* TODO + press button to bring in ship sprite + another button make lines to origin, plus noise for few frames + then crosshair and flash +*/ + diff --git a/mode7/starfield_demo.s b/mode7/starfield_demo.s index 3ae4374c..99260c12 100644 --- a/mode7/starfield_demo.s +++ b/mode7/starfield_demo.s @@ -29,7 +29,7 @@ NUMSTARS EQU 16 sta DRAW_PAGE sta RANDOM_POINTER - ldy #NUMSTARS + ldy #(NUMSTARS-1) init_stars: jsr random_star dey @@ -52,32 +52,67 @@ starfield_loop: ; draw stars ;=============== - ldx #NUMSTARS + + ; start at 15 and count down (rather than 0 and count up) + ldx #(NUMSTARS-1) draw_stars: stx XX - txa - tay + ;================ ; calculate color + ;================ - lda #$ff + lda #$ff ; want if z<16, color = 5 + sta COLOR ; if 16