{{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Autor: Ingo Kripahle │ │ Copyright (c) 2010 Ingo Kripahle │ │ See end of file for terms of use. │ │ Die Nutzungsbedingungen befinden sich am Ende der Datei │ └──────────────────────────────────────────────────────────────────────────────────────────────────────┘ Informationen : hive-project.de Kontakt : drohne235@googlemail.com System : TriOS Name : VGA-Text-Treiber 1024x768 Pixel, 128x64 Zeichen Chip : Bellatrix Typ : Treiber Version : 00 Subversion : 01 Funktion : VGA-Text- und Tastatur-Treiber Komponenten : VGA High-Res Text Driver v1.0 Chip Gracey MIT PS/2 Keyboard Driver v1.0.1 Chip Gracey, ogg MIT COG's : MANAGMENT 1 COG VGA 2 COG's KEYB 1 COG ------------------- 4 COG's Logbuch : 09-03-2009-dr235 - übernahme der codebasis vom vga-textdriver - steuercodes eingefügt - div. steuercodes werden ignoriert für kompatibilität - test mit beltest ok :) 22-03-2010-dr235 - anpassung trios Kommandoliste: Notizen: }} CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 'signaldefinitionen regnatix #0, D0,D1,D2,D3,D4,D5,D6,D7 'datenbus #8, BEL_VGABASE 'vga-signale (8pin) #16, BEL_KEYBC,BEL_KEYBD 'keyboard-signale #18, BEL_MOUSEC,BEL_MOUSED 'maus-signale #20, BEL_VIDBASE 'video-signale(3pin) #23, BEL_SELECT 'belatrix-auswahlsignal #24, HBEAT 'front-led BUSCLK 'bustakt BUS_WR '/wr - schreibsignal BUS_HS ' '/hs - quittungssignal cols = VGA#cols 'anzahl der spalten rows = VGA#rows 'anzahl der zeilen chrs = cols * rows 'anzahl der zeichen TAB1 = 16 TAB2 = 32 TAB3 = 48 SPACETILE = $8000 + $20 << 6 VGA_BASPORT = 8 'vga startport VGA_RESX = COLS * 16 'vga anzahl pixel x VGA_RESY = ROWS * 16 'vga anzahl pixel y KEYB_DPORT = BEL_KEYBD 'tastatur datenport KEYB_CPORT = BEL_KEYBC 'tastatur taktport CURSORCHAR = $0E 'cursorzeichen DB_WAIT = %00000001_00000000_00000000_00000000 'dira-wert f?r wait-status am bus DB_IN = %00001001_00000000_00000000_00000000 'dira-wert f?r datenbuseingabe DB_OUT = %00001001_00000000_00000000_11111111 'dira-wert f?r datenbusausgabe CNT_HBEAT = 5_000_0000 'blinkgeschw. front-led OBJ vga : "htext-vid" keyb : "htext-keyb" VAR long stackhb[9] 'stack f?r hbeat-cog byte cursor 'cursorzeichen byte curstat 'cursorstatus 1 = ein byte sline 'startzeile des scrollfensters byte eline 'endzeile des scrollfensters 'htext byte array[chrs] 'bildschirmspeicher byte VGACogStatus 'status des vga-treiber-cogs byte cx0, cy0, cm0 'x, y, mode von cursor 0 byte cx1, cy1, cm1 'x, y, mode von cursor 1 word colors[rows] 'zeilenfarbenspeicher long ScreenIndex 'index im bildschirmspeicher long RowIndex 'zeilenindex long ColumnIndex 'spaltenindex long color 'zeilenfarbe long sync 'gets signal for vertical refresh sync PUB main | zeichen {{interpreter f?r hostdialog}} init_subsysteme 'bus/vga/keyboard/maus initialisieren repeat zeichen := bus_getchar '1. zeichen empfangen if zeichen > 0 print_char(zeichen) else zeichen := bus_getchar '2. zeichen kommando empfange case zeichen 1: bus_putchar(keyb.gotkey) '1: Tastaturstatus senden 2: bus_putchar(keyb.key) '2: Tastaturzeichen senden 3: zeichen := bus_getchar print_char(zeichen + $100) '3: Sonderzeichen von $100 bis $1FF ausgeben 99: reboot '99: bellatrix neu starten PUB init_subsysteme {{initialisierung des belatrix-chips}} cognew(led_hbeat, @stackhb) 'heartbeat aktivieren bus_init 'bussignale initialisieren keyb.start(keyb_dport, keyb_cport) 'tastaturport starten start_htext(VGA_BASPORT, @sync) 'vga-treiber starten print_char($100) 'bildschirm l?schen cursor := CURSORCHAR 'cursorzeichen setzen curstat := 1 'cursor anschalten sline := 2 eline := rows PUB start_htext(BasePin,pSyncAddress)| ColorIndex stop_htext 'stopt ein bereits laufenden vga-task cm0 := %000 'cursor 0 aus cm1 := %110 'cursor 1 unterstrich blinkend print_char($0E) 'bildschirm löschen ColorIndex := 0 'graue balken auf scharzem grund repeat rows colors[ColorIndex++] := %00000100_01101000 'rrggbb00_rrggbb00 VGACogStatus := VGA.Start(BasePin,@array, @colors, @cx0, pSyncAddress) 'startet vga-treiber (2cogs) return true PUB stop_htext '' to stop specific running monitor cog VGA.stop ' stop any VGA cogs that were started PUB bus_init {{initialisierung des bussystems}} dira := db_in 'datenbus auf eingabe schalten outa[bus_hs] := 1 'handshake inaktiv PUB bus_putchar(zeichen) {{ein byte ?ber bus ausgeben}} waitpeq(%00000010_00000000_00000000_00000000,%00000010_10000000_00000000_00000000,0) 'busclk=1? & prop2=0? dira := db_out 'datenbus auf ausgabe stellen outa[7..0] := zeichen 'daten ausgeben outa[bus_hs] := 0 'daten g?ltig waitpeq(%00000000_00000000_00000000_00000000,%00000010_00000000_00000000_00000000,0) 'busclk=0? 'waitcnt(1_000 + cnt) 'zeit f?r master outa[bus_hs] := 1 'daten ung?ltig dira := db_in 'bus freigeben PUB bus_getchar : zeichen {{ein byte ?ber bus empfangen}} waitpeq(%00000010_00000000_00000000_00000000,%00000010_10000000_00000000_00000000,0) 'busclk=1? & prop2=0? zeichen := ina[7..0] 'daten einlesen outa[bus_hs] := 0 'daten quittieren outa[bus_hs] := 1 waitpeq(%00000000_00000000_00000000_00000000,%00000010_00000000_00000000_00000000,0) 'busclk=0? PUB led_hbeat {{led_hbeat - herzschlag f?r front-led}} dira := db_in repeat !outa[hbeat] waitcnt(cnt_hbeat + cnt) PUB home '' move writing place to upper left without clearing screen SetXY(0,sline) PUB SetXY(x,y) ColumnIndex := x <# cols 'setzt spalte mit begrenzung auf spaltenzahl RowIndex := y <# rows 'setzt zeile mit begrenzung auf zeilenzahl ScreenIndex := ColumnIndex + (RowIndex * cols) 'berechnet bildschirmindex PUB print_str(ptr) {{zeichenkette auf bildschirm ausgeben}} repeat while byte[ptr] print_char(byte[ptr++]) PUB print_char(c) | i, k, code, n '' Print a character '' '' $0D = new line '' $0E = clear screen '' $20..$FF = character case c $0A: 'LF ausblenden return $00..$0C: pchar(c) $0D: 'return? newline $0E..$FF: 'character? schar(c) $100: 'clear screen? ScreenIndex := 0 n := sline * cols repeat chrs - n array[n + ScreenIndex++] := 32 home $101: 'home? RowIndex := sline ColumnIndex := 0 $102: 'backspace? if ColumnIndex ColumnIndex-- schar($20) ColumnIndex-- $103: 'tab if ColumnIndex < TAB1 ColumnIndex := TAB1 return if ColumnIndex < TAB2 ColumnIndex := TAB2 return if ColumnIndex < TAB3 ColumnIndex := TAB3 return $104: 'setcur code := bus_getchar cursor := code $105: 'pos1 ColumnIndex := 0 $106: 'setx ColumnIndex := bus_getchar $107: 'sety RowIndex := bus_getchar + sline '2 tiles pro zeichen! $108: 'getx bus_putchar(ColumnIndex) $109: 'gety bus_putchar(RowIndex) $110: 'setcolor color := bus_getchar $111: 'sline sline := bus_getchar $112: 'eline eline := bus_getchar $113: 'screeninit ScreenIndex := 0 repeat chrs array[ScreenIndex++] := 32 RowIndex := 0 ColumnIndex := 0 sline := 0 $114: 'curon curstat := 1 schar(cursor) $115: 'curoff curstat := 0 $130..$13F: 'select color? color := c & $F PRI schar(c) 'schreibt zeichen an aktuelle position ohne cursorposition zu verändern array[RowIndex * cols + ColumnIndex] := c if ++ColumnIndex == cols newline cx1 := ColumnIndex cy1 := RowIndex PRI pchar(c) 'schreibt zeichen an aktuelle position z?hlt position weiter schar(c) if ++ColumnIndex == cols newline PUB newline | i ColumnIndex := 0 if (RowIndex += 1) == rows RowIndex -= 1 'scroll lines repeat i from sline to rows-2 bytemove(@array[i*cols], @array[(i+1)*cols], cols) 'BYTEMOVE (DestAddress, SrcAddress, Count) 'clear new line ' bytefill(@array[(rows-1)*cols], 32, cols<<1) 'BYTEFILL (StartAddress, Value, Count) ' code fehlerhaft, zähler ist falsch gesetzt! bytefill(@array[(rows-1)*cols], 32, cols) 'BYTEFILL (StartAddress, Value, Count) DAT {{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TERMS OF USE: MIT License │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ │is furnished to do so, subject to the following conditions: │ │ │ │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ }}