2019-09-27 07:38:51 +00:00
|
|
|
;
|
|
|
|
; 2016-02-28, Groepaz
|
2022-04-02 13:39:35 +00:00
|
|
|
; 2022-03-29, Greg King
|
2019-09-27 07:38:51 +00:00
|
|
|
;
|
|
|
|
; char cpeekc (void);
|
|
|
|
; /* Return the character from the current cursor position. */
|
|
|
|
;
|
|
|
|
|
|
|
|
.export _cpeekc
|
|
|
|
|
|
|
|
.include "cx16.inc"
|
2022-04-02 13:39:35 +00:00
|
|
|
.macpack generic
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
|
2022-04-02 13:39:35 +00:00
|
|
|
screen_addr := $1B000 ; VRAM address of text screen
|
|
|
|
|
2019-09-27 07:38:51 +00:00
|
|
|
_cpeekc:
|
|
|
|
stz VERA::CTRL ; use port 0
|
|
|
|
lda CURS_Y
|
2022-04-02 13:39:35 +00:00
|
|
|
add #<(>screen_addr)
|
2019-09-27 07:38:51 +00:00
|
|
|
sta VERA::ADDR+1 ; set row number
|
2022-04-02 13:39:35 +00:00
|
|
|
lda #^screen_addr
|
|
|
|
sta VERA::ADDR+2
|
2019-09-27 07:38:51 +00:00
|
|
|
lda CURS_X ; get character column
|
2019-11-16 18:11:40 +00:00
|
|
|
asl a ; each character has two bytes
|
2019-09-27 07:38:51 +00:00
|
|
|
sta VERA::ADDR
|
|
|
|
lda VERA::DATA0 ; get screen code
|
|
|
|
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
|