Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replacing VARSEG ??? Help please!!!!
#1
Hi, im using 0.12b for dos and am porting across some old routines from QB for vesa and mouse. I know allegro covers these but its a bit of a bloater for very simple programs.

Anyway my problem occurs with VARSEG not being in FB. I think i've sussed the way to do what i want but it just wont work.

Heres a little example. this is just a very simple check to see if a VESA mode is available, and return the dimensions & bpp if necessary.

Code:
#include "dos/go32.bi"
#include "dos/dpmi.bi"
#include "dos/sys/farptr.bi"

TYPE ModeInfoBlock
    ModeAttributes AS INTEGER
    WinAAttributes AS STRING * 1
    WinBAttributes AS STRING * 1
    WinGranularity AS INTEGER
    WinSize AS INTEGER
    WinASegment AS INTEGER
    WinBSegment AS INTEGER
    WinFuncPtr AS LONG
    BytesPerScanLine AS INTEGER
    XResolution AS INTEGER
    YResolution AS INTEGER
    XCharSize AS STRING * 1
    YCharSize AS STRING * 1
    NumberOfPlanes AS STRING * 1
    BitsPerPixel AS STRING * 1
    NumberOfBanks AS STRING * 1
    MemoryModel AS STRING * 1
    BankSize AS STRING * 1
    NumberOfImagePages AS STRING * 1
    Rsvd AS STRING * 1
    RedMaskSize AS STRING * 1
    RedFieldPosition AS STRING * 1
    GreenMaskSize AS STRING * 1
    GreenFieldPosition AS STRING * 1
    BlueMaskSize AS STRING * 1
    BlueFieldPosition AS STRING * 1
    RsvdMaskSize AS STRING * 1
    DirectColorModeInfo AS STRING * 1
    Reserved AS STRING * 216
END TYPE

DIM regs As __dpmi_regs
DIM ModeInfo AS ModeInfoBlock

Regs.x.AX = &H4F01
Regs.x.CX = &H103

'Used to be this in QB
'Regs.ES = VARSEG(ModeInfo)
'Regs.DI = VARPTR(ModeInfo)

'Now Needs This??
'>> is a operator from C/C++ but i dont know what it is.

regs.x.di= __tb AND &H0F
regs.x.es=(__tb >> 4) AND &HFFFF
__dpmi_int &H10, @regs
'Should next line 3rd param be *modeinfo or @modeinfo ??
dosmemget(__tb, len(ModeInfoBlock), modeinfo)


IF (ModeInfo.ModeAttributes AND 1) = 0 THEN     'Bit 1 = 0 then mode not
  PRINT "Error - screen mode not available."    'available.
ELSE
  winGran = 64 \ ModeInfo.WinGranularity          'Window granularity adjusted.
  xRes = ModeInfo.XResolution                     'Get screen resolution.
  yRes = ModeInfo.YResolution
  bpp = ASC(ModeInfo.BitsPerPixel)  
  PRINT xRes,yRes,bpp
  'if mode &H103 then output should be 800,600,8
END IF

Thanks in advance for your help
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#2
the >> operator from c is used to shift right, that is divide by a power of 2, you can replace it with shr.

on varseg, sorry i can't help out on that one. varseg in qbasic returns you the segment adress of the var you passed to it. varptr returns the offset to that variable relative to the segment start. the later one should be achivable via the @ operator. however, i don't know what's the operator, command for getting the segment adress of a variable in fb dos.
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#3
since fbdos port is in protected mode so there is no segments. so it should be simple simler to flat memorey model.
Reply
#4
thanks for the replys. I changed some of my code to incorperate the shr, and now xres and yres contain 0 rather than junk numbers so i guess im closer.

could you elaborate a bit on the flat mode stuff. im a relative newbie.
i got the basis of my code from the falconseye dos code which uses DJGPP, so i assumed that the __tb stuff is the way to do it with DJGPP


Thanks

Code:
dim modeinfoseg

dim modeinfoseg
modeinfoseg=__tb

asm
mov eax,[modeinfoseg]
shr eax,4
mov [modeinfoseg],eax
end asm

regs.x.di= __tb AND &H0F
regs.x.es=(modeinfoseg) AND &HFFFF
__dpmi_int &H10, @regs
dosmemget(__tb, len(ModeInfoBlock), @modeinfo)
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#5
Why are you porting that? AFAIK gfxlib works in DOS and covers VESA modes and mouse...
Antoni
Reply
#6
gfxlib i was told has not been ported to dos, on the SF forums

http://sourceforge.net/forum/forum.php?t..._id=417224

By: Nick Whiu - nexinarus
yeh
2005-04-09 12:49
yeah, i dont think gfx lib has been ported to dos yet.
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#7
You're right. There's nothing in the sub-dir gfxlib\DOS in the CVS
Antoni
Reply
#8
woops sorry forgot that fb dos uses flatmode

in that case your interrupt calling thingy won't work that easy anyways unless you use the proper dpmi functions, which i have no clue about.
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#9
Fb uses flatmode and vesa uses virtual memory...perhaps the best would be to get the allegro source and see how they are doing it...
Antoni
Reply
#10
yep ive looked at allegro, its bassically the same as ive posted,except for a few lines at the start

Quote: int c;

_farsetsel(_dos_ds);

for (c=0; c<(int)sizeof(MODE_INFO); c++)
_farnspokeb(MASK_LINEAR(__tb)+c, 0);

however this code doesnt appear in another source ive checked from falconseye

Code:
int jtp_DOSGetVBEModeInfo
(
  unsigned short mode,
  jtp_dos_vbe_modeinfo *modeinfo
)
{
   __dpmi_regs regs;

   regs.x.ax=0x4F01;
   regs.x.cx=mode;
   regs.x.di=__tb & 0x0F;
   regs.x.es=(__tb >> 4) & 0xFFFF;
   __dpmi_int(0x10, &regs);
   dosmemget(__tb, sizeof(jtp_dos_vbe_modeinfo), modeinfo);

   return(regs.h.ah);
}

i know they both work so im very confused
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)