awave: fix lightgun trigger and position

fix aw lightgun trigger virtual key with new lightgun map
delay maple dma int when maple bus occupy is set for a lightgun.
raise maple int at vblank in if off screen
nudge reported position to avoid registering as off screen
This commit is contained in:
Flyinghead 2020-11-30 21:31:50 +01:00
parent c6f5a406a7
commit ef16842074
5 changed files with 57 additions and 13 deletions

View File

@ -28,7 +28,7 @@ u8 GetBtFromSgn(s8 val)
return val+128;
}
u32 awave_button_mapping[] = {
u32 awave_button_mapping[16] = {
AWAVE_SERVICE_KEY, // DC_BTN_C
AWAVE_BTN1_KEY, // DC_BTN_B
AWAVE_BTN0_KEY, // DC_BTN_A
@ -42,9 +42,28 @@ u32 awave_button_mapping[] = {
AWAVE_BTN2_KEY, // DC_BTN_X
AWAVE_COIN_KEY, // DC_BTN_D
AWAVE_BTN4_KEY, // DC_DPAD2_UP
// DC_DPAD2_DOWN
// DC_DPAD2_LEFT
// DC_DPAD2_RIGHT
0, // DC_DPAD2_DOWN
0, // DC_DPAD2_LEFT
0, // DC_DPAD2_RIGHT
};
u32 awavelg_button_mapping[16] = {
AWAVE_SERVICE_KEY, // DC_BTN_C
AWAVE_BTN0_KEY, // DC_BTN_B
AWAVE_TRIGGER_KEY, // DC_BTN_A
AWAVE_START_KEY, // DC_BTN_START
AWAVE_UP_KEY, // DC_DPAD_UP
AWAVE_DOWN_KEY, // DC_DPAD_DOWN
AWAVE_LEFT_KEY, // DC_DPAD_LEFT
AWAVE_RIGHT_KEY, // DC_DPAD_RIGHT
AWAVE_TEST_KEY, // DC_BTN_Z
AWAVE_BTN2_KEY, // DC_BTN_Y
AWAVE_BTN1_KEY, // DC_BTN_X
AWAVE_COIN_KEY, // DC_BTN_D
AWAVE_BTN3_KEY, // DC_DPAD2_UP
AWAVE_BTN4_KEY, // DC_DPAD2_DOWN
0, // DC_DPAD2_LEFT
0, // DC_DPAD2_RIGHT
};
struct MapleConfigMap : IMapleConfigMap
@ -79,11 +98,12 @@ struct MapleConfigMap : IMapleConfigMap
}
else if (settings.platform.system == DC_PLATFORM_ATOMISWAVE)
{
const u32* mapping = settings.input.JammaSetup == JVS::LightGun ? awavelg_button_mapping : awave_button_mapping;
pjs->kcode = 0xFFFF;
for (int i = 0; i < 16; i++)
{
if ((kcode[player_num] & (1 << i)) == 0)
pjs->kcode &= ~awave_button_mapping[i];
pjs->kcode &= ~mapping[i];
}
pjs->joy[PJAI_X1] = GetBtFromSgn(joyx[player_num]);
if (NaomiGameInputs != NULL && NaomiGameInputs->axes[1].name != NULL && NaomiGameInputs->axes[1].type == Half)

View File

@ -1443,10 +1443,10 @@ struct maple_lightgun : maple_base
}
}
virtual void get_lightgun_pos()
virtual bool get_lightgun_pos() override
{
read_lightgun_position(mo_x_abs, mo_y_abs);
// TODO If NAOMI, set some bits at 0x600284 http://64darksoft.blogspot.com/2013/10/atomiswage-to-naomi-update-4.html
return true;
}
};

View File

@ -87,7 +87,7 @@ enum AWAVE_KEYS
// Not an actual button
AWAVE_COIN_KEY = 1 << 15,
AWAVE_TRIGGER_KEY = 1 << 12,
AWAVE_TRIGGER_KEY = 1 << 12,
};
struct IMapleConfigMap;
@ -110,7 +110,7 @@ struct maple_device
virtual bool maple_serialize(void **data, unsigned int *total_size){return true;};
virtual bool maple_unserialize(void **data, unsigned int *total_size){return true;};
virtual MapleDeviceType get_device_type() = 0;
virtual void get_lightgun_pos() {};
virtual bool get_lightgun_pos() { return false; }
};
maple_device* maple_Create(MapleDeviceType type);

