dos33fsprogs/xmas_2019/tree.s

243 lines
4.7 KiB
ArmAsm
Raw Normal View History

2019-12-14 05:12:31 +00:00
; Display awesome tree
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
CH = $24
CV = $25
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
HGR_COLOR = $E4
SNOWX = $F0
COLOR = $F1
2019-12-16 18:24:09 +00:00
CMASK1 = $F2
CMASK2 = $F3
2019-12-17 05:55:39 +00:00
WHICH_Y = $F4
2019-12-14 05:12:31 +00:00
.include "hardware.inc"
;==================================
;==================================
bit SET_GR
bit FULLGR
bit LORES
bit PAGE0
display_loop:
;=========================
2019-12-16 18:24:09 +00:00
; erase old lines
2019-12-16 05:52:07 +00:00
2019-12-17 18:21:23 +00:00
jsr clear_lores ; 6+1709
2019-12-14 05:12:31 +00:00
;==========================
; move line
2019-12-17 05:55:39 +00:00
inc WHICH_Y ; 5
lda WHICH_Y ; 3
2019-12-16 18:24:09 +00:00
and #$7f ; 2
2019-12-17 05:55:39 +00:00
sta WHICH_Y ; 3
2019-12-16 18:24:09 +00:00
;=====
2019-12-17 05:55:39 +00:00
; 13
2019-12-14 05:12:31 +00:00
;=========================
; draw new line
2019-12-19 03:34:11 +00:00
;OLD: 2,6,8,10,12,14,16,18,20,2
2019-12-17 18:21:23 +00:00
; 2+10*(100) + 18*(2+6+8+10+12+14+16+18+20+2) =
; 1002+18*108=1002+1944=2946
2019-12-19 03:34:11 +00:00
;NEW: 2,4,6,8,10,12,14,16,18,2,2,2
; 2+12*(100) + 18*(2+4+6+8+10+12+14+16+18+2+2+2) =
; 1202+18*96=1202+1728=2930
2019-12-17 18:21:23 +00:00
ldx #0 ; 2
2019-12-16 18:24:09 +00:00
draw_line_loop:
2019-12-14 05:12:31 +00:00
2019-12-17 18:21:23 +00:00
jsr draw_line ; 6+87+(18*len)
inx ; 2
cpx #10 ; 2
bne draw_line_loop ; 3
2019-12-16 05:52:07 +00:00
2019-12-17 18:21:23 +00:00
; -1
2019-12-16 05:52:07 +00:00
2019-12-14 05:12:31 +00:00
lda #100
jsr WAIT
jmp display_loop ; 3
2019-12-16 18:24:09 +00:00
;=================================
2019-12-14 05:12:31 +00:00
;=================================
; draw line
2019-12-16 18:24:09 +00:00
;=================================
;=================================
; X = which
2019-12-14 05:12:31 +00:00
2019-12-17 05:55:39 +00:00
; original: 31 + 14 + 26 + 20 + 23*len + 5 = 96+(23*len)
; optimized: 30 + 18 + 34 + 18*len + 5 = 87+(18*len)
2019-12-14 05:12:31 +00:00
draw_line:
2019-12-16 20:11:11 +00:00
; set up proper sine table
2019-12-17 05:55:39 +00:00
lda sine_table_l,X ; 4+
sta sine_table_smc+1 ; 4
lda sine_table_h,X ; 4+
sta sine_table_smc+2 ; 4
2019-12-16 20:11:11 +00:00
2019-12-17 05:55:39 +00:00
ldy WHICH_Y ; 3
2019-12-16 20:11:11 +00:00
sine_table_smc:
2019-12-17 05:55:39 +00:00
lda sine_table5,Y ; 4+
lsr ; 2
tay ; 2
bcs draw_line_odd ; 3
;======
; 30
2019-12-14 05:12:31 +00:00
draw_line_even:
2019-12-17 05:55:39 +00:00
; -1
lda tree_color,X ; 4+
and #$0f ; 2
sta ll_smc1+1 ; 4
lda #$f0 ; 2
sta ll_smc2+1 ; 4
jmp draw_line_actual ; 3
;====
; 18
2019-12-14 05:12:31 +00:00
draw_line_odd:
2019-12-17 05:55:39 +00:00
lda tree_color,X ; 4+
and #$f0 ; 2
sta ll_smc1+1 ; 4
lda #$0f ; 2
sta ll_smc2+1 ; 4
nop ; 2
;====
; 18
2019-12-16 18:24:09 +00:00
draw_line_actual:
2019-12-17 05:55:39 +00:00
lda gr_offsets_l,Y ; 4+
clc ; 2
adc tree_start,X ; 4+
sta ll_smc3+1 ; 4
sta ll_smc4+1 ; 4
2019-12-16 20:11:11 +00:00
2019-12-17 05:55:39 +00:00
lda gr_offsets_h,Y ; 4+
sta ll_smc3+2 ; 4
sta ll_smc4+2 ; 4
2019-12-16 18:24:09 +00:00
2019-12-17 05:55:39 +00:00
ldy tree_len,X ; 4+
;=====
; 34
2019-12-16 20:11:11 +00:00
2019-12-16 18:24:09 +00:00
line_loop:
2019-12-16 20:11:11 +00:00
ll_smc3:
2019-12-17 05:55:39 +00:00
lda $400,Y ; 4+
ll_smc2:
and #$f0 ; 2
ll_smc1:
ora #$0f ; 2
ll_smc4:
sta $400,Y ; 5
dey ; 2
bpl line_loop ; 3
;=====
; 18
2019-12-14 05:12:31 +00:00
2019-12-17 05:55:39 +00:00
; -1
rts ; 6
2019-12-14 05:12:31 +00:00
2019-12-16 18:24:09 +00:00
;=====================================
;=====================================
; clear the top 4 lines (eventually)
; clear 10-30 on lines 8-38
2019-12-17 18:21:23 +00:00
; 4+(80+5)*20+5 = 1709 cycles
2019-12-16 18:24:09 +00:00
clear_lores:
lda #$0 ; 2
2019-12-17 18:21:23 +00:00
ldx #19 ; 2
2019-12-16 18:24:09 +00:00
;===========
; 4
clear_lores_loop:
2019-12-17 18:21:23 +00:00
sta $600+10,X ; 8 ; 5
sta $680+10,X ; 10 ; 5
sta $700+10,X ; 12 ; 5
sta $780+10,X ; 14 ; 5
sta $428+10,X ; 16 ; 5
sta $4A8+10,X ; 18 ; 5
sta $528+10,X ; 20 ; 5
sta $5A8+10,X ; 22 ; 5
sta $628+10,X ; 24 ; 5
sta $6A8+10,X ; 26 ; 5
sta $728+10,X ; 28 ; 5
sta $7A8+10,X ; 30 ; 5
sta $450+10,X ; 32 ; 5
sta $4D0+10,X ; 34 ; 5
sta $550+10,X ; 36 ; 5
sta $5D0+10,X ; 38 ; 5
2019-12-16 18:24:09 +00:00
;===========
; 80
2019-12-17 18:21:23 +00:00
dex ; 2
bpl clear_lores_loop ; 3
2019-12-16 18:24:09 +00:00
;===========
2019-12-17 18:21:23 +00:00
; 5
2019-12-16 18:24:09 +00:00
; -1
rts ; 6
tree:
; color start stop ; 01234567890123456789
2019-12-16 20:11:11 +00:00
; .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
tree_color: .byte $DD,$44,$CC,$44,$CC,$44,$CC,$44,$CC,$88
tree_start: .byte 19, 17, 16, 15, 14, 13, 12, 11, 10, 19
2019-12-17 05:55:39 +00:00
tree_len: .byte 2-1, 6-1, 8-1, 10-1, 12-1, 14-1, 16-1, 18-1, 20-1, 2-1
2019-12-14 05:12:31 +00:00
2019-12-17 05:55:39 +00:00
gr_offsets_l:
.byte <$400,<$480,<$500,<$580,<$600,<$680,<$700,<$780
.byte <$428,<$4a8,<$528,<$5a8,<$628,<$6a8,<$728,<$7a8
.byte <$450,<$4d0,<$550,<$5d0,<$650,<$6d0,<$750,<$7d0
2019-12-14 05:12:31 +00:00
2019-12-17 05:55:39 +00:00
gr_offsets_h:
.byte >$400,>$480,>$500,>$580,>$600,>$680,>$700,>$780
.byte >$428,>$4a8,>$528,>$5a8,>$628,>$6a8,>$728,>$7a8
.byte >$450,>$4d0,>$550,>$5d0,>$650,>$6d0,>$750,>$7d0
2019-12-16 20:11:11 +00:00
sine_table_l:
.byte <sine_table5, <sine_table6, <sine_table7, <sine_table8
.byte <sine_table9, <sine_table10,<sine_table11,<sine_table12
.byte <sine_table13,<sine_table14,<sine_table15
sine_table_h:
.byte >sine_table5, >sine_table6, >sine_table7, >sine_table8
.byte >sine_table9, >sine_table10,>sine_table11,>sine_table12
.byte >sine_table13,>sine_table14,>sine_table15
2019-12-16 05:52:07 +00:00
.include "sines.inc"