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

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [boot_tb/] [video.asm] - Blame information for rev 46

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

Line No. Rev Author Line
1 28 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
; Video BIOS routines don't touch the data segment. It is assumed that a
24
; different data segment will be is use for each text controller.
25
; ============================================================================
26
 
27
;------------------------------------------------------------------------------
28
;------------------------------------------------------------------------------
29
 
30
public VBClearScreen:
31
                ldi             r1,#' '
32
                lh              r2,NormAttr
33
                andi    r2,r2,#-1024
34
                or              r2,r2,r1
35
                ldis    lc,#SCRSZ-1
36
                lh              r1,Vidptr
37
;               ldi             r1,#TEXTSCR
38
                stset.hi        r2,hs:[r1]
39
                rts
40
endpublic
41
 
42
public VBClearScreen2:
43
                ldis    lc,#SCRSZ-1
44
                ldi             r2,#' '|%000011000_111111111_00_00000000;
45
                ldi             r1,#TEXTSCR2
46
                stset.hi        r2,hs:[r1]
47
                rts
48
endpublic
49
 
50
;------------------------------------------------------------------------------
51
; Scroll the screen upwards.
52
;------------------------------------------------------------------------------
53
 
54
ScrollUp:
55
                addui   r31,r31,#-8
56
                sws             c1,[r31]
57
                mov             r1,r0
58
                mov             r2,r0
59
                lcu             r3,Textcols
60
                lcu             r4,Textrows
61
                ldi             r5,#1
62
                bsr             VBScrollWindowUp
63
                addui   r1,r4,#-1
64
                bsr             BlankLine
65
                lws             c1,[r31]
66
                addui   r31,r31,#8
67
                rts
68
 
69
;------------------------------------------------------------------------------
70
; Blank out a line on the screen.
71
;
72
; Parameters:
73
;       r1 = line number to blank
74
; Trashes:
75
;       r2,r3,r4
76
;------------------------------------------------------------------------------
77
 
78
BlankLine:
79
                lcu             r2,Textcols
80
                mulu    r1,r1,r2
81
                _4addu  r3,r1,r0
82
                lh              r1,NormAttr
83
                ori             r1,r1,#$20
84
                lh              r4,Vidptr
85
.0001:
86
                sh              r1,[r4+r3]
87
                addui   r3,r3,#4
88
                addui   r2,r2,#-1
89
                tst             p0,r2
90
p0.ne   br              .0001
91
                rts
92
 
93
;------------------------------------------------------------------------------
94
; Turn cursor on or off.
95
;------------------------------------------------------------------------------
96
 
97
VBCursorOn:
98
CursorOn:
99
                addui   r31,r31,#-16
100
                sw              r1,zs:8[r31]
101
                sw              r2,zs:[r31]
102
                lh              r2,Vidregs
103
                ldi             r1,#$40
104
                sh              r1,hs:32[r2]
105
                ldi             r1,#$1F
106
                sh              r1,hs:36[r2]
107
                lw              r2,zs:[r31]
108
                lw              r1,zs:8[r31]
109
                addui   r31,r31,#16
110
                mov             r6,r0
111
                rts
112
 
113
VBCursorOff:
114
CursorOff:
115
                addui   r31,r31,#-16
116
                sw              r1,zs:8[r31]
117
                sw              r2,zs:[r31]
118
                lh              r2,Vidregs
119
                ldi             r1,#$20
120
                sh              r1,hs:32[r2]
121
                mov             r1,r0
122
                sh              r1,hs:36[r2]
123
                lw              r2,zs:[r31]
124
                lw              r1,zs:8[r31]
125
                addui   r31,r31,#16
126
                mov             r6,r0
127
                rts
128
 
129
;------------------------------------------------------------------------------
130
; Get the number of text rows and columns from the video controller.
131
;------------------------------------------------------------------------------
132
 
133
GetTextRowscols:
134
                lh              r2,Vidregs
135
                lvc             r1,hs:0[r2]
136
                sc              r1,Textcols
137
                lvc             r1,hs:4[r2]
138
                sc              r1,Textrows
139
                rts
140
 
141
;------------------------------------------------------------------------------
142
; Set cursor to home position.
143
;------------------------------------------------------------------------------
144
 
145
public HomeCursor:
146
                sc              r0,CursorX
147
                sc              r0,CursorY
148
endpublic
149
 
150
;------------------------------------------------------------------------------
151
; SyncVideoPos:
152
;
153
; Synchronize the absolute video position with the cursor co-ordinates.
154
; Does not modify any predicates. Leaf routine.
155
;------------------------------------------------------------------------------
156
 
157
SyncVideoPos:
158
                addui   r31,r31,#-32
