xmas2019: autogen sine table

This commit is contained in:
Vince Weaver 2019-12-16 00:52:07 -05:00
parent dc9473b95b
commit a6627524fb
4 changed files with 177 additions and 12 deletions

View File

@ -4,7 +4,7 @@ DOS33 = ../dos33fs-utils/dos33
B2D = ../bmp2dhr/b2d
PNG_TO_40x48D = ../gr-utils/png_to_40x48d
all: xmas2019.dsk
all: xmas2019.dsk sine_table
xmas2019.dsk: SNOW TREE HELLO
cp empty.dsk xmas2019.dsk
@ -49,6 +49,15 @@ FIREWORKS.BAS: fireworks.bas
HELLO: hello.bas
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO
####
sine_table: sine_table.o
$(CC) -o sine_table sine_table.o -lm
sine_table.o: sine_table.c
$(CC) -c sine_table.c
####
clean:
rm -f *~ *.o *.lst *.inc FIREWORKS.BAS

21
xmas_2019/sine_table.c Normal file
View File

@ -0,0 +1,21 @@
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv) {
int i,s;
for(s=4;s<16;s++) {
printf("sine_table%d:",s);
for(i=0;i<128;i++) {
if (i%16==0) printf("\n.byte\t");
printf("%2d",s+8+(15-s)+
(int)(s*sin(i*2*3.14159265/128.0)));
if (i%16!=15) printf(",");
}
printf("\n");
}
return 0;
}

108
xmas_2019/sines.inc Normal file
View File

@ -0,0 +1,108 @@
sine_table4:
.byte 23,23,23,23,23,23,24,24,24,24,24,25,25,25,25,25
.byte 25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26
.byte 27,26,26,26,26,26,26,26,26,26,26,26,26,26,26,25
.byte 25,25,25,25,25,25,24,24,24,24,24,23,23,23,23,23
.byte 23,23,23,23,23,23,22,22,22,22,22,21,21,21,21,21
.byte 21,21,20,20,20,20,20,20,20,20,20,20,20,20,20,20
.byte 19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21
.byte 21,21,21,21,21,21,22,22,22,22,22,23,23,23,23,23
sine_table5:
.byte 23,23,23,23,23,24,24,24,24,25,25,25,25,25,26,26
.byte 26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27
.byte 28,27,27,27,27,27,27,27,27,27,27,27,27,27,26,26
.byte 26,26,26,25,25,25,25,25,24,24,24,24,23,23,23,23
.byte 23,23,23,23,23,22,22,22,22,21,21,21,21,21,20,20
.byte 20,20,20,19,19,19,19,19,19,19,19,19,19,19,19,19
.byte 18,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20
.byte 20,20,20,21,21,21,21,21,22,22,22,22,23,23,23,23
sine_table6:
.byte 23,23,23,23,24,24,24,25,25,25,25,26,26,26,26,27
.byte 27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28
.byte 29,28,28,28,28,28,28,28,28,28,28,28,27,27,27,27
.byte 27,27,26,26,26,26,25,25,25,25,24,24,24,23,23,23
.byte 23,23,23,23,22,22,22,21,21,21,21,20,20,20,20,19
.byte 19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18
.byte 17,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19
.byte 19,19,20,20,20,20,21,21,21,21,22,22,22,23,23,23
sine_table7:
.byte 23,23,23,24,24,24,25,25,25,25,26,26,26,27,27,27
.byte 27,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29
.byte 30,29,29,29,29,29,29,29,29,29,29,29,28,28,28,28
.byte 27,27,27,27,26,26,26,25,25,25,25,24,24,24,23,23
.byte 23,23,23,22,22,22,21,21,21,21,20,20,20,19,19,19
.byte 19,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17
.byte 16,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18
.byte 19,19,19,19,20,20,20,21,21,21,21,22,22,22,23,23
sine_table8:
.byte 23,23,23,24,24,24,25,25,26,26,26,27,27,27,28,28
.byte 28,28,29,29,29,29,30,30,30,30,30,30,30,30,30,30
.byte 31,30,30,30,30,30,30,30,30,30,30,29,29,29,29,28
.byte 28,28,28,27,27,27,26,26,26,25,25,24,24,24,23,23
.byte 23,23,23,22,22,22,21,21,20,20,20,19,19,19,18,18
.byte 18,18,17,17,17,17,16,16,16,16,16,16,16,16,16,16
.byte 15,16,16,16,16,16,16,16,16,16,16,17,17,17,17,18
.byte 18,18,18,19,19,19,20,20,20,21,21,22,22,22,23,23
sine_table9:
.byte 23,23,23,24,24,25,25,26,26,26,27,27,28,28,28,29
.byte 29,29,29,30,30,30,30,31,31,31,31,31,31,31,31,31
.byte 32,31,31,31,31,31,31,31,31,31,30,30,30,30,29,29
.byte 29,29,28,28,28,27,27,26,26,26,25,25,24,24,23,23
.byte 23,23,23,22,22,21,21,20,20,20,19,19,18,18,18,17
.byte 17,17,17,16,16,16,16,15,15,15,15,15,15,15,15,15
.byte 14,15,15,15,15,15,15,15,15,15,16,16,16,16,17,17
.byte 17,17,18,18,18,19,19,20,20,20,21,21,22,22,23,23
sine_table10:
.byte 23,23,23,24,24,25,25,26,26,27,27,28,28,28,29,29
.byte 30,30,30,31,31,31,31,32,32,32,32,32,32,32,32,32
.byte 33,32,32,32,32,32,32,32,32,32,31,31,31,31,30,30
.byte 30,29,29,28,28,28,27,27,26,26,25,25,24,24,23,23
.byte 23,23,23,22,22,21,21,20,20,19,19,18,18,18,17,17
.byte 16,16,16,15,15,15,15,14,14,14,14,14,14,14,14,14
.byte 13,14,14,14,14,14,14,14,14,14,15,15,15,15,16,16
.byte 16,17,17,18,18,18,19,19,20,20,21,21,22,22,23,23
sine_table11:
.byte 23,23,24,24,25,25,26,26,27,27,28,28,29,29,29,30
.byte 30,31,31,31,32,32,32,32,33,33,33,33,33,33,33,33
.byte 34,33,33,33,33,33,33,33,33,32,32,32,32,31,31,31
.byte 30,30,29,29,29,28,28,27,27,26,26,25,25,24,24,23
.byte 23,23,22,22,21,21,20,20,19,19,18,18,17,17,17,16
.byte 16,15,15,15,14,14,14,14,13,13,13,13,13,13,13,13
.byte 12,13,13,13,13,13,13,13,13,14,14,14,14,15,15,15
.byte 16,16,17,17,17,18,18,19,19,20,20,21,21,22,22,23
sine_table12:
.byte 23,23,24,24,25,25,26,27,27,28,28,29,29,30,30,31
.byte 31,31,32,32,32,33,33,33,34,34,34,34,34,34,34,34
.byte 35,34,34,34,34,34,34,34,34,33,33,33,32,32,32,31
.byte 31,31,30,30,29,29,28,28,27,27,26,25,25,24,24,23
.byte 23,23,22,22,21,21,20,19,19,18,18,17,17,16,16,15
.byte 15,15,14,14,14,13,13,13,12,12,12,12,12,12,12,12
.byte 11,12,12,12,12,12,12,12,12,13,13,13,14,14,14,15
.byte 15,15,16,16,17,17,18,18,19,19,20,21,21,22,22,23
sine_table13:
.byte 23,23,24,24,25,26,26,27,27,28,29,29,30,30,31,31
.byte 32,32,33,33,33,34,34,34,35,35,35,35,35,35,35,35
.byte 36,35,35,35,35,35,35,35,35,34,34,34,33,33,33,32
.byte 32,31,31,30,30,29,29,28,27,27,26,26,25,24,24,23
.byte 23,23,22,22,21,20,20,19,19,18,17,17,16,16,15,15
.byte 14,14,13,13,13,12,12,12,11,11,11,11,11,11,11,11
.byte 10,11,11,11,11,11,11,11,11,12,12,12,13,13,13,14
.byte 14,15,15,16,16,17,17,18,19,19,20,20,21,22,22,23
sine_table14:
.byte 23,23,24,25,25,26,27,27,28,28,29,30,30,31,31,32
.byte 32,33,33,34,34,35,35,35,35,36,36,36,36,36,36,36
.byte 37,36,36,36,36,36,36,36,35,35,35,35,34,34,33,33
.byte 32,32,31,31,30,30,29,28,28,27,27,26,25,25,24,23
.byte 23,23,22,21,21,20,19,19,18,18,17,16,16,15,15,14
.byte 14,13,13,12,12,11,11,11,11,10,10,10,10,10,10,10
.byte 9,10,10,10,10,10,10,10,11,11,11,11,12,12,13,13
.byte 14,14,15,15,16,16,17,18,18,19,19,20,21,21,22,23
sine_table15:
.byte 23,23,24,25,25,26,27,28,28,29,30,30,31,31,32,33
.byte 33,34,34,35,35,35,36,36,36,37,37,37,37,37,37,37
.byte 38,37,37,37,37,37,37,37,36,36,36,35,35,35,34,34
.byte 33,33,32,31,31,30,30,29,28,28,27,26,25,25,24,23
.byte 23,23,22,21,21,20,19,18,18,17,16,16,15,15,14,13
.byte 13,12,12,11,11,11,10,10,10, 9, 9, 9, 9, 9, 9, 9
.byte 8, 9, 9, 9, 9, 9, 9, 9,10,10,10,11,11,11,12,12
.byte 13,13,14,15,15,16,16,17,18,18,19,20,21,21,22,23

