xmas2019: update tree drawing

This commit is contained in:
Vince Weaver 2019-12-16 13:24:09 -05:00
parent a6627524fb
commit c77f604680
4 changed files with 191 additions and 169 deletions

View File

@ -60,4 +60,4 @@ sine_table.o: sine_table.c
####
clean:
rm -f *~ *.o *.lst *.inc FIREWORKS.BAS
rm -f *~ *.o *.lst FIREWORKS.BAS

View File

@ -11,7 +11,7 @@ int main(int argc, char **argv) {
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)));
(int)round(s*sin(i*2*3.14159265/128.0)));
if (i%16!=15) printf(",");
}
printf("\n");

View File

@ -1,108 +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
.byte 23,23,23,24,24,24,24,24,25,25,25,25,25,25,26,26
.byte 26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27
.byte 27,27,27,27,27,27,27,27,27,27,27,26,26,26,26,26
.byte 26,26,26,25,25,25,25,25,25,24,24,24,24,24,23,23
.byte 23,23,23,22,22,22,22,22,21,21,21,21,21,21,20,20
.byte 20,20,20,20,20,20,19,19,19,19,19,19,19,19,19,19
.byte 19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20
.byte 20,20,20,21,21,21,21,21,21,22,22,22,22,22,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
.byte 23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,26
.byte 27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28
.byte 28,28,28,28,28,28,28,28,28,28,27,27,27,27,27,27
.byte 27,26,26,26,26,26,25,25,25,25,24,24,24,24,23,23
.byte 23,23,23,22,22,22,22,21,21,21,21,20,20,20,20,20
.byte 19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18
.byte 18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19
.byte 19,20,20,20,20,20,21,21,21,21,22,22,22,22,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
.byte 23,23,24,24,24,24,25,25,25,26,26,26,26,27,27,27
.byte 27,27,28,28,28,28,28,28,29,29,29,29,29,29,29,29
.byte 29,29,29,29,29,29,29,29,29,28,28,28,28,28,28,27
.byte 27,27,27,27,26,26,26,26,25,25,25,24,24,24,24,23
.byte 23,23,22,22,22,22,21,21,21,20,20,20,20,19,19,19
.byte 19,19,18,18,18,18,18,18,17,17,17,17,17,17,17,17
.byte 17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,19
.byte 19,19,19,19,20,20,20,20,21,21,21,22,22,22,22,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
.byte 23,23,24,24,24,25,25,25,26,26,26,27,27,27,27,28
.byte 28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30
.byte 30,30,30,30,30,30,30,30,29,29,29,29,29,29,28,28
.byte 28,28,27,27,27,27,26,26,26,25,25,25,24,24,24,23
.byte 23,23,22,22,22,21,21,21,20,20,20,19,19,19,19,18
.byte 18,18,18,17,17,17,17,17,17,16,16,16,16,16,16,16
.byte 16,16,16,16,16,16,16,16,17,17,17,17,17,17,18,18
.byte 18,18,19,19,19,19,20,20,20,21,21,21,22,22,22,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
.byte 23,23,24,24,25,25,25,26,26,26,27,27,27,28,28,28
.byte 29,29,29,29,30,30,30,30,30,31,31,31,31,31,31,31
.byte 31,31,31,31,31,31,31,31,30,30,30,30,30,29,29,29
.byte 29,28,28,28,27,27,27,26,26,26,25,25,25,24,24,23
.byte 23,23,22,22,21,21,21,20,20,20,19,19,19,18,18,18
.byte 17,17,17,17,16,16,16,16,16,15,15,15,15,15,15,15
.byte 15,15,15,15,15,15,15,15,16,16,16,16,16,17,17,17
.byte 17,18,18,18,19,19,19,20,20,20,21,21,21,22,22,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
.byte 23,23,24,24,25,25,26,26,26,27,27,28,28,28,29,29
.byte 29,30,30,30,30,31,31,31,31,31,32,32,32,32,32,32
.byte 32,32,32,32,32,32,32,31,31,31,31,31,30,30,30,30
.byte 29,29,29,28,28,28,27,27,26,26,26,25,25,24,24,23
.byte 23,23,22,22,21,21,20,20,20,19,19,18,18,18,17,17
.byte 17,16,16,16,16,15,15,15,15,15,14,14,14,14,14,14
.byte 14,14,14,14,14,14,14,15,15,15,15,15,16,16,16,16
.byte 17,17,17,18,18,18,19,19,20,20,20,21,21,22,22,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,31,31,31,32,32,32,32,32,33,33,33,33,33,33
.byte 33,33,33,33,33,33,33,32,32,32,32,32,31,31,31,30
.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,15,15,15,14,14,14,14,14,13,13,13,13,13,13
.byte 13,13,13,13,13,13,13,14,14,14,14,14,15,15,15,16
.byte 16,16,17,17,17,18,18,19,19,20,20,21,21,22,22,23
sine_table11:
.byte 23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,30
.byte 31,31,32,32,32,32,33,33,33,33,34,34,34,34,34,34
.byte 34,34,34,34,34,34,34,33,33,33,33,32,32,32,32,31
.byte 31,30,30,30,29,29,28,28,27,27,26,26,25,25,24,24
.byte 23,22,22,21,21,20,20,19,19,18,18,17,17,16,16,16
.byte 15,15,14,14,14,14,13,13,13,13,12,12,12,12,12,12
.byte 12,12,12,12,12,12,12,13,13,13,13,14,14,14,14,15
.byte 15,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22
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
.byte 23,24,24,25,25,26,26,27,28,28,29,29,30,30,31,31
.byte 31,32,32,33,33,33,34,34,34,34,34,35,35,35,35,35
.byte 35,35,35,35,35,35,34,34,34,34,34,33,33,33,32,32
.byte 31,31,31,30,30,29,29,28,28,27,26,26,25,25,24,24
.byte 23,22,22,21,21,20,20,19,18,18,17,17,16,16,15,15
.byte 15,14,14,13,13,13,12,12,12,12,12,11,11,11,11,11
.byte 11,11,11,11,11,11,12,12,12,12,12,13,13,13,14,14
.byte 15,15,15,16,16,17,17,18,18,19,20,20,21,21,22,22
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
.byte 23,24,24,25,26,26,27,27,28,29,29,30,30,31,31,32
.byte 32,33,33,33,34,34,34,35,35,35,35,36,36,36,36,36
.byte 36,36,36,36,36,36,35,35,35,35,34,34,34,33,33,33
.byte 32,32,31,31,30,30,29,29,28,27,27,26,26,25,24,24
.byte 23,22,22,21,20,20,19,19,18,17,17,16,16,15,15,14
.byte 14,13,13,13,12,12,12,11,11,11,11,10,10,10,10,10
.byte 10,10,10,10,10,10,11,11,11,11,12,12,12,13,13,13
.byte 14,14,15,15,16,16,17,17,18,19,19,20,20,21,22,22
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
.byte 23,24,24,25,26,26,27,28,28,29,30,30,31,31,32,32
.byte 33,33,34,34,35,35,35,36,36,36,36,37,37,37,37,37
.byte 37,37,37,37,37,37,36,36,36,36,35,35,35,34,34,33
.byte 33,32,32,31,31,30,30,29,28,28,27,26,26,25,24,24
.byte 23,22,22,21,20,20,19,18,18,17,16,16,15,15,14,14
.byte 13,13,12,12,11,11,11,10,10,10,10, 9, 9, 9, 9, 9
.byte 9, 9, 9, 9, 9, 9,10,10,10,10,11,11,11,12,12,13
.byte 13,14,14,15,15,16,16,17,18,18,19,20,20,21,22,22
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
.byte 23,24,24,25,26,27,27,28,29,29,30,31,31,32,33,33
.byte 34,34,35,35,35,36,36,37,37,37,37,38,38,38,38,38
.byte 38,38,38,38,38,38,37,37,37,37,36,36,35,35,35,34
.byte 34,33,33,32,31,31,30,29,29,28,27,27,26,25,24,24
.byte 23,22,22,21,20,19,19,18,17,17,16,15,15,14,13,13
.byte 12,12,11,11,11,10,10, 9, 9, 9, 9, 8, 8, 8, 8, 8
.byte 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11,11,11,12
.byte 12,13,13,14,15,15,16,17,17,18,19,19,20,21,22,22