159
                sw              r1,16[r31]                      ; save off some working regs
160
                sw              r2,8[r31]
161
                sw              r3,[r31]
162
                sws             hs,24[r31]
163
                ldis    hs,#$FFD00000
164
                ldi             r1,#5
165
                sc              r1,hs:LEDS
166
                lc              r2,CursorY
167
                lc              r3,Textcols
168
                mulu    r1,r2,r3
169
                lc              r2,CursorX
170
                addu    r1,r1,r2
171
                sc              r1,VideoPos
172
                lh              r3,Vidregs                      ; r3 = address of video registers
173
                sh              r1,hs:44[r3]            ; Update the position in the text controller
174
                lws             hs,24[r31]
175
                lw              r3,[r31]                        ; restore the regs
176
                lw              r2,8[r31]
177
                lw              r1,16[r31]
178
                addui   r31,r31,#32
179
                rts
180
 
181
;------------------------------------------------------------------------------
182
; Video BIOS
183
; Video Exception #10
184
;
185
; Parameters:
186
;       r1 to r5 as needed
187
;       r6 = Function
188
; Returns:
189
;       r6 = 0 if everything ok, otherwise BIOS error code
190
;
191
; 0x02 = Set Cursor Position    r1 = row, r2 = col
192
; 0x03 = Get Cursor position    returns r1 = row, r2 = col
193
; 0x06 = Scroll Window up               r1=left, r2=top, r3=right, r4=bottom, r5=#lines
194
; 0x0A = Display character at cursor position, r1 = char, r2 = # times
195
; 0x14 = Display String r1 = pointer to string
196
; 0x15 = Display number r1 = number, r2 = # digits
197
; 0x17 = Display Word r1 as hex = word
198
; 0x18 = Display Half word as hex r1 = half word
199
; 0x19 = Display Charr char in hex r1 = char
200
; 0x1A = Display Byte in hex r1 = byte
201
; 0x20 = Convert ascii to screen r1 = char to convert
202
; 0x21 = Convert screen to ascii r1 = char to convert
203
; 0x22 = clear screen
204
; 0x23 = set attribute  r1 = attribute
205
; 0x24 = turn cursor on
206
; 0x25 = turn cursor off
207
;------------------------------------------------------------------------------
208
 
209
MAX_VIDEO_BIOS_CALL = 0x25
210
 
211
                code
212
            align   2
213
VideoBIOS_FuncTable:
214
                dc      VBUnsupported  ; 0x00
215
                dc      VBUnsupported
216
                dc      VBSetCursorPos ; 0x02
217
                dc      VBGetCursorPos ; 0x03
218
                dc      VBUnsupported
219
                dc      VBUnsupported
220
                dc      VBScrollWindowUp        ; 0x06
221
                dc      VBUnsupported
222
                dc      VBUnsupported   ; 0x08
223
                dc      VBUnsupported
224
                dc      VBDisplayCharRep
225
                dc      VBUnsupported
226
                dc      VBUnsupported
227
                dc      VBUnsupported
228
                dc      VBUnsupported
229
                dc      VBUnsupported
230
                dc      VBUnsupported   ; 0x10
231
                dc      VBUnsupported
232
                dc      VBUnsupported
233
                dc      VBUnsupported
234
                dc      VBDisplayString
235
                dc      PRTNUM
236
                dc      VBUnsupported
237
                dc      VBDispWord
238
                dc      VBDispHalf
239
                dc      VBDispCharr
240
                dc      VBDispByte
241
                dc      VBUnsupported
242
                dc      VBUnsupported
243
                dc      VBUnsupported
244
                dc      VBUnsupported
245
                dc      VBUnsupported
246
                dc      VBAsciiToScreen ; 0x20
247
                dc      VBScreenToAscii
248
                dc      VBClearScreen
249
                dc      VBSetNormAttribute
250
                dc              VBCursorOn
251
                dc              VBCursorOff             ; 0x25
252
 
253
VideoBIOSCall:
254
                addui   r31,r31,#-16
255
                sws             c1,[r31]
256
                sws             hs,8[r31]
257
                ldis    hs,#$FFD00000
258
                cmpi    p0,r6,#MAX_VIDEO_BIOS_CALL
259
p0.ge   br              .badCallno
260
                jci             c1,cs:VideoBIOS_FuncTable[r6]
261
.0004:
262
;               bsr     UnlockVideoBIOS
263
                lws             c1,[r31]
264
                lws             hs,8[r31]
265
                addui   r31,r31,#16
266
                rte
267
.badCallno:
268
                ldi     r2,#E_BadFuncno
269
                br      .0004
270
 
271
;------------------------------------------------------------------------------
272
;------------------------------------------------------------------------------
273
 
