📄 tecmosys.c
字号:
/******************************************************************************//* *//* NINJA GAIDEN (C)1988 TECMO *//* *//* TECMO KNIGHT (C)1989 TECMO *//* *//******************************************************************************/#include "gameinc.h"#include "tecmosys.h"#include "taitosnd.h"#include "2203intf.h"#include "sasound.h" // sample support routines#ifdef RAINE_DEBUG#include "debug.h"#endifstatic struct DIR_INFO ninja_gaiden_dirs[] ={ { "ninja_gaiden", }, { "gaiden", }, { NULL, },};static struct ROM_INFO ninja_gaiden_roms[] ={ { "gaiden.10", 0x00020000, 0xa6451dec, 0, 0, 0, }, { "gaiden.11", 0x00020000, 0x7fbfdf5e, 0, 0, 0, }, { "gaiden.12", 0x00020000, 0x90f1e13a, 0, 0, 0, }, { "gaiden.13", 0x00020000, 0x7d9f5c5e, 0, 0, 0, }, { "gaiden.2", 0x00020000, 0x454f7314, 0, 0, 0, }, { "gaiden.3", 0x00010000, 0x75fd3e6a, 0, 0, 0, }, { "gaiden.4", 0x00020000, 0xb0e0faf9, 0, 0, 0, }, { "gaiden.6", 0x00020000, 0xe7ccdf9f, 0, 0, 0, }, { "gaiden.7", 0x00020000, 0x016bec95, 0, 0, 0, }, { "gaiden.8", 0x00020000, 0x7ef7f880, 0, 0, 0, }, { "gaiden.9", 0x00020000, 0x6e9b7fd3, 0, 0, 0, }, { "18.bin", 0x00020000, 0x3fadafd6, 0, 0, 0, }, { "19.bin", 0x00020000, 0xddae9d5b, 0, 0, 0, }, { "gaiden.1", 0x00020000, 0xe037ff7c, 0, 0, 0, }, { "20.bin", 0x00020000, 0x08cf7a93, 0, 0, 0, }, { "21.bin", 0x00020000, 0x1ac892f5, 0, 0, 0, }, { "gaiden.5", 0x00010000, 0x8d4035f7, 0, 0, 0, }, { "14.bin", 0x00020000, 0x1ecfddaa, 0, 0, 0, }, { "15.bin", 0x00020000, 0x1291a696, 0, 0, 0, }, { "16.bin", 0x00020000, 0x140b47ca, 0, 0, 0, }, { "17.bin", 0x00020000, 0x7638cccb, 0, 0, 0, }, { NULL, 0, 0, 0, 0, 0, },};static struct INPUT_INFO ninja_gaiden_inputs[] ={ { KB_DEF_COIN1, MSG_COIN1, 0x01A000, 0x40, BIT_ACTIVE_0 }, { KB_DEF_COIN2, MSG_COIN2, 0x01A000, 0x80, BIT_ACTIVE_0 }, { KB_DEF_P1_START, MSG_P1_START, 0x01A000, 0x01, BIT_ACTIVE_0 }, { KB_DEF_P1_UP, MSG_P1_UP, 0x01A002, 0x08, BIT_ACTIVE_0 }, { KB_DEF_P1_DOWN, MSG_P1_DOWN, 0x01A002, 0x04, BIT_ACTIVE_0 }, { KB_DEF_P1_LEFT, MSG_P1_LEFT, 0x01A002, 0x01, BIT_ACTIVE_0 }, { KB_DEF_P1_RIGHT, MSG_P1_RIGHT, 0x01A002, 0x02, BIT_ACTIVE_0 }, { KB_DEF_P1_B1, MSG_P1_B1, 0x01A002, 0x10, BIT_ACTIVE_0 }, { KB_DEF_P1_B2, MSG_P1_B2, 0x01A002, 0x20, BIT_ACTIVE_0 }, { KB_DEF_P1_B3, MSG_P1_B3, 0x01A002, 0x40, BIT_ACTIVE_0 }, { KB_DEF_P2_START, MSG_P2_START, 0x01A000, 0x02, BIT_ACTIVE_0 }, { KB_DEF_P2_UP, MSG_P2_UP, 0x01A003, 0x08, BIT_ACTIVE_0 }, { KB_DEF_P2_DOWN, MSG_P2_DOWN, 0x01A003, 0x04, BIT_ACTIVE_0 }, { KB_DEF_P2_LEFT, MSG_P2_LEFT, 0x01A003, 0x01, BIT_ACTIVE_0 }, { KB_DEF_P2_RIGHT, MSG_P2_RIGHT, 0x01A003, 0x02, BIT_ACTIVE_0 }, { KB_DEF_P2_B1, MSG_P2_B1, 0x01A003, 0x10, BIT_ACTIVE_0 }, { KB_DEF_P2_B2, MSG_P2_B2, 0x01A003, 0x20, BIT_ACTIVE_0 }, { KB_DEF_P2_B3, MSG_P2_B3, 0x01A003, 0x40, BIT_ACTIVE_0 }, { 0, NULL, 0, 0, 0 },};static struct DSW_DATA dsw_data_ninja_gaiden_0[] ={ { MSG_DSWA_BIT1, 0x01, 0x02 }, { MSG_OFF, 0x01, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT2, 0x02, 0x02 }, { MSG_OFF, 0x02, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_TEST_MODE, 0x04, 0x02 }, { MSG_OFF, 0x04, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT4, 0x08, 0x02 }, { MSG_OFF, 0x08, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT5, 0x10, 0x02 }, { MSG_OFF, 0x10, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT6, 0x20, 0x02 }, { MSG_OFF, 0x20, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT7, 0x40, 0x02 }, { MSG_OFF, 0x40, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT8, 0x80, 0x02 }, { MSG_OFF, 0x80, 0x00 }, { MSG_ON, 0x00, 0x00 }, { NULL, 0, 0, },};static struct DSW_INFO ninja_gaiden_dsw[] ={ { 0x01A005, 0xFF, dsw_data_ninja_gaiden_0 }, { 0x01A004, 0xFF, dsw_data_default_1 }, { 0, 0, NULL, },};static struct VIDEO_INFO ninja_gaiden_video ={ DrawTecmoSys, 256, 224, 64, VIDEO_ROTATE_NORMAL | VIDEO_ROTATABLE,};static struct YM2203interface ym2203_interface ={ 2, // 2 x YM2203 4000000, // Rate - Guessed { 0x00ff20c0, 0x00ff20c0 }, // Volume Control { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { NULL, NULL }};static struct OKIM6295interface m6295_interface ={ 1, // 1 chip { 15700/2 }, // rate { 0 }, // rom list { 100 },};static struct SOUND_INFO ninja_gaiden_sound[] ={ { SOUND_YM2203, &ym2203_interface, }, { SOUND_M6295, &m6295_interface, }, { 0, NULL, },};struct GAME_MAIN game_ninja_gaiden ={ ninja_gaiden_dirs, ninja_gaiden_roms, ninja_gaiden_inputs, ninja_gaiden_dsw, NULL, LoadNGaiden, ClearNGaiden, &ninja_gaiden_video, ExecuteTecmoSysFrame, "gaiden", "Ninja Gaiden", "鱁幰棿寱揱", COMPANY_ID_TECMO, NULL, 1988, ninja_gaiden_sound, GAME_BEAT,};static struct DIR_INFO tecmo_knight_dirs[] ={ { "tecmo_knight", }, { "tknight", }, { NULL, },};static struct ROM_INFO tecmo_knight_roms[] ={ { "tkni1.bin", 0x00020000, 0x9121daa8, 0, 0, 0, }, { "tkni2.bin", 0x00020000, 0x6669cd87, 0, 0, 0, }, { "tkni3.bin", 0x00010000, 0x15623ec7, 0, 0, 0, }, { "tkni4.bin", 0x00020000, 0xa7a1dbcf, 0, 0, 0, }, { "tkni5.bin", 0x00010000, 0x5ed15896, 0, 0, 0, }, { "tkni6.bin", 0x00080000, 0xf68fafb1, 0, 0, 0, }, { "tkni7.bin", 0x00080000, 0x4b4d4286, 0, 0, 0, }, { "tkni8.bin", 0x00080000, 0x4931b184, 0, 0, 0, }, { "tkni9.bin", 0x00080000, 0xd22f4239, 0, 0, 0, }, { NULL, 0, 0, 0, 0, 0, },};static struct INPUT_INFO tecmo_knight_inputs[] ={ { KB_DEF_COIN1, MSG_COIN1, 0x01A000, 0x40, BIT_ACTIVE_0 }, { KB_DEF_COIN2, MSG_COIN2, 0x01A000, 0x80, BIT_ACTIVE_0 }, { KB_DEF_P1_START, MSG_P1_START, 0x01A000, 0x01, BIT_ACTIVE_0 }, { KB_DEF_P1_UP, MSG_P1_UP, 0x01A002, 0x08, BIT_ACTIVE_0 }, { KB_DEF_P1_DOWN, MSG_P1_DOWN, 0x01A002, 0x04, BIT_ACTIVE_0 }, { KB_DEF_P1_LEFT, MSG_P1_LEFT, 0x01A002, 0x01, BIT_ACTIVE_0 }, { KB_DEF_P1_RIGHT, MSG_P1_RIGHT, 0x01A002, 0x02, BIT_ACTIVE_0 }, { KB_DEF_P1_B1, MSG_P1_B1, 0x01A002, 0x10, BIT_ACTIVE_0 }, { KB_DEF_P1_B2, MSG_P1_B2, 0x01A002, 0x20, BIT_ACTIVE_0 }, { KB_DEF_P1_B3, MSG_P1_B3, 0x01A002, 0x40, BIT_ACTIVE_0 }, { KB_DEF_P2_START, MSG_P2_START, 0x01A000, 0x02, BIT_ACTIVE_0 }, { KB_DEF_P2_UP, MSG_P2_UP, 0x01A003, 0x08, BIT_ACTIVE_0 }, { KB_DEF_P2_DOWN, MSG_P2_DOWN, 0x01A003, 0x04, BIT_ACTIVE_0 }, { KB_DEF_P2_LEFT, MSG_P2_LEFT, 0x01A003, 0x01, BIT_ACTIVE_0 }, { KB_DEF_P2_RIGHT, MSG_P2_RIGHT, 0x01A003, 0x02, BIT_ACTIVE_0 }, { KB_DEF_P2_B1, MSG_P2_B1, 0x01A003, 0x10, BIT_ACTIVE_0 }, { KB_DEF_P2_B2, MSG_P2_B2, 0x01A003, 0x20, BIT_ACTIVE_0 }, { KB_DEF_P2_B3, MSG_P2_B3, 0x01A003, 0x40, BIT_ACTIVE_0 }, { 0, NULL, 0, 0, 0 },};static struct DSW_DATA dsw_data_tecmo_knight_0[] ={ { MSG_DSWA_BIT1, 0x01, 0x02 }, { MSG_OFF, 0x01, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT2, 0x02, 0x02 }, { MSG_OFF, 0x02, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_TEST_MODE, 0x04, 0x02 }, { MSG_OFF, 0x04, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT4, 0x08, 0x02 }, { MSG_OFF, 0x08, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT5, 0x10, 0x02 }, { MSG_OFF, 0x10, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT6, 0x20, 0x02 }, { MSG_OFF, 0x20, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT7, 0x40, 0x02 }, { MSG_OFF, 0x40, 0x00 }, { MSG_ON, 0x00, 0x00 }, { MSG_DSWA_BIT8, 0x80, 0x02 }, { MSG_OFF, 0x80, 0x00 }, { MSG_ON, 0x00, 0x00 }, { NULL, 0, 0, },};static struct DSW_INFO tecmo_knight_dsw[] ={ { 0x01A005, 0xFF, dsw_data_tecmo_knight_0 }, { 0x01A004, 0xFF, dsw_data_default_1 }, { 0, 0, NULL, },};struct GAME_MAIN game_tecmo_knight ={ tecmo_knight_dirs, tecmo_knight_roms, tecmo_knight_inputs, tecmo_knight_dsw, NULL, LoadTKnight, ClearTKnight, &ninja_gaiden_video, ExecuteTecmoSysFrame, "tknight", "Tecmo Knight", "儚僀儖僪僼傽儞僌", COMPANY_ID_TECMO, NULL, 1989, ninja_gaiden_sound, GAME_BEAT,};static int sport=0;static void CtrlWriteB(UINT32 offset,UINT8 data){ if((offset==0x7A802)||(offset==0x7A803)){ sport=data&0xFF;#ifdef RAINE_DEBUG print_debug("68000 Sends $%02x\n",sport);#endif cpu_int_nmi(CPU_Z80_0); } offset-=0x60000; offset&=0x1FFFF; RAM[offset^1]=data;}static UINT16 SoundReadZ80(UINT16 address){ #ifdef RAINE_DEBUG print_debug("Z80 Receives $%02x\n",sport); #endif return sport;}void AddTecmoSound(UINT32 p1, UINT32 p2, UINT32 romsize, UINT8 *adpcm, UINT32 adpcmsize){ // Apply Speed Patch // ----------------- Z80ROM[p1+0]=0xD3; // OUTA (AAh) Z80ROM[p1+1]=0xAA; // SetStopZ80Mode2( (UINT16) p2); // Setup Z80 memory map // -------------------- AddZ80AROMBase(Z80ROM, 0x0038, 0x0066); AddZ80AReadByte(0x0000, 0xF7FF, NULL, Z80ROM+0x0000); // Z80 ROM/RAM AddZ80AReadByte(0xF800, 0xF800, M6295_A_Read_Z80, NULL); // ADPCM //AddZ80AReadByte(0xF810, 0xF811, YM2203AReadZ80, NULL); // YM2203 A //AddZ80AReadByte(0xF820, 0xF821, YM2203BReadZ80, NULL); // YM2203 B AddZ80AReadByte(0xFC20, 0xFC20, SoundReadZ80, NULL); // 68000 COMM AddZ80AReadByte(0x0000, 0xFFFF, NULL, Z80ROM+0x0000); // <test> AddZ80AReadByte(0x0000, 0xFFFF, DefBadReadZ80, NULL); // <bad reads> AddZ80AReadByte(-1, -1, NULL, NULL); AddZ80AWriteByte(0xF000, 0xF7FF, NULL, Z80ROM+0xF000); // Z80 RAM AddZ80AWriteByte(0xF800, 0xF800, M6295_A_Write_Z80, NULL); // ADPCM CHANNEL A AddZ80AWriteByte(0xF810, 0xF811, YM2203AWriteZ80, NULL); // YM2203 A AddZ80AWriteByte(0xF820, 0xF821, YM2203BWriteZ80, NULL); // YM2203 B AddZ80AWriteByte(0x0000, 0xFFFF, NULL, Z80ROM+0x0000); // <test> AddZ80AWriteByte(0x0000, 0xFFFF, DefBadWriteZ80, NULL); // <bad writes> AddZ80AWriteByte(-1, -1, NULL, NULL); AddZ80AReadPort(0x00, 0xFF, DefBadReadZ80, NULL); AddZ80AReadPort( -1, -1, NULL, NULL); AddZ80AWritePort(0xAA, 0xAA, StopZ80Mode2, NULL); AddZ80AWritePort(0x00, 0xFF, DefBadWriteZ80, NULL); AddZ80AWritePort( -1, -1, NULL, NULL); AddZ80AInit(); ADPCMSetBuffers(((struct ADPCMinterface*)&m6295_interface),adpcm,adpcmsize); }static UINT8 *GFX_BG0;static UINT8 *GFX_BG1;static UINT8 *GFX_FG0;static UINT8 *GFX_SPR;static UINT8 *GFX_BG0_SOLID;static UINT8 *GFX_BG1_SOLID;static UINT8 *GFX_FG0_SOLID;static UINT8 *GFX_SPR_SOLID;void LoadNGaiden(void){ int ta,tb; if(!(ROM=AllocateMem(0x040000))) return; if(!(RAM=AllocateMem(0x080000))) return; if(!(GFX=AllocateMem(0x420000))) return; GFX_BG0=GFX+0x220000; GFX_BG1=GFX+0x320000; GFX_FG0=GFX+0x000000;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -