Previous 15994 Revisions Next

r8355 Tuesday 29th June, 2010 at 20:55:49 UTC by Fabio Priuli
[MICRONIC] made progresses on the emulation and added NVRAM [Sandro Ronco]
[src/mess/drivers]micronic.c
[src/mess/includes]micronic.h
[src/mess/video]hd61830.c hd61830.h

src/mess/includes/micronic.h
r8354r8355
1212
1313   micronic_state(running_machine &machine) { }
1414
15   UINT8 *ram;
16   UINT8 kp_matrix;
17   UINT8 lcd_contrast;
18   UINT8 lcd_light;
19   UINT8 status_flag;
20
21   /* rtc-146818 */
22   UINT8 rtc_address;
23   UINT8 periodic_irq;
24   UINT8 irq_flags;
25
26   emu_timer *rtc_periodic_irq;
27
28   /* devices */
1529   running_device *hd61830;
30   running_device *speaker;
31
1632};
1733
1834#endif
src/mess/video/hd61830.c
r8354r8355
6060typedef struct _hd61830_t hd61830_t;
6161struct _hd61830_t
6262{
63   const address_space *space;   /* memory space */
64
6365   int bf;                  /* busy flag */
6466
6567   UINT8 ir;               /* instruction register */
r8354r8355
7577   int nx;                  /* number of time divisions */
7678   int cp;                  /* cursor position */
7779
80    int blink;               /* blinking */
81
7882   /* devices */
7983   screen_device *screen;
8084
r8354r8355
161165READ8_DEVICE_HANDLER( hd61830_data_r )
162166{
163167   hd61830_t *hd61830 = get_safe_token(device);
164   const address_space *space = cputag_get_address_space(device->machine, HD61830_TAG, ADDRESS_SPACE_PROGRAM);
165168   UINT8 data = hd61830->dor;
166169
167170   if (LOG) logerror("HD61380 '%s' Display Data Read %02x\n", device->tag(), hd61830->dor);
168171
169   hd61830->dor = memory_read_byte(space, hd61830->cac);
172   hd61830->dor = memory_read_byte(hd61830->space, hd61830->cac);
170173
171174   hd61830->cac++;
172175
r8354r8355
180183WRITE8_DEVICE_HANDLER( hd61830_data_w )
181184{
182185   hd61830_t *hd61830 = get_safe_token(device);
183   const address_space *space = cputag_get_address_space(device->machine, HD61830_TAG, ADDRESS_SPACE_PROGRAM);
184186   switch (hd61830->ir)
185187   {
186188   case HD61830_INSTRUCTION_MODE_CONTROL:
r8354r8355
255257      break;
256258
257259   case HD61830_INSTRUCTION_DISPLAY_DATA_WRITE:
258      memory_write_byte(space, hd61830->cac, data);
260      memory_write_byte(hd61830->space, hd61830->cac, data);
259261
260262      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);
261263
r8354r8355
265267   case HD61830_INSTRUCTION_CLEAR_BIT:
266268      {
267269      int nb = data & 0x07;
268      UINT8 data_ = memory_read_byte(space, hd61830->cac);
270      UINT8 data_ = memory_read_byte(hd61830->space, hd61830->cac);
269271
270272      data_ &= ~(2 << nb);
271273
272274      if (LOG) logerror("HD61380 '%s' Clear Bit %u at %04x\n", device->tag(), nb + 1, hd61830->cac);
273275
274      memory_write_byte(space, hd61830->cac, data_);
276      memory_write_byte(hd61830->space, hd61830->cac, data_);
275277
276278      hd61830->cac++;
277279      }
r8354r8355
280282   case HD61830_INSTRUCTION_SET_BIT:
281283      {
282284      int nb = data & 0x07;
283      UINT8 data_ = memory_read_byte(space, hd61830->cac);
285      UINT8 data_ = memory_read_byte(hd61830->space, hd61830->cac);
284286
285287      data_ |= 2 << nb;
286288
287289      if (LOG) logerror("HD61380 '%s' Set Bit %u at %04x\n", device->tag(), nb + 1, hd61830->cac);
288290
289      memory_write_byte(space, hd61830->cac, data_);
291      memory_write_byte(hd61830->space, hd61830->cac, data_);
290292
291293      hd61830->cac++;
292294      }
r8354r8355
309311{
310312   hd61830_t *hd61830 = get_safe_token(device);
311313   int sx, x;
312   const address_space *space = cputag_get_address_space(device->machine, HD61830_TAG, ADDRESS_SPACE_PROGRAM);
313314
314315   for (sx = 0; sx < hd61830->hn; sx++)
315316   {
316      UINT8 data = memory_read_byte(space, ra++);
317      UINT8 data = memory_read_byte(hd61830->space, ra++);
317318
318319      for (x = 0; x < hd61830->hp; x++)
319320      {
r8354r8355
346347}
347348
348349/*-------------------------------------------------
350    draw_char - draw a char
351-------------------------------------------------*/
352
353static void draw_char(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int x, int y, UINT8 char_code)
354{
355   hd61830_t *hd61830 = get_safe_token(device);
356
357   if (char_code < 0x20 || char_code > 0x7f)
358      return;
359
360   for(int cl = 0; cl < 7; cl++)
361   {
362      for(int cr = 0; cr < 5; cr++)
363      {
364         if (hd61830->screen->height() > y * hd61830->vp + cl && hd61830->screen->width() > x * hd61830->hp + cr )
365            *BITMAP_ADDR16(bitmap, y * hd61830->vp + cl, x * hd61830->hp + cr) = device->subregion("hd61830")->base.u8[((char_code - 0x20) * 7 + cl)] & (1<<(4 - cr)) ? 1 : 0;
366      }
367   }
368}
369
370/*-------------------------------------------------
371    update_text- draw text mode screen
372-------------------------------------------------*/
373
374static void update_text(running_device *device, bitmap_t *bitmap, const rectangle *cliprect)
375{
376   hd61830_t *hd61830 = get_safe_token(device);
377
378   if (hd61830->blink < 0xff)
379      hd61830->blink++;
380   else
381      hd61830->blink = 0;
382
383   for(int y = 0; y < 8; y++)
384      for(int x = 0; x < hd61830->hn; x++)
385      {
386         UINT8 char_code = memory_read_byte(hd61830->space, y * hd61830->hn + x);
387
388         if (hd61830->cac == y * hd61830->hn + x)
389         {
390            /* update cursor */
391            switch ((hd61830->mcr >> 2) & 0x03)
392            {
393               case 0: //cursor OFF
394                  draw_char(device, bitmap, cliprect, x, y, char_code);
395                  break;
396               case 1:  //cursor ON
397                  if (hd61830->blink & 0x20)
398                     for(int cr = 0; cr < hd61830->hp; cr++)
399                        *BITMAP_ADDR16(bitmap, y * hd61830->vp + (hd61830->cp - 1), x * hd61830->hp + cr) = 1;
400                  else
401                     draw_char(device, bitmap, cliprect, x, y, char_code);
402                  break;
403               case 2: //cursor OFF character blink
404               case 3: //cursor blank
405                  if (hd61830->blink & 0x20)
406                     draw_char(device, bitmap, cliprect, x, y, 0x20);
407                  else
408                     draw_char(device, bitmap, cliprect, x, y, char_code);
409                  break;
410            }
411         }
412         else
413            draw_char(device, bitmap, cliprect, x, y, char_code);
414      }
415}
416
417/*-------------------------------------------------
349418    hd61830_update - update screen
350419-------------------------------------------------*/
351420
r8354r8355
359428   }
360429   else
361430   {
362      logerror("HD61830 text mode not supported!\n");
431      update_text(device, bitmap, cliprect);
363432   }
364433}
365434
r8354r8355
387456
388457ROM_START( hd61830 )
389458   ROM_REGION( 0x398, "hd61830", ROMREGION_LOADBYNAME )
390   ROM_LOAD( "hd61830.bin", 0x000, 0x398, NO_DUMP ) /* internal 7360-bit chargen ROM */
459   /* this is a fake charset used only for testing, the internal charset is still not dumped */
460   ROM_LOAD( "hd61830.bin", 0x000, 0x2a0, BAD_DUMP CRC(8faff7b9) SHA1(9626d4ace32d495f9840e456a501845fe60ad64c) ) /* internal 7360-bit chargen ROM */
391461ROM_END
392462
393463/*-------------------------------------------------
r8354r8355
411481   hd61830->screen = device->machine->device<screen_device>(config->screen_tag);
412482   assert(hd61830->screen != NULL);
413483
484   hd61830->space = device_get_space(device, ADDRESS_SPACE_0);
485
414486   /* create the busy timer */
415487   hd61830->busy_timer = timer_alloc(device->machine, busy_tick, (void *)device);
416488
r8354r8355
475547   }
476548}
477549
478DEFINE_LEGACY_DEVICE(HD61830, hd61830);
550DEFINE_LEGACY_MEMORY_DEVICE(HD61830, hd61830);
src/mess/video/hd61830.h
r8354r8355
1919
2020#define HD61830_TAG      "hd61830"
2121
22DECLARE_LEGACY_DEVICE(HD61830, hd61830);
22DECLARE_LEGACY_MEMORY_DEVICE(HD61830, hd61830);
2323
2424#define MDRV_HD61830_ADD(_tag, _clock, _screen) \
2525   MDRV_DEVICE_ADD(_tag, HD61830, _clock) \
src/mess/drivers/micronic.c
r8354r8355
9797
9898/*
9999
100    06/2010 (Sandro Ronco)
101
102    - ROM/RAM banking
103    - keypad input
104    - Periodic IRQ (RTC-146818)
105    - NVRAM
106
100107    TODO:
101108
102109    - HD61830 text mode
103    - everything else
110    - IR I/O port
104111
112    NOTE:
113    The display shows "TESTING..." for about 2 min before showing the information screen
114
105115*/
106116
107117#include "emu.h"
r8354r8355
109119#include "cpu/z80/z80.h"
110120#include "video/hd61830.h"
111121#include "machine/mc146818.h"
122#include "devices/messram.h"
123#include "sound/beep.h"
112124
125static UINT8 keypad_r (running_machine *machine)
126{
127   micronic_state *state = (micronic_state *)machine->driver_data;
128   static const char *const bitnames[] = {"BIT0", "BIT1", "BIT2", "BIT3", "BIT4", "BIT5"};
129   UINT8 port, bit, data = 0;
130
131   for (bit = 0; bit < 8; bit++)
132      if (state->kp_matrix & (1 << bit))
133         for (port = 0; port < 6; port++)
134            data |= input_port_read(machine, bitnames[port]) & (0x01 << bit) ? 0x01 << port : 0x00;
135   return data;
136}
137
138READ8_HANDLER( kp_r )
139{
140   return  keypad_r(space->machine);
141}
142
143READ8_HANDLER( status_flag_r )
144{
145   micronic_state *state = (micronic_state *)space->machine->driver_data;
146   return  state->status_flag;
147}
148
149WRITE8_HANDLER( status_flag_w )
150{
151   micronic_state *state = (micronic_state *)space->machine->driver_data;
152   state->status_flag = data;
153}
154
155WRITE8_HANDLER( kp_matrix_w )
156{
157   micronic_state *state = (micronic_state *)space->machine->driver_data;
158   state->kp_matrix = data;
159}
160
161WRITE8_HANDLER( beep_w )
162{
163   micronic_state *state = (micronic_state *)space->machine->driver_data;
164   UINT16 frequency = 0;
165
166   beep_set_state(state->speaker, (data) ? 1 : 0);
167
168   switch(data)
169   {
170      case 0x00:      frequency = 0;      break;
171      case 0x01:      frequency = 4000;   break;
172      case 0x02:      frequency = 2000;   break;
173      case 0x03:      frequency = 1333;   break;
174      case 0x04:      frequency = 1000;   break;
175      case 0x05:      frequency = 800;   break;
176      case 0x06:      frequency = 667;   break;
177      case 0x07:      frequency = 571;   break;
178      case 0x08:      frequency = 500;   break;
179      case 0x09:      frequency = 444;   break;
180      case 0x0a:      frequency = 400;   break;
181      case 0x0b:      frequency = 364;   break;
182      case 0x0c:      frequency = 333;   break;
183      case 0x0d:      frequency = 308;   break;
184      case 0x0e:      frequency = 286;   break;
185      case 0x0f:      frequency = 267;   break;
186   }
187
188   beep_set_frequency(state->speaker, frequency);
189}
190
191READ8_HANDLER( irq_flag_r )
192{
193   return (input_port_read(space->machine, "BACKBATTERY")<<4) | (input_port_read(space->machine, "MAINBATTERY")<<3) | (keypad_r(space->machine) ? 0 : 1);
194}
195
196WRITE8_HANDLER( bank_select_w )
197{
198   if (data < 2)
199   {
200      memory_set_bank(space->machine, "bank1", data);
201      memory_unmap_write(cputag_get_address_space(space->machine, Z80_TAG, ADDRESS_SPACE_PROGRAM), 0x0000, 0x7fff, 0, 0);
202   }
203   else
204   {
205      memory_set_bank(space->machine, "bank1", (data < 9) ? data : 8);
206      memory_install_write_bank(cputag_get_address_space(space->machine, Z80_TAG, ADDRESS_SPACE_PROGRAM), 0x0000, 0x7fff, 0, 0, "bank1");
207   }
208}
209
210WRITE8_HANDLER( lcd_contrast_w )
211{
212   micronic_state *state = (micronic_state *)space->machine->driver_data;
213
214   state->lcd_contrast = data;
215}
216
217
218/***************************************************************************
219    RTC-146818
220***************************************************************************/
221
222void set_146818_periodic_irq(running_machine *machine, UINT8 data)
223{
224   micronic_state *state = (micronic_state *)machine->driver_data;
225
226   attotime timer_per = ATTOTIME_IN_SEC(0);
227
228   switch(data & 0xf)
229   {
230      case 0:      timer_per = ATTOTIME_IN_NSEC(0);            break;
231      case 1:      timer_per = ATTOTIME_IN_NSEC((data & 0x20) ? 30517 : 3906250);   break;
232      case 2:      timer_per = ATTOTIME_IN_NSEC((data & 0x20) ? 61035 : 7812500);   break;
233      case 3:      timer_per = ATTOTIME_IN_NSEC(122070);         break;
234      case 4:      timer_per = ATTOTIME_IN_NSEC(244141);         break;
235      case 5:      timer_per = ATTOTIME_IN_NSEC(488281);         break;
236      case 6:      timer_per = ATTOTIME_IN_NSEC(976562);         break;
237      case 7:      timer_per = ATTOTIME_IN_NSEC(1953125);         break;
238      case 8:      timer_per = ATTOTIME_IN_NSEC(3906250);         break;
239      case 9:      timer_per = ATTOTIME_IN_NSEC(7812500);         break;
240      case 10:   timer_per = ATTOTIME_IN_USEC(15625);         break;
241      case 11:   timer_per = ATTOTIME_IN_USEC(31250);         break;
242      case 12:   timer_per = ATTOTIME_IN_USEC(62500);         break;
243      case 13:   timer_per = ATTOTIME_IN_USEC(62500);         break;
244      case 14:   timer_per = ATTOTIME_IN_MSEC(250);            break;
245      case 15:   timer_per = ATTOTIME_IN_MSEC(500);            break;
246   }
247
248   timer_adjust_periodic(state->rtc_periodic_irq, timer_per, 0, timer_per);
249}
250
251WRITE8_HANDLER( rtc_address_w )
252{
253   micronic_state *state = (micronic_state *)space->machine->driver_data;
254   state->rtc_address = data;
255
256   mc146818_port_w(space, 0, data);
257}
258
259READ8_HANDLER( rtc_data_r )
260{
261   micronic_state *state = (micronic_state *)space->machine->driver_data;
262   UINT8 data = 0;
263
264   switch(state->rtc_address & 0x3f)
265   {
266      case 0x0c:
267         data = state->irq_flags | mc146818_port_r(space, 1);
268         state->irq_flags = 0;
269         break;
270      default:
271         data = mc146818_port_r(space, 1);
272   }
273
274   return data;
275}
276
277WRITE8_HANDLER( rtc_data_w )
278{
279   micronic_state *state = (micronic_state *)space->machine->driver_data;
280
281   mc146818_port_w(space, 1, data);
282
283   switch(state->rtc_address & 0x3f)
284   {
285      case 0x0a:
286         set_146818_periodic_irq(space->machine, data);
287
288         break;
289      case 0x0b:
290         state->periodic_irq = (data & 0x40) ? 1 : 0;
291   }
292}
293
294static TIMER_CALLBACK( rtc_periodic_irq )
295{
296   micronic_state *state = (micronic_state *)machine->driver_data;
297
298   if (state->periodic_irq)
299      cputag_set_input_line(machine, Z80_TAG, 0, HOLD_LINE);
300
301   state->irq_flags =  (state->periodic_irq<<7) | 0x40;
302}
303
304/***************************************************************************
305    Machine
306***************************************************************************/
307
113308static ADDRESS_MAP_START(micronic_mem, ADDRESS_SPACE_PROGRAM, 8)
114309   ADDRESS_MAP_UNMAP_HIGH
115   AM_RANGE(0x0000, 0xffff) AM_ROM
310   AM_RANGE(0x0000, 0x7fff) AM_RAMBANK("bank1")
311   AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE_MEMBER(micronic_state, ram)
116312ADDRESS_MAP_END
117313
118314static ADDRESS_MAP_START(micronic_io, ADDRESS_SPACE_IO, 8)
315   ADDRESS_MAP_GLOBAL_MASK (0xff)
316
317   /* keypad */
318   AM_RANGE(0x00, 0x00) AM_READ(kp_r)
319   AM_RANGE(0x02, 0x02) AM_WRITE(kp_matrix_w)
320
321   /* hd61830 */
119322   AM_RANGE(0x03, 0x03) AM_DEVREADWRITE(HD61830_TAG, hd61830_data_r, hd61830_data_w)
120323   AM_RANGE(0x23, 0x23) AM_DEVREADWRITE(HD61830_TAG, hd61830_status_r, hd61830_control_w)
324
325   /* rtc-146818 */
326   AM_RANGE(0x08, 0x08) AM_WRITE(rtc_address_w)
327   AM_RANGE(0x28, 0x28) AM_READWRITE(rtc_data_r, rtc_data_w)
328
329   /* sound */
330   AM_RANGE(0x2b, 0x2b) AM_WRITE(beep_w)
331
332   /* basic machine */
333   AM_RANGE(0x05, 0x05) AM_READ(irq_flag_r)
334   AM_RANGE(0x47, 0x47) AM_WRITE(bank_select_w)
335   AM_RANGE(0x46, 0x46) AM_WRITE(lcd_contrast_w)
336   AM_RANGE(0x48, 0x48) AM_WRITE(status_flag_w)
337   AM_RANGE(0x49, 0x49) AM_READ(status_flag_r)
121338ADDRESS_MAP_END
122339
123340/* Input ports */
124341static INPUT_PORTS_START( micronic )
342
343   PORT_START("MAINBATTERY")
344      PORT_CONFNAME( 0x01, 0x01, "Main Battery Status" )
345      PORT_CONFSETTING( 0x01, DEF_STR( Normal ) )
346      PORT_CONFSETTING( 0x00, "Low Battery" )
347
348   PORT_START("BACKBATTERY")
349      PORT_CONFNAME( 0x01, 0x01, "Backup Battery Status" )
350      PORT_CONFSETTING( 0x01, DEF_STR( Normal ) )
351      PORT_CONFSETTING( 0x00, "Low Battery" )
352
353   PORT_START("BIT0")
354      PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("MODE") PORT_CODE(KEYCODE_EQUALS)
355      PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("A (") PORT_CODE(KEYCODE_A)
356      PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("B )") PORT_CODE(KEYCODE_B)
357      PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("2nd") PORT_CODE(KEYCODE_LSHIFT)
358      PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("U 1") PORT_CODE(KEYCODE_1)
359      PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("BACKSPACE") PORT_CODE(KEYCODE_BACKSPACE)
360
361   PORT_START("BIT1")
362      PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("C") PORT_CODE(KEYCODE_C)
363      PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("D DEL") PORT_CODE(KEYCODE_D)
364      PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("E #") PORT_CODE(KEYCODE_E)
365      PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("F &") PORT_CODE(KEYCODE_F)
366      PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("V 2") PORT_CODE(KEYCODE_2)
367      PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("SPACE 0") PORT_CODE(KEYCODE_0)
368
369   PORT_START("BIT2")
370      PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("G +") PORT_CODE(KEYCODE_G)
371      PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("H /") PORT_CODE(KEYCODE_H)
372      PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("I ,") PORT_CODE(KEYCODE_I)
373      PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("J ?") PORT_CODE(KEYCODE_J)
374      PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("W 3") PORT_CODE(KEYCODE_3)
375      PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("NO") PORT_CODE(KEYCODE_PGUP)
376
377   PORT_START("BIT3")
378      PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("K -") PORT_CODE(KEYCODE_K)
379      PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("L *") PORT_CODE(KEYCODE_L)
380      PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("M .") PORT_CODE(KEYCODE_M)
381      PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("N Z") PORT_CODE(KEYCODE_Z)
382      PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER)
383      PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("YES") PORT_CODE(KEYCODE_PGDN)
384
385   PORT_START("BIT4")
386      PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("O 7") PORT_CODE(KEYCODE_7)
387      PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("P 8") PORT_CODE(KEYCODE_8)
388      PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("Q 9") PORT_CODE(KEYCODE_9)
389      PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("DEPT") PORT_CODE(KEYCODE_R)
390
391   PORT_START("BIT5")
392      PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("R 4") PORT_CODE(KEYCODE_4)
393      PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("S 5") PORT_CODE(KEYCODE_5)
394      PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("T 6") PORT_CODE(KEYCODE_6)
395      PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("END") PORT_CODE(KEYCODE_END)
125396INPUT_PORTS_END
126397
398static NVRAM_HANDLER( micronic )
399{
400   micronic_state *state = (micronic_state *)machine->driver_data;
401   UINT8 reg_a = 0, reg_b = 0;
402
403   if (read_or_write)
404   {
405      mame_fwrite(file, state->ram, 0x8000);
406      mame_fwrite(file, messram_get_ptr(devtag_get_device(machine, "messram")), 224*1024);
407      mc146818_save_stream(file);
408   }
409   else
410   {
411      if (file)
412      {
413         mame_fread(file, state->ram, 0x8000);
414         mame_fread(file, messram_get_ptr(devtag_get_device(machine, "messram")), 224*1024);
415         mc146818_load_stream(file);
416
417         /* reload register A and B for restore the periodic irq state */
418         mame_fseek(file, 0x4000a, SEEK_SET);
419         mame_fread(file, &reg_a, 0x01);
420         mame_fread(file, &reg_b, 0x01);
421
422         set_146818_periodic_irq(machine, reg_a);
423         state->periodic_irq = (reg_b & 0x40) ? 1 : 0;
424         state->status_flag = 0x01;
425      }
426      else
427         state->status_flag = 0;
428   }
429}
430
127431static PALETTE_INIT( micronic )
128432{
129433   palette_set_color(machine, 0, MAKE_RGB(138, 146, 148));
r8354r8355
149453
150454   /* find devices */
151455   state->hd61830 = devtag_get_device(machine, HD61830_TAG);
456   state->speaker = devtag_get_device(machine, "beep");
152457
458   /* ROM banks */
459   memory_configure_bank(machine, "bank1", 0x00, 0x02, memory_region(machine, Z80_TAG), 0x10000);
460
461   /* RAM banks */
462   memory_configure_bank(machine, "bank1", 0x02, 0x07, messram_get_ptr(devtag_get_device(machine, "messram")), 0x8000);
463
464   state->rtc_periodic_irq = timer_alloc(machine, rtc_periodic_irq, 0);
465
466   mc146818_init(machine, MC146818_IGNORE_CENTURY);
467
153468   /* register for state saving */
154469//  state_save_register_global(machine, state->);
155470}
156471
472
473static MACHINE_RESET( micronic )
474{
475   memory_set_bank(machine, "bank1", 0);
476   memory_unmap_write(cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM), 0x0000, 0x7fff, 0, 0);
477}
478
157479static MACHINE_DRIVER_START( micronic )
158480   MDRV_DRIVER_DATA(micronic_state)
159481
160482   /* basic machine hardware */
161    MDRV_CPU_ADD(Z80_TAG, Z80, 4000000)
483    MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_3_579545MHz)
162484    MDRV_CPU_PROGRAM_MAP(micronic_mem)
163485    MDRV_CPU_IO_MAP(micronic_io)
164486
165487    MDRV_MACHINE_START(micronic)
488   MDRV_MACHINE_RESET(micronic)
166489
167490    /* video hardware */
168491   MDRV_SCREEN_ADD(SCREEN_TAG, LCD)
169492   MDRV_SCREEN_REFRESH_RATE(80)
170493   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
171   MDRV_SCREEN_SIZE(160, 64)
172   MDRV_SCREEN_VISIBLE_AREA(0, 160-1, 0, 64-1)
494   MDRV_SCREEN_SIZE(120, 64)   //6x20, 8x8
495   MDRV_SCREEN_VISIBLE_AREA(0, 120-1, 0, 64-1)
173496
174497   MDRV_DEFAULT_LAYOUT(layout_lcd)
175498
r8354r8355
180503    MDRV_VIDEO_UPDATE(micronic)
181504
182505   MDRV_HD61830_ADD(HD61830_TAG, XTAL_4_9152MHz/2/2, SCREEN_TAG)
506
507   /* sound hardware */
508   MDRV_SPEAKER_STANDARD_MONO( "mono" )
509   MDRV_SOUND_ADD( "beep", BEEP, 0 )
510   MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
511
512   /* ram banks */
513   MDRV_RAM_ADD("messram")
514   MDRV_RAM_DEFAULT_SIZE("224K")
515
516   MDRV_NVRAM_HANDLER(micronic)
517
183518MACHINE_DRIVER_END
184519
185520/* ROM definition */
186521ROM_START( micronic )
187522    ROM_REGION( 0x18000, Z80_TAG, 0 )
188   ROM_LOAD( "micron1.bin", 0x0000, 0x8000, CRC(5632c8b7) SHA1(d1c9cf691848e9125f9ea352e4ffa41c288f3e29))
189   ROM_LOAD( "micron2.bin", 0x8000, 0x8000, CRC(dc8e7341) SHA1(927dddb3914a50bb051256d126a047a29eff7c65))
190   ROM_LOAD( "monitor2.bin", 0x10000, 0x8000, CRC(c6ae2bbf) SHA1(1f2e3a3d4720a8e1bb38b37f4ab9e0e32676d030))
523   ROM_SYSTEM_BIOS(0, "v228", "Micronic 1000")
524   ROMX_LOAD( "micron1.bin", 0x0000, 0x8000, CRC(5632c8b7) SHA1(d1c9cf691848e9125f9ea352e4ffa41c288f3e29), ROM_BIOS(1))
525   ROMX_LOAD( "micron2.bin", 0x10000, 0x8000, CRC(dc8e7341) SHA1(927dddb3914a50bb051256d126a047a29eff7c65), ROM_BIOS(1))
526   ROM_SYSTEM_BIOS(1, "test", "Micronic 1000 LCD monitor")
527   ROMX_LOAD( "monitor2.bin", 0x0000, 0x8000, CRC(c6ae2bbf) SHA1(1f2e3a3d4720a8e1bb38b37f4ab9e0e32676d030), ROM_BIOS(2))
191528ROM_END
192529
193530/* Driver */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team