duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit e2b5d936b3853eca826bf00d8b398ce0aa0b9659
parent 4d41f645976ee3107894ec8fb439af4245f9db50
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun, 11 Dec 2022 20:17:27 -0500

drv/pc/vesa: pixels on screen!

I suppose that most VESA cards have the same IDS for basic resolution. I used
the 640x480x8 resolution which according to ".vesamodes" has the ID $101. On
boot you do:

$101 vesamode! colortest

and you have pixels.

Diffstat:
Mfs/drv/pc/vesa.fs | 23++++++++++++++++++-----
Mfs/drv/pc/vga.fs | 3+++
2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/fs/drv/pc/vesa.fs b/fs/drv/pc/vesa.fs @@ -12,8 +12,6 @@ struct[ VBEInfo sfield vendor sfield productname sfield productrev - - : :new ( -- self ) here SZ allot ; ]struct struct[ VBEModeInfo @@ -52,6 +50,8 @@ struct[ VBEModeInfo : :linear? attributes $80 and bool ; ]struct +here VBEModeInfo SZ allot structbind VBEModeInfo _curmode + : _err abort" VESA error" ; : _assert not if _err then ; @@ -73,11 +73,14 @@ struct[ VBEModeInfo r@ VBEInfo productname seg>32 .f" Product name: %z\n" r> VBEInfo productrev seg>32 .f" Product rev: %z\n" ; +: _modeinfo ( mode -- info ) + ( cx ) 0 $4f01 int10h ( di bx ax ) + $4f = _assert drop ; + \ To make the output a bit lighter, we ignore any mode that is less than 8bpp or \ that don't support a linear frame buffer. -: _.mode ( n -- ) - dup >r ( cx ) 0 $4f01 int10h ( di bx ax ) \ V1=n - $4f = _assert drop >r ( ) \ V2=mode +: _.mode ( mode -- ) + dup >r _modeinfo >r \ V1=modeid V2=modeinfo r@ VBEModeInfo bpp 8 >= r@ VBEModeInfo :linear? and if r@ VBEModeInfo bpp r@ VBEModeInfo height r> VBEModeInfo width r> .f" |%w %dx%dx%d " @@ -90,3 +93,13 @@ struct[ VBEModeInfo -1 ( sentinel ) begin 16b to@+ V1 dup $ffff = until ( -1 ... $ffff ) drop rdrop begin ( -1 ... ) dup 0>= while _.mode repeat ( -1 ) drop ; + +: vesamode! ( modenum -- ) + dup _modeinfo _curmode :self VBEModeInfo SZ move + 0 swap $4000 or $4f02 int10h ( di bx ax ) + $4f = _assert 2drop ; + +: colortest + _curmode height >r begin + r@ _curmode pitch * _curmode framebuffer + ( a ) + $100 >r begin ( a ) r@ swap c!+ next drop next ; diff --git a/fs/drv/pc/vga.fs b/fs/drv/pc/vga.fs @@ -14,3 +14,6 @@ $b8000 const _mem( move ; : newln ( oldln -- newln ) dup LINES 1- = if scroll else 1+ then ; + +\ Set video mode to text mode, 80x25 +: vgatext! ( -- ) 0 0 3 int10h 2drop drop ;