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

📄 spacegun.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************/
/*                                                                            */
/*                     SPACE GUN (C) 1991 TAITO CORPORATION                   */
/*                                                                            */
/******************************************************************************/

#include "gameinc.h"
#include "spacegun.h"
#include "tc100scn.h"
#include "tc110pcr.h"
#include "tc220ioc.h"
#include "sasound.h"		// sample support routines
#include "taitosnd.h"

static struct DIR_INFO space_gun_dirs[] =
{
   { "space_gun", },
   { "spacegun", },
   { NULL, },
};

static struct ROM_INFO space_gun_roms[] =
{
   {       "c57-16", 0x00020000, 0xbfb5d1e7, 0, 0, 0, },
   {       "c57-07", 0x00080000, 0xad653dc1, 0, 0, 0, },
   {       "c57-06", 0x00080000, 0x4ebadd5b, 0, 0, 0, },
   {       "c57-05", 0x00080000, 0x6a70eb2e, 0, 0, 0, },
   {       "c57-03", 0x00100000, 0xfafca86f, 0, 0, 0, },
   {       "c57-02", 0x00100000, 0x21ee4633, 0, 0, 0, },
   {       "c57-01", 0x00100000, 0xf901b04e, 0, 0, 0, },
   {       "c57-15", 0x00020000, 0xb36eb8f1, 0, 0, 0, },
   {       "c57-08", 0x00080000, 0x22593550, 0, 0, 0, },
   {       "c57-17", 0x00020000, 0xe197edb8, 0, 0, 0, },
   {       "c57-18", 0x00020000, 0x19d7d52e, 0, 0, 0, },
   {       "c57-22", 0x00020000, 0x5855fde3, 0, 0, 0, },
   {       "c57-20", 0x00020000, 0x2e58253f, 0, 0, 0, },
   {       "c57-04", 0x00100000, 0xa9787090, 0, 0, 0, },
   {           NULL,          0,          0, 0, 0, 0, },
};

static struct INPUT_INFO space_gun_inputs[] =
{
   { KB_DEF_COIN1,        MSG_COIN1,               0x044004, 0x08, BIT_ACTIVE_0 },
   { KB_DEF_COIN2,        MSG_COIN2,               0x044004, 0x04, BIT_ACTIVE_0 },
   { KB_DEF_TILT,         MSG_TILT,                0x044004, 0x20, BIT_ACTIVE_0 },
   { KB_DEF_SERVICE,      MSG_SERVICE,             0x044004, 0x10, BIT_ACTIVE_0 },

   { KB_DEF_P1_START,     MSG_P1_START,            0x044004, 0x40, BIT_ACTIVE_0 },
   { KB_DEF_P1_UP,        MSG_P1_UP,               0x044010, 0x01, BIT_ACTIVE_1 },
   { KB_DEF_P1_DOWN,      MSG_P1_DOWN,             0x044010, 0x02, BIT_ACTIVE_1 },
   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x044010, 0x04, BIT_ACTIVE_1 },
   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x044010, 0x08, BIT_ACTIVE_1 },
   { KB_DEF_P1_B1,        "P1 Trigger",            0x04400E, 0x01, BIT_ACTIVE_0 },
   { KB_DEF_P1_B2,        "P1 Bomb",               0x04400E, 0x04, BIT_ACTIVE_0 },
   { KB_DEF_P1_B3,        "P1 Pedal",              0x044004, 0x01, BIT_ACTIVE_0 },

   { KB_DEF_P2_START,     MSG_P2_START,            0x044004, 0x80, BIT_ACTIVE_0 },
   { KB_DEF_P2_UP,        MSG_P2_UP,               0x044020, 0x01, BIT_ACTIVE_1 },
   { KB_DEF_P2_DOWN,      MSG_P2_DOWN,             0x044020, 0x02, BIT_ACTIVE_1 },
   { KB_DEF_P2_LEFT,      MSG_P2_LEFT,             0x044020, 0x04, BIT_ACTIVE_1 },
   { KB_DEF_P2_RIGHT,     MSG_P2_RIGHT,            0x044020, 0x08, BIT_ACTIVE_1 },
   { KB_DEF_P2_B1,        "P2 Trigger",            0x04400E, 0x02, BIT_ACTIVE_0 },
   { KB_DEF_P2_B2,        "P2 Bomb",               0x04400E, 0x08, BIT_ACTIVE_0 },
   { KB_DEF_P2_B3,        "P2 Pedal",              0x044004, 0x02, BIT_ACTIVE_0 },

   { 0,                   NULL,                    0,        0,    0            },
};

