This commit is contained in:
twinaphex 2015-03-26 12:33:55 +01:00
parent 1b772464ba
commit 25b2b776cf
6 changed files with 3084 additions and 3226 deletions

1130
id_sd.c

File diff suppressed because it is too large Load Diff

854
id_us_1.c

File diff suppressed because it is too large Load Diff

11
id_vl.c
View File

@ -113,7 +113,8 @@ void VL_SetVGAPlaneMode (void)
curPitch = bufferPitch; curPitch = bufferPitch;
scaleFactor = screenWidth/320; scaleFactor = screenWidth/320;
if(screenHeight/200 < scaleFactor) scaleFactor = screenHeight/200; if(screenHeight/200 < scaleFactor)
scaleFactor = screenHeight/200;
pixelangle = (short *) malloc(screenWidth * sizeof(short)); pixelangle = (short *) malloc(screenWidth * sizeof(short));
@ -515,10 +516,8 @@ void VL_MemToLatch(byte *source, int width, int height,
for(ysrc = 0; ysrc < height; ysrc++) for(ysrc = 0; ysrc < height; ysrc++)
{ {
for(xsrc = 0; xsrc < width; xsrc++) for(xsrc = 0; xsrc < width; xsrc++)
{
dest[ysrc * pitch + xsrc] = source[(ysrc * (width >> 2) + (xsrc >> 2)) dest[ysrc * pitch + xsrc] = source[(ysrc * (width >> 2) + (xsrc >> 2))
+ (xsrc & 3) * (width >> 2) * height]; + (xsrc & 3) * (width >> 2) * height];
}
} }
VL_UnlockSurface(destSurface); VL_UnlockSurface(destSurface);
} }
@ -556,9 +555,7 @@ void VL_MemToScreenScaledCoord (byte *source, int width, int height, int destx,
for(m=0; m<scaleFactor; m++) for(m=0; m<scaleFactor; m++)
{ {
for(n=0; n<scaleFactor; n++) for(n=0; n<scaleFactor; n++)
{
vbuf[(scj+m+desty)*curPitch+sci+n+destx] = col; vbuf[(scj+m+desty)*curPitch+sci+n+destx] = col;
}
} }
} }
} }
@ -599,9 +596,7 @@ void VL_MemToScreenScaledCoord2 (byte *source, int origwidth, int origheight, in
for(m=0; m<scaleFactor; m++) for(m=0; m<scaleFactor; m++)
{ {
for(n=0; n<scaleFactor; n++) for(n=0; n<scaleFactor; n++)
{
vbuf[(scj+m+desty)*curPitch+sci+n+destx] = col; vbuf[(scj+m+desty)*curPitch+sci+n+destx] = col;
}
} }
} }
} }
@ -644,9 +639,7 @@ void VL_LatchToScreenScaledCoord(SDL_Surface *source, int xsrc, int ysrc,
for(m=0; m<scaleFactor; m++) for(m=0; m<scaleFactor; m++)
{ {
for(n=0; n<scaleFactor; n++) for(n=0; n<scaleFactor; n++)
{
vbuf[(scydest+scj+m)*curPitch+scxdest+sci+n] = col; vbuf[(scydest+scj+m)*curPitch+scxdest+sci+n] = col;
}
} }
} }
} }

422
wl_act1.c
View File

