Previous 15994 Revisions Next

r4411 Thursday 12th March, 2009 at 10:25:11 UTC by Robbbert
[SUPER80] Using mc6845 device.
[src/mess/drivers]super80.c
[src/mess/includes]super80.h
[src/mess/video]super80.c

src/mess/video/super80.c
r4410r4411
11/* Super80.c written by Robbbert, 2005-2009. See the MESS wiki for documentation. */
22 
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 
39#include "driver.h"
10#include "video/mc6845.h"
411#include "super80.h"
512 
613 
r4410r4411
1421static UINT8 mc6845_ind;            /* register index */
1522static const UINT8 mc6845_mask[]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0};
1623 
24static const device_config *mc6845;
25static UINT8 chr,col,gfx,fg,bg;
26static UINT16 mem,x;
27static UINT8 framecnt=0;
28static UINT8 speed,flash;
29static UINT16 cursor;
30static UINT8 options;
31 
32 
1733/**************************** PALETTES for super80m and super80v ******************************************/
1834 
1935static const UINT8 super80_rgb_palette[16*3] =
r4410r4411
123139   }
124140}
125141 
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 */
127143static void mc6845_cursor_configure(void)
128144{
129145   UINT8 i,curs_type=0,r9,r10,r11;
r4410r4411
195211{
196212   UINT8 x, y, code=32, screen_on=0;
197213   UINT8 mask = screen->machine->gfx[0]->total_elements - 1;   /* 0x3F for super80; 0xFF for super80d & super80e */
214   UINT8 *RAM = memory_region(screen->machine, "maincpu");
198215 
199216   if ((super80_mhz == 1) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
200217      screen_on++;
r4410r4411
205222      for (x=0; x<32; x++)
206223      {
207224         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 */
209226 
210227         drawgfx(bitmap, screen->machine->gfx[0], code & mask, 0, 0, 0, x*8, y*10, cliprect, TRANSPARENCY_NONE, 0);
211228      }
r4410r4411
217234VIDEO_UPDATE( super80m )
218235{
219236   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");
220238 
221239   /* get selected character generator */
222240   UINT8 cgen = current_charset ^ ((options & 0x10)>>4);   /* bit 0 of port F1 and cgen config switch */
r4410r4411
239257      {
240258         if (screen_on)
241259         {
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 */
243261 
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 */
245263         }
246264 
247265         drawgfx(bitmap, screen->machine->gfx[cgen], code, col, 0, 0, x*8, y*10,   cliprect, TRANSPARENCY_NONE, 0);
r4410r4411
251269   return 0;
252270}
253271 
272 
273VIDEO_START( super80v )
274{
275   mc6845 = devtag_get_device(machine, "crtc");
276}
277 
254278VIDEO_UPDATE( super80v )
255279{
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");
263280   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}
264287 
265   for (y = 0; y < mc6845_reg[6]; y++)                     // for each row of chars
288MC6845_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
266293   {
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];
270298 
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
276303 
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      }
281310 
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];
288317 
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;
295322 
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++;
312331   }
313   return 0;
314332}
315333 
316334/**************************** I/O PORTS *****************************************************************/
317335 
318READ8_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 
326336WRITE8_HANDLER( super80v_10_w )
327337{
328338   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 );
329340}
330341 
331342WRITE8_HANDLER( super80v_11_w )
332343{
333344   if (mc6845_ind < 16) mc6845_reg[mc6845_ind] = data & mc6845_mask[mc6845_ind];   /* save data in register */
334345   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 );
336348}
337349 
338350WRITE8_HANDLER( super80_f1_w )
src/mess/includes/super80.h
r4410r4411
77WRITE8_HANDLER( super80v_high_w );
88VIDEO_UPDATE( super80 );
99VIDEO_UPDATE( super80m );
10VIDEO_START( super80v );
1011VIDEO_UPDATE( super80v );
1112VIDEO_EOF( super80m );
1213READ8_HANDLER( super80v_11_r );
1314WRITE8_HANDLER( super80v_10_w );
1415WRITE8_HANDLER( super80v_11_w );
1516WRITE8_HANDLER( super80_f1_w );
17MC6845_BEGIN_UPDATE( super80v_begin_update );
18MC6845_UPDATE_ROW( super80v_update_row );
1619 
1720extern UINT8 *pcgram;
1821extern UINT8 super80v_vid_col;
src/mess/drivers/super80.c
r4410r4411
1111#include "devices/z80bin.h"
1212#include "sound/speaker.h"
1313#include "machine/ctronics.h"
14#include "video/mc6845.h"
1415#include "super80.h"
1516
1617
r4410r4411
3738
3839#define SUPER80V_SCREEN_WIDTH      (560)
3940#define SUPER80V_SCREEN_HEIGHT      (300)
41#define SUPER80V_DOTS         (7)
4042
4143
4244/**************************** PIO ******************************************************************************/
r4410r4411
234236
235237/**************************** MEMORY AND I/O MAPPINGS *****************************************************************/
236238
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 */
238241static READ8_HANDLER( super80_read_ff ) { return 0xff; }
239242
240243static 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)
243246   AM_RANGE(0xc000, 0xefff) AM_ROM
244247   AM_RANGE(0xf000, 0xffff) AM_READWRITE(super80_read_ff, SMH_NOP)
245248ADDRESS_MAP_END
246249
247250static 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)
250253   AM_RANGE(0xc000, 0xefff) AM_ROM
251   AM_RANGE(0xf000, 0xffff) AM_RAM
254   AM_RANGE(0xf000, 0xffff) AM_RAM AM_REGION("maincpu", 0xf000)
252255ADDRESS_MAP_END
253256
254257static ADDRESS_MAP_START( super80v_map, ADDRESS_SPACE_PROGRAM, 8)
r4410r4411
276279   ADDRESS_MAP_GLOBAL_MASK(0xff)
277280   ADDRESS_MAP_UNMAP_HIGH
278281   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)
280284   AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w)
281285   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80r_f0_w)
282286   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
r4410r4411
290294   ADDRESS_MAP_GLOBAL_MASK(0xff)
291295   ADDRESS_MAP_UNMAP_HIGH
292296   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)
294299   AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w)
295300   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80v_f0_w)
296301   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
r4410r4411
575580   8*16               /* every char takes 16 bytes */
576581};
577582
583/* for documentation only - not needed by video update */
578584static const gfx_layout super80v_charlayout =
579585{
580586   8,16,               /* 8 x 16 characters */
r4410r4411
670676   return INIT_PASS;
671677}
672678
679static 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
673690static MACHINE_DRIVER_START( super80_cartslot )
674691   MDRV_CARTSLOT_ADD("cart")
675692   MDRV_CARTSLOT_EXTENSION_LIST("rom")
r4410r4411
755772   MDRV_PALETTE_LENGTH(256*2)
756773   MDRV_PALETTE_INIT(super80m)
757774
775   MDRV_MC6845_ADD("crtc", MC6845, MASTER_CLOCK / SUPER80V_DOTS, super80v_crtc)
776
777   MDRV_VIDEO_START(super80v)
758778   MDRV_VIDEO_EOF(super80m)
759779   MDRV_VIDEO_UPDATE(super80v)
760780
r4410r4411
821841   ROM_LOAD("super80.u26",   0xc000, 0x1000, CRC(6a6a9664) SHA1(2c4fcd943aa9bf7419d58fbc0e28ffb89ef22e0b) )
822842   ROM_LOAD("super80.u33",   0xd000, 0x1000, CRC(cf8020a8) SHA1(2179a61f80372cd49e122ad3364773451531ae85) )
823843   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 */
824845
825846   ROM_REGION(0x0400, "gfx1", ROMREGION_DISPOSE)
826847   ROM_LOAD("super80.u27",   0x0000, 0x0400, CRC(d1e4b3c6) SHA1(3667b97c6136da4761937958f281609690af4081) )
r4410r4411
836857   ROMX_LOAD("super80g.u26", 0xc000, 0x1000, CRC(7386f507) SHA1(69d7627033d62bd4e886ccc136e89f1524d38f47), ROM_BIOS(3))
837858   ROM_LOAD("super80.u33",     0xd000, 0x1000, CRC(cf8020a8) SHA1(2179a61f80372cd49e122ad3364773451531ae85) )
838859   ROM_LOAD("super80.u42",     0xe000, 0x1000, CRC(a1c6cb75) SHA1(d644ca3b399c1a8902f365c6095e0bbdcea6733b) )
860   ROM_FILL( 0xf000, 0x1000, 0xff)
839861
840862   ROM_REGION(0x1000, "gfx1", ROMREGION_DISPOSE)
841863   ROM_LOAD("super80d.u27",  0x0000, 0x0800, CRC(cb4c81e2) SHA1(8096f21c914fa76df5d23f74b1f7f83bd8645783) )
r4410r4411
847869   ROM_LOAD("super80e.u26",  0xc000, 0x1000, CRC(bdc668f8) SHA1(3ae30b3cab599fca77d5e461f3ec1acf404caf07) )
848870   ROM_LOAD("super80.u33",     0xd000, 0x1000, CRC(cf8020a8) SHA1(2179a61f80372cd49e122ad3364773451531ae85) )
849871   ROM_LOAD("super80.u42",     0xe000, 0x1000, CRC(a1c6cb75) SHA1(d644ca3b399c1a8902f365c6095e0bbdcea6733b) )
872   ROM_FILL( 0xf000, 0x1000, 0xff)
850873
851874   ROM_REGION(0x1000, "gfx1", ROMREGION_DISPOSE)
852875   ROM_LOAD("super80e.u27",  0x0000, 0x1000, CRC(ebe763a7) SHA1(ffaa6d6a2c5dacc5a6651514e6707175a32e83e8) )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team