cleanup/fix pce cpeekc/cpeekcolor/cpeekrevers/cpeeks, replaces #532
This commit is contained in:
@@ -14,11 +14,11 @@ _cpeekc:
|
||||
st0 #VDC_MARR ; Memory-Address Read
|
||||
ldy SCREEN_PTR
|
||||
ldx SCREEN_PTR+1
|
||||
sty VDC_DATA_LO
|
||||
stx VDC_DATA_HI
|
||||
sty a:VDC_DATA_LO
|
||||
stx a:VDC_DATA_HI
|
||||
|
||||
st0 #VDC_VRR ; VRAM Read Register
|
||||
lda VDC_DATA_LO ; character
|
||||
lda a:VDC_DATA_LO ; character
|
||||
and #<~$80 ; remove reverse bit
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
@@ -14,11 +14,11 @@ _cpeekcolor:
|
||||
st0 #VDC_MARR ; Memory-Address Read
|
||||
ldy SCREEN_PTR
|
||||
ldx SCREEN_PTR+1
|
||||
sty VDC_DATA_LO
|
||||
stx VDC_DATA_HI
|
||||
sty a:VDC_DATA_LO
|
||||
stx a:VDC_DATA_HI
|
||||
|
||||
st0 #VDC_VRR ; VRAM Read Register
|
||||
lda VDC_DATA_HI
|
||||
lda a:VDC_DATA_HI
|
||||
and #<~$02
|
||||
lsr a
|
||||
lsr a
|
||||
|
||||
@@ -14,13 +14,14 @@ _cpeekrevers:
|
||||
st0 #VDC_MARR ; Memory-Address Read
|
||||
ldy SCREEN_PTR
|
||||
ldx SCREEN_PTR+1
|
||||
sty VDC_DATA_LO
|
||||
stx VDC_DATA_HI
|
||||
sty a:VDC_DATA_LO
|
||||
stx a:VDC_DATA_HI
|
||||
|
||||
st0 #VDC_VRR ; VRAM Read Register
|
||||
lda VDC_DATA_LO ; character (bit 7 is revers bit)
|
||||
rol a
|
||||
rol a
|
||||
and #1
|
||||
ldx #0
|
||||
|
||||
lda a:VDC_DATA_LO ; character (bit 7 is revers bit)
|
||||
and #$80 ; get reverse bit
|
||||
asl a ; reverse bit to carry, A=0
|
||||
tax ; ldx #>$0000
|
||||
rol a ; reverse bit from carry
|
||||
rts
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
;
|
||||
; 2020-07-14, Groepaz
|
||||
; 2020-07-15, Greg King
|
||||
;
|
||||
; void cpeeks (char* s, unsigned length);
|
||||
;
|
||||
@@ -8,9 +9,7 @@
|
||||
.export _cpeeks
|
||||
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, tmp1, tmp2
|
||||
|
||||
.macpack generic
|
||||
.importzp ptr1, ptr2
|
||||
|
||||
.include "pce.inc"
|
||||
.include "extzp.inc"
|
||||
@@ -22,35 +21,31 @@ _cpeeks:
|
||||
eor #>$FFFF
|
||||
sta ptr2+1
|
||||
|
||||
st0 #VDC_CR ; Control Register
|
||||
st2 #>$0088 ; make VRAM address increment by one
|
||||
|
||||
st0 #VDC_MARR ; Memory-Address Read
|
||||
ldy SCREEN_PTR
|
||||
ldx SCREEN_PTR+1
|
||||
sty VDC_DATA_LO
|
||||
stx VDC_DATA_HI
|
||||
sty a:VDC_DATA_LO
|
||||
stx a:VDC_DATA_HI
|
||||
|
||||
st0 #VDC_VRR ; VRAM Read Register
|
||||
|
||||
jsr popax
|
||||
sta tmp1 ; (will be a .Y index)
|
||||
tay ; low byte of address will be used as index
|
||||
stx ptr1+1
|
||||
|
||||
ldx #<$0000
|
||||
stx ptr1
|
||||
beq L2 ; branch always
|
||||
|
||||
L3: ldy tmp2
|
||||
lda VDC_DATA_LO ; get character
|
||||
bit VDC_DATA_HI ; we need to "read" the highbyte to advance the address
|
||||
iny
|
||||
sty tmp2
|
||||
L3: lda a:VDC_DATA_LO ; get character
|
||||
bit a:VDC_DATA_HI ; need to read high byte to advance VDC address
|
||||
and #<~$80 ; remove reverse bit
|
||||
|
||||
ldy tmp1
|
||||
sta (ptr1),y
|
||||
iny
|
||||
bne L1
|
||||
bne L2
|
||||
inc ptr1+1
|
||||
L1: sty tmp1
|
||||
|
||||
L2: inc ptr2 ; count length
|
||||
bne L3
|
||||
@@ -58,6 +53,5 @@ L2: inc ptr2 ; count length
|
||||
bne L3
|
||||
|
||||
txa ; terminate the string
|
||||
ldy tmp1
|
||||
sta (ptr1),y
|
||||
rts
|
||||
|
||||
Reference in New Issue
Block a user