Wolfi30
Anmeldungsdatum: 17.08.2007 Beiträge: 38
|
Verfasst am: 16.09.2007, 18:09 Titel: Problem mit Zugriff auf linear frame buffer via DPMI |
|
|
Hallo Leute,
hab Probleme auf den linear frame buffer(VBE2) zuzugreifen!
Beim Versuch den Speicher zu mappen um darauf zuzugreifen bricht das Programm ab (__dpmi_physical_address_mapping)
Ist ein Beispiel das ich von C nach Freebasic portiert habe.
Hier ist der Code
Code: | #include "dos/dpmi.bi"
#Include "dos/dos.bi"
#Include "dos/go32.bi"
#Include "dos/sys/movedata.bi"
#Include "dos/sys/farptr.bi"
#Include "dos/sys/nearptr.bi"
#Include "dos/conio.bi"
#Include "crt/string.bi"
#Define word UShort
#define VBE_OK 0 ' No errors
#define VBE_NOMEM 1 ' Insufficient memory
#define VBE_NOBUFFER 2 ' Call to a buffer-function without buffer
#define VBE_INVALID_MODE 3 ' Try to init with an invalid VBE mode
#define VBE_MAPPING 4 ' Error during mapping physical address
#define VBE_LINEAR 5 ' Linear flat mode not supported
#define NO_SELECTOR 6 'Konnte kein Selector angelegt werden
#define RGB_RESET &h03C6
#define RGB_READ &h03C7
#define RGB_WRITE &h03C8
#define RGB_DATA &h03C9
Type image
Width As UInteger
height As UInteger
dat As ubyte ptr
End type
type TVBEInfoBlock Field=1
VesaSignature As ZString *4
VesaVersion As word
OEMStringPtr As uinteger
Capabilities As UInteger
VideoModePtr As uinteger
TotalMemory as word
oemsoftwarerev As Word' VBE implementation Software revision
oemvendornameptr As ZString ptr' Pointer to Vendor Name String
oemproductnameptr As ZString ptr ' Pointer to Product Name String
oemproductrevptr As ZString ptr ' Pointer to Product Revision String
reserved(222) As uByte ' Reserved for VBE implementation
scratch area
oemdata(256) As uByte ' Data Area for OEM Strings
End type
type TModeInfoBlock Field=1
ModeAttributes as word
WinAAttributes as ubyte
WinBAttributes as ubyte
WinGranularity as word
WinSize as word
WinASegment as word
WinBSegment as word
WinFuncPtr as UInteger
BytesPerScanLine as word
XResolution as word
YResolution as word
XCharSize as ubyte
YCharSize as ubyte
NumberOfPlanes as ubyte
BitsPerPixel as ubyte
NumberOfBanks as ubyte
MemoryModel as ubyte
BankSize as ubyte
NumberOfImagePages as ubyte
resl as ubyte
RedMaskSize as ubyte
RedFieldPosition as ubyte
GreenMaskSize as ubyte
GreenFieldPosition as ubyte
BlueMaskSize as ubyte
BlueFieldPosition as ubyte
RsvdMaskSize as ubyte
RsvdFieldPosition as uByte
directcolormodeinfo As ubyte
PhysBasePtr As UInteger
offscreenmemoffset As UInteger
offscreenmemsize As Word
reserved2(206) As ubyte
End Type
Dim Shared vbememory As Byte ptr
Dim Shared vbebuffer As byte ptr
Dim Shared xresolution As Word
dim Shared yresolution As Word
Dim Shared vbeInfo As TVBEInfoBlock
Dim Shared modeInfo As TModeInfoBlock
Dim Shared mapping As __dpmi_meminfo
Dim Shared addr As uInteger
Dim Shared my_video_ds As integer
Dim Shared selector As ushort
Function getVBEInfo as Word
Dim As __dpmi_regs regin
vbeinfo.vesasignature="VBE2"
regin.x.ax=&h4F00
regin.x.di=__tb And &h0F
regin.x.es=(__tb Shr 4) And &hFFFF
dosmemput(@vbeinfo,SizeOf(vbeinfo),__tb)
__dpmi_int(&h10,@regin)
dosmemget(__tb,SizeOf(vbeinfo),@vbeinfo)
Return regin.x.ax
End function
Function getModeInfo(ByVal mode as word) as Word
Dim As __dpmi_regs reg
reg.x.ax=&h4F01
reg.x.cx=mode
reg.x.di=__tb And &h0F
reg.x.es= (__tb Shr 4) And &hFFFF
dosmemput(@modeinfo,SizeOf(modeinfo),__tb)
__dpmi_int(&h10,@reg)
dosmemget(__tb,SizeOf(modeinfo),@modeinfo)
Return reg.x.ax
End function
function SetVBEMode(ByVal mode as word) As word
Dim As __dpmi_regs reg
reg.x.ax=&h4F02
reg.x.bx=mode Or &h4000
__dpmi_int(&h10,@reg)
Return reg.x.ax
End Function
function init_VBE_mode(ByVal vbemode As Word) As Integer
If (getmodeinfo(vbemode) <> &h4F)then Return VBE_INVALID_MODE
If (modeinfo.bitsperpixel <> 8) then Return VBE_INVALID_MODE
If (modeinfo.modeattributes And &h80 <> &h80) then
Return VBE_LINEAR
else
mapping.size=vbeinfo.TotalMemory shl 16 'modeinfo.xresolution*modeinfo.yresolution*8
mapping.address=modeinfo.physbaseptr
if(__dpmi_physical_address_mapping(@mapping) = -1) Then
Return VBE_MAPPING
else
selector = __dpmi_allocate_ldt_descriptors(1)
endif
if (selector < 0) then
__dpmi_free_physical_address_mapping(@mapping)
return NO_SELECTOR
Else
'set the descriptor location and size
__dpmi_set_segment_base_address(selector,mapping.address)
__dpmi_set_segment_limit(selector, mapping.size-1)
Return SetVBEMode(vbemode)
EndIf
endif
End Function
function getVBEMode(vbemode As Word) As UByte
dim regs as __dpmi_regs
regs.x.ax=&h4F03
__dpmi_int(&h10, @regs)
vbemode=regs.x.bx
Return regs.h.ah
End function
sub Exitgraph
Dim reg As __dpmi_regs
reg.x.ax=&h03
__dpmi_int(&h10,@reg)
__dpmi_free_physical_address_mapping(@mapping)
__dpmi_free_ldt_descriptor(selector)
End Sub
Sub linear_putpixel(ByVal x As uInteger, ByVal y As uinteger, ByVal col As UByte)
_farpokeb(selector, y*xresolution+x, col)
End sub
Dim as integer x,y,i
x=init_VBE_mode(&h101)
If x <> -1 then
linear_putpixel(300,200,15)
sleep
Exitgraph
endif
Print x
sleep
end
|
Vielleicht entdeckt ja jemand einen Fehler im Detail und kann mir helfen:-)
Danke!
Gruß wolfi |
|