I forgot to tell something. I don't know how to acceed video memory ... I don't know if it's a good way but it seems to work.
Thanks! It's not accessing it using a base address, but it's the closest thing :) I'm not partial to any particular segment register so gs is good enough for me so long as I don't have to reload it every time :)
If anybody knows how to access the VGA segment using only a base address I'd still appreciate the tip.
See ya! Orlando Llanes
"Hey, we all did the drug thing, we all did the money thing, and eventually you find out that none of that stuff fixes anything, and we have nowhere else to go except to evolve spiritually and intellectually" -- Meredith Brooks
"Look out fo' flyeeng feet" O__/ a010111t@bc.seflin.org /|____. O <__. /> / \ ____________|_________ http://ourworld.compuserve.com/homepages/Monkey414
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/