summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_p.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_p.h')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_p.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_p.h b/3rdparty/bgfx/examples/common/entry/entry_p.h
index ab45cfef5b5..fa4792a5cb5 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_p.h
+++ b/3rdparty/bgfx/examples/common/entry/entry_p.h
@@ -67,7 +67,7 @@ namespace entry
static void static_deallocate(void* _ptr, size_t /*_bytes*/);
};
- int main(int _argc, char** _argv);
+ int main(int _argc, const char* const* _argv);
char keyToAscii(Key::Enum _key, uint8_t _modifiers);
@@ -177,6 +177,11 @@ namespace entry
class EventQueue
{
public:
+ EventQueue()
+ : m_queue(getAllocator() )
+ {
+ }
+
~EventQueue()
{
for (const Event* ev = poll(); NULL != ev; ev = poll() )
@@ -187,7 +192,7 @@ namespace entry
void postAxisEvent(WindowHandle _handle, GamepadHandle _gamepad, GamepadAxis::Enum _axis, int32_t _value)
{
- AxisEvent* ev = new AxisEvent(_handle);
+ AxisEvent* ev = BX_NEW(getAllocator(), AxisEvent)(_handle);
ev->m_gamepad = _gamepad;
ev->m_axis = _axis;
ev->m_value = _value;
@@ -196,7 +201,7 @@ namespace entry
void postCharEvent(WindowHandle _handle, uint8_t _len, const uint8_t _char[4])
{
- CharEvent* ev = new CharEvent(_handle);
+ CharEvent* ev = BX_NEW(getAllocator(), CharEvent)(_handle);
ev->m_len = _len;
bx::memCopy(ev->m_char, _char, 4);
m_queue.push(ev);
@@ -204,13 +209,13 @@ namespace entry
void postExitEvent()
{
- Event* ev = new Event(Event::Exit);
+ Event* ev = BX_NEW(getAllocator(), Event)(Event::Exit);
m_queue.push(ev);
}
void postGamepadEvent(WindowHandle _handle, GamepadHandle _gamepad, bool _connected)
{
- GamepadEvent* ev = new GamepadEvent(_handle);
+ GamepadEvent* ev = BX_NEW(getAllocator(), GamepadEvent)(_handle);
ev->m_gamepad = _gamepad;
ev->m_connected = _connected;
m_queue.push(ev);
@@ -218,7 +223,7 @@ namespace entry
void postKeyEvent(WindowHandle _handle, Key::Enum _key, uint8_t _modifiers, bool _down)
{
- KeyEvent* ev = new KeyEvent(_handle);
+ KeyEvent* ev = BX_NEW(getAllocator(), KeyEvent)(_handle);
ev->m_key = _key;
ev->m_modifiers = _modifiers;
ev->m_down = _down;
@@ -227,7 +232,7 @@ namespace entry
void postMouseEvent(WindowHandle _handle, int32_t _mx, int32_t _my, int32_t _mz)
{
- MouseEvent* ev = new MouseEvent(_handle);
+ MouseEvent* ev = BX_NEW(getAllocator(), MouseEvent)(_handle);
ev->m_mx = _mx;
ev->m_my = _my;
ev->m_mz = _mz;
@@ -239,7 +244,7 @@ namespace entry
void postMouseEvent(WindowHandle _handle, int32_t _mx, int32_t _my, int32_t _mz, MouseButton::Enum _button, bool _down)
{
- MouseEvent* ev = new MouseEvent(_handle);
+ MouseEvent* ev = BX_NEW(getAllocator(), MouseEvent)(_handle);
ev->m_mx = _mx;
ev->m_my = _my;
ev->m_mz = _mz;
@@ -251,7 +256,7 @@ namespace entry
void postSizeEvent(WindowHandle _handle, uint32_t _width, uint32_t _height)
{
- SizeEvent* ev = new SizeEvent(_handle);
+ SizeEvent* ev = BX_NEW(getAllocator(), SizeEvent)(_handle);
ev->m_width = _width;
ev->m_height = _height;
m_queue.push(ev);
@@ -259,14 +264,14 @@ namespace entry
void postWindowEvent(WindowHandle _handle, void* _nwh = NULL)
{
- WindowEvent* ev = new WindowEvent(_handle);
+ WindowEvent* ev = BX_NEW(getAllocator(), WindowEvent)(_handle);
ev->m_nwh = _nwh;
m_queue.push(ev);
}
void postSuspendEvent(WindowHandle _handle, Suspend::Enum _state)
{
- SuspendEvent* ev = new SuspendEvent(_handle);
+ SuspendEvent* ev = BX_NEW(getAllocator(), SuspendEvent)(_handle);
ev->m_state = _state;
m_queue.push(ev);
}
@@ -293,7 +298,7 @@ namespace entry
void release(const Event* _event) const
{
- delete _event;
+ BX_DELETE(getAllocator(), const_cast<Event*>(_event) );
}
private:
.highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/***************************************************************************

  SH7604 SCI Controller

   Lies at 0xfffffe00-0xfffffe0f

  TODO:
  - diserial;
  - CPU callbacks for RX and TX;

***************************************************************************/

#include "emu.h"
#include "sh7604_sci.h"



//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

// device type definition
DEFINE_DEVICE_TYPE(SH7604_SCI, sh7604_sci_device, "sh7604sci", "SH7604 SCI Controller")


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

uint8_t sh7604_sci_device::serial_mode_r()
{
	return m_smr;
}

void sh7604_sci_device::serial_mode_w(uint8_t data)
{
	m_smr = data;

	logerror("%s: serial mode set:\n",tag());
	logerror("\tCommunication Mode: %s mode\n",data & 0x80 ? "clocked synchronous" : "asynchronous");
	logerror("\tCharacter Length: %s mode\n",data & 0x40 ? "7-bit" : "8-bit");
	logerror("\tParity Enable: %s\n",data & 0x20 ? "yes" : "no");
	logerror("\tParity Mode: %s\n",data & 0x10 ? "Odd" : "Even");
	logerror("\tStop bits: %s\n",data & 0x08 ? "2" : "1");
	logerror("\tMultiprocessor mode: %s\n",data & 0x04 ? "yes" : "no");
	logerror("\tClock select: clock/%d\n",4 << ((data & 0x03)*2));
}

uint8_t sh7604_sci_device::serial_control_r()
{
	return m_scr;
}

void sh7604_sci_device::serial_control_w(uint8_t data)
{
	m_scr = data;

	if(data & 0x30)
		throw emu_fatalerror("%s: enabled serial control %02x\n", tag(),data);
}

uint8_t sh7604_sci_device::serial_status_r()
{
	return m_ssr;
}

void sh7604_sci_device::serial_ack_w(uint8_t data)
{
	// TODO: verify this
	m_ssr = (m_ssr & 0x06) | (m_ssr & data & 0xf9);
}

uint8_t sh7604_sci_device::bitrate_r()
{
	return m_brr;
}

void sh7604_sci_device::bitrate_w(uint8_t data)
{
	m_brr = data;
}

uint8_t sh7604_sci_device::transmit_data_r()
{
	// ...
	return 0;
}

void sh7604_sci_device::transmit_data_w(uint8_t data)
{
	// ...
}

uint8_t sh7604_sci_device::receive_data_r()
{
	// ...
	return 0;
}

void sh7604_sci_device::sci_regs(address_map &map)
{
	map(0x00, 0x00).rw(FUNC(sh7604_sci_device::serial_mode_r), FUNC(sh7604_sci_device::serial_mode_w));
	map(0x01, 0x01).rw(FUNC(sh7604_sci_device::bitrate_r), FUNC(sh7604_sci_device::bitrate_w));
	map(0x02, 0x02).rw(FUNC(sh7604_sci_device::serial_control_r), FUNC(sh7604_sci_device::serial_control_w));
	map(0x03, 0x03).rw(FUNC(sh7604_sci_device::transmit_data_r), FUNC(sh7604_sci_device::transmit_data_w));
	map(0x04, 0x04).rw(FUNC(sh7604_sci_device::serial_status_r), FUNC(sh7604_sci_device::serial_ack_w));
	map(0x05, 0x05).r(FUNC(sh7604_sci_device::receive_data_r));
}

//-------------------------------------------------
//  sh7604_sci_device - constructor
//-------------------------------------------------

sh7604_sci_device::sh7604_sci_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, SH7604_SCI, tag, owner, clock)

{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void sh7604_sci_device::device_start()
{
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void sh7604_sci_device::device_reset()
{
	m_smr = 0;
	m_scr = 0;
	m_ssr = STATUS_TDRE|STATUS_TEND; //0x84;
	m_brr = 0xff;
}


//**************************************************************************
//  READ/WRITE HANDLERS
//**************************************************************************

uint8_t sh7604_sci_device::read(address_space &space, offs_t offset)
{
	return space.read_byte(offset);
}

void sh7604_sci_device::write(address_space &space, offs_t offset, uint8_t data)
{
	space.write_byte(offset,data);
}