dos33fsprogs/games/space_bars/level6_saturn.s

567 lines
9.0 KiB
ArmAsm
Raw Normal View History

2018-08-02 04:13:40 +00:00
;================================
; spacebars gameplay
2018-08-02 04:13:40 +00:00
;================================
2019-06-14 01:32:14 +00:00
level6_saturn:
2018-08-02 04:13:40 +00:00
;===================
; init screen
bit KEYRESET
;===================
; init vars
lda #15
sta XPOS
lda #38
sta YPOS
2018-08-02 04:13:40 +00:00
2018-10-08 16:20:09 +00:00
lda #0
sta FRAMEH
2018-10-08 03:45:37 +00:00
;=============================
; Load graphic hgr
lda #<background_hgr
sta LZ4_SRC
lda #>background_hgr
sta LZ4_SRC+1
lda #<(background_hgr_end-8) ; skip checksum at end
sta LZ4_END
lda #>(background_hgr_end-8) ; skip checksum at end
sta LZ4_END+1
lda #<$2000
sta LZ4_DST
lda #>$2000
sta LZ4_DST+1
jsr lz4_decode
2018-10-08 02:59:56 +00:00
;==================
; setup framebuffer
2018-10-08 16:00:10 +00:00
lda #0
sta ZPOS
; lda #$12
; sta FRAMEBUFFER+0
; lda #$3f
; sta FRAMEBUFFER+1
; lda #$56
; sta FRAMEBUFFER+2
; lda #$78
; sta FRAMEBUFFER+3
; lda #$9A
; sta FRAMEBUFFER+4
; lda #$BC
; sta FRAMEBUFFER+5
; lda #$DE
; sta FRAMEBUFFER+6
; lda #$F0
; sta FRAMEBUFFER+7
; lda #$12
; sta FRAMEBUFFER+8
; lda #$3f
; sta FRAMEBUFFER+9
; lda #$56
; sta FRAMEBUFFER+10
; lda #$78
; sta FRAMEBUFFER+11
; lda #$9A
; sta FRAMEBUFFER+12
2018-10-08 02:59:56 +00:00
;=============================
; Load graphic page1 $800
lda #4
sta DRAW_PAGE
lda #$22
jsr clear_gr
2018-10-08 02:59:56 +00:00
;=============================
; Load graphic page2 $c00
2018-10-07 21:43:13 +00:00
lda #8
sta DRAW_PAGE
lda #$00
2018-10-07 21:43:13 +00:00
jsr clear_gr
2018-10-08 02:59:56 +00:00
lda #<score_text
sta OUTL
lda #>score_text
sta OUTH
jsr move_and_print
2018-08-02 04:13:40 +00:00
lda #0
sta DRAW_PAGE
; GR part
bit PAGE0
;==============================
; 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
jsr gr_copy_to_current ; 6+ 9292
; now we have 322 left
; GR part
bit LORES ; 4
bit SET_GR ; 4
bit FULLGR ; 4
; 322 - 12 = 310
; - 3 for jmp
; 307
; Try X=9 Y=6 cycles=307
ldy #6 ; 2
sbloopA:ldx #9 ; 2
sbloopB:dex ; 2
bne sbloopB ; 2nt/3
dey ; 2
bne sbloopA ; 2nt/3
jmp sb_begin_loop
.align $100
;================================================
; Spacebars 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
sb_begin_loop:
sb_display_loop:
2018-10-08 04:49:48 +00:00
; 1 2 3
;0123456789012345678901234567890123456789
;LEVEL: 6 LIVES: 2 SCORE: 01978 HI: 02018
2018-10-08 04:49:48 +00:00
; 0-7 = text mode
; 8-87 = hgr
; 88 - 168 = split
; 169 - 191 = gr
; 8 lines of text mode
ldy #8 ; 2
sb_text_loop:
bit SET_TEXT ; 4
lda #29 ; 2
jsr delay_a ; 25+29
dey ; 2
bne sb_text_loop ; 3
;================
; 65
; -1
sb_hgr_loop:
2018-10-08 04:49:48 +00:00
; delay 80*65 = 5200
; 2180
; -2
; +1
; -8
;=========================
2018-10-08 04:49:48 +00:00
; 3011
bit SET_GR ; 4
bit HIRES ; 4
; draw sprite at same time
lda #>ship_forward ; 2
sta INH ; 3
lda #<ship_forward ; 2
sta INL ; 3
jsr put_sprite ; 6
; + 2164
;===========
; 2180
2018-10-08 04:49:48 +00:00
; Try X=59 Y=10 cycles=3011
ldy #10 ; 2
2018-10-08 04:49:48 +00:00
sbloopC:ldx #59 ; 2
sbloopD:dex ; 2
bne sbloopD ; 2nt/3
dey ; 2
bne sbloopC ; 2nt/3
2018-10-07 00:46:06 +00:00
sb_mixed:
lda $0 ;kill 6 cycles (room for rts) ; 2
ldx #9 ; 2
2018-10-08 04:49:48 +00:00
ldy #9 ; 14 ; 126 ; 2
2018-10-07 00:46:06 +00:00
sb_mixed_loop:
lda ss_multiples,x ; 4
sta split_smc+1 ; 4
split_smc:
jsr split_4 ; 6+46
dey ; 2
bne sb_mixed_loop ; 3
; -1
nop ; 2
2018-10-08 04:49:48 +00:00
ldy #9 ; 2
dex ; 2
bne split_smc ; 3
; -1
; need to kill
; -6 from offset
; +1 fall through
; -9 from check
; +1 from other fallthrough
;================
; -13
2018-10-07 00:46:06 +00:00
2018-10-07 20:29:40 +00:00
sb_all_gr:
2018-10-08 04:49:48 +00:00
; 23 lines of this
2018-10-07 00:46:06 +00:00
2018-10-08 04:49:48 +00:00
; 23 * 65 = 1495
2018-10-07 20:29:40 +00:00
; -4
; -13
2018-10-07 20:29:40 +00:00
; =========
2018-10-08 04:49:48 +00:00
; 1478
2018-10-07 20:29:40 +00:00
bit LORES ; 4
2018-10-08 04:49:48 +00:00
; Try X=41 Y=7 cycles=1478
2018-10-07 20:29:40 +00:00
2018-10-08 04:49:48 +00:00
ldy #7 ; 2
sbloopE:ldx #41 ; 2
2018-10-07 20:29:40 +00:00
sbloopF:dex ; 2
bne sbloopF ; 2nt/3
dey ; 2
bne sbloopE ; 2nt/3
2018-10-07 00:46:06 +00:00
;======================================================
; We have 4550 cycles in the vblank, use them wisely
;======================================================
; do_nothing should be 4550
2018-10-08 04:49:48 +00:00
; -3470 draw_framebuffer
2018-10-08 19:49:13 +00:00
; -533 setup framebuffer
2018-10-08 16:20:09 +00:00
; -21 frame count
2018-10-08 01:37:41 +00:00
; -34 keypress
; -1 adjust center mark back
; ===========
2018-10-08 19:49:13 +00:00
; 491
; Try X=11 Y=8 cycles=489 R2
2018-10-08 19:33:47 +00:00
; Try X=8 Y=5 cycles=231
2018-10-08 16:00:10 +00:00
2018-10-08 19:49:13 +00:00
nop
2018-10-08 19:33:47 +00:00
2018-10-08 19:49:13 +00:00
ldy #8 ; 2
sbloop1:ldx #11 ; 2
sbloop2:dex ; 2
bne sbloop2 ; 2nt/3
dey ; 2
bne sbloop1 ; 2nt/3
2018-10-08 19:49:13 +00:00
jsr setup_framebuffer ; 6+527
2018-10-08 16:00:10 +00:00
2018-10-08 04:49:48 +00:00
jsr draw_framebuffer ; 6+3464
2018-10-08 02:59:56 +00:00
2018-10-08 16:20:09 +00:00
; Increment frame count
; noflo: 16 + 2 + (3) = 21
; oflo: 16 + 5 = 21
inc FRAME ; 5
lda FRAME ; 3
and #3 ; 15 Hz ; 2
sta FRAME ; 3
beq sb_frame_oflo ; 3
;============
; 16
; -1
lda $0 ; nop ; 3
jmp sb_frame_noflo ; 3
sb_frame_oflo:
inc FRAMEH ; 5
sb_frame_noflo:
2018-10-08 01:37:41 +00:00
; no keypress = 10+(24) = 34
; left pressed = 9+8+12+(5)= 34
; right pressed = 9+8+5+12 = 34
lda KEYPRESS ; 4
bpl sb_no_keypress ; 3
2018-10-08 01:37:41 +00:00
; -1
jmp sb_handle_keypress ; 3
sb_no_keypress:
2018-10-08 01:37:41 +00:00
inc $0 ; 5
dec $0 ; 5
inc $0 ; 5
dec $0 ; 5
nop ; 2
nop ; 2
jmp sb_display_loop ; 3
2018-08-02 04:13:40 +00:00
2018-10-08 01:37:41 +00:00
sb_handle_keypress:
bit KEYRESET ; clear keypress ; 4
2019-06-14 01:37:01 +00:00
cmp #27|$80 ; escape ; 2
2018-10-08 01:37:41 +00:00
beq sb_exit ; 3
; -1
sb_check_left:
2018-10-08 02:59:56 +00:00
cmp #$08|$80 ; left ; 2
2018-10-08 01:37:41 +00:00
bne sb_check_right ; 3
; -1
dec XPOS ; 5
nop ; nop ; 2
lda $0 ; nop ; 3
jmp sb_display_loop ; 3
sb_check_right:
2018-10-08 02:59:56 +00:00
cmp #$15|$80 ; 2
2019-06-14 01:37:01 +00:00
bne sb_unknown ; 3
2018-10-08 01:37:41 +00:00
; -1
inc XPOS ; 5
jmp sb_display_loop ; 3
2019-06-14 01:37:01 +00:00
sb_unknown:
nop
nop
jmp sb_display_loop ; 3
2018-10-08 01:37:41 +00:00
sb_exit:
rts ; 6
2018-08-02 04:13:40 +00:00
2018-10-08 02:59:56 +00:00
.align $100
2018-10-08 03:45:37 +00:00
; total =
2018-10-08 04:49:48 +00:00
; 4 wide: = 53
2018-10-08 04:00:18 +00:00
; 12 wide: = 253
; 20 wide: = 421
2018-10-08 04:49:48 +00:00
; 28 wide: = 813
2018-10-08 03:45:37 +00:00
; 36 wide: = 757
2018-10-08 04:00:18 +00:00
; 40 wide: = 1161
; 6
2018-10-08 03:45:37 +00:00
;====================================
2018-10-08 04:49:48 +00:00
; 3464
2018-10-08 02:59:56 +00:00
draw_framebuffer:
2018-10-08 04:00:18 +00:00
; 2 + (4*(X*8)+5) -1 =
2018-10-08 04:49:48 +00:00
; 2 + 4*(8+5) -1 = 85
2018-10-08 03:45:37 +00:00
2018-10-08 04:00:18 +00:00
ldx #4 ; 2
fb4_loop:
lda FRAMEBUFFER+0 ; 3
sta $5a8+18-1,x ; 5
dex ; 2
bne fb4_loop ; 3
; 2 + (12*(X*8)+5) -1 =
; 2 + 12*(16+5) -1 = 253
ldx #12 ; 2
fb12_loop:
2018-10-08 04:49:48 +00:00
lda FRAMEBUFFER+1 ; 3
sta $628+14-1,x ; 5
2018-10-08 03:45:37 +00:00
lda FRAMEBUFFER+2 ; 3
2018-10-08 04:00:18 +00:00
sta $6a8+14-1,x ; 5
2018-10-08 03:45:37 +00:00
dex ; 2
2018-10-08 04:00:18 +00:00
bne fb12_loop ; 3
2018-10-08 03:45:37 +00:00
2018-10-08 04:00:18 +00:00
; 2 + (20*(X*8)+5) -1 =
; 2 + 20*(16+5) -1 = 421
2018-10-08 03:45:37 +00:00
2018-10-08 04:00:18 +00:00
ldx #20 ; 2
fb20_loop:
2018-10-08 04:49:48 +00:00
lda FRAMEBUFFER+3 ; 3
sta $728+10-1,x ; 5
2018-10-08 03:45:37 +00:00
lda FRAMEBUFFER+4 ; 3
2018-10-08 04:00:18 +00:00
sta $7a8+10-1,x ; 5
2018-10-08 03:45:37 +00:00
dex ; 2
2018-10-08 04:00:18 +00:00
bne fb20_loop ; 3
2018-10-08 03:45:37 +00:00
2018-10-08 04:00:18 +00:00
; 2 + (28*(X*8)+5) -1 =
2018-10-08 04:49:48 +00:00
; 2 + 28*(24+5) -1 = 813
2018-10-08 03:45:37 +00:00
2018-10-08 04:00:18 +00:00
ldx #28 ; 2
fb28_loop:
2018-10-08 04:49:48 +00:00
lda FRAMEBUFFER+5 ; 3
sta $450+6-1,x ; 5
2018-10-08 03:45:37 +00:00
lda FRAMEBUFFER+6 ; 3
2018-10-08 04:00:18 +00:00
sta $4d0+6-1,x ; 5
2018-10-08 03:45:37 +00:00
lda FRAMEBUFFER+7 ; 3
2018-10-08 04:00:18 +00:00
sta $550+6-1,x ; 5
2018-10-08 03:45:37 +00:00
dex ; 2
2018-10-08 04:00:18 +00:00
bne fb28_loop ; 3
2018-10-08 03:45:37 +00:00
; 2 + (36*(X*8)+5) -1 =
; 2 + 36*(16+5) -1 = 757
ldx #36 ; 2
fb36_loop:
lda FRAMEBUFFER+8 ; 3
sta $5d0+2-1,x ; 5
lda FRAMEBUFFER+9 ; 3
sta $650+2-1,x ; 5
dex ; 2
bne fb36_loop ; 3
2018-10-08 04:00:18 +00:00
; 2 + (40*(X*8)+5) -1 =
; 2 + 40*(24+5) + -1 = 1161
2018-10-08 03:45:37 +00:00
2018-10-08 02:59:56 +00:00
ldx #40 ; 2
2018-10-08 03:45:37 +00:00
fb40_loop:
lda FRAMEBUFFER+10 ; 3
sta $6d0-1,x ; 5
2018-10-08 02:59:56 +00:00
lda FRAMEBUFFER+11 ; 3
sta $750-1,x ; 5
lda FRAMEBUFFER+12 ; 3
sta $7d0-1,x ; 5
dex ; 2
2018-10-08 03:45:37 +00:00
bne fb40_loop ; 3
2018-10-08 02:59:56 +00:00
; -1
rts ; 6
2018-10-07 20:29:40 +00:00
.align $100
.include "screen_split.s"
;.include "deater.inc"
background_hgr:
.incbin "SB_BACKGROUNDC.BIN.lz4",11
background_hgr_end:
2018-08-02 04:13:40 +00:00
2018-10-08 02:59:56 +00:00
score_text:
.byte 0,0
.asciiz "LEVEL:6 LIVES:2 SCORE:001978 HI:002018"
2018-10-08 16:00:10 +00:00
; Note on the distance calculations
; we use something simplistic here
; see http://www.extentofthejam.com/pseudo/
; "Texture": 64?
; 0 GREY 5,7,f,7,5,0,0,0
; 1 0,0,0,0,0,0,0,0
; 2 BLUE 2,6,f,6,2,0,0,0
; 3 0,0,0,0,0,0,0,0
; 4 GREEN 4,c,f,c,4,0,0,0
; 5 0,0,0,0,0,0,0,0
; 6 RED 1,b,f,b,1,0,0,0
; 7 0,0,0,0,0,0,0,0
.align 64
raster_texture:
2018-10-08 16:35:48 +00:00
.byte $5,$7,$f,$7,$5,$0,$0,$0 ; grey
2018-10-08 16:00:10 +00:00
.byte $0,$0,$0,$0,$0,$0,$0,$0
2018-10-08 16:35:48 +00:00
.byte $2,$6,$f,$6,$2,$0,$0,$0 ; blue
2018-10-08 16:00:10 +00:00
.byte $0,$0,$0,$0,$0,$0,$0,$0
2018-10-08 16:35:48 +00:00
.byte $4,$c,$f,$c,$4,$0,$0,$0 ; green
2018-10-08 16:00:10 +00:00
.byte $0,$0,$0,$0,$0,$0,$0,$0
2018-10-08 16:35:48 +00:00
.byte $1,$b,$f,$b,$1,$0,$0,$0 ; red
.byte $0,$0,$0,$0,$0,$0,$0,$0,$0
2018-10-08 16:00:10 +00:00
2018-10-08 19:33:47 +00:00
offset_lookup:
; Linear
; .byte 26,24,22,20,18,16,14,12,10, 8, 6, 4, 2,0
2018-10-08 19:49:13 +00:00
.byte 29,24,20,16,13,10,8,6,4,3,2,1,0,0
2018-10-08 16:00:10 +00:00
2018-10-08 19:33:47 +00:00
.align $100
2018-10-08 16:00:10 +00:00
2018-10-08 19:49:13 +00:00
; 2 + 40*13 + 5 = 527
2018-10-08 16:00:10 +00:00
setup_framebuffer:
ldx #0 ; 2
setup_fb_loop:
2018-10-08 19:33:47 +00:00
lda offset_lookup,X ; 4
clc ; 2
adc FRAMEH ; 3
2018-10-08 16:35:48 +00:00
and #$3f ; 2
tay ; 2
lda raster_texture,y ; 4
2018-10-08 16:20:09 +00:00
asl ; 2
asl ; 2
asl ; 2
asl ; 2
2018-10-08 19:49:13 +00:00
;============
; 25
2018-10-08 19:33:47 +00:00
2018-10-08 19:49:13 +00:00
ora raster_texture+1,y ; 4
2018-10-08 19:33:47 +00:00
2018-10-08 16:20:09 +00:00
sta FRAMEBUFFER,x ; zp ; 4
2018-10-08 16:00:10 +00:00
inx ; 2
2018-10-08 16:20:09 +00:00
cpx #13 ; 2
2018-10-08 16:00:10 +00:00
bne setup_fb_loop ; 3
;===========
2018-10-08 19:49:13 +00:00
; 15
2018-10-08 16:00:10 +00:00
; -1
rts ; 6