{{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ 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, 64x24 Zeichen Chip : Bellatrix Typ : Treiber Version : 00 Subversion : 01 Funktion : VGA-Text- und Tastatur-Treiber Komponenten : VGA 1024x768 Tile Driver v0.9 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 : 23-10-2008-dr235 - erste funktionsfähige version erstellt - cursor eingebaut 06-11-2008-dr235 - keyb auf deutsche zeichenbelegung angepasst (ohne umlaute) 24-11-2008-dr235 - tab, setcur, pos1, setx, sety, getx, gety, setcol, sline, screeninit curon, curoff - beltest 13-03-2009-dr235 - LF als Zeichencode ausgeblendet 22-03-2009-dr235 - abfrage für statustasten eingefügt 05-09-2009-dr235 - abfrage der laufenden cogs eingefügt - deutschen tastaturtreiber mit vollständiger belegung! von ogg eingebunden 22-03-2010-dr235 - anpassung trios Kommandoliste: 0 1 Tastaturstatus abfragen 0 2 Tastaturzeichen holen 0 3 n Screensteuerzeichen 0 3 0 CLS 0 3 1 Home 0 3 2 Backspace 0 3 3 TAB 0 3 4 n SETCUR Cursorzeichen auf n setzen 0 3 5 POS1 0 3 6 x SETX 0 3 7 y SETY 0 3 8 (x) GETX 0 3 9 (y) GETY 0 3 10 c SETCOL 0 3 11 n SLINE 0 3 13 SCREENINIT 0 3 14 CURON 0 3 15 CUROFF 0 4 (status) Status der Sondertasten abfragen 0 5 (cogs) Status der belegten COG's abfragen 0 99 Reboot und neuen Treiber laden 1..255 Zeichenausgabe Notizen: - setheader ACHTUNG: row ist nicht die Zeilenposition, da zwei tiles untereinander ein zeichen bilden. vielmehr ist die reale zeilenposition row/2. }} CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 'signaldefinitionen bellatrixix #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 = 64 ROWS = 48 TILES = cols * rows 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 : "vga-vid" keyb : "vga-keyb" VAR long col, row, color 'spalten-, zeilenposition und zeichenfarbe long array[tiles/2] 'bildschirmpuffer 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 byte cogs 'freie cogs byte cog[8] PUB main | zeichen,n {{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: n := keyb.key bus_putchar(n) '2: Tastaturzeichen senden 3: zeichen := bus_getchar print_char(zeichen + $100) '3: Sonderzeichen von $100 bis $1FF ausgeben 4: bus_putchar(n >> 8) '4: Statustasten 5: getcogs '5: Belegte Cogs abfragen bus_putchar(cogs) 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 vga.start(vga_basport, @array, @vgacolors, 0, 0, 0) 'vga-treiber starten print_char($100) 'bildschirm l?schen cursor := CURSORCHAR 'cursorzeichen setzen curstat := 1 'cursor anschalten sline := 2 eline := rows 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 getcogs |i,c {{ fragt freie cogs ab }} i :=0 cogs := 0 repeat 'loads as many cogs as possible and stores their cog numbers c := cog[i] := cognew(@entry, 0) if c=>0 i++ while c => 0 cogs := i repeat 'unloads the cogs and updates the string i-- if i=>0 cogstop(cog[i]) while i=>0 PUB print_str(ptr) {{zeichenkette auf bildschirm ausgeben}} repeat while byte[ptr] print_char(byte[ptr++]) PUB print_char(c) | code,n {{zeichen auf bildschirm ausgeben}} '' Print a character '' '' $0D = new line '' $20..$FF = character '' $100 = clear screen '' $101 = home '' $108 = backspace ''$110..$11F = select color case c $0A: 'LF ausblenden return $00..$0C: pchar(c) if curstat == 1 schar(cursor) $0D: 'return? if curstat == 1 schar($20) newline if curstat == 1 schar(cursor) $0E..$FF: 'character? pchar(c) if curstat == 1 schar(cursor) $100: 'clear screen? if curstat == 1 schar($20) n := sline * cols * 2 wordfill(@array + n, spacetile, tiles - n) row := sline col := 0 if curstat == 1 schar(cursor) $101: 'home? row := sline col := 0 $102: 'backspace? if col if curstat == 1 schar($20) col-- if curstat == 1 schar(cursor) $103: 'tab if col < TAB1 if curstat == 1 schar($20) col := TAB1 if curstat == 1 schar(cursor) return if col < TAB2 if curstat == 1 schar($20) col := TAB2 if curstat == 1 schar(cursor) return if col < TAB3 if curstat == 1 schar($20) col := TAB3 if curstat == 1 schar(cursor) return $104: 'setcur code := bus_getchar cursor := code if curstat == 1 schar(code) $105: 'pos1 if curstat == 1 schar($20) col := 0 if curstat == 1 schar(cursor) $106: 'setx if curstat == 1 schar($20) col := bus_getchar if curstat == 1 schar(cursor) $107: 'sety if curstat == 1 schar($20) row := bus_getchar * 2 + sline '2 tiles pro zeichen! if curstat == 1 schar(cursor) $108: 'getx bus_putchar(col) $109: 'gety bus_putchar(row / 2) $110: 'setcolor color := bus_getchar $111: 'sline sline := bus_getchar * 2 $112: 'eline eline := bus_getchar * 2 $113: 'screeninit wordfill(@array, spacetile, tiles) row := 0 col := 0 sline := 0 $114: 'curon curstat := 1 schar(cursor) $115: 'curoff if curstat == 1 schar($20) curstat := 0 $116: 'scrollup scrollup $117: 'scrolldown scrolldown $130..$13F: 'select color? color := c & $F PRI schar(c)| i,k 'schreibt zeichen an aktuelle position ohne cursorposition zu ver?ndern k := color << 1 + c & 1 i := $8000 + (c & $FE) << 6 + k array.word[row * cols + col] := i 'oberes tile setzen array.word[(row + 1) * cols + col] := i | $40 'unteres tile setzen PRI pchar(c) 'schreibt zeichen an aktuelle position z?hlt position weiter schar(c) if ++col == cols newline PUB newline | i col := 0 if (row += 2) == rows row -= 2 'scroll lines repeat i from sline to rows-3 wordmove(@array.word[i*cols], @array.word[(i+2)*cols], cols) 'wordmove(dest,src,cnt) 'clear new line wordfill(@array.word[(rows-2)*cols], spacetile, cols<<1) PUB scrollup | i 'scrollt den screen nach oben 'scroll lines repeat i from sline to rows-3 wordmove(@array.word[i*cols], @array.word[(i+2)*cols], cols) 'wordmove(dest,src,cnt) 'clear new line wordfill(@array.word[(rows-2)*cols], spacetile, cols<<1) PUB scrolldown | i 'scrollt den screen nach unten 'scroll lines repeat i from sline to rows-3 wordmove(@array.word[((rows-i)+2)*cols], @array.word[(rows-i)*cols], cols) 'wordmove(dest,src,cnt) 'clear new line wordfill(@array.word[sline*cols], spacetile, cols<<1) DAT {{ '' array_ptr = Pointer to 3,072 long-aligned words, organized as 64 across by 48 down, '' which will serve as the tile array. Each word specifies a tile bitmap and '' a color palette for its tile area. The top 10 bits of each word form the '' base address of a 16-long tile bitmap, while the lower 6 bits select a '' color palette for the bitmap. For example, $B2E5 would specify the tile '' bitmap spanning $B2C0..$B2FF and color palette $25. '' color_ptr = Pointer to 64 longs which will define the 64 color palettes. The RGB data '' in each long is arranged as %%RGBx_RGBx_RGBx_RGBx with the sub-bytes 3..0 '' providing the color data for pixel values %11..%00, respectively: '' '' %%3330_0110_0020_3300: %11=white, %10=dark cyan, %01=blue, %00=gold '' %% ist quaternary-darstellung; jedes digit von 0 bis 3, also 4-wertigkeit bildaufbau: 24 zeilen zu je 64 zeichen; jedes zeichen wird durch zwei tiles gebildet die ?bereinander liegen. jedes tile belegt ein word: 10 bit bitmap und 6 bit color. zwei tiles ein long. '0 %%RGBx_RGBx_RGBx_RGBx long %%0330_0010_0330_0010 long %%0330_0330_0010_0010 long $3C043C04 'grau/blau erste - hive-version long $3C3C0404 For the 1024x768 VGA tile driver: 2 longs are required for each text foreground/background color combo, arranged as: $ff_bb_ff_bb $ff_ff_bb_bb where 'ff' is the foreground color and 'bb' is the background color 2 longs needed because characters are in an interleaved pair The first long is the color for the first character in a pair, the second long is for the second character in a pair. Demo routine "print()" only allows for 8 fore/back combinations (using longs 0 to 15) 1 long required for box colors, arranged as: $tl_br_fi_bb where 'tl' is top-left edge, 'br' is bottom-right edge, 'fi' is focus indicators, and 'bb' is background color The demo "box()" procedure hardwired to add 16 to input color number to pick box color and adds 5 to input color number to pick text color for box... So, "box(left,top,clr,str)" uses color number 16+clr for box colors and 5+clr for text color. You probably want the 'bb' background colors of these two to match! Note that this limits you to 4 box colors. 1 long used for graphics colors, arranged as $00_11_22_33 where 00,11,22,33 are the selectable graphics colors 0,1,2,3 Demo hardwired to use the 21st long (last one) for the graphics colors The Propeller's "tile driver" video uses 32-bit (long) values to define a four color palette The "color_ptr" parameter, given to the tile driver, specifies the location of the data block of up to 64 different long palette values Each long palette represents 4 different colors, one byte each. Each color byte uses 2 bits for each primary colors, RGB, arranged as RGBx. The "x" represents the two least significant bits, which are ignored. Parallax gives this example of a 32-bit long palette, represented as a 16-digit quaternary (2-bit) number: %%3330_0110_0020_3300 or $FC1408F0 The first byte, %%3330 (binary %11111100), is the color white The second byte, %%0110, is the color dark cyan }} org ' ' Entry: dummy-assemblercode fuer cogtest ' entry jmp entry 'just loops vgacolors long 'farbpalette '============================================================ ' v h v h ' v=Vordergrund, h=Hintergrund ' long $ 3C 04 3C 04 'Muster ' v v h h ' long $ 3C 3C 04 04 'Muster '0 %%RGBx_RGBx_RGBx_RGBx ' long %%0330_0010_0330_0010 ' long %%0330_0330_0010_0010 '============================================================ long $3C043C04 'grau/blau erste - hive-version long $3C3C0404 long $F004F004 'yellow/blue long $F0F00404 long $C004C004 'rot/blau long $C0C00404 long $30043004 'grün/blau long $30300404 long $043C043C 'Color 0 reverse long $04043C3C long $FC04FC04 'weiss/blau long $FCFC0404 long $FF80FF80 'red/white long $FFFF8080 long $88048804 'magenta/blau long $88880404 long $C0408080 'redbox long $CC440088 'magentabox long $3C142828 'cyanbox long $FC54A8A8 'greybox long $3C14FF28 'cyanbox+underscore long $F030C050 'graphics colors long $881430FC long $8008FCA4 ' alte definitionen ' long $F010 F010 'yellow on dk green ' long $F0F0 1010 ' long $C000C000 'red ' long $C0C00000 ' long $30003000 'green ' long $30300000 ' long $0C000C00 'blue ' long $0C0C0000 ' long $FC04FC04 'white ' long $FCFC0404 ' long $FF88FF88 'magenta/white ' long $FFFF8888 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. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ }}