summaryrefslogtreecommitdiffstats
path: root/docs/source/whatis.rst
blob: fb5dffe497bce21c243455c8a7787f14c5b71201 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
What is MAME
============

MAME is a multi-purpose emulation framework.

MAME's purpose is to preserve decades of software history. As electronic technology continues to rush forward, MAME prevents this important "vintage" software from being lost and forgotten. This is achieved by documenting the hardware and how it functions. The source code to MAME serves as this documentation. The fact that the software is usable serves primarily to validate the accuracy of the documentation (how else can you prove that you have recreated the hardware faithfully?). Over time, MAME (originally stood for Multiple Arcade Machine Emulator) absorbed the sister-project MESS (Multi Emulator Super System), so MAME now documents a wide variety of (mostly vintage) computers, video game consoles and calculators, in addition to the arcade video games that were its initial focus.

|
| **MAME®**
| **Copyright © 1997-2018 by Nicola Salmoria and the MAME team**
| **MAME is a registered trademark owned by Gregory Ember**
|


I. Purpose
----------

MAME's main purpose is to be a reference to the inner workings of the
emulated machines. This is done both for educational purposes and for
preservation purposes, in order to prevent historical software from
disappearing forever once the hardware it runs on stops working. Of
course, in order to preserve the software and demonstrate that the
emulated behavior matches the original, one must also be able to
actually use the software. This is considered a nice side effect, and is
not MAME's primary focus.

It is not our intention to infringe on any copyrights or patents on the
original games. All of MAME's source code is either our own or freely
available. To operate, the emulator requires images of the original
ROMs, CDs, hard disks or other media from the machines, which must be
provided by the user. No portions of the original game code are included
in the executable.


II. Cost
--------
MAME is free. Its source code is free. The project as whole is
distributed under the GNU General Public License, version 2 or later
(GPL-2.0+), but most of code (including core functionality) is also
available under the 3-clause BSD license (BSD-3-clause).


III. Software Image Files
-------------------------

ROM, CD, hard disk and other media images are all copyrighted material.
They cannot be distributed without the explicit permission of the
copyright holder(s). They are not "abandonware", nor has any of the
software supported by MAME passed out of copyright.

MAME is not intended to be used as a tool for mass copyright
infringement. Therefore, it is strongly against the authors' wishes to
sell, advertise, or link to resources that provide illegal copies of
ROM, CD, hard disk or other media images.


IV. Derivative Works
--------------------
Because the name MAME is trademarked, you must abide by the rules set
out for trademark usage if you wish to use "MAME" as part of the name
your derivative work. In general, this means you must request
permission, which requires that you follow the guidelines above.

The version number of any derivative work should reflect the version
number of the MAME release from which it was was derived.