View File

@ -94,6 +94,7 @@ static void maple_SB_MDEN_Write(u32 addr, u32 data)
}
}
#ifdef STRICT_MODE
static bool check_mdapro(u32 addr)
{
u32 area = (addr >> 26) & 7;
@ -114,6 +115,7 @@ static void maple_SB_MDSTAR_Write(u32 addr, u32 data)
if (!check_mdapro(SB_MDSTAR))
asic_RaiseInterrupt(holly_MAPLE_ILLADDR);
}
#endif
bool IsOnSh4Ram(u32 addr)
{
@ -146,6 +148,7 @@ static void maple_DoDma()
const bool swap_msb = (SB_MMSEL == 0);
u32 xfer_count=0;
bool last = false;
bool occupy = false;
while (last != true)
{
u32 header_1 = ReadMem32_nommu(addr);
@ -247,7 +250,10 @@ static void maple_DoDma()
{
u32 bus = (header_1 >> 16) & 3;
if (MapleDevices[bus][5])
MapleDevices[bus][5]->get_lightgun_pos();
{
occupy = MapleDevices[bus][5]->get_lightgun_pos();
verify(last);
}
addr += 1 * 4;
}
@ -272,7 +278,8 @@ static void maple_DoDma()
}
//printf("Maple XFER size %d bytes - %.2f ms\n",xfer_count,xfer_count*100.0f/(2*1024*1024/8));
sh4_sched_request(maple_schid, std::min((u64)xfer_count * (SH4_MAIN_CLOCK / (2 * 1024 * 1024 / 8)), (u64)SH4_MAIN_CLOCK));
if (!occupy)
sh4_sched_request(maple_schid, std::min((u64)xfer_count * (SH4_MAIN_CLOCK / (2 * 1024 * 1024 / 8)), (u64)SH4_MAIN_CLOCK));
}
static int maple_schd(int tag, int c, int j)

View File

@ -1,6 +1,7 @@
#include "spg.h"
#include "Renderer_if.h"
#include "hw/holly/holly_intc.h"
#include "hw/holly/sb.h"
#include "hw/sh4/sh4_sched.h"
#include "input/gamepad_device.h"
#include "oslib/oslib.h"
@ -64,6 +65,7 @@ void CalculateSync()
static u32 lightgun_line = 0xffff;
static u32 lightgun_hpos;
static bool maple_int_pending;
u32 fskip;
@ -81,7 +83,15 @@ int spg_line_sched(int tag, int cycl, int jit)
//Check for scanline interrupts -- really need to test the scanline values
if (SPG_VBLANK_INT.vblank_in_interrupt_line_number == prv_cur_scanline)
{
if (maple_int_pending)
{
maple_int_pending = false;
SB_MDST = 0;
asic_RaiseInterrupt(holly_MAPLE_DMA);
}
asic_RaiseInterrupt(holly_SCANINT1);
}
if (SPG_VBLANK_INT.vblank_out_interrupt_line_number == prv_cur_scanline)
asic_RaiseInterrupt(holly_SCANINT2);
@ -184,7 +194,9 @@ int spg_line_sched(int tag, int cycl, int jit)
}
if (lightgun_line != 0xffff && lightgun_line == prv_cur_scanline)
{
maple_int_pending = false;
SPG_TRIGGER_POS = ((lightgun_line & 0x3FF) << 16) | (lightgun_hpos & 0x3FF);
SB_MDST = 0;
asic_RaiseInterrupt(holly_MAPLE_DMA);
lightgun_line = 0xffff;
}
@ -222,14 +234,19 @@ int spg_line_sched(int tag, int cycl, int jit)
void read_lightgun_position(int x, int y)
{
static u8 flip;
maple_int_pending = true;
if (y < 0 || y >= 480 || x < 0 || x >= 640)
{
// Off screen
lightgun_line = 0xffff;
}
else
{
lightgun_line = y / (SPG_CONTROL.interlace ? 2 : 1) + SPG_VBLANK_INT.vblank_out_interrupt_line_number;
lightgun_hpos = x * (SPG_HBLANK.hstart - SPG_HBLANK.hbend) / 640 + SPG_HBLANK.hbend * 2; // Ok but why *2 ????
lightgun_hpos = std::min((u32)0x3FF, lightgun_hpos);
// For some reason returning the same position twice makes it register off screen
lightgun_hpos = (x + 286) ^ flip;
flip ^= 1;
}
}