From bbed9e6a954027c918eda13197cab5ffd2e5b794 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 28 Sep 2022 14:34:13 -0400 Subject: [PATCH] hgr: sier: not able to speed up --- graphics/hgr/parallax/sier.s | 28 ++--- graphics/hgr/parallax/super_sier.s | 179 +++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+), 19 deletions(-) create mode 100644 graphics/hgr/parallax/super_sier.s diff --git a/graphics/hgr/parallax/sier.s b/graphics/hgr/parallax/sier.s index d3b09472..3606086a 100644 --- a/graphics/hgr/parallax/sier.s +++ b/graphics/hgr/parallax/sier.s @@ -13,8 +13,6 @@ ; Zero Page GBASL = $26 GBASH = $27 -H2 = $2C -COLOR = $30 HGR_X = $E0 HGR_Y = $E2 @@ -22,14 +20,8 @@ HGR_COLOR = $E4 HGR_HORIZ = $E5 HGR_PAGE = $E6 -FRAME = $F0 -FRAME2 = $F1 -FRAME4 = $F2 - -X2 = $FB -COLORS = $FC - ; Soft Switches + PAGE1 = $C054 ; Page1 PAGE2 = $C055 ; Page2 @@ -39,22 +31,22 @@ PAGE2 = $C055 ; Page2 HGR = $F3E2 HGR2 = $F3D8 HCLR = $F3F2 -HPLOT0 = $F457 ;; plot at (Y,X), (A) -WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us -HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y) +HPLOT0 = $F457 ; plot at (Y,X), (A) +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us +HPOSN = $F411 ; (Y,X),(A) (valued stores in HGRX,XH,Y) hgr_lookup_h = $1000 hgr_lookup_l = $1100 div4_lookup = $90 - parallax: ;=================== ; init screen - jsr HGR - jsr HGR2 + + jsr HGR ; clear PAGE1 + jsr HGR2 ; clear PAGE2 ;=================== ; int tables @@ -154,8 +146,8 @@ medium_smc: adc #$DD ; go other way ; 2 and div4_lookup,X ; sierpinski ; 4 - bne draw_black ; draw black ; 2/3 + bne draw_black ; draw black ; 2/3 draw_purple: lda #$55 ; purple/green ; 2 bne draw_color ; bra ; 3 @@ -181,6 +173,4 @@ out_smc: cpy #32 ; 2 bne yloop ; 2/3 - beq parallax_forever ; 2/3 - - + beq parallax_forever ; bra ; 3 diff --git a/graphics/hgr/parallax/super_sier.s b/graphics/hgr/parallax/super_sier.s new file mode 100644 index 00000000..2e812cdc --- /dev/null +++ b/graphics/hgr/parallax/super_sier.s @@ -0,0 +1,179 @@ +; Parallax Sierpinski/xor boxes HGR + +; by deater (Vince Weaver) + +; Already heavily optimized: + +; only 128 lines +; frame 0: 27c78 = 162,936 cycles = roughly 6.1 fps +; full 192 lines +; frame 0: 3bf5f = 245,599 cycles = roughly 4 fps + + +; Zero Page +GBASL = $26 +GBASH = $27 + +HGR_X = $E0 +HGR_Y = $E2 +HGR_COLOR = $E4 +HGR_HORIZ = $E5 +HGR_PAGE = $E6 + +; Soft Switches + +PAGE1 = $C054 ; Page1 +PAGE2 = $C055 ; Page2 + + +; ROM routines + +HGR = $F3E2 +HGR2 = $F3D8 +HCLR = $F3F2 +HPLOT0 = $F457 ; plot at (Y,X), (A) +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us +HPOSN = $F411 ; (Y,X),(A) (valued stores in HGRX,XH,Y) + + +hgr_lookup_h = $1000 +hgr_lookup_l = $1100 +div4_lookup = $90 +color_lookup = $1200 + +parallax: + + ;=================== + ; init screen + + jsr HGR ; clear PAGE1 + jsr HGR2 ; clear PAGE2 + + ;=================== + ; int tables + + ldx #191 +init_loop: + txa + pha + jsr HPOSN + pla + tax + lda GBASL + sta hgr_lookup_l,X + lda GBASH + and #$1F ; 20 30 001X 40 50 010X + sta hgr_lookup_h,X + + + dex + cpx #$ff + bne init_loop + + ldx #39 +div4_loop: + txa + asl + asl + sta div4_lookup,X + dex + bpl div4_loop + + +parallax_forever: + + ; increment offsets + + inc large_smc+1 ; 6 + inc medium_smc+1 ; 6 + + ;======================== + ; flip page + + lda HGR_PAGE ; $40 or $20 + + eor #$60 ; flip draw_page + sta HGR_PAGE + + asl + asl + rol + eor #$1 + tax + lda PAGE1,X ; flip show_page + + + ldy #159 ; init Y + +yloop: + + ;============== + ; point output to current line + + lda hgr_lookup_l,Y ; 4+ + sta out_smc+1 ; 4 + lda hgr_lookup_h,Y ; 4+ + ora HGR_PAGE ; 3 + sta out_smc+2 ; 4 + + ;============== + ; current column (work backwards) + + ldx #39 ; 2 +xloop: + + ;=========================== + ; Boxes + + tya ; 2 + + ; carry always clear here? +large_smc: + sbc #$DD ; 2 +; eor div4_lookup,X ; 4 +; and #$40 ; 2 + + and div4_lookup,X ; 4 + + bne draw_white ; 2/3 + + ; 0 means transparent + +skip_color_large: + + ;=========================== + ; Sierpinski + + tya ; 2 +medium_smc: + adc #$DD ; go other way ; 2 + and div4_lookup,X ; sierpinski ; 4 + + + bne draw_black ; draw black ; 2/3 +draw_purple: + lda #$55 ; purple/green ; 2 + bne draw_color ; bra ; 3 +draw_black: + lda #$00 ; 2 + beq draw_color ; bra ; 3 + + ; white block +draw_white: + lda #$7f ; 2 + + ;======================== + ; actually draw color + +draw_color: +out_smc: + sta $2000,X ; 5 + + dex ; 2 + bpl xloop ; 2/3 + + dey ; 2 + cpy #32 ; 2 + bne yloop ; 2/3 + + beq parallax_forever ; bra ; 3