static struct DSW_DATA dsw_data_space_gun_0[] =
{
   { MSG_DSWA_BIT1,           0x01, 0x02 },
   { MSG_OFF,                 0x01, 0x00 },
   { MSG_ON,                  0x00, 0x00 },
   { MSG_SCREEN,              0x02, 0x02 },
   { MSG_NORMAL,              0x02, 0x00 },
   { MSG_INVERT,              0x00, 0x00 },
   { MSG_TEST_MODE,           0x04, 0x02 },
   { MSG_OFF,                 0x04, 0x00 },
   { MSG_ON,                  0x00, 0x00 },
   { MSG_DEMO_SOUND,          0x08, 0x02 },
   { MSG_ON,                  0x08, 0x00 },
   { MSG_OFF,                 0x00, 0x00 },
   { MSG_COIN1,               0x30, 0x04 },
   { MSG_1COIN_1PLAY,         0x30, 0x00 },
   { MSG_2COIN_1PLAY,         0x20, 0x00 },
   { MSG_3COIN_1PLAY,         0x10, 0x00 },
   { MSG_4COIN_1PLAY,         0x00, 0x00 },
   { MSG_COIN2,               0xC0, 0x04 },
   { MSG_1COIN_2PLAY,         0xC0, 0x00 },
   { MSG_1COIN_3PLAY,         0x80, 0x00 },
   { MSG_1COIN_4PLAY,         0x40, 0x00 },
   { MSG_1COIN_6PLAY,         0x00, 0x00 },
   { NULL,                    0,    0,   },
};


static struct DSW_DATA dsw_fake_input_behaviour[] =
{

   { "Mouse Speed",           0x04, 0x02 },
   { "Slow",                  0x04, 0x00 },
   { "Fast",                  0x00, 0x00 },
   { "Digital Input Speed",   0x08, 0x02 },
   { "Slow",                  0x08, 0x00 },
   { "Fast",                  0x00, 0x00 },
   { "P1 Input Control",      0x30, 0x04 },
   { "Mouse",                 0x30, 0x00 },
   { "Analog Joystick",       0x20, 0x00 },
   { "Digital",               0x10, 0x00 },
   { MSG_UNUSED,                0x00, 0x00 },
   { "Show Crosshair",        0xC0, 0x04 },
   { "All",                   0xC0, 0x00 },
   { "Player 1 Only",         0x80, 0x00 },
   { "Player 2 Only",         0x40, 0x00 },
   { "None",                  0x00, 0x00 },


   { NULL,                    0,    0,   },
};

static struct DSW_INFO space_gun_dsw[] =
{
   { 0x044000, 0xFF, dsw_data_space_gun_0 },
   { 0x044002, 0xFF, dsw_data_default_1 },
   { 0x044005, 0xF3, dsw_fake_input_behaviour },
   { 0,        0,    NULL,      },
};

static struct ROMSW_DATA romsw_data_space_gun_0[] =
{
   { "Taito America",            0x01 },
   { "Taito America (FBI logo)", 0x02 },
   { "Taito Japan",              0x03 },
   { "Taito Japan (Romstar)",    0x05 },
   { NULL,                       0    },
};

static struct ROMSW_INFO space_gun_romsw[] =
{
   { 0x07FFFF, 0x03, romsw_data_space_gun_0 },
   { 0,        0,    NULL },
};

static struct VIDEO_INFO space_gun_video =
{
   DrawSpaceGun,
   320,
   240,
   64,
   VIDEO_ROTATE_NORMAL| VIDEO_ROTATABLE,
};

