summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/snes_ctrl/bcbattle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/snes_ctrl/bcbattle.cpp')
-rw-r--r--src/devices/bus/snes_ctrl/bcbattle.cpp65
1 files changed, 29 insertions, 36 deletions
diff --git a/src/devices/bus/snes_ctrl/bcbattle.cpp b/src/devices/bus/snes_ctrl/bcbattle.cpp
index 4c0b17ef6ce..c5d78bc04b3 100644
--- a/src/devices/bus/snes_ctrl/bcbattle.cpp
+++ b/src/devices/bus/snes_ctrl/bcbattle.cpp
@@ -26,47 +26,40 @@ void snes_bcbattle_device::device_add_mconfig(machine_config &config)
}
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-// This part is the hacky replacement for the real Barcode unit [shared with NES implementation]:
+// This part is a hacky replacement for the real Barcode unit [shared with NES implementation]:
// code periodically checks whether a new code has been scanned and it moves it to the
// m_current_barcode array
-void snes_bcbattle_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(snes_bcbattle_device::scan_tick)
{
- if (id == TIMER_BATTLER)
+ int old = m_new_code;
+ m_new_code = m_reader->get_pending_code();
+ // has something new been scanned?
+ if (old < m_new_code)
{
- int old = m_new_code;
- m_new_code = m_reader->get_pending_code();
- // has something new been scanned?
- if (old < m_new_code)
+ if (m_reader->get_byte_length() == 13)
{
- if (m_reader->get_byte_length() == 13)
- {
- for (int i = 0; i < 13; i++)
- m_current_barcode[i] = m_reader->read_code() + '0';
- }
- else if (m_reader->get_byte_length() == 8)
- {
- for (int i = 0; i < 5; i++)
- m_current_barcode[i] = 0x20;
- for (int i = 5; i < 13; i++)
- m_current_barcode[i] = m_reader->read_code() + '0';
- }
- // read one more, to reset the internal byte counter
- m_reader->read_code();
-
- // the string "SUNSOFT" is accepted as well by Barcode World
- m_current_barcode[13] = 'E';
- m_current_barcode[14] = 'P';
- m_current_barcode[15] = 'O';
- m_current_barcode[16] = 'C';
- m_current_barcode[17] = 'H';
- m_current_barcode[18] = 0x0d;
- m_current_barcode[19] = 0x0a;
- m_pending_code = 1;
+ for (int i = 0; i < 13; i++)
+ m_current_barcode[i] = m_reader->read_code() + '0';
+ }
+ else if (m_reader->get_byte_length() == 8)
+ {
+ for (int i = 0; i < 5; i++)
+ m_current_barcode[i] = 0x20;
+ for (int i = 5; i < 13; i++)
+ m_current_barcode[i] = m_reader->read_code() + '0';
}
+ // read one more, to reset the internal byte counter
+ m_reader->read_code();
+
+ // the string "SUNSOFT" is accepted as well by Barcode World
+ m_current_barcode[13] = 'E';
+ m_current_barcode[14] = 'P';
+ m_current_barcode[15] = 'O';
+ m_current_barcode[16] = 'C';
+ m_current_barcode[17] = 'H';
+ m_current_barcode[18] = 0x0d;
+ m_current_barcode[19] = 0x0a;
+ m_pending_code = 1;
}
}
@@ -98,7 +91,7 @@ void snes_bcbattle_device::device_start()
// lacking emulation of the standalone Barcode Battler, we refresh periodically the input from the reader
// proper emulation would have the standalone unit acknowledging that a new barcode has been scanned
// and sending the proper serial bits, instead of our read_current_bit() function!
- battler_timer = timer_alloc(TIMER_BATTLER);
+ battler_timer = timer_alloc(FUNC(snes_bcbattle_device::scan_tick), this);
battler_timer->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(1000));
save_item(NAME(m_current_barcode));