ref: 664bab86ba561e61c734ca1319c4f74b7e21d76d
parent: 6c8d7340dce68608d920aaf8656c65c046df2c9c
author: Fabien Sanglard <[email protected]>
date: Wed Dec 19 12:55:41 EST 2012
Removed dead code. Renamed meaningless 'a' translation unit to 'draw'.
--- a/Engine/src/a.c
+++ /dev/null
@@ -1,831 +1,0 @@
-// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
-// Ken Silverman's official web site: "http://www.advsys.net/ken"
-// See the included license file "BUILDLIC.TXT" for license info.
-// This file has been modified from Ken Silverman's original release
-
-/* DDOI - This file is an attempt to reimplement a_nasm.asm in C */
-
-#include "platform.h"
-#include "build.h"
-#include "a.h"
-
-uint32_t pixelsAllowed = 10000000000;
-
-#define shrd(a,b,c) (((b)<<(32-(c))) | ((a)>>(c)))
-#define shld(a,b,c) (((b)>>(32-(c))) | ((a)<<(c)))
-
-extern int32_t asm1;
-extern int32_t asm2;
-extern int32_t asm3;
-extern int32_t asm4;
-
-static uint8_t machxbits_al;
-static uint8_t machxbits_bl;
-static int32_t machxbits_ecx;
-void sethlinesizes(int32_t i1, int32_t i2, int32_t i3)
-{
- machxbits_al = i1;
- machxbits_bl = i2;
- machxbits_ecx = i3;
-}
-
-
-//FCS: Draw ceiling/floors
-//Draw a line from destination in the framebuffer to framebuffer-numPixels
-void hlineasm4(int32_t numPixels, int32_t shade, uint32_t i4, uint32_t i5, int32_t destination){
-
- uint8_t *dest = (uint8_t *) destination;
- int32_t shifter = ((256-machxbits_al) & 0x1f);
- uint32_t source;
- uint8_t bits = machxbits_bl;
- uint8_t *lookup = (uint8_t *) machxbits_ecx;
-
-
- shade = shade & 0xffffff00;
- numPixels++;
-
- if (!RENDER_DRAW_CEILING_AND_FLOOR)
- return;
-
- while (numPixels) {
-
- source = i5 >> shifter;
- source = shld(source,i4,bits);
- source = lookup[source];
-
- if (pixelsAllowed-- > 0)
- *dest = globalpalwritten[shade|source];
-
- dest--;
-
- i5 -= asm1;
- i4 -= asm2;
-
- numPixels--;
-
- }
-}
-
-static int32_t rmach_eax;
-static int32_t rmach_ebx;
-static int32_t rmach_ecx;
-static int32_t rmach_edx;
-static int32_t rmach_esi;
-void setuprhlineasm4(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- rmach_eax = i1;
- rmach_ebx = i2;
- rmach_ecx = i3;
- rmach_edx = i4;
- rmach_esi = i5;
-}
-
-
-void rhlineasm4(int32_t i1, int32_t i2, int32_t i3, uint32_t i4, uint32_t i5, int32_t dest)
-{
- uint32_t ebp = dest - i1;
- uint32_t rmach6b = ebp-1;
- int32_t numPixels;
-
- if (i1 <= 0) return;
-
- numPixels = i1;
- do {
-
-
-
- i3 = ((i3&0xffffff00)|(*((uint8_t *)i2)));
- i4 -= rmach_eax;
- ebp = (((i4+rmach_eax) < i4) ? -1 : 0);
- i5 -= rmach_ebx;
- if ((i5 + rmach_ebx) < i5) i2 -= (rmach_ecx+1);
- else i2 -= rmach_ecx;
- ebp &= rmach_esi;
- i1 = ((i1&0xffffff00)|(((uint8_t *)i3)[rmach_edx]));
-
- if (pixelsAllowed-- > 0)
- ((uint8_t *)rmach6b)[numPixels] = (i1&0xff);
-
- i2 -= ebp;
- numPixels--;
- } while (numPixels);
-}
-
-static int32_t rmmach_eax;
-static int32_t rmmach_ebx;
-static int32_t rmmach_ecx;
-static int32_t rmmach_edx;
-static int32_t rmmach_esi;
-void setuprmhlineasm4(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- rmmach_eax = i1;
- rmmach_ebx = i2;
- rmmach_ecx = i3;
- rmmach_edx = i4;
- rmmach_esi = i5;
-}
-
-
-//FCS: ????
-void rmhlineasm4(int32_t i1, int32_t shade, int32_t colorIndex, int32_t i4, int32_t i5, int32_t dest)
-{
- uint32_t ebp = dest - i1;
- uint32_t rmach6b = ebp-1;
- int32_t numPixels;
-
- if (i1 <= 0)
- return;
-
- numPixels = i1;
- do {
-
-
-
- colorIndex = ((colorIndex&0xffffff00)|(*((uint8_t *)shade)));
- i4 -= rmmach_eax;
- ebp = (((i4+rmmach_eax) < i4) ? -1 : 0);
- i5 -= rmmach_ebx;
-
- if ((i5 + rmmach_ebx) < i5)
- shade -= (rmmach_ecx+1);
- else
- shade -= rmmach_ecx;
-
- ebp &= rmmach_esi;
-
- //Check if this colorIndex is the transparent color (255).
- if ((colorIndex&0xff) != 255) {
- if (pixelsAllowed-- > 0)
- {
- i1 = ((i1&0xffffff00)|(((uint8_t *)colorIndex)[rmmach_edx]));
- ((uint8_t *)rmach6b)[numPixels] = (i1&0xff);
- }
- }
-
- shade -= ebp;
- numPixels--;
-
- } while (numPixels);
-}
-
-
-//Variable used to draw column.
-//This is how much you have to skip in the framebuffer in order to be one pixel below.
-static int32_t bytesperline;
-void setBytesPerLine(int32_t _bytesperline)
-{
- bytesperline = _bytesperline;
-}
-
-
-static uint8_t* transPalette;
-void fixtransluscence(uint8_t* transLuscentPalette)
-{
- transPalette = transLuscentPalette;
-}
-
-static uint8_t mach3_al;
-
-//FCS: RENDER TOP AND BOTTOM COLUMN
-int32_t prevlineasm1(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- uint8_t *source = (uint8_t *)i5;
- uint8_t *dest = (uint8_t *)i6;
-
- if (i3 == 0)
- {
- if (!RENDER_DRAW_TOP_AND_BOTTOM_COLUMN)
- return 0;
-
- i1 += i4;
- //FCS
- //((uint32_t)i4) >>= mach3_al;
- i4 = ((uint32_t)i4) >> mach3_al;
- i4 = (i4&0xffffff00) | (source[i4]&0xff);
-
- if (pixelsAllowed-- > 0)
- *dest = ((uint8_t *)i2)[i4];
-
-
-
- return i1;
- } else {
- return vlineasm1(i1,i2,i3,i4,i5,i6);
- }
-}
-
-
-//FCS: This is used to draw wall border vertical lines
-int32_t vlineasm1(int32_t vince, int32_t palookupoffse, int32_t numPixels, int32_t vplce, int32_t bufplce, int32_t frameBufferDestination)
-{
- uint32_t temp;
- uint8_t *dest = (uint8_t *)frameBufferDestination;
-
- if (!RENDER_DRAW_WALL_BORDERS)
- return vplce;
-
- numPixels++;
- while (numPixels)
- {
-
-
-
- temp = ((uint32_t)vplce) >> mach3_al;
-
- temp = ((uint8_t *)bufplce)[temp];
-
- if (pixelsAllowed-- > 0)
- *dest = ((uint8_t *)palookupoffse)[temp];
-
- vplce += vince;
- dest += bytesperline;
- numPixels--;
- }
- return vplce;
-}
-
-static int transrev = 0;
-int32_t tvlineasm1(int32_t i1, int32_t i2, int32_t numPixels, int32_t i4, int32_t i5, int32_t _dest)
-{
- uint8_t *source = (uint8_t *)i5;
- uint8_t *dest = (uint8_t *)_dest;
-
- uint8_t shiftValue = (globalshiftval & 0x1f);
-
- numPixels++;
- while (numPixels)
- {
- uint32_t temp = i4;
- temp >>= shiftValue;
- temp = source[temp];
-
- //255 is the index for transparent color index. Skip drawing this pixel.
- if (temp != 255)
- {
- uint16_t colorIndex;
-
- colorIndex = ((uint8_t *)i2)[temp];
- colorIndex |= ((*dest)<<8);
-
- if (transrev)
- colorIndex = ((colorIndex>>8)|(colorIndex<<8));
-
- if (pixelsAllowed-- > 0)
- *dest = transPalette[colorIndex];
- }
-
- i4 += i1;
-
- //We are drawing a column ?!
- dest += bytesperline;
- numPixels--;
- }
- return i4;
-} /* tvlineasm1 */
-
-
-static uint8_t tran2shr;
-static uint32_t tran2pal_ebx;
-static uint32_t tran2pal_ecx;
-void setuptvlineasm2(int32_t i1, int32_t i2, int32_t i3)
-{
- tran2shr = (i1&0x1f);
- tran2pal_ebx = i2;
- tran2pal_ecx = i3;
-} /* */
-
-
-void tvlineasm2(uint32_t i1, uint32_t i2, uint32_t i3, uint32_t i4, uint32_t i5, uint32_t i6)
-{
- uint32_t ebp = i1;
- uint32_t tran2inca = i2;
- uint32_t tran2incb = asm1;
- uint32_t tran2bufa = i3;
- uint32_t tran2bufb = i4;
- uint32_t tran2edi = asm2;
- uint32_t tran2edi1 = asm2 + 1;
-
- i6 -= asm2;
-
- do {
-
- i1 = i5 >> tran2shr;
- i2 = ebp >> tran2shr;
- i5 += tran2inca;
- ebp += tran2incb;
- i3 = ((uint8_t *)tran2bufa)[i1];
- i4 = ((uint8_t *)tran2bufb)[i2];
- if (i3 == 255) { // skipdraw1
- if (i4 != 255) { // skipdraw3
- uint16_t val;
- val = ((uint8_t *)tran2pal_ecx)[i4];
- val |= (((uint8_t *)i6)[tran2edi1]<<8);
-
- if (transrev)
- val = ((val>>8)|(val<<8));
-
- if (pixelsAllowed-- > 0)
- ((uint8_t *)i6)[tran2edi1] = transPalette[val];
- }
- } else if (i4 == 255) { // skipdraw2
- uint16_t val;
- val = ((uint8_t *)tran2pal_ebx)[i3];
- val |= (((uint8_t *)i6)[tran2edi]<<8);
-
- if (transrev) val =
- ((val>>8)|(val<<8));
-
- if (pixelsAllowed-- > 0)
- ((uint8_t *)i6)[tran2edi] = transPalette[val];
- } else {
- uint16_t l = ((uint8_t *)i6)[tran2edi]<<8;
- uint16_t r = ((uint8_t *)i6)[tran2edi1]<<8;
- l |= ((uint8_t *)tran2pal_ebx)[i3];
- r |= ((uint8_t *)tran2pal_ecx)[i4];
- if (transrev) {
- l = ((l>>8)|(l<<8));
- r = ((r>>8)|(r<<8));
- }
- if (pixelsAllowed-- > 0)
- {
- ((uint8_t *)i6)[tran2edi] = transPalette[l];
- ((uint8_t *)i6)[tran2edi1] =transPalette[r];
- pixelsAllowed--;
- }
- }
- i6 += bytesperline;
- } while (i6 > i6 - bytesperline);
- asm1 = i5;
- asm2 = ebp;
-}
-
-
-
-static uint8_t machmv;
-int32_t mvlineasm1(int32_t vince, int32_t palookupoffse, int32_t i3, int32_t vplce, int32_t bufplce, int32_t i6)
-{
- uint32_t temp;
- uint8_t *dest = (uint8_t *)i6;
-
- // FIX_00087: 1024x768 mode being slow. Undone FIX_00070 and fixed font issue again
- for(;i3>=0;i3--)
- {
- temp = ((uint32_t)vplce) >> machmv;
- temp = ((uint8_t *)bufplce)[temp];
-
- if (temp != 255)
- {
- if (pixelsAllowed-- > 0)
- *dest = ((uint8_t *)palookupoffse)[temp];
- }
-
- vplce += vince;
- dest += bytesperline;
- }
- return vplce;
-} /* mvlineasm1 */
-
-
-void setupvlineasm(int32_t i1)
-{
- mach3_al = (i1&0x1f);
-}
-
-extern int32_t vplce[4], vince[4], palookupoffse[4], bufplce[4];
-
-
-
-//FCS This is used to fill the inside of a wall
-void vlineasm4(int32_t i1, int32_t i2)
-{
-
- if (!RENDER_DRAW_WALL_INSIDE)
- return ;
-
- {
- int i;
- uint32_t temp;
- uint32_t index = (i2 + ylookup[i1]);
- uint8_t *dest = (uint8_t *)(-ylookup[i1]);
- do {
- for (i = 0; i < 4; i++)
- {
-
- temp = ((uint32_t)vplce[i]) >> mach3_al;
- temp = (((uint8_t *)(bufplce[i]))[temp]);
- if (pixelsAllowed-- > 0)
- dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
- vplce[i] += vince[i];
- }
- dest += bytesperline;
- } while (((uint32_t)dest - bytesperline) < ((uint32_t)dest));
- }
-}
-
-
-void setupmvlineasm(int32_t i1)
-{
- machmv = (i1&0x1f);
-}
-
-
-void mvlineasm4(int32_t column, int32_t framebufferOffset)
-{
- int i;
- uint32_t temp;
- uint32_t index = (framebufferOffset + ylookup[column]);
- uint8_t *dest = (uint8_t *)(-ylookup[column]);
-
- do {
-
- if (pixelsAllowed <= 0)
- return;
-
- for (i = 0; i < 4; i++)
- {
-
- temp = ((uint32_t)vplce[i]) >> machmv;
- temp = (((uint8_t *)(bufplce[i]))[temp]);
- if (temp != 255)
- {
- if (pixelsAllowed-- > 0)
- dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
- }
- vplce[i] += vince[i];
- }
- dest += bytesperline;
-
- } while (((uint32_t)dest - bytesperline) < ((uint32_t)dest));
-} /* mvlineasm4 */
-
-
-static int32_t spal_eax;
-static int32_t smach_eax;
-static int32_t smach2_eax;
-static int32_t smach5_eax;
-static int32_t smach_ecx;
-void setupspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- spal_eax = i1;
- smach_eax = (i5<<16);
- smach2_eax = (i5>>16)+i2;
- smach5_eax = smach2_eax + i4;
- smach_ecx = i3;
-}
-
-
-void spritevline(int32_t i1, uint32_t i2, int32_t i3, uint32_t i4, int32_t i5, int32_t i6)
-{
- uint8_t *source = (uint8_t *)i5;
- uint8_t *dest = (uint8_t *)i6;
-
-setup:
-
- i2 += smach_eax;
- i1 = (i1&0xffffff00) | (*source&0xff);
- if ((i2 - smach_eax) > i2)
- source += smach2_eax + 1;
- else
- source += smach2_eax;
-
-draw:
- i1 = (i1&0xffffff00) | (((uint8_t *)spal_eax)[i1]&0xff);
-
- if (pixelsAllowed-- > 0)
- *dest = i1;
-
-
-
- dest += bytesperline;
-
- i4 += smach_ecx;
- i4--;
-
- if (!((i4 - smach_ecx) > i4) && i4 != 0)
- goto setup;
-
- if (i4 == 0)
- return;
-
- i2 += smach_eax;
- i1 = (i1&0xffffff00) | (*source&0xff);
-
- if ((i2 - smach_eax) > i2)
- source += smach5_eax + 1;
- else
- source += smach5_eax;
-
- goto draw;
-} /* spritevline */
-
-
-static int32_t mspal_eax;
-static int32_t msmach_eax;
-static int32_t msmach2_eax;
-static int32_t msmach5_eax;
-static int32_t msmach_ecx;
-void msetupspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- mspal_eax = i1;
- msmach_eax = (i5<<16);
- msmach2_eax = (i5>>16)+i2;
- msmach5_eax = smach2_eax + i4;
- msmach_ecx = i3;
-}
-
-
-void mspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- uint8_t *source = (uint8_t *)i5;
- uint8_t *dest = (uint8_t *)i6;
-
-setup:
- i2 += smach_eax;
- i1 = (i1&0xffffff00) | (*source&0xff);
- if ((i2 - smach_eax) > i2) source += smach2_eax + 1;
- else source += smach2_eax;
-
- draw:
- if ((i1&0xff) != 255)
- {
- i1 = (i1&0xffffff00) | (((uint8_t *)spal_eax)[i1]&0xff);
- if (pixelsAllowed-- > 0)
- *dest = i1;
-
-
- }
- dest += bytesperline;
-
- i4 += smach_ecx;
- i4--;
- if (!((i4 - smach_ecx) > i4) && i4 != 0)
- goto setup;
- if (i4 == 0) return;
- i2 += smach_eax;
- i1 = (i1&0xffffff00) | (*source&0xff);
- if ((i2 - smach_eax) > i2) source += smach5_eax + 1;
- else source += smach5_eax;
- goto draw;
-}
-
-
-uint32_t tspal;
-uint32_t tsmach_eax1;
-uint32_t tsmach_eax2;
-uint32_t tsmach_eax3;
-uint32_t tsmach_ecx;
-void tsetupspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- tspal = i1;
- tsmach_eax1 = i5 << 16;
- tsmach_eax2 = (i5 >> 16) + i2;
- tsmach_eax3 = tsmach_eax2 + i4;
- tsmach_ecx = i3;
-}
-
-
-void tspritevline(int32_t i1, int32_t i2, int32_t numPixels, uint32_t i4, int32_t i5, int32_t dest)
-{
- while (numPixels)
- {
- numPixels--;
- if (numPixels != 0)
- {
- uint32_t adder = tsmach_eax2;
- i4 += tsmach_ecx;
- if (i4 < (i4 - tsmach_ecx)) adder = tsmach_eax3;
- i1 = *((uint8_t *)i5);
- i2 += tsmach_eax1;
- if (i2 < (i2 - tsmach_eax1)) i5++;
- i5 += adder;
- // tstartsvline
- if (i1 != 0xff)
- {
- uint16_t val;
- val = ((uint8_t *)tspal)[i1];
- val |= ((*((uint8_t *)dest))<<8);
-
- if (transrev)
- val = ((val>>8)|(val<<8));
-
- i1 = transPalette[val];
-
- if (pixelsAllowed-- > 0)
- *((uint8_t *)dest) = (i1&0xff);
- }
- dest += bytesperline;
- }
-
-
- }
-}
-
-
-static int32_t mmach_eax;
-static int32_t mmach_asm3;
-static int32_t mmach_asm1;
-static int32_t mmach_asm2;
-
-void mhline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- mmach_eax = i1;
- mmach_asm3 = asm3;
- mmach_asm1 = asm1;
- mmach_asm2 = asm2;
- mhlineskipmodify(asm2,i2,i3,i4,i5,i6);
-}
-
-
-static uint8_t mshift_al = 26;
-static uint8_t mshift_bl = 6;
-void mhlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- uint32_t ebx;
- int counter = (i3>>16);
- while (counter >= 0)
- {
- ebx = i2 >> mshift_al;
- ebx = shld (ebx, (uint32_t)i5, mshift_bl);
- i1 = ((uint8_t *)mmach_eax)[ebx];
-
- if (pixelsAllowed-- > 0)
- if ((i1&0xff) != 0xff)
- *((uint8_t *)i6) = (((uint8_t *)mmach_asm3)[i1]);
-
- i2 += mmach_asm1;
- i5 += mmach_asm2;
- i6++;
- counter--;
-
-
- }
-}
-
-
-void msethlineshift(int32_t i1, int32_t i2)
-{
- i1 = 256-i1;
- mshift_al = (i1&0x1f);
- mshift_bl = (i2&0x1f);
-} /* msethlineshift */
-
-
-static int32_t tmach_eax;
-static int32_t tmach_asm3;
-static int32_t tmach_asm1;
-static int32_t tmach_asm2;
-
-void thline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- tmach_eax = i1;
- tmach_asm3 = asm3;
- tmach_asm1 = asm1;
- tmach_asm2 = asm2;
- thlineskipmodify(asm2,i2,i3,i4,i5,i6);
-}
-
-static uint8_t tshift_al = 26;
-static uint8_t tshift_bl = 6;
-void thlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- uint32_t ebx;
- int counter = (i3>>16);
- while (counter >= 0)
- {
- ebx = i2 >> tshift_al;
- ebx = shld (ebx, (uint32_t)i5, tshift_bl);
- i1 = ((uint8_t *)tmach_eax)[ebx];
- if ((i1&0xff) != 0xff)
- {
- uint16_t val = (((uint8_t *)tmach_asm3)[i1]);
- val |= (*((uint8_t *)i6)<<8);
-
- if (transrev)
- val = ((val>>8)|(val<<8));
-
- if (pixelsAllowed-- > 0)
- *((uint8_t *)i6) = transPalette[val];
- }
-
- i2 += tmach_asm1;
- i5 += tmach_asm2;
- i6++;
- counter--;
-
-
- }
-}
-
-
-void tsethlineshift(int32_t i1, int32_t i2)
-{
- i1 = 256-i1;
- tshift_al = (i1&0x1f);
- tshift_bl = (i2&0x1f);
-}
-
-
-
-
-static int32_t slopemach_ebx;
-static int32_t slopemach_ecx;
-static int32_t slopemach_edx;
-static uint8_t slopemach_ah1;
-static uint8_t slopemach_ah2;
-static float asm2_f;
-typedef union { unsigned int i; float f; } bitwisef2i;
-void setupslopevlin(int32_t i1, int32_t i2, int32_t i3)
-{
- bitwisef2i c;
- slopemach_ebx = i2;
- slopemach_ecx = i3;
- slopemach_edx = (1<<(i1&0x1f)) - 1;
- slopemach_edx <<= ((i1&0x1f00)>>8);
- slopemach_ah1 = 32-((i1&0x1f00)>>8);
- slopemach_ah2 = (slopemach_ah1 - (i1&0x1f)) & 0x1f;
- c.f = asm2_f = (float)asm1;
- asm2 = c.i;
-}
-
-extern int32_t reciptable[2048];
-extern int32_t globalx3, globaly3;
-extern int32_t fpuasm;
-#define low32(a) ((a&0xffffffff))
-#define high32(a) ((int)(((__int64)a&(__int64)0xffffffff00000000)>>32))
-
-//FCS: Render RENDER_SLOPPED_CEILING_AND_FLOOR
-void slopevlin(int32_t i1, uint32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
-{
- bitwisef2i c;
- uint32_t ecx,eax,ebx,edx,esi,edi;
- float a = (float) asm3 + asm2_f;
- i1 -= slopemach_ecx;
- esi = i5 + low32((__int64)globalx3 * (__int64)(i2<<3));
- edi = i6 + low32((__int64)globaly3 * (__int64)(i2<<3));
- ebx = i4;
-
- if (!RENDER_SLOPPED_CEILING_AND_FLOOR)
- return;
-
- do {
- // -------------
- // All this is calculating a fixed point approx. of 1/a
- c.f = a;
- fpuasm = eax = c.i;
- edx = (((int32_t)eax) < 0) ? 0xffffffff : 0;
- eax = eax << 1;
- ecx = (eax>>24); // exponent
- eax = ((eax&0xffe000)>>11);
- ecx = ((ecx&0xffffff00)|((ecx-2)&0xff));
- eax = reciptable[eax/4];
- eax >>= (ecx&0x1f);
- eax ^= edx;
- // -------------
- edx = i2;
- i2 = eax;
- eax -= edx;
- ecx = low32((__int64)globalx3 * (__int64)eax);
- eax = low32((__int64)globaly3 * (__int64)eax);
- a += asm2_f;
-
- asm4 = ebx;
- ecx = ((ecx&0xffffff00)|(ebx&0xff));
- if (ebx >= 8) ecx = ((ecx&0xffffff00)|8);
-
- ebx = esi;
- edx = edi;
- while ((ecx&0xff))
- {
- ebx >>= slopemach_ah2;
- esi += ecx;
- edx >>= slopemach_ah1;
- ebx &= slopemach_edx;
- edi += eax;
- i1 += slopemach_ecx;
- edx = ((edx&0xffffff00)|((((uint8_t *)(ebx+edx))[slopemach_ebx])));
- ebx = *((uint32_t*)i3); // register trickery
- i3 -= 4;
- eax = ((eax&0xffffff00)|(*((uint8_t *)(ebx+edx))));
- ebx = esi;
-
- if (pixelsAllowed-- > 0)
- *((uint8_t *)i1) = (eax&0xff);
-
- edx = edi;
- ecx = ((ecx&0xffffff00)|((ecx-1)&0xff));
-
-
- }
- ebx = asm4;
- ebx -= 8; // BITSOFPRECISIONPOW
-
-
-
- } while ((int32_t)ebx > 0);
-}
-
-
-
-void settrans(int32_t type){
- transrev = type;
-}
\ No newline at end of file
--- a/Engine/src/a.h
+++ /dev/null
@@ -1,97 +1,0 @@
-/*
- * "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
- * Ken Silverman's official web site: "http://www.advsys.net/ken"
- * See the included license file "BUILDLIC.TXT" for license info.
- * This file IS NOT A PART OF Ken Silverman's original release
- */
-
-#ifndef _INCLUDE_A_H_
-#define _INCLUDE_A_H_
-
-#ifdef _WIN32
- #include "windows/inttypes.h"
-#else
- #include <inttypes.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern uint8_t *globalpalwritten;
-extern int16_t globalshiftval;
-
-void sethlinesizes(int32_t,int32_t,int32_t);
-
-
-void hlineasm4(int32_t,int32_t,uint32_t,uint32_t,int32_t);
-void setuprhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void rhlineasm4(int32_t,int32_t,int32_t,uint32_t,uint32_t,int32_t);
-void setuprmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void rmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-
-
-void setBytesPerLine(int32_t);
-void fixtransluscence(uint8_t*);
-int32_t prevlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-int32_t vlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-
-int32_t tvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void setuptvlineasm2(int32_t,int32_t,int32_t);
-void tvlineasm2(uint32_t,uint32_t,uint32_t,uint32_t,uint32_t,uint32_t);
-int32_t mvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void setupvlineasm(int32_t);
-void vlineasm4(int32_t,int32_t);
-void setupmvlineasm(int32_t);
-void mvlineasm4(int32_t,int32_t);
-void setupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void spritevline(int32_t,uint32_t,int32_t,uint32_t,int32_t,int32_t);
-void msetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void mspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void tsetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void tspritevline(int32_t,int32_t,int32_t,uint32_t,int32_t,int32_t);
-void mhline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void mhlineskipmodify(int32_t,uint32_t,uint32_t,int32_t,int32_t,int32_t);
-void msethlineshift(int32_t,int32_t);
-void thline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void thlineskipmodify(int32_t,uint32_t,uint32_t,int32_t,int32_t,int32_t);
-void tsethlineshift(int32_t,int32_t);
-void setupslopevlin(int32_t,int32_t,int32_t);
-void slopevlin(int32_t,uint32_t,int32_t,int32_t,int32_t,int32_t);
-#define TRANS_NORMAL 0
-#define TRANS_REVERSE 1
-void settrans(int32_t type);
-
-
-
-int32_t is_vmware_running(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-//FCS: In order to see how the engine renders different part of the screen you can set the following macros
-//VISUALIZE RENDERER
-
-#define MAX_PIXEL_RENDERERED (800*600)
-extern uint32_t pixelsAllowed;
-
-#define RENDER_DRAW_WALL_BORDERS 1
-#define RENDER_DRAW_WALL_INSIDE 1
-#define RENDER_DRAW_CEILING_AND_FLOOR 1
-#define RENDER_DRAW_TOP_AND_BOTTOM_COLUMN 1
-#define RENDER_SLOPPED_CEILING_AND_FLOOR 1
-
-#if RENDER_DRAW_WALL_BORDERS && RENDER_DRAW_WALL_INSIDE && RENDER_DRAW_CEILING_AND_FLOOR && RENDER_DRAW_TOP_AND_BOTTOM_COLUMN && RENDER_SLOPPED_CEILING_AND_FLOOR && MAX_PIXEL_RENDERERED!=0
- #define CLEAR_FRAMEBUFFER 0
-#else
- #define CLEAR_FRAMEBUFFER 1
-#endif
-//END VISUALIZE RENDERER
-
-#endif /* include-once-blocker. */
-
-/* end of a.h ... */
-
-
--- a/Engine/src/cache1d.h
+++ b/Engine/src/cache1d.h
@@ -24,7 +24,12 @@
void allocache (int32_t *newhandle, int32_t newbytes, uint8_t *newlockptr);
void suckcache (int32_t *suckptr);
void agecache(void);
+
+
void reportandexit(char *errormessage);
+
+
+//Filesystem
int32_t initgroupfile(const char *filename);
void uninitgroupfile(void);
uint16_t crc16(uint8_t *data_p, uint16_t length);
@@ -47,9 +52,4 @@
extern int32_t TCkopen4load(const char *filename, int readfromGRP);
-#endif /* !defined _INCLUDE_CACHE1D_H_ */
-
-/* end of cache1d.h ... */
-
-
-
+#endif
\ No newline at end of file
--- a/Engine/src/display.h
+++ b/Engine/src/display.h
@@ -10,62 +10,6 @@
#include "platform.h"
-#if (defined PLATFORM_SUPPORTS_SDL)
-#include "SDL.h"
-
-/* environment variables names... */
-/* These are only honored by the SDL driver. */
-#define BUILD_NOMOUSEGRAB "BUILD_NOMOUSEGRAB"
-#define BUILD_WINDOWED "BUILD_WINDOWED"
-#define BUILD_SDLDEBUG "BUILD_SDLDEBUG"
-#define BUILD_RENDERER "BUILD_RENDERER"
-#define BUILD_GLLIBRARY "BUILD_GLLIBRARY"
-#define BUILD_USERSCREENRES "BUILD_USERSCREENRES"
-#define BUILD_MAXSCREENRES "BUILD_MAXSCREENRES"
-#define BUILD_HALLOFMIRRORS "BUILD_HALLOFMIRRORS"
-#define BUILD_GLDUMP "BUILD_GLDUMP"
-#define BUILD_SDLJOYSTICK "BUILD_SDLJOYSTICK"
-
-/* This part sucks. */
-#if (defined __WATCOMC__)
-#pragma aux (__cdecl) SDL_Init;
-#pragma aux (__cdecl) SDL_PumpEvents;
-#pragma aux (__cdecl) SDL_PollEvent;
-#pragma aux (__cdecl) SDL_GetMouseState;
-#pragma aux (__cdecl) SDL_WM_GrabInput;
-#pragma aux (__cdecl) SDL_GetError;
-#pragma aux (__cdecl) SDL_SetEventFilter;
-#pragma aux (__cdecl) SDL_WM_SetCaption;
-#pragma aux (__cdecl) SDL_ClearError;
-#pragma aux (__cdecl) SDL_SetVideoMode;
-#pragma aux (__cdecl) SDL_ClearError;
-#pragma aux (__cdecl) SDL_Quit;
-#pragma aux (__cdecl) SDL_QuitSubSystem;
-#pragma aux (__cdecl) SDL_GetTicks;
-#pragma aux (__cdecl) SDL_GetVideoInfo;
-#pragma aux (__cdecl) SDL_ListModes;
-#pragma aux (__cdecl) SDL_SetColors;
-#pragma aux (__cdecl) SDL_ShowCursor;
-#pragma aux (__cdecl) SDL_LockSurface;
-#pragma aux (__cdecl) SDL_UnlockSurface;
-#pragma aux (__cdecl) SDL_FillRect;
-#pragma aux (__cdecl) SDL_Delay;
-#pragma aux (__cdecl) SDL_AddTimer;
-#pragma aux (__cdecl) SDL_RemoveTimer;
-#pragma aux (__cdecl) SDL_Flip;
-#pragma aux (__cdecl) SDL_UpdateRect;
-#pragma aux (__cdecl) SDL_GetVideoSurface;
-#pragma aux (__cdecl) SDL_VideoDriverName;
-#pragma aux (__cdecl) SDL_SetPalette;
-#pragma aux (__cdecl) SDL_VideoModeOK;
-#pragma aux (__cdecl) SDL_GetClipRect;
-#pragma aux (__cdecl) SDL_SetClipRect;
-#pragma aux (__cdecl) SDL_WM_ToggleFullScreen;
-#pragma aux (__cdecl) SDL_Linked_Version;
-#endif /* defined __WATCOMC__ */
-
-#endif /* defined PLATFORM_SUPPORTS_SDL */
-
/* set these in your _platform_init() implementation. */
extern int _argc;
extern char **_argv;
@@ -116,28 +60,20 @@
int _joystick_hat(int hat);
int _joystick_button(int button);
-/*
- * VESA replacement code: The Unix (not-actually-VESA) version of this is
- * originally using SDL (Simple Directmedia Layer: http://www.libsdl.org/),
- * and is stored in sdl_driver.c, but there's no reason another driver
- * couldn't be dropped in, so int32_t as it implements these functions. Please
- * reference sdl_driver.c and ves2.h (the original code) for all the nuances
- * and global variables that need to get set up correctly.
- */
void getvalidvesamodes(void);
int VBE_getPalette(int32_t start, int32_t num, uint8_t *dapal);
int VBE_setPalette(int32_t start, int32_t num, uint8_t *palettebuffer);
int setvesa(int32_t x, int32_t y);
-void uninitvesa(void);
+
void setvmode(int mode);
uint8_t readpixel(int32_t offset);
-void drawpixel(int32_t offset, Uint8 pixel);
-void drawpixels(int32_t offset, Uint16 pixels);
-void drawpixelses(int32_t offset, Uint32 pixelses);
+void drawpixel(int32_t offset, uint8_t pixel);
+void drawpixels(int32_t offset, uint16_t pixels);
+void drawpixelses(int32_t offset, uint32_t pixelses);
void drawpixel16(int32_t offset);
void fillscreen16 (int32_t input1, int32_t input2, int32_t input3);
-void setactivepage(int32_t dapagenum);
+
void clear2dscreen(void);
void _updateScreenRect(int32_t x, int32_t y, int32_t w, int32_t h);
@@ -163,10 +99,7 @@
void drawline16(int32_t XStart, int32_t YStart, int32_t XEnd, int32_t YEnd, uint8_t Color);
void setcolor16(int i1);
-int using_opengl(void);
-#endif /* _INCLUDE_DISPLAY_H_ */
-
-/* end of display.h ... */
+#endif
--- /dev/null
+++ b/Engine/src/draw.c
@@ -1,0 +1,831 @@
+// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
+// Ken Silverman's official web site: "http://www.advsys.net/ken"
+// See the included license file "BUILDLIC.TXT" for license info.
+// This file has been modified from Ken Silverman's original release
+
+/* DDOI - This file is an attempt to reimplement a_nasm.asm in C */
+
+#include "platform.h"
+#include "build.h"
+#include "draw.h"
+
+uint32_t pixelsAllowed = 10000000000;
+
+#define shrd(a,b,c) (((b)<<(32-(c))) | ((a)>>(c)))
+#define shld(a,b,c) (((b)>>(32-(c))) | ((a)<<(c)))
+
+extern int32_t asm1;
+extern int32_t asm2;
+extern int32_t asm3;
+extern int32_t asm4;
+
+static uint8_t machxbits_al;
+static uint8_t machxbits_bl;
+static int32_t machxbits_ecx;
+void sethlinesizes(int32_t i1, int32_t i2, int32_t i3)
+{
+ machxbits_al = i1;
+ machxbits_bl = i2;
+ machxbits_ecx = i3;
+}
+
+
+//FCS: Draw ceiling/floors
+//Draw a line from destination in the framebuffer to framebuffer-numPixels
+void hlineasm4(int32_t numPixels, int32_t shade, uint32_t i4, uint32_t i5, int32_t destination){
+
+ uint8_t *dest = (uint8_t *) destination;
+ int32_t shifter = ((256-machxbits_al) & 0x1f);
+ uint32_t source;
+ uint8_t bits = machxbits_bl;
+ uint8_t *lookup = (uint8_t *) machxbits_ecx;
+
+
+ shade = shade & 0xffffff00;
+ numPixels++;
+
+ if (!RENDER_DRAW_CEILING_AND_FLOOR)
+ return;
+
+ while (numPixels) {
+
+ source = i5 >> shifter;
+ source = shld(source,i4,bits);
+ source = lookup[source];
+
+ if (pixelsAllowed-- > 0)
+ *dest = globalpalwritten[shade|source];
+
+ dest--;
+
+ i5 -= asm1;
+ i4 -= asm2;
+
+ numPixels--;
+
+ }
+}
+
+static int32_t rmach_eax;
+static int32_t rmach_ebx;
+static int32_t rmach_ecx;
+static int32_t rmach_edx;
+static int32_t rmach_esi;
+void setuprhlineasm4(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ rmach_eax = i1;
+ rmach_ebx = i2;
+ rmach_ecx = i3;
+ rmach_edx = i4;
+ rmach_esi = i5;
+}
+
+
+void rhlineasm4(int32_t i1, int32_t i2, int32_t i3, uint32_t i4, uint32_t i5, int32_t dest)
+{
+ uint32_t ebp = dest - i1;
+ uint32_t rmach6b = ebp-1;
+ int32_t numPixels;
+
+ if (i1 <= 0) return;
+
+ numPixels = i1;
+ do {
+
+
+
+ i3 = ((i3&0xffffff00)|(*((uint8_t *)i2)));
+ i4 -= rmach_eax;
+ ebp = (((i4+rmach_eax) < i4) ? -1 : 0);
+ i5 -= rmach_ebx;
+ if ((i5 + rmach_ebx) < i5) i2 -= (rmach_ecx+1);
+ else i2 -= rmach_ecx;
+ ebp &= rmach_esi;
+ i1 = ((i1&0xffffff00)|(((uint8_t *)i3)[rmach_edx]));
+
+ if (pixelsAllowed-- > 0)
+ ((uint8_t *)rmach6b)[numPixels] = (i1&0xff);
+
+ i2 -= ebp;
+ numPixels--;
+ } while (numPixels);
+}
+
+static int32_t rmmach_eax;
+static int32_t rmmach_ebx;
+static int32_t rmmach_ecx;
+static int32_t rmmach_edx;
+static int32_t rmmach_esi;
+void setuprmhlineasm4(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ rmmach_eax = i1;
+ rmmach_ebx = i2;
+ rmmach_ecx = i3;
+ rmmach_edx = i4;
+ rmmach_esi = i5;
+}
+
+
+//FCS: ????
+void rmhlineasm4(int32_t i1, int32_t shade, int32_t colorIndex, int32_t i4, int32_t i5, int32_t dest)
+{
+ uint32_t ebp = dest - i1;
+ uint32_t rmach6b = ebp-1;
+ int32_t numPixels;
+
+ if (i1 <= 0)
+ return;
+
+ numPixels = i1;
+ do {
+
+
+
+ colorIndex = ((colorIndex&0xffffff00)|(*((uint8_t *)shade)));
+ i4 -= rmmach_eax;
+ ebp = (((i4+rmmach_eax) < i4) ? -1 : 0);
+ i5 -= rmmach_ebx;
+
+ if ((i5 + rmmach_ebx) < i5)
+ shade -= (rmmach_ecx+1);
+ else
+ shade -= rmmach_ecx;
+
+ ebp &= rmmach_esi;
+
+ //Check if this colorIndex is the transparent color (255).
+ if ((colorIndex&0xff) != 255) {
+ if (pixelsAllowed-- > 0)
+ {
+ i1 = ((i1&0xffffff00)|(((uint8_t *)colorIndex)[rmmach_edx]));
+ ((uint8_t *)rmach6b)[numPixels] = (i1&0xff);
+ }
+ }
+
+ shade -= ebp;
+ numPixels--;
+
+ } while (numPixels);
+}
+
+
+//Variable used to draw column.
+//This is how much you have to skip in the framebuffer in order to be one pixel below.
+static int32_t bytesperline;
+void setBytesPerLine(int32_t _bytesperline)
+{
+ bytesperline = _bytesperline;
+}
+
+
+static uint8_t* transPalette;
+void fixtransluscence(uint8_t* transLuscentPalette)
+{
+ transPalette = transLuscentPalette;
+}
+
+static uint8_t mach3_al;
+
+//FCS: RENDER TOP AND BOTTOM COLUMN
+int32_t prevlineasm1(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ uint8_t *source = (uint8_t *)i5;
+ uint8_t *dest = (uint8_t *)i6;
+
+ if (i3 == 0)
+ {
+ if (!RENDER_DRAW_TOP_AND_BOTTOM_COLUMN)
+ return 0;
+
+ i1 += i4;
+ //FCS
+ //((uint32_t)i4) >>= mach3_al;
+ i4 = ((uint32_t)i4) >> mach3_al;
+ i4 = (i4&0xffffff00) | (source[i4]&0xff);
+
+ if (pixelsAllowed-- > 0)
+ *dest = ((uint8_t *)i2)[i4];
+
+
+
+ return i1;
+ } else {
+ return vlineasm1(i1,i2,i3,i4,i5,i6);
+ }
+}
+
+
+//FCS: This is used to draw wall border vertical lines
+int32_t vlineasm1(int32_t vince, int32_t palookupoffse, int32_t numPixels, int32_t vplce, int32_t bufplce, int32_t frameBufferDestination)
+{
+ uint32_t temp;
+ uint8_t *dest = (uint8_t *)frameBufferDestination;
+
+ if (!RENDER_DRAW_WALL_BORDERS)
+ return vplce;
+
+ numPixels++;
+ while (numPixels)
+ {
+
+
+
+ temp = ((uint32_t)vplce) >> mach3_al;
+
+ temp = ((uint8_t *)bufplce)[temp];
+
+ if (pixelsAllowed-- > 0)
+ *dest = ((uint8_t *)palookupoffse)[temp];
+
+ vplce += vince;
+ dest += bytesperline;
+ numPixels--;
+ }
+ return vplce;
+}
+
+static int transrev = 0;
+int32_t tvlineasm1(int32_t i1, int32_t i2, int32_t numPixels, int32_t i4, int32_t i5, int32_t _dest)
+{
+ uint8_t *source = (uint8_t *)i5;
+ uint8_t *dest = (uint8_t *)_dest;
+
+ uint8_t shiftValue = (globalshiftval & 0x1f);
+
+ numPixels++;
+ while (numPixels)
+ {
+ uint32_t temp = i4;
+ temp >>= shiftValue;
+ temp = source[temp];
+
+ //255 is the index for transparent color index. Skip drawing this pixel.
+ if (temp != 255)
+ {
+ uint16_t colorIndex;
+
+ colorIndex = ((uint8_t *)i2)[temp];
+ colorIndex |= ((*dest)<<8);
+
+ if (transrev)
+ colorIndex = ((colorIndex>>8)|(colorIndex<<8));
+
+ if (pixelsAllowed-- > 0)
+ *dest = transPalette[colorIndex];
+ }
+
+ i4 += i1;
+
+ //We are drawing a column ?!
+ dest += bytesperline;
+ numPixels--;
+ }
+ return i4;
+} /* tvlineasm1 */
+
+
+static uint8_t tran2shr;
+static uint32_t tran2pal_ebx;
+static uint32_t tran2pal_ecx;
+void setuptvlineasm2(int32_t i1, int32_t i2, int32_t i3)
+{
+ tran2shr = (i1&0x1f);
+ tran2pal_ebx = i2;
+ tran2pal_ecx = i3;
+} /* */
+
+
+void tvlineasm2(uint32_t i1, uint32_t i2, uint32_t i3, uint32_t i4, uint32_t i5, uint32_t i6)
+{
+ uint32_t ebp = i1;
+ uint32_t tran2inca = i2;
+ uint32_t tran2incb = asm1;
+ uint32_t tran2bufa = i3;
+ uint32_t tran2bufb = i4;
+ uint32_t tran2edi = asm2;
+ uint32_t tran2edi1 = asm2 + 1;
+
+ i6 -= asm2;
+
+ do {
+
+ i1 = i5 >> tran2shr;
+ i2 = ebp >> tran2shr;
+ i5 += tran2inca;
+ ebp += tran2incb;
+ i3 = ((uint8_t *)tran2bufa)[i1];
+ i4 = ((uint8_t *)tran2bufb)[i2];
+ if (i3 == 255) { // skipdraw1
+ if (i4 != 255) { // skipdraw3
+ uint16_t val;
+ val = ((uint8_t *)tran2pal_ecx)[i4];
+ val |= (((uint8_t *)i6)[tran2edi1]<<8);
+
+ if (transrev)
+ val = ((val>>8)|(val<<8));
+
+ if (pixelsAllowed-- > 0)
+ ((uint8_t *)i6)[tran2edi1] = transPalette[val];
+ }
+ } else if (i4 == 255) { // skipdraw2
+ uint16_t val;
+ val = ((uint8_t *)tran2pal_ebx)[i3];
+ val |= (((uint8_t *)i6)[tran2edi]<<8);
+
+ if (transrev) val =
+ ((val>>8)|(val<<8));
+
+ if (pixelsAllowed-- > 0)
+ ((uint8_t *)i6)[tran2edi] = transPalette[val];
+ } else {
+ uint16_t l = ((uint8_t *)i6)[tran2edi]<<8;
+ uint16_t r = ((uint8_t *)i6)[tran2edi1]<<8;
+ l |= ((uint8_t *)tran2pal_ebx)[i3];
+ r |= ((uint8_t *)tran2pal_ecx)[i4];
+ if (transrev) {
+ l = ((l>>8)|(l<<8));
+ r = ((r>>8)|(r<<8));
+ }
+ if (pixelsAllowed-- > 0)
+ {
+ ((uint8_t *)i6)[tran2edi] = transPalette[l];
+ ((uint8_t *)i6)[tran2edi1] =transPalette[r];
+ pixelsAllowed--;
+ }
+ }
+ i6 += bytesperline;
+ } while (i6 > i6 - bytesperline);
+ asm1 = i5;
+ asm2 = ebp;
+}
+
+
+
+static uint8_t machmv;
+int32_t mvlineasm1(int32_t vince, int32_t palookupoffse, int32_t i3, int32_t vplce, int32_t bufplce, int32_t i6)
+{
+ uint32_t temp;
+ uint8_t *dest = (uint8_t *)i6;
+
+ // FIX_00087: 1024x768 mode being slow. Undone FIX_00070 and fixed font issue again
+ for(;i3>=0;i3--)
+ {
+ temp = ((uint32_t)vplce) >> machmv;
+ temp = ((uint8_t *)bufplce)[temp];
+
+ if (temp != 255)
+ {
+ if (pixelsAllowed-- > 0)
+ *dest = ((uint8_t *)palookupoffse)[temp];
+ }
+
+ vplce += vince;
+ dest += bytesperline;
+ }
+ return vplce;
+} /* mvlineasm1 */
+
+
+void setupvlineasm(int32_t i1)
+{
+ mach3_al = (i1&0x1f);
+}
+
+extern int32_t vplce[4], vince[4], palookupoffse[4], bufplce[4];
+
+
+
+//FCS This is used to fill the inside of a wall
+void vlineasm4(int32_t i1, int32_t i2)
+{
+
+ if (!RENDER_DRAW_WALL_INSIDE)
+ return ;
+
+ {
+ int i;
+ uint32_t temp;
+ uint32_t index = (i2 + ylookup[i1]);
+ uint8_t *dest = (uint8_t *)(-ylookup[i1]);
+ do {
+ for (i = 0; i < 4; i++)
+ {
+
+ temp = ((uint32_t)vplce[i]) >> mach3_al;
+ temp = (((uint8_t *)(bufplce[i]))[temp]);
+ if (pixelsAllowed-- > 0)
+ dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
+ vplce[i] += vince[i];
+ }
+ dest += bytesperline;
+ } while (((uint32_t)dest - bytesperline) < ((uint32_t)dest));
+ }
+}
+
+
+void setupmvlineasm(int32_t i1)
+{
+ machmv = (i1&0x1f);
+}
+
+
+void mvlineasm4(int32_t column, int32_t framebufferOffset)
+{
+ int i;
+ uint32_t temp;
+ uint32_t index = (framebufferOffset + ylookup[column]);
+ uint8_t *dest = (uint8_t *)(-ylookup[column]);
+
+ do {
+
+ if (pixelsAllowed <= 0)
+ return;
+
+ for (i = 0; i < 4; i++)
+ {
+
+ temp = ((uint32_t)vplce[i]) >> machmv;
+ temp = (((uint8_t *)(bufplce[i]))[temp]);
+ if (temp != 255)
+ {
+ if (pixelsAllowed-- > 0)
+ dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
+ }
+ vplce[i] += vince[i];
+ }
+ dest += bytesperline;
+
+ } while (((uint32_t)dest - bytesperline) < ((uint32_t)dest));
+} /* mvlineasm4 */
+
+
+static int32_t spal_eax;
+static int32_t smach_eax;
+static int32_t smach2_eax;
+static int32_t smach5_eax;
+static int32_t smach_ecx;
+void setupspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ spal_eax = i1;
+ smach_eax = (i5<<16);
+ smach2_eax = (i5>>16)+i2;
+ smach5_eax = smach2_eax + i4;
+ smach_ecx = i3;
+}
+
+
+void spritevline(int32_t i1, uint32_t i2, int32_t i3, uint32_t i4, int32_t i5, int32_t i6)
+{
+ uint8_t *source = (uint8_t *)i5;
+ uint8_t *dest = (uint8_t *)i6;
+
+setup:
+
+ i2 += smach_eax;
+ i1 = (i1&0xffffff00) | (*source&0xff);
+ if ((i2 - smach_eax) > i2)
+ source += smach2_eax + 1;
+ else
+ source += smach2_eax;
+
+draw:
+ i1 = (i1&0xffffff00) | (((uint8_t *)spal_eax)[i1]&0xff);
+
+ if (pixelsAllowed-- > 0)
+ *dest = i1;
+
+
+
+ dest += bytesperline;
+
+ i4 += smach_ecx;
+ i4--;
+
+ if (!((i4 - smach_ecx) > i4) && i4 != 0)
+ goto setup;
+
+ if (i4 == 0)
+ return;
+
+ i2 += smach_eax;
+ i1 = (i1&0xffffff00) | (*source&0xff);
+
+ if ((i2 - smach_eax) > i2)
+ source += smach5_eax + 1;
+ else
+ source += smach5_eax;
+
+ goto draw;
+} /* spritevline */
+
+
+static int32_t mspal_eax;
+static int32_t msmach_eax;
+static int32_t msmach2_eax;
+static int32_t msmach5_eax;
+static int32_t msmach_ecx;
+void msetupspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ mspal_eax = i1;
+ msmach_eax = (i5<<16);
+ msmach2_eax = (i5>>16)+i2;
+ msmach5_eax = smach2_eax + i4;
+ msmach_ecx = i3;
+}
+
+
+void mspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ uint8_t *source = (uint8_t *)i5;
+ uint8_t *dest = (uint8_t *)i6;
+
+setup:
+ i2 += smach_eax;
+ i1 = (i1&0xffffff00) | (*source&0xff);
+ if ((i2 - smach_eax) > i2) source += smach2_eax + 1;
+ else source += smach2_eax;
+
+ draw:
+ if ((i1&0xff) != 255)
+ {
+ i1 = (i1&0xffffff00) | (((uint8_t *)spal_eax)[i1]&0xff);
+ if (pixelsAllowed-- > 0)
+ *dest = i1;
+
+
+ }
+ dest += bytesperline;
+
+ i4 += smach_ecx;
+ i4--;
+ if (!((i4 - smach_ecx) > i4) && i4 != 0)
+ goto setup;
+ if (i4 == 0) return;
+ i2 += smach_eax;
+ i1 = (i1&0xffffff00) | (*source&0xff);
+ if ((i2 - smach_eax) > i2) source += smach5_eax + 1;
+ else source += smach5_eax;
+ goto draw;
+}
+
+
+uint32_t tspal;
+uint32_t tsmach_eax1;
+uint32_t tsmach_eax2;
+uint32_t tsmach_eax3;
+uint32_t tsmach_ecx;
+void tsetupspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ tspal = i1;
+ tsmach_eax1 = i5 << 16;
+ tsmach_eax2 = (i5 >> 16) + i2;
+ tsmach_eax3 = tsmach_eax2 + i4;
+ tsmach_ecx = i3;
+}
+
+
+void tspritevline(int32_t i1, int32_t i2, int32_t numPixels, uint32_t i4, int32_t i5, int32_t dest)
+{
+ while (numPixels)
+ {
+ numPixels--;
+ if (numPixels != 0)
+ {
+ uint32_t adder = tsmach_eax2;
+ i4 += tsmach_ecx;
+ if (i4 < (i4 - tsmach_ecx)) adder = tsmach_eax3;
+ i1 = *((uint8_t *)i5);
+ i2 += tsmach_eax1;
+ if (i2 < (i2 - tsmach_eax1)) i5++;
+ i5 += adder;
+ // tstartsvline
+ if (i1 != 0xff)
+ {
+ uint16_t val;
+ val = ((uint8_t *)tspal)[i1];
+ val |= ((*((uint8_t *)dest))<<8);
+
+ if (transrev)
+ val = ((val>>8)|(val<<8));
+
+ i1 = transPalette[val];
+
+ if (pixelsAllowed-- > 0)
+ *((uint8_t *)dest) = (i1&0xff);
+ }
+ dest += bytesperline;
+ }
+
+
+ }
+}
+
+
+static int32_t mmach_eax;
+static int32_t mmach_asm3;
+static int32_t mmach_asm1;
+static int32_t mmach_asm2;
+
+void mhline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ mmach_eax = i1;
+ mmach_asm3 = asm3;
+ mmach_asm1 = asm1;
+ mmach_asm2 = asm2;
+ mhlineskipmodify(asm2,i2,i3,i4,i5,i6);
+}
+
+
+static uint8_t mshift_al = 26;
+static uint8_t mshift_bl = 6;
+void mhlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ uint32_t ebx;
+ int counter = (i3>>16);
+ while (counter >= 0)
+ {
+ ebx = i2 >> mshift_al;
+ ebx = shld (ebx, (uint32_t)i5, mshift_bl);
+ i1 = ((uint8_t *)mmach_eax)[ebx];
+
+ if (pixelsAllowed-- > 0)
+ if ((i1&0xff) != 0xff)
+ *((uint8_t *)i6) = (((uint8_t *)mmach_asm3)[i1]);
+
+ i2 += mmach_asm1;
+ i5 += mmach_asm2;
+ i6++;
+ counter--;
+
+
+ }
+}
+
+
+void msethlineshift(int32_t i1, int32_t i2)
+{
+ i1 = 256-i1;
+ mshift_al = (i1&0x1f);
+ mshift_bl = (i2&0x1f);
+} /* msethlineshift */
+
+
+static int32_t tmach_eax;
+static int32_t tmach_asm3;
+static int32_t tmach_asm1;
+static int32_t tmach_asm2;
+
+void thline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ tmach_eax = i1;
+ tmach_asm3 = asm3;
+ tmach_asm1 = asm1;
+ tmach_asm2 = asm2;
+ thlineskipmodify(asm2,i2,i3,i4,i5,i6);
+}
+
+static uint8_t tshift_al = 26;
+static uint8_t tshift_bl = 6;
+void thlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ uint32_t ebx;
+ int counter = (i3>>16);
+ while (counter >= 0)
+ {
+ ebx = i2 >> tshift_al;
+ ebx = shld (ebx, (uint32_t)i5, tshift_bl);
+ i1 = ((uint8_t *)tmach_eax)[ebx];
+ if ((i1&0xff) != 0xff)
+ {
+ uint16_t val = (((uint8_t *)tmach_asm3)[i1]);
+ val |= (*((uint8_t *)i6)<<8);
+
+ if (transrev)
+ val = ((val>>8)|(val<<8));
+
+ if (pixelsAllowed-- > 0)
+ *((uint8_t *)i6) = transPalette[val];
+ }
+
+ i2 += tmach_asm1;
+ i5 += tmach_asm2;
+ i6++;
+ counter--;
+
+
+ }
+}
+
+
+void tsethlineshift(int32_t i1, int32_t i2)
+{
+ i1 = 256-i1;
+ tshift_al = (i1&0x1f);
+ tshift_bl = (i2&0x1f);
+}
+
+
+
+
+static int32_t slopemach_ebx;
+static int32_t slopemach_ecx;
+static int32_t slopemach_edx;
+static uint8_t slopemach_ah1;
+static uint8_t slopemach_ah2;
+static float asm2_f;
+typedef union { unsigned int i; float f; } bitwisef2i;
+void setupslopevlin(int32_t i1, int32_t i2, int32_t i3)
+{
+ bitwisef2i c;
+ slopemach_ebx = i2;
+ slopemach_ecx = i3;
+ slopemach_edx = (1<<(i1&0x1f)) - 1;
+ slopemach_edx <<= ((i1&0x1f00)>>8);
+ slopemach_ah1 = 32-((i1&0x1f00)>>8);
+ slopemach_ah2 = (slopemach_ah1 - (i1&0x1f)) & 0x1f;
+ c.f = asm2_f = (float)asm1;
+ asm2 = c.i;
+}
+
+extern int32_t reciptable[2048];
+extern int32_t globalx3, globaly3;
+extern int32_t fpuasm;
+#define low32(a) ((a&0xffffffff))
+#define high32(a) ((int)(((__int64)a&(__int64)0xffffffff00000000)>>32))
+
+//FCS: Render RENDER_SLOPPED_CEILING_AND_FLOOR
+void slopevlin(int32_t i1, uint32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+{
+ bitwisef2i c;
+ uint32_t ecx,eax,ebx,edx,esi,edi;
+ float a = (float) asm3 + asm2_f;
+ i1 -= slopemach_ecx;
+ esi = i5 + low32((__int64)globalx3 * (__int64)(i2<<3));
+ edi = i6 + low32((__int64)globaly3 * (__int64)(i2<<3));
+ ebx = i4;
+
+ if (!RENDER_SLOPPED_CEILING_AND_FLOOR)
+ return;
+
+ do {
+ // -------------
+ // All this is calculating a fixed point approx. of 1/a
+ c.f = a;
+ fpuasm = eax = c.i;
+ edx = (((int32_t)eax) < 0) ? 0xffffffff : 0;
+ eax = eax << 1;
+ ecx = (eax>>24); // exponent
+ eax = ((eax&0xffe000)>>11);
+ ecx = ((ecx&0xffffff00)|((ecx-2)&0xff));
+ eax = reciptable[eax/4];
+ eax >>= (ecx&0x1f);
+ eax ^= edx;
+ // -------------
+ edx = i2;
+ i2 = eax;
+ eax -= edx;
+ ecx = low32((__int64)globalx3 * (__int64)eax);
+ eax = low32((__int64)globaly3 * (__int64)eax);
+ a += asm2_f;
+
+ asm4 = ebx;
+ ecx = ((ecx&0xffffff00)|(ebx&0xff));
+ if (ebx >= 8) ecx = ((ecx&0xffffff00)|8);
+
+ ebx = esi;
+ edx = edi;
+ while ((ecx&0xff))
+ {
+ ebx >>= slopemach_ah2;
+ esi += ecx;
+ edx >>= slopemach_ah1;
+ ebx &= slopemach_edx;
+ edi += eax;
+ i1 += slopemach_ecx;
+ edx = ((edx&0xffffff00)|((((uint8_t *)(ebx+edx))[slopemach_ebx])));
+ ebx = *((uint32_t*)i3); // register trickery
+ i3 -= 4;
+ eax = ((eax&0xffffff00)|(*((uint8_t *)(ebx+edx))));
+ ebx = esi;
+
+ if (pixelsAllowed-- > 0)
+ *((uint8_t *)i1) = (eax&0xff);
+
+ edx = edi;
+ ecx = ((ecx&0xffffff00)|((ecx-1)&0xff));
+
+
+ }
+ ebx = asm4;
+ ebx -= 8; // BITSOFPRECISIONPOW
+
+
+
+ } while ((int32_t)ebx > 0);
+}
+
+
+
+void settrans(int32_t type){
+ transrev = type;
+}
\ No newline at end of file
--- /dev/null
+++ b/Engine/src/draw.h
@@ -1,0 +1,93 @@
+/*
+ * "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
+ * Ken Silverman's official web site: "http://www.advsys.net/ken"
+ * See the included license file "BUILDLIC.TXT" for license info.
+ * This file IS NOT A PART OF Ken Silverman's original release
+ */
+
+#ifndef _INCLUDE_A_H_
+#define _INCLUDE_A_H_
+
+#ifdef _WIN32
+ #include "windows/inttypes.h"
+#else
+ #include <inttypes.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern uint8_t *globalpalwritten;
+extern int16_t globalshiftval;
+
+void sethlinesizes(int32_t,int32_t,int32_t);
+
+
+void hlineasm4(int32_t,int32_t,uint32_t,uint32_t,int32_t);
+void setuprhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void rhlineasm4(int32_t,int32_t,int32_t,uint32_t,uint32_t,int32_t);
+void setuprmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void rmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+
+
+void setBytesPerLine(int32_t);
+void fixtransluscence(uint8_t*);
+int32_t prevlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+int32_t vlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+
+int32_t tvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void setuptvlineasm2(int32_t,int32_t,int32_t);
+void tvlineasm2(uint32_t,uint32_t,uint32_t,uint32_t,uint32_t,uint32_t);
+int32_t mvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void setupvlineasm(int32_t);
+void vlineasm4(int32_t,int32_t);
+void setupmvlineasm(int32_t);
+void mvlineasm4(int32_t,int32_t);
+void setupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void spritevline(int32_t,uint32_t,int32_t,uint32_t,int32_t,int32_t);
+void msetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void mspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void tsetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void tspritevline(int32_t,int32_t,int32_t,uint32_t,int32_t,int32_t);
+void mhline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void mhlineskipmodify(int32_t,uint32_t,uint32_t,int32_t,int32_t,int32_t);
+void msethlineshift(int32_t,int32_t);
+void thline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
+void thlineskipmodify(int32_t,uint32_t,uint32_t,int32_t,int32_t,int32_t);
+void tsethlineshift(int32_t,int32_t);
+void setupslopevlin(int32_t,int32_t,int32_t);
+void slopevlin(int32_t,uint32_t,int32_t,int32_t,int32_t,int32_t);
+#define TRANS_NORMAL 0
+#define TRANS_REVERSE 1
+void settrans(int32_t type);
+
+
+
+int32_t is_vmware_running(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+//FCS: In order to see how the engine renders different part of the screen you can set the following macros
+//VISUALIZE RENDERER
+
+#define MAX_PIXEL_RENDERERED (800*600)
+extern uint32_t pixelsAllowed;
+
+#define RENDER_DRAW_WALL_BORDERS 1
+#define RENDER_DRAW_WALL_INSIDE 1
+#define RENDER_DRAW_CEILING_AND_FLOOR 1
+#define RENDER_DRAW_TOP_AND_BOTTOM_COLUMN 1
+#define RENDER_SLOPPED_CEILING_AND_FLOOR 1
+
+#if RENDER_DRAW_WALL_BORDERS && RENDER_DRAW_WALL_INSIDE && RENDER_DRAW_CEILING_AND_FLOOR && RENDER_DRAW_TOP_AND_BOTTOM_COLUMN && RENDER_SLOPPED_CEILING_AND_FLOOR && MAX_PIXEL_RENDERERED!=0
+ #define CLEAR_FRAMEBUFFER 0
+#else
+ #define CLEAR_FRAMEBUFFER 1
+#endif
+//END VISUALIZE RENDERER
+
+#endif
\ No newline at end of file
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -285,7 +285,7 @@
uint16_t mapCRC;
-#include "a.h"
+#include "draw.h"
static __inline int32_t nsqrtasm(uint32_t param)
{
@@ -3853,7 +3853,7 @@
{
obuffermode = buffermode;
buffermode = 0;
- setactivepage(activepage);
+
}
}
else if (dastat&8)
@@ -4173,7 +4173,7 @@
if ((vidoption == 1) && (dastat&128) && (origbuffermode == 0))
{
buffermode = obuffermode;
- setactivepage(activepage);
+
}
}
@@ -7728,35 +7728,9 @@
}
-#ifdef DBGRECORD
-int krand(int line, uint8_t * file)
-{
- int i, k=0;
- uint8_t filename[2048];
- FILE *pFile;
-#else
int krand()
{
-#endif
-
randomseed = (randomseed*27584621)+1;
-
-#ifdef DBGRECORD
- for(i=0; file[i]; i++)
- {
- if(file[i]=='\\')
- {
- i++;
- k = 0;
- }
- filename[k++]=(file[i]=='.')?0:file[i];
- }
- // printf("%-5d %-8s %-8x\n", line, filename, randomseed);
- pFile = fopen("c:\\temp\\krand.txt","a");
- fprintf(pFile,"%-4d %-5s %-6x\n", line, filename, randomseed);
- fclose(pFile);
-#endif
-
return(((uint32_t )randomseed)>>16);
}
@@ -9043,10 +9017,10 @@
case 1:
for(i=0; i<numpages; i++)
{
- setactivepage(i);
+
clearbufbyte((void *)frameplace,imageSize,0L);
}
- setactivepage(activepage);
+
case 2:
clearbuf((void *)frameplace,(xdim*ydim)>>2,0L);
break;
--- a/Engine/src/engine.h
+++ b/Engine/src/engine.h
@@ -123,11 +123,9 @@
int pushmove(int32_t *x, int32_t *y, int32_t *z, short *sectnum,
int32_t walldist, int32_t ceildist, int32_t flordist,
uint32_t cliptype);
-#ifdef DBGRECORD
-int krand(int line, uint8_t * file);
-#else
+
int krand(void);
-#endif
+
void flushperms(void);
void rotatesprite(int32_t sx, int32_t sy, int32_t z, short a, short picnum,
int8_t dashade, uint8_t dapalnum, uint8_t dastat,
--- a/Engine/src/engine_protos.h
+++ b/Engine/src/engine_protos.h
@@ -37,7 +37,7 @@
extern int32_t klseek(int32_t handle, int32_t offset, int32_t whence);
extern int32_t kfilelength(int32_t handle);
extern void kclose(int32_t handle);
-extern void kdfread(void *buffer, size_t dasizeof, size_t count, int32_t fil);
+extern void kdfsread(void *buffer, size_t dasizeof, size_t count, int32_t fil);
extern void dfread(void *buffer, size_t dasizeof, size_t count, FILE *fil);
extern void dfwrite(void *buffer, size_t dasizeof, size_t count, FILE *fil);
extern int32_t compress(uint8_t *lzwinbuf, int32_t uncompleng, uint8_t *lzwoutbuf);
@@ -44,11 +44,10 @@
extern int32_t uncompress(uint8_t *lzwinbuf, int32_t compleng, uint8_t *lzwoutbuf);
/* sdl_driver.c */
-extern int using_opengl(void);
extern void _handle_events(void);
extern uint8_t _readlastkeyhit(void);
-extern int mprotect_align(const void *addr, size_t len, int prot);
-extern void unprotect_ASM_pages(void);
+
+
extern void _platform_init(int argc, char **argv, const char *title, const char *icon);
extern int setvesa(int32_t x, int32_t y);
extern int screencapture(char *filename, uint8_t inverseit);
@@ -58,7 +57,7 @@
extern int VBE_setPalette(int32_t start, int32_t num, uint8_t *palettebuffer);
extern int VBE_getPalette(int32_t start, int32_t num, uint8_t *palettebuffer);
extern void _uninitengine(void);
-extern void uninitvesa(void);
+
extern int setupmouse(void);
extern void readmousexy(short *x, short *y);
extern void readmousebstatus(short *bstatus);
@@ -75,8 +74,8 @@
extern void clear2dscreen(void);
extern void _idle(void);
extern void *_getVideoBase(void);
-extern void setactivepage(int32_t dapagenum);
+
extern int inittimer(int);
extern void uninittimer(void);
extern void initkeys(void);
@@ -153,11 +152,9 @@
extern void draw2dscreen(int32_t posxe, int32_t posye, short ange, int32_t zoome, short gride);
extern void printext256(int32_t xpos, int32_t ypos, short col, short backcol, char name[82], uint8_t fontsize);
extern void printext256_noupdate(int32_t xpos, int32_t ypos, short col, short backcol, char name[82], uint8_t fontsize);
-#ifdef DBGRECORD
-extern int krand(int line, uint8_t * file);
-#else
+
extern int krand(void);
-#endif
+
extern void getzrange(int32_t x, int32_t y, int32_t z, short sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype);
extern void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
extern void setaspect(int32_t daxrange, int32_t daaspect);
--- a/Engine/src/sdl_driver.c
+++ b/Engine/src/sdl_driver.c
@@ -24,6 +24,18 @@
#error This platform apparently does not use SDL. Do not compile this.
#endif
+
+#define BUILD_NOMOUSEGRAB "BUILD_NOMOUSEGRAB"
+#define BUILD_WINDOWED "BUILD_WINDOWED"
+#define BUILD_SDLDEBUG "BUILD_SDLDEBUG"
+#define BUILD_RENDERER "BUILD_RENDERER"
+#define BUILD_GLLIBRARY "BUILD_GLLIBRARY"
+#define BUILD_USERSCREENRES "BUILD_USERSCREENRES"
+#define BUILD_MAXSCREENRES "BUILD_MAXSCREENRES"
+#define BUILD_HALLOFMIRRORS "BUILD_HALLOFMIRRORS"
+#define BUILD_GLDUMP "BUILD_GLDUMP"
+#define BUILD_SDLJOYSTICK "BUILD_SDLJOYSTICK"
+
#include "SDL.h"
#include "build.h"
#include "display.h"
@@ -279,7 +291,7 @@
static sdl_renderer_type renderer = RENDERER_SOFTWARE;
-#include "a.h"
+#include "draw.h"
#include "cache1d.h"
@@ -462,12 +474,7 @@
} /* get_framebuffer */
-int using_opengl(void)
-{
- return(renderer == RENDERER_OPENGL3D);
-} /* using_opengl */
-
/*
* !!! This is almost an entire copy of the original setgamemode().
* !!! Figure out what is needed for just 2D mode, and separate that
@@ -1050,44 +1057,11 @@
//#include "mmulti_stable.h"
void Setup_UnstableNetworking()
{
- /*
- callcommit = unstable_callcommit;
- initcrc = unstable_initcrc;
- getcrc = unstable_getcrc;
- initmultiplayers = unstable_initmultiplayers;
- sendpacket = unstable_sendpacket;
- setpackettimeout = unstable_setpackettimeout;
- uninitmultiplayers = unstable_uninitmultiplayers;
- sendlogon = unstable_sendlogon;
- sendlogoff = unstable_sendlogoff;
- getoutputcirclesize = unstable_getoutputcirclesize;
- setsocket = unstable_setsocket;
- getpacket = unstable_getpacket;
- flushpackets = unstable_flushpackets;
- genericmultifunction = unstable_genericmultifunction;
- */
nNetMode = 0;
}
void Setup_StableNetworking()
{
- /*
- callcommit = stable_callcommit;
- initcrc = stable_initcrc;
- getcrc = stable_getcrc;
- initmultiplayers = stable_initmultiplayers;
- sendpacket = stable_sendpacket;
- setpackettimeout = stable_setpackettimeout;
- uninitmultiplayers = stable_uninitmultiplayers;
- sendlogon = stable_sendlogon;
- sendlogoff = stable_sendlogoff;
- getoutputcirclesize = stable_getoutputcirclesize;
- setsocket = stable_setsocket;
- getpacket = stable_getpacket;
- flushpackets = stable_flushpackets;
- genericmultifunction = stable_genericmultifunction;
- */
-
nNetMode = 1;
}
@@ -1693,10 +1667,6 @@
} /* _uninitengine */
-void uninitvesa(void)
-{
- SDL_QuitSubSystem(SDL_INIT_VIDEO);
-} /* uninitvesa */
int setupmouse(void)
@@ -2107,11 +2077,6 @@
return((void *) surface->pixels);
}
-void setactivepage(int32_t dapagenum)
-{
- /* !!! Is this really still needed? - DDOI */
- /*fprintf(stderr, "%s, line %d; setactivepage(): STUB.\n", __FILE__, __LINE__);*/
-} /* setactivepage */
//-------------------------------------------------------------------------------------------------
// TIMER
--- a/Game/src/config.c
+++ b/Game/src/config.c
@@ -100,8 +100,7 @@
setupfilename[0] = '\0';
// Are we trying to load a mod?
- if(game_dir[0] != '\0')
- {
+ if(game_dir[0] != '\0'){
FILE *fp = NULL;
//Yes
@@ -110,17 +109,14 @@
// let's make sure it's actually there
fp = fopen(setupfilename, "r");
if(fp)
- {
fclose(fp);
- }else
- {
+ else{
// It doesn't exist, so revert to the main one.
printf("Config file: %s does not exist, using main config.\n", setupfilename);
sprintf(setupfilename, "%s", SETUPFILENAME);
}
- }else
- {
+ }else{
//No
strcpy (setupfilename, SETUPFILENAME);
}
@@ -127,19 +123,10 @@
printf("Using Setup file: '%s'\n",setupfilename);
i=clock()+(3*CLOCKS_PER_SEC/4);
- while (clock()<i)
- {
+ while (clock()<i){
;
- }
-#if 0 //STUB .CFG lookup
- /*
- for (i=0;i<numfiles;i++)
- {
- SafeFree(filenames[i]);
- }
- */
-#endif //STUB .CFG lookup
}
+}
/*
===================
--- a/Game/src/duke3d.h
+++ b/Game/src/duke3d.h
@@ -279,11 +279,7 @@
#define furthestdir 1024
#define dodgebullet 4096
-#ifdef DBGRECORD
-#define TRAND krand(__LINE__,__FILE__)
-#else
#define TRAND krand()
-#endif
#define MAX_WEAPONS 12
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -7211,17 +7211,14 @@
c++;
if(*c)
{
- if(game_dir[0] != '\0')
- {
+ if(game_dir[0] != '\0'){
sprintf(confilename, "%s\\%s", game_dir, c);
}
- else
- {
+ else{
strcpy(confilename,c);
}
- if(SafeFileExists(confilename) == 0)
- {
+ if(SafeFileExists(confilename) == 0){
Error(EXIT_SUCCESS, "Could not find con file '%s'.\n",confilename);
}
else printf("Using con file: '%s'\n",confilename);
@@ -7230,22 +7227,18 @@
case 'g':
case 'G':
c++;
- if(*c)
- {
+ if(*c){
char fullpathgrpfile[16]; // 16 not enough
memset(fullpathgrpfile, 0, 16);
- if( strchr(c,'.') == 0)
- {
+ if( strchr(c,'.') == 0){
strcat(c,".grp"); // crap!
}
- if(game_dir[0] != '\0')
- {
+ if(game_dir[0] != '\0'){
sprintf(fullpathgrpfile, "%s\\%s", game_dir, c);
}
- else
- {
+ else{
strcpy(fullpathgrpfile, c);
}
@@ -7263,27 +7256,27 @@
case 'n':
case 'N':
c++;
- if(*c == 's' || *c == 'S')
- {
+ if(*c == 's' || *c == 'S'){
CommandSoundToggleOff = 2;
puts("Sound off.");
}
- else if(*c == 'm' || *c == 'M')
- {
+ else
+ if(*c == 'm' || *c == 'M'){
CommandMusicToggleOff = 1;
puts("Music off.");
- }
- else
- {
- comlinehelp(argv);
- Error(EXIT_SUCCESS, "");
- }
+ }
+ else{
+ comlinehelp(argv);
+ Error(EXIT_SUCCESS, "");
+ }
break;
case 'i':
case 'I':
c++;
- if(*c == '0') networkmode = 0;
- if(*c == '1') networkmode = 1;
+ if(*c == '0')
+ networkmode = 0;
+ if(*c == '1')
+ networkmode = 1;
printf("Network Mode %d\n",networkmode);
break;
case 'c':
@@ -8698,13 +8691,11 @@
ver = BYTEVERSION;
// Are we loading a TC?
- if(game_dir[0] != '\0')
- {
+ if(game_dir[0] != '\0'){
// Yes
sprintf(fullpathdemofilename, "%s\\%s", game_dir, d);
}
- else
- {
+ else{
// No
sprintf(fullpathdemofilename, "%s", d);
}
@@ -8746,20 +8737,9 @@
void record(void)
{
short i;
-#ifdef DBGRECORD
- FILE *pFile;
-#endif
-
for(i=connecthead;i>=0;i=connectpoint2[i])
{
copybufbyte(&sync[i],&recsync[ud.reccnt],sizeof(input));
-#ifdef DBGRECORD
- pFile = fopen("c:\\temp\\record.txt","a");
- fprintf(pFile,"i=%-5d a=%-2x b=%-8x f=%-4x h=%-2x s=%-4x s=%-8x\n",
- ud.reccnt, recsync[ud.reccnt].avel&0xFF, recsync[ud.reccnt].bits&0xFFFFFFFF, recsync[ud.reccnt].fvel&0xFFFF,
- recsync[ud.reccnt].horz&0xFF, recsync[ud.reccnt].svel&0xFFFF, randomseed&0xFFFFFFFF);
- fclose(pFile);
-#endif
ud.reccnt++;
totalreccnt++;
if (ud.reccnt >= RECSYNCBUFSIZ)
@@ -8803,9 +8783,7 @@
{
int32_t i,j,k,l,t;
uint8_t foundemo;
-#ifdef DBGRECORD
- FILE * pFile;
-#endif
+
if( ready2send )
{
return 0;
@@ -8896,13 +8874,7 @@
for(j=connecthead;j>=0;j=connectpoint2[j])
{
copybufbyte(&recsync[i],&inputfifo[movefifoend[j]&(MOVEFIFOSIZ-1)][j],sizeof(input));
-#ifdef DBGRECORD
- pFile = fopen("c:\\temp\\playback.txt","a");
- fprintf(pFile,"i=%-5d a=%-2x b=%-8x f=%-4x h=%-2x s=%-4x s=%-8x\n",
- i, recsync[i].avel&0xFF, recsync[i].bits&0xFFFFFFFF, recsync[i].fvel&0xFFFF,
- recsync[i].horz&0xFF, recsync[i].svel&0xFFFF, randomseed&0xFFFFFFFF);
- fclose(pFile);
-#endif
+
movefifoend[j]++;
i++;
ud.reccnt--;
@@ -9501,9 +9473,6 @@
short i, j;
uint8_t ch;
-#ifdef DBGRECORD
- FILE *pFile;
-#endif
for(i=connecthead;i>=0;i=connectpoint2[i])
if( sync[i].bits&(1<<17) )
@@ -9644,14 +9613,7 @@
syncval[myconnectindex][syncvalhead[myconnectindex]&(MOVEFIFOSIZ-1)] = ch;
syncvalhead[myconnectindex]++;
-#ifdef DBGRECORD
- pFile = fopen("c:\\temp\\synch.txt","a");
- for(i=connecthead;i>=0;i=connectpoint2[i])
- fprintf(pFile,"i=%-1d x=%-8x y=%-8x z=%-8x a=%-4x h=%-8x s=%-8x\n",
- i, ps[i].posx, ps[i].posy, ps[i].posz, ps[i].ang, ps[i].horiz,
- randomseed&0xFFFFFFFF);
- fclose(pFile);
-#endif
+
}
if(ud.recstat == 1) record();
--- a/Game/src/player.c
+++ b/Game/src/player.c
@@ -1871,10 +1871,6 @@
loc.bits |= ACTION(gamefunc_Aim_Up)<<3;
loc.bits |= ACTION(gamefunc_Aim_Down)<<4;
loc.bits |= ACTION(gamefunc_Run)<<5;
-#if 0 // this function won't be recorded anymore, but it's not really needed as it's *local*
- loc.bits |= ACTION(gamefunc_Look_Left)<<6;
- loc.bits |= ACTION(gamefunc_Look_Right)<<7;
-#endif
loc.bits |= (ud.auto_aim==2)<<6; // 2 = normal, 1 = bullet only, 0 = disabled (not implemented)
loc.bits |= ud.weaponautoswitch<<7;
--- a/xcode/Duke3D.xcodeproj/project.pbxproj
+++ b/xcode/Duke3D.xcodeproj/project.pbxproj
@@ -8,7 +8,7 @@
/* Begin PBXBuildFile section */
2D4FB6FF167D430F00915887 /* sdl_midi.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D4FB6FE167D430F00915887 /* sdl_midi.c */; };
- 2D7B621D1678885A00E35E54 /* a.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B61F11678885A00E35E54 /* a.c */; };
+ 2D7B621D1678885A00E35E54 /* draw.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B61F11678885A00E35E54 /* draw.c */; };
2D7B621E1678885A00E35E54 /* cache1d.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B61F41678885A00E35E54 /* cache1d.c */; };
2D7B621F1678885A00E35E54 /* host.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B61FA1678885A00E35E54 /* host.c */; };
2D7B62201678885A00E35E54 /* list.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B62061678885A00E35E54 /* list.c */; };
@@ -75,8 +75,8 @@
2D2A07BB167F1ABA00064107 /* global.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = global.h; path = ../../Game/src/global.h; sourceTree = "<group>"; };
2D4FB6FE167D430F00915887 /* sdl_midi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sdl_midi.c; sourceTree = "<group>"; };
2D7B61DE167886FB00E35E54 /* Duke3D */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Duke3D; sourceTree = BUILT_PRODUCTS_DIR; };
- 2D7B61F11678885A00E35E54 /* a.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = a.c; path = ../../Engine/src/a.c; sourceTree = "<group>"; };
- 2D7B61F21678885A00E35E54 /* a.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = a.h; path = ../../Engine/src/a.h; sourceTree = "<group>"; };
+ 2D7B61F11678885A00E35E54 /* draw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = draw.c; path = ../../Engine/src/draw.c; sourceTree = "<group>"; };
+ 2D7B61F21678885A00E35E54 /* draw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = draw.h; path = ../../Engine/src/draw.h; sourceTree = "<group>"; };
2D7B61F31678885A00E35E54 /* build.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = build.h; path = ../../Engine/src/build.h; sourceTree = "<group>"; };
2D7B61F41678885A00E35E54 /* cache1d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cache1d.c; path = ../../Engine/src/cache1d.c; sourceTree = "<group>"; };
2D7B61F51678885A00E35E54 /* cache1d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cache1d.h; path = ../../Engine/src/cache1d.h; sourceTree = "<group>"; };
@@ -229,8 +229,8 @@
2D7B61F01678884400E35E54 /* Engine */ = {
isa = PBXGroup;
children = (
- 2D7B61F11678885A00E35E54 /* a.c */,
- 2D7B61F21678885A00E35E54 /* a.h */,
+ 2D7B61F21678885A00E35E54 /* draw.h */,
+ 2D7B61F11678885A00E35E54 /* draw.c */,
2D7B61F31678885A00E35E54 /* build.h */,
2D7B61F41678885A00E35E54 /* cache1d.c */,
2D7B61F51678885A00E35E54 /* cache1d.h */,
@@ -426,7 +426,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 2D7B621D1678885A00E35E54 /* a.c in Sources */,
+ 2D7B621D1678885A00E35E54 /* draw.c in Sources */,
2D7B621E1678885A00E35E54 /* cache1d.c in Sources */,
2D7B621F1678885A00E35E54 /* host.c in Sources */,
2D7B62201678885A00E35E54 /* list.c in Sources */,