Previous 15994 Revisions Next

r11224 Monday 18th April, 2011 at 06:49:50 UTC by Robbbert
[H19] modernised
[src/mess/drivers]h19.c

src/mess/drivers/h19.c
r11223r11224
2828        - When the internal keyboard works, get rid of the generic_terminal.
2929
3030****************************************************************************/
31#define ADDRESS_MAP_MODERN
3132
3233#include "emu.h"
3334#include "cpu/z80/z80.h"
r11223r11224
3637#include "machine/ins8250.h"
3738#include "machine/terminal.h"
3839
40#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
41#define VIDEO_START_MEMBER(name) void name::video_start()
42#define SCREEN_UPDATE_MEMBER(name) bool name::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
3943
4044#define H19_CLOCK (XTAL_12_288MHz / 6)
4145#define H19_BEEP_FRQ (H19_CLOCK / 1024)
r11223r11224
4549{
4650public:
4751   h19_state(running_machine &machine, const driver_device_config_base &config)
48      : driver_device(machine, config) { }
52      : driver_device(machine, config),
53   m_maincpu(*this, "maincpu"),
54   m_crtc(*this, "crtc"),
55   m_ace(*this, "ins8250"),
56   m_term(*this, TERMINAL_TAG),
57   m_beep(*this, "beep")
58   { }
4959
50   UINT8 *m_videoram;
51   UINT8 *m_charrom;
52   device_t *m_beeper;
60   required_device<cpu_device> m_maincpu;
61   required_device<device_t> m_crtc;
62   required_device<device_t> m_ace;
63   required_device<device_t> m_term;
64   required_device<device_t> m_beep;
65   DECLARE_READ8_MEMBER(h19_80_r);
66   DECLARE_READ8_MEMBER(h19_a0_r);
67   DECLARE_WRITE8_MEMBER(h19_c0_w);
68   WRITE8_MEMBER(h19_kbd_put);
69   UINT8 *m_p_videoram;
70   UINT8 *m_p_chargen;
5371   UINT8 m_term_data;
72   virtual void machine_reset();
73   virtual void video_start();
74   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
5475};
5576
5677
5778static TIMER_CALLBACK( h19_beepoff )
5879{
5980   h19_state *state = machine.driver_data<h19_state>();
60   beep_set_state(state->m_beeper, 0);
81   beep_set_state(state->m_beep, 0);
6182}
6283
63static READ8_HANDLER( h19_80_r )
84READ8_MEMBER( h19_state::h19_80_r )
6485{
6586// keyboard data
66   h19_state *state = space->machine().driver_data<h19_state>();
67   UINT8 ret = state->m_term_data;
68   state->m_term_data = 0;
87   UINT8 ret = m_term_data;
88   m_term_data = 0;
6989   return ret;
7090}
7191
72static READ8_HANDLER( h19_a0_r )
92READ8_MEMBER( h19_state::h19_a0_r )
7393{
7494// keyboard status
75   cputag_set_input_line(space->machine(), "maincpu", 0, CLEAR_LINE);
95   cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE);
7696   return 0x7f; // says that a key is ready and no modifier keys are pressed
7797}
7898
79static WRITE8_HANDLER( h19_c0_w )
99WRITE8_MEMBER( h19_state::h19_c0_w )
80100{
81   h19_state *state = space->machine().driver_data<h19_state>();
82101/* Beeper control - a 96L02 contains 2 oneshots, one for bell and one for keyclick.
83102- lengths need verifying
84103    offset 00-1F = keyclick
85104    offset 20-3F = terminal bell */
86105
87106   UINT8 length = (offset & 0x20) ? 200 : 4;
88   beep_set_state(state->m_beeper, 1);
89   space->machine().scheduler().timer_set(attotime::from_msec(length), FUNC(h19_beepoff));
107   beep_set_state(m_beep, 1);
108   machine().scheduler().timer_set(attotime::from_msec(length), FUNC(h19_beepoff));
90109}
91110
92static ADDRESS_MAP_START(h19_mem, AS_PROGRAM, 8)
111static ADDRESS_MAP_START(h19_mem, AS_PROGRAM, 8, h19_state)
93112   ADDRESS_MAP_UNMAP_HIGH
94113   AM_RANGE(0x0000, 0x1fff) AM_ROM
95114   AM_RANGE(0x2000, 0xf7ff) AM_RAM
96   AM_RANGE(0xf800, 0xffff) AM_RAM AM_BASE_MEMBER(h19_state, m_videoram)
115   AM_RANGE(0xf800, 0xffff) AM_RAM AM_BASE(m_p_videoram)
97116ADDRESS_MAP_END
98117
99static ADDRESS_MAP_START( h19_io , AS_IO, 8)
118static ADDRESS_MAP_START( h19_io, AS_IO, 8, h19_state)
100119   ADDRESS_MAP_UNMAP_HIGH
101120   ADDRESS_MAP_GLOBAL_MASK(0xff)
102121   AM_RANGE(0x00, 0x1F) AM_READ_PORT("S401")
103122   AM_RANGE(0x20, 0x3F) AM_READ_PORT("S402")
104   AM_RANGE(0x40, 0x47) AM_MIRROR(0x18) AM_DEVREADWRITE("ins8250", ins8250_r, ins8250_w )
105   AM_RANGE(0x60, 0x60) AM_DEVWRITE("crtc", mc6845_address_w)
106   AM_RANGE(0x61, 0x61) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
123   AM_RANGE(0x40, 0x47) AM_MIRROR(0x18) AM_DEVREADWRITE_LEGACY("ins8250", ins8250_r, ins8250_w )
124   AM_RANGE(0x60, 0x60) AM_DEVWRITE_LEGACY("crtc", mc6845_address_w)
125   AM_RANGE(0x61, 0x61) AM_DEVREADWRITE_LEGACY("crtc", mc6845_register_r, mc6845_register_w)
107126   AM_RANGE(0x80, 0x9F) AM_READ(h19_80_r)
108127   AM_RANGE(0xA0, 0xBF) AM_READ(h19_a0_r)
109128   AM_RANGE(0xC0, 0xFF) AM_WRITE(h19_c0_w)
r11223r11224
276295INPUT_PORTS_END
277296
278297
279static MACHINE_RESET(h19)
298MACHINE_RESET_MEMBER(h19_state)
280299{
281   h19_state *state = machine.driver_data<h19_state>();
282   state->m_beeper = machine.device("beep");
283   beep_set_frequency(state->m_beeper, H19_BEEP_FRQ);
300   beep_set_frequency(m_beep, H19_BEEP_FRQ);
284301}
285302
286static VIDEO_START( h19 )
303VIDEO_START_MEMBER( h19_state )
287304{
288   h19_state *state = machine.driver_data<h19_state>();
289   state->m_charrom = machine.region("chargen")->base();
305   m_p_chargen = m_machine.region("chargen")->base();
290306}
291307
292static SCREEN_UPDATE( h19 )
308SCREEN_UPDATE_MEMBER( h19_state )
293309{
294   device_t *mc6845 = screen->machine().device("crtc");
295   mc6845_update(mc6845, bitmap, cliprect);
310   mc6845_update(m_crtc, &bitmap, &cliprect);
296311   return 0;
297312}
298313
r11223r11224
308323      UINT8 inv=0;
309324      if (x == cursor_x) inv=0xff;
310325      mem = (ma + x) & 0x7ff;
311      chr = state->m_videoram[mem];
326      chr = state->m_p_videoram[mem];
312327
313328      if (chr & 0x80)
314329      {
r11223r11224
317332      }
318333
319334      /* get pattern of pixels for that character scanline */
320      gfx = state->m_charrom[(chr<<4) | ra] ^ inv;
335      gfx = state->m_p_chargen[(chr<<4) | ra] ^ inv;
321336
322337      /* Display a scanline of a character (8 pixels) */
323      *p++ = ( gfx & 0x80 ) ? 1 : 0;
324      *p++ = ( gfx & 0x40 ) ? 1 : 0;
325      *p++ = ( gfx & 0x20 ) ? 1 : 0;
326      *p++ = ( gfx & 0x10 ) ? 1 : 0;
327      *p++ = ( gfx & 0x08 ) ? 1 : 0;
328      *p++ = ( gfx & 0x04 ) ? 1 : 0;
329      *p++ = ( gfx & 0x02 ) ? 1 : 0;
330      *p++ = ( gfx & 0x01 ) ? 1 : 0;
338      *p++ = BIT(gfx, 7);
339      *p++ = BIT(gfx, 6);
340      *p++ = BIT(gfx, 5);
341      *p++ = BIT(gfx, 4);
342      *p++ = BIT(gfx, 3);
343      *p++ = BIT(gfx, 2);
344      *p++ = BIT(gfx, 1);
345      *p++ = BIT(gfx, 0);
331346   }
332347}
333348
r11223r11224
377392   GFXDECODE_ENTRY( "chargen", 0x0000, h19_charlayout, 0, 1 )
378393GFXDECODE_END
379394
380static WRITE8_DEVICE_HANDLER( h19_kbd_put )
395WRITE8_MEMBER( h19_state::h19_kbd_put )
381396{
382   h19_state *state = device->machine().driver_data<h19_state>();
383   state->m_term_data = data;
384   cputag_set_input_line(device->machine(), "maincpu", 0, HOLD_LINE);
397   m_term_data = data;
398   cputag_set_input_line(machine(), "maincpu", 0, HOLD_LINE);
385399}
386400
387401static GENERIC_TERMINAL_INTERFACE( h19_terminal_intf )
388402{
389   DEVCB_HANDLER(h19_kbd_put)
403   DEVCB_DRIVER_MEMBER(h19_state, h19_kbd_put)
390404};
391405
392406static MACHINE_CONFIG_START( h19, h19_state )
r11223r11224
396410   MCFG_CPU_IO_MAP(h19_io)
397411   //MCFG_DEVICE_PERIODIC_INT(irq0_line_hold, 50) // for testing, causes a keyboard scan
398412
399   MCFG_MACHINE_RESET(h19)
400
401413   /* video hardware */
402414   MCFG_SCREEN_ADD("screen", RASTER)
403415   MCFG_SCREEN_REFRESH_RATE(60)
r11223r11224
405417   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
406418   MCFG_SCREEN_SIZE(640, 200)
407419   MCFG_SCREEN_VISIBLE_AREA(0, 640 - 1, 0, 200 - 1)
408   MCFG_SCREEN_UPDATE( h19 )
409
410420   MCFG_GFXDECODE(h19)
411421   MCFG_PALETTE_LENGTH(2)
412   MCFG_PALETTE_INIT(black_and_white)
422   MCFG_PALETTE_INIT(monochrome_green)
413423
414424   MCFG_MC6845_ADD("crtc", MC6845, XTAL_12_288MHz / 8, h19_crtc6845_interface) // clk taken from schematics
415425   MCFG_INS8250_ADD( "ins8250", h19_ace_interface )
416426   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, h19_terminal_intf) // keyboard only
417427
418   MCFG_VIDEO_START( h19 )
419
420428   /* sound hardware */
421429   MCFG_SPEAKER_STANDARD_MONO("mono")
422430   MCFG_SOUND_ADD("beep", BEEP, 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team