V. Official Contact Information
-------------------------------
For questions regarding the MAME license, trademark, or other usage, go to http://www.mamedev.org/
' href='#n274'>274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
/***************************************************************************

                          -= Newer Seta Hardware =-

                    driver by   Luca Elia (l.elia@tin.it)


    This hardware only generates sprites. But they're of various types,
    including some large "floating tilemap" ones.

    Sprites RAM is 0x40000 bytes long. All games write the sprites list
    at offset 0x3000. Each entry in the list holds data for a multi-sprite
    of up to 256 single-sprites. The list looks like this:

    Offset:     Bits:                   Value:

        0.w     f--- ---- ---- ----     Last sprite
                -edc ---- ---- ----     ?
                ---c ---- ---- ----     0 = Each sprite specifies its size, 1 = use the size in the following words
                ---- b--- ---- ----     ?
                ---- -a98 ---- ----     tile color depth
                ---- ---- 7654 3210     Number of sprites - 1

        2.w     fedc ---- ---- ----     Number of tiles?
                ---- ba-- ---- ----     Number of tiles along X (1 << n)
                ---- --98 7654 3210     X displacement

        4.w     fedc ---- ---- ----     Number of tiles?
                ---- ba-- ---- ----     Number of tiles along Y (1 << n)
                ---- --98 7654 3210     Y displacement

        6.w     f--- ---- ---- ----     Single-sprite(s) type: tile (0) or row of tiles (1)
                -edc ba98 7654 3210     Offset of the single-sprite(s) data


    A single-sprite can be a tile or some horizontal rows of tiles.

    Tile case:

        0.w     fedc ---- ---- ----     Number of tiles?
                ---- ba-- ---- ----     Number of tiles along X (1 << n)
                ---- --98 7654 3210     X

        2.w     fedc ---- ---- ----     Number of tiles?
                ---- ba-- ---- ----     Number of tiles along Y (1 << n)
                ---- --98 7654 3210     Y

        4.w     fedc ba98 765- ----     Color code (16 color steps)
                ---- ---- ---4 ----     Flip X
                ---- ---- ---- 3---     Flip Y
                ---- ---- ---- -210     Code (high bits)

        6.w                             Code (low bits)


    Row case:

        0.w     fedc ba-- ---- ----
                ---- --98 7654 3210     X

        2.w     fedc ba-- ---- ----     Number of rows - 1
                ---- --98 7654 3210     Y

        4.w     f--- ---- ---- ----     Tile size: 8x8 (0) or 16x16 (1)
                -edc ba-- ---- ----     "Tilemap" page
                ---- --98 7654 3210     "Tilemap" Scroll X

        6.w     fedc ba9- ---- ----
                ---- ---8 7654 3210     "Tilemap" Scroll Y

***************************************************************************/

#include "driver.h"
#include "includes/seta.h"

UINT16 *seta2_vregs;

static int yoffset;

/***************************************************************************


                                Video Registers

    Offset:     Bits:                   Value:

    0/2/4/6                             ? Horizontal
    8/a/c/e                             ? Vertical

    10
    12                                  Offset X?
    14                                  Zoom X? low bits
    16                                  Zoom X? high bits *

    18
    1a                                  Offset Y?
    1c                                  Zoom Y? low bits
    1e                                  Zoom Y? high bits

    30          fedc ba98 7654 321-
                ---- ---- ---- ---0     Disable video

    32..3f                              ?


    * A value of 1 is means no zoom, a value of 2 will halve the size.
      It's unknown whether a value less than 1 means magnification (probably yes)

***************************************************************************/

WRITE16_HANDLER( seta2_vregs_w )
{
	/* 02/04 = horizontal display start/end
               mj4simai = 0065/01E5 (0180 visible area)
               myangel =  005D/01D5 (0178 visible area)
               pzlbowl =  0058/01D8 (0180 visible area)
               penbros =  0065/01A5 (0140 visible area)
               grdians =  0059/0188 (012f visible area)
       06    = horizontal total?
               mj4simai = 0204
               myangel =  0200
               pzlbowl =  0204
               penbros =  01c0
               grdians =  019a
    */

	if ( seta2_vregs[offset] != COMBINE_DATA(&seta2_vregs[offset]) )
		logerror("CPU #0 PC %06X: Video Reg %02X <- %04X\n",cpu_get_pc(space->cpu),offset*2,data);

	switch( offset*2 )
	{
	case 0x1c:	// FLIP SCREEN (myangel)    <- this is actually zoom
		flip_screen_set(space->machine,  data & 1 );
		if (data & ~1)	logerror("CPU #0 PC %06X: flip screen unknown bits %04X\n",cpu_get_pc(space->cpu),data);
		break;
	case 0x2a:	// FLIP X (pzlbowl)
		flip_screen_x_set(space->machine,  data & 1 );
		if (data & ~1)	logerror("CPU #0 PC %06X: flipx unknown bits %04X\n",cpu_get_pc(space->cpu),data);
		break;
	case 0x2c:	// FLIP Y (pzlbowl)
		flip_screen_y_set(space->machine,  data & 1 );
		if (data & ~1)	logerror("CPU #0 PC %06X: flipy unknown bits %04X\n",cpu_get_pc(space->cpu),data);
		break;

	case 0x30:	// BLANK SCREEN (pzlbowl, myangel)
		if (data & ~1)	logerror("CPU #0 PC %06X: blank unknown bits %04X\n",cpu_get_pc(space->cpu),data);
		break;
	}
}