@ -140,51 +140,51 @@ void InitStaticList (void)
void SpawnStatic (int tilex, int tiley, int type) void SpawnStatic (int tilex, int tiley, int type)
{ {
laststatobj->shapenum = statinfo[type].picnum; laststatobj->shapenum = statinfo[type].picnum;
laststatobj->tilex = tilex; laststatobj->tilex = tilex;
laststatobj->tiley = tiley; laststatobj->tiley = tiley;
laststatobj->visspot = &spotvis[tilex][tiley]; laststatobj->visspot = &spotvis[tilex][tiley];
switch (statinfo[type].type) switch (statinfo[type].type)
{ {
case block: case block:
actorat[tilex][tiley] = (objtype *) 64; // consider it a blocking tile actorat[tilex][tiley] = (objtype *) 64; // consider it a blocking tile
case none: case none:
laststatobj->flags = 0; laststatobj->flags = 0;
break; break;
case bo_cross: case bo_cross:
case bo_chalice: case bo_chalice:
case bo_bible: case bo_bible:
case bo_crown: case bo_crown:
case bo_fullheal: case bo_fullheal:
if (!loadedgame) if (!loadedgame)
gamestate.treasuretotal++; gamestate.treasuretotal++;
case bo_firstaid: case bo_firstaid:
case bo_key1: case bo_key1:
case bo_key2: case bo_key2:
case bo_key3: case bo_key3:
case bo_key4: case bo_key4:
case bo_clip: case bo_clip:
case bo_25clip: case bo_25clip:
case bo_machinegun: case bo_machinegun:
case bo_chaingun: case bo_chaingun:
case bo_food: case bo_food:
case bo_alpo: case bo_alpo:
case bo_gibs: case bo_gibs:
case bo_spear: case bo_spear:
laststatobj->flags = FL_BONUS; laststatobj->flags = FL_BONUS;
laststatobj->itemnumber = statinfo[type].type; laststatobj->itemnumber = statinfo[type].type;
break; break;
} }
laststatobj->flags |= statinfo[type].specialFlags; laststatobj->flags |= statinfo[type].specialFlags;
laststatobj++; laststatobj++;
if (laststatobj == &statobjlist[MAXSTATS]) if (laststatobj == &statobjlist[MAXSTATS])
Quit ("Too many static objects!\n"); Quit ("Too many static objects!\n");
} }
@ -202,45 +202,40 @@ void SpawnStatic (int tilex, int tiley, int type)
void PlaceItemType (int itemtype, int tilex, int tiley) void PlaceItemType (int itemtype, int tilex, int tiley)
{ {
int type; int type;
statobj_t *spot; statobj_t *spot;
// /* find the item number */
// find the item number for (type=0; ; type++)
// {
for (type=0; ; type++) if (statinfo[type].picnum == -1) // end of list
{ Quit ("PlaceItemType: couldn't find type!");
if (statinfo[type].picnum == -1) // end of list if (statinfo[type].type == itemtype)
Quit ("PlaceItemType: couldn't find type!"); break;
if (statinfo[type].type == itemtype) }
break;
}
// /* find a spot in statobjlist to put it in */
// find a spot in statobjlist to put it in for (spot=&statobjlist[0]; ; spot++)
// {
for (spot=&statobjlist[0]; ; spot++) if (spot==laststatobj)
{ {
if (spot==laststatobj) if (spot == &statobjlist[MAXSTATS])
{ return; // no free spots
if (spot == &statobjlist[MAXSTATS]) laststatobj++; // space at end
return; // no free spots break;
laststatobj++; // space at end }
break;
}
if (spot->shapenum == -1) // -1 is a free spot if (spot->shapenum == -1) // -1 is a free spot
break; break;
} }
//
// place it /* place it */
// spot->shapenum = statinfo[type].picnum;
spot->shapenum = statinfo[type].picnum; spot->tilex = tilex;
spot->tilex = tilex; spot->tiley = tiley;
spot->tiley = tiley; spot->visspot = &spotvis[tilex][tiley];
spot->visspot = &spotvis[tilex][tiley]; spot->flags = FL_BONUS | statinfo[type].specialFlags;
spot->flags = FL_BONUS | statinfo[type].specialFlags; spot->itemnumber = statinfo[type].type;
spot->itemnumber = statinfo[type].type;
} }
@ -368,10 +363,8 @@ void SpawnDoor (int tilex, int tiley, boolean vertical, int lock)
actorat[tilex][tiley] = (objtype *)(uintptr_t)(doornum | 0x80); // consider it a solid wall actorat[tilex][tiley] = (objtype *)(uintptr_t)(doornum | 0x80); // consider it a solid wall
//
// make the door tile a special tile, and mark the adjacent tiles // make the door tile a special tile, and mark the adjacent tiles
// for door sides // for door sides
//
tilemap[tilex][tiley] = doornum | 0x80; tilemap[tilex][tiley] = doornum | 0x80;
map = mapsegs[0] + (tiley<<mapshift) +tilex; map = mapsegs[0] + (tiley<<mapshift) +tilex;
if (vertical) if (vertical)
@ -563,9 +556,7 @@ void DoorOpening (int door)
position = doorposition[door]; position = doorposition[door];
if (!position) if (!position)
{ {
//
// door is just starting to open, so connect the areas // door is just starting to open, so connect the areas
//
map = mapsegs[0] + (doorobjlist[door].tiley<<mapshift) map = mapsegs[0] + (doorobjlist[door].tiley<<mapshift)
+doorobjlist[door].tilex; +doorobjlist[door].tilex;
@ -595,15 +586,11 @@ void DoorOpening (int door)
} }
} }
//
// slide the door by an adaptive amount // slide the door by an adaptive amount
//
position += tics<<10; position += tics<<10;
if (position >= 0xffff) if (position >= 0xffff)
{ {
//
// door is all the way open // door is all the way open
//
position = 0xffff; position = 0xffff;
doorobjlist[door].ticcount = 0; doorobjlist[door].ticcount = 0;
doorobjlist[door].action = dr_open; doorobjlist[door].action = dr_open;
@ -624,62 +611,58 @@ void DoorOpening (int door)
void DoorClosing (int door) void DoorClosing (int door)
{ {
unsigned area1,area2; unsigned area1,area2;
word *map; word *map;
int32_t position; int32_t position;
int tilex,tiley; int tilex,tiley;
tilex = doorobjlist[door].tilex; tilex = doorobjlist[door].tilex;
tiley = doorobjlist[door].tiley; tiley = doorobjlist[door].tiley;
if ( ((int)(uintptr_t)actorat[tilex][tiley] != (door | 0x80)) if ( ((int)(uintptr_t)actorat[tilex][tiley] != (door | 0x80))
|| (player->tilex == tilex && player->tiley == tiley) ) || (player->tilex == tilex && player->tiley == tiley) )
{ // something got inside the door { // something got inside the door
OpenDoor (door); OpenDoor (door);
return; return;
}; };
position = doorposition[door]; position = doorposition[door];
// // slide the door by an adaptive amount
// slide the door by an adaptive amount position -= tics<<10;
// if (position <= 0)
position -= tics<<10; {
if (position <= 0) // door is closed all the way, so disconnect the areas
{ position = 0;
//
// door is closed all the way, so disconnect the areas
//
position = 0;
doorobjlist[door].action = dr_closed; doorobjlist[door].action = dr_closed;
map = mapsegs[0] + (doorobjlist[door].tiley<<mapshift) + doorobjlist[door].tilex; map = mapsegs[0] + (doorobjlist[door].tiley<<mapshift) + doorobjlist[door].tilex;
if (doorobjlist[door].vertical) if (doorobjlist[door].vertical)
{ {
area1 = *(map+1); area1 = *(map+1);
area2 = *(map-1); area2 = *(map-1);
} }
else else
{ {
area1 = *(map-mapwidth); area1 = *(map-mapwidth);
area2 = *(map+mapwidth); area2 = *(map+mapwidth);
} }
area1 -= AREATILE; area1 -= AREATILE;
area2 -= AREATILE; area2 -= AREATILE;
if (area1 < NUMAREAS && area2 < NUMAREAS) if (area1 < NUMAREAS && area2 < NUMAREAS)
{ {
areaconnect[area1][area2]--; areaconnect[area1][area2]--;
areaconnect[area2][area1]--; areaconnect[area2][area1]--;
if (player->areanumber < NUMAREAS) if (player->areanumber < NUMAREAS)
ConnectAreas (); ConnectAreas ();
} }
} }
doorposition[door] = (word) position; doorposition[door] = (word) position;
} }
@ -697,28 +680,28 @@ void DoorClosing (int door)
void MoveDoors (void) void MoveDoors (void)
{ {
int door; int door;
if (gamestate.victoryflag) // don't move door during victory sequence if (gamestate.victoryflag) // don't move door during victory sequence
return; return;
for (door = 0; door < doornum; door++) for (door = 0; door < doornum; door++)
{ {
switch (doorobjlist[door].action) switch (doorobjlist[door].action)
{ {
case dr_open: case dr_open:
DoorOpen (door); DoorOpen (door);
break; break;
case dr_opening: case dr_opening:
DoorOpening(door); DoorOpening(door);
break; break;
case dr_closing: case dr_closing:
DoorClosing(door); DoorClosing(door);
break; break;
} }
} }
} }
@ -746,38 +729,38 @@ int dirs[4][2]={{0,-1},{1,0},{0,1},{-1,0}};
void PushWall (int checkx, int checky, int dir) void PushWall (int checkx, int checky, int dir)
{ {
int oldtile, dx, dy; int oldtile, dx, dy;
if (pwallstate) if (pwallstate)
return; return;
oldtile = tilemap[checkx][checky]; oldtile = tilemap[checkx][checky];
if (!oldtile) if (!oldtile)
return; return;
dx = dirs[dir][0]; dx = dirs[dir][0];
dy = dirs[dir][1]; dy = dirs[dir][1];
if (actorat[checkx+dx][checky+dy]) if (actorat[checkx+dx][checky+dy])
{ {
SD_PlaySound (NOWAYSND); SD_PlaySound (NOWAYSND);
return; return;
} }
actorat[checkx+dx][checky+dy] = (objtype *)(uintptr_t) (tilemap[checkx+dx][checky+dy] = oldtile); actorat[checkx+dx][checky+dy] = (objtype *)(uintptr_t) (tilemap[checkx+dx][checky+dy] = oldtile);
gamestate.secretcount++; gamestate.secretcount++;
pwallx = checkx; pwallx = checkx;
pwally = checky; pwally = checky;
pwalldir = dir; pwalldir = dir;
pwallstate = 1; pwallstate = 1;
pwallpos = 0; pwallpos = 0;
pwalltile = tilemap[pwallx][pwally]; pwalltile = tilemap[pwallx][pwally];
tilemap[pwallx][pwally] = 64; tilemap[pwallx][pwally] = 64;
tilemap[pwallx+dx][pwally+dy] = 64; tilemap[pwallx+dx][pwally+dy] = 64;
*(mapsegs[1]+(pwally<<mapshift)+pwallx) = 0; // remove P tile info *(mapsegs[1]+(pwally<<mapshift)+pwallx) = 0; // remove P tile info
*(mapsegs[0]+(pwally<<mapshift)+pwallx) = *(mapsegs[0]+(player->tiley<<mapshift)+player->tilex); // set correct floorcode (BrotherTank's fix) *(mapsegs[0]+(pwally<<mapshift)+pwallx) = *(mapsegs[0]+(player->tiley<<mapshift)+player->tilex); // set correct floorcode (BrotherTank's fix)
SD_PlaySound (PUSHWALLSND); SD_PlaySound (PUSHWALLSND);
} }
@ -792,62 +775,57 @@ void PushWall (int checkx, int checky, int dir)
void MovePWalls (void) void MovePWalls (void)
{ {
int oldblock,oldtile; int oldblock,oldtile;
if (!pwallstate) if (!pwallstate)
return; return;
oldblock = pwallstate/128; oldblock = pwallstate/128;
pwallstate += (word)tics; pwallstate += (word)tics;
if (pwallstate/128 != oldblock) if (pwallstate/128 != oldblock)
{ {
// block crossed into a new block // block crossed into a new block
oldtile = pwalltile; oldtile = pwalltile;
// // the tile can now be walked into
// the tile can now be walked into tilemap[pwallx][pwally] = 0;
// actorat[pwallx][pwally] = 0;
tilemap[pwallx][pwally] = 0; *(mapsegs[0]+(pwally<<mapshift)+pwallx) = player->areanumber+AREATILE;
actorat[pwallx][pwally] = 0;
*(mapsegs[0]+(pwally<<mapshift)+pwallx) = player->areanumber+AREATILE;
int dx=dirs[pwalldir][0], dy=dirs[pwalldir][1]; int dx=dirs[pwalldir][0], dy=dirs[pwalldir][1];
//
// see if it should be pushed farther // see if it should be pushed farther
// if (pwallstate>=256) // only move two tiles fix
if (pwallstate>=256) // only move two tiles fix {
{ // the block has been pushed two tiles
// pwallstate = 0;
// the block has been pushed two tiles tilemap[pwallx+dx][pwally+dy] = oldtile;
// return;
}
else
{
int xl,yl,xh,yh;
xl = (player->x-PLAYERSIZE) >> TILESHIFT;
yl = (player->y-PLAYERSIZE) >> TILESHIFT;
xh = (player->x+PLAYERSIZE) >> TILESHIFT;
yh = (player->y+PLAYERSIZE) >> TILESHIFT;
pwallx += dx;
pwally += dy;
if (actorat[pwallx+dx][pwally+dy]
|| xl<=pwallx+dx && pwallx+dx<=xh && yl<=pwally+dy && pwally+dy<=yh)
{
pwallstate = 0; pwallstate = 0;
tilemap[pwallx+dx][pwally+dy] = oldtile; tilemap[pwallx][pwally] = oldtile;
return; return;
} }
else actorat[pwallx+dx][pwally+dy] = (objtype *)(uintptr_t) (tilemap[pwallx+dx][pwally+dy] = oldtile);
{ tilemap[pwallx+dx][pwally+dy] = 64;
int xl,yl,xh,yh; }
xl = (player->x-PLAYERSIZE) >> TILESHIFT; }
yl = (player->y-PLAYERSIZE) >> TILESHIFT;
xh = (player->x+PLAYERSIZE) >> TILESHIFT;
yh = (player->y+PLAYERSIZE) >> TILESHIFT;
pwallx += dx; pwallpos = (pwallstate/2)&63;
pwally += dy;
if (actorat[pwallx+dx][pwally+dy]
|| xl<=pwallx+dx && pwallx+dx<=xh && yl<=pwally+dy && pwally+dy<=yh)
{
pwallstate = 0;
tilemap[pwallx][pwally] = oldtile;
return;
}
actorat[pwallx+dx][pwally+dy] = (objtype *)(uintptr_t) (tilemap[pwallx+dx][pwally+dy] = oldtile);
tilemap[pwallx+dx][pwally+dy] = 64;
}
}
pwallpos = (pwallstate/2)&63;
} }

2410
wl_act2.c

File diff suppressed because it is too large Load Diff

1483
wl_agent.c

File diff suppressed because it is too large Load Diff