|
|
1.1 ! root 1: #ifndef DRIVER_H ! 2: #define DRIVER_H ! 3: ! 4: #include "osd_cpu.h" ! 5: #include "memory.h" ! 6: #include "mamedbg.h" ! 7: #include "osdepend.h" ! 8: #include "mame.h" ! 9: #include "common.h" ! 10: #include "drawgfx.h" ! 11: #include "palette.h" ! 12: #include "cpuintrf.h" ! 13: #include "sndintrf.h" ! 14: #include "input.h" ! 15: #include "inptport.h" ! 16: #include "usrintrf.h" ! 17: #include "cheat.h" ! 18: #include "tilemap.h" ! 19: #include "profiler.h" ! 20: ! 21: #ifdef MAME_NET ! 22: #include "network.h" ! 23: #endif /* MAME_NET */ ! 24: ! 25: ! 26: #define MAX_CPU 8 /* MAX_CPU is the maximum number of CPUs which cpuintrf.c */ ! 27: /* can run at the same time. Currently, 8 is enough. */ ! 28: ! 29: #define MAX_SOUND 5 /* MAX_SOUND is the maximum number of sound subsystems */ ! 30: /* which can run at the same time. Currently, 5 is enough. */ ! 31: ! 32: ! 33: ! 34: struct MachineDriver ! 35: { ! 36: /* basic machine hardware */ ! 37: const struct MachineCPU cpu[MAX_CPU]; ! 38: float frames_per_second; ! 39: int vblank_duration; /* in microseconds - see description below */ ! 40: int cpu_slices_per_frame; /* for multicpu games. 1 is the minimum, meaning */ ! 41: /* that each CPU runs for the whole video frame */ ! 42: /* before giving control to the others. The higher */ ! 43: /* this setting, the more closely CPUs are interleaved */ ! 44: /* and therefore the more accurate the emulation is. */ ! 45: /* However, an higher setting also means slower */ ! 46: /* performance. */ ! 47: void (*init_machine)(void); ! 48: #ifdef MESS ! 49: void (*stop_machine)(void); /* needed for MESS */ ! 50: #endif ! 51: ! 52: /* video hardware */ ! 53: int screen_width,screen_height; ! 54: const struct rectangle default_visible_area; /* the visible area can be changed at */ ! 55: /* run time, but it should never be larger than the */ ! 56: /* one specified here, in order not to force the */ ! 57: /* OS dependant code to resize the display window. */ ! 58: const struct GfxDecodeInfo *gfxdecodeinfo; ! 59: unsigned int total_colors; /* palette is 3*total_colors bytes long */ ! 60: unsigned int color_table_len; /* length in shorts of the color lookup table */ ! 61: void (*vh_init_palette)(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); ! 62: ! 63: int video_attributes; /* ASG 081897 */ ! 64: ! 65: void (*vh_eof_callback)(void); /* called every frame after osd_update_video_and_audio() */ ! 66: /* This is useful when there are operations that need */ ! 67: /* to be performed every frame regardless of frameskip, */ ! 68: /* e.g. sprite buffering or collision detection. */ ! 69: int (*vh_start)(void); ! 70: void (*vh_stop)(void); ! 71: void (*vh_update)(struct osd_bitmap *bitmap,int full_refresh); ! 72: ! 73: /* sound hardware */ ! 74: int sound_attributes; ! 75: int obsolete1; ! 76: int obsolete2; ! 77: int obsolete3; ! 78: const struct MachineSound sound[MAX_SOUND]; ! 79: ! 80: /* ! 81: use this to manage nvram/eeprom/cmos/etc. ! 82: It is called before the emulation starts and after it ends. Note that it is ! 83: NOT called when the game is reset, since it is not needed. ! 84: file == 0, read_or_write == 0 -> first time the game is run, initialize nvram ! 85: file != 0, read_or_write == 0 -> load nvram from disk ! 86: file == 0, read_or_write != 0 -> not allowed ! 87: file != 0, read_or_write != 0 -> save nvram to disk ! 88: */ ! 89: void (*nvram_handler)(void *file,int read_or_write); ! 90: }; ! 91: ! 92: ! 93: ! 94: /* VBlank is the period when the video beam is outside of the visible area and */ ! 95: /* returns from the bottom to the top of the screen to prepare for a new video frame. */ ! 96: /* VBlank duration is an important factor in how the game renders itself. MAME */ ! 97: /* generates the vblank_interrupt, lets the game run for vblank_duration microseconds, */ ! 98: /* and then updates the screen. This faithfully reproduces the behaviour of the real */ ! 99: /* hardware. In many cases, the game does video related operations both in its vblank */ ! 100: /* interrupt, and in the normal game code; it is therefore important to set up */ ! 101: /* vblank_duration accurately to have everything properly in sync. An example of this */ ! 102: /* is Commando: if you set vblank_duration to 0, therefore redrawing the screen BEFORE */ ! 103: /* the vblank interrupt is executed, sprites will be misaligned when the screen scrolls. */ ! 104: ! 105: /* Here are some predefined, TOTALLY ARBITRARY values for vblank_duration, which should */ ! 106: /* be OK for most cases. I have NO IDEA how accurate they are compared to the real */ ! 107: /* hardware, they could be completely wrong. */ ! 108: #define DEFAULT_60HZ_VBLANK_DURATION 0 ! 109: #define DEFAULT_30HZ_VBLANK_DURATION 0 ! 110: /* If you use IPT_VBLANK, you need a duration different from 0. */ ! 111: #define DEFAULT_REAL_60HZ_VBLANK_DURATION 2500 ! 112: #define DEFAULT_REAL_30HZ_VBLANK_DURATION 2500 ! 113: ! 114: ! 115: ! 116: /* flags for video_attributes */ ! 117: ! 118: /* bit 1 of the video attributes indicates whether or not dirty rectangles will work */ ! 119: #define VIDEO_SUPPORTS_DIRTY 0x0002 ! 120: ! 121: /* bit 0 of the video attributes indicates raster or vector video hardware */ ! 122: #define VIDEO_TYPE_RASTER 0x0000 ! 123: #define VIDEO_TYPE_VECTOR 0x0001 ! 124: ! 125: /* bit 3 of the video attributes indicates that the game's palette has 6 or more bits */ ! 126: /* per gun, and would therefore require a 24-bit display. This is entirely up to */ ! 127: /* the OS dependant layer, the bitmap will still be 16-bit. */ ! 128: #define VIDEO_NEEDS_6BITS_PER_GUN 0x0008 ! 129: ! 130: /* ASG 980417 - added: */ ! 131: /* bit 4 of the video attributes indicates that the driver wants its refresh after */ ! 132: /* the VBLANK instead of before. */ ! 133: #define VIDEO_UPDATE_BEFORE_VBLANK 0x0000 ! 134: #define VIDEO_UPDATE_AFTER_VBLANK 0x0010 ! 135: ! 136: /* In most cases we assume pixels are square (1:1 aspect ratio) but some games need */ ! 137: /* different proportions, e.g. 1:2 for Blasteroids */ ! 138: #define VIDEO_PIXEL_ASPECT_RATIO_MASK 0x0060 ! 139: #define VIDEO_PIXEL_ASPECT_RATIO_1_1 0x0000 ! 140: #define VIDEO_PIXEL_ASPECT_RATIO_1_2 0x0020 ! 141: #define VIDEO_PIXEL_ASPECT_RATIO_2_1 0x0040 ! 142: ! 143: #define VIDEO_DUAL_MONITOR 0x0080 ! 144: ! 145: /* Mish 181099: See comments in vidhrdw/generic.c for details */ ! 146: #define VIDEO_BUFFERS_SPRITERAM 0x0100 ! 147: ! 148: /* game wants to use a hicolor or truecolor bitmap (e.g. for alpha blending) */ ! 149: #define VIDEO_RGB_DIRECT 0x0200 ! 150: ! 151: /* automatically extend the palette creating a darker copy for shadows */ ! 152: #define VIDEO_HAS_SHADOWS 0x0400 ! 153: ! 154: /* automatically extend the palette creating a brighter copy for highlights */ ! 155: #define VIDEO_HAS_HIGHLIGHTS 0x0800 ! 156: ! 157: /* generic aspect ratios */ ! 158: #define VIDEO_ASPECT_RATIO_MASK 0xffff0000 ! 159: #define VIDEO_ASPECT_RATIO_NUM(a) (((a) >> 24) & 0xff) ! 160: #define VIDEO_ASPECT_RATIO_DEN(a) (((a) >> 16) & 0xff) ! 161: #define VIDEO_ASPECT_RATIO(n,d) ((((n) & 0xff) << 24) | (((d) & 0xff) << 16)) ! 162: ! 163: ! 164: /* flags for sound_attributes */ ! 165: #define SOUND_SUPPORTS_STEREO 0x0001 ! 166: ! 167: ! 168: ! 169: struct GameDriver ! 170: { ! 171: const char *source_file; /* set this to __FILE__ */ ! 172: const struct GameDriver *clone_of; /* if this is a clone, point to */ ! 173: /* the main version of the game */ ! 174: const char *name; ! 175: const char *description; ! 176: const char *year; ! 177: const char *manufacturer; ! 178: const struct MachineDriver *drv; ! 179: const struct InputPortTiny *input_ports; ! 180: void (*driver_init)(void); /* optional function to be called during initialization */ ! 181: /* This is called ONCE, unlike Machine->init_machine */ ! 182: /* which is called every time the game is reset. */ ! 183: ! 184: const struct RomModule *rom; ! 185: #ifdef MESS ! 186: const struct IODevice *dev; ! 187: #endif ! 188: ! 189: UINT32 flags; /* orientation and other flags; see defines below */ ! 190: }; ! 191: ! 192: ! 193: /* values for the flags field */ ! 194: ! 195: #define ORIENTATION_MASK 0x0007 ! 196: #define ORIENTATION_FLIP_X 0x0001 /* mirror everything in the X direction */ ! 197: #define ORIENTATION_FLIP_Y 0x0002 /* mirror everything in the Y direction */ ! 198: #define ORIENTATION_SWAP_XY 0x0004 /* mirror along the top-left/bottom-right diagonal */ ! 199: ! 200: #define GAME_NOT_WORKING 0x0008 ! 201: #define GAME_UNEMULATED_PROTECTION 0x0010 /* game's protection not fully emulated */ ! 202: #define GAME_WRONG_COLORS 0x0020 /* colors are totally wrong */ ! 203: #define GAME_IMPERFECT_COLORS 0x0040 /* colors are not 100% accurate, but close */ ! 204: #define GAME_IMPERFECT_GRAPHICS 0x0080 /* graphics are wrong/incomplete */ ! 205: #define GAME_NO_COCKTAIL 0x0100 /* screen flip support is missing */ ! 206: #define GAME_NO_SOUND 0x0200 /* sound is missing */ ! 207: #define GAME_IMPERFECT_SOUND 0x0400 /* sound is known to be wrong */ ! 208: #define NOT_A_DRIVER 0x4000 /* set by the fake "root" driver_0 and by "containers" */ ! 209: /* e.g. driver_neogeo. */ ! 210: #ifdef MESS ! 211: #define GAME_COMPUTER 0x8000 /* Driver is a computer (needs full keyboard) */ ! 212: #define GAME_COMPUTER_MODIFIED 0x0800 /* Official? Hack */ ! 213: #define GAME_ALIAS NOT_A_DRIVER /* Driver is only an alias for an existing model */ ! 214: #endif ! 215: ! 216: ! 217: #define GAME(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME) \ ! 218: extern const struct GameDriver driver_##PARENT; \ ! 219: const struct GameDriver driver_##NAME = \ ! 220: { \ ! 221: __FILE__, \ ! 222: &driver_##PARENT, \ ! 223: #NAME, \ ! 224: FULLNAME, \ ! 225: #YEAR, \ ! 226: COMPANY, \ ! 227: &machine_driver_##MACHINE, \ ! 228: input_ports_##INPUT, \ ! 229: init_##INIT, \ ! 230: rom_##NAME, \ ! 231: MONITOR \ ! 232: }; ! 233: ! 234: #define GAMEX(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME,FLAGS) \ ! 235: extern const struct GameDriver driver_##PARENT; \ ! 236: const struct GameDriver driver_##NAME = \ ! 237: { \ ! 238: __FILE__, \ ! 239: &driver_##PARENT, \ ! 240: #NAME, \ ! 241: FULLNAME, \ ! 242: #YEAR, \ ! 243: COMPANY, \ ! 244: &machine_driver_##MACHINE, \ ! 245: input_ports_##INPUT, \ ! 246: init_##INIT, \ ! 247: rom_##NAME, \ ! 248: (MONITOR)|(FLAGS) \ ! 249: }; ! 250: ! 251: ! 252: /* monitor parameters to be used with the GAME() macro */ ! 253: #define ROT0 0 ! 254: #define ROT90 (ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X) /* rotate clockwise 90 degrees */ ! 255: #define ROT180 (ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y) /* rotate 180 degrees */ ! 256: #define ROT270 (ORIENTATION_SWAP_XY|ORIENTATION_FLIP_Y) /* rotate counter-clockwise 90 degrees */ ! 257: ! 258: /* this allows to leave the INIT field empty in the GAME() macro call */ ! 259: #define init_0 0 ! 260: ! 261: ! 262: extern const struct GameDriver *drivers[]; ! 263: ! 264: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.