dos33fsprogs/xmas_2019/snow.s

202 lines
2.6 KiB
ArmAsm
Raw Normal View History

2019-12-11 13:35:56 +00:00
; Display falling snow
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
CH = $24
CV = $25
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
2019-12-19 02:11:36 +00:00
SEEDL = $4E
SEEDH = $4F
2019-12-11 13:35:56 +00:00
HGR_COLOR = $E4
SNOWX = $F0
HGR = $F3E2
2019-12-19 02:11:36 +00:00
NUMFLAKES = 10
2019-12-11 13:35:56 +00:00
.include "hardware.inc"
;==================================
;==================================
jsr HGR
bit FULLGR
display_loop:
; 0 4 8 c 10 14 18 1c
; 0 1 2 3 4 5 6 7
;=========================
; erase old snow
ldx #0
erase_loop:
2019-12-19 02:11:36 +00:00
lda snow_y,X ; get Y
2019-12-11 13:35:56 +00:00
lsr
lsr
2019-12-19 02:11:36 +00:00
lsr ; divide by 8
2019-12-11 13:35:56 +00:00
tay
2019-12-19 02:11:36 +00:00
2019-12-11 13:35:56 +00:00
clc
2019-12-19 02:11:36 +00:00
lda hgr_offsets_l,Y
2019-12-11 13:35:56 +00:00
adc snow_x,X
2019-12-19 02:11:36 +00:00
sta GBASL ; point GBASL to right location
2019-12-11 13:35:56 +00:00
lda snow_y,X
asl
asl
and #$1f
clc
2019-12-19 02:11:36 +00:00
adc hgr_offsets_h,Y
2019-12-11 13:35:56 +00:00
sta GBASH
ldy #0
lda #0
sta (GBASL),Y
inx
2019-12-19 02:11:36 +00:00
cpx #NUMFLAKES
2019-12-11 13:35:56 +00:00
bne erase_loop
;==========================
; move snow
ldx #0
move_snow:
lda snow_y,X ; inc to next line
cmp #191
bne just_inc
lda #0
sta snow_y,X
jmp done_inc
just_inc:
2019-12-19 02:11:36 +00:00
jsr random16
lda SEEDL
and #$f
beq snow_left
cmp #$1
beq snow_right
2019-12-11 13:35:56 +00:00
inc snow_y,X
2019-12-19 02:11:36 +00:00
jmp snow_no
snow_right:
inc snow_offset,X
jmp snow_no
snow_left:
dec snow_offset,X
snow_no:
2019-12-11 13:35:56 +00:00
done_inc:
inx
2019-12-19 02:11:36 +00:00
cpx #NUMFLAKES
2019-12-11 13:35:56 +00:00
bne move_snow
;=========================
; draw new snow
ldx #0
draw_loop:
lda snow_y,X
lsr
lsr
2019-12-19 02:11:36 +00:00
lsr
2019-12-11 13:35:56 +00:00
tay
clc
2019-12-19 02:11:36 +00:00
lda hgr_offsets_l,Y
2019-12-11 13:35:56 +00:00
adc snow_x,X
sta GBASL
lda snow_y,X
asl
asl
and #$1f
clc
2019-12-19 02:11:36 +00:00
adc hgr_offsets_h,Y
2019-12-11 13:35:56 +00:00
sta GBASH
ldy #0
lda #1
sta (GBASL),Y
inx
2019-12-19 02:11:36 +00:00
cpx #NUMFLAKES
2019-12-11 13:35:56 +00:00
bne draw_loop
lda #100
jsr WAIT
jmp display_loop ; 3
snow_x:
2019-12-19 02:11:36 +00:00
.byte 2,4,6,8,10,12,14,16,18,20
2019-12-11 13:35:56 +00:00
snow_offset:
2019-12-19 02:11:36 +00:00
.byte 0,1,2,3,4,5,6,7,0,1
2019-12-11 13:35:56 +00:00
snow_y:
2019-12-19 02:11:36 +00:00
.byte 0,0,0,0,0,0,0,0,0,0
hgr_offsets_h:
.byte >$2000,>$2080,>$2100,>$2180,>$2200,>$2280,>$2300,>$2380
.byte >$2028,>$20A8,>$2128,>$21A8,>$2228,>$22A8,>$2328,>$23A8
.byte >$2050,>$20D0,>$2150,>$21D0,>$2250,>$22D0,>$2350,>$23D0
hgr_offsets_l:
.byte <$2000,<$2080,<$2100,<$2180,<$2200,<$2280,<$2300,<$2380
.byte <$2028,<$20A8,<$2128,<$21A8,<$2228,<$22A8,<$2328,<$23A8
.byte <$2050,<$20D0,<$2150,<$21D0,<$2250,<$22D0,<$2350,<$23D0
2019-12-11 13:35:56 +00:00
2019-12-19 19:18:34 +00:00
div_7_q:
.byte 0,0,0,0,0,0,0 ; 0..6
.byte 1,1,1,1,1,1,1 ; 7..13
.byte 2,2,2,2,2,2,2 ; 14..20
.byte 3,3,3,3,3,3,3 ; 21..27
.byte 4,4,4,4,4,4,4 ; 28..34
.byte 5,5,5,5,5,5,5 ; 35..41
.byte 6,6,6,6,6,6,6 ; 42..48
.byte 7,7,7,7,7,7,7 ; 49..55
.byte 8,8,8,8,8,8,8 ; 56..62
.byte 9 ; 63
div_7_r:
.byte 0,1,2,3,4,5,6 ; 0..6
.byte 0,1,2,3,4,5,6 ; 7..13
.byte 0,1,2,3,4,5,6 ; 14..20
.byte 0,1,2,3,4,5,6 ; 21..27
.byte 0,1,2,3,4,5,6 ; 28..34
.byte 0,1,2,3,4,5,6 ; 35..41
.byte 0,1,2,3,4,5,6 ; 42..48
.byte 0,1,2,3,4,5,6 ; 49..55
.byte 0,1,2,3,4,5,6 ; 56..62
.byte 0 ; 63
2019-12-19 02:11:36 +00:00
.include "random16.s"