View File

@ -12,8 +12,8 @@ BASH = $29
HGR_COLOR = $E4
SNOWX = $F0
COLOR = $F1
HGR = $F3E2
CMASK1 = $F2
CMASK2 = $F3
.include "hardware.inc"
@ -30,68 +30,37 @@ HGR = $F3E2
display_loop:
;=========================
; erase old line
; erase old lines
ldx #0
ldy which_line_y,X
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
jsr clear_lores ; 6+1749
;==========================
; move line
inc which_line_y
lda which_line_y
and #$7f
sta which_line_y
inc which_line_y ; 6
lda which_line_y ; 4
and #$7f ; 2
sta which_line_y ; 4
;=====
; 16
;=========================
; draw new line
; draw line 3
ldx #0
ldy which_line_y,X
lda sine_table13,Y
draw_line_loop:
ldy which_line_y
sine_table_smc:
lda sine_table5,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
inx
cpx #10
bne draw_line_loop
lda #100
jsr WAIT
@ -99,8 +68,13 @@ display_loop:
jmp display_loop ; 3
;=================================
;=================================
; draw line
;=================================
;=================================
; Y = y position
; X = which
draw_line:
tya
@ -108,7 +82,24 @@ draw_line:
bne draw_line_odd
draw_line_even:
lda #$0f
sta ll_smc1+1
lda #$f0
sta ll_smc2+1
jmp draw_line_actual
draw_line_odd:
lda #$f0
sta ll_smc1+1
lda #$0f
sta ll_smc2+1
draw_line_actual:
tya
and #$fe
tay
lda gr_offsets,Y
clc
adc #10
sta GBASL
@ -117,11 +108,14 @@ draw_line_even:
sta GBASH
ldy #0
txa
lda #$CC
ll_smc1:
and #$0f
sta COLOR
line_loop:
lda (GBASL),Y
ll_smc2:
and #$f0
ora COLOR
sta (GBASL),Y
@ -132,33 +126,61 @@ line_loop:
rts
draw_line_odd:
tya
and #$fe
tay
lda gr_offsets,Y
clc
adc #10
sta GBASL
;=====================================
;=====================================
lda gr_offsets+1,Y
sta GBASH
; clear the top 4 lines (eventually)
; clear 10-30 on lines 8-38
ldy #0
txa
and #$f0
sta COLOR
line_loop_odd:
lda (GBASL),Y
and #$0f
ora COLOR
sta (GBASL),Y
iny
cpy #20
bne line_loop_odd
; 4+(80+7)*20+5 = 1749 cycles
clear_lores:
rts
lda #$0 ; 2
ldx #10 ; 2
;===========
; 4
clear_lores_loop:
sta $600,X ; 8 ; 5
sta $680,X ; 10 ; 5
sta $700,X ; 12 ; 5
sta $780,X ; 14 ; 5
sta $428,X ; 16 ; 5
sta $4A8,X ; 18 ; 5
sta $528,X ; 20 ; 5
sta $5A8,X ; 22 ; 5
sta $628,X ; 24 ; 5
sta $6A8,X ; 26 ; 5
sta $728,X ; 28 ; 5
sta $7A8,X ; 30 ; 5
sta $450,X ; 32 ; 5
sta $4D0,X ; 34 ; 5
sta $550,X ; 36 ; 5
sta $5D0,X ; 38 ; 5
;===========
; 80
inx ; 2
cpx #30 ; 2
bne clear_lores_loop ; 3
;===========
; 7
; -1
rts ; 6
tree:
; color start stop ; 01234567890123456789
.byte $DD, 19, 20, $00 ; YY
.byte $44, 17, 22, $00 ; DDDDDD
.byte $CC, 16, 23, $00 ; LLLLLLLL
.byte $44, 15, 24, $00 ; DDDDDDDDDD
.byte $CC, 14, 25, $00 ; LLLLLLLLLLLL
.byte $44, 13, 26, $00 ; DDDDDDDDDDDDDD
.byte $CC, 12, 27, $00 ; LLLLLLLLLLLLLLLL
.byte $44, 11, 28, $00 ; DDDDDDDDDDDDDDDDDD
.byte $CC, 10, 29, $00 ; LLLLLLLLLLLLLLLLLLLL
.byte $88, 19, 20, $00 ; BB
gr_offsets:
.word $400,$480,$500,$580,$600,$680,$700,$780