274
VBUnsupported:
275
                ldi     r2,#E_Unsupported
276
                rts
277
 
278
VBSetCursorPos:
279
                addui   r31,r31,#-8
280
                sws             c1,[r31]
281
                sc              r1,CursorY
282
                sc              r2,CursorX
283
                bsr             SyncVideoPos
284
                mov             r6,r0
285
                lws             c1,[r31]
286
                addui   r31,r31,#8
287
                rts
288
 
289
VBGetCursorPos:
290
                lcu             r1,CursorY
291
                lcu             r2,CursorX
292
                mov             r6,r0
293
                rts
294
 
295
;------------------------------------------------------------------------------
296
; Set the attribute to use for subsequent video output.
297
;------------------------------------------------------------------------------
298
 
299
VBSetNormAttribute:
300
                sh              r1,NormAttr
301
                mov             r6,r0
302
                rts
303
 
304
;------------------------------------------------------------------------------
305
;------------------------------------------------------------------------------
306
 
307
VBDisplayCharRep:
308
                addui   r31,r31,#-8
309
                sws             c1,[r31]
310
                tst             p0,r2                   ; check if zero chars requested
311
p0.eq   br              .0002
312
                addui   r31,r31,#-16
313
                sws             c1,zs:[r31]
314
                sws             lc,zs:8[r31]
315
                addui   r2,r2,#-1
316
                mtspr   lc,r2                   ; loop count is one less
317
                addui   r2,r2,#1                ; leaves r2 unchanged
318
.0001:
319
                bsr             VBDisplayChar
320
                loop    .0001
321
                lws             lc,zs:8[r31]
322
                lws             c1,zs:[r31]
323
                addui   r31,r31,#16
324
.0002:
325
                lws             c1,[r31]
326
                addui   r31,r31,#8
327
                mov             r6,r0
328
                rts
329
 
330
;------------------------------------------------------------------------------
331
; Convert Ascii character to screen character.
332
;------------------------------------------------------------------------------
333
 
334
VBAsciiToScreen:
335
                zxb             r1,r1
336
                cmp             p0,r1,#' '
337
p0.le   ori             r1,r1,#$100
338
p0.le   br              .0003
339
                cmp             p0,r1,#$5B                      ; special test for  [ ] characters
340
p0.eq   br              .0002
341
                cmp             p0,r1,#$5D
342
p0.eq   br              .0002
343
                ori             r1,r1,#$100
344
                biti    p0,r1,#$20                      ; if bit 5 isn't set
345
p0.eq   br              .0003
346
                biti    p0,r1,#$40                      ; or bit 6 isn't set
347
p0.ne   andi    r1,r1,#$19F
348
.0003:
349
                mov             r6,r0
350
                rts
351
.0002:
352
                andi    r1,r1,#~$40
353
                mov             r6,r0
354
                rts
355
 
356
;------------------------------------------------------------------------------
357
; Convert screen character to ascii character
358
;------------------------------------------------------------------------------
359
;
360
VBScreenToAscii:
361
                zxb             r1,r1
362
                cmpi    p0,r1,#$1B
363
p0.eq   br              .0004
364
                cmpi    p0,r1,#$1D
365
p0.eq   br              .0004
366
                cmpi    p0,r1,#27
367
p0.le   addui   r1,r1,#$60
368
                mov             r6,r0
369
                rts
370
.0004:
371
                ori             r1,r1,#$40
372
                mov             r6,r0
373
                rts
374
 
375
;------------------------------------------------------------------------------
376
; Display a string on the screen.
377
; Parameters:
378
;       r1 = linear address pointer to string
379
;------------------------------------------------------------------------------
380
 
381
public VBDisplayString:
382
                addui   r31,r31,#-32
383
                sws             c1,[r31]                        ; save return address
384
                sws             lc,8[r31]               ; save loop counter
385
                sw              r2,16[r31]
386
                sws             p0,24[r31]
387
                ldis    lc,#$FFF                ; set max 4k
388
                mov             r2,r1
389
.0001:
390
                lbu             r1,zs:[r2]
391
                tst             p0,r1
392
p0.eq   br              .0002
393
                bsr             VBDisplayChar
394
                addui   r2,r2,#1
395
                loop    .0001
396
.0002:
397
                lws             c1,[r31]                        ; restore return address
398
                lws             lc,8[r31]               ; restore loop counter
399
                lw              r2,16[r31]
400
                lws             p0,24[r31]
401
                addui   r31,r31,#32
402
                mov             r6,r0
403
                rts
404
endpublic
405
 
406
;------------------------------------------------------------------------------
407
;------------------------------------------------------------------------------
408
 
