145 lines
4.0 KiB
Plaintext
145 lines
4.0 KiB
Plaintext
CON
|
|
|
|
cols = VGA#cols 'anzahl der spalten
|
|
rows = VGA#rows 'anzahl der zeilen
|
|
chrs = cols * rows 'anzahl der zeichen
|
|
|
|
OBJ
|
|
VGA : "bel-vga1024-htext"
|
|
|
|
VAR
|
|
|
|
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
|
|
|
|
PUB Start(BasePin,pSyncAddress)| ColorIndex
|
|
stop 'stopt ein bereits laufenden vga-task
|
|
cm0 := %000 'cursor 0 aus
|
|
cm1 := %110 'cursor 1 unterstrich blinkend
|
|
printchar($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 '' to stop specific running monitor cog
|
|
VGA.stop ' stop any VGA cogs that were started
|
|
|
|
PUB home
|
|
'' move writing place to upper left without clearing screen
|
|
SetXY(0,0)
|
|
|
|
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_string(ptr)
|
|
repeat while byte[ptr]
|
|
printchar(byte[ptr++])
|
|
|
|
PUB printchar(c) | i, k
|
|
'' Print a character
|
|
''
|
|
'' $0D = new line
|
|
'' $0E = clear screen
|
|
'' $20..$FF = character
|
|
|
|
case c
|
|
$0D: 'return?
|
|
newline
|
|
|
|
$20..$FF: 'character?
|
|
array[RowIndex * cols + ColumnIndex] := c
|
|
if ++ColumnIndex == cols
|
|
newline
|
|
cx1 := ColumnIndex
|
|
cy1 := RowIndex
|
|
|
|
$0E: 'clear screen?
|
|
ScreenIndex := 0
|
|
repeat chrs
|
|
array[ScreenIndex++] := 32
|
|
home
|
|
|
|
|
|
PUB newline_test | i
|
|
|
|
ColumnIndex := 0
|
|
if (RowIndex += 1) == rows
|
|
RowIndex -= 1
|
|
|
|
'scroll lines
|
|
ScreenIndex := 0
|
|
repeat i from 0 to chrs - cols
|
|
array[ScreenIndex + i] := array[ScreenIndex + i + cols]
|
|
|
|
'clear new line
|
|
bytefill(@array[(rows-1)*cols], 32, cols) 'BYTEFILL (StartAddress, Value, Count)
|
|
|
|
PUB newline | i
|
|
|
|
ColumnIndex := 0
|
|
if (RowIndex += 1) == rows
|
|
RowIndex -= 1
|
|
'scroll lines
|
|
repeat i from 0 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)
|
|
|
|
|
|
{
|
|
PUB newline | i
|
|
|
|
ColumnIndex := 0
|
|
if (RowIndex += 1) == rows
|
|
RowIndex -= 2
|
|
'scroll lines
|
|
repeat i from 0 to rows-3
|
|
wordmove(@array.word[i*cols], @array.word[(i+2)*cols], cols)
|
|
'clear new line
|
|
wordfill(@array.word[(rows-2)*cols], 32, cols<<1)
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|