/*************************************************************************** ***************************** *** NINJA KID II hardware *** (by Roberto Ventura) ***************************** Game authors: Game design: Tsutomu Fuzisawa Program design: Satoru Kinjo Char. design: Tsutomu Fizisawa Char. design: Akemi Tsunoda Sound compose: Tsutomu Fuzisawa Bgm create: Mecano Associate Data make: Takashi Hayashi General aspect. The game is driven by a fast Z80 CPU. Screen resolution is 256x192. 768 colors on screen. 96 sprites. Rom Contents: NK2_01.ROM Main CPU program ROM NK2_02.ROM CPU banked data ROM 0 (banks 0 and 1) NK2_03.ROM CPU banked data ROM 1 (banks 2 and 3) NK2_04.ROM CPU banked data ROM 2 (banks 4 and 5) NK2_05.ROM CPU banked data ROM 3 (banks 6 and 7) NK2_06.ROM Sound CPU program ROM (encrypted) NK2_07.ROM Sprites data ROM 1 NK2_08.ROM Sprites data ROM 0 NK2_09.ROM Raw PCM samples (complete?) NK2_10.ROM Background data ROM 1 NK2_11.ROM Background data ROM 0 NK2_12.ROM Foreground data ROM *** MEMORY MAP *** 0000-7fff Main CPU ROM 8000-bfff Banked CPU ROM c000-c7ff I/O c800-cdff Color RAM d000-d7ff "FRONT" tile map d800-dfff "BACK" tile map e000-efff Main RAM f400-f7ff ??? screen frame ??? f800-f9ff CPU Stack fa00-ffff Sprite registers (misc RAM) 1) CPU 1 OSC 12 MHz 1 OSC 5 MHz 2 YM 2203C.......CaBBe!. The Z80 runs in IM0,the game expects execution of RST10 each frame. Game level maps,additional code and data are available to main program via CPU banking at lacations 8000-bf00 In two of the sets, the encrypted sound program ROM is replaced with a double-sized decrypted version. I don0t know if they are bootlegs or originals. 2) I/O c000 "KEYCOIN" button 76543210 || | || || | |^-COIN 1 || | ^--COIN 2 || ^-----TEST MODE (on the fly,to be pressed during boot) |^-------START 1 ^--------START 2 c001 "PAD1" c002 "PAD2" 76543210 |||||| |||||^-RIGHT ||||^--LEFT |||^---DOWN ||^----UP |^-----FIRE 0 ^------FIRE 1 c003 "DIPSW1" 76543210 |||||||| |||||||^-UNUSED? ||||||^-->EXTRA |||||^--->LIVES ||||^----CONTINUE MODE |||^-----DEMO SOUND ||^------NORMAL/HARD |^-------LIVES 3/4 ^--------ENGLISH/JAP c004 "DIPSW2" 76543210 |||||||| |||||||^-TEST MODE ||||||^--TABLE/UPRIGHT |||||^---"CREDIT SERVICE" ||||^----> |||^----->> ||^------>>> coin/credit configurations |^------->> ^--------> c200 Sound command This byte is written when game plays sound effects... it is set when music or sound effects (both pcm and fm) are triggered; I guess it is read by another CPU,then. c201 Unknown,but used. c202 Bank selector (0 to 7) c203 Sprite 'overdraw' this is the most interesting feature of the game,when set the sprites drawn in the previous frame remain on the screen,so the game can perform special effects such as the 'close up' when you die or the "infinite balls" appearing when an extra weapon is collected. Appears to work like a xor mask,a sprite removes older sprite 'bitmap' when present;other memory locations connected to this function may be f400-f7ff...should be investigated more. -mmmh... I believe this is sci-fiction for a non-bitmap game... C208 Scroll X 0-7 C209 Scroll X MSB C20A Scroll Y 0-7 C20B Scroll Y MSB C20C Background ENABLE when set to zero the background is totally black,but sprites are drawn correctly. 3) COLOR RAM The palette system is dynamic,the game can show up to 768 different colors on screen. Palette depth is 12 bits as usual,two consecutive bytes are used for each color code. format: RRRRGGGGBBBB0000 Colors are organized in palettes,since graphics is 4 bits (16 colors) each palette takes 32 bytes,the three different layers,BACK,SPRITES and FRONT don't share any color,each has its own 256 color space,hence the 768 colors on screen. c800-c9ff Background palettes ca00-cbff Sprites palettes cc00-cdff Foreground palettes 4) TILE-BASED LAYERS The tile format for background and foreground is the same,the only difference is that background tiles are 16x16 pixels while foreground tiles are only 8x8. Background virtual screen is 512x512 pixels scrollable. Two consecutive tiles bytes identify one tile. O7 O6 O5 O4 O3 O2 O1 O0 gfx Offset O9 O8 FY FX C3 C2 C1 C0 Attibute O= GFX offset (1024 tiles) F= Flip X and Y C= Color palette selector 5) SPRITES Five bytes identify each sprite,but the registers actually used are placed at intervals of 16. Some of the remaining bytes are used (e.g. fa00),their meaning is totally unknown to me,they seem to be related to the surprising additional sprite feature of the game,but maybe they're just random writes in RAM. The first sprite data is located at fa0b,then fa1b and so on. 0b Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 Y coord 0c X7 X6 X5 X4 X3 X2 X1 X0 X coord 0d O9 O8 FY FX -- -- EN X8 hi gfx - FLIP - Enable - hi X 0e O7 O6 O5 O4 O3 O2 O1 O0 gfx - offset 0f -- -- -- -- C3 C2 C1 C0 color Y= Y coordinate X= X coordinate (X8 is used to clip sprite on the left) O= Gfx offset (1024 sprites) F= Flip EN= Enable (this is maybe the Y8 coordinate bit,but it isn't set accordingly in the test mode C= Color palette selector ***************************************************************************/ #include "driver.h" #include "sound/2203intf.h" #include "sound/samples.h" #include "machine/mc8123.h" extern WRITE8_HANDLER( ninjakd2_bgvideoram_w ); extern WRITE8_HANDLER( ninjakd2_fgvideoram_w ); extern WRITE8_HANDLER( ninjakd2_scrollx_w ); extern WRITE8_HANDLER( ninjakd2_scrolly_w ); extern WRITE8_HANDLER( ninjakd2_sprite_overdraw_w ); extern WRITE8_HANDLER( ninjakd2_background_enable_w ); extern VIDEO_START( ninjakd2 ); extern VIDEO_UPDATE( ninjakd2 ); extern UINT8 *ninjakd2_bg_videoram, *ninjakd2_fg_videoram; static int ninjakd2_bank_latch = 255; static INT16 *sampledata[8]; static int samplelen[8]; static void ninjakd2_init_samples(void) { int i,n; UINT8 *source = memory_region(REGION_SOUND1); static const int sample_info [9][2] = { {0x0000,0x0A00},{0x0A00,0x1D00},{0x2700,0x1700}, {0x3E00,0x1500},{0x5300,0x0B00},{0x5E00,0x0A00},{0x6800,0x0E00},{0x7600,0x1E00},{0xF000,0x0400} }; for (i=0;i<8;i++) { sampledata[i] = auto_malloc(sample_info[i][1] * sizeof(sampledata[0])); samplelen[i] = sample_info[i][1]; for (n=0; n