From 620e3e75ba0153c6afedddc0fd6123f50f256bb5 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 17 Sep 2023 21:24:41 -0400 Subject: [PATCH] second: more work on animation --- demos/second/gr_pageflip.s | 4 +- demos/second/hardware.inc | 8 ++-- demos/second/part18_3d/3d.inc | 73 +++++++++++++++++++++++++++-- demos/second/part18_3d/draw_boxes.s | 63 ++++++++++++++++++++++++- demos/second/part18_3d/threed.s | 20 +++++++- demos/second/roto.s | 2 +- demos/second/second.s | 4 +- 7 files changed, 159 insertions(+), 15 deletions(-) diff --git a/demos/second/gr_pageflip.s b/demos/second/gr_pageflip.s index f199f5be..742052cb 100644 --- a/demos/second/gr_pageflip.s +++ b/demos/second/gr_pageflip.s @@ -6,14 +6,14 @@ page_flip: lda DISP_PAGE ; 3 beq page_flip_show_1 ; 2nt/3 page_flip_show_0: - bit PAGE0 ; 4 + bit PAGE1 ; 4 lda #4 ; 2 sta DRAW_PAGE ; DRAW_PAGE=1 ; 3 lda #0 ; 2 sta DISP_PAGE ; DISP_PAGE=0 ; 3 rts ; 6 page_flip_show_1: - bit PAGE1 ; 4 + bit PAGE2 ; 4 sta DRAW_PAGE ; DRAW_PAGE=0 ; 3 lda #1 ; 2 sta DISP_PAGE ; DISP_PAGE=1 ; 3 diff --git a/demos/second/hardware.inc b/demos/second/hardware.inc index 0d1cfc38..c420c4a5 100644 --- a/demos/second/hardware.inc +++ b/demos/second/hardware.inc @@ -4,8 +4,8 @@ KEYPRESS = $C000 KEYRESET = $C010 ;; SOFT SWITCHES -CLR80COL = $C000 ; PAGE0/PAGE1 normal -SET80COL = $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead +CLR80COL = $C000 ; PAGE1/PAGE1 normal +SET80COL = $C001 ; PAGE1/PAGE2 switches PAGE1 in Aux instead EIGHTYCOLOFF = $C00C EIGHTYCOLON = $C00D TBCOLOR = $C022 ; IIgs fg/bg colors @@ -16,8 +16,8 @@ SET_GR = $C050 SET_TEXT = $C051 FULLGR = $C052 TEXTGR = $C053 -PAGE0 = $C054 -PAGE1 = $C055 +PAGE1 = $C054 +PAGE2 = $C055 LORES = $C056 ; Enable LORES graphics HIRES = $C057 ; Enable HIRES graphics AN3 = $C05E ; Annunciator 3 diff --git a/demos/second/part18_3d/3d.inc b/demos/second/part18_3d/3d.inc index f5f467fc..bdad503a 100644 --- a/demos/second/part18_3d/3d.inc +++ b/demos/second/part18_3d/3d.inc @@ -8,7 +8,7 @@ ; BOX x1,y1 to x2,y2 ; CLEAR - -num_scenes=2 +num_scenes=5 frame15: .byte SET_COLOR | BLACK @@ -35,5 +35,72 @@ frame16: .byte HLIN, 28, 33, 22 .byte HLIN, 28, 30, 23 .byte END - - +frame17: + .byte SET_COLOR | BLACK ; 1 + .byte CLEAR ; 2 + .byte SET_COLOR | WHITE ; 3 + .byte BOX, 4, 6, 23,41 ; 8 + .byte SET_COLOR | BROWN ; 9 + .byte BOX, 24, 6, 35,36 ; 14 + .byte SET_COLOR | GREY1 ; 15 + .byte BOX, 26, 20, 32, 21 ; 20 + .byte BOX, 24, 36, 30, 40 ; 25 + .byte BOX, 29, 37, 35, 41 ; 30 + .byte HLIN, 27, 31, 19 ; 34 + .byte SET_COLOR | RED ; 35 + .byte HLIN, 26, 32, 22 ; 39 + .byte SET_COLOR | MEDIUM_BLUE ; 40 + .byte BOX, 33, 11, 35, 17 ; 45 + .byte BOX, 33, 25, 35, 30 ; 50 + .byte SET_COLOR | LIGHT_BLUE ; 51 + .byte HLIN, 26, 32, 23 ; 55 + .byte HLIN, 27, 31, 24 ; 59 + .byte END ; 60 +frame18: + .byte SET_COLOR | BLACK + .byte CLEAR + .byte SET_COLOR | WHITE + .byte BOX, 4, 6, 18,41 + .byte SET_COLOR | BROWN + .byte BOX, 19, 6, 35,38 + .byte SET_COLOR | GREY1 + .byte BOX, 27, 21, 34, 23 + .byte BOX, 19, 39, 35, 41 + .byte HLIN, 28, 31, 20 + .byte HLIN, 19, 23, 37 + .byte HLIN, 19, 28, 38 + .byte SET_COLOR | RED + .byte HLIN, 27, 34, 24 + .byte SET_COLOR | MEDIUM_BLUE + .byte BOX, 29, 11, 32, 18 + .byte BOX, 29, 27, 32, 32 + .byte SET_COLOR | LIGHT_BLUE + .byte HLIN, 27, 34, 25 + .byte HLIN, 28, 33, 26 + .byte END +frame19: + .byte SET_COLOR | BLACK + .byte CLEAR + .byte SET_COLOR | WHITE + .byte BOX, 4, 6, 12,41 + .byte SET_COLOR | BROWN + .byte BOX, 13, 6, 35,40 + .byte SET_COLOR | MEDIUM_BLUE + .byte BOX, 25, 11, 28, 18 + .byte BOX, 33, 11, 35, 18 + .byte BOX, 25, 26, 28, 32 + .byte BOX, 33, 29, 35, 33 + .byte SET_COLOR | GREY1 + .byte BOX, 29, 21, 35, 24 + .byte HLIN, 29, 34, 20 + .byte HLIN, 13, 18, 38 + .byte HLIN, 13, 25, 39 + .byte HLIN, 13, 35, 41 + .byte SET_COLOR | RED + .byte HLIN, 29, 35, 25 + .byte SET_COLOR | LIGHT_BLUE + .byte HLIN, 28, 35, 26 + .byte HLIN, 29, 35, 27 + .byte HLIN, 30, 35, 38 + .byte VLIN, 21, 26, 28 + .byte END diff --git a/demos/second/part18_3d/draw_boxes.s b/demos/second/part18_3d/draw_boxes.s index b7b17057..50747685 100644 --- a/demos/second/part18_3d/draw_boxes.s +++ b/demos/second/part18_3d/draw_boxes.s @@ -91,9 +91,10 @@ update_pointer: draw_table_l: .byte <(clear_screen-1),<(draw_box-1),<(draw_hlin-1),<(draw_vlin-1) + .byte <(draw_plot-1) draw_table_h: .byte >(clear_screen-1),>(draw_box-1),>(draw_hlin-1),>(draw_vlin-1) - + .byte >(draw_plot-1) ;================================= ;================================= @@ -153,7 +154,7 @@ draw_box_xloop_smc: iny draw_box_yend_smc: cpy #0 - bne draw_box_yloop + bcc draw_box_yloop ; done @@ -167,6 +168,39 @@ draw_box_yend_smc: ;================================= ;================================= draw_hlin: + + iny ; FIXME: move to common code + lda (INL),Y + sta X1 + iny + lda (INL),Y + sta X2 + iny + lda (INL),Y + sta Y1 + + + lda Y1 + lsr + tay + + lda gr_offsets_l,Y + sta draw_hlin_xloop_smc+1 + + lda gr_offsets_h,Y + clc + adc DRAW_PAGE + sta draw_hlin_xloop_smc+2 + + lda COLOR + ldx X2 +draw_hlin_xloop: +draw_hlin_xloop_smc: + sta $400,X + dex + cpx X1 + bcs draw_hlin_xloop ; bge + ; done lda #4 @@ -184,6 +218,31 @@ draw_vlin: jmp update_pointer + ;================================= + ;================================= + ; draw plot + ;================================= + ;================================= +draw_plot: + iny + lda (INL),Y + tax + + iny + lda (INL),Y + tay + +draw_plot_smc: + sta $400 + + + ; done + + lda #3 + jmp update_pointer + + + .include "gr_fast_clear.s" diff --git a/demos/second/part18_3d/threed.s b/demos/second/part18_3d/threed.s index bcc87e25..5adacc38 100644 --- a/demos/second/part18_3d/threed.s +++ b/demos/second/part18_3d/threed.s @@ -31,7 +31,7 @@ load_loop: bit SET_GR bit LORES bit FULLGR - bit PAGE0 + bit PAGE1 lda #0 sta DRAW_PAGE @@ -50,8 +50,26 @@ forever: scene_loop: jsr draw_scene + ;============================ + ; flip pages + ;============================ + lda DRAW_PAGE ; 3 + beq was_page1 ; 2/3 +was_page2: + bit PAGE2 ; 4 + lda #$0 ; 2 + beq done_pageflip ; 2/3 +was_page1: + bit PAGE1 ; 4 + lda #$4 ; 2 +done_pageflip: + sta DRAW_PAGE ; 3 + + jsr wait_until_keypress + + dec SCENE_COUNT bne scene_loop diff --git a/demos/second/roto.s b/demos/second/roto.s index 4e3626b5..f12a88bf 100644 --- a/demos/second/roto.s +++ b/demos/second/roto.s @@ -5,7 +5,7 @@ do_rotozoom: ; Clear screen and setup graphics ;================================ - bit PAGE0 ; set page 0 + bit PAGE1 ; set page 1 bit LORES ; Lo-res graphics lda #0 diff --git a/demos/second/second.s b/demos/second/second.s index ef7da186..d23000d5 100644 --- a/demos/second/second.s +++ b/demos/second/second.s @@ -232,7 +232,7 @@ load_loop: bit SET_GR bit HIRES bit FULLGR - bit PAGE0 + bit PAGE1 ;======================= ; start music @@ -287,7 +287,7 @@ load_loop: bit HIRES bit FULLGR - bit PAGE0 + bit PAGE1 ;================================