-
Notifications
You must be signed in to change notification settings - Fork 1
/
soft80_cgetc.s
73 lines (60 loc) · 1.62 KB
/
soft80_cgetc.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// Groepaz/Hitmen, 11.10.2015
//
// high level implementation for the soft80 implementation
//
// char cgetc (void)//
//
#import "soft80.inc"
cursor: .byte $00
soft80_cgetc:
lda KEY_COUNT // Get number of characters
bne L3 // Jump if there are already chars waiting
sec
jsr invertcursor // set cursor on or off accordingly
L1: lda KEY_COUNT // wait for key
beq L1
clc
jsr invertcursor // set cursor on or off accordingly
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
lda $01 // enable RAM under I/O
pha
lda #$34
sta $01
// 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 soft80.tmp1
bcc lp0
set:
// save old value
lda (CRAM_PTR),y // vram
sta soft80.tmp1
lda soft80_internal_cellcolor
lp0:
sta (CRAM_PTR),y // vram
ldx soft80_internal_cursorxlsb
ldy #7
!:
lda (SCREEN_PTR),y
eor nibble,x
sta (SCREEN_PTR),y
dey
bpl !-
pla
sta $01 // enable I/O
cli
rts
nibble: .byte $f0, $0f