From: jjensen@cc.usu.edu (Joshua C. Jensen)
Newsgroups: rec.games.programmer
Subject: Re: IS IT IMPOSSIBLE?!?
Date: 13 Feb 95 21:34:14 MDT

> Is it impossible in protected mode to call (or jump to) code in
> DS:anything?  And is it impossible to write in CS:anything? because of
> the protection?  (And that using Watcom C 9.5?)

yes.

> Because if it is, I can't seem to find a way to *LOAD* and run 
> code-compiled-sprites in prot.mode... I have been trying, but the program 
> locks all the time...

Here's a function to convert a data selector to a code selector.  This will
solve your problem.

unsigned short dpmiCreateCodeSelFromDataSel(unsigned short OrigSel)
{
  union REGS r;
  struct SREGS sregs;
  unsigned short Sel;
  unsigned char Des[8];

  r.x.eax = 0x000B;             /* DPMI Get Descriptor */
  r.x.ebx = OrigSel;
  sregs.es = FP_SEG( &Des );
  sregs.ds = GET_DS();
  r.x.edi = FP_OFF( &Des );
  int386x(0x31, &r, &r, &sregs);
  r.x.eax = 0x0000;           /* DPMI allocate LDT selectors */
  r.x.ecx = 1;
  int386 (0x31, &r, &r);
  Sel = r.x.eax;
  Des[5] = Des[5] & 0xF0 | 0xA;
  Des[6] = Des[6] | 0x40;
  r.x.eax = 0x000C;             /* DPMI Set Descriptor */
  r.x.ebx = Sel;
  sregs.es = FP_SEG( &Des );
  r.x.edi = FP_OFF( &Des );
  int386x(0x31, &r, &r, &sregs);
  return Sel;
}

Joshua Jensen

From: peter@cs.uct.ac.za (Peter Hinz)
Newsgroups: rec.games.programmer
Subject: Re: IS IT IMPOSSIBLE?!?
Date: 15 Feb 1995 11:06:47 +0200

>Hello there, I am in the same situation as he ^^^^^^^ I cannot seem
>to figure out how to program some kind of compiled sprites into my
>code.  If anyone has any ifo on this PLEASE post it...

I don't know why everybody is having problems with this.  For the following
I'm assuming Watcom with DOS4GW.

Both the CS and DS point to the same memory area.  Here is how I create
my compiled bitmaps:

char *BitmapMLCode;
BitmapMLCode = (char *)malloc(wanted_size);

Now I go and generate my compiled bitmap code directly into this array.
When I want to call a compiled bitmap all I do is:

lea	eax, [BitmapIndex+eax*4]
mov	eax, [eax]
call	eax

The BitmapIndex array contains points to the actual routines within 
BitmapMLCode.

And that is all there is to it.

If some people ask me nicely I might post my bitmap compiler (even does
some basic compression) :-)

Till later
Peter Hinz
Dungeon Entertainment
The creator of "3D CyberPuck", a new fast paced action game.

-- 
Peter Hinz             | Cerebus Software, knows what I do!
peter@cs.uct.ac.za     | Note: Windows is NOT a virus, Viruses do something!
University of Cape Town| One in a million things happen nine times out of ten.
Mosaic: "http://www.cs.uct.ac.za/PeopleInCompSciDept/peter/index.htm"

