burn_gun enhancements, konami/d_lethal.cpp oopses

This commit is contained in:
dinkc64 2014-11-24 13:39:18 +00:00
parent 38db25456c
commit 51dc908289
3 changed files with 39 additions and 26 deletions

View File

@ -5,6 +5,7 @@
// written by Barry Harris (Treble Winner) based on the code in Kev's opwolf driver
INT32 nBurnGunNumPlayers = 0;
bool bBurnGunAutoHide = 1;
static bool bBurnGunDrawTargets = true;
static INT32 nBurnGunMaxX = 0;
@ -39,6 +40,26 @@ UINT8 BurnGunTargetData[18][18] = {
#undef b
#undef a
#define GunTargetHideTime 60 * 4 /* 4 seconds @ 60 fps */
static INT32 GunTargetTimer[MAX_GUNS] = {0, 0, 0, 0};
static INT32 GunTargetLastX[MAX_GUNS] = {0, 0, 0, 0};
static INT32 GunTargetLastY[MAX_GUNS] = {0, 0, 0, 0};
static void GunTargetUpdate(INT32 player)
{
if (GunTargetLastX[player] != BurnGunReturnX(player) || GunTargetLastY[player] != BurnGunReturnY(player)) {
GunTargetLastX[player] = BurnGunReturnX(player);
GunTargetLastY[player] = BurnGunReturnY(player);
GunTargetTimer[player] = nCurrentFrame;
}
}
static UINT8 GunTargetShouldDraw(INT32 player)
{
return (nCurrentFrame < GunTargetTimer[player] + GunTargetHideTime);
}
#undef GunTargetHideTime
UINT8 BurnGunReturnX(INT32 num)
{
#if defined FBA_DEBUG
@ -76,7 +97,9 @@ void BurnGunMakeInputs(INT32 num, INT16 x, INT16 y)
const INT32 MinX = -8 * 0x100;
const INT32 MinY = -8 * 0x100;
if (y == 1 || y == -1 || x == 1 || x == -1) return; // prevent walking crosshair
BurnGunX[num] += x;
BurnGunY[num] += y;
@ -84,6 +107,9 @@ void BurnGunMakeInputs(INT32 num, INT16 x, INT16 y)
if (BurnGunX[num] > MinX + nBurnGunMaxX * 0x100) BurnGunX[num] = MinX + nBurnGunMaxX * 0x100;
if (BurnGunY[num] < MinY) BurnGunY[num] = MinY;
if (BurnGunY[num] > MinY + nBurnGunMaxY * 0x100) BurnGunY[num] = MinY + nBurnGunMaxY * 0x100;
for (INT32 i = 0; i < nBurnGunNumPlayers; i++)
GunTargetUpdate(i);
}
void BurnGunInit(INT32 nNumPlayers, bool bDrawTargets)
@ -146,7 +172,9 @@ void BurnGunDrawTarget(INT32 num, INT32 x, INT32 y)
if (bBurnGunDrawTargets == false) return;
if (num > MAX_GUNS - 1) return;
if (bBurnGunAutoHide && !GunTargetShouldDraw(num)) return;
UINT8* pTile = pBurnDraw + nBurnGunMaxX * nBurnBpp * (y - 1) + nBurnBpp * x;
UINT32 nTargetCol = 0;

View File

@ -1,6 +1,7 @@
#define MAX_GUNS 4
extern INT32 nBurnGunNumPlayers;
extern bool bBurnGunAutoHide;
extern INT32 BurnGunX[MAX_GUNS];
extern INT32 BurnGunY[MAX_GUNS];

View File

@ -101,24 +101,6 @@ STDDIPINFO(Lethalen)
#define GUNX(a) (( ( BurnGunReturnX(a - 1) * 287 ) / 0xff ) + 16)
#define GUNY(a) (( ( BurnGunReturnY(a - 1) * 223 ) / 0xff ) + 10)
static UINT32 GunTargetTimer[2] = {0, 0};
static UINT32 GunTargetLastX[2] = {0, 0};
static UINT32 GunTargetLastY[2] = {0, 0};
static void GunTargetUpdate(UINT16 player)
{
if (GunTargetLastX[player] != GUNX(player + 1) || GunTargetLastY[player] != GUNY(player + 1)) {
GunTargetLastX[player] = GUNX(player + 1);
GunTargetLastY[player] = GUNY(player + 1);
GunTargetTimer[player] = nCurrentFrame;
}
}
static UINT8 GunTargetShouldDraw(UINT16 player)
{
return (nCurrentFrame < GunTargetTimer[player] + 60 * 2 /* two secs */);
}
static UINT8 guns_r(UINT16 address)
{
switch (address)
@ -152,6 +134,9 @@ static UINT8 gunsaux_r()
return res;
}
#undef GUNX
#undef GUNY
static void bankswitch(INT32 bank)
{
bank = (bank & 0x1f) * 0x2000;
@ -569,6 +554,8 @@ static INT32 DrvExit()
K054539Exit();
BurnGunExit();
BurnFree (AllMem);
return 0;
@ -647,9 +634,7 @@ static INT32 DrvDraw()
#endif
KonamiBlendCopy(DrvPalette);
for (INT32 i = 0; i < nBurnGunNumPlayers; i++) {
if (GunTargetShouldDraw(i)) {
BurnGunDrawTarget(i, BurnGunX[i] >> 8, BurnGunY[i] >> 8);
}
BurnGunDrawTarget(i, BurnGunX[i] >> 8, BurnGunY[i] >> 8);
}
return 0;
@ -670,8 +655,6 @@ static INT32 DrvFrame()
BurnGunMakeInputs(0, (INT16)LethalGun0, (INT16)LethalGun1);
BurnGunMakeInputs(1, (INT16)LethalGun2, (INT16)LethalGun3);
GunTargetUpdate(0);
GunTargetUpdate(1);
}
INT32 nInterleave = nBurnSoundLen;
@ -738,7 +721,7 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
*pnMin = 0x029732;
}
if (nAction & ACB_VOLATILE) {
if (nAction & ACB_VOLATILE) {
memset(&ba, 0, sizeof(ba));
ba.Data = AllRam;
@ -752,6 +735,7 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
K054539Scan(nAction);
KonamiICScan(nAction);
BurnGunScan();
SCAN_VAR(current_4800_bank);
SCAN_VAR(sound_nmi_enable);