1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-02 15:37:58 +00:00

implemented conio peek functions for PCE target

This commit is contained in:
mrdudz 2020-07-14 14:22:29 +02:00
parent a4f1e37f0c
commit 1f2fdbd9b1
5 changed files with 143 additions and 2 deletions

24
libsrc/pce/cpeekc.s Normal file
View File

@ -0,0 +1,24 @@
;
; 2020-07-14, Groepaz
;
; char cpeekc (void);
;
; get character from current position, do NOT advance cursor
.export _cpeekc
.include "pce.inc"
.include "extzp.inc"
_cpeekc:
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
st0 #VDC_VRR ; VRAM Read Register
lda VDC_DATA_LO ; character
and #<~$80 ; remove reverse bit
ldx #0
rts

28
libsrc/pce/cpeekcolor.s Normal file
View File

@ -0,0 +1,28 @@
;
; 2020-07-14, Groepaz
;
; unsigned char cpeekcolor (void);
;
; get color from current position, do NOT advance cursor
.export _cpeekcolor
.include "pce.inc"
.include "extzp.inc"
_cpeekcolor:
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
st0 #VDC_VRR ; VRAM Read Register
lda VDC_DATA_HI
and #<~$02
lsr a
lsr a
lsr a
lsr a
ldx #0
rts

26
libsrc/pce/cpeekrevers.s Normal file
View File

@ -0,0 +1,26 @@
;
; 2020-07-14, Groepaz
;
; unsigned char cpeekrevers (void);
;
; get inverse flag from current position, do NOT advance cursor
.export _cpeekrevers
.include "pce.inc"
.include "extzp.inc"
_cpeekrevers:
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx 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
rts

63
libsrc/pce/cpeeks.s Normal file
View File

@ -0,0 +1,63 @@
;
; 2020-07-14, Groepaz
;
; void cpeeks (char* s, unsigned length);
;
; get string from current position, do NOT advance cursor
.export _cpeeks
.import popax
.importzp ptr1, ptr2, tmp1, tmp2
.macpack generic
.include "pce.inc"
.include "extzp.inc"
_cpeeks:
eor #<$FFFF ; counting a word upward is faster
sta ptr2 ; so, we use -(length + 1)
txa
eor #>$FFFF
sta ptr2+1
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
st0 #VDC_VRR ; VRAM Read Register
jsr popax
sta tmp1 ; (will be a .Y 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
and #<~$80 ; remove reverse bit
ldy tmp1
sta (ptr1),y
iny
bne L1
inc ptr1+1
L1: sty tmp1
L2: inc ptr2 ; count length
bne L3
inc ptr2+1
bne L3
txa ; terminate the string
ldy tmp1
sta (ptr1),y
rts

View File

@ -68,10 +68,10 @@ putchar:
sty VDC_DATA_LO
stx VDC_DATA_HI
st0 #VDC_VWR
st0 #VDC_VWR ; VRAM Write Register
sta VDC_DATA_LO ; character
lda CHARCOLOR ; pallette number
lda CHARCOLOR ; palette number
asl a
asl a
asl a