409
VBDispWord:
410
                addui   r31,r31,#-8
411
                sws             c1,[r31]
412
                roli    r1,r1,#32
413
                bsr             VBDispHalf
414
                roli    r1,r1,#32
415
                bsr             VBDispHalf
416
                lws             c1,[r31]
417
                addui   r31,r31,#8
418
                rts
419
 
420
VBDispHalf:
421
                addui   r31,r31,#-8
422
                sws             c1,[r31]
423
                rori    r1,r1,#16
424
                bsr             VBDispCharr
425
                roli    r1,r1,#16
426
                bsr             VBDispCharr
427
                lws             c1,[r31]
428
                addui   r31,r31,#8
429
                rts
430
 
431
VBDispCharr:
432
                addui   r31,r31,#-8
433
                sws             c1,[r31]
434
                rori    r1,r1,#8
435
                bsr             VBDispByte
436
                roli    r1,r1,#8
437
                bsr             VBDispByte
438
                lws             c1,[r31]
439
                addui   r31,r31,#8
440
                rts
441
 
442
VBDispByte:
443
                addui   r31,r31,#-8
444
                sws             c1,[r31]
445
                rori    r1,r1,#4
446
                bsr             VBDispNybble
447
                roli    r1,r1,#4
448
                bsr             VBDispNybble
449
                lws             c1,[r31]
450
                addui   r31,r31,#8
451
                rts
452
 
453
VBDispNybble:
454
                addui   r31,r31,#-16
455
                sws             c1,[r31]
456
                sw              r1,8[r31]
457
                andi    r1,r1,#15
458
                cmpi    p0,r1,#10
459
p0.ge   addui   r1,r1,#7
460
                ori             r1,r1,#'0'
461
                bsr             VBDisplayChar
462
                lws             c1,[r31]
463
                lw              r1,8[r31]
464
                addui   r31,r31,#16
465
                mov             r6,r0
466
                rts
467
 
468
;------------------------------------------------------------------------------
469
; 'PRTNUM' prints the 64 bit number in r1, leading blanks are added if
470
; needed to pad the number of spaces to the number in r2.
471
; However, if the number of digits is larger than the no. in
472
; r2, all digits are printed anyway. Negative sign is also
473
; printed and counted in, positive sign is not.
474
;
475
; r1 = number to print
476
; r2 = number of digits
477
; Register Usage
478
;       r5 = number of padding spaces
479
;------------------------------------------------------------------------------
480
PRTNUM:
481
                addui   r31,r31,#-48
482
                sws             c1,zs:[r31]
483
                sw              r3,zs:8[r31]
484
                sw              r5,zs:16[r31]
485
                sw              r6,zs:24[r31]
486
                sw              r7,zs:32[r31]
487
                lw              r4,zs:40[r31]
488
                ldi             r7,#NUMWKA      ; r7 = pointer to numeric work area
489
                mov             r6,r1           ; save number for later
490
                mov             r5,r2           ; r5 = min number of chars
491
                tst             p0,r1           ; is it negative? if not
492
p0.lt   subu    r1,r0,r1        ; else make it positive
493
p0.lt   addui   r5,r5,#-1       ; one less for width count
494
PN2:
495
        ldi             r3,#10
496
PN1:
497
                divui   r3,r1,#10       ; r3 = r1/10 divide by 10
498
                mului   r4,r3,#10
499
                subu    r2,r1,r4        ; r2 = r1 mod 10
500
                mov             r1,r3           ; r1 = r1 / 10
501
                addui   r2,r2,#'0'      ; convert remainder to ascii
502
                sb              r2,[r7]         ; and store in buffer
503
                addui   r7,r7,#1
504
                addui   r5,r5,#-1       ; decrement width
505
                tst             p0,r1
506
p0.ne   br              PN1
507
PN6:
508
                tst             p0,r5   ; test pad count, skip padding if not needed
509
p0.le   br              PN4
510
                ldi             r1,#' '
511
                mov             r2,r5
512
                bsr             VBDisplayCharRep        ; display the required leading spaces
513
PN4:
514
                tst             p0,r6   ; is number negative?
515
p0.ge   br              PN5
516
                ldi             r1,#'-' ; if so, display the sign
517
                bsr             VBDisplayChar
518
PN5:
519
                subui   r7,r7,#1
520
                lb              r1,[r7]         ; now unstack the digits and display
521
                bsr             VBDisplayChar
522
                cmpi    p0,r7,#NUMWKA
523
p0.gt   br              PN5
524
PNRET:
525
                lws             c1,zs:[r31]
526
                lw              r3,zs:8[r31]
527
                lw              r5,zs:16[r31]
528
                lw              r6,zs:24[r31]
