peasant: fix narrow rectangles being drawn

also drop use of HGLIN, use rectangles for everything
This commit is contained in:
Vince Weaver 2021-09-01 22:42:57 -04:00
parent 32d20ead2f
commit c680123ada
6 changed files with 178 additions and 18 deletions

View File

@ -66,3 +66,25 @@ EO EO
6|----c>>>-----------c------c-------| 6|----c>>>-----------c------c-------|
5|-aaa----aaab>>>aaa---a-b-a---------| 5|-aaa----aaab>>>aaa---a-b-a---------|
46, XRUN=2
46/7= 6R4 ; RUN of 0=1 wide, run of 1=2 wide
start at 4, end at 5
start at 4 (left) = $F0 1111 0000
end at 5 (Right) = $BF 1011 1111
=========
x011 0000
OR them!!!!
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF

View File

@ -15,7 +15,11 @@ draw_box:
lda BOX_Y1 lda BOX_Y1
sta VGI_RY1 sta VGI_RY1
sec ; calculate X run
sec ; 16-bit subtract?
lda BOX_X2H ; doesn't handle >255
sbc BOX_X1H
lda BOX_X2L lda BOX_X2L
sbc BOX_X1L sbc BOX_X1L
sta VGI_RXRUN sta VGI_RXRUN
@ -29,12 +33,101 @@ draw_box:
; draw lines ; draw lines
ldx #2 ; color is purple ; ldx #2 ; color is purple
lda colortbl,X ; lda colortbl,X
sta HGR_COLOR ; sta HGR_COLOR
lda #$22 ; color is purple
sta VGI_RCOLOR
; draw outer rectangle, x+6, y+5 x-6, y-5 ; draw outer rectangle, x+6, y+5 x-6, y-5
; draw 4 boxes
; x1+6,y1+5 ... x2-6,y1+6
; x1+6,y2-6 ... x2-6,y2-5
; x1+6,y1+5 ... x1+7,y2-6
; x2-7,y1+5 ... x2-6,y2-6
;===============================
; top: x1+6,y1+5 ... x2-6,y1+6
clc
lda VGI_RX1
adc #6
sta VGI_RX1
sec
lda VGI_RXRUN
sbc #12
sta VGI_RXRUN
clc
lda BOX_Y1
adc #5
sta VGI_RY1
lda #2
sta VGI_RYRUN
jsr vgi_simple_rectangle
;===============================
; bottom: x1+6,y2-6 ... x2-6,y2-5
sec
lda BOX_Y2
sbc #6
sta VGI_RY1
lda #2
sta VGI_RYRUN
jsr vgi_simple_rectangle
;===============================
; left: x1+6,y1+5 ... x1+7,y2-6
clc
lda BOX_Y1
adc #5
sta VGI_RY1
lda #2
sta VGI_RXRUN
sec
lda BOX_Y2
sbc BOX_Y1
sbc #10
sta VGI_RYRUN
jsr vgi_simple_rectangle
;===============================
; right: x2-7,y1+5 ... x2-6,y2-6
sec
lda BOX_X2L
sbc #7
sta VGI_RX1
clc
lda BOX_Y1
adc #5
sta VGI_RY1
sec
lda BOX_Y2
sbc BOX_Y1
sbc #9
sta VGI_RYRUN
jsr vgi_simple_rectangle
.if 0
clc clc
lda BOX_X1L lda BOX_X1L
adc #6 adc #6
@ -80,11 +173,11 @@ draw_box:
jsr draw_rectangle jsr draw_rectangle
.endif
rts rts
.if 0
draw_rectangle: draw_rectangle:
ldy #0 ldy #0
@ -114,3 +207,4 @@ draw_rectangle:
rts rts
.endif

View File

@ -61,16 +61,30 @@ simple_rectangle_loop:
bcs not_corner bcs not_corner
corner: corner:
; want to use MASK of left_mask, MOD7 and 7-XRUN ; left=(RX1 MOD 7) right=(RX1 MOD 7)+XRUN
; mask is left AND right
ldx VGI_RX1
lda mod7_table,X lda mod7_table,X
tax tax
lda left_masks,X
sta OTHER_MASK
txa
clc
adc XRUN
tax
lda right_masks,X
and OTHER_MASK
sta OTHER_MASK
; actual
lda (GBASL),Y lda (GBASL),Y
eor HGR_BITS eor HGR_BITS
and left_masks,X
ldx XRUN and OTHER_MASK
and right_masks,X
eor (GBASL),Y eor (GBASL),Y
sta (GBASL),Y sta (GBASL),Y

View File

@ -68,9 +68,25 @@ hposn_loop:
rts rts
; left masks
; in memory on screen
; x111 1111 1111111 start at 0
; x111 1110 0111111 start at 1
; x111 1100 0011111 start at 2
; ...
; x100 0000 0000001 start at 6
left_masks: left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0 .byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
; right masks
; in memory on screen
; x000 0001 1000000 end at 0
; x000 0011 1100000 end at 1
; x000 0111 1110000 end at 2
; ...
; x011 1111 1111110 end at 5
; x111 1111 1111111 end at 6
right_masks: right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF .byte $81,$83,$87, $8F,$9F,$BF,$FF

View File

@ -176,8 +176,8 @@ done_cottage:
; even odd
; 01234567 01234567
peasant_text: peasant_text:
@ -185,7 +185,7 @@ peasant_text:
cottage_text1: cottage_text1:
.byte 0,53,24, 0,253,82 .byte 0,52,24, 0,253,82
.byte 9,35,"YOU are Rather Dashing, a",13 .byte 9,35,"YOU are Rather Dashing, a",13
.byte "humble peasant living in",13 .byte "humble peasant living in",13
.byte "the peasant kingdom of",13 .byte "the peasant kingdom of",13
@ -194,7 +194,7 @@ cottage_text1:
; wait a few seconds ; wait a few seconds
cottage_text2: cottage_text2:
.byte 0,40,15, 0,255,96 .byte 0,41,15, 0,255,96
.byte 8,25,"You return home from a",13 .byte 8,25,"You return home from a",13
.byte "vacation on Scalding Lake",13 .byte "vacation on Scalding Lake",13
.byte "only to find that TROGDOR",13 .byte "only to find that TROGDOR",13

View File

@ -114,16 +114,30 @@ not_striped:
bcs not_corner bcs not_corner
corner: corner:
; want to use MASK of left_mask, MOD7 and 7-XRUN ; left=(RX1 MOD 7) right=(RX1 MOD 7)+XRUN
; mask is left AND right
ldx VGI_RX1
lda mod7_table,X lda mod7_table,X
tax tax
lda left_masks,X
sta OTHER_MASK
txa
clc
adc XRUN
tax
lda right_masks,X
and OTHER_MASK
sta OTHER_MASK
; actual
lda (GBASL),Y lda (GBASL),Y
eor HGR_BITS eor HGR_BITS
and left_masks,X
ldx XRUN and OTHER_MASK
and right_masks,X
eor (GBASL),Y eor (GBASL),Y
sta (GBASL),Y sta (GBASL),Y