1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-28 22:30:12 +00:00
cc65/libsrc/c128/cpeekc.s

71 lines
1.4 KiB
ArmAsm
Raw Normal View History

2017-12-11 18:49:14 +00:00
;
; 2016-02-28, Groepaz
; 2017-06-26, Greg King
;
; char cpeekc (void);
;
.export _cpeekc
.import plot, popa
.include "zeropage.inc"
.include "c128.inc"
_cpeekc:
lda MODE
bmi @c80
ldy CURS_X
lda (SCREEN_PTR),y ; get char
@return:
and #<~$80 ; remove reverse flag
; Convert the screen code into a PetSCII code.
; $00 - $1F: +$40
; $20 - $3F
2017-12-11 20:53:00 +00:00
; $40 - $5f: +$20
; $60 - $7F: +$40
2017-12-11 18:49:14 +00:00
cmp #$20
bcs @sk1 ;(bge)
ora #$40
rts
@sk1: cmp #$40
bcc @end ;(blt)
2017-12-11 20:53:00 +00:00
cmp #$60
bcc @sk2 ;(blt)
;sec
adc #$20 - $01
@sk2: ;clc ; both above cmp and adc clear carry flag
adc #$20
@end: rts
2017-12-11 18:49:14 +00:00
@c80:
lda SCREEN_PTR
ldy SCREEN_PTR+1
clc
adc CURS_X
bcc @s
iny
; get byte from VDC mem
@s: ldx #VDC_DATA_LO
stx VDC_INDEX
@L0: bit VDC_INDEX
bpl @L0
sta VDC_DATA
dex
stx VDC_INDEX
sty VDC_DATA
ldx #VDC_RAM_RW
stx VDC_INDEX
@L1: bit VDC_INDEX
bpl @L1 ; wait for blanking
lda VDC_DATA
jmp @return