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

📄 silkworm.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************//*                                                                         *//*                          SILKWORM (C) 1988 TECMO                        *//*                                                                         *//*                    Z80 + Z80 + YM3812 + MSM5205(not yet emulated)       *//*                                                                         *//***************************************************************************//*	Converted to Raine from Mame sourcecode.	Original Mame driver written by: Nicola Salmoria	* The MSM5205 chip is not yet emulated, so no ADPCM samples are heard.	  (ADPCM samples are used for the drums in background music).*/#include "gameinc.h"#include "silkworm.h"#include "taitosnd.h"#include "msm5205.h"#include "sasound.h"		// sample support routinesstatic int sound_command;static int bank_offs;static int nmi_trigger;/******************   SILKWORM SET 1 ******************/static struct DIR_INFO silkworm_dirs[] ={   { "silkworm", },   { "silkworm", },   { NULL, },};static struct ROM_INFO silkworm_roms[] ={   {   "silkworm.4", 0x10000, 0xa5277cce, 0, 0, 0, },	// cpu1   {   "silkworm.5", 0x10000, 0xa6c7bb51, 0, 0, 0, }, // cpu1   {   "silkworm.3", 0x08000, 0xb589f587, 0, 0, 0, }, // cpu2   {   "silkworm.2", 0x08000, 0xe80a1cd9, 0, 0, 0, }, // char   {   "silkworm.6", 0x10000, 0x1138d159, 0, 0, 0, }, // spr   {   "silkworm.7", 0x10000, 0xd96214f7, 0, 0, 0, }, // spr   {   "silkworm.8", 0x10000, 0x0494b38e, 0, 0, 0, }, // spr   {   "silkworm.9", 0x10000, 0x8ce3cdf5, 0, 0, 0, }, // spr   {   "silkworm.10",0x10000, 0x8c7138bb, 0, 0, 0, }, // tile1   {   "silkworm.11",0x10000, 0x6c03c476, 0, 0, 0, }, // tile1   {   "silkworm.12",0x10000, 0xbb0f568f, 0, 0, 0, }, // tile1   {   "silkworm.13",0x10000, 0x773ad0a4, 0, 0, 0, }, // tile1   {   "silkworm.14",0x10000, 0x409df64b, 0, 0, 0, }, // tile2   {   "silkworm.15",0x10000, 0x6e4052c9, 0, 0, 0, }, // tile2   {   "silkworm.16",0x10000, 0x9292ed63, 0, 0, 0, }, // tile2   {   "silkworm.17",0x10000, 0x3fa4563d, 0, 0, 0, }, // tile2   {   "silkworm.1", 0x08000, 0x5b553644, 0, 0, 0, }, // adpcm   {           NULL,          0,          0, 0, 0, 0, },};static struct INPUT_INFO silkworm_inputs[] ={   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x030000, 0x01, BIT_ACTIVE_1 },   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x030000, 0x02, BIT_ACTIVE_1 },   { KB_DEF_P1_DOWN,      MSG_P1_DOWN,             0x030000, 0x04, BIT_ACTIVE_1 },   { KB_DEF_P1_UP,        MSG_P1_UP,               0x030000, 0x08, BIT_ACTIVE_1 },   { KB_DEF_P1_B1,        MSG_P1_B1,               0x030001, 0x01, BIT_ACTIVE_1 },   { KB_DEF_P1_B2,        MSG_P1_B2,               0x030001, 0x02, BIT_ACTIVE_1 },   { KB_DEF_P1_B3,        MSG_P1_B3,               0x030001, 0x04, BIT_ACTIVE_1 },   { KB_DEF_P2_LEFT,      MSG_P2_LEFT,             0x030002, 0x01, BIT_ACTIVE_1 },   { KB_DEF_P2_RIGHT,     MSG_P2_RIGHT,            0x030002, 0x02, BIT_ACTIVE_1 },   { KB_DEF_P2_DOWN,      MSG_P2_DOWN,             0x030002, 0x04, BIT_ACTIVE_1 },   { KB_DEF_P2_UP,        MSG_P2_UP,               0x030002, 0x08, BIT_ACTIVE_1 },   { KB_DEF_P2_B1,        MSG_P2_B1,               0x030003, 0x01, BIT_ACTIVE_1 },   { KB_DEF_P2_B2,        MSG_P2_B2,               0x030003, 0x02, BIT_ACTIVE_1 },   { KB_DEF_P2_B3,        MSG_P2_B3,               0x030003, 0x04, BIT_ACTIVE_1 },   { KB_DEF_P1_START,     MSG_P1_START,            0x03000F, 0x01, BIT_ACTIVE_1 },   { KB_DEF_P2_START,     MSG_P2_START,            0x03000F, 0x02, BIT_ACTIVE_1 },   { KB_DEF_COIN1,        MSG_COIN1,               0x03000F, 0x04, BIT_ACTIVE_1 },   { KB_DEF_COIN2,        MSG_COIN2,               0x03000F, 0x08, BIT_ACTIVE_1 },   { 0,                   NULL,                    0,        0,    0            },};/* Dipswitch B */static struct DSW_DATA dsw_data_silkworm_B[] ={   { MSG_EXTRA_LIFE,          0x07, 0x07 },   { "50k, 200k and 500k",    0x00, 0x00 },   { "100k, 300k and 800k",   0x01, 0x00 },   { "50k and 200k",          0x02, 0x00 },   { "100k and 300k",         0x03, 0x00 },   { "50k only",              0x04, 0x00 },   { "100k only",             0x05, 0x00 },   { "200k only",             0x06, 0x00 },   { "None",                  0x07, 0x00 },   { MSG_DSWB_BIT3,           0x08, 0x02 },   { MSG_OFF,                 0x08, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DIFFICULTY,          0x70, 0x06 },   { "0",                     0x00, 0x00 },   { "1",                     0x10, 0x00 },   { "2",                     0x20, 0x00 },   { "3",                     0x30, 0x00 },   { "4",                     0x40, 0x00 },   { "5",                     0x50, 0x00 },   /* 0x06 and 0x07 are the same as 0x00 */   { MSG_CONTINUE_PLAY,       0x80, 0x02 },   { MSG_OFF,                 0x80, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { NULL,                    0,    0,   },};/* Dipswitch A */static struct DSW_DATA dsw_data_silkworm_A[] ={   { MSG_COIN1,               0x03, 0x04 },    { MSG_2COIN_1PLAY,         0x01, 0x00 },   { MSG_1COIN_1PLAY,         0x00, 0x00 },   { MSG_1COIN_2PLAY,         0x02, 0x00 },   { MSG_1COIN_3PLAY,         0x03, 0x00 },   { MSG_COIN2,               0x0C, 0x04 },    { MSG_2COIN_1PLAY,         0x04, 0x00 },   { MSG_1COIN_1PLAY,         0x00, 0x00 },   { MSG_1COIN_2PLAY,         0x08, 0x00 },   { MSG_1COIN_3PLAY,         0x0C, 0x00 },   { MSG_LIVES,               0x30, 0x04 },   { "2",                     0x30, 0x00 },   { "3",                     0x00, 0x00 },   { "4",                     0x10, 0x00 },   { "5",                     0x20, 0x00 },   { MSG_DSWA_BIT6,           0x40, 0x02 },   { MSG_OFF,                 0x40, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DEMO_SOUND,          0x80, 0x02 },   { MSG_OFF,                 0x00, 0x00 },   { MSG_ON,                  0x80, 0x00 },   { NULL,                    0,    0,   },};static struct DSW_INFO silkworm_dsw[] ={   { 0x030006, 0x80, dsw_data_silkworm_A },   { 0x030008, 0x00, dsw_data_silkworm_B },   { 0,        0,    NULL,      },};static struct VIDEO_INFO silkworm_video ={   DrawSilkworm,   256,   256,   32,   VIDEO_ROTATE_NORMAL,};static struct YM3812interface ym3812_interface ={   1,              // 1 chip   4000000,        // 4.0 MHz   { 255 },        // Volume (emu only)   { NULL }};static struct SOUND_INFO silkworm_sound[] ={   { SOUND_YM3812,  &ym3812_interface,    },   { 0,             NULL,                 },};struct GAME_MAIN game_silkworm ={   silkworm_dirs,   silkworm_roms,   silkworm_inputs,   silkworm_dsw,   NULL,   LoadSilkworm,   ClearSilkworm,   &silkworm_video,   ExecuteSilkwormFrame,   "silkworm",   "Silkworm (Set 1)",   NULL,   COMPANY_ID_TECMO,   "6217",   1988,   silkworm_sound,   GAME_SHOOT,};/******************   SILKWORM SET 2 ******************/static struct DIR_INFO silkworm_set2_dirs[] ={   { "silkworm_set2", },   { "silkwrm2", },   { ROMOF("silkworm"), },   { CLONEOF("silkworm"), },   { NULL, },};static struct ROM_INFO silkworm_set2_roms[] ={   {           "r4", 0x10000, 0x6df3df22, 0, 0, 0, },   // cpu1   {   "silkworm.5", 0x10000, 0xa6c7bb51, 0, 0, 0, }, // cpu1   {           "r3", 0x08000, 0xb79848d0, 0, 0, 0, }, // cpu2   {   "silkworm.2", 0x08000, 0xe80a1cd9, 0, 0, 0, }, // char   {   "silkworm.6", 0x10000, 0x1138d159, 0, 0, 0, }, // spr   {   "silkworm.7", 0x10000, 0xd96214f7, 0, 0, 0, }, // spr   {   "silkworm.8", 0x10000, 0x0494b38e, 0, 0, 0, }, // spr   {   "silkworm.9", 0x10000, 0x8ce3cdf5, 0, 0, 0, }, // spr   {   "silkworm.10",0x10000, 0x8c7138bb, 0, 0, 0, }, // tile1   {   "silkworm.11",0x10000, 0x6c03c476, 0, 0, 0, }, // tile1   {   "silkworm.12",0x10000, 0xbb0f568f, 0, 0, 0, }, // tile1   {   "silkworm.13",0x10000, 0x773ad0a4, 0, 0, 0, }, // tile1   {   "silkworm.14",0x10000, 0x409df64b, 0, 0, 0, }, // tile2   {   "silkworm.15",0x10000, 0x6e4052c9, 0, 0, 0, }, // tile2   {   "silkworm.16",0x10000, 0x9292ed63, 0, 0, 0, }, // tile2   {   "silkworm.17",0x10000, 0x3fa4563d, 0, 0, 0, }, // tile2   {   "silkworm.1", 0x08000, 0x5b553644, 0, 0, 0, }, // adpcm   {           NULL,          0,          0, 0, 0, 0, },};struct GAME_MAIN game_silkworm_set2 ={   silkworm_set2_dirs,   silkworm_set2_roms,   silkworm_inputs,   silkworm_dsw,   NULL,   LoadSilkworm,   ClearSilkworm,   &silkworm_video,   ExecuteSilkwormFrame,   "silkwrm2",   "Silkworm (Set 2)",   NULL,   COMPANY_ID_TECMO,   "6217",   1988,   silkworm_sound,   GAME_SHOOT,};/**********************************************************************//**********************************************************************/static UINT8 *TMP;static UINT8 *RAM1;static UINT8 *RAM2;static UINT8 *ROM1;static UINT8 *ROM2;static UINT8 *RAM_INPUT;static UINT8 *RAM_VIDEO_BG;static UINT8 *RAM_COLOR_BG;static UINT8 *RAM_VIDEO_FG;static UINT8 *RAM_COLOR_FG;static UINT8 *RAM_VIDEO_TX;static UINT8 *RAM_COLOR_TX;static UINT8 *RAM_VIDEO_SPR;static UINT8 *RAM_PALETTE;static UINT8 *GFX_CHAR;static UINT8 *GFX_CHAR_SOLID;static UINT8 *GFX_TILE;static UINT8 *GFX_TILE_SOLID;static UINT8 *GFX_SPR;static UINT8 *GFX_SPR_SOLID;static int   flip_screen;static int	 rom_bank;/************************************************************************//*	CPU1 write ports									*//************************************************************************/void sw_sound_command(UINT32 address, UINT8 data){	(void)(data);	sound_command = data;	if(RaineSoundCard){		nmi_trigger = 1;//		cpu_int_nmi(CPU_Z80_1);//		print_ingame(120, "CPU1 Writes: %i", sound_command);	}}void sw_flip_screen(UINT32 address, UINT8 data){//	print_ingame(120, "Flip screen: %i", data);	flip_screen = data;}void sw_bankswitch(UINT32 address, UINT8 data){	bank_offs = 0x1000 + ( (data&0xF8) << 8);}UINT8 sw_read_bank(UINT32 address){	return ROM1[bank_offs + address];}void sw_palette_write(UINT32 address, UINT8 data){	// write to real palette (not used)	RAM1[address] = data;	// write to fake palette	if( (address&0x01)==0)		RAM1[address+0x30000] = ((data & 0x0F) << 4);	else		RAM1[address+0x30000] = data;}/************************************************************************//*	CPU1 read ports									*//************************************************************************/UINT8 sw_dsw_a_lo(UINT32 address){	return ((RAM_INPUT[0x06] & 0x0F) + 0xF0);}UINT8 sw_dsw_a_hi(UINT32 address){	return (((RAM_INPUT[0x06]& 0xF0)>>4) + 0xF0);}UINT8 sw_dsw_b_lo(UINT32 address){	return ((RAM_INPUT[0x08] & 0x0F) + 0xF0);}UINT8 sw_dsw_b_hi(UINT32 address){	return (((RAM_INPUT[0x08] & 0xF0)>>4) + 0xF0);}/************************************************************************//*	CPU2 write ports									*//************************************************************************/void sw_ym3812_control_port(UINT32 address, UINT8 data){	if(RaineSoundCard){		YM3812_control_port_0_w(address, data);//		print_ingame(120, "YM3812 control: %i", data);	}}void sw_ym3812_write_port(UINT32 address, UINT8 data){	if(RaineSoundCard){		YM3812_write_port_0_w(address, data);//		print_ingame(120, "YM3812 write: %i", data);	}}void sw_adpcm_start(UINT32 address, UINT8 data){	if(RaineSoundCard){//		print_ingame(120, "ADPCM Start: %i", data);	}}void sw_adpcm_end(UINT32 address, UINT8 data){	if(RaineSoundCard){//		print_ingame(120, "ADPCM End: %i", data);	}}void sw_adpcm_volume(UINT32 address, UINT8 data){	if(RaineSoundCard){//		print_ingame(120, "ADPCM Volume: %i", data);	}}/************************************************************************//*	CPU2 read ports									*//************************************************************************/UINT8 sw_soundlatch(UINT32 address){	int ta = 0x00;	if(RaineSoundCard)		ta = sound_command;	nmi_trigger = 0;	sound_command = 0;//	print_ingame(120, "CPU2 Reads: %i", sound_command);	return ta;}/************************************************************************//*	GFX LOADING										*//************************************************************************/void DecodeSilkwormGfx_8x8(char *file, int gfx_offs, int gfx_size){	int ta,tb;	if(!(load_rom(file, TMP, gfx_size))){		print_ingame(120, "ERROR: Unable to load gfx rom: %s", file);	}else{		tb = gfx_offs * 0x20000;		for(ta=0; ta<gfx_size; ta++){			GFX[tb+1] = TMP[ta] & 0x0F;			GFX[tb+0] = TMP[ta] >> 4;			tb += 2;		}	}}void DecodeSilkwormGfx_16x16(char *file, UINT8 gfx_offs, UINT32 gfx_size){	int ta,tb;	int i,j;	if(!(load_rom(file, TMP, gfx_size))){		print_ingame(120, "ERROR: Unable to load gfx rom: %s", file);	}else{		tb = gfx_offs * 0x20000;		ta = 0;		for(i=0; i<(gfx_size/128); i++){			for(j=0; j<8; j++){				GFX[tb+0]  = (TMP[ta+0] >> 4) & 0x0F;				GFX[tb+1]  = (TMP[ta+0] >> 0) & 0x0F;				GFX[tb+2]  = (TMP[ta+1] >> 4) & 0x0F;				GFX[tb+3]  = (TMP[ta+1] >> 0) & 0x0F;				GFX[tb+4]  = (TMP[ta+2] >> 4) & 0x0F;				GFX[tb+5]  = (TMP[ta+2] >> 0) & 0x0F;				GFX[tb+6]  = (TMP[ta+3] >> 4) & 0x0F;				GFX[tb+7]  = (TMP[ta+3] >> 0) & 0x0F;				GFX[tb+8]  = (TMP[ta+0+32] >> 4) & 0x0F;

⌨️ 快捷键说明

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