dos33fsprogs/xmas_2018/ball.s

203 lines
3.4 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 #>a2_scroll
sta INH
lda #<a2_scroll
sta INL
2018-12-18 03:58:19 +00:00
jsr decompress_scroll
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
; -1841 scroll
2018-12-18 05:17:20 +00:00
; -18 frame adjust
2018-12-12 17:33:05 +00:00
; -10 keypress
2018-12-18 05:17:20 +00:00
; -7 check for end
2018-12-12 17:33:05 +00:00
; ===========
2018-12-18 05:17:20 +00:00
; 1651
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 #30 ; length of song? ; 2
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
2018-12-18 03:58:19 +00:00
jsr scroll_loop ; 6+1835
2018-12-12 17:33:05 +00:00
2018-12-18 05:17:20 +00:00
; Try X=1 Y=150 cycles=1651
2018-12-12 17:33:05 +00:00
2018-12-18 05:17:20 +00:00
ldy #150 ; 2
2018-12-18 03:58:19 +00:00
baloop1:ldx #1 ; 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
2018-12-18 03:58:19 +00:00
.include "gr_scroll.s"
.include "greets.inc"