trunk/src/mess/drivers/smc777.c
| r20264 | r20265 | |
| 38 | 38 | { } |
| 39 | 39 | |
| 40 | 40 | optional_device<sn76489a_device> m_sn; |
| 41 | |
| 42 | UINT8 *m_ipl_rom; |
| 43 | UINT8 *m_work_ram; |
| 44 | UINT8 *m_vram; |
| 45 | UINT8 *m_attr; |
| 46 | UINT8 *m_gvram; |
| 47 | UINT8 *m_pcg; |
| 48 | |
| 41 | 49 | UINT16 m_cursor_addr; |
| 42 | 50 | UINT16 m_cursor_raster; |
| 43 | 51 | UINT8 m_keyb_press; |
| r20264 | r20265 | |
| 107 | 115 | { |
| 108 | 116 | int x,y,yi; |
| 109 | 117 | UINT16 count; |
| 110 | | UINT8 *vram = machine().root_device().memregion("vram")->base(); |
| 111 | | UINT8 *attr = machine().root_device().memregion("attr")->base(); |
| 112 | | UINT8 *gram = memregion("fbuf")->base(); |
| 113 | | UINT8 *gfx_data = machine().root_device().memregion("pcg")->base(); |
| 114 | | |
| 115 | 118 | int x_width; |
| 116 | 119 | |
| 117 | 120 | bitmap.fill(machine().pens[m_backdrop_pen], cliprect); |
| r20264 | r20265 | |
| 128 | 131 | { |
| 129 | 132 | UINT16 color; |
| 130 | 133 | |
| 131 | | color = (gram[count] & 0xf0) >> 4; |
| 134 | color = (m_gvram[count] & 0xf0) >> 4; |
| 132 | 135 | /* todo: clean this up! */ |
| 133 | 136 | if(x_width == 2) |
| 134 | 137 | { |
| r20264 | r20265 | |
| 140 | 143 | bitmap.pix16(y+yi+CRTC_MIN_Y, x*4+1+CRTC_MIN_X) = machine().pens[color]; |
| 141 | 144 | } |
| 142 | 145 | |
| 143 | | color = (gram[count] & 0x0f) >> 0; |
| 146 | color = (m_gvram[count] & 0x0f) >> 0; |
| 144 | 147 | if(x_width == 2) |
| 145 | 148 | { |
| 146 | 149 | bitmap.pix16(y+yi+CRTC_MIN_Y, x*2+1+CRTC_MIN_X) = machine().pens[color]; |
| r20264 | r20265 | |
| 171 | 174 | --xx x--- bg color (00 transparent, 01 white, 10 black, 11 complementary to fg color |
| 172 | 175 | ---- -xxx fg color |
| 173 | 176 | */ |
| 174 | | int tile = vram[count]; |
| 175 | | int color = attr[count] & 7; |
| 176 | | int bk_color = (attr[count] & 0x18) >> 3; |
| 177 | | int blink = attr[count] & 0x40; |
| 177 | int tile = m_vram[count]; |
| 178 | int color = m_attr[count] & 7; |
| 179 | int bk_color = (m_attr[count] & 0x18) >> 3; |
| 180 | int blink = m_attr[count] & 0x40; |
| 178 | 181 | int xi; |
| 179 | 182 | int bk_pen; |
| 180 | 183 | //int bk_struct[4] = { -1, 0x10, 0x11, (color & 7) ^ 8 }; |
| r20264 | r20265 | |
| 199 | 202 | { |
| 200 | 203 | int pen; |
| 201 | 204 | |
| 202 | | pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? (color) : bk_pen; |
| 205 | pen = ((m_pcg[tile*8+yi]>>(7-xi)) & 1) ? (color) : bk_pen; |
| 203 | 206 | |
| 204 | 207 | if (pen != -1) |
| 205 | 208 | bitmap.pix16(y*8+CRTC_MIN_Y+yi, x*8+CRTC_MIN_X+xi) = machine().pens[pen]; |
| r20264 | r20265 | |
| 261 | 264 | |
| 262 | 265 | READ8_MEMBER(smc777_state::smc777_vram_r) |
| 263 | 266 | { |
| 264 | | UINT8 *vram = memregion("vram")->base(); |
| 265 | 267 | UINT16 vram_index; |
| 266 | 268 | |
| 267 | 269 | vram_index = ((offset & 0x0007) << 8); |
| 268 | 270 | vram_index |= ((offset & 0xff00) >> 8); |
| 269 | 271 | |
| 270 | | return vram[vram_index]; |
| 272 | return m_vram[vram_index]; |
| 271 | 273 | } |
| 272 | 274 | |
| 273 | 275 | READ8_MEMBER(smc777_state::smc777_attr_r) |
| 274 | 276 | { |
| 275 | | UINT8 *attr = memregion("attr")->base(); |
| 276 | 277 | UINT16 vram_index; |
| 277 | 278 | |
| 278 | 279 | vram_index = ((offset & 0x0007) << 8); |
| 279 | 280 | vram_index |= ((offset & 0xff00) >> 8); |
| 280 | 281 | |
| 281 | | return attr[vram_index]; |
| 282 | return m_attr[vram_index]; |
| 282 | 283 | } |
| 283 | 284 | |
| 284 | 285 | READ8_MEMBER(smc777_state::smc777_pcg_r) |
| 285 | 286 | { |
| 286 | | UINT8 *pcg = memregion("pcg")->base(); |
| 287 | 287 | UINT16 vram_index; |
| 288 | 288 | |
| 289 | 289 | vram_index = ((offset & 0x0007) << 8); |
| 290 | 290 | vram_index |= ((offset & 0xff00) >> 8); |
| 291 | 291 | |
| 292 | | return pcg[vram_index]; |
| 292 | return m_pcg[vram_index]; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | WRITE8_MEMBER(smc777_state::smc777_vram_w) |
| 296 | 296 | { |
| 297 | | UINT8 *vram = memregion("vram")->base(); |
| 298 | 297 | UINT16 vram_index; |
| 299 | 298 | |
| 300 | 299 | vram_index = ((offset & 0x0007) << 8); |
| 301 | 300 | vram_index |= ((offset & 0xff00) >> 8); |
| 302 | 301 | |
| 303 | | vram[vram_index] = data; |
| 302 | m_vram[vram_index] = data; |
| 304 | 303 | } |
| 305 | 304 | |
| 306 | 305 | WRITE8_MEMBER(smc777_state::smc777_attr_w) |
| 307 | 306 | { |
| 308 | | UINT8 *attr = memregion("attr")->base(); |
| 309 | 307 | UINT16 vram_index; |
| 310 | 308 | |
| 311 | 309 | vram_index = ((offset & 0x0007) << 8); |
| 312 | 310 | vram_index |= ((offset & 0xff00) >> 8); |
| 313 | 311 | |
| 314 | | attr[vram_index] = data; |
| 312 | m_attr[vram_index] = data; |
| 315 | 313 | } |
| 316 | 314 | |
| 317 | 315 | WRITE8_MEMBER(smc777_state::smc777_pcg_w) |
| 318 | 316 | { |
| 319 | | UINT8 *pcg = memregion("pcg")->base(); |
| 320 | 317 | UINT16 vram_index; |
| 321 | 318 | |
| 322 | 319 | vram_index = ((offset & 0x0007) << 8); |
| 323 | 320 | vram_index |= ((offset & 0xff00) >> 8); |
| 324 | 321 | |
| 325 | | pcg[vram_index] = data; |
| 322 | m_pcg[vram_index] = data; |
| 326 | 323 | |
| 327 | 324 | machine().gfx[0]->mark_dirty(vram_index >> 3); |
| 328 | 325 | } |
| 329 | 326 | |
| 330 | 327 | READ8_MEMBER(smc777_state::smc777_fbuf_r) |
| 331 | 328 | { |
| 332 | | UINT8 *fbuf = memregion("fbuf")->base(); |
| 333 | 329 | UINT16 vram_index; |
| 334 | 330 | |
| 335 | 331 | vram_index = ((offset & 0x007f) << 8); |
| 336 | 332 | vram_index |= ((offset & 0xff00) >> 8); |
| 337 | 333 | |
| 338 | | return fbuf[vram_index]; |
| 334 | return m_gvram[vram_index]; |
| 339 | 335 | } |
| 340 | 336 | |
| 341 | 337 | WRITE8_MEMBER(smc777_state::smc777_fbuf_w) |
| 342 | 338 | { |
| 343 | | UINT8 *fbuf = memregion("fbuf")->base(); |
| 344 | 339 | UINT16 vram_index; |
| 345 | 340 | |
| 346 | 341 | vram_index = ((offset & 0x00ff) << 8); |
| 347 | 342 | vram_index |= ((offset & 0xff00) >> 8); |
| 348 | 343 | |
| 349 | | fbuf[vram_index] = data; |
| 344 | m_gvram[vram_index] = data; |
| 350 | 345 | } |
| 351 | 346 | |
| 352 | 347 | |
| r20264 | r20265 | |
| 579 | 574 | |
| 580 | 575 | READ8_MEMBER(smc777_state::smc777_mem_r) |
| 581 | 576 | { |
| 582 | | UINT8 *wram = memregion("wram")->base(); |
| 583 | | UINT8 *bios = memregion("bios")->base(); |
| 584 | 577 | UINT8 z80_r; |
| 585 | 578 | |
| 586 | 579 | if(m_raminh_prefetch != 0xff) //do the bankswitch AFTER that the prefetch instruction is executed (FIXME: this is an hackish implementation) |
| r20264 | r20265 | |
| 595 | 588 | } |
| 596 | 589 | |
| 597 | 590 | if(m_raminh == 1 && ((offset & 0xc000) == 0)) |
| 598 | | return bios[offset]; |
| 591 | return m_ipl_rom[offset]; |
| 599 | 592 | |
| 600 | | return wram[offset]; |
| 593 | return m_work_ram[offset]; |
| 601 | 594 | } |
| 602 | 595 | |
| 603 | 596 | WRITE8_MEMBER(smc777_state::smc777_mem_w) |
| 604 | 597 | { |
| 605 | | UINT8 *wram = memregion("wram")->base(); |
| 606 | | |
| 607 | | wram[offset] = data; |
| 598 | m_work_ram[offset] = data; |
| 608 | 599 | } |
| 609 | 600 | |
| 610 | 601 | READ8_MEMBER(smc777_state::smc777_irq_mask_r) |
| r20264 | r20265 | |
| 954 | 945 | } |
| 955 | 946 | } |
| 956 | 947 | |
| 948 | static const gfx_layout smc777_charlayout = |
| 949 | { |
| 950 | 8, 8, |
| 951 | 0x800 / 8, |
| 952 | 1, |
| 953 | { 0 }, |
| 954 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 955 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 956 | 8*8 |
| 957 | }; |
| 958 | |
| 957 | 959 | void smc777_state::machine_start() |
| 958 | 960 | { |
| 961 | m_ipl_rom = memregion("ipl")->base(); |
| 962 | m_work_ram = auto_alloc_array(machine(), UINT8, 0x10000); |
| 963 | m_vram = auto_alloc_array(machine(), UINT8, 0x800); |
| 964 | m_attr = auto_alloc_array(machine(), UINT8, 0x800); |
| 965 | m_gvram = auto_alloc_array(machine(), UINT8, 0x8000); |
| 966 | m_pcg = auto_alloc_array(machine(), UINT8, 0x800); |
| 967 | |
| 959 | 968 | beep_set_frequency(machine().device(BEEPER_TAG),300); //guesswork |
| 960 | 969 | beep_set_state(machine().device(BEEPER_TAG),0); |
| 970 | |
| 971 | state_save_register_global_pointer(machine(), m_work_ram, 0x10000); |
| 972 | state_save_register_global_pointer(machine(), m_vram, 0x800); |
| 973 | state_save_register_global_pointer(machine(), m_attr, 0x800); |
| 974 | state_save_register_global_pointer(machine(), m_gvram, 0x8000); |
| 975 | state_save_register_global_pointer(machine(), m_pcg, 0x800); |
| 976 | |
| 977 | machine().gfx[0] = auto_alloc(machine(), gfx_element(machine(), smc777_charlayout, (UINT8 *)m_pcg, 8, 0)); |
| 961 | 978 | } |
| 962 | 979 | |
| 963 | 980 | void smc777_state::machine_reset() |
| r20264 | r20265 | |
| 967 | 984 | m_raminh_prefetch = 0xff; |
| 968 | 985 | } |
| 969 | 986 | |
| 970 | | static const gfx_layout smc777_charlayout = |
| 971 | | { |
| 972 | | 8, 8, |
| 973 | | RGN_FRAC(1,1), |
| 974 | | 1, |
| 975 | | { 0 }, |
| 976 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 977 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 978 | | 8*8 |
| 979 | | }; |
| 980 | 987 | |
| 981 | | static GFXDECODE_START( smc777 ) |
| 982 | | GFXDECODE_ENTRY( "pcg", 0x0000, smc777_charlayout, 0, 8 ) |
| 983 | | GFXDECODE_END |
| 984 | | |
| 985 | 988 | static const mc6845_interface mc6845_intf = |
| 986 | 989 | { |
| 987 | 990 | "screen", /* screen we are acting on */ |
| r20264 | r20265 | |
| 1076 | 1079 | MCFG_CPU_IO_MAP(smc777_io) |
| 1077 | 1080 | MCFG_CPU_VBLANK_INT_DRIVER("screen", smc777_state, smc777_vblank_irq) |
| 1078 | 1081 | |
| 1079 | | |
| 1080 | 1082 | /* video hardware */ |
| 1081 | 1083 | MCFG_SCREEN_ADD("screen", RASTER) |
| 1082 | 1084 | MCFG_SCREEN_REFRESH_RATE(60) |
| r20264 | r20265 | |
| 1086 | 1088 | MCFG_SCREEN_UPDATE_DRIVER(smc777_state, screen_update_smc777) |
| 1087 | 1089 | |
| 1088 | 1090 | MCFG_PALETTE_LENGTH(SMC777_NUMPENS) |
| 1089 | | MCFG_GFXDECODE(smc777) |
| 1090 | 1091 | |
| 1091 | 1092 | MCFG_MC6845_ADD("crtc", H46505, MASTER_CLOCK/2, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 1092 | 1093 | |
| 1093 | | |
| 1094 | 1094 | MCFG_MB8876_ADD("fdc",smc777_mb8876_interface) |
| 1095 | 1095 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(smc777_floppy_interface) |
| 1096 | 1096 | MCFG_SOFTWARE_LIST_ADD("flop_list","smc777") |
| r20264 | r20265 | |
| 1109 | 1109 | |
| 1110 | 1110 | /* ROM definition */ |
| 1111 | 1111 | ROM_START( smc777 ) |
| 1112 | | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |
| 1113 | | |
| 1114 | 1112 | /* shadow ROM */ |
| 1115 | | ROM_REGION( 0x10000, "bios", ROMREGION_ERASEFF ) |
| 1113 | ROM_REGION( 0x10000, "ipl", ROMREGION_ERASEFF ) |
| 1116 | 1114 | ROM_SYSTEM_BIOS(0, "1st", "1st rev.") |
| 1117 | 1115 | ROMX_LOAD( "smcrom.dat", 0x0000, 0x4000, CRC(b2520d31) SHA1(3c24b742c38bbaac85c0409652ba36e20f4687a1), ROM_BIOS(1)) |
| 1118 | 1116 | ROM_SYSTEM_BIOS(1, "2nd", "2nd rev.") |
| r20264 | r20265 | |
| 1120 | 1118 | |
| 1121 | 1119 | ROM_REGION( 0x800, "mcu", ROMREGION_ERASEFF ) |
| 1122 | 1120 | ROM_LOAD( "i80xx", 0x000, 0x800, NO_DUMP ) // keyboard mcu, needs decapping |
| 1123 | | |
| 1124 | | ROM_REGION( 0x10000, "wram", ROMREGION_ERASE00 ) |
| 1125 | | |
| 1126 | | ROM_REGION( 0x800, "vram", ROMREGION_ERASE00 ) |
| 1127 | | |
| 1128 | | ROM_REGION( 0x800, "attr", ROMREGION_ERASE00 ) |
| 1129 | | |
| 1130 | | ROM_REGION( 0x800, "pcg", ROMREGION_ERASE00 ) |
| 1131 | | |
| 1132 | | ROM_REGION( 0x8000,"fbuf", ROMREGION_ERASE00 ) |
| 1133 | 1121 | ROM_END |
| 1134 | 1122 | |
| 1135 | 1123 | /* Driver */ |