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

📄 robokid.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************//*                                                                            *//*                        ATOMIC ROBOKID (C) 1988 UPL                         *//*                                                                            *//******************************************************************************/#include "gameinc.h"#include "robokid.h"#include "sasound.h"		// sample support routines#include "taitosnd.h"#include "2203intf.h"#include "decode.h"#ifdef RAINE_DEBUG#include "debug.h"#endif#include "savegame.h"static struct DIR_INFO atomic_robo_kid_dirs[] ={   { "atomic_robo_kid", },   { "robokid", },   { NULL, },};static struct ROM_INFO atomic_robo_kid_roms[] ={   {  "robokid.12a", 0x00010000, 0xe64d1c10, 0, 0, 0, },   {  "robokid.12c", 0x00010000, 0x0ab45f94, 0, 0, 0, },   {  "robokid.14a", 0x00010000, 0x8f9371e4, 0, 0, 0, },   {  "robokid.14c", 0x00010000, 0x029bbd4a, 0, 0, 0, },   {  "robokid.15a", 0x00010000, 0x469204e7, 0, 0, 0, },   {  "robokid.15c", 0x00010000, 0x7de67ebb, 0, 0, 0, },   {  "robokid.15d", 0x00010000, 0xcd632a4d, 0, 0, 0, },   {  "robokid.15f", 0x00010000, 0xba61f5ab, 0, 0, 0, },   {  "robokid.16a", 0x00010000, 0x4e340815, 0, 0, 0, },   {  "robokid.16c", 0x00010000, 0x53c0e582, 0, 0, 0, },   {  "robokid.16d", 0x00010000, 0x18d92b2b, 0, 0, 0, },   {  "robokid.16f", 0x00010000, 0xd9b399ce, 0, 0, 0, },   {  "robokid.17a", 0x00010000, 0xf0863106, 0, 0, 0, },   {  "robokid.17c", 0x00010000, 0x0cae5a1e, 0, 0, 0, },   {  "robokid.17d", 0x00010000, 0x2fa29b99, 0, 0, 0, },   {  "robokid.17f", 0x00010000, 0xafe432b9, 0, 0, 0, },   {  "robokid.18a", 0x00010000, 0xfdff7441, 0, 0, 0, },   {  "robokid.18c", 0x00010000, 0x56ac7c8a, 0, 0, 0, },   {  "robokid.18d", 0x00010000, 0xae15ce02, 0, 0, 0, },   {  "robokid.18f", 0x00010000, 0xa0aa2a84, 0, 0, 0, },   {  "robokid.19c", 0x00010000, 0x02220421, 0, 0, 0, },   {  "robokid.19d", 0x00010000, 0x784b089e, 0, 0, 0, },   {  "robokid.19f", 0x00010000, 0x0f9071c6, 0, 0, 0, },   {  "robokid.20c", 0x00010000, 0x02d59bc2, 0, 0, 0, },   {  "robokid.20d", 0x00010000, 0xb0b395ed, 0, 0, 0, },   {   "robokid.b9", 0x00008000, 0xfac59c3f, 0, 0, 0, },   {   "robokid.k7", 0x00010000, 0xf490a2e9, 0, 0, 0, },   { "robokid1.18j", 0x00010000, 0x378c21fc, 0, 0, 0, },   { "robokid2.18k", 0x00010000, 0xddef8c5a, 0, 0, 0, },   { "robokid3.15k", 0x00010000, 0x05295ec3, 0, 0, 0, },   { "robokid4.12k", 0x00010000, 0x3bc3977f, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};static struct INPUT_INFO atomic_robo_kid_inputs[] ={   { KB_DEF_COIN1,        MSG_COIN1,               0x00DC00, 0x20, BIT_ACTIVE_0 },   { KB_DEF_COIN2,        MSG_COIN2,               0x00DC00, 0x40, BIT_ACTIVE_0 },   { KB_DEF_TILT,         MSG_TILT,                0x00DC00, 0x04, BIT_ACTIVE_0 },   { KB_DEF_SERVICE,      MSG_SERVICE,             0x00DC00, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_START,     MSG_P1_START,            0x00DC00, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P1_UP,        MSG_P1_UP,               0x00DC01, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P1_DOWN,      MSG_P1_DOWN,             0x00DC01, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x00DC01, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x00DC01, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P1_B1,        MSG_P1_B1,               0x00DC01, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P1_B2,        MSG_P1_B2,               0x00DC01, 0x20, BIT_ACTIVE_0 },   { KB_DEF_P2_START,     MSG_P2_START,            0x00DC00, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P2_UP,        MSG_P2_UP,               0x00DC02, 0x08, BIT_ACTIVE_0 },   { KB_DEF_P2_DOWN,      MSG_P2_DOWN,             0x00DC02, 0x04, BIT_ACTIVE_0 },   { KB_DEF_P2_LEFT,      MSG_P2_LEFT,             0x00DC02, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P2_RIGHT,     MSG_P2_RIGHT,            0x00DC02, 0x01, BIT_ACTIVE_0 },   { KB_DEF_P2_B1,        MSG_P2_B1,               0x00DC02, 0x10, BIT_ACTIVE_0 },   { KB_DEF_P2_B2,        MSG_P2_B2,               0x00DC02, 0x20, BIT_ACTIVE_0 },   { 0,                   NULL,                    0,        0,    0            },};static struct DSW_INFO atomic_robo_kid_dsw[] ={   { 0x00DC03, 0xFF, dsw_data_default_0 },   { 0x00DC04, 0xFF, dsw_data_default_1 },   { 0,        0,    NULL,      },};static struct VIDEO_INFO atomic_robo_kid_video ={   DrawRoboKid,   256,   192,   32,   VIDEO_ROTATE_NORMAL |   VIDEO_ROTATABLE,};static struct YM2203interface ym2203_interface ={     2,				// 2 Chips     5000000,			// 1.25 * 4 ?   { 0x00ff20c0, 0x00ff20c0 },   { 0,          0          },   { 0,          0          },   { 0,          0          },   { 0,          0          },   { NULL,       NULL       }};static struct SOUND_INFO atomic_robo_kid_sound[] ={   { SOUND_YM2203,  &ym2203_interface,    },   { 0,             NULL,                 },};struct GAME_MAIN game_atomic_robo_kid ={   atomic_robo_kid_dirs,   atomic_robo_kid_roms,   atomic_robo_kid_inputs,   atomic_robo_kid_dsw,   NULL,   LoadRoboKid,   ClearRoboKid,   &atomic_robo_kid_video,   ExecuteRoboKidFrame,   "robokid",   "Atomic Robo Kid",   "傾僩儈僢僋儘儃僉僢僪",   COMPANY_ID_UPL,   "UPL-88013",   1988,   atomic_robo_kid_sound,   GAME_SHOOT,};static struct DIR_INFO atomic_robo_kid_japanese_dirs[] ={   { "atomic_robo_kid_japanese", },   { "robokidj", },   { ROMOF("robokid"), },   { CLONEOF("robokid"), },   { NULL, },};static struct ROM_INFO atomic_robo_kid_japanese_roms[] ={   {  "robokid.12a", 0x00010000, 0xe64d1c10, 0, 0, 0, },   {  "robokid.12c", 0x00010000, 0x0ab45f94, 0, 0, 0, },   {  "robokid.14a", 0x00010000, 0x8f9371e4, 0, 0, 0, },   {  "robokid.14c", 0x00010000, 0x029bbd4a, 0, 0, 0, },   {  "robokid.15a", 0x00010000, 0x469204e7, 0, 0, 0, },   {  "robokid.15c", 0x00010000, 0x7de67ebb, 0, 0, 0, },   {  "robokid.15d", 0x00010000, 0xcd632a4d, 0, 0, 0, },   {  "robokid.15f", 0x00010000, 0xba61f5ab, 0, 0, 0, },   {  "robokid.16a", 0x00010000, 0x4e340815, 0, 0, 0, },   {  "robokid.16c", 0x00010000, 0x53c0e582, 0, 0, 0, },   {  "robokid.16d", 0x00010000, 0x18d92b2b, 0, 0, 0, },   {  "robokid.16f", 0x00010000, 0xd9b399ce, 0, 0, 0, },   {  "robokid.17a", 0x00010000, 0xf0863106, 0, 0, 0, },   {  "robokid.17c", 0x00010000, 0x0cae5a1e, 0, 0, 0, },   {  "robokid.17d", 0x00010000, 0x2fa29b99, 0, 0, 0, },   {  "robokid.17f", 0x00010000, 0xafe432b9, 0, 0, 0, },   {  "robokid.18a", 0x00010000, 0xfdff7441, 0, 0, 0, },   {  "robokid.18c", 0x00010000, 0x56ac7c8a, 0, 0, 0, },   {  "robokid.18d", 0x00010000, 0xae15ce02, 0, 0, 0, },   {  "robokid.18f", 0x00010000, 0xa0aa2a84, 0, 0, 0, },   {  "robokid.19c", 0x00010000, 0x02220421, 0, 0, 0, },   {  "robokid.19d", 0x00010000, 0x784b089e, 0, 0, 0, },   {  "robokid.19f", 0x00010000, 0x0f9071c6, 0, 0, 0, },   {  "robokid.20c", 0x00010000, 0x02d59bc2, 0, 0, 0, },   {  "robokid.20d", 0x00010000, 0xb0b395ed, 0, 0, 0, },   {   "robokid.b9", 0x00008000, 0xfac59c3f, 0, 0, 0, },   {   "robokid.k7", 0x00010000, 0xf490a2e9, 0, 0, 0, },   {         "1.29", 0x00010000, 0x59a1e2ec, 0, 0, 0, },   {         "2.30", 0x00010000, 0xe3f73476, 0, 0, 0, },   { "robokid3.15k", 0x00010000, 0x05295ec3, 0, 0, 0, },   { "robokid4.12k", 0x00010000, 0x3bc3977f, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};struct GAME_MAIN game_atomic_robo_kid_japanese ={   atomic_robo_kid_japanese_dirs,   atomic_robo_kid_japanese_roms,   atomic_robo_kid_inputs,   atomic_robo_kid_dsw,   NULL,   LoadRoboKid,   ClearRoboKid,   &atomic_robo_kid_video,   ExecuteRoboKidFrame,   "robokidj",   "Atomic Robo Kid Japanese",   "傾僩儈僢僋儘儃僉僢僪",   COMPANY_ID_UPL,   "UPL-88013",   1988,   atomic_robo_kid_sound,   GAME_SHOOT,};static int romset;static UINT8 *RAM2;static UINT8 *ROM2;static UINT8 *RAM_VIDEO;static UINT8 *RAM_BG0;static UINT8 *RAM_BG1;static UINT8 *RAM_BG2;static UINT8 *RAM_FG0;static UINT8 *RAM_SPR;static UINT8 *SCR_BG0;static UINT8 *SCR_BG1;static UINT8 *SCR_BG2;static UINT8 mask_bg0;static UINT8 mask_bg1;static UINT8 mask_bg2;static UINT8 mask_fg0;static UINT8 mask_spr;static UINT8 *GFX_FG0;static UINT8 *FG0_Mask;static UINT8 *GFX_SPR;static UINT8 *SPR_Mask;static UINT8 *GFX_BG1;static UINT8 *BG1_Mask;static UINT8 *GFX_BG0;static UINT8 *BG0_Mask;static UINT8 *GFX_BG2;static UINT8 *BG2_Mask;/*UPL GAMES---------Supported romsets:0 - Atomic RobokidNinja Kid 2 was seperated, due to several hardware differences.*//******************************************************************************//* ROBO KID Z80 ROM BANKING                                                   *//******************************************************************************/static UINT8 Z80Bank;static UINT8 Z80BankCount;static UINT8 *ROM_BANK[0x10];void RoboKidBankWrite(UINT16 offset, UINT8 data){   if((data != Z80Bank)&&(data < Z80BankCount)){      Z80Bank = data;      Z80BSetBank( ROM_BANK[Z80Bank] );      //memcpy(RAM+0x8000, ROM+(Z80Bank<<14), 0x4000);   }   else{#ifdef RAINE_DEBUG      print_debug("MAIN Bank: %02x [%04x]\n", data, z80pc);#endif   }}static void init_bank_rom(UINT8 *src, UINT8 *dst, UINT8 bank_skip){   int ta;   for(ta=0;ta<0x10;ta++){      ROM_BANK[ta]=NULL;   }   for(ta=0;ta<Z80BankCount;ta++){      ROM_BANK[ta] = dst+(ta*0xC000);      memcpy(ROM_BANK[ta]+0x0000,src+0x0000,0x8000);      memcpy(ROM_BANK[ta]+0x8000,src+((ta+bank_skip)*0x4000),0x4000);   }}/******************************************************************************//* ROBO KID SOUND COMMUNICATION                                               *//******************************************************************************/static UINT8 sound_byte;static void RoboKidSoundWrite(UINT16 offset, UINT8 data){   sound_byte = data;}static UINT8 RoboKidSoundRead(UINT16 offset){   UINT8 ta;   ta = sound_byte;   sound_byte = 0xFF;   return ta;}/******************************************************************************//* ROBO KID VIDEO RAM BANKING                                                 *//******************************************************************************/static UINT8 *BG_BANK[4];static void RoboKidBG0BankWrite(UINT16 offset, UINT8 data){   BG_BANK[2] = RAM_VIDEO+(2<<11)+((data&1)<<10);}static void RoboKidBG1BankWrite(UINT16 offset, UINT8 data){   BG_BANK[1] = RAM_VIDEO+(1<<11)+((data&1)<<10);}static void RoboKidBG2BankWrite(UINT16 offset, UINT8 data){   BG_BANK[0] = RAM_VIDEO+(0<<11)+((data&1)<<10);}static void RoboKidBG012Write(UINT16 offset, UINT8 data){   BG_BANK[(offset>>10)&3][offset&0x3FF] = data;}static UINT8 RoboKidBG012Read(UINT16 offset){   return BG_BANK[(offset>>10)&3][offset&0x3FF];}static void RoboKidBG012Init(void){   BG_BANK[0] = RAM_VIDEO+(0<<11);   BG_BANK[1] = RAM_VIDEO+(1<<11);   BG_BANK[2] = RAM_VIDEO+(2<<11);   BG_BANK[3] = RAM_VIDEO+(3<<11);}/******************************************************************************//* GFX DECODES (from MS-1)                                                    *//******************************************************************************/static int MS1DecodeFG0(UINT8 *src, UINT32 size){   UINT32 ta,tb;   if(!(GFX_FG0=AllocateMem(0x10000))) return(0);   memset(GFX_FG0,0x00,0x10000);   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;

⌨️ 快捷键说明

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