]> git.sur5r.net Git - cc65/blob - libsrc/geos-common/conio/cputc.s
Renamed to '--no-crt-lib'
[cc65] / libsrc / geos-common / conio / cputc.s
1 ;
2 ; Maciej 'YTM/Elysium' Witkowiak
3 ;
4 ; 27.10.2001
5 ; 06.03.2002
6 ; 25.07.2005
7
8 ; void cputcxy (unsigned char x, unsigned char y, char c);
9 ; void cputc (char c);
10
11 ; TODO:
12 ; TAB (should be implemented)
13 ; other special characters directly from keyboard are unsafe, though some might be
14 ; implemented:
15 ; HOME, UPLINE, ULINEON, ULINEOFF, REV_ON, REV_OFF, BOLDON, ITALICON, OUTLINEON, PLAINTEXT
16 ; and cursor movement, maybe stuff like INSERT too
17 ;
18 ; these must be ignored:
19 ; ESC_GRAPHICS, ESC_RULER, GOTOX, GOTOY, GOTOXY, NEWCARDSET, all 1..8
20 ;
21 ; note that there are conflicts between control characters and keyboard:
22 ; HOME = KEY_ENTER, KEY_HOME = REV_ON, 
23 ; UPLINE = ?, KEY_UPARROW = GOTOY, ...
24
25             .export _cputcxy, _cputc
26             .import gotoxy, fixcursor
27             .import xsize,ysize
28             .importzp cursor_x, cursor_y, cursor_c, cursor_r
29
30             .include "const.inc"
31             .include "geossym.inc"
32             .include "jumptab.inc"
33
34 _cputcxy:
35         pha                     ; Save C
36         jsr gotoxy              ; Set cursor, drop x and y
37         pla                     ; Restore C
38
39 ; Plot a character - also used as internal function
40
41 _cputc:
42         tax                     ; save character
43 ; some characters 0-31 are not safe for PutChar
44         cmp #$20
45         bcs L1
46         cmp #CR
47         beq do_cr
48         cmp #LF
49         beq do_lf
50         cmp #KEY_DELETE
51         bne L0
52         ldx #BACKSPACE
53         sec
54         bcs L2
55 L0:     rts
56
57 L1:     clc
58 L2:     php
59         lda cursor_x
60         sta r11L
61         lda cursor_x+1
62         sta r11H
63         lda cursor_y
64         clc
65         adc #6                  ; 6 pixels down to the baseline
66         sta r1H
67         txa
68         jsr PutChar
69         plp
70         bcs fix_cursor
71
72         inc cursor_c
73         lda cursor_c
74         cmp xsize               ; hit right margin?
75         bne fix_cursor
76         lda #0                  ; yes - do cr+lf
77         sta cursor_c
78 do_lf:  inc cursor_r
79         lda cursor_r
80         cmp ysize               ; hit bottom margin?
81         bne fix_cursor
82         dec cursor_r            ; yes - stay in the last line
83
84 fix_cursor:
85         jmp fixcursor
86
87 do_cr:  lda #0
88         sta cursor_c
89         beq fix_cursor