At 09:09 28/12/97 -0500, you wrote:
I forgot to tell something. I don't know how to acceed video memory
OK, heres how I do it:
Const VgaOffset = $A000; { Real-Mode Segment } Type TInfoBlock = Record Size : Word; Screen : Pointer; Screen2 : Pointer; TransferBuf : Word; TransBufSize : Word; PID : Word; MasterInt : Byte; SlaveInt : Byte; LinearSel : ShortWord; StubInfo : Pointer; OriginalPSP : Pointer; RunMode : ShortWord; RunModeInfo : ShortWord; End; Var InfoBlock : AsmName '_go32_info_block' TInfoBlock;
Procedure PutPixel(X,Y:Integer; Color:Word); Var Dest : Word; Begin Dest := ((Y * ScanWidth) + X) + (VgaOffset Shl 4); {1}
Asm(" movw %w0,%%fs " {2} " .byte 0x64 " {3} " movb %b1,(%k2) " {4} : : "g" (InfoBlock.LinearSel), "q" (Color), "r" (Dest)); End;
Explanations
{1}: This is pretty much self explanatory except for the "shl 4". This simply converts the real mode Segment into a linear address.
In real-mode "Segment:Offset" addressing the CPU automatically converts this into the actual adress of the memory. Because we are in flat-mode, we no longer use "Segment:Offset" - we must do the translation ourselves:
The formula is rather simple:
Effective Address = (Segment Shl 4) + Offset
If you want to know more, get a book and read about the stupidity of our forefathers who created this Segment:Offset scheme!! (Thank god for Protected Mode :-)
So, using InfoBlock.LinearSel allows you to access any real-mode memory area by pumping the Segment:Offset pair through the above formula!
So, ($A000 shr 4) + $0000 = $A0000 (WOW, the famous extra 0!!)
{2}: Beacause NONE of the GPC standard functions EVER use FS, it is fairly safe to load FS with InfoBlock.LinearSel when you swith into graphics mode.
{3}: OK, this is STUPID! Instead of specifying FS:(addres), you HAVE TO use this! The assembler ALWAYS stuffs up if you specify FS:(address).
{4}: This puts the pixel!
I hope this helps! Cya L8r
Bernie
PS: If you need to know how to access VESA SVGA just ask! Its a BIT more complicating :~(
________________________ e-mail: bernie@icenet.com.au | _) | | ptschirrenb@curtin.edu.au |___)ernhard |_|schirren tschirre@cs.curtin.edu.au www: www.geocities.com/CollegePark/Quad/8070/