src/mess/video/super80.c
| r4410 | r4411 | |
| 1 | 1 | /* Super80.c written by Robbbert, 2005-2009. See the MESS wiki for documentation. */
|
| 2 | 2 | |
| 3 | /* Notes on using MAME MC6845 device (MMD).
|
| 4 | 1. Speed of MMD is about 20% slower than pre-MMD coding
|
| 5 | 2. Undocumented cursor start and end-lines is not supported by MMD, so we do it here
|
| 6 | 3. MMD doesn't support auto-screen-resize, so we do it here. */
|
| 7 | |
| 8 | |
| 3 | 9 | #include "driver.h"
|
| 10 | #include "video/mc6845.h"
|
| 4 | 11 | #include "super80.h"
|
| 5 | 12 | |
| 6 | 13 | |
| r4410 | r4411 | |
| 14 | 21 | static UINT8 mc6845_ind; /* register index */
|
| 15 | 22 | static const UINT8 mc6845_mask[]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0};
|
| 16 | 23 | |
| 24 | static const device_config *mc6845;
|
| 25 | static UINT8 chr,col,gfx,fg,bg;
|
| 26 | static UINT16 mem,x;
|
| 27 | static UINT8 framecnt=0;
|
| 28 | static UINT8 speed,flash;
|
| 29 | static UINT16 cursor;
|
| 30 | static UINT8 options;
|
| 31 | |
| 32 | |
| 17 | 33 | /**************************** PALETTES for super80m and super80v ******************************************/
|
| 18 | 34 | |
| 19 | 35 | static const UINT8 super80_rgb_palette[16*3] =
|
| r4410 | r4411 | |
| 123 | 139 | }
|
| 124 | 140 | }
|
| 125 | 141 | |
| 126 | | /* The 6845 can produce a variety of cursor shapes - all are emulated here */
|
| 142 | /* The 6845 can produce a variety of cursor shapes - all are emulated here - remove when mame fixed */
|
| 127 | 143 | static void mc6845_cursor_configure(void)
|
| 128 | 144 | {
|
| 129 | 145 | UINT8 i,curs_type=0,r9,r10,r11;
|
| r4410 | r4411 | |
| 195 | 211 | {
|
| 196 | 212 | UINT8 x, y, code=32, screen_on=0;
|
| 197 | 213 | UINT8 mask = screen->machine->gfx[0]->total_elements - 1; /* 0x3F for super80; 0xFF for super80d & super80e */
|
| 214 | UINT8 *RAM = memory_region(screen->machine, "maincpu");
|
| 198 | 215 | |
| 199 | 216 | if ((super80_mhz == 1) || (!(input_port_read(screen->machine, "CONFIG") & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */
|
| 200 | 217 | screen_on++;
|
| r4410 | r4411 | |
| 205 | 222 | for (x=0; x<32; x++)
|
| 206 | 223 | {
|
| 207 | 224 | if (screen_on)
|
| 208 | | code = memory_read_byte(cputag_get_address_space(screen->machine,"maincpu",ADDRESS_SPACE_PROGRAM), vidpg | x | (y<<5));
|
| 225 | code = RAM[vidpg | x | (y<<5)]; /* get character to display */
|
| 209 | 226 | |
| 210 | 227 | drawgfx(bitmap, screen->machine->gfx[0], code & mask, 0, 0, 0, x*8, y*10, cliprect, TRANSPARENCY_NONE, 0);
|
| 211 | 228 | }
|
| r4410 | r4411 | |
| 217 | 234 | VIDEO_UPDATE( super80m )
|
| 218 | 235 | {
|
| 219 | 236 | UINT8 x, y, code=32, col=0, screen_on=0, options=input_port_read(screen->machine, "CONFIG");
|
| 237 | UINT8 *RAM = memory_region(screen->machine, "maincpu");
|
| 220 | 238 | |
| 221 | 239 | /* get selected character generator */
|
| 222 | 240 | UINT8 cgen = current_charset ^ ((options & 0x10)>>4); /* bit 0 of port F1 and cgen config switch */
|
| r4410 | r4411 | |
| 239 | 257 | {
|
| 240 | 258 | if (screen_on)
|
| 241 | 259 | {
|
| 242 | | code = memory_read_byte(cputag_get_address_space(screen->machine,"maincpu",ADDRESS_SPACE_PROGRAM), vidpg | x | (y<<5)); /* get character to display */
|
| 260 | code = RAM[vidpg | x | (y<<5)]; /* get character to display */
|
| 243 | 261 | |
| 244 | | if (!(options & 0x40)) col = memory_read_byte(cputag_get_address_space(screen->machine,"maincpu",ADDRESS_SPACE_PROGRAM), 0xfe00 | x | (y<<5)); /* byte of colour to display */
|
| 262 | if (!(options & 0x40)) col = RAM[0xfe00 | x | (y<<5)]; /* byte of colour to display */
|
| 245 | 263 | }
|
| 246 | 264 | |
| 247 | 265 | drawgfx(bitmap, screen->machine->gfx[cgen], code, col, 0, 0, x*8, y*10, cliprect, TRANSPARENCY_NONE, 0);
|
| r4410 | r4411 | |
| 251 | 269 | return 0;
|
| 252 | 270 | }
|
| 253 | 271 | |
| 272 | |
| 273 | VIDEO_START( super80v )
|
| 274 | {
|
| 275 | mc6845 = devtag_get_device(machine, "crtc");
|
| 276 | }
|
| 277 | |
| 254 | 278 | VIDEO_UPDATE( super80v )
|
| 255 | 279 | {
|
| 256 | | UINT8 y,z,chr,col,gfx,fg,bg;
|
| 257 | | UINT16 mem,sy=0,sx=0,x;
|
| 258 | | static UINT8 framecnt=0;
|
| 259 | | UINT8 speed = mc6845_reg[10]&0x20, flash = mc6845_reg[10]&0x40; // cursor modes
|
| 260 | | UINT16 cursor = (mc6845_reg[14]<<8) | mc6845_reg[15]; // get cursor position
|
| 261 | | UINT16 screen_home = (mc6845_reg[12]<<8) | mc6845_reg[13]; // screen home offset (usually zero)
|
| 262 | | UINT8 options=input_port_read(screen->machine, "CONFIG");
|
| 263 | 280 | framecnt++;
|
| 281 | speed = mc6845_reg[10]&0x20, flash = mc6845_reg[10]&0x40; // cursor modes
|
| 282 | cursor = (mc6845_reg[14]<<8) | mc6845_reg[15]; // get cursor position
|
| 283 | options=input_port_read(screen->machine, "CONFIG");
|
| 284 | mc6845_update(mc6845, bitmap, cliprect);
|
| 285 | return 0;
|
| 286 | }
|
| 264 | 287 | |
| 265 | | for (y = 0; y < mc6845_reg[6]; y++) // for each row of chars
|
| 288 | MC6845_UPDATE_ROW( super80v_update_row )
|
| 289 | {
|
| 290 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0);
|
| 291 | |
| 292 | for (x = 0; x < x_count; x++) // for each character
|
| 266 | 293 | {
|
| 267 | | for (z = 0; z < mc6845_reg[9]+1; z++) // for each scanline
|
| 268 | | {
|
| 269 | | UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
|
| 294 | UINT8 inv=0;
|
| 295 | // if (x == cursor_x) inv=0xff; /* uncomment when mame fixed */
|
| 296 | mem = (ma + x) & 0xfff;
|
| 297 | chr = videoram[mem];
|
| 270 | 298 | |
| 271 | | for (x = sx; x < sx + mc6845_reg[1]; x++) // for each character
|
| 272 | | {
|
| 273 | | UINT8 inv=0;
|
| 274 | | mem = (x + screen_home) & 0xfff;
|
| 275 | | chr = videoram[mem];
|
| 299 | /* get colour or b&w */
|
| 300 | col = 5; /* green */
|
| 301 | if ((options & 0x60) == 0x60) col = 15; /* b&w */
|
| 302 | if (!(options & 0x40)) col = colorram[mem]; // read a byte of colour
|
| 276 | 303 | |
| 277 | | /* get colour or b&w */
|
| 278 | | col = 5; /* green */
|
| 279 | | if ((options & 0x60) == 0x60) col = 15; /* b&w */
|
| 280 | | if (!(options & 0x40)) col = colorram[mem]; // read a byte of colour
|
| 304 | /* if inverse mode, replace any pcgram chrs with inverse chrs */
|
| 305 | if ((!super80v_rom_pcg) && (chr & 0x80)) // is it a high chr in inverse mode
|
| 306 | {
|
| 307 | inv ^= 0xff; // invert the chr
|
| 308 | chr &= 0x7f; // and drop bit 7
|
| 309 | }
|
| 281 | 310 | |
| 282 | | /* if inverse mode, replace any pcgram chrs with inverse chrs */
|
| 283 | | if ((!super80v_rom_pcg) && (chr & 0x80)) // is it a high chr in inverse mode
|
| 284 | | {
|
| 285 | | inv = 0xff; // invert the chr
|
| 286 | | chr &= 0x7f; // and drop bit 7
|
| 287 | | }
|
| 311 | /* process cursor - remove when mame fixed */
|
| 312 | if ((((!flash) && (!speed)) ||
|
| 313 | ((flash) && (speed) && (framecnt & 0x10)) ||
|
| 314 | ((flash) && (!speed) && (framecnt & 8))) &&
|
| 315 | (mem == cursor))
|
| 316 | inv ^= mc6845_cursor[ra];
|
| 288 | 317 | |
| 289 | | /* process cursor */
|
| 290 | | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always
|
| 291 | | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames
|
| 292 | | ((flash) && (!speed) && (framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames
|
| 293 | | (mem == cursor)) // displaying at cursor position?
|
| 294 | | inv ^= mc6845_cursor[z]; // cursor scan row
|
| 318 | /* get pattern of pixels for that character scanline */
|
| 319 | gfx = pcgram[(chr<<4) | ra] ^ inv;
|
| 320 | fg = ((col & 0x0f) << 1) + 1;
|
| 321 | bg = ((col & 0xf0) >> 3) + 1;
|
| 295 | 322 | |
| 296 | | /* get pattern of pixels for that character scanline */
|
| 297 | | gfx = pcgram[(chr<<4) | z] ^ inv;
|
| 298 | | fg = ((col & 0x0f) << 1) + 1;
|
| 299 | | bg = ((col & 0xf0) >> 3) + 1;
|
| 300 | | |
| 301 | | /* Display a scanline of a character (7 pixels) */
|
| 302 | | *p = ( gfx & 0x80 ) ? fg : bg; p++;
|
| 303 | | *p = ( gfx & 0x40 ) ? fg : bg; p++;
|
| 304 | | *p = ( gfx & 0x20 ) ? fg : bg; p++;
|
| 305 | | *p = ( gfx & 0x10 ) ? fg : bg; p++;
|
| 306 | | *p = ( gfx & 0x08 ) ? fg : bg; p++;
|
| 307 | | *p = ( gfx & 0x04 ) ? fg : bg; p++;
|
| 308 | | *p = ( gfx & 0x02 ) ? fg : bg; p++;
|
| 309 | | }
|
| 310 | | }
|
| 311 | | sx+=mc6845_reg[1];
|
| 323 | /* Display a scanline of a character (7 pixels) */
|
| 324 | *p = ( gfx & 0x80 ) ? fg : bg; p++;
|
| 325 | *p = ( gfx & 0x40 ) ? fg : bg; p++;
|
| 326 | *p = ( gfx & 0x20 ) ? fg : bg; p++;
|
| 327 | *p = ( gfx & 0x10 ) ? fg : bg; p++;
|
| 328 | *p = ( gfx & 0x08 ) ? fg : bg; p++;
|
| 329 | *p = ( gfx & 0x04 ) ? fg : bg; p++;
|
| 330 | *p = ( gfx & 0x02 ) ? fg : bg; p++;
|
| 312 | 331 | }
|
| 313 | | return 0;
|
| 314 | 332 | }
|
| 315 | 333 | |
| 316 | 334 | /**************************** I/O PORTS *****************************************************************/
|
| 317 | 335 | |
| 318 | | READ8_HANDLER( super80v_11_r )
|
| 319 | | {
|
| 320 | | if ((mc6845_ind > 13) && (mc6845_ind < 18)) /* determine readable registers */
|
| 321 | | return mc6845_reg[mc6845_ind];
|
| 322 | | else
|
| 323 | | return 0;
|
| 324 | | }
|
| 325 | | |
| 326 | 336 | WRITE8_HANDLER( super80v_10_w )
|
| 327 | 337 | {
|
| 328 | 338 | if (data < 18) mc6845_ind = data; else mc6845_ind = 19; /* make sure if you try using an invalid register your write will go nowhere */
|
| 339 | mc6845_address_w( mc6845, 0, data );
|
| 329 | 340 | }
|
| 330 | 341 | |
| 331 | 342 | WRITE8_HANDLER( super80v_11_w )
|
| 332 | 343 | {
|
| 333 | 344 | if (mc6845_ind < 16) mc6845_reg[mc6845_ind] = data & mc6845_mask[mc6845_ind]; /* save data in register */
|
| 334 | 345 | if ((mc6845_ind == 1) || (mc6845_ind == 6) || (mc6845_ind == 9)) mc6845_screen_configure(space->machine); /* adjust screen size */
|
| 335 | | if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure(); /* adjust cursor shape */
|
| 346 | if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure(); /* adjust cursor shape - remove when mame fixed */
|
| 347 | mc6845_register_w( mc6845, 0, data );
|
| 336 | 348 | }
|
| 337 | 349 | |
| 338 | 350 | WRITE8_HANDLER( super80_f1_w )
|
src/mess/drivers/super80.c
| r4410 | r4411 | |
| 11 | 11 | #include "devices/z80bin.h" |
| 12 | 12 | #include "sound/speaker.h" |
| 13 | 13 | #include "machine/ctronics.h" |
| 14 | #include "video/mc6845.h" |
| 14 | 15 | #include "super80.h" |
| 15 | 16 | |
| 16 | 17 | |
| r4410 | r4411 | |
| 37 | 38 | |
| 38 | 39 | #define SUPER80V_SCREEN_WIDTH (560) |
| 39 | 40 | #define SUPER80V_SCREEN_HEIGHT (300) |
| 41 | #define SUPER80V_DOTS (7) |
| 40 | 42 | |
| 41 | 43 | |
| 42 | 44 | /**************************** PIO ******************************************************************************/ |
| r4410 | r4411 | |
| 234 | 236 | |
| 235 | 237 | /**************************** MEMORY AND I/O MAPPINGS *****************************************************************/ |
| 236 | 238 | |
| 237 | | /* A read_byte or write_byte to unmapped memory crashes MESS, and UNMAP doesnt fix it */ |
| 239 | /* A read_byte or write_byte to unmapped memory crashes MESS, and UNMAP doesnt fix it. |
| 240 | This makes the H and E monitor commands show FF */ |
| 238 | 241 | static READ8_HANDLER( super80_read_ff ) { return 0xff; } |
| 239 | 242 | |
| 240 | 243 | static ADDRESS_MAP_START( super80_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 241 | | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 242 | | AM_RANGE(0x4000, 0xbfff) AM_RAM |
| 244 | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) AM_REGION("maincpu", 0x0000) |
| 245 | AM_RANGE(0x4000, 0xbfff) AM_RAM AM_REGION("maincpu", 0x4000) |
| 243 | 246 | AM_RANGE(0xc000, 0xefff) AM_ROM |
| 244 | 247 | AM_RANGE(0xf000, 0xffff) AM_READWRITE(super80_read_ff, SMH_NOP) |
| 245 | 248 | ADDRESS_MAP_END |
| 246 | 249 | |
| 247 | 250 | static ADDRESS_MAP_START( super80m_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 248 | | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 249 | | AM_RANGE(0x4000, 0xbfff) AM_RAM |
| 251 | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) AM_REGION("maincpu", 0x0000) |
| 252 | AM_RANGE(0x4000, 0xbfff) AM_RAM AM_REGION("maincpu", 0x4000) |
| 250 | 253 | AM_RANGE(0xc000, 0xefff) AM_ROM |
| 251 | | AM_RANGE(0xf000, 0xffff) AM_RAM |
| 254 | AM_RANGE(0xf000, 0xffff) AM_RAM AM_REGION("maincpu", 0xf000) |
| 252 | 255 | ADDRESS_MAP_END |
| 253 | 256 | |
| 254 | 257 | static ADDRESS_MAP_START( super80v_map, ADDRESS_SPACE_PROGRAM, 8) |
| r4410 | r4411 | |
| 276 | 279 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 277 | 280 | ADDRESS_MAP_UNMAP_HIGH |
| 278 | 281 | AM_RANGE(0x10, 0x10) AM_WRITE(super80v_10_w) |
| 279 | | AM_RANGE(0x11, 0x11) AM_READWRITE(super80v_11_r, super80v_11_w) |
| 282 | AM_RANGE(0x11, 0x11) AM_DEVREAD("crtc", mc6845_register_r) |
| 283 | AM_RANGE(0x11, 0x11) AM_WRITE(super80v_11_w) |
| 280 | 284 | AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w) |
| 281 | 285 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80r_f0_w) |
| 282 | 286 | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r) |
| r4410 | r4411 | |
| 290 | 294 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 291 | 295 | ADDRESS_MAP_UNMAP_HIGH |
| 292 | 296 | AM_RANGE(0x10, 0x10) AM_WRITE(super80v_10_w) |
| 293 | | AM_RANGE(0x11, 0x11) AM_READWRITE(super80v_11_r, super80v_11_w) |
| 297 | AM_RANGE(0x11, 0x11) AM_DEVREAD("crtc", mc6845_register_r) |
| 298 | AM_RANGE(0x11, 0x11) AM_WRITE(super80v_11_w) |
| 294 | 299 | AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w) |
| 295 | 300 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80v_f0_w) |
| 296 | 301 | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r) |
| r4410 | r4411 | |
| 575 | 580 | 8*16 /* every char takes 16 bytes */ |
| 576 | 581 | }; |
| 577 | 582 | |
| 583 | /* for documentation only - not needed by video update */ |
| 578 | 584 | static const gfx_layout super80v_charlayout = |
| 579 | 585 | { |
| 580 | 586 | 8,16, /* 8 x 16 characters */ |
| r4410 | r4411 | |
| 670 | 676 | return INIT_PASS; |
| 671 | 677 | } |
| 672 | 678 | |
| 679 | static const mc6845_interface super80v_crtc = { |
| 680 | "screen", /* name of screen */ |
| 681 | SUPER80V_DOTS, /* number of dots per character */ |
| 682 | NULL, |
| 683 | super80v_update_row, /* handler to display a scanline */ |
| 684 | NULL, |
| 685 | NULL, |
| 686 | NULL, |
| 687 | NULL |
| 688 | }; |
| 689 | |
| 673 | 690 | static MACHINE_DRIVER_START( super80_cartslot ) |
| 674 | 691 | MDRV_CARTSLOT_ADD("cart") |
| 675 | 692 | MDRV_CARTSLOT_EXTENSION_LIST("rom") |
| r4410 | r4411 | |
| 755 | 772 | MDRV_PALETTE_LENGTH(256*2) |
| 756 | 773 | MDRV_PALETTE_INIT(super80m) |
| 757 | 774 | |
| 775 | MDRV_MC6845_ADD("crtc", MC6845, MASTER_CLOCK / SUPER80V_DOTS, super80v_crtc) |
| 776 | |
| 777 | MDRV_VIDEO_START(super80v) |
| 758 | 778 | MDRV_VIDEO_EOF(super80m) |
| 759 | 779 | MDRV_VIDEO_UPDATE(super80v) |
| 760 | 780 | |
| r4410 | r4411 | |
| 821 | 841 | ROM_LOAD("super80.u26", 0xc000, 0x1000, CRC(6a6a9664) SHA1(2c4fcd943aa9bf7419d58fbc0e28ffb89ef22e0b) ) |
| 822 | 842 | ROM_LOAD("super80.u33", 0xd000, 0x1000, CRC(cf8020a8) SHA1(2179a61f80372cd49e122ad3364773451531ae85) ) |
| 823 | 843 | ROM_LOAD("super80.u42", 0xe000, 0x1000, CRC(a1c6cb75) SHA1(d644ca3b399c1a8902f365c6095e0bbdcea6733b) ) |
| 844 | ROM_FILL( 0xf000, 0x1000, 0xff) /* This makes the screen show the FF character when O F1 F0 entered */ |
| 824 | 845 | |
| 825 | 846 | ROM_REGION(0x0400, "gfx1", ROMREGION_DISPOSE) |
| 826 | 847 | ROM_LOAD("super80.u27", 0x0000, 0x0400, CRC(d1e4b3c6) SHA1(3667b97c6136da4761937958f281609690af4081) ) |
| r4410 | r4411 | |
| 836 | 857 | ROMX_LOAD("super80g.u26", 0xc000, 0x1000, CRC(7386f507) SHA1(69d7627033d62bd4e886ccc136e89f1524d38f47), ROM_BIOS(3)) |
| 837 | 858 | ROM_LOAD("super80.u33", 0xd000, 0x1000, CRC(cf8020a8) SHA1(2179a61f80372cd49e122ad3364773451531ae85) ) |
| 838 | 859 | ROM_LOAD("super80.u42", 0xe000, 0x1000, CRC(a1c6cb75) SHA1(d644ca3b399c1a8902f365c6095e0bbdcea6733b) ) |
| 860 | ROM_FILL( 0xf000, 0x1000, 0xff) |
| 839 | 861 | |
| 840 | 862 | ROM_REGION(0x1000, "gfx1", ROMREGION_DISPOSE) |
| 841 | 863 | ROM_LOAD("super80d.u27", 0x0000, 0x0800, CRC(cb4c81e2) SHA1(8096f21c914fa76df5d23f74b1f7f83bd8645783) ) |
| r4410 | r4411 | |
| 847 | 869 | ROM_LOAD("super80e.u26", 0xc000, 0x1000, CRC(bdc668f8) SHA1(3ae30b3cab599fca77d5e461f3ec1acf404caf07) ) |
| 848 | 870 | ROM_LOAD("super80.u33", 0xd000, 0x1000, CRC(cf8020a8) SHA1(2179a61f80372cd49e122ad3364773451531ae85) ) |
| 849 | 871 | ROM_LOAD("super80.u42", 0xe000, 0x1000, CRC(a1c6cb75) SHA1(d644ca3b399c1a8902f365c6095e0bbdcea6733b) ) |
| 872 | ROM_FILL( 0xf000, 0x1000, 0xff) |
| 850 | 873 | |
| 851 | 874 | ROM_REGION(0x1000, "gfx1", ROMREGION_DISPOSE) |
| 852 | 875 | ROM_LOAD("super80e.u27", 0x0000, 0x1000, CRC(ebe763a7) SHA1(ffaa6d6a2c5dacc5a6651514e6707175a32e83e8) ) |