1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-27 00:29:31 +00:00
cc65/libsrc/cbm610/cpeekc.s

46 lines
932 B
ArmAsm
Raw Normal View History

2017-12-11 18:49:14 +00:00
;
; 2016-02-28, Groepaz
; 2017-06-19, Greg King
;
; char cpeekc (void);
;
.export _cpeekc
.import CURS_X: zp, CharPtr: zp
.include "cbm610.inc"
_cpeekc:
ldx IndReg
ldy #$0F
sty IndReg
ldy CURS_X
lda (CharPtr),y ; get char from system bank
stx IndReg
ldx #>$0000
and #<~$80 ; remove reverse bit
; Convert the screen code into a PetSCII code.
; $00 - $1F: +$40
; $20 - $3F
; $40 - $5f: +$20
; $60 - $7F: +$40
cmp #$20
bcs @sk1 ;(bge)
ora #$40
rts
@sk1: cmp #$40
bcc @end ;(blt)
cmp #$60
bcc @sk2 ;(blt)
;sec
adc #$20 - $01
@sk2: ;clc ; both above cmp and adc clear carry flag
adc #$20
@end: rts