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

📄 megasys1.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 5 页
字号:
{   {   "iga_01.bin", 0x00020000, 0xfa416a9e, 0, 0, 0, },   {   "iga_02.bin", 0x00020000, 0xbd00c280, 0, 0, 0, },   {   "iga_03.bin", 0x00010000, 0xde5937ad, 0, 0, 0, },   {   "iga_04.bin", 0x00010000, 0xafaf0480, 0, 0, 0, },   {   "iga_05.bin", 0x00010000, 0x13580868, 0, 0, 0, },   {   "iga_06.bin", 0x00010000, 0x7904d5dd, 0, 0, 0, },   {   "iga_08.bin", 0x00040000, 0x857dbf60, 0, 0, 0, },   {   "iga_10.bin", 0x00040000, 0x67a89e0d, 0, 0, 0, },   {   "iga_14.bin", 0x00040000, 0xc707d513, 0, 0, 0, },   {   "iga_18.bin", 0x00080000, 0x6c727519, 0, 0, 0, },   {   "iga_19.bin", 0x00020000, 0x98a7e998, 0, 0, 0, },   {   "iga_23.bin", 0x00080000, 0xfb58c5f4, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};static struct DSW_INFO iga_ninjyutsuden_dsw[] ={   { 0x010007, 0xFF, dsw_data_default_0 },   { 0x010006, 0xFF, dsw_data_default_1 },   { 0,        0,    NULL,      },};struct GAME_MAIN game_iga_ninjyutsuden ={   iga_ninjyutsuden_dirs,   iga_ninjyutsuden_roms,   megasys_1_inputs,   iga_ninjyutsuden_dsw,   NULL,   load_iga_ninjyutsuden,   ClearSaintDragon,   &megasys1_video,   ExecuteMegaSystem1Frame,   "iganinju",   "Iga Ninjyutsuden",   "埳夑鱁弍揱",   COMPANY_ID_JALECO,   NULL,   1988,   jaleco_ym2151_m6295x2_sound,   GAME_SHOOT,};static struct DIR_INFO shingen_dirs[] ={   { "shingen", },   { "tshingen", },   { "tshingna", },   { NULL, },};static struct ROM_INFO shingen_roms[] ={   { "shing_06.rom", 0x00010000, 0x8fa65b69, 0, 0, 0, },   { "shing_01.rom", 0x00020000, 0xa9d2de20, 0, 0, 0, },   { "shing_02.rom", 0x00020000, 0xd9ab5b78, 0, 0, 0, },   { "shing_05.rom", 0x00010000, 0xfbdc51c0, 0, 0, 0, },   { "shing_07.rom", 0x00020000, 0xc37ecbdc, 0, 0, 0, },   { "shing_08.rom", 0x00020000, 0x36d56c8c, 0, 0, 0, },   { "shing_09.rom", 0x00020000, 0xdb7f3f4f, 0, 0, 0, },   { "shing_10.rom", 0x00020000, 0xc9959d71, 0, 0, 0, },   { "shing_11.rom", 0x00020000, 0xbf0b40a6, 0, 0, 0, },   { "shing_12.rom", 0x00020000, 0x5e4adedb, 0, 0, 0, },   { "shing_15.rom", 0x00020000, 0x9db18233, 0, 0, 0, },   { "shing_16.rom", 0x00020000, 0xceda9dd6, 0, 0, 0, },   { "shing_17.rom", 0x00020000, 0x3d4371dc, 0, 0, 0, },   { "shing_19.rom", 0x00010000, 0x97282d9d, 0, 0, 0, },   { "shing_20.rom", 0x00020000, 0x7f6f8384, 0, 0, 0, },   { "shing_21.rom", 0x00020000, 0x12fb006b, 0, 0, 0, },   { "shing_22.rom", 0x00020000, 0xb165b6ae, 0, 0, 0, },   { "shing_23.rom", 0x00020000, 0x37cb9214, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};static struct DSW_INFO shingen_dsw[] ={   { 0x010007, 0xFF, dsw_data_default_0 },   { 0x010006, 0xFF, dsw_data_default_1 },   { 0,        0,    NULL,      },};struct GAME_MAIN game_shingen ={   shingen_dirs,   shingen_roms,   megasys_1_inputs,   shingen_dsw,   NULL,   LoadShingen,   ClearShingen,   &megasys1_video,   ExecuteMegaSystem1Frame,   "tshingna",   "Takeda Shingen",   NULL,   COMPANY_ID_JALECO,   NULL,   1988,   jaleco_ym2151_m6295x2_sound,   GAME_BEAT,};static UINT8 *RAM_COL;static UINT8 *GFX_FG0;static UINT8 *FG0_Mask;static UINT8 *GFX_SPR;static UINT8 *SPR_Mask;#define MSK_SPR         0x0FFFstatic UINT8 *GFX_BG1;static UINT8 *BG1_Mask;static UINT8 *GFX_BG0;static UINT8 *BG0_Mask;static UINT8 RenderSpr;/**********************************************************/static int romset;/**********************************************************//**** add & modified by hiro-shi!! ****/static UINT16 SoundByte[32];static int SoundW, SoundR;static int NowReadSound;void SoundWorkInit( void ){  SoundW = SoundR = 0;  NowReadSound = 0;};static void MS1VideoWrite(UINT32 addr, UINT16 data){   addr&=0xFFFF;   WriteWord(&RAM[0x10000+addr],data);   // Sprite Chain RAM   if(addr>=0xE000){      RenderSpr=0;                      // Force Recalculate Chain Pointers      return;   }   // Sound COMM   if(addr==0x4308){      SoundByte[SoundW]=data;      SoundW = (SoundW+1) & 31;      //#ifdef RAINE_DEBUG      //print_debug("Main 68000 Sends:%04x\n",data);      //#endif      return;   }}static void MS2SoundWrite(UINT32 addr, UINT16 data){   WriteWord(&RAM[0x18000],data);   SoundByte[SoundW]=data;   SoundW = (SoundW+1) & 31;   //#ifdef RAINE_DEBUG   //print_debug("Main 68000 Sends:%04x\n",SoundByte);   //#endif}/*-------[Sub 68000 Sound Port]-------*/static int SubSoundRead(UINT32 address){   //#ifdef RAINE_DEBUG   //print_debug("Sub 68000 Reads:%04x\n",SoundByte);   //#endif   if( SoundW != SoundR ){      NowReadSound = SoundByte[SoundR];      SoundR = (SoundR+1) & 31;   }   return NowReadSound;}static UINT16 SubSoundReadZ80(UINT16 address){   //#ifdef RAINE_DEBUG   //print_debug("Sub Z80 Reads:%02x\n",SoundByte[SoundR]&0xFF);   //#endif   if( SoundW != SoundR ){      NowReadSound = SoundByte[SoundR] & 0xFF;      SoundR = (SoundR+1) & 31;   }   return NowReadSound;}static void SubSoundWrite(UINT32 address, UINT16 data){   WriteWord(&RAM[0x10008],NowReadSound);       // Write to 68000 readback port}/*-------[YM2151 PORT]-------*/static UINT8 ym2151_rb(UINT32 address){  static UINT8 ta=0;  int res;  if (ta++>251) ta =0;  if (ta > 249) res= 1;  else    res= 0;#if 0  if (res)  fprintf(stderr,"*%d*\n",res);  else    fprintf(stderr,"%d ",res);#endif  return res;     //}}static UINT16 ym2151_rw(UINT32 address){  return ym2151_rb(address)<<8 | ym2151_rb(address+1);}static void ym2151_wb(UINT32 address, UINT8 data){   address&=3;   if(address<2)      YM2151_register_port_0_w(address, data);   else      YM2151_data_port_0_w(address, data);}static void ym2151_ww(UINT32 address, UINT16 data){  ym2151_wb(address, (UINT8) (data&0xff)); //>>8) );  //   ym2151_wb(address+1, (UINT8) (data&0xFF) );}int MS1DecodeFG0(UINT8 *src, UINT32 size){   UINT32 ta,tb;   if(!(GFX_FG0=AllocateMem(0x40000))) return(0);   memset(GFX_FG0,0x00,0x40000);   tb=0;   for(ta=0;ta<size;ta++,tb+=2){      GFX_FG0[tb+0]=(src[ta]>>4)^15;      GFX_FG0[tb+1]=(src[ta]&15)^15;   }   FG0_Mask = make_solid_mask_8x8(GFX_FG0, 0x1000);   return 1;}int MS1DecodeSPR(UINT8 *src, UINT32 size){   UINT32 ta,tb;   if(!(GFX_SPR=AllocateMem(size<<1))) return(0);   tb=0;   for(ta=0;ta<size;ta+=4){      GFX_SPR[tb+0]=(src[ta+0]>>4)^15;      GFX_SPR[tb+1]=(src[ta+0]&15)^15;      GFX_SPR[tb+2]=(src[ta+1]>>4)^15;      GFX_SPR[tb+3]=(src[ta+1]&15)^15;      GFX_SPR[tb+4]=(src[ta+2]>>4)^15;      GFX_SPR[tb+5]=(src[ta+2]&15)^15;      GFX_SPR[tb+6]=(src[ta+3]>>4)^15;      GFX_SPR[tb+7]=(src[ta+3]&15)^15;      tb+=16;      if((tb&0xFF)==0){tb-=0xF8;}      else{if((tb&0xFF)==8){tb-=8;}}   }   SPR_Mask = make_solid_mask_16x16(GFX_SPR, size/0x80);   RenderSpr=0;   return 1;}int MS1DecodeBG1(UINT8 *src, UINT32 size){   UINT32 ta,tb;   if(!(GFX_BG1=AllocateMem(0x100000))) return(0);   memset(GFX_BG1,0x00,0x100000);   tb=0;   for(ta=0;ta<size;ta+=4){      GFX_BG1[tb+0]=(src[ta+0]>>4)^15;      GFX_BG1[tb+1]=(src[ta+0]&15)^15;      GFX_BG1[tb+2]=(src[ta+1]>>4)^15;      GFX_BG1[tb+3]=(src[ta+1]&15)^15;      GFX_BG1[tb+4]=(src[ta+2]>>4)^15;      GFX_BG1[tb+5]=(src[ta+2]&15)^15;      GFX_BG1[tb+6]=(src[ta+3]>>4)^15;      GFX_BG1[tb+7]=(src[ta+3]&15)^15;      tb+=16;      if((tb&0xFF)==0){tb-=0xF8;}      else{if((tb&0xFF)==8){tb-=8;}}   }   BG1_Mask = make_solid_mask_16x16(GFX_BG1, 0x1000);   return 1;}int MS1DecodeBG0(UINT8 *src, UINT32 size){   UINT32 ta,tb;   if(!(GFX_BG0=AllocateMem(0x100000))) return(0);   memset(GFX_BG0,0x00,0x100000);   tb=0;   for(ta=0;ta<size;ta+=4){      GFX_BG0[tb+0]=(src[ta+0]>>4)^15;      GFX_BG0[tb+1]=(src[ta+0]&15)^15;      GFX_BG0[tb+2]=(src[ta+1]>>4)^15;      GFX_BG0[tb+3]=(src[ta+1]&15)^15;      GFX_BG0[tb+4]=(src[ta+2]>>4)^15;      GFX_BG0[tb+5]=(src[ta+2]&15)^15;      GFX_BG0[tb+6]=(src[ta+3]>>4)^15;      GFX_BG0[tb+7]=(src[ta+3]&15)^15;      tb+=16;      if((tb&0xFF)==0){tb-=0xF8;}      else{if((tb&0xFF)==8){tb-=8;}}   }   BG0_Mask = make_solid_mask_16x16(GFX_BG0, 0x1000);   return 1;}#define DEF_MS1_SOUNDCLOCK  (CPU_FRAME_MHz(12,60))static int MS1SoundLoop = 8;static int MS1SoundClock = DEF_MS1_SOUNDCLOCK;static void MS1SoundFrame(void){  int ta;  for( ta = MS1SoundLoop; ta > 0; ta-- ){    cpu_execute_cycles(CPU_68K_1, MS1SoundClock);#ifdef RAINE_DEBUG       if(ta==1) print_debug("PC:%06x SR:%04x\n",s68000context.pc,s68000context.sr);#endif    cpu_interrupt(CPU_68K_1, 4);  }}static void MS2SoundFrame(void){   int ta;   for(ta=0;ta<2;ta++){   cpu_execute_cycles(CPU_68K_1, CPU_FRAME_MHz(12,60)/2);          // 2 Ints/Frame (correct music speed?)   cpu_interrupt(CPU_68K_1, 2);   }}static void LegendOfMakajSoundFrame(void){   cpu_execute_cycles(CPU_Z80_0, 4000000/60);                        // Z80 4MHz   /*#ifdef RAINE_DEBUG      print_debug("Z80PC0:%04x\n",z80pc);   #endif*/   cpu_interrupt(CPU_Z80_0, 0x38);                               // 4 Ints/Frame (correct speed?)   cpu_interrupt(CPU_Z80_0, 0x38);   cpu_interrupt(CPU_Z80_0, 0x38);   cpu_interrupt(CPU_Z80_0, 0x38);}static void EmptySoundFrame(void){}static int layer_id_data[4];static char *layer_id_name[4] ={   "BG0",   "BG1",   "BG2",   "OBJ",};static void AddMS1Controls(void){   ExecuteSoundFrame=&MS1SoundFrame;   if(romset==12){      ExecuteSoundFrame=&LegendOfMakajSoundFrame;   }   if(romset==16){      ExecuteSoundFrame=&EmptySoundFrame;   }   if(romset!=12){      memset(RAM+0x00000,0x00,0x40000);   }   memset(RAM+0x10000,0xFF,0x00008);   RAM_COL=RAM+0x18000;   InitPaletteMap(RAM_COL, 0x40, 0x10, 0x8000);   set_colour_mapper(&col_map_rrrr_gggg_bbbb_rgbx_rev);   layer_id_data[0] = add_layer_info(layer_id_name[0]);   layer_id_data[1] = add_layer_info(layer_id_name[1]);   layer_id_data[2] = add_layer_info(layer_id_name[2]);   layer_id_data[3] = add_layer_info(layer_id_name[3]);}static void AddMS2Controls(void){   if(romset!=8){      ExecuteSoundFrame=&MS1SoundFrame;   }   else{      ExecuteSoundFrame=&MS2SoundFrame;   }   memset(&RAM[

⌨️ 快捷键说明

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