529
                lw              r7,zs:32[r31]
530
                lw              r4,zs:40[r31]
531
                addui   r31,r31,#48
532
                mov             r6,r0
533
                rts
534
 
535
;------------------------------------------------------------------------------
536
; Parameters:
537
;       r1 = row
538
;       r2 = col
539
; Returns:
540
;       r1 = char+attrib
541
;------------------------------------------------------------------------------
542
 
543
VBGetCharAt:
544
                shli    r1,r1,#1
545
                lcu             r1,cs:LineTbl[r1]
546
                _4addu  r1,r2,r1
547
                lhu             r3,Vidptr
548
                lhu             r1,[r3+r1]
549
                mov             r6,r0
550
                rts
551
 
552
;------------------------------------------------------------------------------
553
; Parameters:
554
;       r1 = left
555
;       r2 = top
556
;       r3 = right
557
;       r4 = bottom
558
;------------------------------------------------------------------------------
559
 
560
VBScrollWindowUp:
561
                addui   r31,r31,#-96
562
                sw              r1,[r31]
563
                sw              r2,8[r31]
564
                sw              r3,16[r31]
565
                sw              r4,24[r31]
566
                sw              r5,32[r31]
567
                sw              r7,48[r31]
568
                sw              r9,56[r31]
569
                sw              r10,64[r31]
570
                sw              r11,72[r31]
571
                sw              r12,80[r31]
572
                sw              r13,88[r31]
573
                mov             r7,r1                           ; r7 = left
574
                mov             r6,r2
575
                lhu             r11,Vidptr
576
                lcu             r13,Textcols            ; r13 = # cols
577
.next:
578
                mulu    r9,r2,r13                       ; r9 = row offset
579
                _4addu  r9,r9,r0                        ; r9 *= 4 for half-words
580
                _4addu  r9,r1,r9                        ; r9 += col * 4
581
                mulu    r10,r13,r5                      ; r10 = #lines to scroll * #cols
582
                _4addu  r10,r10,r9                      ; r10 = 4* r10 + r9
583
                lhu             r12,[r11+r10]           ; r12 = char+atrrib
584
                sh              r12,[r11+r9]            ; mem = char + attrib
585
                ; Now increment the video position
586
                addui   r1,r1,#1
587
                cmp             p0,r1,r3        ; hit right edge ?
588
p0.eq   mov             r1,r7           ; if yes, reset back to left
589
p0.eq   addui   r2,r2,#1        ; and increment row
590
                cmp             p0,r2,r4        ; hit bottom ?
591
p0.ne   br              .next
592
                lw              r1,[r31]
593
                lw              r2,8[r31]
594
                lw              r3,16[r31]
595
                lw              r4,24[r31]
596
                lw              r5,32[r31]
597
                lw              r7,48[r31]
598
                lw              r9,56[r31]
599
                lw              r10,64[r31]
600
                lw              r11,72[r31]
601
                lw              r12,80[r31]
602
                lw              r13,88[r31]
603
                addui   r31,r31,#96
604
                mov             r6,r0
605
                rts
606
 
607
;------------------------------------------------------------------------------
608
; Display a character on the screen device
609
;------------------------------------------------------------------------------
610
;
611
public VBDisplayChar:
612
                addui   r31,r31,#-56
613
                sws             c1,[r31]
614
                sws             pregs,8[r31]
615
                sw              r1,16[r31]
616
                sw              r2,24[r31]
617
                sw              r3,32[r31]
618
                sw              r4,40[r31]
619
                sws             hs,48[r31]
620
                ldis    hs,#$FFD00000
621
                zxb             r1,r1
622
                lb              r2,EscState
623
                tst             p0,r2
624
p0.lt   br              processEsc
625
                cmpi    p0,r1,#_BS
626
p0.eq   br              doBackSpace
627
                cmpi    p0,r1,#$91      ; cursor right
628
p0.eq   br              doCursorRight
629
                cmpi    p0,r1,#$93      ; cursor left
630
p0.eq   br              doCursorLeft
631
                cmpi    p0,r1,#$90      ; cursor up
632
p0.eq   br              doCursorUp
633
                cmpi    p0,r1,#$92      ; cursor down
634
p0.eq   br              doCursorDown
635
                cmpi    p0,r1,#$99      ; delete
636
p0.eq   br              doDelete
637
                cmpi    p0,r1,#CR
638
p0.eq   br              doCR
639
                cmpi    p0,r1,#LF
640
p0.eq   br              doLF
641
                cmpi    p0,r1,#$94      ; cursor home
642
p0.eq   br              doCursorHome
643
                cmpi    p0,r1,#ESC
644
p0.ne   br              _0003
645
                ldi             r1,#1