/***************************************************************************


                                Sprites Drawing


***************************************************************************/

static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
{
	/* Sprites list */

	UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
	UINT16 *s1  = buffered_spriteram16 + 0x3000/2;
	UINT16 *end = &buffered_spriteram16[machine->generic.spriteram_size/2];

	for ( ; s1 < end; s1+=4 )
	{
		int gfx;
		int num		= s1[0];
		int xoffs	= s1[1];
		int yoffs	= s1[2];
		int sprite	= s1[3];

		/* Single-sprite address */
		UINT16 *s2 = &buffered_spriteram16[(sprite & 0x7fff) * 4];

		/* Single-sprite tile size */
		int global_sizex = xoffs & 0x0c00;
		int global_sizey = yoffs & 0x0c00;

		int use_global_size = num & 0x1000;

		xoffs &= 0x3ff;
		yoffs &= 0x3ff;

		/* Color depth */
		switch (num & 0x0700)
		{
			default:
				popmessage("unknown gfxset %x",(num & 0x0700)>>8);
				gfx = mame_rand(machine)&3; break;
			case 0x0700: 	// 8bpp tiles (76543210)
				gfx = 3; break;
			case 0x0600:	// 6bpp tiles (--543210) (myangel sliding blocks test)
				gfx = 2; break;
			case 0x0500:	// 4bpp tiles (3210----)
				gfx = 1; break;
			case 0x0400:	// 4bpp tiles (----3210)
				gfx = 0; break;
//          case 0x0300:
//              unknown
			case 0x0200:	// 3bpp tiles?  (-----210) (myangel "Graduate Tests")
				gfx = 4; break;
			case 0x0100:	// 2bpp tiles??? (--10----) (myangel2 question bubble, myangel endgame)
				gfx = 5; break;
			case 0x0000:	// no idea!
				gfx = 0; break;
		}

		/* Number of single-sprites */
		num = (num & 0x00ff) + 1;

		for( ; num > 0; num--,s2+=4 )
		{
			if (s2 >= end)	break;

// "tilemap" sprite

			if (sprite & 0x8000)
			{
				rectangle clip;
				int dx,x,y;
				int flipx;
				int flipy;
				int sx       = s2[0];
				int sy       = s2[1];
				int scrollx  = s2[2];
				int scrolly  = s2[3];
				int tilesize = (scrollx & 0x8000) >> 15;
				int page     = (scrollx & 0x7c00) >> 10;
				int height   = ((sy & 0xfc00) >> 10) + 1;

				sx &= 0x3ff;
				sy &= 0x1ff;
				scrollx &= 0x3ff;
				scrolly &= 0x1ff;

				clip.min_y = (sy + yoffs) & 0x1ff;
				clip.max_y = clip.min_y + height * 0x10 - 1;

				if (clip.min_y > cliprect->max_y)	continue;
				if (clip.max_y < cliprect->min_y)	continue;

				clip.min_x = cliprect->min_x;
				clip.max_x = cliprect->max_x;

				if (clip.min_y < cliprect->min_y)	clip.min_y = cliprect->min_y;
				if (clip.max_y > cliprect->max_y)	clip.max_y = cliprect->max_y;

				dx = sx + (scrollx & 0x3ff) + xoffs + 0x10;

				/* Draw the rows */
				/* I don't think the following is entirely correct (when using 16x16
                   tiles x should probably loop from 0 to 0x20) but it seems to work
                   fine in all the games we have for now. */
				for (y = 0; y < (0x40 >> tilesize); y++)
				{
					int py = ((scrolly - (y+1) * (8 << tilesize) + 0x10) & 0x1ff) - 0x10 - yoffset;

					if (py < clip.min_y - 0x10) continue;
					if (py > clip.max_y) continue;

					for (x = 0; x < 0x40;x++)
					{
						int px = ((dx + x * (8 << tilesize) + 0x10) & 0x3ff) - 0x10;
						int tx, ty;
						int attr, code, color;
						UINT16 *s3;

						if (px < clip.min_x - 0x10) continue;
						if (px > clip.max_x) continue;

						s3	=	&buffered_spriteram16[2 * ((page * 0x2000/4) + ((y & 0x1f) << 6) + (x & 0x03f))];

						attr  = s3[0];
						code  = s3[1] + ((attr & 0x0007) << 16);
						flipx = (attr & 0x0010);
						flipy = (attr & 0x0008);
						color = (attr & 0xffe0) >> 5;

						if (tilesize) code &= ~3;

						for (ty = 0; ty <= tilesize; ty++)
						{
							for (tx = 0; tx <= tilesize; tx++)
							{
								drawgfx_transpen(bitmap, cliprect,machine->gfx[gfx],
										code ^ tx ^ (ty<<1),
										color,
										flipx, flipy,
										px + (flipx ? tilesize-tx : tx) * 8, py + (flipy ? tilesize-ty : ty) * 8,0 );
							}
						}

					}
				}
			}
			else
// "normal" sprite
			{
				int sx    = s2[0];
				int sy    = s2[1];
				int attr  = s2[2];
				int code  = s2[3] + ((attr & 0x0007) << 16);
				int flipx = (attr & 0x0010);
				int flipy = (attr & 0x0008);
				int color = (attr & 0xffe0) >> 5;

				int sizex = use_global_size ? global_sizex : sx;
				int sizey = use_global_size ? global_sizey : sy;
				int x,y;
				sizex = (1 << ((sizex & 0x0c00)>> 10))-1;
				sizey = (1 << ((sizey & 0x0c00)>> 10))-1;


				sx += xoffs;
				sy += yoffs;

				sx = (sx & 0x1ff) - (sx & 0x200);
				sy &= 0x1ff;
				sy -= yoffset;

				code &= ~((sizex+1) * (sizey+1) - 1);	// see myangel, myangel2 and grdians

				for (y = 0; y <= sizey; y++)
				{
					for (x = 0; x <= sizex; x++)
					{
						drawgfx_transpen(bitmap, cliprect,machine->gfx[gfx],
								code++,
								color,
								flipx, flipy,
								sx + (flipx ? sizex-x : x) * 8, sy + (flipy ? sizey-y : y) * 8,0 );
					}
				}
			}
		}

		if (s1[0] & 0x8000) break;	/* end of list marker */
	}	/* sprite list */
}


/***************************************************************************


                                Screen Drawing


***************************************************************************/

VIDEO_START( seta2 )
{
	machine->gfx[2]->color_granularity = 16;
	machine->gfx[3]->color_granularity = 16;
	machine->gfx[4]->color_granularity = 16;
	machine->gfx[5]->color_granularity = 16;

	machine->generic.buffered_spriteram.u16 = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);

	yoffset = 0;
}

VIDEO_START( seta2_offset )
{
	VIDEO_START_CALL(seta2);

	yoffset = 0x10;
}

VIDEO_UPDATE( seta2 )
{
	/* Black or pen 0? */
	bitmap_fill(bitmap,cliprect,0);

	if (seta2_vregs[0x30/2] & 1)	return 0;		// BLANK SCREEN

	draw_sprites(screen->machine,bitmap,cliprect);
	return 0;
}

VIDEO_EOF( seta2 )
{
	/* Buffer sprites by 1 frame */
	memcpy(machine->generic.buffered_spriteram.u16,machine->generic.spriteram.u16,machine->generic.spriteram_size);
}