src/mess/machine/super80.c
| r9179 | r9180 | |
| 8 | 8 | #include "machine/ctronics.h" |
| 9 | 9 | #include "includes/super80.h" |
| 10 | 10 | |
| 11 | | /* Bits in shared variable: |
| 12 | | d5 cassette LED |
| 13 | | d4 super80v rom or pcg bankswitch (1=pcg ram, 0=char gen rom) |
| 14 | | d2 super80v video or colour bankswitch (1=video ram, 0=colour ram) |
| 15 | | d2 super80 screen off (=2mhz) or on (bursts of 2mhz at 50hz = 1mhz) */ |
| 16 | | |
| 17 | | UINT8 super80_shared=0xff; |
| 18 | | UINT8 *super80_colorram; |
| 19 | 11 | static running_device *super80_z80pio; |
| 20 | 12 | static running_device *super80_speaker; |
| 21 | 13 | static running_device *super80_cassette; |
| r9179 | r9180 | |
| 129 | 121 | { |
| 130 | 122 | static UINT8 int_sw=0; |
| 131 | 123 | UINT8 go_fast = 0; |
| 132 | | if (!(super80_shared & 4) || (!(input_port_read(machine, "CONFIG") & 2))) /* bit 2 of port F0 is low, OR user turned on config switch */ |
| 124 | super80_state *state = machine->driver_data<super80_state>(); |
| 125 | if (!(state->super80_shared & 4) || (!(input_port_read(machine, "CONFIG") & 2))) /* bit 2 of port F0 is low, OR user turned on config switch */ |
| 133 | 126 | go_fast++; |
| 134 | 127 | |
| 135 | 128 | /* code to slow down computer to 1 MHz by halting cpu on every second frame */ |
| r9179 | r9180 | |
| 200 | 193 | |
| 201 | 194 | WRITE8_HANDLER( super80_f0_w ) |
| 202 | 195 | { |
| 196 | super80_state *state = space->machine->driver_data<super80_state>(); |
| 203 | 197 | UINT8 bits = data ^ last_data; |
| 204 | | super80_shared = data; |
| 198 | state->super80_shared = data; |
| 205 | 199 | speaker_level_w(super80_speaker, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 206 | 200 | if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 207 | 201 | cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| r9179 | r9180 | |
| 211 | 205 | |
| 212 | 206 | WRITE8_HANDLER( super80r_f0_w ) |
| 213 | 207 | { |
| 208 | super80_state *state = space->machine->driver_data<super80_state>(); |
| 214 | 209 | super80_f0_w(space, 0, data); |
| 215 | | super80_shared |= 0x14; |
| 210 | state->super80_shared |= 0x14; |
| 216 | 211 | } |
| 217 | 212 | |
| 218 | 213 | /**************************** BASIC MACHINE CONSTRUCTION ***********************************************************/ |
| 219 | 214 | |
| 220 | 215 | MACHINE_RESET( super80 ) |
| 221 | 216 | { |
| 222 | | super80_shared=0xff; |
| 217 | super80_state *state = machine->driver_data<super80_state>(); |
| 218 | state->super80_shared=0xff; |
| 223 | 219 | timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, super80_reset); |
| 224 | 220 | memory_set_bank(machine, "bank1", 1); |
| 225 | 221 | super80_z80pio = machine->device("z80pio"); |
| r9179 | r9180 | |
| 244 | 240 | DRIVER_INIT( super80v ) |
| 245 | 241 | { |
| 246 | 242 | super80_state *state = machine->driver_data<super80_state>(); |
| 247 | | super80_pcgram = memory_region(machine, "maincpu")+0xf000; |
| 243 | state->pcgram = memory_region(machine, "maincpu")+0xf000; |
| 248 | 244 | state->videoram = memory_region(machine, "maincpu")+0x18000; |
| 249 | | super80_colorram = memory_region(machine, "maincpu")+0x1C000; |
| 245 | state->colorram = memory_region(machine, "maincpu")+0x1C000; |
| 250 | 246 | driver_init_common(machine); |
| 251 | 247 | } |
| 252 | 248 | |
src/mess/video/super80.c
| r9179 | r9180 | |
| 17 | 17 | |
| 18 | 18 | static const UINT8 *FNT; |
| 19 | 19 | static UINT8 s_options; |
| 20 | | extern UINT8 *super80_colorram; |
| 21 | 20 | |
| 21 | |
| 22 | 22 | /**************************** PALETTES for super80m and super80v ******************************************/ |
| 23 | 23 | |
| 24 | 24 | static const UINT8 super80_rgb_palette[16*3] = |
| r9179 | r9180 | |
| 99 | 99 | UINT8 y,ra,chr=32,gfx,screen_on=0; |
| 100 | 100 | UINT16 sy=0,ma=vidpg,x; |
| 101 | 101 | UINT8 *RAM = memory_region(screen->machine, "maincpu"); |
| 102 | super80_state *state = screen->machine->driver_data<super80_state>(); |
| 102 | 103 | |
| 103 | | output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0); |
| 104 | output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0); |
| 104 | 105 | |
| 105 | | if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 106 | if ((state->super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 106 | 107 | screen_on++; |
| 107 | 108 | |
| 108 | 109 | for (y = 0; y < 16; y++) |
| r9179 | r9180 | |
| 140 | 141 | UINT8 y,ra,chr=32,gfx,screen_on=0; |
| 141 | 142 | UINT16 sy=0,ma=vidpg,x; |
| 142 | 143 | UINT8 *RAM = memory_region(screen->machine, "maincpu"); |
| 144 | super80_state *state = screen->machine->driver_data<super80_state>(); |
| 143 | 145 | |
| 144 | | output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0); |
| 146 | output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0); |
| 145 | 147 | |
| 146 | | if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 148 | if ((state->super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 147 | 149 | screen_on++; |
| 148 | 150 | |
| 149 | 151 | for (y = 0; y < 16; y++) |
| r9179 | r9180 | |
| 181 | 183 | UINT8 y,ra,chr=32,gfx,screen_on=0; |
| 182 | 184 | UINT16 sy=0,ma=vidpg,x; |
| 183 | 185 | UINT8 *RAM = memory_region(screen->machine, "maincpu"); |
| 186 | super80_state *state = screen->machine->driver_data<super80_state>(); |
| 184 | 187 | |
| 185 | | output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0); |
| 188 | output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0); |
| 186 | 189 | |
| 187 | | if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 190 | if ((state->super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 188 | 191 | screen_on++; |
| 189 | 192 | |
| 190 | 193 | for (y = 0; y < 16; y++) |
| r9179 | r9180 | |
| 223 | 226 | UINT16 sy=0,ma=vidpg,x; |
| 224 | 227 | UINT8 col, bg=0, fg=0, options=input_port_read(screen->machine, "CONFIG"); |
| 225 | 228 | UINT8 *RAM = memory_region(screen->machine, "maincpu"); |
| 229 | super80_state *state = screen->machine->driver_data<super80_state>(); |
| 226 | 230 | |
| 227 | 231 | /* get selected character generator */ |
| 228 | 232 | UINT8 cgen = current_charset ^ ((options & 0x10)>>4); /* bit 0 of port F1 and cgen config switch */ |
| 229 | 233 | |
| 230 | | output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0); |
| 234 | output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0); |
| 231 | 235 | |
| 232 | | if ((super80_shared & 4) || (!(options & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 236 | if ((state->super80_shared & 4) || (!(options & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ |
| 233 | 237 | screen_on++; |
| 234 | 238 | |
| 235 | 239 | if (screen_on) |
| r9179 | r9180 | |
| 303 | 307 | READ8_HANDLER( super80v_low_r ) |
| 304 | 308 | { |
| 305 | 309 | super80_state *state = space->machine->driver_data<super80_state>(); |
| 306 | | UINT8 *videoram = state->videoram; |
| 307 | | if (super80_shared & 4) |
| 310 | |
| 311 | if (state->super80_shared & 4) |
| 312 | { |
| 313 | UINT8 *videoram = state->videoram; |
| 308 | 314 | return videoram[offset]; |
| 315 | } |
| 309 | 316 | else |
| 310 | | return super80_colorram[offset]; |
| 317 | { |
| 318 | UINT8 *colorram = state->colorram; |
| 319 | return colorram[offset]; |
| 320 | } |
| 311 | 321 | } |
| 312 | 322 | |
| 313 | 323 | WRITE8_HANDLER( super80v_low_w ) |
| 314 | 324 | { |
| 315 | 325 | super80_state *state = space->machine->driver_data<super80_state>(); |
| 316 | | UINT8 *videoram = state->videoram; |
| 317 | | if (super80_shared & 4) |
| 326 | |
| 327 | if (state->super80_shared & 4) |
| 328 | { |
| 329 | UINT8 *videoram = state->videoram; |
| 318 | 330 | videoram[offset] = data; |
| 331 | } |
| 319 | 332 | else |
| 320 | | super80_colorram[offset] = data; |
| 333 | { |
| 334 | UINT8 *colorram = state->colorram; |
| 335 | colorram[offset] = data; |
| 336 | } |
| 321 | 337 | } |
| 322 | 338 | |
| 323 | 339 | READ8_HANDLER( super80v_high_r ) |
| 324 | 340 | { |
| 325 | | if (~super80_shared & 4) |
| 326 | | return super80_colorram[0x800+offset]; |
| 341 | super80_state *state = space->machine->driver_data<super80_state>(); |
| 327 | 342 | |
| 328 | | if (super80_shared & 0x10) |
| 329 | | return super80_pcgram[0x800+offset]; |
| 343 | if (~state->super80_shared & 4) |
| 344 | { |
| 345 | UINT8 *colorram = state->colorram; |
| 346 | return colorram[0x800+offset]; |
| 347 | } |
| 330 | 348 | else |
| 331 | | return super80_pcgram[offset]; |
| 349 | { |
| 350 | UINT8 *pcgram = state->pcgram; |
| 351 | if (state->super80_shared & 0x10) |
| 352 | return pcgram[0x800+offset]; |
| 353 | else |
| 354 | return pcgram[offset]; |
| 355 | } |
| 332 | 356 | } |
| 333 | 357 | |
| 334 | 358 | WRITE8_HANDLER( super80v_high_w ) |
| 335 | 359 | { |
| 336 | 360 | super80_state *state = space->machine->driver_data<super80_state>(); |
| 337 | | UINT8 *videoram = state->videoram; |
| 338 | | if (~super80_shared & 4) |
| 339 | | super80_colorram[offset+0x800] = data; |
| 361 | |
| 362 | if (~state->super80_shared & 4) |
| 363 | { |
| 364 | UINT8 *colorram = state->colorram; |
| 365 | colorram[offset+0x800] = data; |
| 366 | } |
| 340 | 367 | else |
| 341 | 368 | { |
| 369 | UINT8 *videoram = state->videoram; |
| 342 | 370 | videoram[offset+0x800] = data; |
| 343 | 371 | |
| 344 | | if (super80_shared & 0x10) |
| 345 | | super80_pcgram[0x800+offset] = data; |
| 372 | if (state->super80_shared & 0x10) |
| 373 | { |
| 374 | UINT8 *pcgram = state->pcgram; |
| 375 | pcgram[0x800+offset] = data; |
| 376 | } |
| 346 | 377 | } |
| 347 | 378 | } |
| 348 | 379 | |
| r9179 | r9180 | |
| 407 | 438 | |
| 408 | 439 | VIDEO_UPDATE( super80v ) |
| 409 | 440 | { |
| 441 | super80_state *state = screen->machine->driver_data<super80_state>(); |
| 410 | 442 | framecnt++; |
| 411 | 443 | speed = mc6845_reg[10]&0x20, flash = mc6845_reg[10]&0x40; // cursor modes |
| 412 | 444 | cursor = (mc6845_reg[14]<<8) | mc6845_reg[15]; // get cursor position |
| 413 | 445 | s_options=input_port_read(screen->machine, "CONFIG"); |
| 414 | | output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0); |
| 446 | output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0); |
| 415 | 447 | mc6845_update(mc6845, bitmap, cliprect); |
| 416 | 448 | return 0; |
| 417 | 449 | } |
| r9179 | r9180 | |
| 420 | 452 | { |
| 421 | 453 | super80_state *state = device->machine->driver_data<super80_state>(); |
| 422 | 454 | UINT8 *videoram = state->videoram; |
| 455 | UINT8 *pcgram = state->pcgram; |
| 456 | UINT8 *colorram = state->colorram; |
| 423 | 457 | UINT8 chr,col,gfx,fg,bg=0; |
| 424 | 458 | UINT16 mem,x; |
| 425 | 459 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| r9179 | r9180 | |
| 437 | 471 | |
| 438 | 472 | if (~s_options & 0x40) |
| 439 | 473 | { |
| 440 | | col = super80_colorram[mem]; /* byte of colour to display */ |
| 474 | col = colorram[mem]; /* byte of colour to display */ |
| 441 | 475 | fg = col & 0x0f; |
| 442 | 476 | bg = (col & 0xf0) >> 4; |
| 443 | 477 | } |
| 444 | 478 | |
| 445 | 479 | /* if inverse mode, replace any pcgram chrs with inverse chrs */ |
| 446 | | if ((~super80_shared & 0x10) && (chr & 0x80)) // is it a high chr in inverse mode |
| 480 | if ((~state->super80_shared & 0x10) && (chr & 0x80)) // is it a high chr in inverse mode |
| 447 | 481 | { |
| 448 | 482 | inv ^= 0xff; // invert the chr |
| 449 | 483 | chr &= 0x7f; // and drop bit 7 |
| r9179 | r9180 | |
| 457 | 491 | inv ^= mc6845_cursor[ra]; |
| 458 | 492 | |
| 459 | 493 | /* get pattern of pixels for that character scanline */ |
| 460 | | gfx = super80_pcgram[(chr<<4) | ra] ^ inv; |
| 494 | gfx = pcgram[(chr<<4) | ra] ^ inv; |
| 461 | 495 | |
| 462 | 496 | /* Display a scanline of a character (7 pixels) */ |
| 463 | 497 | *p++ = ( gfx & 0x80 ) ? fg : bg; |