scale the analogue sticks for Night Striker so its possible to reach the far edges of the screen

This commit is contained in:
dinkc64 2014-05-22 19:55:43 +00:00
parent 445d607387
commit 0ae853f3dd
1 changed files with 25 additions and 15 deletions

View File

@ -3905,21 +3905,31 @@ static const UINT8 nightstr_stick[128]=
0x46,0x47,0x48,0x49,0xb8
};
UINT32 scalerange(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
static UINT8 NightstrStickRead(INT32 Offset)
{
switch (Offset) {
switch (Offset) { // p0: 3f - be p1: bf - 40
case 0x00: {
UINT8 Temp = 0x7f + (TaitoAnalogPort0 >> 4);
UINT8 Temp2 = 0;
if (Temp < 0x01) Temp = 0x01;
if (Temp > 0xfe) Temp = 0xfe;
return nightstr_stick[(Temp * 0x64) / 0x100];
Temp2 = scalerange(Temp, 0x3f, 0xbe, 0x01, 0xfe);
//bprintf(0, _T("Port0-temp[%X] scaled[%X]\n"), Temp, Temp2);
return nightstr_stick[(Temp2 * 0x64) / 0x100];
}
case 0x01: {
UINT8 Temp = 0x7f - (TaitoAnalogPort1 >> 4);
UINT8 Temp2 = 0;
if (Temp < 0x01) Temp = 0x01;
if (Temp > 0xfe) Temp = 0xfe;
return nightstr_stick[(Temp * 0x64) / 0x100];
Temp2 = scalerange(Temp, 0x40, 0xbf, 0x01, 0xfe);
//bprintf(0, _T("Port1-temp[%X]\n"), Temp);
return nightstr_stick[(Temp2 * 0x64) / 0x100];
}
case 0x02: {
@ -6412,8 +6422,8 @@ static void SpacegunDraw()
static INT32 TaitoZFrame()
{
INT32 nInterleave = TaitoFrameInterleave;
INT32 nVBlankIRQFire = (INT32)(((double)270 / 271) * TaitoFrameInterleave);
INT32 nInterleave = TaitoFrameInterleave;
INT32 nVBlankIRQFire = (INT32)(((double)270 / 271) * TaitoFrameInterleave);
if (TaitoReset) TaitoZDoReset();
@ -6438,7 +6448,7 @@ static INT32 TaitoZFrame()
SekClose();
// Run 68000 #2
if (TaitoNumZ80s) {
if (TaitoNumZ80s) {
if (TaitoCpuACtrl & 0x01) {
nCurrentCPU = 1;
SekOpen(1);
@ -6446,14 +6456,14 @@ static INT32 TaitoZFrame()
nTaitoCyclesSegment = nNext - nTaitoCyclesDone[nCurrentCPU];
nTaitoCyclesDone[nCurrentCPU] += SekRun(nTaitoCyclesSegment);
if (i == nVBlankIRQFire) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO);
SekClose();
SekClose();
}
} else {
nCurrentCPU = 1;
SekOpen(1);
BurnTimerUpdate(i * (nTaitoCyclesTotal[nCurrentCPU] / nInterleave));
if (i == nVBlankIRQFire) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO);
SekClose();
} else {
nCurrentCPU = 1;
SekOpen(1);
BurnTimerUpdate(i * (nTaitoCyclesTotal[nCurrentCPU] / nInterleave));
if (i == nVBlankIRQFire) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO);
SekClose();
}
if (TaitoNumZ80s) {
@ -6469,8 +6479,8 @@ static INT32 TaitoZFrame()
if (pBurnSoundOut) BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
ZetClose();
} else {
SekOpen(1);
if (TaitoCpuACtrl & 0x01) BurnTimerEndFrame(nTaitoCyclesTotal[1]);
SekOpen(1);
if (TaitoCpuACtrl & 0x01) BurnTimerEndFrame(nTaitoCyclesTotal[1]);
if (pBurnSoundOut) BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
SekClose();
}