dos33fsprogs/demos/xmas_2018/ball.s

254 lines
4.1 KiB
ArmAsm
Raw Normal View History

2018-12-12 17:33:05 +00:00
;=====================================
; XMAS2018 -- Ball Part
;=====================================
ball:
;===================
; init screen
;===================
; init vars
lda #15
sta XPOS
lda #38
sta YPOS
lda #0
sta FRAME
sta FRAMEH
;=============================
2018-12-18 03:58:19 +00:00
; ball graphic already loaded to $4000 (HGR page1)
2018-12-12 17:33:05 +00:00
2018-12-18 03:58:19 +00:00
;=============================
; set up scrolling
lda #0
sta OFFSET
2018-12-18 03:58:19 +00:00
;=============================
; decompress scroll image to $800
lda #<greets
sta LZ4_SRC
lda #>greets
sta LZ4_SRC+1
lda #<(greets_end)
sta LZ4_END
lda #>(greets_end)
sta LZ4_END+1
lda #<$800
sta LZ4_DST
lda #>$800
sta LZ4_DST+1
jsr lz4_decode
lda #237
sta SCROLL_LENGTH
2018-12-12 17:33:05 +00:00
;==============================
; setup graphics for vapor lock
;==============================
jsr vapor_lock ; 6
; vapor lock returns with us at beginning of hsync in line
; 114 (7410 cycles), so with 5070 lines to go
; so we have 5070 + 4550 = 9620 to kill
; FIXME: clear page0/page1 screens
; jsr gr_copy_to_current ; 6+ 9292
; now we have 322 left
; GR part
2018-12-17 19:50:40 +00:00
bit HIRES ; 4
2018-12-12 17:33:05 +00:00
bit SET_GR ; 4
bit FULLGR ; 4
2018-12-17 19:50:40 +00:00
bit PAGE1 ; 4
2018-12-12 17:33:05 +00:00
; 9620
2018-12-17 19:50:40 +00:00
; -16 mode set
2018-12-12 17:33:05 +00:00
; - 3 for jmp
;=======
2018-12-17 19:50:40 +00:00
; 9601
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
; Try X=18 Y=100 cycles=9601
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
ldy #100 ; 2
baloopA:ldx #18 ; 2
2018-12-12 17:33:05 +00:00
baloopB:dex ; 2
bne baloopB ; 2nt/3
dey ; 2
bne baloopA ; 2nt/3
jmp ball_begin_loop
.align $100
;================================================
; Ball Loop
;================================================
; each scan line 65 cycles
; 1 cycle each byte (40cycles) + 25 for horizontal
; Total of 12480 cycles to draw screen
; Vertical blank = 4550 cycles (70 scan lines)
; Total of 17030 cycles to get back to where was
ball_begin_loop:
ball_display_loop:
2018-12-17 19:50:40 +00:00
; draw 160 lines of hires PAGE1
bit HIRES ; 4
bit PAGE1 ; 4
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
; (160*65)-8 = 10392
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
; Try X=43 Y=47 cycles=10388 R4
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
nop
nop
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
ldy #47 ; 2
baloopC:ldx #43 ; 2
2018-12-12 17:33:05 +00:00
baloopD:dex ; 2
bne baloopD ; 2nt/3
dey ; 2
bne baloopC ; 2nt/3
2018-12-17 19:50:40 +00:00
; draw 32 (4) lines of lores PAGE0
bit LORES ; 4
bit PAGE0 ; 4
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
; (32*65)-8 = 2072
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
; Try X=1 Y=188 cycles=2069
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
lda $0
2018-12-12 17:33:05 +00:00
2018-12-17 19:50:40 +00:00
ldy #188 ; 2
baloopE:ldx #1 ; 2
2018-12-12 17:33:05 +00:00
baloopF:dex ; 2
bne baloopF ; 2nt/3
dey ; 2
bne baloopE ; 2nt/3
;======================================================
; We have 4550 cycles in the vblank, use them wisely
;======================================================
; do_nothing should be 4550
2018-12-18 03:58:19 +00:00
; -1023 music
; -1844 scroll/else
2018-12-18 05:17:20 +00:00
; -18 frame adjust
2018-12-12 17:33:05 +00:00
; -10 keypress
; -8 pick which
2018-12-18 05:17:20 +00:00
; -7 check for end
2018-12-12 17:33:05 +00:00
; ===========
; 1640
2018-12-18 05:17:20 +00:00
inc FRAME ; 5
lda FRAME ; 3
and #63 ; 2
beq framing ; 3
; -1
lda $0 ; 3
jmp done_framing ; 3
framing:
inc FRAMEH ; 5
done_framing:
;=============
; 18
lda FRAMEH ; 3
cmp #13 ; length of song? ; 2
2018-12-18 05:17:20 +00:00
beq ball_done ; 3
; -1
;===============
; 7
2018-12-18 03:58:19 +00:00
2018-12-12 17:33:05 +00:00
2018-12-18 03:58:19 +00:00
jsr play_music ; 6+1017
2018-12-12 17:33:05 +00:00
; slow things down a bit
lda FRAME ; 3
and #1 ; 2
beq do_scrolling ; 3
;=============
; 8
do_something_else:
; -1
jsr do_reflection ; 6+1836
; 1845 (+1 incoming)
; -3 jmp
;-1842 do_reflection
;===================
; 0
2018-12-21 18:09:42 +00:00
; Try X=16 Y=1 cycles=87
; ldy #1 ; 2
;baloopQ:ldx #16 ; 2
;baloopR:dex ; 2
; bne baloopR ; 2nt/3
; dey ; 2
; bne baloopQ ; 2nt/3
jmp done_actions ; 3
do_scrolling:
jsr scroll_loop ; 6+1835
lda $0 ; 3
;=========
; 1844
done_actions:
2018-12-12 17:33:05 +00:00
; Try X=16 Y=19 cycles=1635 R5
nop
lda $0
2018-12-12 17:33:05 +00:00
ldy #19 ; 2
baloop1:ldx #16 ; 2
2018-12-12 17:33:05 +00:00
baloop2:dex ; 2
bne baloop2 ; 2nt/3
dey ; 2
bne baloop1 ; 2nt/3
2018-12-18 03:58:19 +00:00
; keypress = 10
2018-12-12 17:33:05 +00:00
lda KEYPRESS ; 4
bpl ba_no_keypress ; 3
; -1
2018-12-18 05:17:20 +00:00
jmp ball_done ; 3
2018-12-12 17:33:05 +00:00
ba_no_keypress:
jmp ball_display_loop ; 3
2018-12-18 05:17:20 +00:00
ball_done:
2018-12-12 17:33:05 +00:00
bit KEYRESET ; clear keypress ; 4
rts ; 6
.include "reflection.s"