646
                sb              r1,EscState
647
exitDC:
648
                lws             c1,[r31]
649
                lws             pregs,8[r31]
650
                lw              r1,16[r31]
651
                lw              r2,24[r31]
652
                lw              r3,32[r31]
653
                lw              r4,40[r31]
654
                lws             hs,48[r31]
655
                addui   r31,r31,#56
656
                mov             r6,r0
657
                rts
658
_0003:
659
                andi    r1,r1,#$7F
660
                bsr             VBAsciiToScreen
661
                lhu             r2,NormAttr
662
                andi    r2,r2,#-1024
663
                or              r1,r1,r2
664
                lcu             r3,VideoPos
665
                lhu             r2,Vidptr
666
                sh              r1,hs:[r2+r3*4]
667
                lcu             r1,CursorX
668
                addui   r1,r1,#1
669
                lcu             r2,Textcols
670
                cmp             p0,r1,r2
671
p0.ltu  br              .0001
672
                sc              r0,CursorX
673
                lcu             r1,CursorY
674
                addui   r1,r1,#1
675
                lcu             r2,Textrows
676
                cmp             p0,r1,r2
677
p0.ltu  sc              r1,CursorY
678
p0.ltu  bsr             SyncVideoPos    ; wont affect p0
679
p0.ltu  br              exitDC
680
                bsr             SyncVideoPos
681
                bsr             ScrollUp
682
                br              exitDC
683
.0001:
684
                sc              r1,CursorX
685
                bsr             SyncVideoPos
686
                br              exitDC
687
 
688
doCR:
689
                sc              r0,CursorX
690
                bsr             SyncVideoPos
691
                br              exitDC
692
doLF:
693
                lcu             r1,CursorY
694
                addui   r1,r1,#1
695
                lcu             r2,Textrows
696
                cmp             p1,r1,r2
697
p1.ge   bsr             ScrollUp
698
p1.ge   br              exitDC
699
                sc              r1,CursorY
700
                bsr             SyncVideoPos
701
                br              exitDC
702
 
703
processEsc:
704
                ldi             r4,#22
705
                sc              r4,hs:LEDS
706
                lb              r2,EscState
707
                cmpi    p0,r2,#-1
708
p0.ne   br              .0006
709
                cmpi    p0,r1,#'T'      ; clear to EOL
710
p0.ne   br              .0003
711
                lcu             r3,VideoPos
712
                lcu             r2,CursorX
713
                addui   r2,r2,#1
714
.0001:
715
                lcu             r1,Textcols
716
                cmp             p0,r2,r1
717
p0.ge   br              .0002
718
                ldi             r1,#' '
719
                lhu             r4,NormAttr
720
                or              r1,r1,r4
721
                lhu             r4,Vidptr
722
                sh              r1,hs:[r4+r3*4]
723
                addui   r2,r2,#1
724
                addui   r3,r3,#1
725
                br              .0001
726
.0002:
727
                sb              r0,EscState
728
                br              exitDC
729
 
730
.0003:
731
                cmpi    p0,r1,#'W'
732
p0.eq   sb              r0,EscState
733
p0.eq   br              doDelete
734
                cmpi    p0,r1,#'`'
735
p0.eq   ldi             r1,#-2
736
p0.eq   sb              r1,EscState
737
p0.eq   br              exitDC
738
                cmp             p0,r1,#'('
739
p0.eq   ldi             r1,#-3
740
p0.eq   sb              r1,EscState
741
p0.eq   br              exitDC
742
.0008:
743
                sb              r0,EscState
744
                br              exitDC
745
.0006:
746
                cmpi    p0,r2,#-2
747
p0.ne   br              .0007
748
                sb              r0,EscState
749
                cmpi    p0,r1,#'1'
750
p0.eq   bsr             CursorOn
751
p0.eq   br              exitDC
752
                cmpi    p0,r1,#'0'
753
p0.eq   bsr             CursorOff
754
                br              exitDC
755
.0007:
756
                cmpi    p0,r2,#-3
757
p0.ne   br              .0009
758
                cmpi    p0,r1,#ESC
759
p0.ne   br              .0008
760
                ldi             r1,#-4
761
                sb              r1,EscState
762
                br              exitDC
763
.0009:
764
                cmpi    p0,r2,#-4
765
p0.ne   br              .0010
766
                cmpi    p0,r1,#'G'
767
p0.ne   br              .0008
768
                ldi             r1,#-5
769
                sb              r1,EscState
770
                br              exitDC
771
.0010:
772
                cmpi    p0,r2,#-5
773
p0.ne   br              .0008
774
                sb              r0,EscState
775
                cmpi    p0,r1,#'4'
