Commit 8fa6f79b authored by Libretro-Admin's avatar Libretro-Admin
Browse files
parent 2c1e065a
Pipeline #16314 failed with stages
in 2 minutes and 20 seconds
......@@ -1488,11 +1488,12 @@ struct maple_lightgun : maple_base
}
}
virtual void get_lightgun_pos()
virtual bool get_lightgun_pos()
{
f32 x, y;
config->GetAbsolutePosition(&x, &y);
read_lightgun_position(x + 0.5f, y + 0.5f);
return true;
}
};
......
......@@ -95,7 +95,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);
......
......@@ -94,6 +94,7 @@ static void maple_SB_MDEN_Write(u32 addr, u32 data)
SB_MDEN=data&1;
}
#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
static bool IsOnSh4Ram(u32 addr)
{
......@@ -143,7 +145,8 @@ static void maple_DoDma(void)
#endif
const bool swap_msb = (SB_MMSEL == 0);
u32 xfer_count=0;
bool last = false;
bool last = false;
bool occupy = false;
while (last != true)
{
u32 header_1 = ReadMem32_nommu(addr);
......@@ -246,7 +249,7 @@ static void maple_DoDma(void)
{
u32 bus = (header_1 >> 16) & 3;
if (MapleDevices[bus][5])
MapleDevices[bus][5]->get_lightgun_pos();
occupy = MapleDevices[bus][5]->get_lightgun_pos();
addr += 1 * 4;
}
......@@ -271,7 +274,8 @@ static void maple_DoDma(void)
}
//printf("Maple XFER size %d bytes - %.2f ms\n",xfer_count,xfer_count*100.0f/(2*1024*1024/8));
sh4_sched_request(maple_sched, std::min((u64)xfer_count * (SH4_MAIN_CLOCK / (2 * 1024 * 1024 / 8)), (u64)SH4_MAIN_CLOCK));
if (!occupy)
sh4_sched_request(maple_sched, 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)
......
......@@ -2,6 +2,7 @@
#include "Renderer_if.h"
#include "pvr_regs.h"
#include "hw/holly/holly_intc.h"
#include "hw/holly/sb.h"
#include "hw/sh4/sh4_sched.h"
u32 in_vblank;
......@@ -18,6 +19,7 @@ int vblank_schid;
static u32 lightgun_line = 0xffff;
static u32 lightgun_hpos;
static bool maple_int_pending;
void CalculateSync(void)
{
......@@ -73,7 +75,16 @@ int spg_line_sched(int tag, int cycl, int jit)
/* Vblank in */
if (SPG_VBLANK_INT.vblank_in_interrupt_line_number == pvr_cur_scanline)
asic_RaiseInterrupt(holly_SCANINT1);
{
if (maple_int_pending)
{
maple_int_pending = false;
SB_MDST = 0;
asic_RaiseInterrupt(holly_MAPLE_DMA);
}
asic_RaiseInterrupt(holly_SCANINT1);
}
/* Vblank Out */
if (SPG_VBLANK_INT.vblank_out_interrupt_line_number == pvr_cur_scanline)
......@@ -117,7 +128,9 @@ int spg_line_sched(int tag, int cycl, int jit)
}
if (lightgun_line != 0xffff && lightgun_line == pvr_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;
}
......@@ -159,18 +172,18 @@ 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 = min((u32)0x3FF, lightgun_hpos);
// For some reason returning the same position twice makes it register off screen
lightgun_hpos ^= flip;
flip ^= 1;
lightgun_hpos = (x + 286) ^ flip;
flip ^= 1;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment