OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [boot_tb/] [DisplayChar.asm] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 robfinch
; ============================================================================
2
;        __
3
;   \\__/ o\    (C) 2015  Robert Finch, Stratford
4
;    \  __ /    All rights reserved.
5
;     \/_//     robfinch@finitron.ca
6
;       ||
7
;
8
;
9
; This source file is free software: you can redistribute it and/or modify
10
; it under the terms of the GNU Lesser General Public License as published
11
; by the Free Software Foundation, either version 3 of the License, or
12
; (at your option) any later version.
13
;
14
; This source file is distributed in the hope that it will be useful,
15
; but WITHOUT ANY WARRANTY; without even the implied warranty of
16
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
; GNU General Public License for more details.
18
;
19
; You should have received a copy of the GNU General Public License
20
; along with this program.  If not, see .
21
;
22
; ============================================================================
23
;
24
;------------------------------------------------------------------------------
25
; Display a character on the screen device
26
; Expects the processor to be in 16 bit mode with 16 bit acc and 16 bit indexes
27
;------------------------------------------------------------------------------
28
;
29
public DisplayChar:
30
;               push    c1
31
;               push    pregs
32
;               push    r2
33
;               push    r3
34
;               push    r4
35
                addui   r27,r27,#-40
36
                sws             c1,[r27]
37
                sws             pregs,8[r27]
38
                sw              r2,16[r27]
39
                sw              r3,24[r27]
40
                sw              r4,32[r27]
41
                ldi             r2,#8
42
                sc              r2,$FFDC0600
43
                zxb             r1,r1
44
                lb              r2,EscState
45
                tst             p0,r2
46
p0.lt   br              processEsc
47
                cmpi    p0,r1,#BS
48
p0.eq   br              doBackSpace
49
                cmpi    p0,r1,#$91      ; cursor right
50
p0.eq   br              doCursorRight
51
                cmpi    p0,r1,#$93      ; cursor left
52
p0.eq   br              doCursorLeft
53
                cmpi    p0,r1,#$90      ; cursor up
54
p0.eq   br              doCursorUp
55
                cmpi    p0,r1,#$92      ; cursor down
56
p0.eq   br              doCursorDown
57
                cmpi    p0,r1,#$99      ; delete
58
p0.eq   br              doDelete
59
                cmpi    p0,r1,#CR
60
p0.eq   br              doCR
61
                cmpi    p0,r1,#LF
62
p0.eq   br              doLF
63
                cmpi    p0,r1,#$94      ; cursor home
64
p0.eq   br              doCursorHome
65
                cmpi    p0,r1,#ESC
66
p0.ne   br              _0003
67
                ldi             r1,#1
68
                sb              r1,EscState
69
exitDC:
70
;               pop             r4
71
;               pop             r3
72
;               pop             r2
73
;               pop             pregs
74
;               pop             c1
75
                lws             c1,[r27]
76
                lws             pregs,8[r27]
77
                lw              r2,16[r27]
78
                lw              r3,24[r27]
79
                lw              r4,32[r27]
80
                addui   r27,r27,#40
81
                rts
82
_0003:
83
                bsr             AsciiToScreen
84
                lhu             r2,NormAttr
85
                or              r1,r1,r2
86
                lcu             r3,VideoPos
87
                lhu             r2,Vidptr
88
                ldi             r4,#9
89
                sc              r4,$FFDC0600
90
                sh              r1,hs:[r2+r3*4]
91
                lcu             r1,CursorX
92
                addui   r1,r1,#1
93
                lcu             r2,Textcols
94
                cmp             p0,r1,r2
95
p0.ltu  br              .0001
96
                sc              r0,CursorX
97
                lcu             r1,CursorY
98
                addui   r1,r1,#1
99
                lcu             r2,Textrows
100
                cmp             p0,r1,r2
101
p0.ltu  sc              r1,CursorY
102
p0.ltu  bsr             SyncVideoPos    ; wont affect p0
103
p0.ltu  br              exitDC
104
                bsr             SyncVideoPos
105
                bsr             ScrollUp
106
                br              exitDC
107
.0001:
108
                sc              r1,CursorX
109
                bsr             SyncVideoPos
110
                br              exitDC
111
 
112
doCR:
113
                sc              r0,CursorX
114
                bsr             SyncVideoPos
115
                br              exitDC
116
doLF:
117
                lcu             r1,CursorY
118
                addui   r1,r1,#1
119
                lcu             r2,Textrows
120
                cmp             p1,r1,r2
121
p1.ge   bsr             ScrollUp
122
p1.ge   br              exitDC
123
                sc              r1,CursorY
124
                bsr             SyncVideoPos
125
                br              exitDC
126
 
127
processEsc:
128
                lb              r2,EscState
129
                cmpi    p0,r2,#-1
130
p0.ne   br              .0006
131
                cmpi    p0,r1,#'T'      ; clear to EOL
132
p0.ne   br              .0003
133
                lcu             r3,VideoPos
134
                lcu             r2,CursorX
135
                addui   r2,r2,#1
136
.0001:
137
                lcu             r1,Textcols
138
                cmp             p0,r2,r1
139
p0.ge   br              .0002
140
                ldi             r1,#' '
141
                lhu             r4,NormAttr
142
                or              r1,r1,r4
143
                lhu             r4,Vidptr
144
                sh              r1,hs:[r4+r3*4]
145
                addui   r2,r2,#1
146
                addui   r3,r3,#1
147
                br              .0001
148
.0002:
149
                sb              r0,EscState
150
                br              exitDC
151
 
152
.0003:
153
                cmpi    p0,r1,#'W'
