⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cps1.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************//*                                                                           *//*                   CAPCOM SYSTEM 1 / CPS1 (C) 1990 CAPCOM                  *//* Based on the mame source, but lots of things were rewritten...            *//* Thnaks to the mame team to show how all this works anyway !               *//* See cps1drv.c for the games related data...                               *//*****************************************************************************/#include "gameinc.h"#include "cps1.h"#include "taitosnd.h"#include "mame/eeprom.h"#include "savegame.h"#include "sasound.h"#ifdef RAINE_DEBUG#include "debug.h"#endif/* Output ports */#define CPS1_OBJ_BASE		0x00    /* Base address of objects */#define CPS1_SCROLL1_BASE       0x01    /* Base address of scroll 1 */#define CPS1_SCROLL2_BASE       0x02    /* Base address of scroll 2 */#define CPS1_SCROLL3_BASE       0x03    /* Base address of scroll 3 */#define CPS1_OTHER_BASE		0x04    /* Base address of other video */#define CPS1_PALETTE_BASE       0x05    /* Base address of palette */#define CPS1_SCROLL1_SCROLLX    0x06    /* Scroll 1 X */#define CPS1_SCROLL1_SCROLLY    0x07    /* Scroll 1 Y */#define CPS1_SCROLL2_SCROLLX    0x08    /* Scroll 2 X */#define CPS1_SCROLL2_SCROLLY    0x09    /* Scroll 2 Y */#define CPS1_SCROLL3_SCROLLX    0x0a    /* Scroll 3 X */#define CPS1_SCROLL3_SCROLLY    0x0b    /* Scroll 3 Y */#define CPS1_STARS1_SCROLLX     0x0c    /* Stars 1 X */#define CPS1_STARS1_SCROLLY     0x0d    /* Stars 1 Y */#define CPS1_STARS2_SCROLLX     0x0e    /* Stars 2 X */#define CPS1_STARS2_SCROLLY     0x0f    /* Stars 2 Y */#define CPS1_ROWSCROLL_OFFS     0x10    /* base of row scroll offsets in other RAM */#define CPS1_SCROLL2_WIDTH      0x40#define CPS1_SCROLL2_HEIGHT     0x40#define qsound_rom (Z80RAM+0x4000)#define qsound_decode (Z80RAM+0xc000)const int srcwidth = CPS1_SCROLL2_WIDTH * 0x10;const int srcheight = CPS1_SCROLL2_HEIGHT * 0x10;const int cps1_scroll1_size=0x4000;const int cps1_scroll2_size=0x4000;const int cps1_scroll3_size=0x4000;const int cps1_obj_size    =0x0800;const int cps1_other_size  =0x0800;#define cps1_palette_entries (32*8)  /* Number colour schemes in palette */const int cps1_palette_size=cps1_palette_entries*32; /* Size of palette RAM */static UINT8 *RAM_SPR,*Z80RAM,*qsound_sharedram1,*qsound_sharedram2;static UINT8 *GFX_SPR,*GFX_SPR16,*GFX_SPR32;static UINT8 *GFX_SPR_SOLID;static UINT8 *GFX_SPR_SOLID16,*GFX_SPR_SOLID32;static UINT8 *cps1_gfxram,*cps1_palette;static UINT8 *cps1_buffered_obj;static int cps1_last_sprite_offset;     /* Offset of the last sprite */static int cps1_layer_enabled[4];       /* Layer enabled [Y/N] */static int cps1_stars_enabled;          /* Layer enabled [Y/N] */static int cps1_flip_screen;    /* Flip screen on / off */static int base2,base1,base3,scrwidth,scrheight,spacechar;static int scrlx,scrly,kludge,size_code2;static UINT32 max_sprites,max_sprites32,max_sprites8;/**********************************************************************  EEPROM*  ======**   The EEPROM is accessed by a serial protocol using the register*   0xf1c006*********************************************************************/static struct EEPROM_interface qsound_eeprom_interface ={	7,		/* address bits */	8,		/* data bits */	"0110",	/*  read command */	"0101",	/* write command */	"0111"	/* erase command */};static struct EEPROM_interface pang3_eeprom_interface ={	6,		/* address bits */	16,		/* data bits */	"0110",	/*  read command */	"0101",	/* write command */	"0111"	/* erase command */};UINT16 cps1_eeprom_port_r(UINT32 offset){  return EEPROM_read_bit();}void cps1_eeprom_port_w(UINT32 offset,UINT16 data){  /*    bit 0 = data    bit 6 = clock    bit 7 = cs  */  EEPROM_write_bit(data & 0x01);  EEPROM_set_cs_line((data & 0x80) ? CLEAR_LINE : ASSERT_LINE);  EEPROM_set_clock_line((data & 0x40) ? ASSERT_LINE : CLEAR_LINE);}// Z80 Bankswitch#define MAX_BANKS 0x20static UINT8 *ROM_BANK,*bank[MAX_BANKS];static UINT16 nb_banks,current_bank;void init_banks(UINT8 *rombase) {  UINT32 size,n;  nb_banks = (get_region_size(REGION_ROM2) - 0x8000)/0x4000;  size = nb_banks * (0x8000 + 0x4000); // must copy the rom for each bank  if (nb_banks > MAX_BANKS) {    allegro_message("nb_banks (%d) > MAX_BANKS",nb_banks);    exit(1);  }  ROM_BANK = AllocateMem(size);  if (!ROM_BANK) return;    for (n=0; n<nb_banks; n++) {    UINT8 *dst = ROM_BANK + n * 0xc000;    bank[n] = dst;    memcpy(dst, rombase, 0x8000); // ROM    memcpy(dst+0x8000, Z80ROM+0x8000+(n*0x4000), 0x4000); // bank  }    current_bank = -1;}void cps1_set_bank(UINT16 offset, UINT8 data){  if (data != current_bank && data < nb_banks) {    current_bank = data;    Z80ASetBank(bank[data]);  } }// Soundstatic UINT8 cps1_sound_fade_timer,latch;static void qsound_banksw_w(UINT16 offset,UINT8 data){  data &= 0xf;    if (data != current_bank && data < nb_banks) {    current_bank = data;    Z80ASetBank(bank[data]);  }  }/******************************************************************************//*                                                                            *//*                        PROTECTION DEVICES KTNXMAME                         *//*                                                                            *//******************************************************************************//* Game specific data *//* Game specific data */struct CPS1config{	char *name;             /* game driver name */	/* Some games interrogate a couple of registers on bootup. */	/* These are CPS1 board B self test checks. They wander from game to */	/* game. */	int cpsb_addr;        /* CPS board B test register address */	int cpsb_value;       /* CPS board B test register expected value */	/* some games use as a protection check the ability to do 16-bit multiplies */	/* with a 32-bit result, by writing the factors to two ports and reading the */	/* result from two other ports. */	/* It looks like this feature was introduced with 3wonders (CPSB ID = 08xx) */	int mult_factor1;	int mult_factor2;	int mult_result_lo;	int mult_result_hi;	int layer_control;	int priority0;	int priority1;	int priority2;	int priority3;	int control_reg;  /* Control register? seems to be always 0x3f */	/* ideally, the layer enable masks should consist of only one bit, */	/* but in many cases it is unknown which bit is which. */	int scrl1_enable_mask;	int scrl2_enable_mask;	int scrl3_enable_mask;	int stars_enable_mask;	int bank_scroll1;	int bank_scroll2;	int bank_scroll3;	/* Some characters aren't visible */	const int start_scroll2;	const int end_scroll2;	const int start_scroll3;	const int end_scroll3;	int kludge;  /* Ghouls n Ghosts sprite kludge */};struct CPS1config *cps1_game_config;/*                 CPSB ID    multiply protection  ctrl    priority masks  unknwn     layer enable    */#define CPS_B_01 0x00,0x0000, 0,0,0,0, /* n/a */   0x66,0x68,0x6a,0x6c,0x6e,0x70, 0x02,0x04,0x08,0x30#define UNKNW_02 0x00,0x0000, 0,0,0,0, /* n/a */   0x6c,0x6a,0x68,0x66,0x64,0x62, 0x02,0x04,0x08,0x00#define UNKNW_03 0x00,0x0000, 0,0,0,0, /* n/a */   0x70,0x6e,0x6c,0x6a,0x68,0x66, 0x20,0x10,0x08,0x00#define CPS_B_04 0x60,0x0004, 0,0,0,0, /* n/a */   0x6e,0x66,0x70,0x68,0x72,0x6a, 0x02,0x0c,0x0c,0x00#define CPS_B_05 0x60,0x0005, 0,0,0,0, /* n/a */   0x68,0x6a,0x6c,0x6e,0x70,0x72, 0x02,0x08,0x20,0x14#define CPS_B_11 0x00,0x0000, 0,0,0,0, /* n/a */   0x66,0x68,0x6a,0x6c,0x6e,0x70, 0x20,0x10,0x08,0x00#define CPS_B_12 0x60,0x0402, 0,0,0,0, /* n/a */   0x6c,0x00,0x00,0x00,0x00,0x62, 0x02,0x04,0x08,0x00#define CPS_B_13 0x6e,0x0403, 0,0,0,0, /* n/a */   0x62,0x64,0x66,0x68,0x6a,0x6c, 0x20,0x04,0x02,0x00#define CPS_B_14 0x5e,0x0404, 0,0,0,0, /* n/a */   0x52,0x54,0x56,0x58,0x5a,0x5c, 0x08,0x30,0x30,0x00#define CPS_B_15 0x4e,0x0405, 0,0,0,0, /* n/a */   0x42,0x44,0x46,0x48,0x4a,0x4c, 0x04,0x22,0x22,0x00#define CPS_B_16 0x40,0x0406, 0,0,0,0, /* n/a */   0x4c,0x4a,0x48,0x46,0x44,0x42, 0x10,0x0a,0x0a,0x00#define CPS_B_17 0x48,0x0407, 0,0,0,0, /* n/a */   0x54,0x52,0x50,0x4e,0x4c,0x4a, 0x08,0x10,0x02,0x00#define CPS_B_18 0xd0,0x0408, 0,0,0,0, /* n/a */   0xdc,0xda,0xd8,0xd6,0xd4,0xd2, 0x10,0x0a,0x0a,0x00#define NOBATTRY 0x00,0x0000, 0x40,0x42,0x44,0x46, 0x66,0x68,0x6a,0x6c,0x6e,0x70, 0x02,0x04,0x08,0x00#define BATTRY_1 0x72,0x0800, 0x4e,0x4c,0x4a,0x48, 0x68,0x66,0x64,0x62,0x60,0x70, 0x20,0x04,0x08,0x12#define BATTRY_2 0x00,0x0000, 0x5e,0x5c,0x5a,0x58, 0x60,0x6e,0x6c,0x6a,0x68,0x70, 0x30,0x08,0x30,0x00#define BATTRY_3 0x00,0x0000, 0x46,0x44,0x42,0x40, 0x60,0x6e,0x6c,0x6a,0x68,0x70, 0x20,0x12,0x12,0x00#define BATTRY_4 0x00,0x0000, 0x46,0x44,0x42,0x40, 0x68,0x66,0x64,0x62,0x60,0x70, 0x20,0x10,0x02,0x00#define BATTRY_5 0x00,0x0000, 0x00,0x00,0x00,0x00, 0x6e,0x66,0x70,0x68,0x72,0x6a, 0x02,0x0c,0x0c,0x00#define BATTRY_6 0x00,0x0000, 0x4e,0x4c,0x4a,0x48, 0x60,0x6e,0x6c,0x6a,0x68,0x70, 0x20,0x06,0x06,0x00#define BATTRY_7 0x00,0x0000, 0x00,0x00,0x00,0x00, 0x60,0x6e,0x6c,0x6a,0x68,0x70, 0x20,0x14,0x14,0x00#define BATTRY_8 0x00,0x0000, 0x00,0x00,0x00,0x00, 0x6c,0x00,0x00,0x00,0x00,0x52, 0x14,0x02,0x14,0x00#define QSOUND_1 0x00,0x0000, 0x00,0x00,0x00,0x00, 0x62,0x64,0x66,0x68,0x6a,0x6c, 0x10,0x08,0x04,0x00#define QSOUND_2 0x00,0x0000, 0x00,0x00,0x00,0x00, 0x4a,0x4c,0x4e,0x40,0x42,0x44, 0x16,0x16,0x16,0x00#define QSOUND_3 0x4e,0x0c00, 0x00,0x00,0x00,0x00, 0x52,0x54,0x56,0x48,0x4a,0x4c, 0x04,0x02,0x20,0x00#define QSOUND_4 0x6e,0x0c01, 0x00,0x00,0x00,0x00, 0x56,0x40,0x42,0x68,0x6a,0x6c, 0x04,0x08,0x10,0x00#define QSOUND_5 0x5e,0x0c02, 0x00,0x00,0x00,0x00, 0x6a,0x6c,0x6e,0x70,0x72,0x5c, 0x04,0x08,0x10,0x00static struct CPS1config cps1_config_table[]={	/* name       CPSB    banks        tile limits            kludge */	{"forgottn",CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 7 },	{"lostwrld",CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 7 },	{"ghouls",  CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 1 },	{"ghoulsu", CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 1 },	{"daimakai",CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 1 },	{"strider", CPS_B_01, 1,0,1, 0x0000,0xffff,0x0000,0xffff },	{"striderj",CPS_B_01, 1,0,1, 0x0000,0xffff,0x0000,0xffff },	{"stridrja",CPS_B_01, 1,0,1, 0x0000,0xffff,0x0000,0xffff },	{"dwj",     UNKNW_02, 0,1,1, 0x0000,0xffff,0x0000,0xffff },	{"willow",  UNKNW_03, 0,1,0, 0x0000,0xffff,0x0000,0xffff },	{"willowj", UNKNW_03, 0,1,0, 0x0000,0xffff,0x0000,0xffff },	{"unsquad", CPS_B_11, 0,0,0, 0x0000,0xffff,0x0001,0xffff },	{"area88",  CPS_B_11, 0,0,0, 0x0000,0xffff,0x0001,0xffff },	{"ffight",  CPS_B_04, 0,0,0, 0x0001,0xffff,0x0001,0xffff },	{"ffightu", CPS_B_01, 0,0,0, 0x0001,0xffff,0x0001,0xffff },	{"ffightj", CPS_B_04, 0,0,0, 0x0001,0xffff,0x0001,0xffff },	{"1941",    CPS_B_05, 0,0,0, 0x0000,0xffff,0x0400,0x07ff },	{"1941j",   CPS_B_05, 0,0,0, 0x0000,0xffff,0x0400,0x07ff },	{"mercs",   CPS_B_12, 0,0,0, 0x0600,0x5bff,0x0700,0x17ff, 4 },	/* (uses port 74) */	{"mercsu",  CPS_B_12, 0,0,0, 0x0600,0x5bff,0x0700,0x17ff, 4 },	/* (uses port 74) */	{"mercsj",  CPS_B_12, 0,0,0, 0x0600,0x5bff,0x0700,0x17ff, 4 },	/* (uses port 74) */	{"msword",  CPS_B_13, 0,0,0, 0x2800,0x37ff,0x0000,0xffff },	/* CPSB ID not checked, but it's the same as sf2j */	{"mswordu", CPS_B_13, 0,0,0, 0x2800,0x37ff,0x0000,0xffff },	/* CPSB ID not checked, but it's the same as sf2j */	{"mswordj", CPS_B_13, 0,0,0, 0x2800,0x37ff,0x0000,0xffff },	/* CPSB ID not checked, but it's the same as sf2j */	{"mtwins",  CPS_B_14, 0,0,0, 0x0000,0x3fff,0x0e00,0xffff },	{"chikij",  CPS_B_14, 0,0,0, 0x0000,0x3fff,0x0e00,0xffff },	{"nemo",    CPS_B_15, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"nemoj",   CPS_B_15, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"cawing",  CPS_B_16, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"cawingj", CPS_B_16, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"sf2",     CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2ua",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2ub",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2ue",   CPS_B_18, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2ui",   CPS_B_14, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2j",    CPS_B_13, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2ja",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2jc",   CPS_B_12, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	/* from here onwards the CPS-B board has suicide battery and multiply protection */	{"3wonders",BATTRY_1, 0,1,1, 0x0000,0xffff,0x0000,0xffff, 2 },	{"3wonderu",BATTRY_1, 0,1,1, 0x0000,0xffff,0x0000,0xffff, 2 },	{"wonder3", BATTRY_1, 0,1,1, 0x0000,0xffff,0x0000,0xffff, 2 },	{"kod",     BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"kodu",    BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"kodj",    BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"kodb",    BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* bootleg, doesn't use multiply protection */	{"captcomm",BATTRY_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"captcomu",BATTRY_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"captcomj",BATTRY_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"knights", BATTRY_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 3 },	{"knightsu",BATTRY_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 3 },	{"knightsj",BATTRY_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 3 },	{"sf2ce",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2ceua", NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2ceub", NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2cej",  NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2rb",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2rb2",  NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2red",  NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2v004", NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2accp2",NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"varth",   BATTRY_5, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* CPSB test has been patched out (60=0008) */	{"varthu",  BATTRY_5, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* CPSB test has been patched out (60=0008) */	{"varthj",  BATTRY_6, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* CPSB test has been patched out (72=0001) */	{"cworld2j",BATTRY_7, 0,0,0, 0x0000,0xffff,0x0000,0xffff },  /* The 0x76 priority values are incorrect values */	{"wof",     CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* bootleg? */	{"wofa",    CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* bootleg? */	{"wofu",    QSOUND_1, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"wofj",    QSOUND_1, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"dino",    QSOUND_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* layer enable never used */	{"dinoj",   QSOUND_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* layer enable never used */	{"punisher",QSOUND_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"punishru",QSOUND_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"punishrj",QSOUND_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"slammast",QSOUND_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"slammasu",QSOUND_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"mbomberj",QSOUND_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"mbombrd", QSOUND_5, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"mbombrdj",QSOUND_5, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"sf2t",    NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"sf2tj",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },	{"qad",     BATTRY_8, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	/* TODO: layer enable */	{"qadj",    NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"qtono2",  NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"megaman", CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"rockmanj",CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"pnickj",  CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	{"pang3",   CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 5 },	/* EEPROM port is among the CPS registers */	{"pang3j",  CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 5 },	/* EEPROM port is among the CPS registers */	#ifdef MESS	{"sfzch",   CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff },	#endif    /* CPS2 games */	{"cps2",    NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff },	{"ssf2",    NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },	{"ssf2a",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },	{"ssf2j",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },	{"ssf2jr1", NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },	{"ssf2jr2", NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },	{"ssf2t",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },	{"ssf2tu",  NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },	{"ssf2ta",  NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },	{"ssf2xj",  NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },	{"xmcota",  NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },	{"xmcotaj", NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },	{"xmcotaj1",NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },	{0}		/* End of table */};static UINT16 cps1_output[0x100],scroll2x,scroll2y;static void cps1_find_last_sprite(void)    /* Find the offset of last sprite */{    int offset=0;	/* Locate the end of table marker */    while (offset < cps1_obj_size)	{        int colour=ReadWord(&cps1_buffered_obj[offset+6]);			if (colour == 0xff00)		{			/* Marker found. This is the last sprite. */            cps1_last_sprite_offset=offset-8;			return;		}        offset+=8;	}	/* Sprites must use full sprite RAM */    cps1_last_sprite_offset=cps1_obj_size-8;}INLINE UINT8 *cps1_base(int offset,int boundary){	int base=cps1_output[offset]*256;	/*	The scroll RAM must start on a 0x4000 boundary.	Some games do not do this.	For example:	   Captain commando     - continue screen will not display	   Muscle bomber games  - will animate garbage during gameplay	Mask out the irrelevant bits.	*/	base &= ~(boundary-1); 	return &cps1_gfxram[(base&0x3ffff)];}static UINT16 oldx,oldy,oldx2,oldy2;static void cps1_init_machine(void){   struct CPS1config *pCFG=&cps1_config_table[0];   memset(input_buffer,0xff,0x20);      cps1_sound_fade_timer = latch = 0xff;   size_code2 = get_region_size(REGION_ROM2);      oldx2 = oldx = 0xffff; // To have scroll1x != oldx      while(pCFG->name)   {      if (is_current_game(pCFG->name))      {         break;      }      pCFG++;   }   cps1_game_config=pCFG;   kludge=cps1_game_config->kludge;      if (kludge == 7) // forgottn has digital input     GameMouse=1;   if (is_current_game("sf2rb"))   {      /* Patch out protection check */      UINT16 *rom = (UINT16 *)load_region[REGION_ROM1];      WriteWord68k(&rom[0xe5464/2], 0x6012);   }   if (is_current_game("sf2accp2"))   {      /* Patch out a odd branch which would be incorrectly interpreted         by the cpu core as a 32-bit branch. This branch would make the         game crash (address error, since it would branch to an odd address)         if location 180ca6 (outside ROM space) isn't 0. Protection check? */      UINT16 *rom = (UINT16 *)load_region[REGION_ROM1];      WriteWord68k(&rom[0x11756/2],0x4e71);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -