先看錄像:
http://forth.foxani.com/files/videos/ofw/02-vga-draw.ogv
這次是說繪圖. 注:請在qemu下面測試.
關于如何對vbox,具體硬件和qemu的顯示支持,請參考後面的作者信件,
我還沒深入研究,有興趣的朋友可以試試.
ROM下載:
http://forth.foxani.com/files/emuofw.rom
第一步: 繪制填充的矩形
stdout @ iselect \ 取得設備ihandle
decimal \ 設置為十進制, ofw默認是hex
: 1test
2 50 50 200 20 fill-rectangle \ 填充方塊 色 x y 長 寬
3 50 60 200 20 fill-rectangle
4 50 70 200 20 fill-rectangle
5 50 80 200 20 fill-rectangle
;
1test \ 繪制四個矩形
第二步: 繪制水平線
0 value default-color \ 定義默認顏色
: hline ( y -- ) \ y 決定直線位置
default-color 0 \
rot
800 2 fill-rectangle \ 長800 寬2
;
iunselect \ 關閉設備
第三步: 隨機繪制多彩矩形 來自作者的文件 testrect.fth
重啟qemu
fload c:\testrect.fth
參考:
作者對display的問題回信:
On 5/24/2011 4:10 PM, 胡松涛 wrote:
Hi,
When I learn
http://www.openfirmware.org/1275/practice/#graphics
I found that: I Can't get /pci/display ihandle under vbox,
That is because there is no suitable driver in the demo build.
VirtualBox emulates a linear frame buffer that is managed with VESA BIOS
extensions. The demo build, when running under syslinux, has some words
to access VESA BIOS functions - they are defined in
cpu/x86/pc/biosload/callvbe.fth . You could use them to put the display
into VESA linear framebuffer mode, then access the framebuffer with the
functions in dev/video/common/rectangl.fth .
You would need to use a serial console for this, because as soon as you
switched to VESA linear mode, you would lose the text-mode console display.
when I boot
up with usb-disk on my laptop, I can't get ihandle as well.
Again, the problem is the lack of a driver for the graphics card on your
laptop. Modern PC graphics cards are very complex, and often undocumented.
If your laptop has a conventional BIOS that supports VESA, you could use
the VESA technique outlined above to access its display in graphics mode.
If it has an EFI BIOS, some other technique would be required.
but I can get /pci/vga ihandle under qemu. And it works fine with graphics.
qemu emulates an old Cirrus logic display controller for which OFW has a
driver (the source code is in dev/video/cirrus.bth).
--
Hu Songtao
works as an English Teacher in weekends
Skype: idisblueflash
Beijing, China