mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
Merge branch 'master' of https://github.com/mamedev/mame
This commit is contained in:
commit
2a6658be47
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,6 +13,7 @@
|
||||
!/samples/
|
||||
!/scripts/
|
||||
!/src/
|
||||
!/shaders/
|
||||
!/tests/
|
||||
!/doxygen/
|
||||
!/web/
|
||||
|
1
3rdparty/bgfx/tools/bin/windows/.gitignore
vendored
1
3rdparty/bgfx/tools/bin/windows/.gitignore
vendored
@ -1 +0,0 @@
|
||||
*
|
BIN
3rdparty/bgfx/tools/bin/windows/geometryc.exe
vendored
Normal file
BIN
3rdparty/bgfx/tools/bin/windows/geometryc.exe
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/tools/bin/windows/shaderc.exe
vendored
Normal file
BIN
3rdparty/bgfx/tools/bin/windows/shaderc.exe
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/tools/bin/windows/texturec.exe
vendored
Normal file
BIN
3rdparty/bgfx/tools/bin/windows/texturec.exe
vendored
Normal file
Binary file not shown.
4
makefile
4
makefile
@ -1367,3 +1367,7 @@ cppcheck:
|
||||
@echo Generate CppCheck analysis report
|
||||
cppcheck --enable=all src/ $(CPPCHECK_PARAMS) -j9
|
||||
|
||||
.PHONY: shaders
|
||||
|
||||
shaders:
|
||||
$(SILENT) $(MAKE) -C $(SRC)/osd/modules/render/bgfx rebuild
|
||||
|
BIN
shaders/dx11/fs_line.bin
Normal file
BIN
shaders/dx11/fs_line.bin
Normal file
Binary file not shown.
BIN
shaders/dx11/fs_quad.bin
Normal file
BIN
shaders/dx11/fs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/dx11/fs_quad_texture.bin
Normal file
BIN
shaders/dx11/fs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/dx11/vs_line.bin
Normal file
BIN
shaders/dx11/vs_line.bin
Normal file
Binary file not shown.
BIN
shaders/dx11/vs_quad.bin
Normal file
BIN
shaders/dx11/vs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/dx11/vs_quad_texture.bin
Normal file
BIN
shaders/dx11/vs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/dx9/fs_line.bin
Normal file
BIN
shaders/dx9/fs_line.bin
Normal file
Binary file not shown.
BIN
shaders/dx9/fs_quad.bin
Normal file
BIN
shaders/dx9/fs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/dx9/fs_quad_texture.bin
Normal file
BIN
shaders/dx9/fs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/dx9/vs_line.bin
Normal file
BIN
shaders/dx9/vs_line.bin
Normal file
Binary file not shown.
BIN
shaders/dx9/vs_quad.bin
Normal file
BIN
shaders/dx9/vs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/dx9/vs_quad_texture.bin
Normal file
BIN
shaders/dx9/vs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/gles/fs_line.bin
Normal file
BIN
shaders/gles/fs_line.bin
Normal file
Binary file not shown.
BIN
shaders/gles/fs_quad.bin
Normal file
BIN
shaders/gles/fs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/gles/fs_quad_texture.bin
Normal file
BIN
shaders/gles/fs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/gles/vs_line.bin
Normal file
BIN
shaders/gles/vs_line.bin
Normal file
Binary file not shown.
BIN
shaders/gles/vs_quad.bin
Normal file
BIN
shaders/gles/vs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/gles/vs_quad_texture.bin
Normal file
BIN
shaders/gles/vs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/glsl/fs_line.bin
Normal file
BIN
shaders/glsl/fs_line.bin
Normal file
Binary file not shown.
BIN
shaders/glsl/fs_quad.bin
Normal file
BIN
shaders/glsl/fs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/glsl/fs_quad_texture.bin
Normal file
BIN
shaders/glsl/fs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/glsl/vs_line.bin
Normal file
BIN
shaders/glsl/vs_line.bin
Normal file
Binary file not shown.
BIN
shaders/glsl/vs_quad.bin
Normal file
BIN
shaders/glsl/vs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/glsl/vs_quad_texture.bin
Normal file
BIN
shaders/glsl/vs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/metal/fs_line.bin
Normal file
BIN
shaders/metal/fs_line.bin
Normal file
Binary file not shown.
BIN
shaders/metal/fs_quad.bin
Normal file
BIN
shaders/metal/fs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/metal/fs_quad_texture.bin
Normal file
BIN
shaders/metal/fs_quad_texture.bin
Normal file
Binary file not shown.
BIN
shaders/metal/vs_line.bin
Normal file
BIN
shaders/metal/vs_line.bin
Normal file
Binary file not shown.
BIN
shaders/metal/vs_quad.bin
Normal file
BIN
shaders/metal/vs_quad.bin
Normal file
Binary file not shown.
BIN
shaders/metal/vs_quad_texture.bin
Normal file
BIN
shaders/metal/vs_quad_texture.bin
Normal file
Binary file not shown.
@ -310,14 +310,14 @@ WRITE_LINE_MEMBER( luxor_55_10828_device::fdc_intrq_w )
|
||||
m_fdc_irq = state;
|
||||
m_pio->port_b_write(state << 7);
|
||||
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, CLEAR_LINE);
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, CLEAR_LINE);
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( luxor_55_10828_device::fdc_drq_w )
|
||||
{
|
||||
m_fdc_drq = state;
|
||||
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, CLEAR_LINE);
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, CLEAR_LINE);
|
||||
}
|
||||
|
||||
|
||||
@ -654,7 +654,7 @@ READ8_MEMBER( luxor_55_10828_device::fdc_r )
|
||||
{
|
||||
logerror("Z80 WAIT not supported by MAME core\n");
|
||||
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, ASSERT_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, ASSERT_LINE);
|
||||
}
|
||||
|
||||
return m_fdc->gen_r(offset);
|
||||
@ -671,7 +671,7 @@ WRITE8_MEMBER( luxor_55_10828_device::fdc_w )
|
||||
{
|
||||
logerror("Z80 WAIT not supported by MAME core\n");
|
||||
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, ASSERT_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, ASSERT_LINE);
|
||||
}
|
||||
|
||||
m_fdc->gen_w(offset, data);
|
||||
|
@ -10,6 +10,7 @@
|
||||
* - If LD A,I or LD A,R is interrupted, P/V flag gets reset, even if IFF2
|
||||
* was set before this instruction (implemented, but not enabled: we need
|
||||
* document Z80 types first, see below)
|
||||
* - WAIT only stalls between instructions now, it should stall immediately.
|
||||
* - Ideally, the tiny differences between Z80 types should be supported,
|
||||
* currently known differences:
|
||||
* - LD A,I/R P/V flag reset glitch is fixed on CMOS Z80
|
||||
@ -113,10 +114,6 @@
|
||||
|
||||
#define VERBOSE 0
|
||||
|
||||
/* Debug purpose: set to 1 to test /WAIT pin behaviour.
|
||||
*/
|
||||
#define STALLS_ON_WAIT_ASSERT 0
|
||||
|
||||
/* On an NMOS Z80, if LD A,I or LD A,R is interrupted, P/V flag gets reset,
|
||||
even if IFF2 was set before this instruction. This issue was fixed on
|
||||
the CMOS Z80, so until knowing (most) Z80 types on hardware, it's disabled */
|
||||
@ -3128,6 +3125,27 @@ OP(op,fe) { cp(arg());
|
||||
OP(op,ff) { rst(0x38); } /* RST 7 */
|
||||
|
||||
|
||||
void z80_device::take_nmi()
|
||||
{
|
||||
/* there isn't a valid previous program counter */
|
||||
PRVPC = -1;
|
||||
|
||||
/* Check if processor was halted */
|
||||
leave_halt();
|
||||
|
||||
#if HAS_LDAIR_QUIRK
|
||||
/* reset parity flag after LD A,I or LD A,R */
|
||||
if (m_after_ldair) F &= ~PF;
|
||||
#endif
|
||||
|
||||
m_iff1 = 0;
|
||||
push(m_pc);
|
||||
PCD = 0x0066;
|
||||
WZ=PCD;
|
||||
m_icount -= 11;
|
||||
m_nmi_pending = FALSE;
|
||||
}
|
||||
|
||||
void z80_device::take_interrupt()
|
||||
{
|
||||
int irq_vector;
|
||||
@ -3210,6 +3228,11 @@ void z80_device::take_interrupt()
|
||||
m_icount -= m_cc_ex[0xff];
|
||||
}
|
||||
WZ=PCD;
|
||||
|
||||
#if HAS_LDAIR_QUIRK
|
||||
/* reset parity flag after LD A,I or LD A,R */
|
||||
if (m_after_ldair) F &= ~PF;
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsc800_device::take_interrupt_nsc800()
|
||||
@ -3243,6 +3266,11 @@ void nsc800_device::take_interrupt_nsc800()
|
||||
m_icount -= m_cc_op[0xff] + cc_ex[0xff];
|
||||
|
||||
WZ=PCD;
|
||||
|
||||
#if HAS_LDAIR_QUIRK
|
||||
/* reset parity flag after LD A,I or LD A,R */
|
||||
if (m_after_ldair) F &= ~PF;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -3478,102 +3506,56 @@ void nsc800_device::device_reset()
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Execute 'cycles' T-states. Return number of T-states really executed
|
||||
* Execute 'cycles' T-states.
|
||||
****************************************************************************/
|
||||
void z80_device::execute_run()
|
||||
{
|
||||
|
||||
/* check for NMIs on the way in; they can only be set externally */
|
||||
/* via timers, and can't be dynamically enabled, so it is safe */
|
||||
/* to just check here */
|
||||
if (m_nmi_pending)
|
||||
{
|
||||
LOG(("Z80 '%s' take NMI\n", tag()));
|
||||
PRVPC = -1; /* there isn't a valid previous program counter */
|
||||
leave_halt(); /* Check if processor was halted */
|
||||
|
||||
#if HAS_LDAIR_QUIRK
|
||||
/* reset parity flag after LD A,I or LD A,R */
|
||||
if (m_after_ldair) F &= ~PF;
|
||||
#endif
|
||||
m_after_ldair = FALSE;
|
||||
|
||||
m_iff1 = 0;
|
||||
push(m_pc);
|
||||
PCD = 0x0066;
|
||||
WZ=PCD;
|
||||
m_icount -= 11;
|
||||
m_nmi_pending = FALSE;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
/* check for IRQs before each instruction */
|
||||
if (m_irq_state != CLEAR_LINE && m_iff1 && !m_after_ei)
|
||||
if (m_wait_state)
|
||||
{
|
||||
#if HAS_LDAIR_QUIRK
|
||||
/* reset parity flag after LD A,I or LD A,R */
|
||||
if (m_after_ldair) F &= ~PF;
|
||||
#endif
|
||||
take_interrupt();
|
||||
// stalled
|
||||
m_icount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// check for interrupts before each instruction
|
||||
if (m_nmi_pending)
|
||||
take_nmi();
|
||||
else if (m_irq_state != CLEAR_LINE && m_iff1 && !m_after_ei)
|
||||
take_interrupt();
|
||||
|
||||
m_after_ei = FALSE;
|
||||
m_after_ldair = FALSE;
|
||||
|
||||
PRVPC = PCD;
|
||||
debugger_instruction_hook(this, PCD);
|
||||
m_r++;
|
||||
#if STALLS_ON_WAIT_ASSERT
|
||||
static int test_cycles;
|
||||
|
||||
if(m_wait_state == ASSERT_LINE)
|
||||
{
|
||||
m_icount --;
|
||||
test_cycles ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(test_cycles != 0)
|
||||
printf("stalls for %d z80 cycles\n",test_cycles);
|
||||
test_cycles = 0;
|
||||
EXEC(op,rop());
|
||||
}
|
||||
#else
|
||||
EXEC(op,rop());
|
||||
#endif
|
||||
} while (m_icount > 0);
|
||||
}
|
||||
|
||||
void nsc800_device::execute_run()
|
||||
{
|
||||
/* check for NMIs on the way in; they can only be set externally */
|
||||
/* via timers, and can't be dynamically enabled, so it is safe */
|
||||
/* to just check here */
|
||||
if (m_nmi_pending)
|
||||
{
|
||||
LOG(("Z80 '%s' take NMI\n", tag()));
|
||||
PRVPC = -1; /* there isn't a valid previous program counter */
|
||||
leave_halt(); /* Check if processor was halted */
|
||||
|
||||
m_iff1 = 0;
|
||||
push(m_pc);
|
||||
PCD = 0x0066;
|
||||
WZ=PCD;
|
||||
m_icount -= 11;
|
||||
m_nmi_pending = FALSE;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
/* check for NSC800 IRQs line RSTA, RSTB, RSTC */
|
||||
if ((m_nsc800_irq_state[NSC800_RSTA] != CLEAR_LINE || m_nsc800_irq_state[NSC800_RSTB] != CLEAR_LINE || m_nsc800_irq_state[NSC800_RSTC] != CLEAR_LINE) && m_iff1 && !m_after_ei)
|
||||
take_interrupt_nsc800();
|
||||
if (m_wait_state)
|
||||
{
|
||||
// stalled
|
||||
m_icount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* check for IRQs before each instruction */
|
||||
if (m_irq_state != CLEAR_LINE && m_iff1 && !m_after_ei)
|
||||
// check for interrupts before each instruction
|
||||
if (m_nmi_pending)
|
||||
take_nmi();
|
||||
else if ((m_nsc800_irq_state[NSC800_RSTA] != CLEAR_LINE || m_nsc800_irq_state[NSC800_RSTB] != CLEAR_LINE || m_nsc800_irq_state[NSC800_RSTC] != CLEAR_LINE) && m_iff1 && !m_after_ei)
|
||||
take_interrupt_nsc800();
|
||||
else if (m_irq_state != CLEAR_LINE && m_iff1 && !m_after_ei)
|
||||
take_interrupt();
|
||||
|
||||
m_after_ei = FALSE;
|
||||
m_after_ldair = FALSE;
|
||||
|
||||
PRVPC = PCD;
|
||||
debugger_instruction_hook(this, PCD);
|
||||
@ -3609,6 +3591,9 @@ void z80_device::execute_set_input(int inputnum, int state)
|
||||
case Z80_INPUT_LINE_WAIT:
|
||||
m_wait_state = state;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3616,17 +3601,6 @@ void nsc800_device::execute_set_input(int inputnum, int state)
|
||||
{
|
||||
switch (inputnum)
|
||||
{
|
||||
case Z80_INPUT_LINE_BUSRQ:
|
||||
m_busrq_state = state;
|
||||
break;
|
||||
|
||||
case INPUT_LINE_NMI:
|
||||
/* mark an NMI pending on the rising edge */
|
||||
if (m_nmi_state == CLEAR_LINE && state != CLEAR_LINE)
|
||||
m_nmi_pending = TRUE;
|
||||
m_nmi_state = state;
|
||||
break;
|
||||
|
||||
case NSC800_RSTA:
|
||||
m_nsc800_irq_state[NSC800_RSTA] = state;
|
||||
break;
|
||||
@ -3639,17 +3613,8 @@ void nsc800_device::execute_set_input(int inputnum, int state)
|
||||
m_nsc800_irq_state[NSC800_RSTC] = state;
|
||||
break;
|
||||
|
||||
case INPUT_LINE_IRQ0:
|
||||
/* update the IRQ state via the daisy chain */
|
||||
m_irq_state = state;
|
||||
if (m_daisy.present())
|
||||
m_irq_state = m_daisy.update_irq_state();
|
||||
|
||||
/* the main execute loop will take the interrupt */
|
||||
break;
|
||||
|
||||
case Z80_INPUT_LINE_WAIT:
|
||||
m_wait_state = state;
|
||||
default:
|
||||
z80_device::execute_set_input(inputnum, state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3772,10 +3737,3 @@ nsc800_device::nsc800_device(const machine_config &mconfig, const char *tag, dev
|
||||
}
|
||||
|
||||
const device_type NSC800 = &device_creator<nsc800_device>;
|
||||
|
||||
|
||||
|
||||
WRITE_LINE_MEMBER( z80_device::irq_line )
|
||||
{
|
||||
set_input_line( INPUT_LINE_IRQ0, state );
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ enum
|
||||
NSC800_RSTB,
|
||||
NSC800_RSTC,
|
||||
Z80_INPUT_LINE_WAIT,
|
||||
Z80_INPUT_LINE_BOGUSWAIT, /* WAIT pin implementation used to be nonexistent, please remove this when all drivers are updated with Z80_INPUT_LINE_WAIT */
|
||||
Z80_INPUT_LINE_BUSRQ
|
||||
};
|
||||
|
||||
@ -41,8 +42,6 @@ class z80_device : public cpu_device
|
||||
public:
|
||||
z80_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER( irq_line );
|
||||
|
||||
void z80_set_cycle_tables(const UINT8 *op, const UINT8 *cb, const UINT8 *ed, const UINT8 *xy, const UINT8 *xycb, const UINT8 *ex);
|
||||
template<class _Object> static devcb_base &set_irqack_cb(device_t &device, _Object object) { return downcast<z80_device &>(device).m_irqack_cb.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_refresh_cb(device_t &device, _Object object) { return downcast<z80_device &>(device).m_refresh_cb.set_callback(object); }
|
||||
@ -238,6 +237,7 @@ protected:
|
||||
void ei();
|
||||
|
||||
void take_interrupt();
|
||||
void take_nmi();
|
||||
|
||||
// address spaces
|
||||
const address_space_config m_program_config;
|
||||
|
@ -1067,7 +1067,7 @@ static MACHINE_CONFIG_START( adam, adam_state )
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
MCFG_SOUND_ADD(SN76489A_TAG, SN76489A, XTAL_7_15909MHz/2)
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
|
||||
MCFG_SN76496_READY_HANDLER(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_WAIT))
|
||||
MCFG_SN76496_READY_HANDLER(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_BOGUSWAIT))
|
||||
|
||||
// devices
|
||||
MCFG_ADAMNET_BUS_ADD()
|
||||
|
@ -574,8 +574,8 @@ static MACHINE_CONFIG_START( common, bw12_state )
|
||||
MCFG_PIA_WRITEPB_HANDLER(DEVWRITE8("cent_data_out", output_latch_device, write))
|
||||
MCFG_PIA_CA2_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_strobe))
|
||||
MCFG_PIA_CB2_HANDLER(WRITELINE(bw12_state, pia_cb2_w))
|
||||
MCFG_PIA_IRQA_HANDLER(DEVWRITELINE(Z80_TAG, z80_device, irq_line))
|
||||
MCFG_PIA_IRQB_HANDLER(DEVWRITELINE(Z80_TAG, z80_device, irq_line))
|
||||
MCFG_PIA_IRQA_HANDLER(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0))
|
||||
MCFG_PIA_IRQB_HANDLER(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0))
|
||||
|
||||
MCFG_Z80SIO0_ADD(Z80SIO_TAG, XTAL_16MHz/4, 0, 0, 0, 0)
|
||||
MCFG_Z80DART_OUT_TXDA_CB(DEVWRITELINE(RS232_A_TAG, rs232_port_device, write_txd))
|
||||
|
@ -831,7 +831,7 @@ static MACHINE_CONFIG_START( lynx48k, camplynx_state )
|
||||
MCFG_MC6845_SHOW_BORDER_AREA(false)
|
||||
MCFG_MC6845_CHAR_WIDTH(8)
|
||||
MCFG_MC6845_UPDATE_ROW_CB(camplynx_state, lynx48k_update_row)
|
||||
MCFG_MC6845_OUT_VSYNC_CB(DEVWRITELINE("maincpu", z80_device, irq_line))
|
||||
MCFG_MC6845_OUT_VSYNC_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0))
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
static MACHINE_CONFIG_DERIVED( lynx96k, lynx48k )
|
||||
@ -871,7 +871,7 @@ static MACHINE_CONFIG_START( lynx128k, camplynx_state )
|
||||
MCFG_MC6845_SHOW_BORDER_AREA(false)
|
||||
MCFG_MC6845_CHAR_WIDTH(8)
|
||||
MCFG_MC6845_UPDATE_ROW_CB(camplynx_state, lynx128k_update_row)
|
||||
MCFG_MC6845_OUT_VSYNC_CB(DEVWRITELINE("maincpu", z80_device, irq_line))
|
||||
MCFG_MC6845_OUT_VSYNC_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0))
|
||||
|
||||
MCFG_FRAGMENT_ADD(lynx_disk)
|
||||
MACHINE_CONFIG_END
|
||||
|
@ -516,7 +516,7 @@ static MACHINE_CONFIG_START( ep64, ep64_state )
|
||||
MCFG_EP64_EXPANSION_BUS_SLOT_DAVE(DAVE_TAG)
|
||||
MCFG_EP64_EXPANSION_BUS_SLOT_IRQ_CALLBACK(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0))
|
||||
MCFG_EP64_EXPANSION_BUS_SLOT_NMI_CALLBACK(INPUTLINE(Z80_TAG, INPUT_LINE_NMI))
|
||||
MCFG_EP64_EXPANSION_BUS_SLOT_WAIT_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_WAIT))
|
||||
MCFG_EP64_EXPANSION_BUS_SLOT_WAIT_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_BOGUSWAIT))
|
||||
|
||||
MCFG_CENTRONICS_ADD(CENTRONICS_TAG, centronics_devices, "printer")
|
||||
MCFG_CENTRONICS_BUSY_HANDLER(WRITELINE(ep64_state, write_centronics_busy))
|
||||
|
@ -1047,7 +1047,7 @@ static MACHINE_CONFIG_START( wheelrun, fantland_state )
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
|
||||
MCFG_SOUND_ADD("ymsnd", YM3526, XTAL_14MHz/4)
|
||||
MCFG_YM3526_IRQ_HANDLER(DEVWRITELINE("audiocpu", z80_device, irq_line))
|
||||
MCFG_YM3526_IRQ_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_IRQ0))
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
@ -168,7 +168,7 @@ static MACHINE_CONFIG_START( horizon, horizon_state )
|
||||
|
||||
// S-100
|
||||
MCFG_S100_BUS_ADD()
|
||||
MCFG_S100_RDY_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_WAIT))
|
||||
MCFG_S100_RDY_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_BOGUSWAIT))
|
||||
//MCFG_S100_SLOT_ADD("s100_1", horizon_s100_cards, NULL, NULL) // CPU
|
||||
MCFG_S100_SLOT_ADD("s100_2", horizon_s100_cards, nullptr) // RAM
|
||||
MCFG_S100_SLOT_ADD("s100_3", horizon_s100_cards, "mdsad") // MDS
|
||||
|
@ -716,7 +716,7 @@ static MACHINE_CONFIG_START( mpz80, mpz80_state )
|
||||
MCFG_S100_BUS_ADD()
|
||||
MCFG_S100_IRQ_CALLBACK(WRITELINE(mpz80_state, s100_pint_w))
|
||||
MCFG_S100_NMI_CALLBACK(WRITELINE(mpz80_state, s100_nmi_w))
|
||||
MCFG_S100_RDY_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_WAIT))
|
||||
MCFG_S100_RDY_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_BOGUSWAIT))
|
||||
MCFG_S100_SLOT_ADD("s100_1", mpz80_s100_cards, "mm65k16s")
|
||||
MCFG_S100_SLOT_ADD("s100_2", mpz80_s100_cards, "wunderbus")
|
||||
MCFG_S100_SLOT_ADD("s100_3", mpz80_s100_cards, "dj2db")
|
||||
|
@ -492,7 +492,7 @@ static MACHINE_CONFIG_START( mrgame, mrgame_state )
|
||||
MCFG_DAC_ADD("dacr")
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
|
||||
MCFG_SOUND_ADD("tms", TMS5220, 672000) // uses a RC combination. 672k copied from jedi.h
|
||||
MCFG_TMS52XX_READYQ_HANDLER(INPUTLINE("audiocpu2", Z80_INPUT_LINE_WAIT))
|
||||
MCFG_TMS52XX_READYQ_HANDLER(INPUTLINE("audiocpu2", Z80_INPUT_LINE_BOGUSWAIT))
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
|
||||
|
||||
|
@ -425,12 +425,12 @@ READ8_MEMBER(nightgal_state::royalqn_nsc_blit_r)
|
||||
|
||||
TIMER_CALLBACK_MEMBER(nightgal_state::z80_wait_ack_cb)
|
||||
{
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, CLEAR_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, CLEAR_LINE);
|
||||
}
|
||||
|
||||
void nightgal_state::z80_wait_assert_cb()
|
||||
{
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, ASSERT_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, ASSERT_LINE);
|
||||
|
||||
// Note: cycles_to_attotime requires z80 context to work, calling for example m_subcpu as context gives a x4 cycle boost in z80 terms (reads execute_cycles_to_clocks() from NCS?) even if they runs at same speed basically.
|
||||
// TODO: needs a getter that tells a given CPU how many cycles requires an executing opcode for the r/w operation, which stacks with wait state penalty for accessing this specific area.
|
||||
|
@ -1021,7 +1021,7 @@ static MACHINE_CONFIG_START( bestbest, suna16_state )
|
||||
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
|
||||
|
||||
MCFG_SOUND_ADD("ymsnd", YM3526, XTAL_24MHz/8) /* 3MHz */
|
||||
MCFG_YM3526_IRQ_HANDLER(DEVWRITELINE("audiocpu", z80_device, irq_line))
|
||||
MCFG_YM3526_IRQ_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_IRQ0))
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
|
||||
|
||||
|
@ -193,7 +193,7 @@ READ8_MEMBER( super6_state::fdc_r )
|
||||
|
||||
// don't crash please... but it's true, WAIT does nothing in our Z80
|
||||
//fatalerror("Z80 WAIT not supported by MAME core\n");
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, ASSERT_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, ASSERT_LINE);
|
||||
|
||||
return !m_fdc->intrq_r() << 7;
|
||||
}
|
||||
@ -409,14 +409,14 @@ SLOT_INTERFACE_END
|
||||
|
||||
WRITE_LINE_MEMBER( super6_state::fdc_intrq_w )
|
||||
{
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, CLEAR_LINE);
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, CLEAR_LINE);
|
||||
|
||||
m_ctc->trg3(!state);
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( super6_state::fdc_drq_w )
|
||||
{
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, CLEAR_LINE);
|
||||
if (state) m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, CLEAR_LINE);
|
||||
|
||||
m_dma->rdy_w(state);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ READ8_MEMBER( xor100_state::fdc_wait_r )
|
||||
if (!m_fdc_irq && !m_fdc_drq)
|
||||
{
|
||||
fatalerror("Z80 WAIT not supported by MAME core\n");
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, ASSERT_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, ASSERT_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,7 +442,7 @@ void xor100_state::fdc_intrq_w(bool state)
|
||||
if (state)
|
||||
{
|
||||
fatalerror("Z80 WAIT not supported by MAME core\n");
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, ASSERT_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, ASSERT_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,7 +453,7 @@ void xor100_state::fdc_drq_w(bool state)
|
||||
if (state)
|
||||
{
|
||||
fatalerror("Z80 WAIT not supported by MAME core\n");
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, ASSERT_LINE);
|
||||
m_maincpu->set_input_line(Z80_INPUT_LINE_BOGUSWAIT, ASSERT_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ static MACHINE_CONFIG_START( xor100, xor100_state )
|
||||
|
||||
// S-100
|
||||
MCFG_S100_BUS_ADD()
|
||||
MCFG_S100_RDY_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_WAIT))
|
||||
MCFG_S100_RDY_CALLBACK(INPUTLINE(Z80_TAG, Z80_INPUT_LINE_BOGUSWAIT))
|
||||
MCFG_S100_SLOT_ADD("s100_1", xor100_s100_cards, nullptr)
|
||||
MCFG_S100_SLOT_ADD("s100_2", xor100_s100_cards, nullptr)
|
||||
MCFG_S100_SLOT_ADD("s100_3", xor100_s100_cards, nullptr)
|
||||
|
11
src/osd/modules/render/bgfx/fs_line.sc
Normal file
11
src/osd/modules/render/bgfx/fs_line.sc
Normal file
@ -0,0 +1,11 @@
|
||||
$input v_color0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
|
||||
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = v_color0;
|
||||
}
|
11
src/osd/modules/render/bgfx/fs_quad.sc
Normal file
11
src/osd/modules/render/bgfx/fs_quad.sc
Normal file
@ -0,0 +1,11 @@
|
||||
$input v_color0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
|
||||
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = v_color0;
|
||||
}
|
14
src/osd/modules/render/bgfx/fs_quad_texture.sc
Normal file
14
src/osd/modules/render/bgfx/fs_quad_texture.sc
Normal file
@ -0,0 +1,14 @@
|
||||
$input v_color0, v_texcoord0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
|
||||
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
|
||||
|
||||
SAMPLER2D(s_tex, 0);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture2D(s_tex, v_texcoord0);
|
||||
gl_FragColor = texel * v_color0;
|
||||
}
|
13
src/osd/modules/render/bgfx/makefile
Normal file
13
src/osd/modules/render/bgfx/makefile
Normal file
@ -0,0 +1,13 @@
|
||||
BGFX_DIR=../../../../../3rdparty/bgfx
|
||||
RUNTIME_DIR=../../../../..
|
||||
BUILD_DIR=../../../../../build
|
||||
|
||||
include $(BGFX_DIR)/scripts/shader.mk
|
||||
|
||||
rebuild:
|
||||
@make -s --no-print-directory TARGET=0 clean all
|
||||
@make -s --no-print-directory TARGET=1 clean all
|
||||
@make -s --no-print-directory TARGET=2 clean all
|
||||
@make -s --no-print-directory TARGET=3 clean all
|
||||
@make -s --no-print-directory TARGET=4 clean all
|
||||
@make -s --no-print-directory TARGET=5 clean all
|
7
src/osd/modules/render/bgfx/varying.def.sc
Normal file
7
src/osd/modules/render/bgfx/varying.def.sc
Normal file
@ -0,0 +1,7 @@
|
||||
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
|
||||
vec3 v_pos : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
vec3 a_position : POSITION;
|
||||
vec4 a_color0 : COLOR0;
|
||||
vec2 a_texcoord0 : TEXCOORD0;
|
13
src/osd/modules/render/bgfx/vs_line.sc
Normal file
13
src/osd/modules/render/bgfx/vs_line.sc
Normal file
@ -0,0 +1,13 @@
|
||||
$input a_position, a_color0
|
||||
$output v_color0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
|
||||
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
v_color0 = a_color0;
|
||||
}
|
13
src/osd/modules/render/bgfx/vs_quad.sc
Normal file
13
src/osd/modules/render/bgfx/vs_quad.sc
Normal file
@ -0,0 +1,13 @@
|
||||
$input a_position, a_color0
|
||||
$output v_color0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
|
||||
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
v_color0 = a_color0;
|
||||
}
|
14
src/osd/modules/render/bgfx/vs_quad_texture.sc
Normal file
14
src/osd/modules/render/bgfx/vs_quad_texture.sc
Normal file
@ -0,0 +1,14 @@
|
||||
$input a_position, a_texcoord0, a_color0
|
||||
$output v_texcoord0, v_color0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
|
||||
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
v_texcoord0 = a_texcoord0;
|
||||
v_color0 = a_color0;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Miodrag Milanovic
|
||||
// copyright-holders:Miodrag Milanovic, Dario Manesku, Branimir Karadzic
|
||||
//============================================================
|
||||
//
|
||||
// drawbgfx.c - BGFX drawer
|
||||
@ -30,6 +30,8 @@
|
||||
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/fpumath.h>
|
||||
#include <bx/readerwriter.h>
|
||||
|
||||
//============================================================
|
||||
// DEBUGGING
|
||||
@ -110,6 +112,11 @@ public:
|
||||
INT64 m_last_blit_time;
|
||||
INT64 m_last_blit_pixels;
|
||||
|
||||
bgfx::ProgramHandle m_progQuad;
|
||||
bgfx::ProgramHandle m_progQuadTexture;
|
||||
bgfx::ProgramHandle m_progLine;
|
||||
bgfx::UniformHandle m_s_texColor;
|
||||
|
||||
// Original display_mode
|
||||
};
|
||||
|
||||
@ -155,7 +162,7 @@ static void drawbgfx_exit(void)
|
||||
//============================================================
|
||||
// renderer_bgfx::create
|
||||
//============================================================
|
||||
|
||||
bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName);
|
||||
int renderer_bgfx::create()
|
||||
{
|
||||
// create renderer
|
||||
@ -177,7 +184,12 @@ int renderer_bgfx::create()
|
||||
#endif
|
||||
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(BGFX_DEBUG_STATS);// BGFX_DEBUG_TEXT);
|
||||
bgfx::setDebug(BGFX_DEBUG_TEXT); //BGFX_DEBUG_STATS
|
||||
// Create program from shaders.
|
||||
m_progQuad = loadProgram("vs_quad", "fs_quad");
|
||||
m_progQuadTexture = loadProgram("vs_quad_texture", "fs_quad_texture");
|
||||
m_progLine = loadProgram("vs_line", "fs_line");
|
||||
m_s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
|
||||
|
||||
osd_printf_verbose("Leave drawsdl2_window_create\n");
|
||||
return 0;
|
||||
@ -192,6 +204,12 @@ void renderer_bgfx::destroy()
|
||||
// free the memory in the window
|
||||
|
||||
// destroy_all_textures();
|
||||
//
|
||||
bgfx::destroyUniform(m_s_texColor);
|
||||
// Cleanup.
|
||||
bgfx::destroyProgram(m_progQuad);
|
||||
bgfx::destroyProgram(m_progQuadTexture);
|
||||
bgfx::destroyProgram(m_progLine);
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
@ -215,39 +233,421 @@ int renderer_bgfx::xy_to_render_target(int x, int y, int *xt, int *yt)
|
||||
}
|
||||
#endif
|
||||
|
||||
static const bgfx::Memory* loadMem(bx::FileReaderI* _reader, const char* _filePath)
|
||||
{
|
||||
if (bx::open(_reader, _filePath))
|
||||
{
|
||||
uint32_t size = (uint32_t)bx::getSize(_reader);
|
||||
const bgfx::Memory* mem = bgfx::alloc(size + 1);
|
||||
bx::read(_reader, mem->data, size);
|
||||
bx::close(_reader);
|
||||
mem->data[mem->size - 1] = '\0';
|
||||
return mem;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name)
|
||||
{
|
||||
char filePath[512];
|
||||
|
||||
const char* shaderPath = "shaders/dx9/";
|
||||
|
||||
switch (bgfx::getRendererType())
|
||||
{
|
||||
case bgfx::RendererType::Direct3D11:
|
||||
case bgfx::RendererType::Direct3D12:
|
||||
shaderPath = "shaders/dx11/";
|
||||
break;
|
||||
|
||||
case bgfx::RendererType::OpenGL:
|
||||
shaderPath = "shaders/glsl/";
|
||||
break;
|
||||
|
||||
case bgfx::RendererType::Metal:
|
||||
shaderPath = "shaders/metal/";
|
||||
break;
|
||||
|
||||
case bgfx::RendererType::OpenGLES:
|
||||
shaderPath = "shaders/gles/";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
strcpy(filePath, shaderPath);
|
||||
strcat(filePath, _name);
|
||||
strcat(filePath, ".bin");
|
||||
|
||||
return bgfx::createShader(loadMem(_reader, filePath));
|
||||
}
|
||||
|
||||
bgfx::ProgramHandle loadProgram(bx::FileReaderI* _reader, const char* _vsName, const char* _fsName)
|
||||
{
|
||||
bgfx::ShaderHandle vsh = loadShader(_reader, _vsName);
|
||||
bgfx::ShaderHandle fsh = BGFX_INVALID_HANDLE;
|
||||
if (NULL != _fsName)
|
||||
{
|
||||
fsh = loadShader(_reader, _fsName);
|
||||
}
|
||||
|
||||
return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */);
|
||||
}
|
||||
static auto s_fileReader = new bx::CrtFileReader;
|
||||
|
||||
bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName)
|
||||
{
|
||||
|
||||
return loadProgram(s_fileReader, _vsName, _fsName);
|
||||
}
|
||||
//============================================================
|
||||
// drawbgfx_window_draw
|
||||
//============================================================
|
||||
|
||||
struct PosColorTexCoord0Vertex
|
||||
{
|
||||
float m_x;
|
||||
float m_y;
|
||||
float m_z;
|
||||
uint32_t m_rgba;
|
||||
float m_u;
|
||||
float m_v;
|
||||
|
||||
static void init()
|
||||
{
|
||||
ms_decl.begin()
|
||||
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
|
||||
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
|
||||
.end();
|
||||
}
|
||||
|
||||
static bgfx::VertexDecl ms_decl;
|
||||
};
|
||||
bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
|
||||
|
||||
void screenQuad(float _x1
|
||||
, float _y1
|
||||
, float _x2
|
||||
, float _y2
|
||||
, uint32_t _abgr
|
||||
, render_quad_texuv uv
|
||||
)
|
||||
{
|
||||
if (bgfx::checkAvailTransientVertexBuffer(6, PosColorTexCoord0Vertex::ms_decl))
|
||||
{
|
||||
bgfx::TransientVertexBuffer vb;
|
||||
bgfx::allocTransientVertexBuffer(&vb, 6, PosColorTexCoord0Vertex::ms_decl);
|
||||
PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)vb.data;
|
||||
|
||||
const float minx = _x1;
|
||||
const float miny = _y1;
|
||||
const float maxx = _x2;
|
||||
const float maxy = _y2;
|
||||
const float zz = 0.0f;
|
||||
|
||||
vertex[0].m_x = minx;
|
||||
vertex[0].m_y = miny;
|
||||
vertex[0].m_z = zz;
|
||||
vertex[0].m_rgba = _abgr;
|
||||
vertex[0].m_u = uv.tl.u;
|
||||
vertex[0].m_v = uv.tl.v;
|
||||
|
||||
vertex[1].m_x = maxx;
|
||||
vertex[1].m_y = miny;
|
||||
vertex[1].m_z = zz;
|
||||
vertex[1].m_rgba = _abgr;
|
||||
vertex[1].m_u = uv.tr.u;
|
||||
vertex[1].m_v = uv.tr.v;
|
||||
|
||||
vertex[2].m_x = maxx;
|
||||
vertex[2].m_y = maxy;
|
||||
vertex[2].m_z = zz;
|
||||
vertex[2].m_rgba = _abgr;
|
||||
vertex[2].m_u = uv.br.u;
|
||||
vertex[2].m_v = uv.br.v;
|
||||
|
||||
vertex[3].m_x = maxx;
|
||||
vertex[3].m_y = maxy;
|
||||
vertex[3].m_z = zz;
|
||||
vertex[3].m_rgba = _abgr;
|
||||
vertex[3].m_u = uv.br.u;
|
||||
vertex[3].m_v = uv.br.v;
|
||||
|
||||
vertex[4].m_x = minx;
|
||||
vertex[4].m_y = maxy;
|
||||
vertex[4].m_z = zz;
|
||||
vertex[4].m_rgba = _abgr;
|
||||
vertex[4].m_u = uv.bl.u;
|
||||
vertex[4].m_v = uv.bl.v;
|
||||
|
||||
vertex[5].m_x = minx;
|
||||
vertex[5].m_y = miny;
|
||||
vertex[5].m_z = zz;
|
||||
vertex[5].m_rgba = _abgr;
|
||||
vertex[5].m_u = uv.tl.u;
|
||||
vertex[5].m_v = uv.tl.v;
|
||||
bgfx::setVertexBuffer(&vb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct PosColorVertex
|
||||
{
|
||||
float m_x;
|
||||
float m_y;
|
||||
uint32_t m_abgr;
|
||||
|
||||
static void init()
|
||||
{
|
||||
ms_decl
|
||||
.begin()
|
||||
.add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
|
||||
.end();
|
||||
}
|
||||
|
||||
static bgfx::VertexDecl ms_decl;
|
||||
};
|
||||
bgfx::VertexDecl PosColorVertex::ms_decl;
|
||||
|
||||
#define MAX_TEMP_COORDS 100
|
||||
|
||||
void drawPolygon(const float* _coords, uint32_t _numCoords, float _r, uint32_t _abgr)
|
||||
{
|
||||
float tempCoords[MAX_TEMP_COORDS * 2];
|
||||
float tempNormals[MAX_TEMP_COORDS * 2];
|
||||
|
||||
_numCoords = _numCoords < MAX_TEMP_COORDS ? _numCoords : MAX_TEMP_COORDS;
|
||||
|
||||
for (uint32_t ii = 0, jj = _numCoords - 1; ii < _numCoords; jj = ii++)
|
||||
{
|
||||
const float* v0 = &_coords[jj * 2];
|
||||
const float* v1 = &_coords[ii * 2];
|
||||
float dx = v1[0] - v0[0];
|
||||
float dy = v1[1] - v0[1];
|
||||
float d = sqrtf(dx * dx + dy * dy);
|
||||
if (d > 0)
|
||||
{
|
||||
d = 1.0f / d;
|
||||
dx *= d;
|
||||
dy *= d;
|
||||
}
|
||||
|
||||
tempNormals[jj * 2 + 0] = dy;
|
||||
tempNormals[jj * 2 + 1] = -dx;
|
||||
}
|
||||
|
||||
for (uint32_t ii = 0, jj = _numCoords - 1; ii < _numCoords; jj = ii++)
|
||||
{
|
||||
float dlx0 = tempNormals[jj * 2 + 0];
|
||||
float dly0 = tempNormals[jj * 2 + 1];
|
||||
float dlx1 = tempNormals[ii * 2 + 0];
|
||||
float dly1 = tempNormals[ii * 2 + 1];
|
||||
float dmx = (dlx0 + dlx1) * 0.5f;
|
||||
float dmy = (dly0 + dly1) * 0.5f;
|
||||
float dmr2 = dmx * dmx + dmy * dmy;
|
||||
if (dmr2 > 0.000001f)
|
||||
{
|
||||
float scale = 1.0f / dmr2;
|
||||
if (scale > 10.0f)
|
||||
{
|
||||
scale = 10.0f;
|
||||
}
|
||||
|
||||
dmx *= scale;
|
||||
dmy *= scale;
|
||||
}
|
||||
|
||||
tempCoords[ii * 2 + 0] = _coords[ii * 2 + 0] + dmx * _r;
|
||||
tempCoords[ii * 2 + 1] = _coords[ii * 2 + 1] + dmy * _r;
|
||||
}
|
||||
|
||||
uint32_t numVertices = _numCoords * 6 + (_numCoords - 2) * 3;
|
||||
if (bgfx::checkAvailTransientVertexBuffer(numVertices, PosColorVertex::ms_decl))
|
||||
{
|
||||
bgfx::TransientVertexBuffer tvb;
|
||||
bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosColorVertex::ms_decl);
|
||||
uint32_t trans = _abgr & 0xffffff;
|
||||
|
||||
PosColorVertex* vertex = (PosColorVertex*)tvb.data;
|
||||
for (uint32_t ii = 0, jj = _numCoords - 1; ii < _numCoords; jj = ii++)
|
||||
{
|
||||
vertex->m_x = _coords[ii * 2 + 0];
|
||||
vertex->m_y = _coords[ii * 2 + 1];
|
||||
vertex->m_abgr = _abgr;
|
||||
++vertex;
|
||||
|
||||
vertex->m_x = _coords[jj * 2 + 0];
|
||||
vertex->m_y = _coords[jj * 2 + 1];
|
||||
vertex->m_abgr = _abgr;
|
||||
++vertex;
|
||||
|
||||
vertex->m_x = tempCoords[jj * 2 + 0];
|
||||
vertex->m_y = tempCoords[jj * 2 + 1];
|
||||
vertex->m_abgr = trans;
|
||||
++vertex;
|
||||
|
||||
vertex->m_x = tempCoords[jj * 2 + 0];
|
||||
vertex->m_y = tempCoords[jj * 2 + 1];
|
||||
vertex->m_abgr = trans;
|
||||
++vertex;
|
||||
|
||||
vertex->m_x = tempCoords[ii * 2 + 0];
|
||||
vertex->m_y = tempCoords[ii * 2 + 1];
|
||||
vertex->m_abgr = trans;
|
||||
++vertex;
|
||||
|
||||
vertex->m_x = _coords[ii * 2 + 0];
|
||||
vertex->m_y = _coords[ii * 2 + 1];
|
||||
vertex->m_abgr = _abgr;
|
||||
++vertex;
|
||||
}
|
||||
|
||||
for (uint32_t ii = 2; ii < _numCoords; ++ii)
|
||||
{
|
||||
vertex->m_x = _coords[0];
|
||||
vertex->m_y = _coords[1];
|
||||
vertex->m_abgr = _abgr;
|
||||
++vertex;
|
||||
|
||||
vertex->m_x = _coords[(ii - 1) * 2 + 0];
|
||||
vertex->m_y = _coords[(ii - 1) * 2 + 1];
|
||||
vertex->m_abgr = _abgr;
|
||||
++vertex;
|
||||
|
||||
vertex->m_x = _coords[ii * 2 + 0];
|
||||
vertex->m_y = _coords[ii * 2 + 1];
|
||||
vertex->m_abgr = _abgr;
|
||||
++vertex;
|
||||
}
|
||||
|
||||
bgfx::setVertexBuffer(&tvb);
|
||||
}
|
||||
}
|
||||
|
||||
void drawLine(float _x0, float _y0, float _x1, float _y1, float _r, uint32_t _abgr, float _fth = 1.0f)
|
||||
{
|
||||
float dx = _x1 - _x0;
|
||||
float dy = _y1 - _y0;
|
||||
float d = sqrtf(dx * dx + dy * dy);
|
||||
if (d > 0.0001f)
|
||||
{
|
||||
d = 1.0f / d;
|
||||
dx *= d;
|
||||
dy *= d;
|
||||
}
|
||||
|
||||
float nx = dy;
|
||||
float ny = -dx;
|
||||
float verts[4 * 2];
|
||||
_r -= _fth;
|
||||
_r *= 0.5f;
|
||||
if (_r < 0.01f)
|
||||
{
|
||||
_r = 0.01f;
|
||||
}
|
||||
|
||||
dx *= _r;
|
||||
dy *= _r;
|
||||
nx *= _r;
|
||||
ny *= _r;
|
||||
|
||||
verts[0] = _x0 - dx - nx;
|
||||
verts[1] = _y0 - dy - ny;
|
||||
|
||||
verts[2] = _x0 - dx + nx;
|
||||
verts[3] = _y0 - dy + ny;
|
||||
|
||||
verts[4] = _x1 + dx + nx;
|
||||
verts[5] = _y1 + dy + ny;
|
||||
|
||||
verts[6] = _x1 + dx - nx;
|
||||
verts[7] = _y1 + dy - ny;
|
||||
|
||||
drawPolygon(verts, 4, _fth, _abgr);
|
||||
}
|
||||
|
||||
void initVertexDecls()
|
||||
{
|
||||
PosColorTexCoord0Vertex::init();
|
||||
PosColorVertex::init();
|
||||
}
|
||||
|
||||
static inline
|
||||
uint32_t u32Color(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255)
|
||||
{
|
||||
return 0
|
||||
| (uint32_t(_r) << 0)
|
||||
| (uint32_t(_g) << 8)
|
||||
| (uint32_t(_b) << 16)
|
||||
| (uint32_t(_a) << 24)
|
||||
;
|
||||
}
|
||||
|
||||
int renderer_bgfx::draw(int update)
|
||||
{
|
||||
//if (has_flags(FI_CHANGED) || (window().width() != m_last_width) || (window().height() != m_last_height))
|
||||
// do something
|
||||
//clear_flags(FI_CHANGED);
|
||||
initVertexDecls();
|
||||
|
||||
// Set view 0 default viewport.
|
||||
int width, height;
|
||||
#ifdef OSD_WINDOWS
|
||||
RECT client;
|
||||
GetClientRect(window().m_hwnd, &client);
|
||||
width = rect_width(&client);
|
||||
height = rect_height(&client);
|
||||
#else
|
||||
width = m_blit_dim.width();
|
||||
height = m_blit_dim.height();
|
||||
#endif
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
bgfx::reset(width, height, BGFX_RESET_VSYNC);
|
||||
// Setup view transform.
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxIdentity(view);
|
||||
|
||||
float left = 0.0f;
|
||||
float top = 0.0f;
|
||||
float right = width;
|
||||
float bottom = height;
|
||||
float proj[16];
|
||||
bx::mtxOrtho(proj, left, right, bottom, top, 0.0f, 100.0f);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
}
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
|
||||
, 0x000000ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
// Set view 0 default viewport.
|
||||
#ifdef OSD_WINDOWS
|
||||
RECT client;
|
||||
GetClientRect(window().m_hwnd, &client);
|
||||
bgfx::setViewRect(0, 0, 0, rect_width(&client), rect_height(&client));
|
||||
#else
|
||||
bgfx::setViewRect(0, 0, 0, m_blit_dim.width(), m_blit_dim.height());
|
||||
#endif
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::touch(0);
|
||||
|
||||
window().m_primlist->acquire_lock();
|
||||
|
||||
// Draw quad.
|
||||
// now draw
|
||||
for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next())
|
||||
{
|
||||
uint64_t flags = BGFX_STATE_RGB_WRITE;
|
||||
switch (prim->flags & PRIMFLAG_BLENDMODE_MASK)
|
||||
{
|
||||
case PRIMFLAG_BLENDMODE(BLENDMODE_NONE):
|
||||
break;
|
||||
case PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA):
|
||||
flags |= BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA);
|
||||
break;
|
||||
case PRIMFLAG_BLENDMODE(BLENDMODE_RGB_MULTIPLY):
|
||||
flags |= BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_DST_COLOR, BGFX_STATE_BLEND_ZERO);
|
||||
break;
|
||||
case PRIMFLAG_BLENDMODE(BLENDMODE_ADD):
|
||||
flags |= BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_ONE);
|
||||
}
|
||||
|
||||
switch (prim->type)
|
||||
{
|
||||
/**
|
||||
@ -255,72 +655,98 @@ int renderer_bgfx::draw(int update)
|
||||
* since entering and leaving one is most expensive..
|
||||
*/
|
||||
case render_primitive::LINE:
|
||||
// check if it's really a point
|
||||
/*
|
||||
if (((prim->bounds.x1 - prim->bounds.x0) == 0) && ((prim->bounds.y1 - prim->bounds.y0) == 0))
|
||||
{
|
||||
curPrimitive=GL_POINTS;
|
||||
} else {
|
||||
curPrimitive=GL_LINES;
|
||||
}
|
||||
|
||||
if(pendingPrimitive!=GL_NO_PRIMITIVE && pendingPrimitive!=curPrimitive)
|
||||
{
|
||||
glEnd();
|
||||
pendingPrimitive=GL_NO_PRIMITIVE;
|
||||
}
|
||||
|
||||
if ( pendingPrimitive==GL_NO_PRIMITIVE )
|
||||
{
|
||||
set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags));
|
||||
}
|
||||
|
||||
glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a);
|
||||
|
||||
if(pendingPrimitive!=curPrimitive)
|
||||
{
|
||||
glBegin(curPrimitive);
|
||||
pendingPrimitive=curPrimitive;
|
||||
}
|
||||
|
||||
// check if it's really a point
|
||||
if (curPrimitive==GL_POINTS)
|
||||
{
|
||||
glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs);
|
||||
}
|
||||
else
|
||||
{
|
||||
glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs);
|
||||
glVertex2f(prim->bounds.x1+hofs, prim->bounds.y1+vofs);
|
||||
}*/
|
||||
|
||||
drawLine(prim->bounds.x0, prim->bounds.y0, prim->bounds.x1, prim->bounds.y1,
|
||||
1.0f,
|
||||
u32Color(prim->color.r * 255, prim->color.g * 255, prim->color.b * 255, prim->color.a * 255),
|
||||
1.0f);
|
||||
bgfx::setState(flags);
|
||||
bgfx::submit(0, m_progLine);
|
||||
break;
|
||||
|
||||
case render_primitive::QUAD:
|
||||
/*
|
||||
if(pendingPrimitive!=GL_NO_PRIMITIVE)
|
||||
{
|
||||
glEnd();
|
||||
pendingPrimitive=GL_NO_PRIMITIVE;
|
||||
}
|
||||
if (prim->texture.base == nullptr) {
|
||||
render_quad_texuv uv;
|
||||
uv.tl.u = uv.tl.v = uv.tr.u = uv.tr.v = 0;
|
||||
uv.bl.u = uv.bl.v = uv.br.u = uv.br.v = 0;
|
||||
screenQuad(prim->bounds.x0, prim->bounds.y0,prim->bounds.x1, prim->bounds.y1,
|
||||
u32Color(prim->color.r * 255, prim->color.g * 255, prim->color.b * 255, prim->color.a * 255),uv);
|
||||
bgfx::setState(flags);
|
||||
bgfx::submit(0, m_progQuad);
|
||||
} else {
|
||||
screenQuad(prim->bounds.x0, prim->bounds.y0, prim->bounds.x1, prim->bounds.y1,
|
||||
0xFFFFFFFF,prim->texcoords);
|
||||
bgfx::TextureHandle m_texture;
|
||||
// render based on the texture coordinates
|
||||
switch (prim->flags & PRIMFLAG_TEXFORMAT_MASK)
|
||||
{
|
||||
case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTEA16):
|
||||
case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16):
|
||||
{
|
||||
auto mem = bgfx::alloc(prim->texture.width*prim->texture.height * 4);
|
||||
|
||||
int y, x;
|
||||
|
||||
glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a);
|
||||
for (y = 0; y < prim->texture.height; y++)
|
||||
{
|
||||
unsigned char *pARGB32 = (unsigned char *)prim->texture.base + y*prim->texture.rowpixels*2;
|
||||
unsigned char *pRGBA8 = (unsigned char *)mem->data + y*prim->texture.width * 4;
|
||||
for (x = 0; x < prim->texture.width*2; x+=2)
|
||||
{
|
||||
pRGBA8[x*2 + 0] = prim->texture.palette[pARGB32[x + 0] + pARGB32[x + 1] * 256].r();
|
||||
pRGBA8[x*2 + 1] = prim->texture.palette[pARGB32[x + 0] + pARGB32[x + 1] * 256].g();
|
||||
pRGBA8[x*2 + 2] = prim->texture.palette[pARGB32[x + 0] + pARGB32[x + 1] * 256].b();
|
||||
pRGBA8[x*2 + 3] = prim->texture.palette[pARGB32[x + 0] + pARGB32[x + 1] * 256].a();
|
||||
}
|
||||
}
|
||||
m_texture = bgfx::createTexture2D((uint16_t)prim->texture.width
|
||||
, (uint16_t)prim->texture.height
|
||||
, 1
|
||||
, bgfx::TextureFormat::RGBA8
|
||||
, 0
|
||||
, mem
|
||||
);
|
||||
}
|
||||
break;
|
||||
case PRIMFLAG_TEXFORMAT(TEXFORMAT_YUY16):
|
||||
break;
|
||||
case PRIMFLAG_TEXFORMAT(TEXFORMAT_RGB32):
|
||||
case PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32):
|
||||
{
|
||||
|
||||
auto mem = bgfx::alloc(prim->texture.width*prim->texture.height * 4);
|
||||
int y, x;
|
||||
|
||||
set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags));
|
||||
for (y = 0; y < prim->texture.height; y++)
|
||||
{
|
||||
unsigned char *pARGB32 = (unsigned char *)prim->texture.base + y*prim->texture.rowpixels*4;
|
||||
unsigned char *pRGBA8 = (unsigned char *)mem->data + y*prim->texture.width *4;
|
||||
for (x = 0; x < prim->texture.width *4; x+=4 )
|
||||
{
|
||||
pRGBA8[x] = pARGB32[x+2];
|
||||
pRGBA8[x+1] = pARGB32[x+1];
|
||||
pRGBA8[x+2] = pARGB32[x+0];
|
||||
pRGBA8[x + 3] = pARGB32[x + 3];
|
||||
}
|
||||
}
|
||||
m_texture = bgfx::createTexture2D((uint16_t)prim->texture.width
|
||||
, (uint16_t)prim->texture.height
|
||||
, 1
|
||||
, bgfx::TextureFormat::RGBA8
|
||||
, 0
|
||||
, mem
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
texture = texture_update(window, prim, 0);
|
||||
|
||||
|
||||
sdl->texVerticex[0]=prim->bounds.x0 + hofs;
|
||||
sdl->texVerticex[1]=prim->bounds.y0 + vofs;
|
||||
sdl->texVerticex[2]=prim->bounds.x1 + hofs;
|
||||
sdl->texVerticex[3]=prim->bounds.y0 + vofs;
|
||||
sdl->texVerticex[4]=prim->bounds.x1 + hofs;
|
||||
sdl->texVerticex[5]=prim->bounds.y1 + vofs;
|
||||
sdl->texVerticex[6]=prim->bounds.x0 + hofs;
|
||||
sdl->texVerticex[7]=prim->bounds.y1 + vofs;
|
||||
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
bgfx::setTexture(0, m_s_texColor, m_texture);
|
||||
bgfx::setState(flags);
|
||||
bgfx::submit(0, m_progQuadTexture);
|
||||
bgfx::destroyTexture(m_texture);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user