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

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [source/] [video.asm] - Blame information for rev 37

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

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

powered by: WebSVN 2.1.0

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