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

📄 topspeed.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************//*                                                                            *//*            TOP SPEED / FULL THROTTLE (C) 1986 TAITO CORPORATION            *//*                                                                            *//******************************************************************************/#include "gameinc.h"#include "topspeed.h"#include "tc100scn.h"#include "tc220ioc.h"#include "taitosnd.h"#include "debug.h"static struct DIR_INFO full_throttle_dirs[] ={   { "full_throttle", },   { "fullthr", },   { "fullthrl", },   { ROMOF("topspeed"), },   { CLONEOF("topspeed"), },   { NULL, },};static struct ROM_INFO full_throttle_roms[] ={   {       "b14-02", 0x00080000, 0x6889186b, 0, 0, 0, },   {       "b14-01", 0x00080000, 0x84a56f37, 0, 0, 0, },   {       "b14-03", 0x00080000, 0xd1ed9e71, 0, 0, 0, },   {       "b14-04", 0x00080000, 0xb63f0519, 0, 0, 0, },   {       "b14-05", 0x00080000, 0x6557e9d8, 0, 0, 0, },   {       "b14-06", 0x00020000, 0xb4e2536e, 0, 0, 0, },   {       "b14-07", 0x00020000, 0xc6025fff, 0, 0, 0, },   {       "b14-25", 0x00010000, 0x9eab28ef, 0, 0, 0, },   {       "b14-28", 0x00010000, 0xdf11d0ae, 0, 0, 0, },   {       "b14-29", 0x00010000, 0x7ad983e7, 0, 0, 0, },   {       "b14-30", 0x00010000, 0xdccb0c7f, 0, 0, 0, },   {       "b14-31", 0x00002000, 0x5c6b013d, 0, 0, 0, },   {       "b14-67", 0x00010000, 0x284c943f, 0, 0, 0, },   {       "b14-68", 0x00010000, 0x54cf6196, 0, 0, 0, },   {       "b14-69", 0x00010000, 0xd652e300, 0, 0, 0, },   {       "b14-71", 0x00010000, 0xf7081727, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};static struct INPUT_INFO full_throttle_inputs[] ={   { KB_DEF_COIN1,        MSG_COIN1,               0x055004, 0x08, BIT_ACTIVE_1 },   { KB_DEF_COIN2,        MSG_COIN2,               0x055004, 0x04, BIT_ACTIVE_1 },   { KB_DEF_SERVICE,      MSG_SERVICE,             0x055004, 0x10, BIT_ACTIVE_0 },   { KB_DEF_TILT,         MSG_TILT,                0x055006, 0x02, BIT_ACTIVE_0 },   { KB_DEF_P1_START,     MSG_P1_START,            0x055006, 0x08, BIT_ACTIVE_0 },// Fake wheel addresses, used for keyboard support   { KB_DEF_P1_LEFT,      MSG_P1_LEFT,             0x05501C, 0xFF, BIT_ACTIVE_1 },   { KB_DEF_P1_RIGHT,     MSG_P1_RIGHT,            0x05501D, 0xFF, BIT_ACTIVE_1 },// Fake pedal addresses, used for keyboard support - Unsure if adresses are really unused   { KB_DEF_P1_B1,        "Accelerator",           0x05501E, 0xFF, BIT_ACTIVE_1 },   { KB_DEF_P1_B3,        "Brake",                 0x05501B, 0xFF, BIT_ACTIVE_1 },   { KB_DEF_P1_B2,        "Low Gear",              0x055006, 0x10, BIT_ACTIVE_1 },   { KB_DEF_P1_B4,        "Nitro",                 0x055006, 0x01, BIT_ACTIVE_0 },   { 0,                   NULL,                    0,        0,    0            },};/*Note: Spinner control setting should not be used, because it's not compatible with PC controllers. Spinner is only usefull for MAME cabinet freaks that have built a custom controller, which behaves like a primitive steering wheel from the 1970's. Only the Analog dipswitch settings will work on PC hardware (keyboards and joysticks).Top Speed Controls Description by WarlockCabinet type is selectable via dipswitches A1 and A2A2A1 - 00 (Sit-Down with good wheel)Motor: NoPedals Type: AnalogWheel Type: NormalA2A1 - 01 (Sit-Down with bad wheel)Motor: NoPedals Type: AnalogWheel Type: SpinnerA2A1 - 10 (Upright)Motor: NoPedals Type: DigitalWheel Type: SpinnerA2A1 - 11 - (Deluxe Motorized Sit-Down)Motor: YesPedals Type: AnalogWheel Type: NormalAnalog Pedals Behaviour (same for Accelerator and Brake)Accelerator - Address 0x055006; bits 0xE0Brake       - Address 0x055004; bits 0xE0(Address - Speed Setting)000 - 0001 - 1010 - 3011 - 2100 - 7101 - 6110 - 4111 - 5or000 - 0001 - 1011 - 2010 - 3110 - 4111 - 5101 - 6100 - 7As you can see from the table above, the non-linear behaviour of the pedal is pretty stupid, it's not "standard" :(In order to support PC analog pedals, the following method could be used:For the accelerator, divide joy_y by 16, and for each of the 8 possible states, feed the result in the machine RAM, using the above conversion table.For the brake replace "joy_y" with "-joy_y".For the steering wheel, the following would work:  RAM[0x05501A] = (joy_x)>>8;  RAM[0x055018] = (joy_x);I won't bother doing this because the graphics are not emulated properly, also the game is running too fast (200% speed maybe)*/static struct DSW_DATA dsw_data_full_throttle_0[] ={// Spinner wheel behaviour is not supported, user is not allowed to change the cabinet.//   { "Cabinet",               0x03, 0x04 },//   { "Wheel",                 0x03, 0x00 },//   { "Spinner",               0x02, 0x00 },//   { "Spinner + Digital",     0x01, 0x00 },//   { "Wheel + Motor",         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_data_full_throttle_1[] ={   { MSG_DIFFICULTY,          0x03, 0x04 },   { MSG_NORMAL,              0x03, 0x00 },   { MSG_EASY,                0x02, 0x00 },   { MSG_HARD,                0x01, 0x00 },   { MSG_HARDEST,             0x00, 0x00 },   { "Start Time",            0x0C, 0x04 },   { "60",                    0x0C, 0x00 },   { "70",                    0x08, 0x00 },   { "50",                    0x04, 0x00 },   { "40",                    0x00, 0x00 },   { "Nitros per Stage",      0x30, 0x04 },   { "3",                     0x30, 0x00 },   { "2",                     0x20, 0x00 },   { "4",                     0x10, 0x00 },   { "5",                     0x00, 0x00 },   { "Continue Play",         0x40, 0x02 },   { MSG_OFF,                 0x40, 0x00 },   { MSG_ON,                  0x00, 0x00 },   { NULL,                    0,    0,   },};static struct DSW_INFO full_throttle_dsw[] ={   { 0x055000, 0xFF, dsw_data_full_throttle_0 },   { 0x055002, 0xFF, dsw_data_full_throttle_1 },   { 0,        0,    NULL,      },};/*static struct ROMSW_DATA romsw_data_full_throttle_0[] ={   { "Taito 0",               0x00 },   { "Taito 1",               0x01 },   { "Taito 2",               0x02 },   { "Taito 3",               0x03 },   { NULL,                    0    },};static struct ROMSW_INFO full_throttle_romsw[] ={   { 0x0BFFFF, 0xFF, romsw_data_full_throttle_0 },	// Bad Data?!   { 0,        0,    NULL },};*/static struct VIDEO_INFO full_throttle_video ={   DrawFullThrottle,   320,   240,   32,   VIDEO_ROTATE_NORMAL| VIDEO_ROTATABLE,};struct GAME_MAIN game_full_throttle ={   full_throttle_dirs,   full_throttle_roms,   full_throttle_inputs,   full_throttle_dsw,   NULL,   LoadFullThrottle,   ClearFullThrottle,   &full_throttle_video,   ExecuteFullThrottleFrame,   "fullthrl",   "Full Throttle",   NULL,   COMPANY_ID_TAITO,   "B14",   1987,   taito_ym2151_sound,   GAME_RACE | GAME_NOT_WORKING,};static struct DIR_INFO top_speed_dirs[] ={   { "top_speed", },   { "topspeed", },   { NULL, },};static struct ROM_INFO top_speed_roms[] ={   {       "b14-47", 0x00020000, 0xb3a1f75b, 0, 0, 0, },   {       "b14-07", 0x00020000, 0xc6025fff, 0, 0, 0, },   {       "b14-25", 0x00010000, 0x9eab28ef, 0, 0, 0, },   {       "b14-28", 0x00010000, 0xdf11d0ae, 0, 0, 0, },   {       "b14-29", 0x00010000, 0x7ad983e7, 0, 0, 0, },   {       "b14-30", 0x00010000, 0xdccb0c7f, 0, 0, 0, },   {       "b14-31", 0x00002000, 0x5c6b013d, 0, 0, 0, },   {       "b14-36", 0x00020000, 0x20a7c1b8, 0, 0, 0, },   {       "b14-37", 0x00020000, 0x801b703b, 0, 0, 0, },   {       "b14-38", 0x00020000, 0xde0c213e, 0, 0, 0, },   {       "b14-39", 0x00020000, 0x798c28c5, 0, 0, 0, },   {       "b14-40", 0x00020000, 0xfa2a3cb3, 0, 0, 0, },   {       "b14-41", 0x00020000, 0x09455a14, 0, 0, 0, },   {       "b14-42", 0x00020000, 0xab51f53c, 0, 0, 0, },   {       "b14-43", 0x00020000, 0x1e6d2b38, 0, 0, 0, },   {       "b14-44", 0x00020000, 0x9f6c030e, 0, 0, 0, },   {       "b14-45", 0x00020000, 0x63e4ce03, 0, 0, 0, },   {       "b14-46", 0x00020000, 0xd489adf2, 0, 0, 0, },   {       "b14-06", 0x00020000, 0xb4e2536e, 0, 0, 0, },   {       "b14-48", 0x00020000, 0x30c7f265, 0, 0, 0, },   {       "b14-49", 0x00020000, 0x32ba4265, 0, 0, 0, },   {       "b14-50", 0x00020000, 0xec1ef311, 0, 0, 0, },   {       "b14-51", 0x00020000, 0x35041c5f, 0, 0, 0, },   {       "b14-52", 0x00020000, 0xe1b5b2a1, 0, 0, 0, },   {       "b14-53", 0x00020000, 0x04a04f5f, 0, 0, 0, },   {       "b14-54", 0x00020000, 0x172924d5, 0, 0, 0, },   {       "b14-55", 0x00020000, 0xa1f15499, 0, 0, 0, },   {     "b14-67-1", 0x00010000, 0x23f17616, 0, 0, 0, },   {     "b14-68-1", 0x00010000, 0x835659d9, 0, 0, 0, },   {       "b14-69", 0x00010000, 0xd652e300, 0, 0, 0, },   {       "b14-70", 0x00010000, 0xb720592b, 0, 0, 0, },   {           NULL,          0,          0, 0, 0, 0, },};struct GAME_MAIN game_top_speed ={   top_speed_dirs,   top_speed_roms,   full_throttle_inputs,   full_throttle_dsw,   NULL,   LoadTopSpeed,   ClearTopSpeed,   &full_throttle_video,   ExecuteFullThrottleFrame,   "topspeed",   "Top Speed",   NULL,   COMPANY_ID_TAITO,   "B14",   1987,   taito_ym2151_sound,   GAME_RACE | GAME_NOT_WORKING,};static int romset;#define OBJ_A_COUNT	(0x8000)// OBJECT TILE MAPSstatic UINT8 *OBJECT_MAP;// 16x16 OBJECT TILES BANK Astatic UINT8 *GFX_OBJ_A;static UINT8 *GFX_OBJ_A_SOLID;static UINT8 *zoom16_ofs;static UINT8 *zoom8_ofs;static UINT8 *RAM_VIDEO;static UINT8 *RAM_VIDEO_2;static UINT8 *RAM_SCROLL;static UINT8 *RAM_SCROLL_2;static UINT8 *RAM_INPUT;static UINT8 *GFX_BG0_SOLID;static int tcpu=0;static int BadReadByte(UINT32 address){#ifdef RAINE_DEBUG      print_debug("Rb%01d(%06x) [%06x]\n",tcpu,address,s68000context.pc);#endif   return(0x55);}static int BadReadWord(UINT32 address){   #ifdef RAINE_DEBUG       print_debug("Rw%01d(%06x) [%06x]\n",tcpu,address,s68000context.pc);   #endif   return(0x5555);}static void LoadActual(void){   int ta,tb,tc;   UINT8 *TMP;   if(!(GFX=AllocateMem(0x80000))) return;   if(!(GFX_OBJ_A=AllocateMem(OBJ_A_COUNT*0x80))) return;   if(!(TMP=AllocateMem(0x80000))) return;   if(romset==0){   if(!load_rom("b14-04", TMP, OBJ_A_COUNT*0x10)) return;	// 16x16 OBJ A   tb=0;   for(ta=0;ta<OBJ_A_COUNT*0x10;ta+=2){      tc=ReadWord(&TMP[ta]);      GFX_OBJ_A[tb+0] =((tc&0x8000)>>(15));      GFX_OBJ_A[tb+1] =((tc&0x4000)>>(14));      GFX_OBJ_A[tb+2] =((tc&0x2000)>>(13));      GFX_OBJ_A[tb+3] =((tc&0x1000)>>(12));      GFX_OBJ_A[tb+4] =((tc&0x0800)>>(11));      GFX_OBJ_A[tb+5] =((tc&0x0400)>>(10));      GFX_OBJ_A[tb+6] =((tc&0x0200)>>( 9));      GFX_OBJ_A[tb+7] =((tc&0x0100)>>( 8));      GFX_OBJ_A[tb+8] =((tc&0x0080)>>( 7));      GFX_OBJ_A[tb+9] =((tc&0x0040)>>( 6));      GFX_OBJ_A[tb+10]=((tc&0x0020)>>( 5));      GFX_OBJ_A[tb+11]=((tc&0x0010)>>( 4));      GFX_OBJ_A[tb+12]=((tc&0x0008)>>( 3));      GFX_OBJ_A[tb+13]=((tc&0x0004)>>( 2));      GFX_OBJ_A[tb+14]=((tc&0x0002)>>( 1));      GFX_OBJ_A[tb+15]=((tc&0x0001)>>( 0));      tb+=16;   }   }   else{   if(!load_rom("b14-50", TMP+0x00000, 0x20000)) return;	// 16x16 OBJ A   if(!load_rom("b14-51", TMP+0x20000, 0x20000)) return;	// 16x16 OBJ A   if(!load_rom("b14-48", TMP+0x40000, 0x20000)) return;	// 16x16 OBJ A   if(!load_rom("b14-49", TMP+0x60000, 0x20000)) return;	// 16x16 OBJ A   tb=0;   for(ta=0;ta<0x40000;ta++){      tc=TMP[ta];      GFX_OBJ_A[tb+0] =((tc&0x80)>>( 7));      GFX_OBJ_A[tb+1] =((tc&0x40)>>( 6));      GFX_OBJ_A[tb+2] =((tc&0x20)>>( 5));      GFX_OBJ_A[tb+3] =((tc&0x10)>>( 4));      GFX_OBJ_A[tb+4] =((tc&0x08)>>( 3));      GFX_OBJ_A[tb+5] =((tc&0x04)>>( 2));      GFX_OBJ_A[tb+6] =((tc&0x02)>>( 1));

⌨️ 快捷键说明

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