src/mess/includes/psion.h
| r15966 | r15967 | |
| 9 | 9 | #ifndef _PSION_H_ |
| 10 | 10 | #define _PSION_H_ |
| 11 | 11 | |
| 12 | #include "cpu/m6800/m6800.h" |
| 13 | #include "machine/psion_pack.h" |
| 14 | #include "video/hd44780.h" |
| 15 | #include "sound/beep.h" |
| 16 | |
| 17 | #define MCFG_PSION_CUSTOM_LCDC_ADD( _tag , _config) \ |
| 18 | MCFG_DEVICE_ADD( _tag, PSION_CUSTOM_LCDC, 0 ) \ |
| 19 | MCFG_DEVICE_CONFIG(_config) |
| 20 | |
| 21 | // ======================> psion_custom_lcdc |
| 22 | |
| 23 | class psion_custom_lcdc : public hd44780_device |
| 24 | { |
| 25 | |
| 26 | public: |
| 27 | // construction/destruction |
| 28 | psion_custom_lcdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 29 | |
| 30 | // hd44780_device overrides |
| 31 | virtual DECLARE_WRITE8_MEMBER(control_write); |
| 32 | virtual UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 33 | }; |
| 34 | |
| 35 | |
| 36 | // ======================> psion_state |
| 37 | |
| 12 | 38 | class psion_state : public driver_device |
| 13 | 39 | { |
| 14 | 40 | public: |
| r15966 | r15967 | |
| 60 | 86 | DECLARE_READ8_MEMBER( io_r ); |
| 61 | 87 | }; |
| 62 | 88 | |
| 89 | // device type definition |
| 90 | extern const device_type PSION_CUSTOM_LCDC; |
| 91 | |
| 63 | 92 | #endif // _PSION_H_ |
src/mess/video/hd44780.c
| r15966 | r15967 | |
| 37 | 37 | else |
| 38 | 38 | { |
| 39 | 39 | height = width = 0; |
| 40 | | custom_layout = NULL; |
| 41 | 40 | } |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | | //------------------------------------------------- |
| 45 | | // device_validity_check - perform validity checks |
| 46 | | // on this device |
| 47 | | //------------------------------------------------- |
| 48 | 43 | |
| 49 | | void hd44780_device::device_validity_check(validity_checker &valid) const |
| 50 | | { |
| 51 | | // display with more than 2 lines requires a layout |
| 52 | | if ((custom_layout == NULL && height > 2) || height == 0 || width == 0) |
| 53 | | mame_printf_error("Configured with invalid parameter\n"); |
| 54 | | } |
| 55 | | |
| 56 | 44 | //************************************************************************** |
| 57 | 45 | // live device |
| 58 | 46 | //************************************************************************** |
| r15966 | r15967 | |
| 66 | 54 | { |
| 67 | 55 | } |
| 68 | 56 | |
| 57 | hd44780_device::hd44780_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) : |
| 58 | device_t(mconfig, type, name, tag, owner, clock) |
| 59 | { |
| 60 | } |
| 69 | 61 | |
| 70 | 62 | //------------------------------------------------- |
| 71 | 63 | // device_start - device-specific startup |
| r15966 | r15967 | |
| 170 | 162 | UINT8 line_size = (m_num_line) ? 40 : 80; |
| 171 | 163 | INT8 char_pos = line_base + i; |
| 172 | 164 | |
| 173 | | // if specified uses the custom layout |
| 174 | | if (custom_layout != NULL) |
| 175 | | char_pos = custom_layout[l*width + i]; |
| 176 | | else |
| 177 | | { |
| 178 | | char_pos += m_disp_shift; |
| 165 | char_pos += m_disp_shift; |
| 179 | 166 | |
| 180 | | while (char_pos < 0 || (char_pos - line_base) >= line_size) |
| 181 | | { |
| 182 | | if (char_pos < 0) |
| 183 | | char_pos += line_size; |
| 184 | | else if (char_pos - line_base >= line_size) |
| 185 | | char_pos -= line_size; |
| 186 | | } |
| 167 | while (char_pos < 0 || (char_pos - line_base) >= line_size) |
| 168 | { |
| 169 | if (char_pos < 0) |
| 170 | char_pos += line_size; |
| 171 | else if (char_pos - line_base >= line_size) |
| 172 | char_pos -= line_size; |
| 187 | 173 | } |
| 174 | |
| 188 | 175 | for (int y=0; y<8; y++) |
| 189 | 176 | for (int x=0; x<5; x++) |
| 190 | 177 | if (m_ddram[char_pos] <= 0x10) |
| r15966 | r15967 | |
| 224 | 211 | } |
| 225 | 212 | |
| 226 | 213 | return 0; |
| 227 | | |
| 228 | 214 | } |
| 229 | 215 | |
| 230 | 216 | WRITE8_MEMBER(hd44780_device::control_write) |
| r15966 | r15967 | |
| 233 | 219 | { |
| 234 | 220 | m_ac_mode = 0; |
| 235 | 221 | m_ac = data & 0x7f; |
| 236 | | if (data != 0x81) // not in datasheet spec |
| 237 | | m_cursor_pos = m_ac; |
| 222 | m_cursor_pos = m_ac; |
| 238 | 223 | set_busy_flag(37); |
| 239 | 224 | } |
| 240 | 225 | else if (BIT(data, 6)) // Set CGRAM Address |
src/mess/video/hd44780.h
| r15966 | r15967 | |
| 17 | 17 | //************************************************************************** |
| 18 | 18 | // TYPE DEFINITIONS |
| 19 | 19 | //************************************************************************** |
| 20 | |
| 21 | #define HD44780_INTERFACE(name) \ |
| 22 | const hd44780_interface (name) = |
| 20 | 23 | |
| 21 | 24 | // ======================> hd44780_interface |
| 22 | 25 | |
| r15966 | r15967 | |
| 24 | 27 | { |
| 25 | 28 | UINT8 height; // number of lines |
| 26 | 29 | UINT8 width; // chars for line |
| 27 | | const UINT8 *custom_layout; // custom display layout (NULL for default) |
| 28 | 30 | }; |
| 29 | 31 | |
| 30 | 32 | // ======================> hd44780_device |
| r15966 | r15967 | |
| 36 | 38 | public: |
| 37 | 39 | // construction/destruction |
| 38 | 40 | hd44780_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 41 | hd44780_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); |
| 39 | 42 | |
| 40 | 43 | // device interface |
| 41 | | DECLARE_WRITE8_MEMBER(control_write); |
| 42 | | DECLARE_READ8_MEMBER(control_read); |
| 43 | | DECLARE_WRITE8_MEMBER(data_write); |
| 44 | | DECLARE_READ8_MEMBER(data_read); |
| 44 | virtual DECLARE_WRITE8_MEMBER(control_write); |
| 45 | virtual DECLARE_READ8_MEMBER(control_read); |
| 46 | virtual DECLARE_WRITE8_MEMBER(data_write); |
| 47 | virtual DECLARE_READ8_MEMBER(data_read); |
| 45 | 48 | |
| 46 | | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 49 | virtual UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 47 | 50 | |
| 48 | 51 | protected: |
| 49 | 52 | // device-level overrides |
| r15966 | r15967 | |
| 51 | 54 | virtual void device_reset(); |
| 52 | 55 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 53 | 56 | virtual void device_config_complete(); |
| 54 | | virtual void device_validity_check(validity_checker &valid) const; |
| 55 | 57 | |
| 56 | | private: |
| 58 | protected: |
| 57 | 59 | // internal helper |
| 58 | 60 | void set_busy_flag(UINT16 usec); |
| 59 | 61 | void update_ac(void); |
src/mess/video/psion.c
| r0 | r15967 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Psion Organiser II LZ series custom LCD controller |
| 4 | |
| 5 | ***************************************************************************/ |
| 6 | |
| 7 | #include "emu.h" |
| 8 | #include "includes/psion.h" |
| 9 | |
| 10 | // devices |
| 11 | const device_type PSION_CUSTOM_LCDC = &device_creator<psion_custom_lcdc>; |
| 12 | |
| 13 | |
| 14 | //************************************************************************** |
| 15 | // live device |
| 16 | //************************************************************************** |
| 17 | |
| 18 | //------------------------------------------------- |
| 19 | // psion_custom_lcdc - constructor |
| 20 | //------------------------------------------------- |
| 21 | |
| 22 | psion_custom_lcdc::psion_custom_lcdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 23 | hd44780_device(mconfig, PSION_CUSTOM_LCDC, "Psion Custom LCD Controller", tag, owner, clock) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | |
| 28 | //************************************************************************** |
| 29 | // device interface |
| 30 | //************************************************************************** |
| 31 | |
| 32 | UINT32 psion_custom_lcdc::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 33 | { |
| 34 | assert(height*9 <= bitmap.height() && width*6 <= bitmap.width()); |
| 35 | |
| 36 | bitmap.fill(0, cliprect); |
| 37 | |
| 38 | if (m_display_on) |
| 39 | for (int l=0; l<height; l++) |
| 40 | for (int i=0; i<width; i++) |
| 41 | { |
| 42 | static const UINT8 psion_display_layout[] = |
| 43 | { |
| 44 | 0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
| 45 | 0x40, 0x41, 0x42, 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, |
| 46 | 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, |
| 47 | 0x44, 0x45, 0x46, 0x47, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67 |
| 48 | }; |
| 49 | |
| 50 | INT8 char_pos = psion_display_layout[l*width + i]; |
| 51 | |
| 52 | for (int y=0; y<8; y++) |
| 53 | for (int x=0; x<5; x++) |
| 54 | if (m_ddram[char_pos] <= 0x10) |
| 55 | { |
| 56 | //draw CGRAM characters |
| 57 | bitmap.pix16(l*9 + y, i*6 + x) = BIT(m_cgram[(m_ddram[char_pos]&0x07)*8+y], 4-x); |
| 58 | } |
| 59 | else |
| 60 | { |
| 61 | //draw CGROM characters |
| 62 | if (region()->bytes() <= 0x800) |
| 63 | { |
| 64 | bitmap.pix16(l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x); |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | if(m_ddram[char_pos] < 0xe0) |
| 69 | bitmap.pix16(l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x); |
| 70 | else |
| 71 | bitmap.pix16(l*9 + y, i*6 + x) = BIT(region()->u8(0x700+((m_ddram[char_pos]-0xe0)*11)+y), 4-x); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // if is the correct position draw cursor and blink |
| 76 | if (char_pos == m_cursor_pos) |
| 77 | { |
| 78 | //draw the cursor |
| 79 | if (m_cursor_on) |
| 80 | for (int x=0; x<5; x++) |
| 81 | bitmap.pix16(l*9 + 7, i * 6 + x) = 1; |
| 82 | |
| 83 | if (!m_blink && m_blink_on) |
| 84 | for (int y=0; y<7; y++) |
| 85 | for (int x=0; x<5; x++) |
| 86 | bitmap.pix16(l*9 + y, i * 6 + x) = 1; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | WRITE8_MEMBER(psion_custom_lcdc::control_write) |
| 94 | { |
| 95 | if (BIT(data, 7)) // Set DDRAM Address |
| 96 | { |
| 97 | m_ac_mode = 0; |
| 98 | m_ac = data & 0x7f; |
| 99 | if (data != 0x81) |
| 100 | m_cursor_pos = m_ac; |
| 101 | set_busy_flag(37); |
| 102 | } |
| 103 | else |
| 104 | hd44780_device::control_write(space, offset, data); |
| 105 | } |
| 106 | |
| 107 | |
src/mess/drivers/psion.c
| r15966 | r15967 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | #include "emu.h" |
| 22 | | #include "cpu/m6800/m6800.h" |
| 23 | | #include "sound/beep.h" |
| 24 | | #include "machine/psion_pack.h" |
| 25 | | #include "video/hd44780.h" |
| 26 | 22 | #include "includes/psion.h" |
| 27 | 23 | #include "rendlay.h" |
| 28 | 24 | |
| r15966 | r15967 | |
| 464 | 460 | GFXDECODE_ENTRY( "hd44780", 0x0000, psion_charlayout, 0, 1 ) |
| 465 | 461 | GFXDECODE_END |
| 466 | 462 | |
| 467 | | static const hd44780_interface psion_2line_display = |
| 463 | static HD44780_INTERFACE( psion_2line_display ) |
| 468 | 464 | { |
| 469 | 465 | 2, // number of lines |
| 470 | | 16, // chars for line |
| 471 | | NULL // custom display layout |
| 466 | 16 // chars for line |
| 472 | 467 | }; |
| 473 | 468 | |
| 474 | 469 | /* basic configuration for 2 lines display */ |
| r15966 | r15967 | |
| 507 | 502 | MCFG_SOFTWARE_LIST_ADD("pack_list", "psion") |
| 508 | 503 | MACHINE_CONFIG_END |
| 509 | 504 | |
| 510 | | static const UINT8 psion_4line_layout[] = |
| 511 | | { |
| 512 | | 0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
| 513 | | 0x40, 0x41, 0x42, 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, |
| 514 | | 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, |
| 515 | | 0x44, 0x45, 0x46, 0x47, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67 |
| 516 | | }; |
| 517 | 505 | |
| 518 | | static const hd44780_interface psion_4line_display = |
| 506 | static HD44780_INTERFACE( psion_4line_display ) |
| 519 | 507 | { |
| 520 | 508 | 4, // number of lines |
| 521 | | 20, // chars for line |
| 522 | | psion_4line_layout // custom display layout |
| 509 | 20 // chars for line |
| 523 | 510 | }; |
| 524 | 511 | |
| 525 | 512 | /* basic configuration for 4 lines display */ |
| r15966 | r15967 | |
| 539 | 526 | MCFG_PALETTE_INIT(psion) |
| 540 | 527 | MCFG_GFXDECODE(psion) |
| 541 | 528 | |
| 542 | | MCFG_HD44780_ADD("hd44780", psion_4line_display) |
| 529 | MCFG_PSION_CUSTOM_LCDC_ADD("hd44780", psion_4line_display) |
| 543 | 530 | |
| 544 | 531 | /* sound hardware */ |
| 545 | 532 | MCFG_SPEAKER_STANDARD_MONO( "mono" ) |