1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00
cc65/libsrc/cx16/cpeekc.s

49 lines
1.1 KiB
ArmAsm

;
; 2016-02-28, Groepaz
; 2019-09-25, Greg King
;
; char cpeekc (void);
; /* Return the character from the current cursor position. */
;
.export _cpeekc
.include "cx16.inc"
_cpeekc:
php
sei ; don't let cursor blinking interfere
stz VERA::CTRL ; use port 0
lda CURS_Y
sta VERA::ADDR+1 ; set row number
stz VERA::ADDR+2
lda CURS_X ; get character column
asl a
sta VERA::ADDR
lda VERA::DATA0 ; get screen code
plp
ldx #>$0000
and #<~%10000000 ; 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