View File

@ -34,7 +34,21 @@ display_loop:
ldx #0
ldy which_line_y,X
lda sine_table,Y
lda sine_table15,Y
tay
ldx #0
jsr draw_line
ldx #0
ldy which_line_y,X
lda sine_table14,Y
tay
ldx #0
jsr draw_line
ldx #0
ldy which_line_y,X
lda sine_table13,Y
tay
ldx #0
jsr draw_line
@ -51,13 +65,34 @@ display_loop:
;=========================
; draw new line
; draw line 3
ldx #0
ldy which_line_y,X
lda sine_table,Y
lda sine_table13,Y
tay
ldx #$44
jsr draw_line
; draw line 2
ldx #0
ldy which_line_y,X
lda sine_table14,Y
tay
ldx #$cc
jsr draw_line
; draw line 1
ldx #0
ldy which_line_y,X
lda sine_table15,Y
tay
ldx #$44
jsr draw_line
lda #100
jsr WAIT
@ -133,12 +168,4 @@ gr_offsets:
which_line_y:
.byte 0
sine_table:
.byte 23,23,24,25,25,26,27,28,28,29,30,30,31,31,32,33
.byte 33,34,34,35,35,35,36,36,36,37,37,37,37,37,37,37
.byte 37,37,37,37,37,37,37,37,36,36,36,35,35,35,34,34
.byte 33,33,32,31,31,30,30,29,28,28,27,26,25,25,24,23
.byte 23,23,22,21,21,20,19,18,18,17,16,16,15,15,14,13
.byte 13,12,12,11,11,11,10,10,10, 9, 9, 9, 9, 9, 9, 9
.byte 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,11,11,11,12,12
.byte 13,13,14,15,15,16,16,17,18,18,19,20,21,21,22,23
.include "sines.inc"