2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
#include "switch.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "runlist.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
short LinkCount = -1;
|
|
|
|
short SwitchCount = -1;
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int8_t LinkMap[kMaxLinks][8];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
struct Switch
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short field_0;
|
|
|
|
short field_2;
|
|
|
|
short nChannel;
|
|
|
|
short nLink;
|
|
|
|
short field_8;
|
|
|
|
short nSector;
|
|
|
|
short field_C;
|
|
|
|
short nWall;
|
|
|
|
short field_10;
|
|
|
|
short field_12;
|
|
|
|
short field_14;
|
|
|
|
char pad[10];
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Switch SwitchData[kMaxSwitches];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InitLink()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
LinkCount = kMaxLinks;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2019-08-31 10:36:26 +00:00
|
|
|
int BuildLink(int nCount, ...)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (LinkCount <= 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 10:36:26 +00:00
|
|
|
va_list list;
|
|
|
|
va_start(list, nCount);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
LinkCount--;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
int ebx;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (i >= nCount)
|
|
|
|
{
|
|
|
|
ebx = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-31 10:36:26 +00:00
|
|
|
ebx = va_arg(list, int);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
LinkMap[LinkCount][i] = (int8_t)ebx;
|
|
|
|
}
|
2019-08-31 10:36:26 +00:00
|
|
|
va_end(list);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return LinkCount;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitSwitch()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
SwitchCount = kMaxSwitches;
|
|
|
|
memset(SwitchData, 0, sizeof(SwitchData));
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSwReady(int nChannel, short nLink)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (SwitchCount <= 0 || nLink < 0) {
|
|
|
|
bail2dos("Too many switch readys!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
SwitchCount--;
|
|
|
|
SwitchData[SwitchCount].nChannel = nChannel;
|
|
|
|
SwitchData[SwitchCount].nLink = nLink;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return SwitchCount | 0x10000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuncSwReady(int a, int, int nRun)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSwitch = RunData[nRun].nVal;
|
|
|
|
assert(nSwitch >= 0 && nSwitch < kMaxSwitches);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nMessage = a & 0x7F0000;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nChannel = SwitchData[nSwitch].nChannel;
|
|
|
|
short nLink = SwitchData[nSwitch].nLink;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
case 0x10000:
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
case 0x30000:
|
|
|
|
{
|
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
|
|
|
int8_t nVal = LinkMap[nLink][sRunChannels[nChannel].c];
|
|
|
|
if (nVal >= 0) {
|
|
|
|
runlist_ChangeChannel(nChannel, nVal);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSwPause(int nChannel, int nLink, int ebx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
for (int i = kMaxSwitches - 1; i >= SwitchCount; i--)
|
|
|
|
{
|
|
|
|
if (SwitchData[i].nChannel == nChannel && SwitchData[i].field_2 != 0) {
|
|
|
|
return i | 0x20000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SwitchCount <= 0 || nLink < 0) {
|
|
|
|
bail2dos("Too many switches!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwitchCount--;
|
|
|
|
|
|
|
|
SwitchData[SwitchCount].nChannel = nChannel;
|
|
|
|
SwitchData[SwitchCount].nLink = nLink;
|
|
|
|
SwitchData[SwitchCount].field_2 = ebx;
|
|
|
|
SwitchData[SwitchCount].field_8 = -1;
|
|
|
|
|
|
|
|
return SwitchCount | 0x20000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuncSwPause(int a, int, int nRun)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSwitch = RunData[nRun].nVal;
|
|
|
|
assert(nSwitch >= 0 && nSwitch < kMaxSwitches);
|
|
|
|
|
|
|
|
int nMessage = a & 0x7F0000;
|
|
|
|
|
|
|
|
short nChannel = SwitchData[nSwitch].nChannel;
|
|
|
|
short nLink = SwitchData[nSwitch].nLink;
|
|
|
|
|
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 0x10000:
|
|
|
|
{
|
|
|
|
if (SwitchData[nSwitch].field_8 >= 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_8);
|
|
|
|
SwitchData[nSwitch].field_8 = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x20000:
|
|
|
|
{
|
|
|
|
SwitchData[nSwitch].field_0--;
|
|
|
|
if (SwitchData[nSwitch].field_0 <= 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_8);
|
|
|
|
SwitchData[nSwitch].field_8 = -1;
|
|
|
|
|
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
|
|
|
assert(nLink < 1024);
|
|
|
|
|
|
|
|
runlist_ChangeChannel(nChannel, LinkMap[nLink][sRunChannels[nChannel].c]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x30000:
|
|
|
|
{
|
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
|
|
|
|
|
|
|
if (LinkMap[nLink][sRunChannels[nChannel].c] < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SwitchData[nSwitch].field_8 >= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwitchData[nSwitch].field_8 = runlist_AddRunRec(NewRun, RunData[nRun].nMoves);
|
|
|
|
|
|
|
|
int eax;
|
|
|
|
|
|
|
|
if (SwitchData[nSwitch].field_2 <= 0)
|
|
|
|
{
|
|
|
|
eax = 100;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eax = SwitchData[nSwitch].field_2;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwitchData[nSwitch].field_0 = eax;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSwStepOn(int nChannel, int nLink, int nSector)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (SwitchCount <= 0 || nLink < 0 || nSector < 0)
|
|
|
|
bail2dos("Too many switches!\n");
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSwitch = --SwitchCount;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
SwitchData[nSwitch].nChannel = nChannel;
|
|
|
|
SwitchData[nSwitch].nLink = nLink;
|
|
|
|
SwitchData[nSwitch].nSector = nSector;
|
|
|
|
SwitchData[nSwitch].field_C = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return nSwitch | 0x30000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuncSwStepOn(int a, int, int nRun)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSwitch = RunData[nRun].nVal;
|
|
|
|
assert(nSwitch >= 0 && nSwitch < kMaxSwitches);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nLink = SwitchData[nSwitch].nLink;
|
|
|
|
short nChannel = SwitchData[nSwitch].nChannel;
|
|
|
|
short nSector = SwitchData[nSwitch].nSector;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int8_t var_14 = LinkMap[nLink][sRunChannels[nChannel].c];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nMessage = a & 0x7F0000;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
case 0x10000:
|
|
|
|
{
|
|
|
|
if (SwitchData[nSwitch].field_C >= 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_C);
|
|
|
|
SwitchData[nSwitch].field_C = -1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (var_14 >= 0)
|
|
|
|
{
|
|
|
|
SwitchData[nSwitch].field_C = runlist_AddRunRec(sector[nSector].lotag - 1, RunData[nRun].nMoves);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
case 0x50000:
|
|
|
|
{
|
|
|
|
if (var_14 != sRunChannels[nChannel].c)
|
|
|
|
{
|
|
|
|
short nWall = sector[nSector].wallptr;
|
2019-08-26 03:59:14 +00:00
|
|
|
// TODO PlayFXAtXYZ(StaticSound[nSwitchSound], wall[nWall].x, wall[nWall].y, sector[nSector].floorz, nSector);
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
runlist_ChangeChannel(nChannel, LinkMap[nLink][sRunChannels[nChannel].c]);
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSwNotOnPause(int nChannel, int nLink, int nSector, int ecx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (SwitchCount <= 0 || nLink < 0 || nSector < 0)
|
|
|
|
bail2dos("Too many switches!\n");
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSwitch = --SwitchCount;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
SwitchData[nSwitch].nChannel = nChannel;
|
|
|
|
SwitchData[nSwitch].nLink = nLink;
|
|
|
|
SwitchData[nSwitch].field_2 = ecx;
|
|
|
|
SwitchData[nSwitch].nSector = nSector;
|
|
|
|
SwitchData[nSwitch].field_8 = -1;
|
|
|
|
SwitchData[nSwitch].field_C = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return nSwitch | 0x40000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuncSwNotOnPause(int a, int, int nRun)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSwitch = RunData[nRun].nVal;
|
|
|
|
assert(nSwitch >= 0 && nSwitch < kMaxSwitches);
|
|
|
|
|
|
|
|
int nMessage = a & 0x7F0000;
|
|
|
|
|
|
|
|
short nChannel = SwitchData[nSwitch].nChannel;
|
|
|
|
short nLink = SwitchData[nSwitch].nLink;
|
|
|
|
|
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 0x10000:
|
|
|
|
{
|
|
|
|
if (SwitchData[nSwitch].field_C >= 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_C);
|
|
|
|
SwitchData[nSwitch].field_C = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SwitchData[nSwitch].field_8 >= 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_8);
|
|
|
|
SwitchData[nSwitch].field_8 = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x20000:
|
|
|
|
{
|
|
|
|
SwitchData[nSwitch].field_0 -= 4;
|
|
|
|
if (SwitchData[nSwitch].field_0 <= 0)
|
|
|
|
{
|
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
|
|
|
|
|
|
|
runlist_ChangeChannel(nChannel, LinkMap[nLink][sRunChannels[nChannel].c]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x30000:
|
|
|
|
{
|
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
|
|
|
|
|
|
|
if (LinkMap[nLink][sRunChannels[nChannel].c] >= 0)
|
|
|
|
{
|
|
|
|
if (SwitchData[nSwitch].field_8 < 0)
|
|
|
|
{
|
|
|
|
SwitchData[nSwitch].field_8 = runlist_AddRunRec(NewRun, RunData[nRun].nMoves);
|
|
|
|
|
|
|
|
short nSector = SwitchData[nSwitch].nSector;
|
|
|
|
|
|
|
|
SwitchData[nSwitch].field_0 = SwitchData[nSwitch].field_2;
|
|
|
|
SwitchData[nSwitch].field_C = runlist_AddRunRec(sector[nSector].lotag - 1, RunData[nRun].nMoves);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x50000:
|
|
|
|
{
|
|
|
|
SwitchData[nSwitch].field_0 = SwitchData[nSwitch].field_2;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSwPressSector(int nChannel, int nLink, int nSector, int ecx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (SwitchCount <= 0 || nLink < 0 || nSector < 0)
|
|
|
|
bail2dos("Too many switches!\n");
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSwitch = --SwitchCount;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
SwitchData[nSwitch].nChannel = nChannel;
|
|
|
|
SwitchData[nSwitch].nLink = nLink;
|
|
|
|
SwitchData[nSwitch].nSector = nSector;
|
|
|
|
SwitchData[nSwitch].field_12 = ecx;
|
|
|
|
SwitchData[nSwitch].field_C = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return nSwitch | 0x50000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuncSwPressSector(int a, int, int nRun)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSwitch = RunData[nRun].nVal;
|
|
|
|
assert(nSwitch >= 0 && nSwitch < kMaxSwitches);
|
|
|
|
|
|
|
|
int nMessage = a & 0x7F0000;
|
|
|
|
|
|
|
|
short nChannel = SwitchData[nSwitch].nChannel;
|
|
|
|
short nLink = SwitchData[nSwitch].nLink;
|
|
|
|
short nPlayer = a & 0xFFFF;
|
|
|
|
|
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 0x10000:
|
|
|
|
{
|
|
|
|
if (SwitchData[nSwitch].field_C >= 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_C);
|
|
|
|
SwitchData[nSwitch].field_C = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(sRunChannels[nChannel].c < 8);
|
|
|
|
|
|
|
|
if (LinkMap[nLink][sRunChannels[nChannel].c] < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
short nSector = SwitchData[nSwitch].nSector;
|
|
|
|
|
|
|
|
SwitchData[nSwitch].field_C = runlist_AddRunRec(sector[nSector].lotag - 1, RunData[nRun].nMoves);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x40000:
|
|
|
|
{
|
|
|
|
if ((PlayerList[nPlayer].keys & SwitchData[nSwitch].field_12) == SwitchData[nSwitch].field_12)
|
|
|
|
{
|
|
|
|
runlist_ChangeChannel(nChannel, LinkMap[nLink][sRunChannels[nChannel].c]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (SwitchData[nSwitch].field_12)
|
|
|
|
{
|
|
|
|
short nSprite = PlayerList[nPlayer].nSprite;
|
|
|
|
// TODO PlayFXAtXYZ(StaticSound[nSwitchSound], sprite[nSprite].x, sprite[nSprite].y, 0, sprite[nSprite].sectnum);
|
|
|
|
|
|
|
|
StatusMessage(300, "YOU NEED THE KEY FOR THIS DOOR");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSwPressWall(short nChannel, short nLink, short nWall)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (SwitchCount <= 0 || nLink < 0 || nWall < 0) {
|
|
|
|
bail2dos("Too many switches!\n");
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
SwitchCount--;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
SwitchData[SwitchCount].nChannel = nChannel;
|
|
|
|
SwitchData[SwitchCount].nLink = nLink;
|
|
|
|
SwitchData[SwitchCount].nWall = nWall;
|
|
|
|
SwitchData[SwitchCount].field_10 = -1;
|
|
|
|
SwitchData[SwitchCount].field_14 = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return SwitchCount | 0x60000;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuncSwPressWall(int a, int, int nRun)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSwitch = RunData[nRun].nVal;
|
|
|
|
assert(nSwitch >= 0 && nSwitch < kMaxSwitches);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nChannel = SwitchData[nSwitch].nChannel;
|
|
|
|
short nLink = SwitchData[nSwitch].nLink;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
// TEMP
|
2019-08-26 03:59:14 +00:00
|
|
|
// assert(nLink < 1024);
|
|
|
|
// assert(nChannel < 8);
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nMessage = a & 0x7F0000;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
switch (nMessage)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
case 0x30000:
|
|
|
|
{
|
|
|
|
if (SwitchData[nSwitch].field_10 >= 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_10);
|
|
|
|
SwitchData[nSwitch].field_10 = -1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (LinkMap[nLink][sRunChannels[nChannel].c] >= 0)
|
|
|
|
{
|
|
|
|
short nWall = SwitchData[nSwitch].nWall;
|
|
|
|
SwitchData[nSwitch].field_10 = runlist_AddRunRec(wall[nWall].lotag - 1, RunData[nRun].nMoves);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
case 0x40000:
|
|
|
|
{
|
|
|
|
int8_t cx = LinkMap[nLink][sRunChannels[nChannel].c];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
runlist_ChangeChannel(nChannel, LinkMap[nLink][sRunChannels[nChannel].c]);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (cx < 0 || LinkMap[nLink][cx] < 0)
|
|
|
|
{
|
|
|
|
runlist_SubRunRec(SwitchData[nSwitch].field_10);
|
|
|
|
SwitchData[nSwitch].field_10 = -1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nWall = SwitchData[nSwitch].nWall;
|
|
|
|
short nSector = SwitchData[nSwitch].nSector; // CHECKME - where is this set??
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// TODO PlayFXAtXYZ(StaticSound[nSwitchSound], wall[nWall].x, wall[nWall].y, 0, nSector);
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|