dos33fsprogs/demos/second/part04_chess_shapes/chess.s

519 lines
7.6 KiB
ArmAsm
Raw Normal View History

2023-10-29 04:51:28 +00:00
; Chess board, polyhedrons, circles, interference
2023-10-30 05:11:21 +00:00
; o/~ One night in Bangkok makes a hard man humble... o/~
2023-10-29 04:51:28 +00:00
;
; by deater (Vince Weaver) <vince@deater.net>
.include "../zp.inc"
.include "../hardware.inc"
.include "../qload.inc"
2023-11-01 04:36:34 +00:00
.include "../music.inc"
2023-10-29 04:51:28 +00:00
mod7_table = $1c00
div7_table = $1d00
hposn_low = $1e00
hposn_high = $1f00
chess_start:
;=====================
; initializations
;=====================
2023-11-01 04:36:34 +00:00
; some of this not necessary as we come in in HGR
2023-10-29 04:51:28 +00:00
bit SET_GR
bit HIRES
bit FULLGR
bit PAGE1
2023-11-01 04:36:34 +00:00
bit KEYRESET
2023-10-29 04:51:28 +00:00
2023-10-30 05:11:21 +00:00
lda #$00
2023-10-29 04:51:28 +00:00
jsr hgr_page2_clearscreen
2023-11-01 04:36:34 +00:00
;===================
; Load graphics
;===================
;=============================
; load chessboard image offscreen $6000
;=============================
lda #<chess_data
sta zx_src_l+1
lda #>chess_data
sta zx_src_h+1
lda #$60
jsr zx02_full_decomp
2023-11-01 04:36:34 +00:00
; wait until pattern1
2023-11-01 05:04:28 +00:00
pattern2_loop:
lda #2
jsr wait_for_pattern
bcc pattern2_loop
2023-11-01 04:36:34 +00:00
; technically the above, but we're not fast enough
2023-11-01 05:04:28 +00:00
; lda #175
; jsr wait_ticks
2023-11-01 04:36:34 +00:00
; lda #$FF
; jsr hgr_page1_clearscreen
2023-10-30 05:11:21 +00:00
;==========================
; Falling board animation
;==========================
; TODO
; 148-192 = full = 44
; 0 frames in = 0 high, bottom=125+13 Y=125
; 4 frames in, 130-138 = 8 high bottom=138+17 Y=130
; 8 frames in, from 135-155 = 20 bottom=155+25 Y=135
;12 frames in, from 145-180 = 35 bottom=180 Y=145
; first collapse down, top to 125 bottom up to 133
; so 125 whie other 60
ldx #0
lda #191
sta COUNT
compact_loop:
txa
lsr
bcc compact_not_even
stx SAVEX
ldx COUNT
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
lda #0
ldy #39
compact_inner_loop2:
sta (GBASL),Y
dey
bpl compact_inner_loop2
dec COUNT
ldx SAVEX
compact_not_even:
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
lda #0
ldy #39
compact_inner_loop:
sta (GBASL),Y
dey
bpl compact_inner_loop
2023-11-01 04:36:34 +00:00
lda #30
2023-10-30 05:11:21 +00:00
jsr wait
inx
cpx #122
bne compact_loop
;=============================
; dropping board
;=============================
ldx #0
stx BOARD_COUNT
drop_board_loop:
jsr hgr_clear_screen
ldx BOARD_COUNT
lda board_y,X
sta HGR_DEST
2023-10-30 05:11:21 +00:00
lda board_starty,X
sta HGR_Y1
lda #0
sta HGR_X1
lda #40
sta HGR_X2
lda #192
sta HGR_Y2
jsr hgr_partial
jsr hgr_page_flip
; jsr wait_until_keypress
lda #10
jsr wait_ticks
inc BOARD_COUNT
lda BOARD_COUNT
cmp #7
bne drop_board_loop
2023-10-30 05:11:21 +00:00
;=============================
; Bouncing on board animation
;=============================
2023-11-01 04:36:34 +00:00
lda #10
jsr setup_timeout
2023-10-29 04:51:28 +00:00
bit PAGE2
lda #0
sta COUNT
sta DRAW_PAGE
2023-10-30 05:11:21 +00:00
chess_bounce_loop:
2023-10-29 04:51:28 +00:00
2023-10-30 00:27:56 +00:00
lda #$60 ; copy to screen
2023-10-29 04:51:28 +00:00
jsr hgr_copy
2023-10-30 05:11:21 +00:00
ldx COUNT
lda bounce_coords_x,X
2023-10-30 05:11:21 +00:00
sta SPRITE_X
lda bounce_coords_y,X
2023-10-30 05:11:21 +00:00
sta SPRITE_Y
cmp #100
bcs do_squashed
2023-10-29 04:51:28 +00:00
2023-10-30 05:11:21 +00:00
lda #<object_data
sta INL
lda #>object_data
jmp done_pick_object
do_squashed:
lda #<squished
sta INL
lda #>squished
done_pick_object:
2023-10-30 05:11:21 +00:00
sta INH
2023-10-29 04:51:28 +00:00
2023-10-30 05:11:21 +00:00
jsr hgr_draw_sprite_big
jsr hgr_page_flip
inc COUNT
lda COUNT
cmp #36
2023-10-30 05:11:21 +00:00
bne no_chess_bounce_oflo
lda #0
sta COUNT
no_chess_bounce_oflo:
2023-11-01 04:36:34 +00:00
jsr check_timeout
bcc chess_bounce_loop ; clear if not timed out
done_chess_bounce_loop:
2023-10-30 05:11:21 +00:00
;=============================
; Orange Blob Animation
;=============================
2023-10-30 00:27:56 +00:00
; load image offscreen $6000
lda #<orange_data
sta zx_src_l+1
lda #>orange_data
sta zx_src_h+1
lda #$60
jsr zx02_full_decomp
ldx #0
stx COUNT
orange_loop:
lda #$60 ; copy to screen
jsr hgr_copy
ldx COUNT
lda object_coords_x,X
2023-11-01 04:36:34 +00:00
; cmp #$FF ; needed?
; beq done_orange_loop
2023-10-30 00:27:56 +00:00
sta SPRITE_X
lda object_coords_y,X
sta SPRITE_Y
lda #<object_data
sta INL
lda #>object_data
sta INH
jsr hgr_draw_sprite_big
jsr hgr_page_flip
inc COUNT
lda COUNT
cmp #48
bne no_orange_oflo
lda #0
sta COUNT
no_orange_oflo:
2023-11-01 04:36:34 +00:00
; finish at music pattern #10 or keypress
lda #10
jsr wait_for_pattern
bcc orange_loop
2023-10-30 00:27:56 +00:00
2023-11-01 04:36:34 +00:00
; lda KEYPRESS
; bpl orange_loop
;done_orange_loop:
; bit KEYRESET
2023-10-30 00:27:56 +00:00
2023-10-29 04:51:28 +00:00
chess_done:
2023-10-29 23:00:59 +00:00
2023-10-30 00:27:56 +00:00
2023-10-29 23:00:59 +00:00
;==================
;==================
;==================
; DO TUNNEL HERE
;==================
;==================
;==================
2023-10-30 00:27:56 +00:00
; load image $2000
lda #<tunnel1_data
sta zx_src_l+1
lda #>tunnel1_data
sta zx_src_h+1
lda #$20
jsr zx02_full_decomp
; load image $4000
lda #<tunnel2_data
sta zx_src_l+1
lda #>tunnel2_data
sta zx_src_h+1
lda #$40
jsr zx02_full_decomp
tunnel_loop:
bit PAGE1
lda #8
jsr wait_irq
bit PAGE2
lda #8
jsr wait_irq
2023-11-01 05:04:28 +00:00
; finish at music pattern #13 or keypress
lda #13
jsr wait_for_pattern
bcc tunnel_loop
2023-10-30 00:27:56 +00:00
2023-10-29 23:00:59 +00:00
main_tunnel_done:
2023-10-31 21:05:14 +00:00
;==================
;==================
;==================
; DO circles HERE
;==================
;==================
;==================
jsr zooming_circles
2023-11-01 05:04:28 +00:00
lda #$ff
sta clear_all_color+1
jsr clear_all
2023-10-31 21:05:14 +00:00
; todo, fade to white
2023-10-29 23:00:59 +00:00
;==================
;==================
;==================
; DO INTERFERENCE #1 HERE
2023-10-29 23:00:59 +00:00
;==================
;==================
;==================
2023-11-01 05:04:28 +00:00
; first until pattern 18
2023-10-31 21:05:14 +00:00
2023-11-01 05:04:28 +00:00
lda #18
sta interference_end_smc+1
2023-10-29 23:00:59 +00:00
jsr interference
;======================
2023-11-01 05:04:28 +00:00
; TODO: falling bars
;======================
lda #0
sta DRAW_PAGE
bit PAGE1
2023-11-01 05:04:28 +00:00
jsr clear_all
; left
lda #$FF
sta BAR_X1
lda #13
sta BAR_X2
jsr falling_bars
lda #15
jsr wait_ticks
; middle
lda #13
sta BAR_X1
2023-11-03 01:41:51 +00:00
lda #26
sta BAR_X2
jsr falling_bars
lda #15
jsr wait_ticks
; right
2023-11-03 01:41:51 +00:00
lda #26
sta BAR_X1
lda #39
sta BAR_X2
jsr falling_bars
lda #15
2023-11-01 05:04:28 +00:00
jsr wait_ticks
;==================
;==================
;==================
; DO INTERFERENCE #2 HERE
;==================
;==================
;==================
2023-11-01 05:04:28 +00:00
; again until pattern 25
; lda #25
; sta interference_end_smc+1
; jsr interference
2023-10-29 23:00:59 +00:00
jsr sier_zoom
2023-10-29 23:00:59 +00:00
2023-11-01 05:04:28 +00:00
main_interference_done:
2023-10-29 23:00:59 +00:00
2023-10-29 04:51:28 +00:00
rts
;.align $100
.include "../wait_keypress.s"
; .include "../zx02_optim.s"
2023-10-29 04:51:28 +00:00
; .include "../hgr_table.s"
.include "../hgr_clear_screen.s"
.include "../hgr_copy_fast.s"
2023-10-30 00:27:56 +00:00
.include "../hgr_sprite_big.s"
2023-11-01 04:36:34 +00:00
.include "../irq_wait.s"
2023-10-29 04:51:28 +00:00
2023-10-29 23:00:59 +00:00
.include "interference.s"
2023-10-31 21:05:14 +00:00
.include "circles.s"
.include "sierzoom.s"
2023-10-30 00:27:56 +00:00
.include "../hgr_page_flip.s"
.include "falling_bars.s"
.include "hgr_partial.s"
2023-10-29 04:51:28 +00:00
; wait A * 1/50s
wait_irq:
; lda #50
sta IRQ_COUNTDOWN
wait_irq_loop:
lda IRQ_COUNTDOWN
bne wait_irq_loop
rts
chess_data:
2023-10-30 05:11:21 +00:00
.incbin "graphics/chessboard.hgr.zx02"
2023-10-30 00:27:56 +00:00
orange_data:
.incbin "graphics/orange_bg.hgr.zx02"
object_data:
.include "graphics/object.inc"
tunnel1_data:
.incbin "graphics/tunnel1_cropped.hgr.zx02"
tunnel2_data:
.incbin "graphics/tunnel2_cropped.hgr.zx02"
; object is roughly 15 wide?
2023-10-30 00:27:56 +00:00
; this is a triangle pattern
; we could reverse at some point
; 12*4 = 48
object_coords_x:
.byte 13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12
.byte 13,14,15,16,17,18,19,20,21,22,23,24
.byte 25,24,23,22,21,20,19,18,17,16,15,14
object_coords_y:
.byte 5,10,16,23,30,36,43,49,55,62,68,75
.byte 82,82,82,82,82,82,82,82,82,82,82,82
.byte 82,82,82,82,82,82,82,82,82,82,82,82
.byte 75,68,62,55,49,43,36,30,23,16,10, 5
2023-10-29 04:51:28 +00:00
2023-10-30 05:11:21 +00:00
; 9*4=36
2023-10-30 05:11:21 +00:00
bounce_coords_x:
.byte 12, 12, 12, 12, 12, 12, 12, 10, 10
.byte 10, 10, 12, 12, 12, 12, 12, 12, 12
.byte 12, 12, 12, 12, 12, 12, 12, 10, 10
.byte 10, 10, 12, 12, 12, 12, 12, 12, 12
2023-10-30 05:11:21 +00:00
bounce_coords_y:
.byte 4, 20, 35, 45, 60, 70, 82, 102, 115
.byte 115,102, 82, 70, 60, 45, 35, 20, 4
.byte 4, 20, 35, 45, 60, 70, 82, 102, 115
.byte 115,102, 82, 70, 60, 45, 35, 20, 4
; 148-192 = full = 44
; 0 frames in = 0 high, bottom=125+13 Y=125
; 4 frames in, 130-138 = 8 high bottom=138+17 Y=130
; 8 frames in, from 135-155 = 20 bottom=155+25 Y=135
;12 frames in, from 145-180 = 35 bottom=180 Y=145
2023-10-30 05:11:21 +00:00
board_y:
.byte 125,130,135,145,139,145,139
2023-10-30 05:11:21 +00:00
board_starty:
.byte 184,184,172,157,139,157,139