struct GAME_MAIN game_space_gun =
{
   space_gun_dirs,
   space_gun_roms,
   space_gun_inputs,
   space_gun_dsw,
   space_gun_romsw,

   LoadSpaceGun,
   ClearSpaceGun,
   &space_gun_video,
   ExecuteSpaceGunFrame,
   "spacegun",
   "Space Gun",
   "僗儁乕僗僈儞",
   COMPANY_ID_TAITO,
   "C57",
   1990,
   taito_ym2610b_sound,
   GAME_SHOOT,
};

static UINT8 *RAM_VIDEO;
static UINT8 *RAM_SCROLL;
static UINT8 *RAM_INPUT;

static UINT8 *GFX_SPR;
static UINT8 *GFX_SPR_SOLID;

static UINT8 *GFX_BG0;
static UINT8 *GFX_BG0_SOLID;

static int BadReadByte(UINT32 address)
{
   #ifdef RAINE_DEBUG
      //print_debug("Rb%01d(%06x) [%06x]\n",tcpu,address,s68000context.pc);
   #endif
   return(0xFF);
}

static int BadReadWord(UINT32 address)
{
   #ifdef RAINE_DEBUG
       //print_debug("Rw%01d(%06x) [%06x]\n",tcpu,address,s68000context.pc);
   #endif
   return(0);
}

static void BadWriteByte(UINT32 address, UINT8 data)
{
   #ifdef RAINE_DEBUG
      //print_debug("Wb%01d(%06x,%02x) [%06x]\n",tcpu,address,data,s68000context.pc);
   #endif
}

static void BadWriteWord(UINT32 address, UINT16 data)
{
   #ifdef RAINE_DEBUG
      //print_debug("Ww%01d(%06x,%04x) [%06x]\n",tcpu,address,data,s68000context.pc);
   #endif
}

static int YM2610Read68k(UINT32 address)
{
   return YM2610ReadZ80( (UINT16) ((address&7)>>1) );
}

static void YM2610Write68k(UINT32 address, UINT16 data)
{
   YM2610WriteZ80( (UINT16) ((address&7)>>1) , (UINT8) data);
}

#if 0
static void BadWByte(UINT32 address, UINT8 data){
  print_ingame(120," Mem:%08x = %02x", address, data );
}
static void BadWWord(UINT32 address, UINT16 data){
  print_ingame(120," Mem:%08x=%04x", address, data );
}
#endif
static void PanWrite(UINT32 address, UINT8 data){
  Pan2610WriteZ80_OffsetVol( (UINT16) ((address&7)>>1) , data );
}

