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

📄 gcpball.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************//*                                                                            *//*               GRAND CROSS PINBALL (C) 1994 EXCELLENT SYSTEM                *//*                                                                            *//******************************************************************************/#include "gameinc.h"#include "gcpball.h"#include "taitosnd.h"#include "sasound.h"		// sample support routines#include "m6585.h"#include "savegame.h"#include "debug.h"/*Todo:- M6295 should have a bankswitch- Some gfx I wonder about (the shadow thing when launching a ball)*/static struct DIR_INFO grand_cross_pinball_dirs[] ={   { "grand_cross_pinball", },   { "gcpball", },   { NULL, },};static struct ROM_INFO grand_cross_pinball_roms[] ={   {           "u1", 0x00100000, 0xafa459bb, 0, 0, 0, },   {        "u10.1", 0x00020000, 0x79321550, 0, 0, 0, },   {          "u13", 0x00200000, 0x62f3952f, 0, 0, 0, },   {        "u43.2", 0x00080000, 0xd174bd7f, 0, 0, 0, },   {        "u45.3", 0x00080000, 0x0511ad56, 0, 0, 0, },   {        "u46.4", 0x00080000, 0xe0f3a1b4, 0, 0, 0, },   {          "u55", 0x00080000, 0xb3063351, 0, 0, 0, },   {          "u56", 0x00200000, 0x092b2c0f, 0, 0, 0, },   {           "u6", 0x00100000, 0xc3f024e5, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};static struct INPUT_INFO grand_cross_pinball_inputs[] ={   { KB_DEF_COIN1,        MSG_COIN1,               0x016087, 0x01, BIT_ACTIVE_0 },   { KB_DEF_COIN2,        MSG_COIN2,               0x016087, 0x02, BIT_ACTIVE_0 },   { KB_DEF_SERVICE,      MSG_SERVICE,             0x016087, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_START,     MSG_P1_START,            0x016085, 0x80, BIT_ACTIVE_0 },   { KB_DEF_P2_START,     MSG_P2_START,            0x016084, 0x80, BIT_ACTIVE_0 },   { KB_DEF_FLIPPER_1_L,  MSG_FLIPPER_1_L,         0x016085, 0x10, BIT_ACTIVE_0 },   { KB_DEF_FLIPPER_1_R,  MSG_FLIPPER_1_R,         0x016084, 0x10, BIT_ACTIVE_0 },   { KB_DEF_FLIPPER_2_L,  MSG_FLIPPER_2_L,         0x016085, 0x20, BIT_ACTIVE_0 },   { KB_DEF_FLIPPER_2_R,  MSG_FLIPPER_2_R,         0x016084, 0x20, BIT_ACTIVE_0 },   { KB_DEF_TILT_L,       MSG_TILT_L,              0x016085, 0x40, BIT_ACTIVE_0 },   { KB_DEF_TILT_R,       MSG_TILT_R,              0x016084, 0x40, BIT_ACTIVE_0 },   { KB_DEF_B1_L,         MSG_B1_L,                0x016085, 0x08, BIT_ACTIVE_0 },   { KB_DEF_B1_R,         MSG_B1_R,                0x016084, 0x08, BIT_ACTIVE_0 },   { 0,                   NULL,                    0,        0,    0            },};static struct DSW_DATA dsw_data_grand_cross_pinball_1[] ={   { MSG_DSWB_BIT1,           0x01, 0x02 },   { MSG_OFF,                 0x01, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DSWB_BIT2,           0x02, 0x02 },   { MSG_OFF,                 0x02, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DSWB_BIT3,           0x04, 0x02 },   { MSG_OFF,                 0x04, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DSWB_BIT4,           0x08, 0x02 },   { MSG_OFF,                 0x08, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DSWB_BIT5,           0x10, 0x02 },   { MSG_OFF,                 0x10, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DSWB_BIT6,           0x20, 0x02 },   { MSG_OFF,                 0x20, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DSWB_BIT7,           0x40, 0x02 },   { MSG_OFF,                 0x40, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { MSG_DSWB_BIT8,           0x80, 0x02 },   { MSG_OFF,                 0x80, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { NULL,                    0,    0,   },};static struct DSW_INFO grand_cross_pinball_dsw[] ={   { 0x016080, 0xFF, dsw_data_default_0 },   { 0x016081, 0xFF, dsw_data_grand_cross_pinball_1 },   { 0,        0,    NULL,      },};static struct VIDEO_INFO grand_cross_pinball_video ={   draw_grand_cross_pinball,   320,   224,   32,   VIDEO_ROTATE_270 |   VIDEO_ROTATABLE,};static struct OKIM6295interface m6295_interface ={	1,                  /* 1 chip */	{ 8000 },			/* 8000 KHz? */	{ 0 },  /* memory region (not yet !) */	{ 250 }				/* volume */};static struct M6585_ROM m6585_romlist_chip_a[] ={   { NULL, 0x100000, },		// Bank 0   { NULL, 0x100000, },		// Bank 1   { NULL,        0, },		// Terminator};static struct M6585_interface m6585_interface ={   1,					// 1 chip   { 8000 },				// rate   { m6585_romlist_chip_a },		// rom list};static struct SOUND_INFO grand_cross_pinball_sound[] ={   { SOUND_M6295,   &m6295_interface,     },   { SOUND_M6585,   &m6585_interface,     },   { 0,             NULL,                 },};struct GAME_MAIN game_grand_cross_pinball ={   grand_cross_pinball_dirs,   grand_cross_pinball_roms,   grand_cross_pinball_inputs,   grand_cross_pinball_dsw,   NULL,   load_grand_cross_pinball,   clear_grand_cross_pinball,   &grand_cross_pinball_video,   execute_grand_cross_pinball_frame,   "gcpball",   "Grand Cross Pinball",   "僌儔儞僪僋儘僗僺儞儃乕儖",   COMPANY_ID_EX_SYSTEM,   NULL,   1994,   grand_cross_pinball_sound,   GAME_MISC,};static UINT8 *GFX_BG0;static UINT8 *GFX_BG0_SOLID;static UINT8 *GFX_FG0;static UINT8 *GFX_FG0_SOLID;static UINT8 *GFX_SPR;static UINT8 *GFX_SPR_SOLID;/******************************************************************************//*  I/O CONTROLLER                                                            *//******************************************************************************/static void grand_cross_pinball_ioc_wb(UINT32 offset, UINT8 data){   offset &= 0x00FF;   switch(offset){      case 0x10:      case 0x11:      case 0x12:      case 0x13:      case 0x14:      case 0x15:      case 0x16:      case 0x17:      case 0x18:      case 0x19:      case 0x1A:      case 0x1B:      case 0x1C:      case 0x1D:      case 0x1E:      case 0x1F:      case 0x20:      case 0x21:         RAM[0x16000+(offset^1)] = data;	// Scroll      break;      case 0x60:      case 0x61:      case 0x62:      case 0x63:      case 0x64:      case 0x65:      case 0x66:      case 0x67:      case 0x68:      case 0x69:      case 0x76:      case 0x77:         RAM[0x16000+(offset^1)] = data;	// ?      break;      case 0x88:         RAM[0x16000+(offset^1)] = data;         switch_led(2, (data>>0)&1 );		// Coin A [Ready for coins]         //switch_led(3, (data>>1)&1 );		// Coin B [Ready for coins]         M6585buffer_bank_write(0, (data>>4)&1 );      break;      case 0xA0:      case 0xA1:      case 0xA2:      case 0xA3:	OKIM6295_data_0_w(0,data&0xFF); // M6295buffer_request      break;      case 0xC0:      case 0xC1:      case 0xC2:      case 0xC3:      case 0xC4:      case 0xC5:      case 0xC6:      case 0xC7:      case 0xC8:      case 0xC9:      case 0xCA:      case 0xCB:      case 0xCC:      case 0xCD:         M6585buffer_request(0, (offset>>1)&7, data&0xFF);      break;      default:#ifdef RAINE_DEBUG         print_debug("IOC: %02x %02x\n",offset,data);#endif      break;   }}static void grand_cross_pinball_ioc_ww(UINT32 offset, UINT16 data){   grand_cross_pinball_ioc_wb(offset+0, (UINT8) ((data>>8)&0xFF) );   grand_cross_pinball_ioc_wb(offset+1, (UINT8) ((data>>0)&0xFF) );}static UINT8 grand_cross_pinball_ioc_rb(UINT32 offset){   offset &= 0x00FF;   switch(offset){      case 0xA0:      case 0xA1:      case 0xA2:      case 0xA3:         return OKIM6295_status_0_r(0);                  ;         //return 0;      break;      default:         return RAM[0x16000+(offset^1)];      break;   }}static UINT16 grand_cross_pinball_ioc_rw(UINT32 offset){   UINT16 ret;   ret  = grand_cross_pinball_ioc_rb(offset+0)<<8;   ret |= grand_cross_pinball_ioc_rb(offset+1)<<0;   return ret;}#define RAMSize 0x16200void load_grand_cross_pinball(void){   int ta,tb,tc;   if(!(ROM=AllocateMem(0x200000))) return;   if(!(RAM=AllocateMem(RAMSize))) return;   if(!(GFX=AllocateMem(0x840000))) return;   GFX_BG0 = GFX+0x000000;   if(!load_rom("u1", ROM+0x000000, 0x100000)) return;		// GFX BG0   if(!load_rom("u6", ROM+0x100000, 0x100000)) return;		// GFX BG0   for(ta=0;ta<0x200000;ta+=2){      GFX_BG0[ta+ta+0]=ROM[ta+1]>>4;      GFX_BG0[ta+ta+1]=ROM[ta+1]&15;      GFX_BG0[ta+ta+2]=ROM[ta+0]>>4;      GFX_BG0[ta+ta+3]=ROM[ta+0]&15;   }   GFX_BG0_SOLID = make_solid_mask_16x16(GFX_BG0, 0x4000);   GFX_FG0 = GFX+0x800000;   if(!load_rom("u10.1", ROM+0x00000, 0x20000)) return;		// GFX FG0   for(ta=0;ta<0x20000;ta+=2){      GFX_FG0[ta+ta+0]=ROM[ta+1]>>4;      GFX_FG0[ta+ta+1]=ROM[ta+1]&15;      GFX_FG0[ta+ta+2]=ROM[ta+0]>>4;      GFX_FG0[ta+ta+3]=ROM[ta+0]&15;   }   GFX_FG0_SOLID = make_solid_mask_8x8(GFX_FG0, 0x1000);   GFX_SPR = GFX+0x400000;   if(!load_rom("u13", ROM+0x000000, 0x200000)) return;		// GFX SPR   tb=0;   for(ta=0;ta<0x200000;ta+=8){      tc=ReadWord(&ROM[ta+0]);      GFX_SPR[tb+0] =((tc&0x8000)>>15)<<0;      GFX_SPR[tb+1] =((tc&0x4000)>>14)<<0;      GFX_SPR[tb+2] =((tc&0x2000)>>13)<<0;      GFX_SPR[tb+3] =((tc&0x1000)>>12)<<0;      GFX_SPR[tb+4] =((tc&0x0800)>>11)<<0;      GFX_SPR[tb+5] =((tc&0x0400)>>10)<<0;      GFX_SPR[tb+6] =((tc&0x0200)>> 9)<<0;      GFX_SPR[tb+7] =((tc&0x0100)>> 8)<<0;      GFX_SPR[tb+8] =((tc&0x0080)>> 7)<<0;      GFX_SPR[tb+9] =((tc&0x0040)>> 6)<<0;      GFX_SPR[tb+10]=((tc&0x0020)>> 5)<<0;      GFX_SPR[tb+11]=((tc&0x0010)>> 4)<<0;      GFX_SPR[tb+12]=((tc&0x0008)>> 3)<<0;      GFX_SPR[tb+13]=((tc&0x0004)>> 2)<<0;      GFX_SPR[tb+14]=((tc&0x0002)>> 1)<<0;      GFX_SPR[tb+15]=((tc&0x0001)>> 0)<<0;      tc=ReadWord(&ROM[ta+4]);      GFX_SPR[tb+0] |=((tc&0x8000)>>15)<<1;      GFX_SPR[tb+1] |=((tc&0x4000)>>14)<<1;      GFX_SPR[tb+2] |=((tc&0x2000)>>13)<<1;      GFX_SPR[tb+3] |=((tc&0x1000)>>12)<<1;      GFX_SPR[tb+4] |=((tc&0x0800)>>11)<<1;      GFX_SPR[tb+5] |=((tc&0x0400)>>10)<<1;      GFX_SPR[tb+6] |=((tc&0x0200)>> 9)<<1;      GFX_SPR[tb+7] |=((tc&0x0100)>> 8)<<1;      GFX_SPR[tb+8] |=((tc&0x0080)>> 7)<<1;      GFX_SPR[tb+9] |=((tc&0x0040)>> 6)<<1;      GFX_SPR[tb+10]|=((tc&0x0020)>> 5)<<1;      GFX_SPR[tb+11]|=((tc&0x0010)>> 4)<<1;      GFX_SPR[tb+12]|=((tc&0x0008)>> 3)<<1;      GFX_SPR[tb+13]|=((tc&0x0004)>> 2)<<1;      GFX_SPR[tb+14]|=((tc&0x0002)>> 1)<<1;      GFX_SPR[tb+15]|=((tc&0x0001)>> 0)<<1;      tc=ReadWord(&ROM[ta+2]);      GFX_SPR[tb+0] |=((tc&0x8000)>>15)<<2;      GFX_SPR[tb+1] |=((tc&0x4000)>>14)<<2;      GFX_SPR[tb+2] |=((tc&0x2000)>>13)<<2;      GFX_SPR[tb+3] |=((tc&0x1000)>>12)<<2;      GFX_SPR[tb+4] |=((tc&0x0800)>>11)<<2;      GFX_SPR[tb+5] |=((tc&0x0400)>>10)<<2;      GFX_SPR[tb+6] |=((tc&0x0200)>> 9)<<2;      GFX_SPR[tb+7] |=((tc&0x0100)>> 8)<<2;      GFX_SPR[tb+8] |=((tc&0x0080)>> 7)<<2;      GFX_SPR[tb+9] |=((tc&0x0040)>> 6)<<2;      GFX_SPR[tb+10]|=((tc&0x0020)>> 5)<<2;      GFX_SPR[tb+11]|=((tc&0x0010)>> 4)<<2;      GFX_SPR[tb+12]|=((tc&0x0008)>> 3)<<2;      GFX_SPR[tb+13]|=((tc&0x0004)>> 2)<<2;      GFX_SPR[tb+14]|=((tc&0x0002)>> 1)<<2;      GFX_SPR[tb+15]|=((tc&0x0001)>> 0)<<2;      tc=ReadWord(&ROM[ta+6]);      GFX_SPR[tb+0] |=((tc&0x8000)>>15)<<3;      GFX_SPR[tb+1] |=((tc&0x4000)>>14)<<3;      GFX_SPR[tb+2] |=((tc&0x2000)>>13)<<3;      GFX_SPR[tb+3] |=((tc&0x1000)>>12)<<3;      GFX_SPR[tb+4] |=((tc&0x0800)>>11)<<3;      GFX_SPR[tb+5] |=((tc&0x0400)>>10)<<3;      GFX_SPR[tb+6] |=((tc&0x0200)>> 9)<<3;      GFX_SPR[tb+7] |=((tc&0x0100)>> 8)<<3;      GFX_SPR[tb+8] |=((tc&0x0080)>> 7)<<3;      GFX_SPR[tb+9] |=((tc&0x0040)>> 6)<<3;      GFX_SPR[tb+10]|=((tc&0x0020)>> 5)<<3;      GFX_SPR[tb+11]|=((tc&0x0010)>> 4)<<3;      GFX_SPR[tb+12]|=((tc&0x0008)>> 3)<<3;      GFX_SPR[tb+13]|=((tc&0x0004)>> 2)<<3;      GFX_SPR[tb+14]|=((tc&0x0002)>> 1)<<3;      GFX_SPR[tb+15]|=((tc&0x0001)>> 0)<<3;      tb+=16;   }   GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0x4000);   if(!(PCMROM=AllocateMem(0x280000))) return;   if(!load_rom("u55", PCMROM+0x000000, 0x080000)) return;		// M6295

⌨️ 快捷键说明

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