154
p0.eq   sb              r0,EscState
155
p0.eq   br              doDelete
156
                cmpi    p0,r1,#'`'
157
p0.eq   ldi             r1,#-2
158
p0.eq   sb              r1,EscState
159
p0.eq   br              exitDC
160
                cmp             p0,r1,#'('
161
p0.eq   ldi             r1,#-3
162
p0.eq   sb              r1,EscState
163
p0.eq   br              exitDC
164
.0008:
165
                sb              r0,EscState
166
                br              exitDC
167
.0006:
168
                cmpi    p0,r2,#-2
169
p0.ne   br              .0007
170
                sb              r0,EscState
171
                cmpi    p0,r1,#'1'
172
p0.eq   bsr             CursorOn
173
p0.eq   br              exitDC
174
                cmpi    p0,r1,#'0'
175
p0.eq   bsr             CursorOff
176
                br              exitDC
177
.0007:
178
                cmpi    p0,r2,#-3
179
p0.ne   br              .0009
180
                cmpi    p0,r1,#ESC
181
p0.ne   br              .0008
182
                ldi             r1,#-4
183
                sb              r1,EscState
184
                br              exitDC
185
.0009:
186
                cmpi    p0,r2,#-4
187
p0.ne   br              .0010
188
                cmpi    p0,r1,#'G'
189
p0.ne   br              .0008
190
                ldi             r1,#-5
191
                sb              r1,EscState
192
                br              exitDC
193
.0010:
194
                cmpi    p0,r2,#-5
195
p0.ne   br              .0008
196
                sb              r0,EscState
197
                cmpi    p0,r1,#'4'
198
p0.ne   br              .0011
199
                lhu             r1,NormAttr
200
                mov             r2,r1
201
                shli    r1,r1,#9
202
                andi    r1,r1,#%111111111_000000000_00_00000000
203
                shrui   r2,r2,#9
204
                andi    r2,r2,#%000000000_111111111_00_00000000
205
                or              r1,r1,r2
206
                sh              r1,NormAttr
207
                br              exitDC
208
.0011:
209
                cmpi    p0,r1,#'0'
210
p0.ne   br              .0012
211
                ; Light grey on dark grey
212
                ldi             r1,#%001001001_011011011_00_00000000
213
                sh              r1,NormAttr
214
                br              exitDC
215
.0012:
216
                ; Light grey on dark grey
217
                ldi             r1,#%001001001_011011011_00_00000000
218
                sh              r1,NormAttr
219
                br              exitDC
220
 
221
doBackSpace:
222
                lc              r2,CursorX
223
                tst             p0,r2
224
p0.eq   br              exitDC          ; Can't backspace anymore
225
                lcu             r3,VideoPos
226
.0002:
227
                lh              r4,Vidptr
228
                lh              r1,hs:[r4+r3*4]
229
                addui   r3,r3,#-1
230
                sh              r1,hs:[r4+r3*4]
231
                addui   r3,r3,#2
232
                lc              r4,Textcols
233
                addui   r2,r2,#1
234
                cmp             p0,r2,r4
235
p0.ne   br              .0002
236
.0003:
237
                ldi             r1,#' '
238
                lh              r4,NormAttr
239
                or              r1,r1,r4
240
                lh              r4,Vidptr
241
                sh              r1,hs:[r4+r3*4]
242
                inc             CursorX,#-1
243
                bsr             SyncVideoPos
244
                br              exitDC
245
 
246
; Deleting a character does not change the video position so there's no need
247
; to resynchronize it.
248
 
249
doDelete:
250
                lc              r2,CursorX
251
                lh              r3,VideoPos
252
.0002:
253
                addui   r2,r2,#1
254
                lc              r4,Textcols
255
                cmp             p0,r2,r4
256
p0.ge   br              .0001
257
                addui   r2,r2,#-1
258
                addui   r3,r3,#1
259
                lh              r4,Vidptr
260
                lh              r1,hs:[r4+r3*4]
261
                addui   r3,r3,#-1
262
                sh              r1,hs:[r4+r3*4]
263
                addui   r3,r3,#1
264
                addui   r2,r2,#1
265
                br              .0002
266
.0001:
267
                ldi             r1,#' '
268
                lh              r2,NormAttr
269
                or              r1,r1,r2
270
                sh              r1,hs:[r4+r3*4]
271
                br              exitDC
272
 
273
doCursorHome:
274
                lcu             r1,CursorX
275
                tst             p0,r1
276
p0.eq   br              doCursor1
277
                sc              r0,CursorX
278
                bsr             SyncVideoPos
279
                br              exitDC
280
doCursorRight:
281
                lcu             r1,CursorX
282
                addui   r1,r1,#1
283
                lcu             r2,Textcols
284
                cmp             p0,r1,r2
285
p0.ge   br              exitDC
286
doCursor2:
287
                sc              r1,CursorX
288
                bsr             SyncVideoPos
289
                br              exitDC
290
doCursorLeft:
291
                lcu             r1,CursorX
292
                tst             p0,r1
293
p0.eq   br              exitDC
294
                subui   r1,r1,#1
295
                br              doCursor2
296
doCursorUp:
297
                lcu             r1,CursorY
298
                tst             p0,r1
299
p0.eq   br              exitDC
300
                subui   r1,r1,#1
301
                br              doCursor1
302
doCursorDown:
303
                lcu             r1,CursorY
304
                addui   r1,r1,#1
305
                lcu             r2,Textrows
306
p0.ge   br              exitDC
307
doCursor1:
308
                sc              r1,CursorY
309
                bsr             SyncVideoPos
310
                br              exitDC
311
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.