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
lda msktbl-$100+7,x ; LDA MSKTBL-$100+7,X BIT MASK
; 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
tya
lsr

View File

@ -123,39 +123,40 @@ hposn:
; Divide by 7 (From December '84 Apple Assembly Line)
txa
clc
sta HGR_HORIZ
lsr
lsr
lsr
adc HGR_HORIZ
ror
lsr
lsr
adc HGR_HORIZ
ror
lsr
lsr
txa ; 2
clc ; 2
sta HGR_HORIZ ; 3
lsr ; 2
lsr ; 2
lsr ; 2
adc HGR_HORIZ ; 3
ror ; 2
lsr ; 2
lsr ; 2
adc HGR_HORIZ ; 3
ror ; 2
lsr ; 2
lsr ; 2
; x/7 is in A
;============
; 31
; calculate remainder
clc
sta HGR_HORIZ
asl
adc HGR_HORIZ
asl
adc HGR_HORIZ
clc ; 2
sta HGR_HORIZ ; 3
asl ; 2
adc HGR_HORIZ ; 3
asl ; 2
adc HGR_HORIZ ; 3
; HGR_HORIZ=x/7, A=HGR_HORIZ*7
; calculate remainder by X-(Q*7)
sec
eor #$ff
adc HGR_X
; A = remainder
sec ; 2
eor #$ff ; 2
adc HGR_X ; 3
; A = remainder ;===========
; 22
cpy #0
beq only_low
cpy #0 ; 2
beq done_mod
theres_high:
clc
@ -165,7 +166,7 @@ theres_high:
adc #36
sta HGR_HORIZ
pla
only_low:
cmp #7
bcc done_mod ; blt
@ -174,40 +175,10 @@ only_low:
inc HGR_HORIZ
done_mod:
; 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
ldy HGR_HORIZ ; 2
tax ; 2
lda msktbl,x ;
; lda msktbl-$100+7,x ; LDA MSKTBL-$100+7,X BIT MASK ; 4?
; weird two's complement?
lda msktbl,x ; 4+
; 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
tya ; 2
lsr ; 2
@ -249,8 +220,13 @@ lr_4:
sty HGR_HORIZ
lda HGR_BITS
color_shift:
; F47E
;===================================
;
; positive = 7+(7)+6 = 20
; negative = 7+ 7 +6 = 20
color_shift: ; F47E
asl ; 2
cmp #$c0 ; 2
@ -259,8 +235,11 @@ color_shift:
lda HGR_BITS ; 3
eor #$7f ; 2
sta HGR_BITS ; 3
rts ; 6
done_color_shift:
lda HGR_BITS ; nop ; 3
nop ; 2
nop ; 2
rts ; 6
move_right: