Mercurial > hg > index.cgi
comparison src/consscr.s @ 73:2d52cd154ed1
Split some code into separate files for easier management
Because the source for lwbasic is so large, split it into several
different files to make it easier to navigate and modify. This is
part one of the split.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 06 Aug 2023 00:12:29 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
72:f492fa6f6dc8 | 73:2d52cd154ed1 |
---|---|
1 *pragmapush list | |
2 *pragma list | |
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4 ; Console screen output driver | |
5 ; | |
6 ; Clear screen | |
7 console_clear ldb #0x60 ; VDG space character | |
8 ldx #textscreen ; point to text screen | |
9 stx console_curptr ; set cursor pointer to start of screen | |
10 console_clear0 stb ,x+ ; blank a character | |
11 cmpx #textscreen+0x200 ; end of screen? | |
12 blo console_clear0 ; brif not | |
13 rts | |
14 ; Output NUL terminated string | |
15 console_outstr0 bsr console_outchr ; output the character | |
16 console_outstr lda ,x+ ; get byte from string | |
17 bne console_outstr0 ; brif not end of string | |
18 rts | |
19 ; Output NUL terminated string followed by a newline | |
20 console_outstrn bsr console_outstr ; output the string | |
21 ; fallthrough intentional | |
22 ; Output a newline (CR LF) | |
23 console_outnl lda #0x0d ; do the CR | |
24 bsr console_outchr | |
25 lda #0x0a ; do the LF | |
26 ; fallthrough intentional | |
27 ; Output a single character to the screen; enter with character in A | |
28 console_outchr pshs d,x ; save registers | |
29 ldx console_curptr ; get current cursor pointer | |
30 cmpa #0x20 ; printable character? | |
31 blo console_outchr5 ; brif not | |
32 tsta ; is it a graphics block? | |
33 bmi console_outchr1 ; brif so - don't do anything to it | |
34 cmpa #0x40 ; number or most non-alpha characters? | |
35 blo console_outchr0 ; brif so - will need to flip bit 6 | |
36 cmpa #0x60 ; upper case? | |
37 blo console_outchr1 ; brif so - don't need to do anything to it | |
38 anda #0xdf ; clear bit 5 of lower case; moves it to bottom of character set | |
39 console_outchr0 eora #0x40 ; flip bit 6 - the "inversion" bit | |
40 console_outchr1 sta ,x+ ; stick it on screen | |
41 console_outchr2 stx console_curptr ; save new cursor pointer | |
42 cmpx #textscreen+0x200 ; end of screen? | |
43 blo console_outchr4 ; brif not | |
44 leax -32,x ; move pointer back one line | |
45 stx console_curptr | |
46 ldx #textscreen ; point to start of screen | |
47 console_outchr3 ldd 32,x ; get bytes from next line | |
48 std ,x++ ; stick them here | |
49 cmpx #textscreen+0x1e0 ; at last row? | |
50 blo console_outchr3 ; brif not | |
51 ldb #0x60 ; space character for VDG screen | |
52 bsr console_clear0 ; blank out last row (borrowing screen clear loop) | |
53 console_outchr4 puls d,x,pc ; restore registers and return | |
54 console_outchr5 cmpa #0x0c ; form feed? | |
55 bne console_outchr6 ; brif not | |
56 bsr console_clear ; clear screen | |
57 puls d,x,pc ; restore registers and return | |
58 console_outchr6 cmpa #0x0d ; carriage return? | |
59 bne console_outchr7 ; brif not | |
60 ldb console_curptr+1 ; get current screen pointer LSB | |
61 andb #0xe0 ; reset offset to start of line | |
62 stb console_curptr+1 ; save new pointer LSB | |
63 puls d,x,pc ; restore registers and return | |
64 console_outchr7 cmpa #0x0a ; line feed? | |
65 bne console_outchr8 ; brif not | |
66 ldx console_curptr ; get cursor pointer | |
67 leax 32,x ; move it forward exactly one line | |
68 bra console_outchr2 ; go update stuff check for scroll | |
69 console_outchr8 cmpa #0x08 ; backspace? | |
70 bne console_outchr9 ; brif not | |
71 cmpx #textscreen ; at start of screen? | |
72 beq console_outchr4 ; brif so - backspace does nothing | |
73 leax -1,x ; back up pointer (backspace is non-destructive) | |
74 bra console_outchr2 ; go update pointers, etc. | |
75 console_outchr9 cmpa #0x09 ; TAB character? | |
76 bne console_outchr4 ; brif not | |
77 ldb console_curptr ; get LSB of pointer | |
78 andb #7 ; 8 space tabs - only keep low 3 bits | |
79 lda #0x60 ; space character (tab is destructive) | |
80 console_outchra sta ,x+ ; put a space out | |
81 incb ; bump counter | |
82 cmpb #8 ; at next tab stop? | |
83 blo console_outchra ; brif not | |
84 bra console_outchr2 ; go update details and check for scroll | |
85 *pragmapop list |