Previous 15994 Revisions Next

r9370 Wednesday 13th October, 2010 at 11:17:54 UTC by Curt Coder
[HD61830] Refactored into a C++ device.
[POFO] Refactored driver to define ADDRESS_MAP_MODERN.
[docs]messnew.txt
[src/mess/drivers]kyocera.c micronic.c portfoli.c
[src/mess/includes]kyocera.h micronic.h portfoli.h
[src/mess/video]hd61830.c hd61830.h kyocera.c

src/mess/video/kyocera.c
r9369r9370
4444   tandy200_state *state = machine->driver_data<tandy200_state>();
4545
4646   /* find devices */
47   state->hd61830 = machine->device(HD61830_TAG);
47   state->hd61830 = machine->device<hd61830_device>(HD61830_TAG);
4848}
4949
5050static VIDEO_UPDATE( tandy200 )
5151{
5252   tandy200_state *state = screen->machine->driver_data<tandy200_state>();
5353
54   hd61830_update(state->hd61830, bitmap, cliprect);
54   state->hd61830->update_screen(bitmap, cliprect);
5555
5656   return 0;
5757}
r9369r9370
5959static HD61830_INTERFACE( lcdc_intf )
6060{
6161   SCREEN_TAG,
62   NULL
62   DEVCB_NULL
6363};
6464
6565MACHINE_CONFIG_FRAGMENT( kc85_video )
src/mess/video/hd61830.c
r9369r9370
1010#include "emu.h"
1111#include "hd61830.h"
1212
13/***************************************************************************
14    PARAMETERS
15***************************************************************************/
1613
14
15//**************************************************************************
16//   MACROS / CONSTANTS
17//**************************************************************************
18
1719#define LOG 0
1820
1921enum
2022{
21   HD61830_INSTRUCTION_MODE_CONTROL = 0,
22   HD61830_INSTRUCTION_CHARACTER_PITCH,
23   HD61830_INSTRUCTION_NUMBER_OF_CHARACTERS,
24   HD61830_INSTRUCTION_NUMBER_OF_TIME_DIVISIONS,
25   HD61830_INSTRUCTION_CURSOR_POSITION,
26   HD61830_INSTRUCTION_DISPLAY_START_LOW = 8,
27   HD61830_INSTRUCTION_DISPLAY_START_HIGH,
28   HD61830_INSTRUCTION_CURSOR_ADDRESS_LOW,
29   HD61830_INSTRUCTION_CURSOR_ADDRESS_HIGH,
30   HD61830_INSTRUCTION_DISPLAY_DATA_WRITE,
31   HD61830_INSTRUCTION_DISPLAY_DATA_READ,
32   HD61830_INSTRUCTION_CLEAR_BIT,
33   HD61830_INSTRUCTION_SET_BIT
23   INSTRUCTION_MODE_CONTROL = 0,
24   INSTRUCTION_CHARACTER_PITCH,
25   INSTRUCTION_NUMBER_OF_CHARACTERS,
26   INSTRUCTION_NUMBER_OF_TIME_DIVISIONS,
27   INSTRUCTION_CURSOR_POSITION,
28   INSTRUCTION_DISPLAY_START_LOW = 8,
29   INSTRUCTION_DISPLAY_START_HIGH,
30   INSTRUCTION_CURSOR_ADDRESS_LOW,
31   INSTRUCTION_CURSOR_ADDRESS_HIGH,
32   INSTRUCTION_DISPLAY_DATA_WRITE,
33   INSTRUCTION_DISPLAY_DATA_READ,
34   INSTRUCTION_CLEAR_BIT,
35   INSTRUCTION_SET_BIT
3436};
3537
36static const int HD61830_CYCLES[] = {
38static const int CYCLES[] =
39{
3740   4, 4, 4, 4, 4, -1, -1, -1, 4, 4, 4, 4, 6, 6, 36, 36
3841};
3942
40#define HD61830_MODE_EXTERNAL_CG   0x01
41#define HD61830_MODE_GRAPHIC      0x02
42#define HD61830_MODE_CURSOR         0x04
43#define HD61830_MODE_BLINK         0x08
44#define HD61830_MODE_MASTER         0x10
45#define HD61830_MODE_DISPLAY_ON      0x20
43const int MODE_EXTERNAL_CG      = 0x01;
44const int MODE_GRAPHIC         = 0x02;
45const int MODE_CURSOR         = 0x04;
46const int MODE_BLINK         = 0x08;
47const int MODE_MASTER         = 0x10;
48const int MODE_DISPLAY_ON      = 0x20;
4649
47/***************************************************************************
48    TYPE DEFINITIONS
49***************************************************************************/
5050
51typedef struct _hd61830_t hd61830_t;
52struct _hd61830_t
51
52//**************************************************************************
53//  GLOBAL VARIABLES
54//**************************************************************************
55
56// devices
57const device_type HD61830 = hd61830_device_config::static_alloc_device_config;
58
59
60// default address map
61static ADDRESS_MAP_START( hd61830, 0, 8 )
62   AM_RANGE(0x0000, 0xffff) AM_RAM
63ADDRESS_MAP_END
64
65
66// internal character generator ROM
67ROM_START( hd61830 )
68   ROM_REGION( 0x5c0, "hd61830", ROMREGION_LOADBYNAME ) // internal 7360-bit chargen ROM
69   ROM_LOAD( "hd61830.bin", 0x000, 0x5c0, BAD_DUMP CRC(06a934da) SHA1(bf3f074db5dc92e6f530cb18d6c013563099a87d) ) // typed in from manual
70ROM_END
71
72
73
74//**************************************************************************
75//  DEVICE CONFIGURATION
76//**************************************************************************
77
78//-------------------------------------------------
79//  hd61830_device_config - constructor
80//-------------------------------------------------
81
82hd61830_device_config::hd61830_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
83   : device_config(mconfig, static_alloc_device_config, "Hitachi HD61830", tag, owner, clock),
84     device_config_memory_interface(mconfig, *this),
85     m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, NULL, *ADDRESS_MAP_NAME(hd61830))
5386{
54   address_space *ram;         /* video RAM memory space */
55   hd61830_rd_read   rd_r;
87}
5688
57   int bf;                  /* busy flag */
5889
59   UINT8 ir;               /* instruction register */
60   UINT8 mcr;               /* mode control register */
61   UINT8 dor;               /* data output register */
90//-------------------------------------------------
91//  static_alloc_device_config - allocate a new
92//  configuration object
93//-------------------------------------------------
6294
63   UINT16 dsa;               /* display start address */
64   UINT16 cac;               /* cursor address counter */
95device_config *hd61830_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
96{
97   return global_alloc(hd61830_device_config(mconfig, tag, owner, clock));
98}
6599
66   int vp;                  /* vertical character pitch */
67   int hp;                  /* horizontal character pitch */
68   int hn;                  /* horizontal number of characters */
69   int nx;                  /* number of time divisions */
70   int cp;                  /* cursor position */
71100
72    int blink;               /* blinking */
73   int cursor;
101//-------------------------------------------------
102//  alloc_device - allocate a new device object
103//-------------------------------------------------
74104
75   /* devices */
76   screen_device *screen;
105device_t *hd61830_device_config::alloc_device(running_machine &machine) const
106{
107   return auto_alloc(&machine, hd61830_device(machine, *this));
108}
77109
78   /* timers */
79   emu_timer *busy_timer;
80};
81110
82/***************************************************************************
83    INLINE FUNCTIONS
84***************************************************************************/
111//-------------------------------------------------
112//  memory_space_config - return a description of
113//  any address spaces owned by this device
114//-------------------------------------------------
85115
86INLINE hd61830_t *get_safe_token(running_device *device)
116const address_space_config *hd61830_device_config::memory_space_config(int spacenum) const
87117{
88   assert(device != NULL);
89   assert(device->type() == HD61830);
90   return (hd61830_t *)downcast<legacy_device_base *>(device)->token();
118   return (spacenum == 0) ? &m_space_config : NULL;
91119}
92120
93INLINE const hd61830_interface *get_interface(running_device *device)
121
122//-------------------------------------------------
123//  rom_region - device-specific ROM region
124//-------------------------------------------------
125
126const rom_entry *hd61830_device_config::rom_region() const
94127{
95   assert(device != NULL);
96   assert(device->type() == HD61830);
97   return (const hd61830_interface *) device->baseconfig().static_config();
128   return ROM_NAME(hd61830);
98129}
99130
100/***************************************************************************
101    IMPLEMENTATION
102***************************************************************************/
103131
104/*-------------------------------------------------
105    TIMER_CALLBACK( busy_tick )
106-------------------------------------------------*/
132//-------------------------------------------------
133//  device_config_complete - perform any
134//  operations now that the configuration is
135//  complete
136//-------------------------------------------------
107137
108static TIMER_CALLBACK( busy_tick )
138void hd61830_device_config::device_config_complete()
109139{
110   running_device *device = (running_device *)ptr;
111   hd61830_t *hd61830 = get_safe_token(device);
140   // inherit a copy of the static data
141   const hd61830_interface *intf = reinterpret_cast<const hd61830_interface *>(static_config());
142   if (intf != NULL)
143      *static_cast<hd61830_interface *>(this) = *intf;
112144
113   /* clear busy flag */
114   hd61830->bf = 0;
145   // or initialize to defaults if none provided
146   else
147   {
148      memset(&m_in_rd_func, 0, sizeof(m_in_rd_func));
149   }
115150}
116151
117/*-------------------------------------------------
118    set_busy_flag - set busy flag and arm timer
119                    to clear it later
120-------------------------------------------------*/
121152
122static void set_busy_flag(hd61830_t *hd61830, int period)
153
154//**************************************************************************
155//  INLINE HELPERS
156//**************************************************************************
157
158//-------------------------------------------------
159//  readbyte - read a byte at the given address
160//-------------------------------------------------
161
162inline UINT8 hd61830_device::readbyte(offs_t address)
123163{
124   /* set busy flag */
125   hd61830->bf = 1;
164   return space()->read_byte(address);
165}
126166
127   /* adjust busy timer */
128   timer_adjust_oneshot(hd61830->busy_timer, ATTOTIME_IN_USEC(period), 0);
167
168//-------------------------------------------------
169//  writebyte - write a byte at the given address
170//-------------------------------------------------
171
172inline void hd61830_device::writebyte(offs_t address, UINT8 data)
173{
174   space()->write_byte(address, data);
129175}
130176
131/*-------------------------------------------------
132    hd61830_status_r - status read
133-------------------------------------------------*/
134177
135READ8_DEVICE_HANDLER( hd61830_status_r )
178
179//**************************************************************************
180//  LIVE DEVICE
181//**************************************************************************
182
183//-------------------------------------------------
184//  hd61830_device - constructor
185//-------------------------------------------------
186
187hd61830_device::hd61830_device(running_machine &_machine, const hd61830_device_config &config)
188    : device_t(_machine, config),
189     device_memory_interface(_machine, config, *this),
190      m_config(config)
136191{
137   hd61830_t *hd61830 = get_safe_token(device);
192   m_bf = false;
193}
138194
139   if (LOG) logerror("HD61380 '%s' Status Read: %s\n", device->tag(), hd61830->bf ? "busy" : "ready");
140195
141   return hd61830->bf << 7;
196//-------------------------------------------------
197//  device_start - device-specific startup
198//-------------------------------------------------
199
200void hd61830_device::device_start()
201{
202   // allocate timers
203   m_busy_timer = device_timer_alloc(*this);
204
205   // resolve callbacks
206    devcb_resolve_read8(&m_in_rd_func, &m_config.m_in_rd_func, this);
207
208   // register for state saving
209   state_save_register_device_item(this, 0, m_bf);
210   state_save_register_device_item(this, 0, m_ir);
211   state_save_register_device_item(this, 0, m_mcr);
212    state_save_register_device_item(this, 0, m_dor);
213   state_save_register_device_item(this, 0, m_cac);
214   state_save_register_device_item(this, 0, m_dsa);
215   state_save_register_device_item(this, 0, m_vp);
216   state_save_register_device_item(this, 0, m_hp);
217   state_save_register_device_item(this, 0, m_hn);
218   state_save_register_device_item(this, 0, m_nx);
219   state_save_register_device_item(this, 0, m_cp);
220   state_save_register_device_item(this, 0, m_blink);
221   state_save_register_device_item(this, 0, m_cursor);
142222}
143223
144/*-------------------------------------------------
145    hd61830_control_w - control write
146-------------------------------------------------*/
147224
148WRITE8_DEVICE_HANDLER( hd61830_control_w )
225//-------------------------------------------------
226//  device_reset - device-specific reset
227//-------------------------------------------------
228
229void hd61830_device::device_reset()
149230{
150   hd61830_t *hd61830 = get_safe_token(device);
231   // display off, slave mode
232   m_mcr &= ~(MODE_MASTER | MODE_DISPLAY_ON);
151233
152   hd61830->ir = data;
234   // default horizontal pitch
235   m_hp = 6;
153236}
154237
238
239//-------------------------------------------------
240//  device_timer - handler timer events
241//-------------------------------------------------
242
243void hd61830_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
244{
245   // clear busy flag
246   m_bf = false;
247}
248
249
155250/*-------------------------------------------------
156    hd61830_data_r - data read
251    set_busy_flag - set busy flag and arm timer
252                    to clear it later
157253-------------------------------------------------*/
158254
159READ8_DEVICE_HANDLER( hd61830_data_r )
255void hd61830_device::set_busy_flag()
160256{
161   hd61830_t *hd61830 = get_safe_token(device);
162   UINT8 data = hd61830->dor;
257   // set busy flag
258   m_bf = true;
163259
164   if (LOG) logerror("HD61380 '%s' Display Data Read %02x\n", device->tag(), hd61830->dor);
260   // adjust busy timer
261   timer_adjust_oneshot(m_busy_timer, ATTOTIME_IN_USEC(CYCLES[m_ir]), 0);
262}
165263
166   hd61830->dor = hd61830->ram->read_byte(hd61830->cac);
167264
168   hd61830->cac++;
265//-------------------------------------------------
266//  status_r - status register read
267//-------------------------------------------------
169268
269READ8_MEMBER( hd61830_device::status_r )
270{
271   if (LOG) logerror("HD61830 '%s' Status Read: %s\n", tag(), m_bf ? "busy" : "ready");
272
273   return m_bf ? 0x80 : 0;
274}
275
276
277//-------------------------------------------------
278//  control_w - instruction register write
279//-------------------------------------------------
280
281WRITE8_MEMBER( hd61830_device::control_w )
282{
283   m_ir = data;
284}
285
286
287//-------------------------------------------------
288//  data_r - data register read
289//-------------------------------------------------
290
291READ8_MEMBER( hd61830_device::data_r )
292{
293   UINT8 data = m_dor;
294
295   if (LOG) logerror("HD61830 '%s' Display Data Read %02x\n", tag(), m_dor);
296
297   m_dor = readbyte(m_cac);
298
299   m_cac++;
300
170301   return data;
171302}
172303
173/*-------------------------------------------------
174    hd61830_data_w - data write
175-------------------------------------------------*/
176304
177WRITE8_DEVICE_HANDLER( hd61830_data_w )
305//-------------------------------------------------
306//  data_w - data register write
307//-------------------------------------------------
308
309WRITE8_MEMBER( hd61830_device::data_w )
178310{
179   hd61830_t *hd61830 = get_safe_token(device);
311   if (m_bf)
312   {
313      logerror("HD61830 '%s' Ignoring data write %02x due to business\n", tag(), data);
314      return;
315   }
180316
181   switch (hd61830->ir)
317   switch (m_ir)
182318   {
183   case HD61830_INSTRUCTION_MODE_CONTROL:
184      hd61830->mcr = data;
319   case INSTRUCTION_MODE_CONTROL:
320      m_mcr = data;
185321
186322      if (LOG)
187323      {
188         logerror("HD61380 '%s' %s CG\n", device->tag(), (data & HD61830_MODE_EXTERNAL_CG) ? "External" : "Internal");
189         logerror("HD61380 '%s' %s Display Mode\n", device->tag(), (data & HD61830_MODE_GRAPHIC) ? "Graphic" : "Character");
190         logerror("HD61380 '%s' %s Mode\n", device->tag(), (data & HD61830_MODE_MASTER) ? "Master" : "Slave");
191         logerror("HD61380 '%s' Cursor %s\n", device->tag(), (data & HD61830_MODE_CURSOR) ? "On" : "Off");
192         logerror("HD61380 '%s' Blink %s\n", device->tag(), (data & HD61830_MODE_BLINK) ? "On" : "Off");
193         logerror("HD61380 '%s' Display %s\n", device->tag(), (data & HD61830_MODE_DISPLAY_ON) ? "On" : "Off");
324         logerror("HD61830 '%s' %s CG\n", tag(), (data & MODE_EXTERNAL_CG) ? "External" : "Internal");
325         logerror("HD61830 '%s' %s Display Mode\n", tag(), (data & MODE_GRAPHIC) ? "Graphic" : "Character");
326         logerror("HD61830 '%s' %s Mode\n", tag(), (data & MODE_MASTER) ? "Master" : "Slave");
327         logerror("HD61830 '%s' Cursor %s\n", tag(), (data & MODE_CURSOR) ? "On" : "Off");
328         logerror("HD61830 '%s' Blink %s\n", tag(), (data & MODE_BLINK) ? "On" : "Off");
329         logerror("HD61830 '%s' Display %s\n", tag(), (data & MODE_DISPLAY_ON) ? "On" : "Off");
194330      }
195331      break;
196332
197   case HD61830_INSTRUCTION_CHARACTER_PITCH:
198      hd61830->hp = (data & 0x07) + 1;
199      hd61830->vp = (data >> 4) + 1;
333   case INSTRUCTION_CHARACTER_PITCH:
334      m_hp = (data & 0x07) + 1;
335      m_vp = (data >> 4) + 1;
200336
201      if (LOG) logerror("HD61380 '%s' Horizontal Character Pitch: %u\n", device->tag(), hd61830->hp);
202      if (LOG) logerror("HD61380 '%s' Vertical Character Pitch: %u\n", device->tag(), hd61830->vp);
337      if (LOG) logerror("HD61830 '%s' Horizontal Character Pitch: %u\n", tag(), m_hp);
338      if (LOG) logerror("HD61830 '%s' Vertical Character Pitch: %u\n", tag(), m_vp);
203339      break;
204340
205   case HD61830_INSTRUCTION_NUMBER_OF_CHARACTERS:
206      hd61830->hn = (data & 0x7f) + 1;
341   case INSTRUCTION_NUMBER_OF_CHARACTERS:
342      m_hn = (data & 0x7f) + 1;
207343
208      if (LOG) logerror("HD61380 '%s' Number of Characters: %u\n", device->tag(), hd61830->hn);
344      if (LOG) logerror("HD61830 '%s' Number of Characters: %u\n", tag(), m_hn);
209345      break;
210346
211   case HD61830_INSTRUCTION_NUMBER_OF_TIME_DIVISIONS:
212      hd61830->nx = (data & 0x7f) + 1;
347   case INSTRUCTION_NUMBER_OF_TIME_DIVISIONS:
348      m_nx = (data & 0x7f) + 1;
213349
214      if (LOG) logerror("HD61380 '%s' Number of Time Divisions: %u\n", device->tag(), hd61830->nx);
350      if (LOG) logerror("HD61830 '%s' Number of Time Divisions: %u\n", tag(), m_nx);
215351      break;
216352
217   case HD61830_INSTRUCTION_CURSOR_POSITION:
218      hd61830->cp = (data & 0x7f) + 1;
353   case INSTRUCTION_CURSOR_POSITION:
354      m_cp = (data & 0x7f) + 1;
219355
220      if (LOG) logerror("HD61380 '%s' Cursor Position: %u\n", device->tag(), hd61830->cp);
356      if (LOG) logerror("HD61830 '%s' Cursor Position: %u\n", tag(), m_cp);
221357      break;
222358
223   case HD61830_INSTRUCTION_DISPLAY_START_LOW:
224      hd61830->dsa = (hd61830->dsa & 0xff00) | data;
359   case INSTRUCTION_DISPLAY_START_LOW:
360      m_dsa = (m_dsa & 0xff00) | data;
225361
226      if (LOG) logerror("HD61380 '%s' Display Start Address Low %04x\n", device->tag(), hd61830->dsa);
362      if (LOG) logerror("HD61830 '%s' Display Start Address Low %04x\n", tag(), m_dsa);
227363      break;
228364
229   case HD61830_INSTRUCTION_DISPLAY_START_HIGH:
230      hd61830->dsa = (data << 8) | (hd61830->dsa & 0xff);
365   case INSTRUCTION_DISPLAY_START_HIGH:
366      m_dsa = (data << 8) | (m_dsa & 0xff);
231367
232      if (LOG) logerror("HD61380 '%s' Display Start Address High %04x\n", device->tag(), hd61830->dsa);
368      if (LOG) logerror("HD61830 '%s' Display Start Address High %04x\n", tag(), m_dsa);
233369      break;
234370
235   case HD61830_INSTRUCTION_CURSOR_ADDRESS_LOW:
236      if (BIT(hd61830->cac, 7) && !BIT(data, 7))
371   case INSTRUCTION_CURSOR_ADDRESS_LOW:
372      if (BIT(m_cac, 7) && !BIT(data, 7))
237373      {
238         hd61830->cac = (((hd61830->cac >> 8) + 1) << 8) | data;
374         m_cac = (((m_cac >> 8) + 1) << 8) | data;
239375      }
240376      else
241377      {
242         hd61830->cac = (hd61830->cac & 0xff00) | data;
378         m_cac = (m_cac & 0xff00) | data;
243379      }
244380
245      if (LOG) logerror("HD61380 '%s' Cursor Address Low %02x: %04x\n", device->tag(), data, hd61830->cac);
381      if (LOG) logerror("HD61830 '%s' Cursor Address Low %02x: %04x\n", tag(), data, m_cac);
246382      break;
247383
248   case HD61830_INSTRUCTION_CURSOR_ADDRESS_HIGH:
249      hd61830->cac = (data << 8) | (hd61830->cac & 0xff);
384   case INSTRUCTION_CURSOR_ADDRESS_HIGH:
385      m_cac = (data << 8) | (m_cac & 0xff);
250386
251      if (LOG) logerror("HD61380 '%s' Cursor Address High %02x: %04x\n", device->tag(), data, hd61830->cac);
387      if (LOG) logerror("HD61830 '%s' Cursor Address High %02x: %04x\n", tag(), data, m_cac);
252388      break;
253389
254   case HD61830_INSTRUCTION_DISPLAY_DATA_WRITE:
255      hd61830->ram->write_byte(hd61830->cac, data);
390   case INSTRUCTION_DISPLAY_DATA_WRITE:
391      writebyte(m_cac, data);
256392
257      if (LOG) logerror("HD61380 '%s' Display Data Write %02x -> %04x row %u col %u\n", device->tag(), data, hd61830->cac, hd61830->cac / 40, hd61830->cac % 40);
393      if (LOG) logerror("HD61830 '%s' Display Data Write %02x -> %04x row %u col %u\n", tag(), data, m_cac, m_cac / 40, m_cac % 40);
258394
259      hd61830->cac++;
395      m_cac++;
260396      break;
261397
262   case HD61830_INSTRUCTION_CLEAR_BIT:
398   case INSTRUCTION_CLEAR_BIT:
263399      {
264      int nb = data & 0x07;
265      UINT8 data_ = hd61830->ram->read_byte(hd61830->cac);
400      int bit = data & 0x07;
401      UINT8 md = readbyte(m_cac);
266402
267      data_ &= ~(2 << nb);
403      md &= ~(1 << bit);
268404
269      if (LOG) logerror("HD61380 '%s' Clear Bit %u at %04x\n", device->tag(), nb + 1, hd61830->cac);
405      if (LOG) logerror("HD61830 '%s' Clear Bit %u at %04x\n", tag(), bit + 1, m_cac);
270406
271      hd61830->ram->write_byte(hd61830->cac, data_);
407      writebyte(m_cac, md);
272408
273      hd61830->cac++;
409      m_cac++;
274410      }
275411      break;
276412
277   case HD61830_INSTRUCTION_SET_BIT:
413   case INSTRUCTION_SET_BIT:
278414      {
279      int nb = data & 0x07;
280      UINT8 data_ = hd61830->ram->read_byte(hd61830->cac);
415      int bit = data & 0x07;
416      UINT8 md = readbyte(m_cac);
281417
282      data_ |= 2 << nb;
418      md |= 1 << bit;
283419
284      if (LOG) logerror("HD61380 '%s' Set Bit %u at %04x\n", device->tag(), nb + 1, hd61830->cac);
420      if (LOG) logerror("HD61830 '%s' Set Bit %u at %04x\n", tag(), bit + 1, m_cac);
285421
286      hd61830->ram->write_byte(hd61830->cac, data_);
422      writebyte(m_cac, md);
287423
288      hd61830->cac++;
424      m_cac++;
289425      }
290426      break;
291427
292428   default:
293      logerror("HD61830 '%s' Illegal Instruction %02x!\n", device->tag(), hd61830->ir);
429      logerror("HD61830 '%s' Illegal Instruction %02x!\n", tag(), m_ir);
294430      return;
295431   }
296432
297   /* burn cycles */
298   set_busy_flag(hd61830, HD61830_CYCLES[hd61830->ir]);
433   // burn cycles
434   set_busy_flag();
299435}
300436
301/*-------------------------------------------------
302    draw_scanline - draw one scanline
303-------------------------------------------------*/
304437
305static void draw_scanline(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ra)
438//-------------------------------------------------
439//  draw_scanline - draw one graphics scanline
440//-------------------------------------------------
441
442void hd61830_device::draw_scanline(bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ra)
306443{
307   hd61830_t *hd61830 = get_safe_token(device);
308
309   for (int sx = 0; sx < hd61830->hn; sx++)
444   for (int sx = 0; sx < m_hn; sx++)
310445   {
311      UINT8 data = hd61830->ram->read_byte(ra++);
446      UINT8 data = readbyte(ra++);
312447
313      for (int x = 0; x < hd61830->hp; x++)
448      for (int x = 0; x < m_hp; x++)
314449      {
315         *BITMAP_ADDR16(bitmap, y, (sx * hd61830->hp) + x) = BIT(data, x);
450         *BITMAP_ADDR16(bitmap, y, (sx * m_hp) + x) = BIT(data, x);
316451      }
317452   }
318453}
319454
320/*-------------------------------------------------
321    update_graphics - draw graphics mode screen
322-------------------------------------------------*/
323455
324static void update_graphics(running_device *device, bitmap_t *bitmap, const rectangle *cliprect)
456//-------------------------------------------------
457//  update_graphics - draw graphics mode screen
458//-------------------------------------------------
459
460void hd61830_device::update_graphics(bitmap_t *bitmap, const rectangle *cliprect)
325461{
326   hd61830_t *hd61830 = get_safe_token(device);
327
328   for (int y = 0; y < hd61830->nx; y++)
462   for (int y = 0; y < m_nx; y++)
329463   {
330      UINT16 rac1 = hd61830->dsa + (y * hd61830->hn);
331      UINT16 rac2 = rac1 + (hd61830->nx * hd61830->hn);
464      UINT16 rac1 = m_dsa + (y * m_hn);
465      UINT16 rac2 = rac1 + (m_nx * m_hn);
332466
333467      /* draw upper half scanline */
334      draw_scanline(device, bitmap, cliprect, y, rac1);
468      draw_scanline(bitmap, cliprect, y, rac1);
335469
336470      /* draw lower half scanline */
337      draw_scanline(device, bitmap, cliprect, y + hd61830->nx, rac2);
471      draw_scanline(bitmap, cliprect, y + m_nx, rac2);
338472   }
339473}
340474
341/*-------------------------------------------------
342    draw_char - draw a char
343-------------------------------------------------*/
344475
345static void draw_char(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, UINT16 ma, int x, int y, UINT8 md)
476//-------------------------------------------------
477//  draw_char - draw a char
478//-------------------------------------------------
479
480void hd61830_device::draw_char(bitmap_t *bitmap, const rectangle *cliprect, UINT16 ma, int x, int y, UINT8 md)
346481{
347   hd61830_t *hd61830 = get_safe_token(device);
348
349   for (int cl = 0; cl < hd61830->vp; cl++)
482   for (int cl = 0; cl < m_vp; cl++)
350483   {
351      for (int cr = 0; cr < hd61830->hp; cr++)
484      for (int cr = 0; cr < m_hp; cr++)
352485      {
353         int sy = y * hd61830->vp + cl;
354         int sx = x * hd61830->hp + cr;
486         int sy = y * m_vp + cl;
487         int sx = x * m_hp + cr;
355488         UINT8 data = 0;
356489
357         if (hd61830->mcr & HD61830_MODE_EXTERNAL_CG)
490         if (m_mcr & MODE_EXTERNAL_CG)
358491         {
359            data = hd61830->rd_r(device, (cl << 12) | (ma & 0xfff), md);
492            data = devcb_call_read8(&m_in_rd_func, (cl << 12) | md);
360493         }
361494         else
362495         {
r9369r9370
378511               addr = 160*7 + (md - 0xe0) * 11 + cl;
379512            }
380513
381            data = device->subregion("hd61830")->u8(addr);
514            data = subregion("hd61830")->u8(addr);
382515         }
383516
384         int cursor = hd61830->mcr & HD61830_MODE_CURSOR;
385         int blink = hd61830->mcr & HD61830_MODE_BLINK;
517         int cursor = m_mcr & MODE_CURSOR;
518         int blink = m_mcr & MODE_BLINK;
386519
387520         // cursor off
388521         int pixel = BIT(data, cr);
389522
390         if (blink && (ma == hd61830->cac))
523         if (blink && (ma == m_cac))
391524         {
392525            // cursor off, character blink
393526            if (!cursor)
394               pixel = hd61830->cursor ? pixel : 0;
527               pixel = m_cursor ? pixel : 0;
395528
396529            // cursor blink
397            if (cursor && (cl == hd61830->cp))
398               pixel = hd61830->cursor;
530            if (cursor && (cl == m_cp))
531               pixel = m_cursor ? 1 : 0;
399532         }
400533         else
401534         {
402535            // cursor on
403            if (cursor && (cl == hd61830->cp))
404               pixel = hd61830->cursor;
536            if (cursor && (cl == m_cp))
537               pixel = m_cursor ? 1 : 0;
405538         }
406539
407540         *BITMAP_ADDR16(bitmap, sy, sx) = pixel;
r9369r9370
409542   }
410543}
411544
412/*-------------------------------------------------
413    update_text - draw text mode screen
414-------------------------------------------------*/
415545
416static void update_text(running_device *device, bitmap_t *bitmap, const rectangle *cliprect)
546//-------------------------------------------------
547//  update_text - draw text mode screen
548//-------------------------------------------------
549
550void hd61830_device::update_text(bitmap_t *bitmap, const rectangle *cliprect)
417551{
418   hd61830_t *hd61830 = get_safe_token(device);
419
420   for (int y = 0; y < (hd61830->nx / hd61830->vp); y++)
552   for (int y = 0; y < (m_nx / m_vp); y++)
421553   {
422      for (int x = 0; x < hd61830->hn; x++)
554      for (int x = 0; x < m_hn; x++)
423555      {
424         UINT16 ma = y * hd61830->hn + x;
425         UINT8 md = hd61830->ram->read_byte(ma);
556         UINT16 ma = y * m_hn + x;
557         UINT8 md = readbyte(ma);
426558
427         draw_char(device, bitmap, cliprect, ma, x, y, md);
559         draw_char(bitmap, cliprect, ma, x, y, md);
428560      }
429561   }
430562}
431563
432/*-------------------------------------------------
433    hd61830_update - update screen
434-------------------------------------------------*/
435564
436void hd61830_update(running_device *device, bitmap_t *bitmap, const rectangle *cliprect)
565//-------------------------------------------------
566//  update_screen - update screen
567//-------------------------------------------------
568
569void hd61830_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
437570{
438   hd61830_t *hd61830 = get_safe_token(device);
439
440   if (hd61830->mcr & HD61830_MODE_DISPLAY_ON)
571   if (m_mcr & MODE_DISPLAY_ON)
441572   {
442      if (hd61830->mcr & HD61830_MODE_GRAPHIC)
573      if (m_mcr & MODE_GRAPHIC)
443574      {
444         update_graphics(device, bitmap, cliprect);
575         update_graphics(bitmap, cliprect);
445576      }
446577      else
447578      {
448         update_text(device, bitmap, cliprect);
579         update_text(bitmap, cliprect);
449580      }
450581   }
451582   else
r9369r9370
453584      bitmap_fill(bitmap, cliprect, 0);
454585   }
455586
456   hd61830->blink++;
587   m_blink++;
457588
458   if (hd61830->blink == 0x20)
589   if (m_blink == 0x20)
459590   {
460      hd61830->blink = 0;
461      hd61830->cursor = !hd61830->cursor;
591      m_blink = 0;
592      m_cursor = !m_cursor;
462593   }
463594}
464
465/*-------------------------------------------------
466    hd61830_r - register read
467-------------------------------------------------*/
468
469READ8_DEVICE_HANDLER( hd61830_r )
470{
471   return (offset & 0x01) ? hd61830_status_r(device, offset) : hd61830_data_r(device, offset);
472}
473
474/*-------------------------------------------------
475    hd61830_w - register write
476-------------------------------------------------*/
477
478WRITE8_DEVICE_HANDLER( hd61830_w )
479{
480   (offset & 0x01) ? hd61830_control_w(device, offset, data) : hd61830_data_w(device, offset, data);
481}
482
483/*-------------------------------------------------
484    ROM( hd61830 )
485-------------------------------------------------*/
486
487ROM_START( hd61830 )
488   ROM_REGION( 0x5c0, "hd61830", ROMREGION_LOADBYNAME ) // internal 7360-bit chargen ROM
489   ROM_LOAD( "hd61830.bin", 0x000, 0x5c0, BAD_DUMP CRC(06a934da) SHA1(bf3f074db5dc92e6f530cb18d6c013563099a87d) ) // typed in from manual
490ROM_END
491
492/*-------------------------------------------------
493    ADDRESS_MAP( hd61830 )
494-------------------------------------------------*/
495
496static ADDRESS_MAP_START( hd61380_ram, 0, 8 )
497   AM_RANGE(0x0000, 0xffff) AM_RAM
498ADDRESS_MAP_END
499
500/*-------------------------------------------------
501    DEVICE_START( hd61830 )
502-------------------------------------------------*/
503
504static DEVICE_START( hd61830 )
505{
506   hd61830_t *hd61830 = get_safe_token(device);
507   const hd61830_interface *intf = get_interface(device);
508
509   hd61830->rd_r = intf->rd_r;
510
511   /* get the screen device */
512   hd61830->screen = device->machine->device<screen_device>(intf->screen_tag);
513   assert(hd61830->screen != NULL);
514
515   hd61830->ram = device_get_space(device, ADDRESS_SPACE_0);
516
517   /* create the busy timer */
518   hd61830->busy_timer = timer_alloc(device->machine, busy_tick, (void *)device);
519
520   /* register for state saving */
521   state_save_register_device_item(device, 0, hd61830->bf);
522   state_save_register_device_item(device, 0, hd61830->ir);
523   state_save_register_device_item(device, 0, hd61830->mcr);
524    state_save_register_device_item(device, 0, hd61830->dor);
525   state_save_register_device_item(device, 0, hd61830->cac);
526   state_save_register_device_item(device, 0, hd61830->dsa);
527   state_save_register_device_item(device, 0, hd61830->vp);
528   state_save_register_device_item(device, 0, hd61830->hp);
529   state_save_register_device_item(device, 0, hd61830->hn);
530   state_save_register_device_item(device, 0, hd61830->nx);
531   state_save_register_device_item(device, 0, hd61830->cp);
532   state_save_register_device_item(device, 0, hd61830->blink);
533   state_save_register_device_item(device, 0, hd61830->cursor);
534}
535
536/*-------------------------------------------------
537    DEVICE_RESET( hd61830 )
538-------------------------------------------------*/
539
540static DEVICE_RESET( hd61830 )
541{
542   hd61830_t *hd61830 = get_safe_token(device);
543
544   hd61830->mcr = hd61830->mcr & ~(HD61830_MODE_MASTER | HD61830_MODE_DISPLAY_ON);
545   hd61830->hp = 6;
546}
547
548/*-------------------------------------------------
549    DEVICE_GET_INFO( hd61830 )
550-------------------------------------------------*/
551
552DEVICE_GET_INFO( hd61830 )
553{
554   switch (state)
555   {
556      /* --- the following bits of info are returned as 64-bit signed integers --- */
557      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(hd61830_t);                  break;
558      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                              break;
559      case DEVINFO_INT_DATABUS_WIDTH_0:            info->i = 8;                              break;
560      case DEVINFO_INT_ADDRBUS_WIDTH_0:            info->i = 16;                              break;
561      case DEVINFO_INT_ADDRBUS_SHIFT_0:            info->i = 0;                              break;
562
563      /* --- the following bits of info are returned as pointers --- */
564      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(hd61830);            break;
565
566      /* --- the following bits of info are returned as pointers to data --- */
567      case DEVINFO_PTR_DEFAULT_MEMORY_MAP_0:         info->default_map8 = ADDRESS_MAP_NAME(hd61380_ram);   break;
568
569      /* --- the following bits of info are returned as pointers to functions --- */
570      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(hd61830);         break;
571      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
572      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(hd61830);         break;
573
574      /* --- the following bits of info are returned as NULL-terminated strings --- */
575      case DEVINFO_STR_NAME:                     strcpy(info->s, "Hitachi HD61830");               break;
576      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Hitachi HD61830");               break;
577      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                        break;
578      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
579      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");            break;
580   }
581}
582
583DEFINE_LEGACY_MEMORY_DEVICE(HD61830, hd61830);
src/mess/video/hd61830.h
r9369r9370
77
88**********************************************************************/
99
10#pragma once
11
1012#ifndef __HD61830__
1113#define __HD61830__
1214
1315#include "emu.h"
14#include "devcb.h"
1516
16/***************************************************************************
17    MACROS / CONSTANTS
18***************************************************************************/
1917
20#define HD61830_TAG      "hd61830"
2118
22DECLARE_LEGACY_MEMORY_DEVICE(HD61830, hd61830);
19//**************************************************************************
20//   MACROS / CONSTANTS
21//**************************************************************************
2322
23
24
25
26//**************************************************************************
27//  INTERFACE CONFIGURATION MACROS
28//**************************************************************************
29
2430#define MDRV_HD61830_ADD(_tag, _clock, _config) \
2531   MDRV_DEVICE_ADD(_tag, HD61830, _clock) \
2632   MDRV_DEVICE_CONFIG(_config)
2733
34
2835#define HD61830_INTERFACE(name) \
2936   const hd61830_interface (name) =
3037
31/***************************************************************************
32    TYPE DEFINITIONS
33***************************************************************************/
3438
35typedef UINT8 (*hd61830_rd_read)(running_device *device, UINT16 ma, UINT8 md);
36#define HD61830_RD_READ(name)   UINT8 name(running_device *device, UINT16 ma, UINT8 md)
3739
38typedef struct _hd61830_interface hd61830_interface;
39struct _hd61830_interface
40//**************************************************************************
41//   TYPE DEFINITIONS
42//**************************************************************************
43
44// ======================> hd61830_interface
45
46struct hd61830_interface
4047{
41   const char *screen_tag;      /* screen we are acting on */
48   const char *screen_tag;
4249
43   hd61830_rd_read   rd_r;
50    devcb_read8 m_in_rd_func;
4451};
4552
46/***************************************************************************
47    PROTOTYPES
48***************************************************************************/
4953
50/* register access */
51READ8_DEVICE_HANDLER( hd61830_r );
52WRITE8_DEVICE_HANDLER( hd61830_w );
5354
54READ8_DEVICE_HANDLER( hd61830_status_r );
55WRITE8_DEVICE_HANDLER( hd61830_control_w );
55// ======================> hd61830_device_config
5656
57READ8_DEVICE_HANDLER( hd61830_data_r );
58WRITE8_DEVICE_HANDLER( hd61830_data_w );
57class hd61830_device_config :   public device_config,
58                        public device_config_memory_interface,
59                                public hd61830_interface
60{
61    friend class hd61830_device;
5962
60/* screen update */
61void hd61830_update(running_device *device, bitmap_t *bitmap, const rectangle *cliprect);
63    // construction/destruction
64    hd61830_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
6265
66public:
67    // allocators
68    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
69    virtual device_t *alloc_device(running_machine &machine) const;
70   
71   // optional information overrides
72   virtual const rom_entry *rom_region() const;
73
74protected:
75   // device_config overrides
76   virtual void device_config_complete();
77
78   // device_config_memory_interface overrides
79   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
80
81    // address space configurations
82   const address_space_config      m_space_config;
83};
84
85
86
87// ======================> hd61830_device
88
89class hd61830_device :   public device_t,
90                  public device_memory_interface
91{
92    friend class hd61830_device_config;
93
94    // construction/destruction
95    hd61830_device(running_machine &_machine, const hd61830_device_config &_config);
96
97public:
98    DECLARE_READ8_MEMBER( status_r );
99    DECLARE_WRITE8_MEMBER( control_w );
100
101    DECLARE_READ8_MEMBER( data_r );
102    DECLARE_WRITE8_MEMBER( data_w );
103
104   void update_screen(bitmap_t *bitmap, const rectangle *cliprect);
105
106protected:
107    // device-level overrides
108    virtual void device_start();
109    virtual void device_reset();
110   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
111
112   static TIMER_CALLBACK( busy_tick );
113
114   inline UINT8 readbyte(offs_t address);
115   inline void writebyte(offs_t address, UINT8 data);
116
117private:
118   void set_busy_flag();
119
120   void draw_scanline(bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ra);
121   void update_graphics(bitmap_t *bitmap, const rectangle *cliprect);
122   void draw_char(bitmap_t *bitmap, const rectangle *cliprect, UINT16 ma, int x, int y, UINT8 md);
123   void update_text(bitmap_t *bitmap, const rectangle *cliprect);
124
125    devcb_resolved_read8 m_in_rd_func;
126
127   screen_device *m_screen;
128   emu_timer *m_busy_timer;
129   address_space *m_data;
130
131   bool m_bf;                  // busy flag
132
133   UINT8 m_ir;                  // instruction register
134   UINT8 m_mcr;               // mode control register
135   UINT8 m_dor;               // data output register
136
137   UINT16 m_dsa;               // display start address
138   UINT16 m_cac;               // cursor address counter
139
140   int m_vp;                  // vertical character pitch
141   int m_hp;                  // horizontal character pitch
142   int m_hn;                  // horizontal number of characters
143   int m_nx;                  // number of time divisions
144   int m_cp;                  // cursor position
145
146    int m_blink;               // blink counter
147   bool m_cursor;               // cursor visible
148
149   const hd61830_device_config &m_config;
150};
151
152
153// device type definition
154extern const device_type HD61830;
155
156
157
63158#endif
src/mess/includes/portfoli.h
r9369r9370
33#ifndef __PORTFOLIO__
44#define __PORTFOLIO__
55
6#include "video/hd61830.h"
7
68#define SCREEN_TAG      "screen"
79#define M80C88A_TAG      "u1"
810#define M82C55A_TAG      "hpc101_u1"
r9369r9370
1618{
1719public:
1820   portfolio_state(running_machine &machine, const driver_device_config_base &config)
19      : driver_device(machine, config) { }
21      : driver_device(machine, config),
22        m_maincpu(*this, M80C88A_TAG),
23        m_lcdc(*this, HD61830_TAG),
24        m_ppi(*this, M82C55A_TAG),
25        m_uart(*this, M82C50A_TAG),
26        m_speaker(*this, SPEAKER_TAG)
27   { }
2028
29   required_device<cpu_device> m_maincpu;
30   required_device<hd61830_device> m_lcdc;
31   required_device<running_device> m_ppi;
32   required_device<running_device> m_uart;
33   required_device<running_device> m_speaker;
34   timer_device *m_timer_tick;
35
36   virtual void machine_start();
37   virtual void machine_reset();
38
39   bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect) { m_lcdc->update_screen(&bitmap, &cliprect); return 0; }
40
41   void check_interrupt();
42   void trigger_interrupt(int level);
43   void scan_keyboard();
44
45   DECLARE_READ8_MEMBER( irq_status_r );
46   DECLARE_READ8_MEMBER( keyboard_r );
47   DECLARE_READ8_MEMBER( battery_r );
48   DECLARE_READ8_MEMBER( counter_r );
49   DECLARE_READ8_MEMBER( pid_r );
50
51   DECLARE_WRITE8_MEMBER( irq_mask_w );
52   DECLARE_WRITE8_MEMBER( sivr_w );
53   DECLARE_WRITE8_MEMBER( speaker_w );
54   DECLARE_WRITE8_MEMBER( power_w );
55   DECLARE_WRITE8_MEMBER( unknown_w );
56   DECLARE_WRITE8_MEMBER( counter_w );
57   DECLARE_WRITE8_MEMBER( ncc1_w );
58
2159   /* interrupt state */
22   UINT8 ip;                  /* interrupt pending */
23   UINT8 ie;                  /* interrupt enable */
24   UINT8 sivr;                  /* serial interrupt vector register */
60   UINT8 m_ip;                     /* interrupt pending */
61   UINT8 m_ie;                     /* interrupt enable */
62   UINT8 m_sivr;                  /* serial interrupt vector register */
2563
2664   /* counter state */
27   UINT16 counter;
65   UINT16 m_counter;
2866
2967   /* keyboard state */
30   UINT8 keylatch;
68   UINT8 m_keylatch;
3169
3270   /* video state */
33   UINT8 contrast;
71   UINT8 m_contrast;
3472
3573   /* peripheral state */
36   UINT8 pid;                  /* peripheral identification */
37
38   /* devices */
39   running_device *hd61830;
40   running_device *centronics;
41   running_device *speaker;
42   timer_device *timer_tick;
74   UINT8 m_pid;                  /* peripheral identification */
4375};
4476
4577#endif
src/mess/includes/kyocera.h
r9369r9370
11#ifndef __KYOCERA__
22#define __KYOCERA__
33
4#include "video/hd61830.h"
5
46#define SCREEN_TAG      "screen"
57#define I8085_TAG      "m19"
68#define I8155_TAG      "m25"
r9369r9370
1719#define RP5C01A_TAG      "m301"
1820#define TCM5089_TAG      "m11"
1921#define MSM8251_TAG      "m20"
22#define HD61830_TAG      "m18"
2023
2124class kc85_state : public driver_device
2225{
r9369r9370
6366   int buzzer;            /* buzzer select */
6467   int bell;            /* bell output */
6568
66   running_device *hd61830;
69   hd61830_device *hd61830;
6770   running_device *im6042;
6871   running_device *mc14412;
6972   running_device *tcm5089;
src/mess/includes/micronic.h
r9369r9370
11#ifndef __MICRONIC__
22#define __MICRONIC__
33
4#include "video/hd61830.h"
5
46#define SCREEN_TAG      "screen"
57#define Z80_TAG         "z80"
68#define MC146818_TAG   "mc146818"
9#define HD61830_TAG      "hd61830"
710
811class micronic_state : public driver_device
912{
r9369r9370
2528   emu_timer *rtc_periodic_irq;
2629
2730   /* devices */
28   running_device *hd61830;
31   hd61830_device *hd61830;
2932   running_device *speaker;
3033
3134};
src/mess/drivers/kyocera.c
r9369r9370
4343    - tandy200 UART8251
4444    - tandy200 RTC alarm
4545    - tandy200 TCM5089 sound
46   - tandy200 LCDC has only 8K of video RAM
4647    - international keyboard option ROMs
4748
4849*/
r9369r9370
568569   AM_RANGE(0xc1, 0xc1) AM_MIRROR(0x0e) AM_DEVREADWRITE(MSM8251_TAG, msm8251_status_r, msm8251_control_w)
569570   AM_RANGE(0xd0, 0xd0) AM_MIRROR(0x0f) AM_READWRITE(tandy200_bank_r, tandy200_bank_w)
570571   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x0f) AM_READWRITE(tandy200_stbk_r, tandy200_stbk_w)
571   AM_RANGE(0xf0, 0xf1) AM_MIRROR(0x0e) AM_DEVREADWRITE(HD61830_TAG, hd61830_r, hd61830_w)
572   AM_RANGE(0xf0, 0xf0) AM_MIRROR(0x0e) AM_DEVREADWRITE_MODERN(HD61830_TAG, hd61830_device, data_r, data_w)
573   AM_RANGE(0xf1, 0xf1) AM_MIRROR(0x0e) AM_DEVREADWRITE_MODERN(HD61830_TAG, hd61830_device, status_r, control_w)
572574ADDRESS_MAP_END
575/*
576static ADDRESS_MAP_START( tandy200_lcdc, 0, 8 )
577   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
578   AM_RANGE(0x0000, 0x1fff) AM_RAM
579ADDRESS_MAP_END
580*/
573581
574582/* Input Ports */
575583
src/mess/drivers/portfoli.c
r9369r9370
4242
4343*/
4444
45#define ADDRESS_MAP_MODERN
46
4547#include "emu.h"
4648#include "includes/portfoli.h"
4749#include "cpu/i86/i86.h"
r9369r9370
8789//  check_interrupt - check interrupt status
8890//-------------------------------------------------
8991
90static void check_interrupt(running_machine *machine)
92void portfolio_state::check_interrupt()
9193{
92   portfolio_state *state = machine->driver_data<portfolio_state>();
93
94   int level = (state->ip & state->ie) ? ASSERT_LINE : CLEAR_LINE;
94   int level = (m_ip & m_ie) ? ASSERT_LINE : CLEAR_LINE;
9595   
96   cputag_set_input_line(machine, M80C88A_TAG, INPUT_LINE_INT0, level);
96   cpu_set_input_line(m_maincpu, INPUT_LINE_INT0, level);
9797}
9898
9999//-------------------------------------------------
100100//  trigger_interrupt - trigger interrupt request
101101//-------------------------------------------------
102102
103static void trigger_interrupt(running_machine *machine, int level)
103void portfolio_state::trigger_interrupt(int level)
104104{
105   portfolio_state *state = machine->driver_data<portfolio_state>();
106
107105   // set interrupt pending bit
108   state->ip |= 1 << level;
106   m_ip |= 1 << level;
109107
110   check_interrupt(machine);
108   check_interrupt();
111109}
112110
113111//-------------------------------------------------
114112//  irq_status_r - interrupt status read
115113//-------------------------------------------------
116114
117static READ8_HANDLER( irq_status_r )
115READ8_MEMBER( portfolio_state::irq_status_r )
118116{
119   portfolio_state *state = space->machine->driver_data<portfolio_state>();
120
121   return state->ip;
117   return m_ip;
122118}
123119
124120//-------------------------------------------------
125121//  irq_mask_w - interrupt enable mask
126122//-------------------------------------------------
127123
128static WRITE8_HANDLER( irq_mask_w )
124WRITE8_MEMBER( portfolio_state::irq_mask_w )
129125{
130   portfolio_state *state = space->machine->driver_data<portfolio_state>();
131
132   state->ie = data;
126   m_ie = data;
133127   //logerror("IE %02x\n", data);
134128
135   check_interrupt(space->machine);
129   check_interrupt();
136130}
137131
138132//-------------------------------------------------
139133//  sivr_w - serial interrupt vector register
140134//-------------------------------------------------
141135
142static WRITE8_HANDLER( sivr_w )
136WRITE8_MEMBER( portfolio_state::sivr_w )
143137{
144   portfolio_state *state = space->machine->driver_data<portfolio_state>();
145
146   state->sivr = data;
138   m_sivr = data;
147139   //logerror("SIVR %02x\n", data);
148140}
149141
r9369r9370
151143//  IRQ_CALLBACK( portfolio_int_ack )
152144//-------------------------------------------------
153145
154static IRQ_CALLBACK( portfolio_int_ack )
146IRQ_CALLBACK( portfolio_int_ack )
155147{
156148   portfolio_state *state = device->machine->driver_data<portfolio_state>();
157149
158   UINT8 vector = state->sivr;
150   UINT8 vector = state->m_sivr;
159151   
160152   for (int i = 0; i < 4; i++)
161153   {
162      if (BIT(state->ip, i))
154      if (BIT(state->m_ip, i))
163155      {
164156         // clear interrupt pending bit
165         state->ip &= ~(1 << i);
157         state->m_ip &= ~(1 << i);
166158
167159         if (i == 3)
168            vector = state->sivr;
160            vector = state->m_sivr;
169161         else
170162            vector = INTERRUPT_VECTOR[i];
171163
r9369r9370
173165      }
174166   }
175167
176   check_interrupt(device->machine);
168   state->check_interrupt();
177169
178170   return vector;
179171}
r9369r9370
186178//  scan_keyboard - scan keyboard
187179//-------------------------------------------------
188180
189static void scan_keyboard(running_machine *machine)
181void portfolio_state::scan_keyboard()
190182{
191   portfolio_state *state = machine->driver_data<portfolio_state>();
192
193183   UINT8 keycode = 0xff;
194184
195185   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" };
196186
197187   for (int row = 0; row < 8; row++)
198188   {
199      UINT8 data = input_port_read(machine, keynames[row]);
189      UINT8 data = input_port_read(&m_machine, keynames[row]);
200190
201191      if (data != 0xff)
202192      {
r9369r9370
213203   if (keycode != 0xff)
214204   {
215205      // key pressed
216      if (keycode != state->keylatch)
206      if (keycode != m_keylatch)
217207      {
218         state->keylatch = keycode;
208         m_keylatch = keycode;
219209
220         trigger_interrupt(machine, INT_KEYBOARD);
210         trigger_interrupt(INT_KEYBOARD);
221211      }
222212   }
223213   else
224214   {
225215      // key released
226      if (state->keylatch != 0xff)
216      if (m_keylatch != 0xff)
227217      {
228         state->keylatch |= 0x80;
218         m_keylatch |= 0x80;
229219
230         trigger_interrupt(machine, INT_KEYBOARD);
220         trigger_interrupt(INT_KEYBOARD);
231221      }
232222   }
233223}
r9369r9370
236226//  TIMER_DEVICE_CALLBACK( keyboard_tick )
237227//-------------------------------------------------
238228
239static TIMER_DEVICE_CALLBACK( keyboard_tick )
229TIMER_DEVICE_CALLBACK( keyboard_tick )
240230{
241   scan_keyboard(timer.machine);
231   portfolio_state *state = timer.machine->driver_data<portfolio_state>();
232
233   state->scan_keyboard();
242234}
243235
244236//-------------------------------------------------
245237//  keyboard_r - keyboard scan code register
246238//-------------------------------------------------
247239
248static READ8_HANDLER( keyboard_r )
240READ8_MEMBER( portfolio_state::keyboard_r )
249241{
250   portfolio_state *state = space->machine->driver_data<portfolio_state>();
251
252   return state->keylatch;
242   return m_keylatch;
253243}
254244
255245//**************************************************************************
r9369r9370
260250//  speaker_w - internal speaker output
261251//-------------------------------------------------
262252
263static WRITE8_HANDLER( speaker_w )
253WRITE8_MEMBER( portfolio_state::speaker_w )
264254{
265255   /*
266256
r9369r9370
277267
278268   */
279269
280   portfolio_state *state = space->machine->driver_data<portfolio_state>();
270   speaker_level_w(m_speaker, !BIT(data, 7));
281271
282   speaker_level_w(state->speaker, !BIT(data, 7));
283
284272   //logerror("SPEAKER %02x\n", data);
285273}
286274
r9369r9370
292280//  power_w - power management
293281//-------------------------------------------------
294282
295static WRITE8_HANDLER( power_w )
283WRITE8_MEMBER( portfolio_state::power_w )
296284{
297285   /*
298286
r9369r9370
316304//  battery_r - battery status
317305//-------------------------------------------------
318306
319static READ8_HANDLER( battery_r )
307READ8_MEMBER( portfolio_state::battery_r )
320308{
321309   /*
322310
r9369r9370
333321
334322   */
335323
336   portfolio_state *state = space->machine->driver_data<portfolio_state>();
337
338324   UINT8 data = 0;
339325
340326   /* peripheral detect */
341   data |= (state->pid != PID_NONE) << 5;
327   data |= (m_pid != PID_NONE) << 5;
342328
343329   /* battery status */
344   data |= BIT(input_port_read(space->machine, "BATTERY"), 0) << 6;
330   data |= BIT(input_port_read(&m_machine, "BATTERY"), 0) << 6;
345331
346332   return data;
347333}
r9369r9370
350336//  unknown_w - ?
351337//-------------------------------------------------
352338
353static WRITE8_HANDLER( unknown_w )
339WRITE8_MEMBER( portfolio_state::unknown_w )
354340{
355341   //logerror("UNKNOWN %02x\n", data);
356342}
r9369r9370
363349//  TIMER_DEVICE_CALLBACK( system_tick )
364350//-------------------------------------------------
365351
366static TIMER_DEVICE_CALLBACK( system_tick )
352TIMER_DEVICE_CALLBACK( system_tick )
367353{
368   trigger_interrupt(timer.machine, INT_TICK);
354   portfolio_state *state = timer.machine->driver_data<portfolio_state>();
355
356   state->trigger_interrupt(INT_TICK);
369357}
370358
371359//-------------------------------------------------
372360//  TIMER_DEVICE_CALLBACK( counter_tick )
373361//-------------------------------------------------
374362
375static TIMER_DEVICE_CALLBACK( counter_tick )
363TIMER_DEVICE_CALLBACK( counter_tick )
376364{
377365   portfolio_state *state = timer.machine->driver_data<portfolio_state>();
378366
379   state->counter++;
367   state->m_counter++;
380368}
381369
382370//-------------------------------------------------
383371//  counter_r - counter register read
384372//-------------------------------------------------
385373
386static READ8_HANDLER( counter_r )
374READ8_MEMBER( portfolio_state::counter_r )
387375{
388   portfolio_state *state = space->machine->driver_data<portfolio_state>();
389
390376   UINT8 data = 0;
391377
392378   switch (offset)
393379   {
394380   case 0:
395      data = state->counter & 0xff;
381      data = m_counter & 0xff;
396382      break;
397383
398384   case 1:
399      data = state->counter >> 1;
385      data = m_counter >> 1;
400386      break;
401387   }
402388
r9369r9370
407393//  counter_w - counter register write
408394//-------------------------------------------------
409395
410static WRITE8_HANDLER( counter_w )
396WRITE8_MEMBER( portfolio_state::counter_w )
411397{
412   portfolio_state *state = space->machine->driver_data<portfolio_state>();
413
414398   switch (offset)
415399   {
416400   case 0:
417      state->counter = (state->counter & 0xff00) | data;
401      m_counter = (m_counter & 0xff00) | data;
418402      break;
419403
420404   case 1:
421      state->counter = (data << 8) | (state->counter & 0xff);
405      m_counter = (data << 8) | (m_counter & 0xff);
422406      break;
423407   }
424408}
r9369r9370
431415//  ncc1_w - credit card memory select
432416//-------------------------------------------------
433417
434static WRITE8_HANDLER( ncc1_w )
418WRITE8_MEMBER( portfolio_state::ncc1_w )
435419{
436   address_space *program = cputag_get_address_space(space->machine, M80C88A_TAG, ADDRESS_SPACE_PROGRAM);
420   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
437421
438422   if (BIT(data, 0))
439423   {
440424      // system ROM
441      UINT8 *rom = memory_region(space->machine, M80C88A_TAG);
425      UINT8 *rom = memory_region(&m_machine, M80C88A_TAG);
442426      memory_install_rom(program, 0xc0000, 0xdffff, 0, 0, rom);
443427   }
444428   else
r9369r9370
454438//  pid_r - peripheral identification
455439//-------------------------------------------------
456440
457static READ8_HANDLER( pid_r )
441READ8_MEMBER( portfolio_state::pid_r )
458442{
459443   /*
460444
r9369r9370
472456
473457   */
474458
475   portfolio_state *state = space->machine->driver_data<portfolio_state>();
476
477   return state->pid;
459   return m_pid;
478460}
479461
480462//**************************************************************************
r9369r9370
485467//  ADDRESS_MAP( portfolio_mem )
486468//-------------------------------------------------
487469
488static ADDRESS_MAP_START( portfolio_mem, ADDRESS_SPACE_PROGRAM, 8 )
470static ADDRESS_MAP_START( portfolio_mem, ADDRESS_SPACE_PROGRAM, 8, portfolio_state )
489471   AM_RANGE(0x00000, 0x1efff) AM_RAM AM_SHARE("nvram1")
490472   AM_RANGE(0x1f000, 0x9efff) AM_RAM // expansion
491473   AM_RANGE(0xb0000, 0xb0fff) AM_MIRROR(0xf000) AM_RAM AM_SHARE("nvram2") // video RAM
r9369r9370
497479//  ADDRESS_MAP( portfolio_io )
498480//-------------------------------------------------
499481
500static ADDRESS_MAP_START( portfolio_io, ADDRESS_SPACE_IO, 8 )
482static ADDRESS_MAP_START( portfolio_io, ADDRESS_SPACE_IO, 8, portfolio_state )
501483   AM_RANGE(0x8000, 0x8000) AM_READ(keyboard_r)
502   AM_RANGE(0x8010, 0x8010) AM_DEVREADWRITE(HD61830_TAG, hd61830_data_r, hd61830_data_w)
503   AM_RANGE(0x8011, 0x8011) AM_DEVREADWRITE(HD61830_TAG, hd61830_status_r, hd61830_control_w)
484   AM_RANGE(0x8010, 0x8010) AM_DEVREADWRITE(HD61830_TAG, hd61830_device, data_r, data_w)
485   AM_RANGE(0x8011, 0x8011) AM_DEVREADWRITE(HD61830_TAG, hd61830_device, status_r, control_w)
504486   AM_RANGE(0x8020, 0x8020) AM_WRITE(speaker_w)
505487   AM_RANGE(0x8030, 0x8030) AM_WRITE(power_w)
506488   AM_RANGE(0x8040, 0x8041) AM_READWRITE(counter_r, counter_w)
507489   AM_RANGE(0x8050, 0x8050) AM_READWRITE(irq_status_r, irq_mask_w)
508490   AM_RANGE(0x8051, 0x8051) AM_READWRITE(battery_r, unknown_w)
509   AM_RANGE(0x8060, 0x8060) AM_RAM AM_BASE_MEMBER(portfolio_state, contrast)
510//   AM_RANGE(0x8070, 0x8077) AM_DEVREADWRITE(M82C50A_TAG, ins8250_r, ins8250_w) Serial Interface
511//   AM_RANGE(0x8078, 0x807b) AM_DEVREADWRITE(M82C55A_TAG, i8255a_r, i8255a_w) Parallel Interface
491   AM_RANGE(0x8060, 0x8060) AM_RAM AM_BASE(m_contrast)
492//   AM_RANGE(0x8070, 0x8077) AM_DEVREADWRITE_LEGACY(M82C50A_TAG, ins8250_r, ins8250_w) // Serial Interface
493//   AM_RANGE(0x8078, 0x807b) AM_DEVREADWRITE_LEGACY(M82C55A_TAG, i8255a_r, i8255a_w) // Parallel Interface
512494   AM_RANGE(0x807c, 0x807c) AM_WRITE(ncc1_w)
513495   AM_RANGE(0x807f, 0x807f) AM_READWRITE(pid_r, sivr_w)
514496ADDRESS_MAP_END
r9369r9370
602584   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
603585   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
604586
587   PORT_START("PPI-PB")
588   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(CENTRONICS_TAG, centronics_strobe_w)
589   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(CENTRONICS_TAG, centronics_autofeed_w)
590   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(CENTRONICS_TAG, centronics_init_w)
591   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_SPECIAL) // PORT_WRITE_LINE_DEVICE(CENTRONICS_TAG, centronics_select_in_w)
592   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED)
593   PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNUSED)
594   PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED)
595   PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
596
597   PORT_START("PPI-PC")
598   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_pe_r)
599   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_vcc_r)
600   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_UNUSED)
601   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_fault_r)
602   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_busy_r)
603   PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_ack_r)
604   PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED)
605   PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
606
605607   PORT_START("BATTERY")
606608   PORT_CONFNAME( 0x01, 0x01, "Battery Status" )
607609   PORT_CONFSETTING( 0x01, DEF_STR( Normal ) )
r9369r9370
629631}
630632
631633//-------------------------------------------------
632//  VIDEO_UPDATE( portfolio )
633//-------------------------------------------------
634
635static VIDEO_UPDATE( portfolio )
636{
637   portfolio_state *state = screen->machine->driver_data<portfolio_state>();
638
639   hd61830_update(state->hd61830, bitmap, cliprect);
640
641   return 0;
642}
643
644//-------------------------------------------------
645634//  HD61830_INTERFACE( lcdc_intf )
646635//-------------------------------------------------
647636
648static HD61830_RD_READ( hd61830_rd_r )
637READ8_DEVICE_HANDLER( hd61830_rd_r )
649638{
650   UINT16 address = (md << 3) | ((ma >> 12) & 0x07);
639   UINT16 address = ((offset & 0xff) << 3) | ((offset >> 12) & 0x07);
651640   UINT8 data = memory_region(device->machine, HD61830_TAG)[address];
652641
653642   return data;
r9369r9370
656645static HD61830_INTERFACE( lcdc_intf )
657646{
658647   SCREEN_TAG,
659   hd61830_rd_r
648   DEVCB_HANDLER(hd61830_rd_r)
660649};
661650
662651//-------------------------------------------------
r9369r9370
670659   1,
671660   { 0 },
672661   { 7, 6, 5, 4, 3, 2 },
673   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
662   { STEP8(0,8) },
674663   8*8
675664};
676665
r9369r9370
690679//  I8255A_INTERFACE( ppi_intf )
691680//-------------------------------------------------
692681
693static WRITE8_DEVICE_HANDLER( ppi_pb_w )
694{
695   /*
696
697        bit     signal
698
699        PB0      strobe
700        PB1      autofeed
701        PB2      init/reset
702        PB3      select in
703        PB4     
704        PB5     
705        PB6     
706        PB7     
707
708    */
709
710   portfolio_state *state = device->machine->driver_data<portfolio_state>();
711
712   /* strobe */
713   centronics_strobe_w(state->centronics, BIT(data, 0));
714   
715   /* autofeed */
716   centronics_autofeed_w(state->centronics, BIT(data, 1));
717   
718   /* init/reset */
719   centronics_init_w(state->centronics, BIT(data, 2));
720   
721   /* select in */
722   //centronics_select_in_w(state->centronics, BIT(data, 3));
723}
724
725static READ8_DEVICE_HANDLER( ppi_pc_r )
726{
727   /*
728
729        bit     signal
730
731        PC0      paper
732        PC1      select
733        PC2     
734        PC3      error
735        PC4      busy
736        PC5      ack
737        PC6     
738        PC7     
739
740    */
741
742   portfolio_state *state = device->machine->driver_data<portfolio_state>();
743
744   UINT8 data = 0;
745
746   /* paper end */
747   data |= centronics_pe_r(state->centronics);
748
749   /* select */
750   data |= centronics_vcc_r(state->centronics) << 1;
751
752   /* error */
753   data |= centronics_fault_r(state->centronics) << 3;
754
755   /* busy */
756   data |= centronics_busy_r(state->centronics) << 4;
757
758   /* acknowledge */
759   data |= centronics_ack_r(state->centronics) << 5;
760
761   return data;
762}
763
764682static I8255A_INTERFACE( ppi_intf )
765683{
766684   DEVCB_NULL,                                       // Port A read
767685   DEVCB_NULL,                                       // Port B read
768   DEVCB_HANDLER(ppi_pc_r),                           // Port C read
686   DEVCB_INPUT_PORT("PPI-PC"),                           // Port C read
769687   DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w),   // Port A write
770   DEVCB_HANDLER(ppi_pb_w),                           // Port B write
688   DEVCB_INPUT_PORT("PPI-PB"),                           // Port B write
771689   DEVCB_NULL                                       // Port C write
772690};
773691
r9369r9370
777695
778696static INS8250_INTERRUPT( i8250_intrpt_w )
779697{
780//   trigger_interrupt(device->machine, INT_EXTERNAL);
698   portfolio_state *driver_state = device->machine->driver_data<portfolio_state>();
699
700   driver_state->trigger_interrupt(INT_EXTERNAL);
781701}
782702
783const ins8250_interface i8250_intf =
703static const ins8250_interface i8250_intf =
784704{
785705   XTAL_1_8432MHz,
786706   i8250_intrpt_w,
r9369r9370
819739//**************************************************************************
820740
821741//-------------------------------------------------
822//  MACHINE_START( portfolio )
742//  machine_start
823743//-------------------------------------------------
824744
825static MACHINE_START( portfolio )
745void portfolio_state::machine_start()
826746{
827   portfolio_state *state = machine->driver_data<portfolio_state>();
828   address_space *program = cputag_get_address_space(machine, M80C88A_TAG, ADDRESS_SPACE_PROGRAM);
747   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
829748
830749   /* set CPU interrupt vector callback */
831   cpu_set_irq_callback(machine->device(M80C88A_TAG), portfolio_int_ack);
750   cpu_set_irq_callback(m_maincpu, portfolio_int_ack);
832751
833752   /* find devices */
834   state->hd61830 = machine->device(HD61830_TAG);
835   state->centronics = machine->device(CENTRONICS_TAG);
836   state->speaker = machine->device(SPEAKER_TAG);
837   state->timer_tick = machine->device<timer_device>(TIMER_TICK_TAG);
753   m_timer_tick = machine->device<timer_device>(TIMER_TICK_TAG);
838754
839755   /* memory expansions */
840756   switch (messram_get_size(machine->device("messram")))
r9369r9370
849765   }
850766
851767   /* set initial values */
852   state->keylatch = 0xff;
853   state->sivr = 0x2a;
854   state->pid = 0xff;
768   m_keylatch = 0xff;
769   m_sivr = 0x2a;
770   m_pid = 0xff;
855771
856772   /* register for state saving */
857   state_save_register_global(machine, state->ip);
858   state_save_register_global(machine, state->ie);
859   state_save_register_global(machine, state->sivr);
860   state_save_register_global(machine, state->counter);
861   state_save_register_global(machine, state->keylatch);
862   state_save_register_global(machine, state->contrast);
863   state_save_register_global(machine, state->pid);
773   state_save_register_global(machine, m_ip);
774   state_save_register_global(machine, m_ie);
775   state_save_register_global(machine, m_sivr);
776   state_save_register_global(machine, m_counter);
777   state_save_register_global(machine, m_keylatch);
778   state_save_register_global(machine, m_contrast);
779   state_save_register_global(machine, m_pid);
864780}
865781
866782//-------------------------------------------------
867//  MACHINE_RESET( portfolio )
783//  machine_reset
868784//-------------------------------------------------
869785
870static MACHINE_RESET( portfolio )
786void portfolio_state::machine_reset()
871787{
872   portfolio_state *state = machine->driver_data<portfolio_state>();
873   address_space *io = cputag_get_address_space(machine, M80C88A_TAG, ADDRESS_SPACE_IO);
788   address_space *io = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_IO);
874789
875   /* peripheral */
876   state->pid = input_port_read(machine, "PERIPHERAL");
790   // peripherals
791   m_pid = input_port_read(&m_machine, "PERIPHERAL");
877792
878   switch (state->pid)
793   memory_unmap_readwrite(io, 0x8070, 0x807b, 0, 0);
794   memory_unmap_readwrite(io, 0x807d, 0x807e, 0, 0);
795
796   switch (m_pid)
879797   {
880798   case PID_SERIAL:
881      memory_install_readwrite8_device_handler(io, machine->device(M82C50A_TAG), 0x8070, 0x8077, 0, 0, ins8250_r, ins8250_w);
799      memory_install_readwrite8_device_handler(io, m_uart, 0x8070, 0x8077, 0, 0, ins8250_r, ins8250_w);
882800      break;
883801
884802   case PID_PARALLEL:
885      memory_install_readwrite8_device_handler(io, machine->device(M82C55A_TAG), 0x8078, 0x807b, 0, 0, i8255a_r, i8255a_w);
803      memory_install_readwrite8_device_handler(io, m_ppi, 0x8078, 0x807b, 0, 0, i8255a_r, i8255a_w);
886804      break;
887805   }
888806}
r9369r9370
901819    MDRV_CPU_PROGRAM_MAP(portfolio_mem)
902820    MDRV_CPU_IO_MAP(portfolio_io)
903821   
904   MDRV_MACHINE_START(portfolio)
905   MDRV_MACHINE_RESET(portfolio)
906
907822    /* video hardware */
908823   MDRV_SCREEN_ADD(SCREEN_TAG, LCD)
909824   MDRV_SCREEN_REFRESH_RATE(72)
r9369r9370
916831   MDRV_PALETTE_LENGTH(2)
917832   MDRV_PALETTE_INIT(portfolio)
918833
919   MDRV_VIDEO_UPDATE(portfolio)
920834   MDRV_GFXDECODE(portfolio)
921835
922836   MDRV_HD61830_ADD(HD61830_TAG, XTAL_4_9152MHz/2/2, lcdc_intf)
src/mess/drivers/micronic.c
r9369r9370
319319   AM_RANGE(0x02, 0x02) AM_WRITE(kp_matrix_w)
320320
321321   /* hd61830 */
322   AM_RANGE(0x03, 0x03) AM_DEVREADWRITE(HD61830_TAG, hd61830_data_r, hd61830_data_w)
323   AM_RANGE(0x23, 0x23) AM_DEVREADWRITE(HD61830_TAG, hd61830_status_r, hd61830_control_w)
322   AM_RANGE(0x03, 0x03) AM_DEVREADWRITE_MODERN(HD61830_TAG, hd61830_device, data_r, data_w)
323   AM_RANGE(0x23, 0x23) AM_DEVREADWRITE_MODERN(HD61830_TAG, hd61830_device, status_r, control_w)
324324
325325   /* rtc-146818 */
326326   AM_RANGE(0x08, 0x08) AM_WRITE(rtc_address_w)
r9369r9370
440440{
441441   micronic_state *state = screen->machine->driver_data<micronic_state>();
442442
443   hd61830_update(state->hd61830, bitmap, cliprect);
443   state->hd61830->update_screen(bitmap, cliprect);
444444
445445   return 0;
446446}
r9369r9370
448448static HD61830_INTERFACE( lcdc_intf )
449449{
450450   SCREEN_TAG,
451   NULL
451   DEVCB_NULL
452452};
453453
454454static MACHINE_START( micronic )
r9369r9370
456456   micronic_state *state = machine->driver_data<micronic_state>();
457457
458458   /* find devices */
459   state->hd61830 = machine->device(HD61830_TAG);
459   state->hd61830 = machine->device<hd61830_device>(HD61830_TAG);
460460   state->speaker = machine->device("beep");
461461
462462   /* ROM banks */
docs/messnew.txt
r9369r9370
3838- TIM-011
3939- WaveMate Bullet
4040- ABC 1600 [Rune Tapper, Curt Coder]
41- Atari TT030
42- Atari Falcon
43- Atari Falcon040
41- Atari TT030 [Curt Coder]
42- Atari Falcon [Curt Coder]
43- Atari Falcon040 [Curt Coder]
4444- IBM PS/2 Model 55SX [Joseba Epalza]
4545- Nakajima ES-210 (Spain) [Joseba Epalza]
4646- Laser PC4 [Joseba Epalza, Curt Coder]
r9369r9370
7575
7676- [MBEE] Added Chess rom. [Robbbert]
7777
78- [POFO] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
79
7880- [PSION] Added support for datapack images [Sandro Ronco]
7981
8082
83
8184Imgtool Changes:
8285----------------
8386
r9369r9370
106109
107110- Added support for external character generator ROM to HD61830 LCDC. [Curt Coder]
108111
112- Introduced more accurate MC6847 palette. [Ensjo]
109113
114- Refactored the HD61830 LCD to a C++ device. [Curt Coder]
110115
116
117
1111180.139
112119
113120New System Drivers Supported:

Previous 15994 Revisions Next


© 1998-2018 The MESS Team