summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/bcreader.h
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2014-02-12 14:54:11 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2014-02-12 14:54:11 +0000
commite2cf4f8b3486461e8dcf29acdb9195b6a3ee2dd8 (patch)
tree503d9010bc60025c0a226fbd62a7f58e01c0ad4d /src/emu/machine/bcreader.h
parent9ec218038ba130d60cf3dcd6e159182468ed93fe (diff)
Added generic barcode reader emulation: the code accepts sequences of digits in
UPC-A, EAN-13 and EAN-8 format, stores them in both byte format and in pixel format; it is up to the driver to implement the correct transfer protocol. [Fabio Priuli] Added UI menu to enter barcodes via keyboard. It only gets activated if the running machine has a barcode device. [Fabio Priuli] out of whatsnew: The latter change was coordinated with Nathan, so it shall not create problems with his UI reorganization ;)
Diffstat (limited to 'src/emu/machine/bcreader.h')
-rw-r--r--src/emu/machine/bcreader.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/emu/machine/bcreader.h b/src/emu/machine/bcreader.h
new file mode 100644
index 00000000000..26e55a3d05c
--- /dev/null
+++ b/src/emu/machine/bcreader.h
@@ -0,0 +1,56 @@
+/*********************************************************************
+
+ bcreader.h
+
+ Generic barcode reader emulation.
+
+*********************************************************************/
+
+#ifndef __BCREADER_H_
+#define __BCREADER_H_
+
+#define MCFG_BARCODE_READER_ADD( _tag ) \
+ MCFG_DEVICE_ADD( _tag, BARCODE_READER, 0 )
+
+#define MCFG_BARCODE_READER_REMOVE( _tag ) \
+ MCFG_DEVICE_REMOVE( _tag )
+
+
+// ======================> barcode_reader_device
+
+class barcode_reader_device : public device_t
+{
+public:
+ // construction/destruction
+ barcode_reader_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ void write_code(const char *barcode, int len);
+ UINT8 read_code();
+ int read_pixel();
+
+ // TODO: add checksum validation!
+ bool is_valid(int len) { return (len != 12 && len != 13 && len != 8) ? FALSE : TRUE; }
+ void decode(int len);
+
+protected:
+ // device-level overrides
+ virtual void device_start();
+
+ UINT8 m_byte_data[13];
+ UINT8 m_pixel_data[100];
+ int m_byte_length;
+ int m_pixel_length;
+ int m_byte_count;
+ int m_pixel_count;
+ int m_new_code;
+};
+
+
+// device type definition
+extern const device_type BARCODE_READER;
+
+// device type iterator
+typedef device_type_iterator<&device_creator<barcode_reader_device>, barcode_reader_device> barcode_reader_device_iterator;
+
+
+#endif