776
p0.ne   br              .0011
777
                lhu             r1,NormAttr
778
                mov             r2,r1
779
                shli    r1,r1,#9
780
                andi    r1,r1,#%111111111_000000000_00_00000000
781
                shrui   r2,r2,#9
782
                andi    r2,r2,#%000000000_111111111_00_00000000
783
                or              r1,r1,r2
784
                sh              r1,NormAttr
785
                br              exitDC
786
.0011:
787
                cmpi    p0,r1,#'0'
788
p0.ne   br              .0012
789
                ; Light grey on dark grey
790
                ldi             r1,#%001001001_011011011_00_00000000
791
                sh              r1,NormAttr
792
                br              exitDC
793
.0012:
794
                ; Light grey on dark grey
795
                ldi             r1,#%001001001_011011011_00_00000000
796
                sh              r1,NormAttr
797
                br              exitDC
798
 
799
doBackSpace:
800
                ldi             r4,#23
801
                sc              r4,hs:LEDS
802
                lc              r2,CursorX
803
                tst             p0,r2
804
p0.eq   br              exitDC          ; Can't backspace anymore
805
                lcu             r3,VideoPos
806
.0002:
807
                lh              r4,Vidptr
808
                lh              r1,hs:[r4+r3*4]
809
                addui   r3,r3,#-1
810
                sh              r1,hs:[r4+r3*4]
811
                addui   r3,r3,#2
812
                lc              r4,Textcols
813
                addui   r2,r2,#1
814
                cmp             p0,r2,r4
815
p0.ne   br              .0002
816
.0003:
817
                ldi             r1,#' '
818
                lh              r4,NormAttr
819
                or              r1,r1,r4
820
                lh              r4,Vidptr
821
                sh              r1,hs:[r4+r3*4]
822
                inc             CursorX,#-1
823
                bsr             SyncVideoPos
824
                br              exitDC
825
 
826
; Deleting a character does not change the video position so there's no need
827
; to resynchronize it.
828
 
829
doDelete:
830
                lc              r2,CursorX
831
                lh              r3,VideoPos
832
.0002:
833
                addui   r2,r2,#1
834
                lc              r4,Textcols
835
                cmp             p0,r2,r4
836
p0.ge   br              .0001
837
                addui   r2,r2,#-1
838
                addui   r3,r3,#1
839
                lh              r4,Vidptr
840
                lh              r1,hs:[r4+r3*4]
841
                addui   r3,r3,#-1
842
                sh              r1,hs:[r4+r3*4]
843
                addui   r3,r3,#1
844
                addui   r2,r2,#1
845
                br              .0002
846
.0001:
847
                ldi             r1,#' '
848
                lhu             r2,NormAttr
849
                or              r1,r1,r2
850
                lhu             r4,Vidptr
851
                sh              r1,hs:[r4+r3*4]
852
                br              exitDC
853
 
854
doCursorHome:
855
                lcu             r1,CursorX
856
                tst             p0,r1
857
p0.eq   br              doCursor1
858
                sc              r0,CursorX
859
                bsr             SyncVideoPos
860
                br              exitDC
861
doCursorRight:
862
                lcu             r1,CursorX
863
                addui   r1,r1,#1
864
                lcu             r2,Textcols
865
                cmp             p0,r1,r2
866
p0.ge   br              exitDC
867
doCursor2:
868
                sc              r1,CursorX
869
                bsr             SyncVideoPos
870
                br              exitDC
871
doCursorLeft:
872
                lcu             r1,CursorX
873
                tst             p0,r1
874
p0.eq   br              exitDC
875
                addui   r1,r1,#-1
876
                br              doCursor2
877
doCursorUp:
878
                lcu             r1,CursorY
879
                tst             p0,r1
880
p0.eq   br              exitDC
881
                addui   r1,r1,#-1
882
                br              doCursor1
883
doCursorDown:
884
                lcu             r1,CursorY
885
                addui   r1,r1,#1
886
                lcu             r2,Textrows
887
                cmp             p0,r1,r2
888
p0.ge   br              exitDC
889
doCursor1:
890
                sc              r1,CursorY
891
                bsr             SyncVideoPos
892
                br              exitDC
893
 
894
;------------------------------------------------------------------------------
895
;------------------------------------------------------------------------------
896
 
897
public VideoInit:
898
                ldi             r1,#84
899
                sc              r1,Textcols
900
                ldi             r1,#31
901
                sc              r1,Textrows
902
                ldi             r1,#%011000000_111111111_00_00000000
903
                sh              r1,NormAttr
904
                ldi             r1,#TEXTREG
905
                sh              r1,Vidregs
906
                ldi             r1,#TEXTSCR
907
                sh              r1,Vidptr
