From d4cedf0e7acb5d96ccbc5c9304f3fd04cccec71d Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 3 Nov 2023 17:00:18 -0400 Subject: [PATCH] second: chessboard falling a hack but maybe good enough for now --- demos/second/hgr_clear_screen.s | 5 ++ demos/second/part04_chess_shapes/Makefile | 1 + demos/second/part04_chess_shapes/chess.s | 73 ++++++++++++++++--- .../second/part04_chess_shapes/hgr_partial.s | 46 ++++++++++++ demos/second/zp.inc | 9 ++- 5 files changed, 122 insertions(+), 12 deletions(-) create mode 100644 demos/second/part04_chess_shapes/hgr_partial.s diff --git a/demos/second/hgr_clear_screen.s b/demos/second/hgr_clear_screen.s index 0c854415..aa0805ab 100644 --- a/demos/second/hgr_clear_screen.s +++ b/demos/second/hgr_clear_screen.s @@ -1,3 +1,8 @@ +hgr_clear_screen: + lda DRAW_PAGE + beq hgr_page1_clearscreen + lda #0 + beq hgr_page2_clearscreen hgr_page1_clearscreen: diff --git a/demos/second/part04_chess_shapes/Makefile b/demos/second/part04_chess_shapes/Makefile index efe4ee7a..5cc2aeb3 100644 --- a/demos/second/part04_chess_shapes/Makefile +++ b/demos/second/part04_chess_shapes/Makefile @@ -21,6 +21,7 @@ chess.o: chess.s \ circles.s \ falling_bars.s \ sierzoom.s \ + hgr_partial.s \ ../irq_wait.s \ ../zp.inc ../hardware.inc ../qload.inc \ graphics/chess_object2.hgr.zx02 \ diff --git a/demos/second/part04_chess_shapes/chess.s b/demos/second/part04_chess_shapes/chess.s index 0ca725e9..d413a6cc 100644 --- a/demos/second/part04_chess_shapes/chess.s +++ b/demos/second/part04_chess_shapes/chess.s @@ -35,6 +35,22 @@ chess_start: ; Load graphics ;=================== + + + ;============================= + ; load chessboard image offscreen $6000 + ;============================= + + lda #chess_data + sta zx_src_h+1 + lda #$60 + jsr zx02_full_decomp + + + + ; wait until pattern1 pattern2_loop: lda #2 @@ -118,7 +134,43 @@ compact_inner_loop: 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 + + 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 ;============================= @@ -130,16 +182,6 @@ compact_inner_loop: bit PAGE2 - ; load image offscreen $6000 - - lda #chess_data - sta zx_src_h+1 - lda #$60 - jsr zx02_full_decomp - - lda #0 sta COUNT sta DRAW_PAGE @@ -403,6 +445,7 @@ main_interference_done: .include "sierzoom.s" .include "../hgr_page_flip.s" .include "falling_bars.s" + .include "hgr_partial.s" ; wait A * 1/50s wait_irq: @@ -461,5 +504,15 @@ bounce_coords_y: .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 +board_y: + .byte 125,130,135,145,139,145,139 + +board_starty: + .byte 184,184,172,157,139,157,139 diff --git a/demos/second/part04_chess_shapes/hgr_partial.s b/demos/second/part04_chess_shapes/hgr_partial.s new file mode 100644 index 00000000..54f8fc3d --- /dev/null +++ b/demos/second/part04_chess_shapes/hgr_partial.s @@ -0,0 +1,46 @@ +; copy partial part of screen from $6000 to DRAW_PAGE + ; HGR_X1,HGR_Y1 to HGR_X2,HGR_Y2 source + ; destination = Y at HGR_DEST + +hgr_partial: + lda HGR_DEST + sta dest_y_smc+1 + + ldx HGR_Y1 ; Y1 +hgr_partial_outer_loop: + lda hposn_low,X + sta INL + lda hposn_high,X + ora #$40 ; convert to $6000 + sta INH + + txa + pha + +dest_y_smc: + ldx #100 ; DEST_Y + lda hposn_low,X + sta OUTL + lda hposn_high,X + clc + adc DRAW_PAGE + sta OUTH + + pla + tax + + ldy HGR_X1 ; X1 +hgr_partial_inner_loop: + lda (INL),Y + sta (OUTL),Y + iny + cpy HGR_X2 ; X2 + bne hgr_partial_inner_loop + + inc dest_y_smc+1 + + inx + cpx HGR_Y2 ; Y2 + bne hgr_partial_outer_loop + + rts diff --git a/demos/second/zp.inc b/demos/second/zp.inc index 65631fa5..9c88fc81 100644 --- a/demos/second/zp.inc +++ b/demos/second/zp.inc @@ -95,8 +95,14 @@ TOTAL_RAM = $8F ;============================= ;============================= -; $D0-$DA = ? +; $D0-$D9 = hgr move ;============================= +HGR_X1 = $D0 +HGR_X2 = $D1 +HGR_Y1 = $D2 +HGR_Y2 = $D3 +HGR_DEST= $D4 +BOARD_COUNT = $D5 WHICH_SLOT = $DA ; from boot sector @@ -176,7 +182,6 @@ Y2 = $F7 SCENE_COUNT = $F8 LAST_TYPE = $F9 - ; lens LENS_X = $F0 LENS_Y = $F1