src/mess/video/fmtowns.c
| r6609 | r6610 | |
| 2 | 2 | /* |
| 3 | 3 | * FM Towns video hardware |
| 4 | 4 | * |
| 5 | | * Resolution: from 320x200 to 640x400 |
| 5 | * Resolution: from 320x200 to 768x512 |
| 6 | 6 | * |
| 7 | 7 | * Up to two graphics layers |
| 8 | 8 | * |
| 9 | 9 | * Sprites |
| 10 | 10 | * |
| 11 | | * CRTC registers: |
| 12 | | * |
| 11 | * CRTC registers (16-bit): |
| 13 | 12 | * |
| 13 | * 0: HSync width 1 |
| 14 | * 1: HSync width 2 |
| 15 | * 4: HSync total |
| 16 | * 5: VSync width 1 |
| 17 | * 6: VSync width 2 |
| 18 | * 7: Equalising pulse accountable time (what?) |
| 19 | * 8: VSync total |
| 20 | * |
| 21 | * 9: |
| 22 | * 10: Graphic layer 0 horizontal start/end |
| 23 | * 11: |
| 24 | * 12: Graphic layer 1 horizontal start/end |
| 25 | * |
| 26 | * 13: |
| 27 | * 14: Graphic layer 0 vertical start/end |
| 28 | * 15: |
| 29 | * 16: Graphic layer 1 vertical start/end |
| 30 | * |
| 31 | * 17: Graphic layer 0 initial address? |
| 32 | * 18: Graphic layer 0 horizontal adjust |
| 33 | * 19: Graphic layer 0 field indirect address offset |
| 34 | * 20: Graphic layer 0 line indirect address offset |
| 35 | * |
| 36 | * 21-24: As above, but for Graphic layer 1 |
| 37 | * |
| 38 | * 28: Control register 0 |
| 39 | * VSync enable (bit 15) (blank display?) |
| 40 | * Scroll type (layer 0 = bit 4, layer 1 = bit 5) |
| 41 | * 0 = spherical scroll, 1 = cylindrical scroll |
| 42 | * |
| 43 | * 29: Control register 1 |
| 44 | * Dot clock (bits 1 and 0) |
| 45 | * 0x00 = 28.6363MHz |
| 46 | * 0x01 = 24.5454MHz |
| 47 | * 0x02 = 25.175MHz |
| 48 | * 0x03 = 21.0525MHz (default?) |
| 49 | * |
| 50 | * 30: Dummy register |
| 51 | * |
| 52 | * 31: Control register 2 |
| 53 | * |
| 54 | * Video registers: |
| 55 | * |
| 56 | * 0: Graphic layer(s) type: (others likely exist) |
| 57 | * bit 4 = 2 layers |
| 58 | * 0x0a: 1 layer, 256 colours |
| 59 | * 0x0f: 1 layer, highcolour |
| 60 | * 0x15: 2 layers, both 16 colours |
| 61 | * 0x17: 2 layers, highcolour, 16 colours |
| 62 | * 0x1d: 2 layers, 16 colours, highcolour |
| 63 | * 0x1f: 2 layers, both highcolour |
| 64 | * |
| 65 | * 1: Layer reverse (priority?) (bit 0) |
| 66 | * YM (bit 2) - unknown |
| 67 | * peltype (bits 4 and 5) |
| 68 | * |
| 14 | 69 | */ |
| 15 | 70 | |
| 16 | 71 | #include "driver.h" |
| r6609 | r6610 | |
| 18 | 73 | #include "devices/messram.h" |
| 19 | 74 | #include "includes/fmtowns.h" |
| 20 | 75 | |
| 76 | //#define CRTC_REG_DISP 1 |
| 77 | |
| 21 | 78 | static UINT8 towns_vram_wplane; |
| 22 | 79 | static UINT8 towns_vram_rplane; |
| 23 | 80 | static UINT8 towns_vram_page_sel; |
| r6609 | r6610 | |
| 26 | 83 | static UINT8 towns_palette_g[256]; |
| 27 | 84 | static UINT8 towns_palette_b[256]; |
| 28 | 85 | static UINT8 towns_degipal[8]; |
| 86 | static UINT8 towns_dpmd_flag; |
| 29 | 87 | static UINT8 towns_crtc_mix; |
| 30 | 88 | static UINT8 towns_crtc_sel; // selected CRTC register |
| 31 | 89 | static UINT16 towns_crtc_reg[32]; |
| 90 | static UINT8 towns_video_sel; // selected shifter register |
| 91 | static UINT8 towns_video_reg[2]; |
| 32 | 92 | static UINT8 towns_tvram_enable; |
| 33 | 93 | static UINT16 towns_kanji_offset; |
| 34 | 94 | static UINT8 towns_kanji_code_h; |
| r6609 | r6610 | |
| 41 | 101 | extern UINT32 towns_mainmem_enable; |
| 42 | 102 | extern UINT32 towns_ankcg_enable; |
| 43 | 103 | |
| 104 | void towns_update_video(running_machine* machine) |
| 105 | { |
| 106 | |
| 107 | } |
| 108 | |
| 44 | 109 | READ8_HANDLER( towns_gfx_high_r ) |
| 45 | 110 | { |
| 46 | 111 | return towns_gfxvram[offset]; |
| r6609 | r6610 | |
| 216 | 281 | * port 0x440-0x443 - CRTC |
| 217 | 282 | * 0x440 = register select |
| 218 | 283 | * 0x442/3 = register data (16-bit) |
| 284 | * 0x448 = shifter register select |
| 285 | * 0x44a = shifter register data (8-bit) |
| 219 | 286 | * |
| 220 | 287 | */ |
| 221 | 288 | READ8_HANDLER(towns_video_440_r) |
| r6609 | r6610 | |
| 230 | 297 | case 0x03: |
| 231 | 298 | logerror("CRTC: reading register %i (0x443) [%04x]\n",towns_crtc_sel,towns_crtc_reg[towns_crtc_sel]); |
| 232 | 299 | return (towns_crtc_reg[towns_crtc_sel] & 0xff00) >> 8; |
| 300 | case 0x08: |
| 301 | return towns_video_sel; |
| 302 | case 0x0a: |
| 303 | logerror("Video: reading register %i (0x44a) [%02x]\n",towns_video_sel,towns_video_reg[towns_video_sel]); |
| 304 | return towns_video_reg[towns_video_sel]; |
| 305 | case 0x0c: |
| 306 | if(towns_dpmd_flag != 0) |
| 307 | { |
| 308 | towns_dpmd_flag = 0; |
| 309 | return 0x80; |
| 310 | } |
| 311 | else |
| 312 | return 0x00; |
| 233 | 313 | default: |
| 234 | 314 | logerror("VID: read port %04x\n",offset+0x440); |
| 235 | 315 | } |
| r6609 | r6610 | |
| 253 | 333 | towns_crtc_reg[towns_crtc_sel] = |
| 254 | 334 | (towns_crtc_reg[towns_crtc_sel] & 0x00ff) | (data << 8); |
| 255 | 335 | break; |
| 336 | case 0x08: |
| 337 | towns_video_sel = data & 0x01; |
| 338 | break; |
| 339 | case 0x0a: |
| 340 | logerror("Video: writing register %i (0x44a) [%02x]\n",towns_video_sel,data); |
| 341 | towns_video_reg[towns_video_sel] = data; |
| 342 | break; |
| 256 | 343 | default: |
| 257 | 344 | logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x440); |
| 258 | 345 | } |
| r6609 | r6610 | |
| 266 | 353 | case 0x00: // 0x5c8 - disable TVRAM? |
| 267 | 354 | if(towns_tvram_enable != 0) |
| 268 | 355 | { |
| 269 | | towns_tvram_enable = 0; |
| 356 | //towns_tvram_enable = 0; |
| 270 | 357 | return 0x80; |
| 271 | 358 | } |
| 272 | 359 | else |
| r6609 | r6610 | |
| 344 | 431 | case 0x0e: |
| 345 | 432 | case 0x0f: |
| 346 | 433 | towns_degipal[offset-0x08] = data; |
| 434 | towns_dpmd_flag = 1; |
| 347 | 435 | break; |
| 348 | 436 | } |
| 349 | 437 | logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0xfd90); |
| r6609 | r6610 | |
| 366 | 454 | * Sprite RAM, low memory |
| 367 | 455 | * Writing to 0xc8xxx or 0xcaxxx activates TVRAM mode |
| 368 | 456 | * Writing to I/O port 0x5c8 disables TVRAM mode |
| 369 | | * (bit 7 returns high is TVRAM mode was previously active) |
| 457 | * (bit 7 returns high if TVRAM mode was previously active) |
| 370 | 458 | * |
| 371 | 459 | * In TVRAM mode: |
| 372 | 460 | * 0xc8000-0xc8fff: ASCII text (2 bytes each: ISO646 code, then attribute) |
| r6609 | r6610 | |
| 443 | 531 | |
| 444 | 532 | if(towns_vram_page_sel != 0) |
| 445 | 533 | off = 0x20000; |
| 446 | | for(y=0;y<480;y++) |
| 534 | for(y=0;y<400;y++) |
| 447 | 535 | { |
| 448 | 536 | // off = 0x50 * y; |
| 449 | 537 | for(x=0;x<640;x+=2) |
| r6609 | r6610 | |
| 533 | 621 | } |
| 534 | 622 | } |
| 535 | 623 | } |
| 536 | | |
| 624 | |
| 625 | #ifdef CRTC_REG_DISP |
| 626 | popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\nZOOM: %04x\nShifter: %02x %02x\nText=%i", |
| 627 | towns_crtc_reg[0],towns_crtc_reg[1],towns_crtc_reg[2],towns_crtc_reg[3], |
| 628 | towns_crtc_reg[4],towns_crtc_reg[5],towns_crtc_reg[6],towns_crtc_reg[7], |
| 629 | towns_crtc_reg[8], |
| 630 | towns_crtc_reg[9],towns_crtc_reg[10],towns_crtc_reg[11],towns_crtc_reg[12], |
| 631 | towns_crtc_reg[13],towns_crtc_reg[14],towns_crtc_reg[15],towns_crtc_reg[16], |
| 632 | towns_crtc_reg[27],towns_video_reg[0],towns_video_reg[1],towns_tvram_enable); |
| 633 | #endif |
| 634 | |
| 537 | 635 | return 0; |
| 538 | 636 | } |
| 539 | 637 | |
src/mess/drivers/fmtowns.c
| r6609 | r6610 | |
| 155 | 155 | static UINT8 towns_kb_output; // key output |
| 156 | 156 | static UINT8 towns_kb_extend; // extended key output |
| 157 | 157 | static emu_timer* towns_kb_timer; |
| 158 | static UINT8 towns_fm_irq_flag; |
| 158 | 159 | |
| 159 | 160 | static struct towns_cdrom_controller |
| 160 | 161 | { |
| r6609 | r6610 | |
| 698 | 699 | } |
| 699 | 700 | } |
| 700 | 701 | |
| 702 | // Sound/LED control (I/O port 0x4e8-0x4ef) |
| 703 | // R/O -- (0x4e9) FM IRQ flag (bit 0), PCM IRQ flag (bit 3) |
| 704 | // (0x4ea) PCM IRQ mask |
| 705 | // R/W -- (0x4eb) PCM IRQ flag |
| 706 | // W/O -- (0x4ec) LED control |
| 707 | static READ8_HANDLER(towns_sound_ctrl_r) |
| 708 | { |
| 709 | UINT8 ret = 0; |
| 710 | |
| 711 | switch(offset) |
| 712 | { |
| 713 | case 0x01: |
| 714 | if(towns_fm_irq_flag) |
| 715 | ret |= 0x01; |
| 716 | break; |
| 717 | default: |
| 718 | logerror("FM: unimplemented port 0x%04x read\n",offset + 0x4e8); |
| 719 | } |
| 720 | return ret; |
| 721 | } |
| 722 | |
| 723 | static WRITE8_HANDLER(towns_sound_ctrl_w) |
| 724 | { |
| 725 | // TODO: |
| 726 | } |
| 727 | |
| 701 | 728 | static READ32_HANDLER(towns_padport_r) |
| 702 | 729 | { |
| 703 | 730 | logerror("PADPORT: read mask %08x\n",mem_mask); |
| r6609 | r6610 | |
| 1498 | 1525 | { |
| 1499 | 1526 | const device_config* pic = devtag_get_device(device->machine,"pic8259_slave"); |
| 1500 | 1527 | if(irq) |
| 1528 | { |
| 1529 | towns_fm_irq_flag = 1; |
| 1501 | 1530 | pic8259_set_irq_line(pic,5,1); |
| 1531 | } |
| 1502 | 1532 | else |
| 1533 | { |
| 1534 | towns_fm_irq_flag = 0; |
| 1503 | 1535 | pic8259_set_irq_line(pic,5,0); |
| 1536 | } |
| 1504 | 1537 | } |
| 1505 | 1538 | |
| 1506 | 1539 | static PIC8259_SET_INT_LINE( towns_pic_irq ) |
| r6609 | r6610 | |
| 1628 | 1661 | AM_RANGE(0x04d4,0x04d7) AM_NOP // R/W -- (0x4d5) mute? |
| 1629 | 1662 | AM_RANGE(0x04d8,0x04df) AM_DEVREADWRITE8("fm",ym3438_r,ym3438_w,0x00ff00ff) |
| 1630 | 1663 | AM_RANGE(0x04e0,0x04e3) AM_NOP // R/W -- volume ports |
| 1631 | | AM_RANGE(0x04e8,0x04ef) AM_NOP // R/O -- (0x4e9) FM IRQ flag (bit 0), PCM IRQ flag (bit 3) |
| 1632 | | // (0x4ea) PCM IRQ mask |
| 1633 | | // R/W -- (0x4eb) PCM IRQ flag |
| 1634 | | // W/O -- (0x4ec) LED control |
| 1664 | AM_RANGE(0x04e8,0x04ef) AM_READWRITE8(towns_sound_ctrl_r,towns_sound_ctrl_w,0xffffffff) |
| 1635 | 1665 | AM_RANGE(0x04f0,0x04fb) AM_DEVWRITE8("pcm",rf5c68_w,0xffffffff) |
| 1636 | 1666 | // CRTC / Video |
| 1637 | 1667 | AM_RANGE(0x05c8,0x05cb) AM_READWRITE8(towns_video_5c8_r, towns_video_5c8_w, 0xffffffff) |
| r6609 | r6610 | |
| 1949 | 1979 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1950 | 1980 | |
| 1951 | 1981 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 1952 | | MDRV_SCREEN_SIZE(640, 480) |
| 1953 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 1982 | MDRV_SCREEN_SIZE(640, 400) |
| 1983 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 400-1) |
| 1954 | 1984 | MDRV_GFXDECODE(towns) |
| 1955 | 1985 | |
| 1956 | 1986 | /* sound hardware */ |