Just a question are you guys using the original source code that was put out by 3DRealms or are you using the source code for the linux version or is there a difference?
The stuff I'm playing with, I'm using the original release by Ken Silverman (Build engine) an patching in stuff from icculus' port as I need it. I've not even looked at Duke 3D's source code yet. The Icculus Linux port has a lot of extra stuff that I don't think we need for a Dreamcast port, and it's easier to leave it out than remove it.
There's a load of functions in pragmas.h that I
know are DOS hardware stuff, so I don't think I need to worry about those. As for the rest of them...
Code: Select all
//returns eax%ebx, dmval = eax/edx;
#pragma aux moddiv =\
"xor edx, edx",\
"div ebx",\
"mov dmval, eax",\
parm [eax][ebx]\
modify exact [eax edx]\
value [edx]
//eax = (unsigned min)umin(eax,ebx)
#pragma aux umin =\
"sub eax, ebx",\
"sbb ecx, ecx",\
"and eax, ecx",\
"add eax, ebx",\
parm nomemory [eax][ebx]\
modify exact [eax ecx]\
//eax = (unsigned max)umax(eax,ebx)
#pragma aux umax =\
"sub eax, ebx",\
"sbb ecx, ecx",\
"xor ecx, 0xffffffff",\
"and eax, ecx",\
"add eax, ebx",\
parm nomemory [eax][ebx]\
modify exact [eax ecx]\
#pragma aux kmin =\
"cmp eax, ebx",\
"jl skipit",\
"mov eax, ebx",\
"skipit:",\
parm nomemory [eax][ebx]\
modify exact [eax]\
#pragma aux kmax =\
"cmp eax, ebx",\
"jg skipit",\
"mov eax, ebx",\
"skipit:",\
parm nomemory [eax][ebx]\
modify exact [eax]\
I could try to guess from the names, but I don't really know. Some of the code I've been implementing by converting each asm line into an equivalent C line, which is not a very good way to do it. But the C code is at least easier to read...
Code: Select all
INLINE void swapbuf4(int *eax, int *ebx, int ecx)
{
int esi, edi;
begswap:
esi = *eax;
edi = *ebx;
*ebx = esi;
*eax = edi;
eax++;
ebx++;
ecx--;
if(ecx != 0)
goto begswap;
}
INLINE void swap64bit(int *a, int *b)
{
int c, d;
c = a[0];
d = b[0];
b[0] = c;
c = a[1];
a[0] = d;
d = b[1];
b[1] = c;
a[1] = d;
}
Unfortunately, that's only a small portion of the inline asm code in the Build engine. And I've not even touched the a.asm file, which contains a load of asm drawing functions.
I'm going to take another look at pragmas.h, and then I'm going to try writing a stand-alone OpenGL renderer.
If anyone wants to try, you're quite welcome. I reccomend that you download 3D Realms' Duke3D source, Ken's Build engine source, Icculus' port of Build, and their port of Duke 3D, at least. At the moment, I'm just playing with it, and trying to make it easier to port (before I actually consider porting it to anything).
And downloading a copy of the Watcom C compiler might be useful too, even if it's just to test that any code you've replaced works.