hgr: color_shift now cycle-invar

This commit is contained in:
Vince Weaver 2018-09-09 16:10:07 -04:00
parent e89c0e85dd
commit a5546691f7
2 changed files with 56 additions and 64 deletions

View File

@ -127,6 +127,19 @@ hposn_2:
tax tax
lda msktbl-$100+7,x ; LDA MSKTBL-$100+7,X BIT MASK lda msktbl-$100+7,x ; LDA MSKTBL-$100+7,X BIT MASK
; MSKTBL=F5B2 ; MSKTBL=F5B2
; weird two's complement?
; if x=-6 = 249 = fa
; F5b2 - 1000 = f4b2
; f4b2+7 = f4b9
; -1 ff + f4b9 = f5b8 C0 6
; -2 fe + f4b9 = f5b7 A0 5
; -3 fd + f4b9 = f5b6 90 4
; -4 fc + f4b9 = f5b5 88 3
; -5 fb + f4b9 = f5b4 84 2
; -6 fa + f4b9 = f5b3 82 1
; -7 f9 + f4b9 = f5b2 81 0
sta HMASK sta HMASK
tya tya
lsr lsr

View File

@ -123,39 +123,40 @@ hposn:
; Divide by 7 (From December '84 Apple Assembly Line) ; Divide by 7 (From December '84 Apple Assembly Line)
txa txa ; 2
clc clc ; 2
sta HGR_HORIZ sta HGR_HORIZ ; 3
lsr lsr ; 2
lsr lsr ; 2
lsr lsr ; 2
adc HGR_HORIZ adc HGR_HORIZ ; 3
ror ror ; 2
lsr lsr ; 2
lsr lsr ; 2
adc HGR_HORIZ adc HGR_HORIZ ; 3
ror ror ; 2
lsr lsr ; 2
lsr lsr ; 2
; x/7 is in A ; x/7 is in A
;============
; 31
; calculate remainder ; calculate remainder
clc clc ; 2
sta HGR_HORIZ sta HGR_HORIZ ; 3
asl asl ; 2
adc HGR_HORIZ adc HGR_HORIZ ; 3
asl asl ; 2
adc HGR_HORIZ adc HGR_HORIZ ; 3
; HGR_HORIZ=x/7, A=HGR_HORIZ*7 ; HGR_HORIZ=x/7, A=HGR_HORIZ*7
; calculate remainder by X-(Q*7) ; calculate remainder by X-(Q*7)
sec sec ; 2
eor #$ff eor #$ff ; 2
adc HGR_X adc HGR_X ; 3
; A = remainder ; A = remainder ;===========
; 22
cpy #0 cpy #0 ; 2
beq only_low beq done_mod
theres_high: theres_high:
clc clc
@ -165,7 +166,7 @@ theres_high:
adc #36 adc #36
sta HGR_HORIZ sta HGR_HORIZ
pla pla
only_low:
cmp #7 cmp #7
bcc done_mod ; blt bcc done_mod ; blt
@ -174,40 +175,10 @@ only_low:
inc HGR_HORIZ inc HGR_HORIZ
done_mod: done_mod:
ldy HGR_HORIZ ; 2
; txa ; 2
; cpy #0 ; 2
; beq hposn_2 ; 3
; -1
; ldy #35 ; 2
; adc #4 ; 2
;hposn_1:
; iny ; 2
; f442
;hposn_2:
; sbc #7 ; 2
; bcs hposn_1 ; 3
; -1
ldy HGR_HORIZ
; sty HGR_HORIZ ; 3
tax ; 2 tax ; 2
lda msktbl,x ; lda msktbl,x ; 4+
; lda msktbl-$100+7,x ; LDA MSKTBL-$100+7,X BIT MASK ; 4?
; weird two's complement?
; if x=-6 = 249 = fa
; F5b2 - 1000 = f4b2
; f4b2+7 = f4b9
; -1 ff + f4b9 = f5b8 C0 6
; -2 fe + f4b9 = f5b7 A0 5
; -3 fd + f4b9 = f5b6 90 4
; -4 fc + f4b9 = f5b5 88 3
; -5 fb + f4b9 = f5b4 84 2
; -6 fa + f4b9 = f5b3 82 1
; -7 f9 + f4b9 = f5b2 81 0
; MSKTBL=F5B2
sta HMASK ; 3 sta HMASK ; 3
tya ; 2 tya ; 2
lsr ; 2 lsr ; 2
@ -249,8 +220,13 @@ lr_4:
sty HGR_HORIZ sty HGR_HORIZ
lda HGR_BITS lda HGR_BITS
color_shift:
; F47E ;===================================
;
; positive = 7+(7)+6 = 20
; negative = 7+ 7 +6 = 20
color_shift: ; F47E
asl ; 2 asl ; 2
cmp #$c0 ; 2 cmp #$c0 ; 2
@ -259,8 +235,11 @@ color_shift:
lda HGR_BITS ; 3 lda HGR_BITS ; 3
eor #$7f ; 2 eor #$7f ; 2
sta HGR_BITS ; 3 sta HGR_BITS ; 3
rts ; 6
done_color_shift: done_color_shift:
lda HGR_BITS ; nop ; 3
nop ; 2
nop ; 2
rts ; 6 rts ; 6
move_right: move_right: