mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-08 15:29:41 +00:00
twist: simulated version
This commit is contained in:
parent
4bad9694e4
commit
0642baaf70
32
utils/gr-sim/twister/Makefile
Normal file
32
utils/gr-sim/twister/Makefile
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
CC = gcc
|
||||||
|
CFLAGS = -O2 -Wall -g
|
||||||
|
LFLAGS = -lm
|
||||||
|
|
||||||
|
SDL_LIBS= `sdl-config --libs`
|
||||||
|
SDL_INCLUDE= `sdl-config --cflags`
|
||||||
|
|
||||||
|
all: generate_sines \
|
||||||
|
twist_6502
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
generate_sines: generate_sines.o
|
||||||
|
$(CC) -o generate_sines generate_sines.o $(LFLAGS) -lm
|
||||||
|
|
||||||
|
generate_sines.o: generate_sines.c
|
||||||
|
$(CC) $(CFLAGS) -c generate_sines.c
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
twist_6502: twist_6502.o ../gr-sim.a
|
||||||
|
$(CC) -o twist_6502 twist_6502.o ../gr-sim.a $(LFLAGS) $(SDL_LIBS)
|
||||||
|
|
||||||
|
twist_6502.o: twist_6502.c
|
||||||
|
$(CC) $(CFLAGS) $(SDL_INCLUDE) -c twist_6502.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *~ *.o dots dots_dump dots_play dots_minimal dots_6502 dots_play2
|
80
utils/gr-sim/twister/twist_6502.c
Normal file
80
utils/gr-sim/twister/twist_6502.c
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
#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"
|
||||||
|
|
||||||
|
int main(int argc,char **argv) {
|
||||||
|
|
||||||
|
int ch,y,j;
|
||||||
|
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=1;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_equals(0);
|
||||||
|
hlin(0,12,27,y);
|
||||||
|
|
||||||
|
color_equals(1);
|
||||||
|
m=s; n=t;
|
||||||
|
if (q<r) { m=q; n=r;}
|
||||||
|
hlin(0,m,n,y);
|
||||||
|
|
||||||
|
color_equals(2);
|
||||||
|
if (r<s) { t=r; q=s;}
|
||||||
|
hlin(0,t,q,y);
|
||||||
|
|
||||||
|
j++;
|
||||||
|
|
||||||
|
}
|
||||||
|
grsim_update();
|
||||||
|
|
||||||
|
/* approximate 50Hz sleep */
|
||||||
|
// usleep(20000);
|
||||||
|
usleep(40000);
|
||||||
|
|
||||||
|
ch=grsim_input();
|
||||||
|
if (ch==27) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user