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

📄 bloodbro.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************//*                                                                            *//*                    BLOOD BROS (C) 1990 TAD CORPORATION                     *//*                                                                            *//*                    WEST STORY (C) 1991 DATSU ALLIANCE                      *//*                                                                            *//******************************************************************************/#include "gameinc.h"#include "bloodbro.h"#include "sasound.h"		// sample support routines#include "3812intf.h"#include "savegame.h"		// save/load game routines#include "debug.h"static struct DIR_INFO blood_bros_dirs[] ={   { "blood_bros", },   { "bloodbro", },   { NULL, },};static struct ROM_INFO blood_bros_roms[] ={   {    "bb_03.bin", 0x00020000, 0x18d3c460, 0, 0, 0, },   {    "bb_01.bin", 0x00020000, 0x2d7e0fdf, 0, 0, 0, },   {    "bb_02.bin", 0x00020000, 0xc0fdc3e4, 0, 0, 0, },   {    "bb_04.bin", 0x00020000, 0xfd951c2c, 0, 0, 0, },   {    "bb_05.bin", 0x00010000, 0x04ba6d19, 0, 0, 0, },   {    "bb_06.bin", 0x00010000, 0x7092e35b, 0, 0, 0, },   {    "bb_07.bin", 0x00010000, 0x411b94e8, 0, 0, 0, },   {    "bb_08.bin", 0x00020000, 0xdeb1b975, 0, 0, 0, },   {    "bloodb.bk", 0x00100000, 0x1aa87ee6, 0, 0, 0, },   {   "bloodb.obj", 0x00100000, 0xd27c3952, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};static struct INPUT_INFO blood_bros_inputs[] ={   { KB_DEF_COIN1,        MSG_COIN1,               0x020005, 0x10, BIT_ACTIVE_0 },   { KB_DEF_TILT,         MSG_TILT,                0x020005, 0x01, BIT_ACTIVE_0 },   { KB_DEF_SERVICE,      MSG_SERVICE,             0x020005, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_START,     MSG_P1_START,            0x020004, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P1_UP,        MSG_P1_UP,               0x020002, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P1_DOWN,      MSG_P1_DOWN,             0x020002, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x020002, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x020002, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_B1,        MSG_P1_B1,               0x020002, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P1_B2,        MSG_P1_B2,               0x020002, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P1_B3,        MSG_P1_B3,               0x020002, 0x40, BIT_ACTIVE_0 },   { KB_DEF_P2_START,     MSG_P2_START,            0x020004, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P2_UP,        MSG_P2_UP,               0x020003, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P2_DOWN,      MSG_P2_DOWN,             0x020003, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P2_LEFT,      MSG_P2_LEFT,             0x020003, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P2_RIGHT,     MSG_P2_RIGHT,            0x020003, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P2_B1,        MSG_P2_B1,               0x020003, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P2_B2,        MSG_P2_B2,               0x020003, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P2_B3,        MSG_P2_B3,               0x020003, 0x40, BIT_ACTIVE_0 },   { 0,                   NULL,                    0,        0,    0            },};static struct DSW_DATA dsw_data_blood_bros_0[] ={   { "Coin Mode",             0x01, 0x02 },   { "1",                     0x01, 0x00 },   { "2",                     0x00, 0x00 },   { "Coinage Mode 1",        0x1E, 0x10 },   { MSG_1COIN_1PLAY,         0x1E, 0x00 },   { MSG_2COIN_1PLAY,         0x1C, 0x00 },   { MSG_3COIN_1PLAY,         0x1A, 0x00 },   { MSG_4COIN_1PLAY,         0x18, 0x00 },   { MSG_5COIN_1PLAY,         0x16, 0x00 },   { MSG_6COIN_1PLAY,         0x14, 0x00 },   { MSG_1COIN_2PLAY,         0x12, 0x00 },   { MSG_1COIN_3PLAY,         0x10, 0x00 },   { MSG_1COIN_4PLAY,         0x0E, 0x00 },   { MSG_1COIN_5PLAY,         0x0C, 0x00 },   { MSG_1COIN_6PLAY,         0x0A, 0x00 },   { MSG_2COIN_3PLAY,         0x08, 0x00 },   { MSG_3COIN_2PLAY,         0x06, 0x00 },   { MSG_5COIN_3PLAY,         0x04, 0x00 },   { MSG_8COIN_3PLAY,         0x02, 0x00 },   { MSG_FREE_PLAY,              0x00, 0x00 },   { "Coin Start",            0x20, 0x02 },   { MSG_NORMAL,              0x20, 0x00 },   { "Double",                0x00, 0x00 },   { "Rom Option",            0xC0, 0x04 },   { "A",                     0xC0, 0x00 },   { "B",                     0x80, 0x00 },   { "C",                     0x40, 0x00 },   { "D",                     0x00, 0x00 },   { NULL,                    0,    0,   },};static struct DSW_DATA dsw_data_blood_bros_1[] ={   { "Lives",                 0x03, 0x04 },   { "3",                     0x03, 0x00 },   { "2",                     0x02, 0x00 },   { "5",                     0x01, 0x00 },   { "1",                     0x00, 0x00 },   { "Bonus",                 0x0C, 0x04 },   { "100k, every 200k",      0x0C, 0x00 },   { "200k, every 300k",      0x08, 0x00 },   { "500k only",             0x04, 0x00 },   { "None",                  0x00, 0x00 },   { MSG_DIFFICULTY,          0x30, 0x04 },   { MSG_NORMAL,              0x30, 0x00 },   { MSG_EASY,                0x20, 0x00 },   { MSG_HARD,                0x10, 0x00 },   { MSG_HARDEST,             0x00, 0x00 },   { "Continue Play",         0x40, 0x02 },   { MSG_ON,                  0x40, 0x00 },   { MSG_OFF,                 0x00, 0x00 },   { MSG_DEMO_SOUND,          0x80, 0x02 },   { MSG_ON,                  0x80, 0x00 },   { MSG_OFF,                 0x00, 0x00 },   { NULL,                    0,    0,   },};static struct DSW_INFO blood_bros_dsw[] ={   { 0x020000, 0xFF, dsw_data_blood_bros_0 },   { 0x020001, 0xFF, dsw_data_blood_bros_1 },   { 0,        0,    NULL,      },};static struct VIDEO_INFO blood_bros_video ={   DrawBloodBros,   256,   224,   32,   VIDEO_ROTATE_NORMAL |   VIDEO_ROTATABLE,};struct GAME_MAIN game_blood_bros ={   blood_bros_dirs,   blood_bros_roms,   blood_bros_inputs,   blood_bros_dsw,   NULL,   LoadBloodBros,   ClearBloodBros,   &blood_bros_video,   ExecuteBloodBrosFrame,   "bloodbro",   "Blood Bros",   "僽儔僢僪僽儔僓乕僘 Bootleg",   COMPANY_ID_TAD,   NULL,   1990,   NULL,   GAME_SHOOT,};static struct DIR_INFO west_story_dirs[] ={   { "west_story", },   { "weststry", },   { ROMOF("bloodbro"), },   { CLONEOF("bloodbro"), },   { NULL, },};static struct ROM_INFO west_story_roms[] ={   {     "ws20.bin", 0x00020000, 0xf1245c16, 0, 0, 0, },   {     "ws21.bin", 0x00020000, 0xe23d7296, 0, 0, 0, },   {     "ws22.bin", 0x00020000, 0x7150a060, 0, 0, 0, },   {     "ws23.bin", 0x00020000, 0x43d58e24, 0, 0, 0, },   {     "ws24.bin", 0x00020000, 0x20a867ea, 0, 0, 0, },   {     "ws25.bin", 0x00020000, 0x8092e8e9, 0, 0, 0, },   {     "ws26.bin", 0x00020000, 0xf6a1f42c, 0, 0, 0, },   {     "ws01.bin", 0x00020000, 0x32bda4bc, 0, 0, 0, },   {     "ws02.bin", 0x00020000, 0xed9d682e, 0, 0, 0, },   {     "ws03.bin", 0x00020000, 0x046b51f8, 0, 0, 0, },   {     "ws04.bin", 0x00020000, 0x75f082e5, 0, 0, 0, },   {     "ws05.bin", 0x00020000, 0x007c8dc0, 0, 0, 0, },   {     "ws06.bin", 0x00020000, 0x459d075e, 0, 0, 0, },   {     "ws07.bin", 0x00020000, 0x0f0c8d9a, 0, 0, 0, },   {     "ws08.bin", 0x00020000, 0x4d6783b3, 0, 0, 0, },   {     "ws13.bin", 0x00020000, 0x158e302a, 0, 0, 0, },   {    "bb_04.bin", 0x00020000, 0xfd951c2c, 0, 0, 0, },   {     "ws15.bin", 0x00020000, 0x672e9027, 0, 0, 0, },   {    "bb_03.bin", 0x00020000, 0x18d3c460, 0, 0, 0, },   {    "bb_08.bin", 0x00020000, 0xdeb1b975, 0, 0, 0, },   {     "ws19.bin", 0x00020000, 0xc5dd0a96, 0, 0, 0, },   {     "ws09.bin", 0x00010000, 0xf05b2b3e, 0, 0, 0, },   {     "ws10.bin", 0x00010000, 0xefdf7c82, 0, 0, 0, },   {     "ws11.bin", 0x00010000, 0x2b10e3d2, 0, 0, 0, },   {     "ws12.bin", 0x00010000, 0xaf993578, 0, 0, 0, },   {     "ws17.bin", 0x00010000, 0xe00a8f09, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};static struct INPUT_INFO west_story_inputs[] ={   { KB_DEF_COIN1,        MSG_COIN1,               0x020004, 0x01, BIT_ACTIVE_0 },   { KB_DEF_COIN2,        MSG_COIN2,               0x020004, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_START,     MSG_P1_START,            0x020004, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_UP,        MSG_P1_UP,               0x020002, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P1_DOWN,      MSG_P1_DOWN,             0x020002, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x020002, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x020002, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_B1,        MSG_P1_B1,               0x020002, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P1_B2,        MSG_P1_B2,               0x020002, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P1_B3,        MSG_P1_B3,               0x020002, 0x40, BIT_ACTIVE_0 },   { KB_DEF_P2_START,     MSG_P2_START,            0x020004, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P2_UP,        MSG_P2_UP,               0x020003, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P2_DOWN,      MSG_P2_DOWN,             0x020003, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P2_LEFT,      MSG_P2_LEFT,             0x020003, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P2_RIGHT,     MSG_P2_RIGHT,            0x020003, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P2_B1,        MSG_P2_B1,               0x020003, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P2_B2,        MSG_P2_B2,               0x020003, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P2_B3,        MSG_P2_B3,               0x020003, 0x40, BIT_ACTIVE_0 },   { 0,                   NULL,                    0,        0,    0            },};static struct YM3812interface ym3812_interface ={   1,		// 1 chip   3000000,	// 3 MHz  (emu only)   { 255 },	// Volume (emu only)   { NULL }};static struct SOUND_INFO west_story_sound[] ={   { SOUND_YM3812,  &ym3812_interface,    },   { 0,             NULL,                 },};struct GAME_MAIN game_west_story ={   west_story_dirs,   west_story_roms,   west_story_inputs,   blood_bros_dsw,   NULL,   LoadWestStry,   ClearWestStry,   &blood_bros_video,   ExecuteWestStryFrame,   "weststry",   "West Story",   "僽儔僢僪僽儔僓乕僘",   COMPANY_ID_BOOTLEG,   NULL,   1991,   west_story_sound,   GAME_SHOOT,};static int sport;static void WriteSound68k(UINT32 address, UINT8 data){	(void)(address);	sport=data&0xFF;#ifdef RAINE_DEBUG      print_debug("68000 Sends:%02x\n",data);#endif   cpu_int_nmi(CPU_Z80_0);   if(sport!=0){   cpu_interrupt(CPU_Z80_0, 0x38);   }}UINT16 WestStorySoundReadZ80(UINT16 offset){   UINT8 ta;   switch(offset&0x1F){      case 0x08:		// YM3812 TimerA/B         return 0x60;      break;      case 0x10:      case 0x11:      case 0x12:      //   return 0xFE;      //break;      case 0x13:         #ifdef RAINE_DEBUG         print_debug("Z80 Receives:%02x\n",sport);         #endif         return sport;      break;      default:         ta = 0xFF;      break;   }   #ifdef RAINE_DEBUG   print_debug("Z80Read:%04x,%02x [%04x]\n",offset,ta,z80pc);   #endif   return ta;}void WestStorySoundWriteZ80(UINT16 offset, UINT8 data){   switch(offset&0x1F){      case 0x08:      case 0x09:         YM3812WriteZ80( (UINT16) (offset&1), data);      break;      default:         #ifdef RAINE_DEBUG         print_debug("Z80Write:%04x,%02x [%04x]\n",offset,data,z80pc);         #endif      break;   }}static UINT8 *GFX_BG0;static UINT8 *GFX_BG1;static UINT8 *GFX_SPR;static UINT8 *GFX_FG0;static UINT8 *GFX_BG0_SOLID;static UINT8 *GFX_BG1_SOLID;static UINT8 *GFX_SPR_SOLID;static UINT8 *GFX_FG0_SOLID;static UINT8 *RAM_BG0;static UINT8 *RAM_BG1;static UINT8 *RAM_SPR;static UINT8 *RAM_FG0;static UINT32 pal_bg0;static UINT32 pal_bg1;static UINT32 pal_spr;static UINT32 pal_fg0;static UINT8 *RAM_SCR;static int romset;void LoadWestStry(void){   int ta,tb,tc;   romset = 1;   if(!(ROM=AllocateMem(0x80000))) return;   if(!(RAM=AllocateMem(0x80000))) return;   if(!(GFX=AllocateMem(0x440000))) return;   GFX_BG0 = GFX + 0x100000;   GFX_BG1 = GFX + 0x000000;   GFX_SPR = GFX + 0x200000;   GFX_FG0 = GFX + 0x400000;   RAM_BG0 = RAM + 0x13000;   RAM_BG1 = RAM + 0x12C00;   RAM_SPR = RAM + 0x14000;   RAM_FG0 = RAM + 0x13800;   pal_bg0 = 0x30;   pal_bg1 = 0x20;   pal_spr = 0x00;   pal_fg0 = 0x10;   RAM_SCR = RAM + 0x05C34;   if(!load_rom("ws04.bin", RAM+0x00000, 0x20000)) return;		// GFX BG1   if(!load_rom("ws08.bin", RAM+0x20000, 0x20000)) return;		// GFX BG0   if(!load_rom("ws19.bin", RAM+0x40000, 0x20000)) return;		// GFX SPR   if(!load_rom("ws20.bin", RAM+0x60000, 0x20000)) return;		// GFX SPR   for(ta=0;ta<0x10000;ta++){      tb=RAM[ta+0x50000];      RAM[ta+0x50000]=RAM[ta+0x60000];      RAM[ta+0x60000]=tb;   }   tb=0;   for(ta=0;ta<0x80000;ta++){      tc=RAM[ta];      GFX[tb+0]=((tc&0x80)>>7)<<0;      GFX[tb+1]=((tc&0x40)>>6)<<0;      GFX[tb+2]=((tc&0x20)>>5)<<0;      GFX[tb+3]=((tc&0x10)>>4)<<0;      GFX[tb+4]=((tc&0x08)>>3)<<0;      GFX[tb+5]=((tc&0x04)>>2)<<0;      GFX[tb+6]=((tc&0x02)>>1)<<0;      GFX[tb+7]=((tc&0x01)>>0)<<0;      tb+=16;      if((tb&0xFF)==0){tb-=0xF8;}      else{if((tb&0xFF)==8){tb-=8;}}   }   if(!load_rom("ws02.bin", RAM+0x00000, 0x20000)) return;		// GFX BG1   if(!load_rom("ws06.bin", RAM+0x20000, 0x20000)) return;		// GFX BG0   if(!load_rom("ws21.bin", RAM+0x40000, 0x20000)) return;		// GFX SPR   if(!load_rom("ws22.bin", RAM+0x60000, 0x20000)) return;		// GFX SPR   for(ta=0;ta<0x10000;ta++){      tb=RAM[ta+0x50000];      RAM[ta+0x50000]=RAM[ta+0x60000];      RAM[ta+0x60000]=tb;   }   tb=0;   for(ta=0;ta<0x80000;ta++){      tc=RAM[ta];      GFX[tb+0]|=((tc&0x80)>>7)<<1;      GFX[tb+1]|=((tc&0x40)>>6)<<1;      GFX[tb+2]|=((tc&0x20)>>5)<<1;      GFX[tb+3]|=((tc&0x10)>>4)<<1;      GFX[tb+4]|=((tc&0x08)>>3)<<1;      GFX[tb+5]|=((tc&0x04)>>2)<<1;      GFX[tb+6]|=((tc&0x02)>>1)<<1;      GFX[tb+7]|=((tc&0x01)>>0)<<1;      tb+=16;      if((tb&0xFF)==0){tb-=0xF8;}      else{if((tb&0xFF)==8){tb-=8;}}   }   if(!load_rom("ws03.bin", RAM+0x00000, 0x20000)) return;		// GFX   if(!load_rom("ws07.bin", RAM+0x20000, 0x20000)) return;		// GFX   if(!load_rom("ws23.bin", RAM+0x40000, 0x20000)) return;		// GFX   if(!load_rom("ws24.bin", RAM+0x60000, 0x20000)) return;		// GFX   for(ta=0;ta<0x10000;ta++){      tb=RAM[ta+0x50000];      RAM[ta+0x50000]=RAM[ta+0x60000];      RAM[ta+0x60000]=tb;   }   tb=0;   for(ta=0;ta<0x80000;ta++){      tc=RAM[ta];      GFX[tb+0]|=((tc&0x80)>>7)<<2;      GFX[tb+1]|=((tc&0x40)>>6)<<2;      GFX[tb+2]|=((tc&0x20)>>5)<<2;      GFX[tb+3]|=((tc&0x10)>>4)<<2;      GFX[tb+4]|=((tc&0x08)>>3)<<2;      GFX[tb+5]|=((tc&0x04)>>2)<<2;      GFX[tb+6]|=((tc&0x02)>>1)<<2;      GFX[tb+7]|=((tc&0x01)>>0)<<2;      tb+=16;      if((tb&0xFF)==0){tb-=0xF8;}      else{if((tb&0xFF)==8){tb-=8;}}   }   if(!load_rom("ws01.bin", RAM+0x00000, 0x20000)) return;		// GFX   if(!load_rom("ws05.bin", RAM+0x20000, 0x20000)) return;		// GFX   if(!load_rom("ws25.bin", RAM+0x40000, 0x20000)) return;		// GFX   if(!load_rom("ws26.bin", RAM+0x60000, 0x20000)) return;		// GFX   for(ta=0;ta<0x10000;ta++){      tb=RAM[ta+0x50000];      RAM[ta+0x50000]=RAM[ta+0x60000];      RAM[ta+0x60000]=tb;   }   tb=0;   for(ta=0;ta<0x40000;ta++){

⌨️ 快捷键说明

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