908
 
909
                ldi             r2,#TC1InitData
910
                ldis    lc,#11                          ; initialize loop counter ( one less)
911
                lhu             r3,Vidregs
912
.0001:
913
                lvh             r1,cs:[r2]
914
                sh              r1,hs:[r3]
915
                addui   r2,r2,#4
916
                addui   r3,r3,#4
917
                loop    .0001
918
                mov             r6,r0
919
                rts
920
endpublic
921
 
922
;------------------------------------------------------------------------------
923
; Initialize the second video controller.
924
; Meant to be called with a different data segment.
925
;------------------------------------------------------------------------------
926
 
927
public VideoInit2:
928
                ldi             r1,#84
929
                sc              r1,Textcols
930
                ldi             r1,#31
931
                sc              r1,Textrows
932
                ldi             r1,#%000011000_111111111_00_00000000
933
                sh              r1,NormAttr
934
                ldi             r1,#TEXTREG2
935
                sh              r1,Vidregs
936
                ldi             r1,#TEXTSCR2
937
                sh              r1,Vidptr
938
 
939
                ldi             r2,#TC2InitData
940
                ldis    lc,#11                          ; initialize loop counter ( one less)
941
                lhu             r3,Vidregs
942
.0001:
943
                lvh             r1,cs:[r2]
944
                sh              r1,hs:[r3]
945
                addui   r2,r2,#4
946
                addui   r3,r3,#4
947
                loop    .0001
948
                mov             r6,r0
949
                rts
950
endpublic
951
 
952
;------------------------------------------------------------------------------
953
; Text controller initialization data.
954
;------------------------------------------------------------------------------
955
                align   4
956
 
957
TC1InitData:
958
                dc              84              ; #columns
959
                dc               3          ; #char out delay
960
                dc              31              ; #rows
961
                dc               0
962
                dc              84              ; window left
963
                dc               0
964
                dc              17              ; window top
965
                dc       0
966
                dc               7              ; max scan line
967
                dc       0
968
                dc         $21          ; pixel size (hhhhvvvv)
969
                dc       0
970
                dc       0              ; not used
971
                dc       0
972
                dc        $1FF          ; transparent color
973
                dc       0
974
                dc         $40          ; cursor blink, start line
975
                dc       0
976
                dc          31          ; cursor end
977
                dc       0
978
                dc               0              ; start address
979
                dc       0
980
                dc               0              ; cursor position
981
                dc       0
982
 
983
                align    4
984
TC2InitData:
985
                dc              84
986
                dc       3
987
                dc              31
988
                dc       0
989
                dc         676
990
                dc       0
991
                dc      64              ; window top
992
                dc       0
993
                dc               7
994
                dc       0
995
                dc         $10
996
                dc       0
997
                dc       0
998
                dc       0
999
                dc        $1FF
1000
                dc       0
1001
                dc         $40
1002
                dc       0
1003
                dc      31
1004
                dc       0
1005
                dc       0
1006
                dc       0
1007
                dc       0
1008
                dc       0
1009
 
1010
;------------------------------------------------------------------------------
1011
; Screen line offset table.
1012
;------------------------------------------------------------------------------
1013
 
1014
                align   2
1015
LineTbl:
1016
                dc              0
1017
                dc              TEXTCOLS*4
1018
                dc              TEXTCOLS*8
1019
                dc              TEXTCOLS*12
1020
                dc              TEXTCOLS*16
1021
                dc              TEXTCOLS*20
1022
                dc              TEXTCOLS*24
1023
                dc              TEXTCOLS*28
1024
                dc              TEXTCOLS*32
1025
                dc              TEXTCOLS*36
1026
                dc              TEXTCOLS*40
1027
                dc              TEXTCOLS*44
1028
                dc              TEXTCOLS*48
1029
                dc              TEXTCOLS*52
1030
                dc              TEXTCOLS*56
1031
                dc              TEXTCOLS*60
1032
                dc              TEXTCOLS*64
1033
                dc              TEXTCOLS*68
1034
                dc              TEXTCOLS*72
1035
                dc              TEXTCOLS*76
1036
                dc              TEXTCOLS*80
1037
                dc              TEXTCOLS*84
1038
                dc              TEXTCOLS*88
1039
                dc              TEXTCOLS*92
1040
                dc              TEXTCOLS*96
1041
                dc              TEXTCOLS*100
1042
                dc              TEXTCOLS*104
1043
                dc              TEXTCOLS*108
1044
                dc              TEXTCOLS*112
1045
                dc              TEXTCOLS*116
1046
                dc              TEXTCOLS*120
1047
                dc              TEXTCOLS*124
1048
 

powered by: WebSVN 2.1.0

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