File: soft80_cgetc.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (91 lines) | stat: -rw-r--r-- 2,200 bytes parent folder | download | duplicates (2)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;
; Groepaz/Hitmen, 11.10.2015
;
; high level implementation for the soft80 implementation
;
; char cgetc (void);
;

        .export         soft80_cgetc
        .import         soft80_internal_cellcolor, soft80_internal_cursorxlsb
        .import         cursor
        .importzp       tmp1

        .include        "cbm_kernal.inc"
        .include        "c64.inc"
        .include        "soft80.inc"

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

        ldy     #$00
        jsr     setcolor

        ldx     soft80_internal_cursorxlsb
@lp1:
        lda     (SCREEN_PTR),y
        eor     nibble,x
        sta     (SCREEN_PTR),y
        iny
        cpy     #8
        bne     @lp1

        pla
        sta     $01             ; enable I/O
        cli
        rts

        ; 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
setcolor:
        ;ldy     #0              ; is 0
        bcs     @set
        ; restore old value
        lda     tmp1
        sta     (CRAM_PTR),y    ; vram
        rts
@set:
        ; save old value
        lda     (CRAM_PTR),y    ; vram
        sta     tmp1
        lda     soft80_internal_cellcolor
        sta     (CRAM_PTR),y    ; vram
        rts

        .rodata
nibble: .byte $f0, $0f

;-------------------------------------------------------------------------------
; force the init constructor to be imported

        .import soft80_init
conio_init      = soft80_init