src/mess/video/hd61830.c
| r8354 | r8355 | |
| 60 | 60 | typedef struct _hd61830_t hd61830_t; |
| 61 | 61 | struct _hd61830_t |
| 62 | 62 | { |
| 63 | const address_space *space; /* memory space */ |
| 64 | |
| 63 | 65 | int bf; /* busy flag */ |
| 64 | 66 | |
| 65 | 67 | UINT8 ir; /* instruction register */ |
| r8354 | r8355 | |
| 75 | 77 | int nx; /* number of time divisions */ |
| 76 | 78 | int cp; /* cursor position */ |
| 77 | 79 | |
| 80 | int blink; /* blinking */ |
| 81 | |
| 78 | 82 | /* devices */ |
| 79 | 83 | screen_device *screen; |
| 80 | 84 | |
| r8354 | r8355 | |
| 161 | 165 | READ8_DEVICE_HANDLER( hd61830_data_r ) |
| 162 | 166 | { |
| 163 | 167 | hd61830_t *hd61830 = get_safe_token(device); |
| 164 | | const address_space *space = cputag_get_address_space(device->machine, HD61830_TAG, ADDRESS_SPACE_PROGRAM); |
| 165 | 168 | UINT8 data = hd61830->dor; |
| 166 | 169 | |
| 167 | 170 | if (LOG) logerror("HD61380 '%s' Display Data Read %02x\n", device->tag(), hd61830->dor); |
| 168 | 171 | |
| 169 | | hd61830->dor = memory_read_byte(space, hd61830->cac); |
| 172 | hd61830->dor = memory_read_byte(hd61830->space, hd61830->cac); |
| 170 | 173 | |
| 171 | 174 | hd61830->cac++; |
| 172 | 175 | |
| r8354 | r8355 | |
| 180 | 183 | WRITE8_DEVICE_HANDLER( hd61830_data_w ) |
| 181 | 184 | { |
| 182 | 185 | hd61830_t *hd61830 = get_safe_token(device); |
| 183 | | const address_space *space = cputag_get_address_space(device->machine, HD61830_TAG, ADDRESS_SPACE_PROGRAM); |
| 184 | 186 | switch (hd61830->ir) |
| 185 | 187 | { |
| 186 | 188 | case HD61830_INSTRUCTION_MODE_CONTROL: |
| r8354 | r8355 | |
| 255 | 257 | break; |
| 256 | 258 | |
| 257 | 259 | case HD61830_INSTRUCTION_DISPLAY_DATA_WRITE: |
| 258 | | memory_write_byte(space, hd61830->cac, data); |
| 260 | memory_write_byte(hd61830->space, hd61830->cac, data); |
| 259 | 261 | |
| 260 | 262 | 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); |
| 261 | 263 | |
| r8354 | r8355 | |
| 265 | 267 | case HD61830_INSTRUCTION_CLEAR_BIT: |
| 266 | 268 | { |
| 267 | 269 | int nb = data & 0x07; |
| 268 | | UINT8 data_ = memory_read_byte(space, hd61830->cac); |
| 270 | UINT8 data_ = memory_read_byte(hd61830->space, hd61830->cac); |
| 269 | 271 | |
| 270 | 272 | data_ &= ~(2 << nb); |
| 271 | 273 | |
| 272 | 274 | if (LOG) logerror("HD61380 '%s' Clear Bit %u at %04x\n", device->tag(), nb + 1, hd61830->cac); |
| 273 | 275 | |
| 274 | | memory_write_byte(space, hd61830->cac, data_); |
| 276 | memory_write_byte(hd61830->space, hd61830->cac, data_); |
| 275 | 277 | |
| 276 | 278 | hd61830->cac++; |
| 277 | 279 | } |
| r8354 | r8355 | |
| 280 | 282 | case HD61830_INSTRUCTION_SET_BIT: |
| 281 | 283 | { |
| 282 | 284 | int nb = data & 0x07; |
| 283 | | UINT8 data_ = memory_read_byte(space, hd61830->cac); |
| 285 | UINT8 data_ = memory_read_byte(hd61830->space, hd61830->cac); |
| 284 | 286 | |
| 285 | 287 | data_ |= 2 << nb; |
| 286 | 288 | |
| 287 | 289 | if (LOG) logerror("HD61380 '%s' Set Bit %u at %04x\n", device->tag(), nb + 1, hd61830->cac); |
| 288 | 290 | |
| 289 | | memory_write_byte(space, hd61830->cac, data_); |
| 291 | memory_write_byte(hd61830->space, hd61830->cac, data_); |
| 290 | 292 | |
| 291 | 293 | hd61830->cac++; |
| 292 | 294 | } |
| r8354 | r8355 | |
| 309 | 311 | { |
| 310 | 312 | hd61830_t *hd61830 = get_safe_token(device); |
| 311 | 313 | int sx, x; |
| 312 | | const address_space *space = cputag_get_address_space(device->machine, HD61830_TAG, ADDRESS_SPACE_PROGRAM); |
| 313 | 314 | |
| 314 | 315 | for (sx = 0; sx < hd61830->hn; sx++) |
| 315 | 316 | { |
| 316 | | UINT8 data = memory_read_byte(space, ra++); |
| 317 | UINT8 data = memory_read_byte(hd61830->space, ra++); |
| 317 | 318 | |
| 318 | 319 | for (x = 0; x < hd61830->hp; x++) |
| 319 | 320 | { |
| r8354 | r8355 | |
| 346 | 347 | } |
| 347 | 348 | |
| 348 | 349 | /*------------------------------------------------- |
| 350 | draw_char - draw a char |
| 351 | -------------------------------------------------*/ |
| 352 | |
| 353 | static 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 | |
| 374 | static 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 | /*------------------------------------------------- |
| 349 | 418 | hd61830_update - update screen |
| 350 | 419 | -------------------------------------------------*/ |
| 351 | 420 | |
| r8354 | r8355 | |
| 359 | 428 | } |
| 360 | 429 | else |
| 361 | 430 | { |
| 362 | | logerror("HD61830 text mode not supported!\n"); |
| 431 | update_text(device, bitmap, cliprect); |
| 363 | 432 | } |
| 364 | 433 | } |
| 365 | 434 | |
| r8354 | r8355 | |
| 387 | 456 | |
| 388 | 457 | ROM_START( hd61830 ) |
| 389 | 458 | 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 */ |
| 391 | 461 | ROM_END |
| 392 | 462 | |
| 393 | 463 | /*------------------------------------------------- |
| r8354 | r8355 | |
| 411 | 481 | hd61830->screen = device->machine->device<screen_device>(config->screen_tag); |
| 412 | 482 | assert(hd61830->screen != NULL); |
| 413 | 483 | |
| 484 | hd61830->space = device_get_space(device, ADDRESS_SPACE_0); |
| 485 | |
| 414 | 486 | /* create the busy timer */ |
| 415 | 487 | hd61830->busy_timer = timer_alloc(device->machine, busy_tick, (void *)device); |
| 416 | 488 | |
| r8354 | r8355 | |
| 475 | 547 | } |
| 476 | 548 | } |
| 477 | 549 | |
| 478 | | DEFINE_LEGACY_DEVICE(HD61830, hd61830); |
| 550 | DEFINE_LEGACY_MEMORY_DEVICE(HD61830, hd61830); |
src/mess/drivers/micronic.c
| r8354 | r8355 | |
| 97 | 97 | |
| 98 | 98 | /* |
| 99 | 99 | |
| 100 | 06/2010 (Sandro Ronco) |
| 101 | |
| 102 | - ROM/RAM banking |
| 103 | - keypad input |
| 104 | - Periodic IRQ (RTC-146818) |
| 105 | - NVRAM |
| 106 | |
| 100 | 107 | TODO: |
| 101 | 108 | |
| 102 | 109 | - HD61830 text mode |
| 103 | | - everything else |
| 110 | - IR I/O port |
| 104 | 111 | |
| 112 | NOTE: |
| 113 | The display shows "TESTING..." for about 2 min before showing the information screen |
| 114 | |
| 105 | 115 | */ |
| 106 | 116 | |
| 107 | 117 | #include "emu.h" |
| r8354 | r8355 | |
| 109 | 119 | #include "cpu/z80/z80.h" |
| 110 | 120 | #include "video/hd61830.h" |
| 111 | 121 | #include "machine/mc146818.h" |
| 122 | #include "devices/messram.h" |
| 123 | #include "sound/beep.h" |
| 112 | 124 | |
| 125 | static 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 | |
| 138 | READ8_HANDLER( kp_r ) |
| 139 | { |
| 140 | return keypad_r(space->machine); |
| 141 | } |
| 142 | |
| 143 | READ8_HANDLER( status_flag_r ) |
| 144 | { |
| 145 | micronic_state *state = (micronic_state *)space->machine->driver_data; |
| 146 | return state->status_flag; |
| 147 | } |
| 148 | |
| 149 | WRITE8_HANDLER( status_flag_w ) |
| 150 | { |
| 151 | micronic_state *state = (micronic_state *)space->machine->driver_data; |
| 152 | state->status_flag = data; |
| 153 | } |
| 154 | |
| 155 | WRITE8_HANDLER( kp_matrix_w ) |
| 156 | { |
| 157 | micronic_state *state = (micronic_state *)space->machine->driver_data; |
| 158 | state->kp_matrix = data; |
| 159 | } |
| 160 | |
| 161 | WRITE8_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 | |
| 191 | READ8_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 | |
| 196 | WRITE8_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 | |
| 210 | WRITE8_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 | |
| 222 | void 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 | |
| 251 | WRITE8_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 | |
| 259 | READ8_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 | |
| 277 | WRITE8_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 | |
| 294 | static 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 | |
| 113 | 308 | static ADDRESS_MAP_START(micronic_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 114 | 309 | 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) |
| 116 | 312 | ADDRESS_MAP_END |
| 117 | 313 | |
| 118 | 314 | static 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 */ |
| 119 | 322 | AM_RANGE(0x03, 0x03) AM_DEVREADWRITE(HD61830_TAG, hd61830_data_r, hd61830_data_w) |
| 120 | 323 | 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) |
| 121 | 338 | ADDRESS_MAP_END |
| 122 | 339 | |
| 123 | 340 | /* Input ports */ |
| 124 | 341 | static 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) |
| 125 | 396 | INPUT_PORTS_END |
| 126 | 397 | |
| 398 | static 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, ®_a, 0x01); |
| 420 | mame_fread(file, ®_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 | |
| 127 | 431 | static PALETTE_INIT( micronic ) |
| 128 | 432 | { |
| 129 | 433 | palette_set_color(machine, 0, MAKE_RGB(138, 146, 148)); |
| r8354 | r8355 | |
| 149 | 453 | |
| 150 | 454 | /* find devices */ |
| 151 | 455 | state->hd61830 = devtag_get_device(machine, HD61830_TAG); |
| 456 | state->speaker = devtag_get_device(machine, "beep"); |
| 152 | 457 | |
| 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 | |
| 153 | 468 | /* register for state saving */ |
| 154 | 469 | // state_save_register_global(machine, state->); |
| 155 | 470 | } |
| 156 | 471 | |
| 472 | |
| 473 | static 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 | |
| 157 | 479 | static MACHINE_DRIVER_START( micronic ) |
| 158 | 480 | MDRV_DRIVER_DATA(micronic_state) |
| 159 | 481 | |
| 160 | 482 | /* basic machine hardware */ |
| 161 | | MDRV_CPU_ADD(Z80_TAG, Z80, 4000000) |
| 483 | MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_3_579545MHz) |
| 162 | 484 | MDRV_CPU_PROGRAM_MAP(micronic_mem) |
| 163 | 485 | MDRV_CPU_IO_MAP(micronic_io) |
| 164 | 486 | |
| 165 | 487 | MDRV_MACHINE_START(micronic) |
| 488 | MDRV_MACHINE_RESET(micronic) |
| 166 | 489 | |
| 167 | 490 | /* video hardware */ |
| 168 | 491 | MDRV_SCREEN_ADD(SCREEN_TAG, LCD) |
| 169 | 492 | MDRV_SCREEN_REFRESH_RATE(80) |
| 170 | 493 | 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) |
| 173 | 496 | |
| 174 | 497 | MDRV_DEFAULT_LAYOUT(layout_lcd) |
| 175 | 498 | |
| r8354 | r8355 | |
| 180 | 503 | MDRV_VIDEO_UPDATE(micronic) |
| 181 | 504 | |
| 182 | 505 | 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 | |
| 183 | 518 | MACHINE_DRIVER_END |
| 184 | 519 | |
| 185 | 520 | /* ROM definition */ |
| 186 | 521 | ROM_START( micronic ) |
| 187 | 522 | 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)) |
| 191 | 528 | ROM_END |
| 192 | 529 | |
| 193 | 530 | /* Driver */ |