From 23b4af92f63ce6f0dfc2e22a309a90558ed72209 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 11 Oct 2022 03:47:24 -0400 Subject: [PATCH] hgr: both: update bot code --- graphics/both/gears/Makefile | 15 ++- graphics/both/gears/dsr_bot.s | 192 ++++++++++++++++++++++++++++++++ graphics/both/gears/dsr_lores.s | 81 +++++++++----- 3 files changed, 255 insertions(+), 33 deletions(-) create mode 100644 graphics/both/gears/dsr_bot.s diff --git a/graphics/both/gears/Makefile b/graphics/both/gears/Makefile index 2ff103e2..618a7de5 100644 --- a/graphics/both/gears/Makefile +++ b/graphics/both/gears/Makefile @@ -8,10 +8,11 @@ TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft all: both.dsk -both.dsk: HELLO DSR_LORES PROOF PROOF2 +both.dsk: HELLO DSR_BOT DSR_LORES PROOF PROOF2 cp $(EMPTY_DISK) both.dsk $(DOS33) -y both.dsk SAVE A HELLO - $(DOS33) -y both.dsk BSAVE -a 0x373 DSR_LORES + $(DOS33) -y both.dsk BSAVE -a 0xC00 DSR_LORES + $(DOS33) -y both.dsk BSAVE -a 0x373 DSR_BOT $(DOS33) -y both.dsk BSAVE -a 0xC00 PROOF $(DOS33) -y both.dsk BSAVE -a 0xC00 PROOF2 @@ -19,13 +20,21 @@ both.dsk: HELLO DSR_LORES PROOF PROOF2 ### DSR_LORES: dsr_lores.o - ld65 -o DSR_LORES dsr_lores.o -C $(LINKER_DIR)/apple2_373.inc + ld65 -o DSR_LORES dsr_lores.o -C $(LINKER_DIR)/apple2_c00.inc dsr_lores.o: dsr_lores.s ca65 -o dsr_lores.o dsr_lores.s -l dsr_lores.lst ### +DSR_BOT: dsr_bot.o + ld65 -o DSR_BOT dsr_bot.o -C $(LINKER_DIR)/apple2_373.inc + +dsr_bot.o: dsr_bot.s + ca65 -o dsr_bot.o dsr_bot.s -l dsr_bot.lst + +### + PROOF: proof.o ld65 -o PROOF proof.o -C $(LINKER_DIR)/apple2_c00.inc diff --git a/graphics/both/gears/dsr_bot.s b/graphics/both/gears/dsr_bot.s new file mode 100644 index 00000000..89b97046 --- /dev/null +++ b/graphics/both/gears/dsr_bot.s @@ -0,0 +1,192 @@ +; dsr rotate lores + +; by deater (Vince Weaver) + +; 147 bytes -- original attempt +; 145 bytes -- hires address tables in zero page +; 143 bytes -- optimize table init some more +; 138 bytes -- swap X and Y in lores code +; 136 bytes -- remove unnecessary compare +; 135 bytes -- realize with shift, hclr is unneccesary +; 134 bytes -- optimize Y usage in inner loop +; 132 bytes -- don't need to init rotate? +; 135 bytes -- bot jump + +; Zero Page +GBASL = $26 +GBASH = $27 +COLOR = $30 + +HGR_X = $E0 +HGR_Y = $E2 +HGR_COLOR = $E4 +HGR_HORIZ = $E5 +HGR_PAGE = $E6 +HGR_SCALE = $E7 +ROTATION = $FA +COUNT = $FC +YY = $FD +BB = $FE +XX = $FF + +; Soft Switches + +SET_GR = $C050 +SET_TEXT = $C051 +FULLGR = $C052 +TEXTGR = $C053 + +PAGE1 = $C054 ; Page1 +PAGE2 = $C055 ; Page2 +LORES = $C056 ; Enable LORES graphics +HIRES = $C057 ; Enable HIRES graphics + + +; 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) +PLOT = $F800 ;; PLOT AT Y,A +SETCOL = $F864 ;; COLOR=A +XDRAW0 = $F65D + + +hgr_lookup_h = $40 ; $40-$70 +hgr_lookup_l = $70 ; $70-$A0 + +;hgr_lookup_h = $1000 +;hgr_lookup_l = $1100 + + +dsr_rotate: + + ;=================== + ; init screen + + jsr HGR ; clear PAGE1 + ; A,Y are 0? + bit FULLGR + + ;=================== + ; init vars + +; sta ROTATION ; start at 0 + ; not needed if don't care start? + + ldx #4 + stx HGR_SCALE + + ;=================== + ; int tables + + ldx #47 +init_loop: + txa + jsr HPOSN ; important part is A=ycoord + ldx HGR_Y ; A value stored in HGR_Y + lda GBASL + sta hgr_lookup_l,X + lda GBASH + sta hgr_lookup_h,X + dex + bpl init_loop + + + bit LORES + + +big_loop: + +;===================================== +; draw dsr +draw_dsr: + + ldy #0 ; Y 0 here from HCLR + ldx #15 + lda #20 + jsr HPOSN ; set screen position to X= (y,x) Y=(a) + ; saves X,Y,A to zero page + ; after Y= orig X/7 + ; A and X are ?? + + ldx #shape_dsr ; point to top byte of shape address + + ; ROT in A + lda ROTATION ; ROT=0 + jsr XDRAW0 ; XDRAW 1 AT X,Y + ; Both A and X are 0 at exit + ; Z flag set on exit + +;=============================== +; copy to lores +; X654 3210 X654 3210 + + + + ldy #47 + sty YY ; set y-coord to 47 +lsier_outer: + ldx YY ; a bit of a wash + lda hgr_lookup_l,X + sta hgr_scrn_smc+1 + lda hgr_lookup_h,X + sta hgr_scrn_smc+2 + + ldx #0 + ldy #0 ; COUNT + +lsier_inner: + + lda #6 + sta BB + +lsier_inner_inner: + +hgr_scrn_smc: + lsr $2000,X ; note this also clears screen + lda #0 + bcs no_color + + lda YY ; get Y-coord into A +no_color: + jsr SETCOL + + lda YY ; y-coord in A + ; x-coord already in Y + + jsr PLOT ; plot at Y,A + + iny ; increment count + cpy #40 ; if hit 40, done + beq done_line + + dec BB ; decrement byte count + bpl lsier_inner_inner ; if <7 then keep shifting + + inx ; increment hires-x value + bne lsier_inner ; bra + +done_line: + dec YY ; decrement y-coord + bpl lsier_outer ; until less than 0 + +end: + inc ROTATION + inc ROTATION + jmp big_loop + +shape_dsr: +.byte $2d,$36,$ff,$3f +.byte $24,$ad,$22,$24,$94,$21,$2c,$4d +.byte $91,$3f,$36,$00 + + + + ; $3F5 - 130 = $373 +for_bot: + jmp dsr_rotate diff --git a/graphics/both/gears/dsr_lores.s b/graphics/both/gears/dsr_lores.s index 89b97046..40e4833b 100644 --- a/graphics/both/gears/dsr_lores.s +++ b/graphics/both/gears/dsr_lores.s @@ -1,16 +1,9 @@ -; dsr rotate lores +; ][ rotate lores ; by deater (Vince Weaver) -; 147 bytes -- original attempt -; 145 bytes -- hires address tables in zero page -; 143 bytes -- optimize table init some more -; 138 bytes -- swap X and Y in lores code -; 136 bytes -- remove unnecessary compare -; 135 bytes -- realize with shift, hclr is unneccesary -; 134 bytes -- optimize Y usage in inner loop -; 132 bytes -- don't need to init rotate? -; 135 bytes -- bot jump +; 144 bytes (close) +; 143 bytes -> jmp to bne ; Zero Page GBASL = $26 @@ -23,6 +16,7 @@ HGR_COLOR = $E4 HGR_HORIZ = $E5 HGR_PAGE = $E6 HGR_SCALE = $E7 +FRAME = $F9 ROTATION = $FA COUNT = $FC YY = $FD @@ -51,6 +45,8 @@ 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) PLOT = $F800 ;; PLOT AT Y,A +PLOT1 = $F80E ;; PLOT at (GBASL),Y (need MASK to be $0f or $f0) + SETCOL = $F864 ;; COLOR=A XDRAW0 = $F65D @@ -58,9 +54,6 @@ XDRAW0 = $F65D hgr_lookup_h = $40 ; $40-$70 hgr_lookup_l = $70 ; $70-$A0 -;hgr_lookup_h = $1000 -;hgr_lookup_l = $1100 - dsr_rotate: @@ -71,12 +64,11 @@ dsr_rotate: ; A,Y are 0? bit FULLGR + bit LORES + ;=================== ; init vars -; sta ROTATION ; start at 0 - ; not needed if don't care start? - ldx #4 stx HGR_SCALE @@ -96,18 +88,17 @@ init_loop: bpl init_loop - bit LORES big_loop: ;===================================== -; draw dsr -draw_dsr: +; draw ][ +draw_II: - ldy #0 ; Y 0 here from HCLR - ldx #15 - lda #20 + ldy #0 ; Y + ldx #20 + lda #24 jsr HPOSN ; set screen position to X= (y,x) Y=(a) ; saves X,Y,A to zero page ; after Y= orig X/7 @@ -137,9 +128,17 @@ lsier_outer: lda hgr_lookup_h,X sta hgr_scrn_smc+2 - ldx #0 + txa ldy #0 ; COUNT + jsr PLOT ; plot at Y,A + ; this sets up GBASL for us + ; does create slight glitch + ; on left side of screen + + ldx #0 ; X = hires x-coord + + lsier_inner: lda #6 @@ -150,16 +149,21 @@ lsier_inner_inner: hgr_scrn_smc: lsr $2000,X ; note this also clears screen lda #0 + + ; bcc = $90, bcs = $b0 + ; 1001 1011 +flip_smc: bcs no_color - lda YY ; get Y-coord into A + lda YY ; use Y-coord for color + adc ROTATION ; rotate colors no_color: jsr SETCOL - lda YY ; y-coord in A ; x-coord already in Y - jsr PLOT ; plot at Y,A + jsr PLOT1 ; plot at (GBASL),Y + ; GBASL/H set earlier with PLOT iny ; increment count cpy #40 ; if hit 40, done @@ -178,13 +182,30 @@ done_line: end: inc ROTATION inc ROTATION - jmp big_loop + + + lda ROTATION + + and #$20 + clc + adc #$90 ; flip bcs/bcc + sta flip_smc + + bne big_loop ; bra shape_dsr: -.byte $2d,$36,$ff,$3f -.byte $24,$ad,$22,$24,$94,$21,$2c,$4d -.byte $91,$3f,$36,$00 +;.byte $2d,$36,$ff,$3f +;.byte $24,$ad,$22,$24,$94,$21,$2c,$4d +;.byte $91,$3f,$36,$00 +;.byte $01,$00,$04,$00 +;.byte $36,$ff,$3f,$24 +;.byte $2d,$12,$24,$40,$ad,$12,$24,$4c +;.byte $39,$37,$36,$2e,$05,$00 + +.byte $d2,$1b,$2d,$24 +.byte $24,$7f,$49,$09,$3f,$36,$36,$2d +.byte $00 ; $3F5 - 130 = $373