void LoadSpaceGun(void)
{
   int ta,tb,tc,td,te,tf;
   UINT8 *TMP;

   if(!(TMP=AllocateMem(0xF94B0+0x7CA580))) return;

   tb=0xF94B0;
   if(!load_rom("C57-04", TMP, 0xF94B0)) return;		// 16x8 SPRITES
   for(ta=0;ta<0xF94B0;ta+=2){
      tc=ReadWord(&TMP[ta]);
      TMP[tb+0]=((tc&0x8000)>>(15-0));
      TMP[tb+1]=((tc&0x4000)>>(14-0));
      TMP[tb+2]=((tc&0x2000)>>(13-0));
      TMP[tb+3]=((tc&0x1000)>>(12-0));
      TMP[tb+4]=((tc&0x0800)>>(11-0));
      TMP[tb+5]=((tc&0x0400)>>(10-0));
      TMP[tb+6]=((tc&0x0200)>>(9-0));
      TMP[tb+7]=((tc&0x0100)>>(8-0));
      TMP[tb+8]=((tc&0x0080)>>(7-0));
      TMP[tb+9]=((tc&0x0040)>>(6-0));
      TMP[tb+10]=((tc&0x0020)>>(5-0));
      TMP[tb+11]=((tc&0x0010)>>(4-0));
      TMP[tb+12]=((tc&0x0008)>>(3-0));
      TMP[tb+13]=((tc&0x0004)>>(2-0));
      TMP[tb+14]=((tc&0x0002)>>(1-0));
      TMP[tb+15]=((tc&0x0001)>>(0-0));
      tb+=16;
   }
   tb=0xF94B0;
   if(!load_rom("C57-03", TMP, 0xF94B0)) return;		// 16x8 SPRITES
   for(ta=0;ta<0xF94B0;ta+=2){
      tc=ReadWord(&TMP[ta]);
      TMP[tb+0]|=((tc&0x8000)>>(15-1));
      TMP[tb+1]|=((tc&0x4000)>>(14-1));
      TMP[tb+2]|=((tc&0x2000)>>(13-1));
      TMP[tb+3]|=((tc&0x1000)>>(12-1));
      TMP[tb+4]|=((tc&0x0800)>>(11-1));
      TMP[tb+5]|=((tc&0x0400)>>(10-1));
      TMP[tb+6]|=((tc&0x0200)>>(9-1));
      TMP[tb+7]|=((tc&0x0100)>>(8-1));
      TMP[tb+8]|=((tc&0x0080)>>(7-1));
      TMP[tb+9]|=((tc&0x0040)>>(6-1));
      TMP[tb+10]|=((tc&0x0020)>>(5-1));
      TMP[tb+11]|=((tc&0x0010)>>(4-1));
      TMP[tb+12]|=((tc&0x0008)>>(3-1));
      TMP[tb+13]|=((tc&0x0004)>>(2-1));
      TMP[tb+14]|=((tc&0x0002)>>(0));
      TMP[tb+15]|=((tc&0x0001)<<(1));
      tb+=16;
   }
   tb=0xF94B0;
   if(!load_rom("C57-02", TMP, 0xF94B0)) return;		// 16x8 SPRITES
   for(ta=0;ta<0xF94B0;ta+=2){
      tc=ReadWord(&TMP[ta]);
      TMP[tb+0]|=((tc&0x8000)>>(15-2));
      TMP[tb+1]|=((tc&0x4000)>>(14-2));
      TMP[tb+2]|=((tc&0x2000)>>(13-2));
      TMP[tb+3]|=((tc&0x1000)>>(12-2));
      TMP[tb+4]|=((tc&0x0800)>>(11-2));
      TMP[tb+5]|=((tc&0x0400)>>(10-2));
      TMP[tb+6]|=((tc&0x0200)>>(9-2));
      TMP[tb+7]|=((tc&0x0100)>>(8-2));
      TMP[tb+8]|=((tc&0x0080)>>(7-2));
      TMP[tb+9]|=((tc&0x0040)>>(6-2));
      TMP[tb+10]|=((tc&0x0020)>>(5-2));
      TMP[tb+11]|=((tc&0x0010)>>(4-2));
      TMP[tb+12]|=((tc&0x0008)>>(3-2));
      TMP[tb+13]|=((tc&0x0004)>>(0));
      TMP[tb+14]|=((tc&0x0002)<<(1));
      TMP[tb+15]|=((tc&0x0001)<<(2));
      tb+=16;
   }
   tb=0xF94B0;
   if(!load_rom("C57-01", TMP, 0xF94B0)) return;		// 16x8 SPRITES
   for(ta=0;ta<0xF94B0;ta+=2){
      tc=ReadWord(&TMP[ta]);
      TMP[tb+0]|=((tc&0x8000)>>(15-3));
      TMP[tb+1]|=((tc&0x4000)>>(14-3));
      TMP[tb+2]|=((tc&0x2000)>>(13-3));
      TMP[tb+3]|=((tc&0x1000)>>(12-3));
      TMP[tb+4]|=((tc&0x0800)>>(11-3));
      TMP[tb+5]|=((tc&0x0400)>>(10-3));
      TMP[tb+6]|=((tc&0x0200)>>(9-3));
      TMP[tb+7]|=((tc&0x0100)>>(8-3));
      TMP[tb+8]|=((tc&0x0080)>>(7-3));
      TMP[tb+9]|=((tc&0x0040)>>(6-3));
      TMP[tb+10]|=((tc&0x0020)>>(5-3));
      TMP[tb+11]|=((tc&0x0010)>>(4-3));
      TMP[tb+12]|=((tc&0x0008)>>(0));

⌨️ 快捷键说明

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