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

📄 cave.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************//*                                                                            *//*                        CAVE / ATLUS GAMES (C) 1998                         *//*                                                                            *//******************************************************************************/#include "gameinc.h"#include "cave.h"#include "cat93c46.h"#include "mame/handlers.h"#include "mame/eeprom.h"#include "sasound.h"		// sample support routines#include "debug.h"#include "savegame.h"#include "lspr16x16.h"#undef RAINE_DEBUG/******************************************************************************/#define MAX_PRI         16              // 16 levels of priority/* Definitions for priorities : * bits 0-1 : tile number *            0 = sprites (OBJ) *            1-3 : bg layers 0-2 * bits 2-3 : priority (from 0 to 3) */#define MAX_TILES       0x8000          // 0x4000*0x14=0xA0000 (640kb)static struct TILE_Q{   UINT32 tile;                          // Tile number   UINT16 x,y;                           // X,Y position   UINT8 *map;                          // Colour map data   UINT8 flip;                          // Flip X/Y Axis   UINT16 ww,hh;   UINT16 zoomx,zoomy;   struct TILE_Q *next;                 // Next item with equal priority} TILE_Q;static struct TILE_QS{   UINT32 tile;                          // Tile number   INT16 x,y;                           // X,Y position   UINT8 *map;                          // Colour map data   UINT8 flip;                          // Flip X/Y Axis   UINT8 *dy;                           // offset for linescroll (adr)  struct TILE_QS *next;                 // Next item with equal priority} TILE_QS;static struct TILE_Q *TileQueue;               // full liststatic struct TILE_Q *last_tile;               // last tile in usestatic struct TILE_Q *next_tile[MAX_PRI];      // next tile for each prioritystatic struct TILE_Q *first_tile[MAX_PRI];     // first tile for each prioritystatic struct TILE_QS *TileQueue_scroll;               // full liststatic struct TILE_QS *last_tile_scroll;               // last tile in usestatic struct TILE_QS *next_tile_scroll[MAX_PRI];      // next tile for each prioritystatic struct TILE_QS *first_tile_scroll[MAX_PRI];     // first tile for each priority/******************************************************************************/// Fake dsw for guwangestatic struct DSW_DATA dsw_guwange_0[] ={   { "Zoom",           0x01, 0x02 },   { MSG_ON,           0x00, 0x00 },   { MSG_OFF,          0x01, 0x00 },};static struct DSW_INFO guwange_dsw[] ={   { 0x005, 0xFE, dsw_guwange_0 },};static UINT32 gfx_bg0_count;static UINT32 gfx_bg1_count;static UINT32 gfx_bg2_count;static UINT32 gfx_obj_count;static const int *scrolldx,*scrolldx_flip;int raster_bg;static int latch;static int limitx, gamex;const int  ddonpach_scrolldx_flip[] = { 0x57, 0x56, 0x55 -7 +1 },  ddonpach_scrolldx[]      = { 0x6c, 0x6d, 0x6e + 7 },  donpachi_scrolldx_flip[] = { 0x57, 0x56, 0x55 -7 +1+2 },  donpachi_scrolldx[]      = { 0x6c, 0x6d, 0x6e +7-2 },  feveron_scrolldx_flip[] = { 0x54, 0x53, 0 },  feveron_scrolldx[]      = { 0x6c, 0x6d, 0 },  uopoko_scrolldx_flip[] = { 0x54, 0, 0 },  uopoko_scrolldx[]      = { 0x6d, 0, 0 },  esprade_scrolldx_flip[] = { 0x57, 0x56, 0x55 },  esprade_scrolldx[]      = { 0x6c, 0x6d, 0x6e }, // also hotdogst  hotdogst_scrolldx_flip[]= { 0x57-0x40, 0x56-0x40, 0x55-0x40 },  guwange_scrolldx_flip[] = { 0x57+2, 0x56+2, 0x55+2 },  guwange_scrolldx[]      = { 0x6c-2, 0x6d-2, 0x6e -2 };      static short vblank_irq,sound_irq,romset;// romset is 1 for ddonpach (bg2 and register places different...)// 2 for uopoko (layer alignement different)// 3 for dfeveron (little slide in flipped bg0...)static unsigned long sprite_size; // To prevent overflows...static short flipx,flipy; // global flipping (sprites & layers)// Nb of sprites / rows for a tile#define DIM_NX 0x20 // _ / col#define DIM_NY 0x20 /* Update the IRQ state based on all possible causes */static int irq_counter = 0;static UINT8 *dsw_buffer = &input_buffer[5];static void setup_cave_game() {  limitx = current_game->video_info->screen_x + current_game->video_info->border_size+16;  gamex = current_game->video_info->screen_x;  if(!(TileQueue = (struct TILE_Q *) AllocateMem(sizeof(TILE_Q)*MAX_TILES)))return;   memset(RAM+0x00000,0x00,0x80000);   AddMemFetch(-1, -1, NULL);      AddRWBW(-1, -1, NULL, NULL);   AddReadByte(0x000000, 0xFFFFFF, DefBadReadByte, NULL);      // <Bad Reads>    AddReadWord(0x000000, 0xFFFFFF, DefBadReadWord, NULL);      // <Bad Reads>   AddWriteByte(0x000000, 0xFFFFFF, DefBadWriteByte, NULL);      // <Bad Writes>   AddWriteWord(0x000000, 0xFFFFFF, DefBadWriteWord, NULL);      // <Bad Writes>   AddInitMemory();   // Set Starscream mem pointers... }static void update_irq_state(void){  //  fprintf(stderr,"vb %d so %d\n",vblank_irq,sound_irq);  if ((vblank_irq || sound_irq) && irq_counter++<3)	  cpu_interrupt(CPU_68K_0, 1);}/* Called by the YMZ280B to set the IRQ state */static void sound_irq_gen(int state){	sound_irq = (state != 0);          update_irq_state();  }static void irqhandler(int irq){  if (irq){    cpu_interrupt(CPU_Z80_0, 0x38);  }}static struct YMZ280Binterface ymz280b_intf ={   1,   { 16934400 },   { REGION_SMP1 },   { YM3012_VOL(255,MIXER_PAN_LEFT,255,MIXER_PAN_RIGHT) },      { sound_irq_gen }};static struct OKIM6295interface donpachi_okim6295_interface ={	2,	{ 8330, 16000 },	{ REGION_SMP1, REGION_SMP2 },	{ 225, 225 }};static struct YM2203interface hotdogst_ym2203_interface ={	1,			/* 1 chip */	3000000,	/* 3 MHz ??? */	{ YM2203_VOL(75,75) },	{ 0 },	{ 0 },	{ 0 },	{ 0 },	{ irqhandler }};static struct OKIM6295interface hotdogst_okim6295_interface ={	1,                  /* 1 chip */	{ 8000 },           /* 8000Hz frequency? */	{ REGION_SMP1 },	/* memory region */	{ 200 }};struct SOUND_INFO donpachi_sound[] ={   { SOUND_M6295,  &donpachi_okim6295_interface,  },   { 0,             NULL,               },};struct SOUND_INFO cave_sound[] ={   { SOUND_YMZ280B,  &ymz280b_intf,  },   { 0,             NULL,               },};struct SOUND_INFO hotdogst_sound[] ={   { SOUND_YM2203,  &hotdogst_ym2203_interface,  },   { SOUND_M6295, &hotdogst_okim6295_interface,},};static struct DIR_INFO esprade_dirs[] ={   { "esprade", },   { NULL, },};static struct DIR_INFO hotdogst_dirs[] ={   { "hotdogst", },   { "HotDogStorm" },   { NULL, },};static struct DIR_INFO donpachi_dirs[] ={   { "donpachi", },   { NULL, },};static struct DIR_INFO guwange_dirs[] ={   { "guwange", },   { NULL, },};static struct DIR_INFO ddonpach_dirs[] ={  { "ddonpach", },  { NULL, },};static struct ROM_INFO esprade_roms[] ={   {      "u42.bin", 0x00080000, 0x0718c7e5,REGION_ROM1,0,LOAD_8_16 },   {      "u41.bin", 0x00080000, 0xdef30539,REGION_ROM1,1,LOAD_8_16 },   {      "u54.bin", 0x00400000, 0xe7ca6936,REGION_GFX1,0x000000,LOAD8X8_16X16 },   {      "u55.bin", 0x00400000, 0xf53bd94f,REGION_GFX1,0x400000,LOAD8X8_16X16 },   {      "u52.bin", 0x00400000, 0xe7abe7b4,REGION_GFX2,0x000000,LOAD8X8_16X16 },   {      "u53.bin", 0x00400000, 0x51a0f391,REGION_GFX2,0x400000,LOAD8X8_16X16 },   {      "u51.bin", 0x00400000, 0x0b9b875c,REGION_GFX3,0x000000,LOAD8X8_16X16 },      {      "u63.bin", 0x00400000, 0x2f2fe92c,REGION_GFX4,0x000000,LOAD_8_16S },   {      "u64.bin", 0x00400000, 0x491a3da4,REGION_GFX4,0x000001,LOAD_8_16S },   {      "u65.bin", 0x00400000, 0x06563efe,REGION_GFX4,0x800000,LOAD_8_16S },   {      "u66.bin", 0x00400000, 0x7bbe4cfc,REGION_GFX4,0x800001,LOAD_8_16S },   {      "u19.bin", 0x00400000, 0xf54b1cab,REGION_SMP1,0,LOAD_NORMAL },   {           NULL,          0,          0, },};static struct ROM_INFO donpachi_roms[] ={   {      "prg.u29", 0x00080000, 0x6be14af6,REGION_ROM1,0,LOAD_SWAP_16 },   {      "atdp.u54", 0x100000, 0x6bda6b66,REGION_GFX1,0x000000, LOAD_NORMAL },   {      "atdp.u57", 0x100000, 0x0a0e72b9,REGION_GFX2,0x000000,LOAD_NORMAL },   {      "u58.bin", 0x00040000, 0x285379ff,REGION_GFX3,0x000000,LOAD_NORMAL },      {      "atdp.u44",0x00200000, 0x7189e953,REGION_GFX4,0x000000,LOAD_SWAP_16 },   {      "atdp.u45",0x00200000, 0x6984173f,REGION_GFX4,0x200000,LOAD_SWAP_16 },   {      "atdp.u33", 0x00200000, 0xd749de00,REGION_SMP1,0x40000,LOAD_NORMAL },   {      "atdp.u32", 0x00100000, 0x0d89fcca,REGION_SMP2,0x40000,LOAD_NORMAL },   {      "atdp.u33", 0x00200000, 0xd749de00,REGION_SMP2,0x140000,LOAD_NORMAL },      {           NULL,          0,          0, },};static struct ROM_INFO guwange_roms[] ={  { "gu-u0127.bin", 0x00080000, 0xf86b5293, REGION_ROM1, 0x0000000, LOAD_8_16,   },  { "gu-u0129.bin", 0x00080000, 0x6c0e3b93, REGION_ROM1, 0x0000001, LOAD_8_16,   },  {     "u101.bin", 0x00800000, 0x0369491f, REGION_GFX1, 0x0000000, LOAD8X8_16X16, },  {   "u10102.bin", 0x00400000, 0xe28d6855, REGION_GFX2, 0x0000000, LOAD8X8_16X16, },   {   "u10103.bin", 0x00400000, 0x0fe91b8e, REGION_GFX3, 0x0000000, LOAD8X8_16X16, },  {     "u083.bin", 0x00800000, 0xadc4b9c4, REGION_GFX4, 0x0000000, LOAD_8_16S, },   {     "u082.bin", 0x00800000, 0x3d75876c, REGION_GFX4, 0x0000001, LOAD_8_16S, },   {     "u086.bin", 0x00400000, 0x188e4f81, REGION_GFX4, 0x1000000, LOAD_8_16S, },   {     "u085.bin", 0x00400000, 0xa7d5659e, REGION_GFX4, 0x1000001, LOAD_8_16S, },   {    "u0462.bin", 0x00400000, 0xb3d75691, REGION_SMP1, 0, LOAD_NORMAL, },   {           NULL,          0,          0, 0, 0, 0, },};static struct ROM_INFO ddonpach_roms[] ={   {      "u27.bin", 0x00080000, 0x2432ff9b, REGION_ROM1, 0x0000000, LOAD_8_16,    },   {      "u26.bin", 0x00080000, 0x4f3a914a, REGION_ROM1, 0x0000001, LOAD_8_16,    },   {      "u60.bin", 0x00200000, 0x903096a7, REGION_GFX1, 0x0000000, LOAD_NORMAL,  },   {      "u61.bin", 0x00200000, 0xd89b7631, REGION_GFX2, 0x0000000, LOAD_NORMAL,  },   {      "u62.bin", 0x00200000, 0x292bfb6b, REGION_GFX3, 0x0000000, LOAD_NORMAL,  },   {      "u50.bin", 0x00200000, 0x14b260ec, REGION_GFX4, 0x0000000, LOAD_SWAP_16, },   {      "u51.bin", 0x00200000, 0xe7ba8cce, REGION_GFX4, 0x0200000, LOAD_SWAP_16, },   {      "u52.bin", 0x00200000, 0x02492ee0, REGION_GFX4, 0x0400000, LOAD_SWAP_16, },   {      "u53.bin", 0x00200000, 0xcb4c10f0, REGION_GFX4, 0x0600000, LOAD_SWAP_16, },   {       "u6.bin", 0x00200000, 0x9dfdafaf, REGION_SMP1, 0x0000000, LOAD_NORMAL, },   {       "u7.bin", 0x00200000, 0x795b17d5, REGION_SMP1, 0x0200000, LOAD_NORMAL, },   {           NULL,          0,          0, 0, 0, 0, },};static struct ROM_INFO hotdogst_roms[] ={   {       "mp3u29", 0x00080000, 0x1f4e5479,REGION_ROM1,0,LOAD_8_16 },   {       "mp4u28", 0x00080000, 0x6f1c3c4b,REGION_ROM1,1,LOAD_8_16 },   {       "mp2u19", 0x00040000, 0xff979ebe,REGION_ROM2,0,LOAD_NORMAL },   {       "mp7u56", 0x080000, 0x87c21c50,REGION_GFX1,0x000000, LOAD_NORMAL },   {       "mp6u61", 0x080000, 0x4dafb288,REGION_GFX2,0x000000,LOAD_NORMAL },   {       "mp5u64",0x0080000, 0x9b26458c,REGION_GFX3,0x000000,LOAD_NORMAL },      {      "mp9u55",0x00200000, 0x258d49ec,REGION_GFX4,0x000000, LOAD_NORMAL },   {      "mp8u54",0x00200000, 0xbdb4d7b8,REGION_GFX4,0x200000, LOAD_NORMAL },   {      "mp1u65", 0x00080000, 0x4868be1b,REGION_SMP1,0x00000,LOAD_NORMAL },   {           NULL,          0,          0, },};   static struct INPUT_INFO cave_68k_inputs[] ={   { KB_DEF_COIN1,        MSG_COIN1,               0x000000, 0x01, BIT_ACTIVE_0 },   { KB_DEF_COIN2,        MSG_COIN2,               0x000002, 0x01, BIT_ACTIVE_0 },   { KB_DEF_TEST,         MSG_TEST,                0x000000, 0x02, BIT_ACTIVE_0 },   { KB_DEF_SERVICE,      MSG_SERVICE,             0x000002, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_START,     MSG_P1_START,            0x000001, 0x80, BIT_ACTIVE_0 },   { KB_DEF_P1_UP,        MSG_P1_UP,               0x000001, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P1_DOWN,      MSG_P1_DOWN,             0x000001, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x000001, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x000001, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_B1,        MSG_P1_B1,               0x000001, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P1_B2,        MSG_P1_B2,               0x000001, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P1_B3,        MSG_P1_B3,               0x000001, 0x40, BIT_ACTIVE_0 },   { KB_DEF_P2_START,     MSG_P2_START,            0x000003, 0x80, BIT_ACTIVE_0 },   { KB_DEF_P2_UP,        MSG_P2_UP,               0x000003, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P2_DOWN,      MSG_P2_DOWN,             0x000003, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P2_LEFT,      MSG_P2_LEFT,             0x000003, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P2_RIGHT,     MSG_P2_RIGHT,            0x000003, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P2_B1,        MSG_P2_B1,               0x000003, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P2_B2,        MSG_P2_B2,               0x000003, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P2_B3,        MSG_P2_B3,               0x000003, 0x40, BIT_ACTIVE_0 },   { 0,                   NULL,                    0,        0,    0            },};static struct INPUT_INFO guwange_inputs[] ={   { KB_DEF_COIN1,        MSG_COIN1,               0x000003, 0x01, BIT_ACTIVE_0 },   { KB_DEF_COIN2,        MSG_COIN2,               0x000003, 0x02, BIT_ACTIVE_0 },   { KB_DEF_TEST,         MSG_TEST,                0x000003, 0x04, BIT_ACTIVE_0 },   { KB_DEF_SERVICE,      MSG_SERVICE,             0x000003, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_START,     MSG_P1_START,            0x000001, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P1_UP,        MSG_P1_UP,               0x000001, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_DOWN,      MSG_P1_DOWN,             0x000001, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x000001, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x000001, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P1_B1,        MSG_P1_B1,               0x000001, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P1_B2,        MSG_P1_B2,               0x000001, 0x40, BIT_ACTIVE_0 },   { KB_DEF_P1_B3,        MSG_P1_B3,               0x000001, 0x80, BIT_ACTIVE_0 },   { KB_DEF_P2_START,     MSG_P2_START,            0x000000, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P2_UP,        MSG_P2_UP,               0x000000, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P2_DOWN,      MSG_P2_DOWN,             0x000000, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P2_LEFT,      MSG_P2_LEFT,             0x000000, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P2_RIGHT,     MSG_P2_RIGHT,            0x000000, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P2_B1,        MSG_P2_B1,               0x000000, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P2_B2,        MSG_P2_B2,               0x000000, 0x40, BIT_ACTIVE_0 },   { KB_DEF_P2_B3,        MSG_P2_B3,               0x000000, 0x80, BIT_ACTIVE_0 },   { 0,                   NULL,                    0,        0,    0            },};/* 8x8x4 tiles */static struct GFX_LAYOUT layout_8x8x4 ={   8,8,   RGN_FRAC(1,1),   4,   {0,1,2,3},   {STEP8(0,4)},   {STEP8(0,8*4)},   8*8*4};/* 8x8x8 tiles */static struct GFX_LAYOUT layout_8x8x8 ={   8,8,   RGN_FRAC(1,1),   8,   {8,9,10,11, 0,1,2,3},   {0*4,1*4,4*4,5*4,8*4,9*4,12*4,13*4},   {0*64,1*64,2*64,3*64,4*64,5*64,6*64,7*64},   8*8*8};/* 16x16x4 tiles */static struct GFX_LAYOUT layout_16x16x4 ={   16,16,   RGN_FRAC(1,1),   4,   {0,1,2,3},   {0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4,

⌨️ 快捷键说明

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