1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 17:29:50 +00:00
cc65/libsrc/c64/soft80_cgetc.s

86 lines
2.0 KiB
ArmAsm
Raw Normal View History

;
; Groepaz/Hitmen, 11.10.2015
;
2015-10-19 00:47:40 +00:00
; high level implementation for the soft80 implementation
;
; char cgetc (void);
;
.export soft80_cgetc
.import soft80_internal_cellcolor, soft80_internal_cursorxlsb
.import cursor
2015-10-09 21:39:37 +00:00
.importzp tmp1
.include "cbm_kernal.inc"
.include "c64.inc"
.include "soft80.inc"
soft80_cgetc:
lda KEY_COUNT ; Get number of characters
2015-10-12 18:38:06 +00:00
bne @L3 ; Jump if there are already chars waiting
2015-10-12 15:12:44 +00:00
sec
jsr invertcursor ; set cursor on or off accordingly
2015-10-12 18:38:06 +00:00
@L1: lda KEY_COUNT ; wait for key
beq @L1
2015-10-12 15:12:44 +00:00
clc
jsr invertcursor ; set cursor on or off accordingly
2015-10-12 18:38:06 +00:00
@L3: jsr KBDREAD ; Read char and return in A
ldx #0
rts
; Switch the cursor on or off (invert)
invertcursor:
lda cursor
bne @invert
rts
@invert:
sei
2015-10-09 21:39:37 +00:00
lda $01 ; enable RAM under I/O
pha
2015-10-09 21:39:37 +00:00
lda #$34
sta $01
2020-07-15 20:44:34 +00:00
; do not use soft80_putcolor here to make sure the cursor is always
; shown using the current textcolor without disturbing the "color voodoo"
; in soft80_cputc
ldy #0
bcs @set
; restore old value
lda tmp1
bcc @lp0
@set:
; save old value
lda (CRAM_PTR),y ; vram
sta tmp1
lda soft80_internal_cellcolor
@lp0:
sta (CRAM_PTR),y ; vram
ldx soft80_internal_cursorxlsb
ldy #7
@lp1:
lda (SCREEN_PTR),y
eor nibble,x
sta (SCREEN_PTR),y
dey
bpl @lp1
pla
2015-10-12 15:12:44 +00:00
sta $01 ; enable I/O
cli
rts
.rodata
nibble: .byte $f0, $0f
2015-10-09 11:34:23 +00:00
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import soft80_init
conio_init = soft80_init