From 8ddc85e896203363278dc9b98c3bb4b85d3e3fbb Mon Sep 17 00:00:00 2001 From: vbt1 Date: Mon, 30 Nov 2015 01:05:18 +0100 Subject: [PATCH] small fixes pacman working --- burn.c | 15 +- burnint.h | 5 + d_higemaru.c | 26 ++- d_pacman.c | 162 +++++++++++++-- d_pacman.h | 150 +++++++++++--- d_sys1_common.c | 26 ++- d_sys2.c | 510 +++++++++++++++++++++++++++++++++++++----------- d_sys2.h | 22 +++ d_zaxxon.c | 19 +- d_zaxxon.h | 2 +- root/sl.cti | 49 +++++ saturn/file.c | 2 +- saturn/saturn.c | 11 +- 13 files changed, 808 insertions(+), 191 deletions(-) diff --git a/burn.c b/burn.c index 412df76..6ca4fe6 100644 --- a/burn.c +++ b/burn.c @@ -4,7 +4,7 @@ //#include "saturn/ovl.h" //char toto[0xF00] ={'0','0'}; -#define NB_DRV 30 +#define NB_DRV 31 struct BurnDriver* pDriver[NB_DRV] __attribute__((aligned (4))); // ---------------------------------------------------------------------------- // Static functions which forward to each driver's data and functions @@ -101,6 +101,8 @@ void BurnDrvAssignList() static struct BurnDriver BurnDrvRaiders5 = {NULL, NULL,NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; static struct BurnDriver BurnDrvWbml = {NULL, NULL,NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; // static struct BurnDriver BurnDrvWbmlb = {NULL, NULL,NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +// static struct BurnDriver BurnDrvWbmlvc = {NULL, NULL,NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + static struct BurnDriver BurnDrvpuckman = {NULL, NULL,NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; BurnDrvsms_akmw.szShortName="sms"; BurnDrvsms_akmw.szFullNameA="Sega Master System"; @@ -246,6 +248,14 @@ BurnDrvWbml.szShortName="wbml"; BurnDrvWbml.szFullNameA="Wonder Boy in Monster Land (Jap New)"; BurnDrvWbml.szParent="sys2"; +//BurnDrvWbmlvc.szShortName="wbmlvc"; +//BurnDrvWbmlvc.szFullNameA="Wonder Boy in Monster Land (EN VC)"; +//BurnDrvWbmlvc.szParent="sys2"; + +BurnDrvpuckman.szShortName="puckman"; +BurnDrvpuckman.szFullNameA="Puck Man (Japan set 1)"; +BurnDrvpuckman.szParent="pacm"; + //BurnDrvWbmlb.szShortName="wbmlb"; //BurnDrvWbmlb.szFullNameA="Wonder Boy in Monster Land (ENG set 1)"; //BurnDrvWbmlb.szParent="sys2"; @@ -273,6 +283,7 @@ pDriver[i++] = &BurnDrvpkunwar; pDriver[i++] = &BurnDrvpengo2u; pDriver[i++] = &BurnDrvhigemaru; pDriver[i++] = &BurnDrvPitfall2u; +pDriver[i++] = &BurnDrvpuckman; pDriver[i++] = &BurnDrvRaflesia; pDriver[i++] = &BurnDrvRaiders5; pDriver[i++] = &BurnDrvStarjack; @@ -282,6 +293,8 @@ pDriver[i++] = &BurnDrvTeddybb; pDriver[i++] = &BurnDrvWboyu; pDriver[i++] = &BurnDrvWbdeluxe; pDriver[i++] = &BurnDrvWbml; +//pDriver[i++] = &BurnDrvWbmlb; +//pDriver[i++] = &BurnDrvWbmlvc; pDriver[i++] = &BurnDrvZaxxon; //pDriver[i++] = &BurnDrvVigilant; //pDriver[i++] = &BurnDrvGnga; diff --git a/burnint.h b/burnint.h index e47eead..38ae948 100644 --- a/burnint.h +++ b/burnint.h @@ -40,6 +40,11 @@ extern unsigned int nBurnDrvCount; // Count of game drivers extern unsigned int nBurnDrvSelect; // Which game driver is selected //extern unsigned int nBurnMallocAddr; // address before loading first game +// --------------------------------------------------------------------------- +// Tile decoding macros + +#define RGN_FRAC(length, numerator, denominator) ((((length) * 8) * (numerator)) / (denominator)) + // --------------------------------------------------------------------------- // Sound clipping macro #define BURN_SND_CLIP(A) ((A) < -0x8000 ? -0x8000 : (A) > 0x7fff ? 0x7fff : (A)) diff --git a/d_higemaru.c b/d_higemaru.c index 660e4f9..096c2e3 100644 --- a/d_higemaru.c +++ b/d_higemaru.c @@ -1,7 +1,7 @@ // FB Alpha Pirate Ship Higemaru Module // Based on MAME driver by Mirko Buffoni -//#define CZ80 1 -#define RAZE 1 +#define CZ80 1 +//#define RAZE 1 #include "d_higemaru.h" @@ -36,6 +36,18 @@ static void __fastcall higemaru_write(unsigned short address, unsigned char data AY8910Write(1, (address - 1) & 1, data); break; } +//#ifndef RAZE +#if 0 + if(address>= 0xd000 && address <=0xd9ff) + { + Rom[address] = data; +/* if(Rom[address]!=data) + { + bg_dirtybuffer[address&0x3ff] = 1; + Rom[address] = data; + }*/ + } +#endif } #ifdef RAZE @@ -469,12 +481,16 @@ static void DrvDrawBackground() // back ground for (int offs = 0x40; offs < 0x3c0; offs++) { +#ifdef RAZE if(bg_dirtybuffer[offs]) +#endif { +#ifdef RAZE bg_dirtybuffer[offs]=0; - int code = Rom[0xd000 + offs] | ((Rom[0xd400 + offs] & 0x80) << 1); - int color = Rom[0xd400 + offs] & 0x1f; - int x = map_offset_lut[offs]; +#endif + unsigned int code = Rom[0xd000 + offs] | ((Rom[0xd400 + offs] & 0x80) << 1); + unsigned int color = Rom[0xd400 + offs] & 0x1f; + unsigned int x = map_offset_lut[offs]; ss_map[x] = color; ss_map[x+1] = code; } diff --git a/d_pacman.c b/d_pacman.c index 7ab865e..803b2b8 100644 --- a/d_pacman.c +++ b/d_pacman.c @@ -18,7 +18,17 @@ int ovlInit(char *szShortName) pengouInit, DrvExit, DrvFrame, DrvDraw //, NULL, &DrvRecalc, 0x200, }; -// if (strcmp(nBurnDrvpengo2u.szShortName, szShortName) == 0) + struct BurnDriver nBurnDrvpuckman = { + "puckman", "pacm", + "Puck Man (Japan set 1)\0", + puckmanRomInfo, puckmanRomName, DrvInputInfo, DrvDIPInfo, + puckmanInit, DrvExit, DrvFrame, DrvDrawPacMan + }; + + + if (strcmp(nBurnDrvpuckman.szShortName, szShortName) == 0) + memcpy(shared,&nBurnDrvpuckman,sizeof(struct BurnDriver)); + if (strcmp(nBurnDrvpengo2u.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvpengo2u,sizeof(struct BurnDriver)); ss_reg = (SclNorscl *)SS_REG; @@ -55,6 +65,48 @@ void __fastcall pacman_out_port(UINT16 a, UINT8 d) } } +UINT8 __fastcall pacman_in_port(UINT16 a) +{ + return 0; +} + +void __fastcall pacman_write(UINT16 a, UINT8 d) +{ + if ((a & 0xffe0) == 0x5040) { + NamcoSoundWrite(a & 0x1f, d); + return; + } + + if ((a & 0xfff0) == 0x5060) { + DrvSprRAM2[a & 0x0f] = d; + return; + } + + switch (a) + { + case 0x5000: + interrupt_mask = d & 1; + break; + + case 0x5001: + // pacman_sound_enable_w + break; + + case 0x5003: +// *flipscreen = d & 1; + break; + + case 0x5002:// nop + case 0x5007:// coin counter + break; + + case 0x50c0: + watchdog = 0; + break; + } +} + + void __fastcall pengo_write(UINT16 a, UINT8 d) { #ifdef CACHE @@ -413,6 +465,33 @@ static void PengoMap() CZetSetReadHandler(pengo_read); } +static void StandardMap() +{ + for (INT32 i = 0; i <= 0x8000; i += 0x8000)// mirror + { + CZetMapArea(0x0000 + i, 0x3fff + i, 0, DrvZ80ROM); + CZetMapArea(0x0000 + i, 0x3fff + i, 2, DrvZ80ROM); + + for (INT32 j = 0; j <= 0x2000; j+= 0x2000) // mirrors + { + CZetMapArea(0x4000 + i + j, 0x43ff + i + j, 0, DrvVidRAM); + CZetMapArea(0x4000 + i + j, 0x43ff + i + j, 1, DrvVidRAM); + CZetMapArea(0x4000 + i + j, 0x43ff + i + j, 2, DrvVidRAM); + CZetMapArea(0x4400 + i + j, 0x47ff + i + j, 0, DrvColRAM); + CZetMapArea(0x4400 + i + j, 0x47ff + i + j, 1, DrvColRAM); + CZetMapArea(0x4400 + i + j, 0x47ff + i + j, 2, DrvColRAM); + CZetMapArea(0x4c00 + i + j, 0x4fff + i + j, 0, DrvZ80RAM + 0x0400); + CZetMapArea(0x4c00 + i + j, 0x4fff + i + j, 1, DrvZ80RAM + 0x0400); + CZetMapArea(0x4c00 + i + j, 0x4fff + i + j, 2, DrvZ80RAM + 0x0400); + } + } + + CZetSetWriteHandler(pacman_write); + CZetSetReadHandler(pacman_read); + CZetSetOutHandler(pacman_out_port); + CZetSetInHandler(pacman_in_port); +} + static INT32 DrvInit(void (*mapCallback)(), void (*pInitCallback)(), INT32 select) { DrvInitSaturn(); @@ -421,7 +500,10 @@ static INT32 DrvInit(void (*mapCallback)(), void (*pInitCallback)(), INT32 selec AllMem = NULL; MemIndex(); INT32 nLen = MemEnd - (UINT8 *)0; - if ((AllMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((AllMem = (UINT8 *)malloc(nLen)) == NULL) + { + return 1; + } memset(AllMem, 0, nLen); MemIndex(); @@ -429,7 +511,10 @@ static INT32 DrvInit(void (*mapCallback)(), void (*pInitCallback)(), INT32 selec make_lut(); memset(bg_dirtybuffer,1,0x400); - if (pacman_load()) return 1; + if (pacman_load()) + { + return 1; + } if (pInitCallback) { pInitCallback(); @@ -581,6 +666,8 @@ static INT32 DrvExit() { NamcoSoundExit(); CZetExit(); + PCM_Task(pcm); + nSoundBufferPos=0; game_select = PACMAN; nPacBank = -1; @@ -592,6 +679,17 @@ static INT32 DrvExit() map_offset_lut = ofst_lut = NULL; free (AllMem); AllMem = NULL; + + game_select = 0; + interrupt_mode = 0; + interrupt_mask = 0; + colortablebank = 0; + palettebank = 0; + spritebank = 0; + charbank = 0; + nPacBank = 0; + watchdog = 0; + DrvReset = 0; return 0; } @@ -617,6 +715,22 @@ static void DrawBackground() } } +static void DrawPacManBackground() +{ + for (UINT16 offs = 0; offs < 36 * 28; offs++) + { + INT16 ofst = ofst_lut[offs]; + + INT32 code = (charbank << 8) | DrvVidRAM[ofst]; + INT32 color = (DrvColRAM[ofst] & 0x1f) | (colortablebank << 5) | (palettebank << 6); + int x = map_offset_lut[offs]; + + ss_map2[x]=color; + ss_map2[x+1]=code; + } +} + + static void DrawSprites() { for (INT32 offs = 0x10 - 2;offs >= 0;offs -= 2) @@ -650,6 +764,14 @@ static INT32 DrvDraw() return 0; } +static INT32 DrvDrawPacMan() +{ + DrawPacManBackground(); + DrawSprites(); + + return 0; +} + static INT32 DrvFrame() { watchdog++; @@ -688,26 +810,31 @@ static INT32 DrvFrame() CZetOpen(0); - INT32 nInterleave = nBurnSoundLen; + INT32 nInterleave = 264; INT32 nSoundBufferPos1 = 0; INT32 nCyclesTotal = (18432000 / 6) / 60; - INT32 nCyclesDone = 0; - INT32 nCyclesSegment; for (INT32 i = 0; i < nInterleave; i++) { - INT32 nNext; - - nNext = (i + 1) * nCyclesTotal / nInterleave; - nCyclesSegment = nNext - nCyclesDone; - nCyclesDone += CZetRun(nCyclesSegment); + CZetRun(nCyclesTotal / nInterleave); - if (i == (nInterleave - 1) && interrupt_mask) { + if (i == 223 && interrupt_mask) + { // CZetSetVector(interrupt_mode); - CZetRaiseIrq(interrupt_mode); + /* if (DrvIrqVector == 0xff) { + // ZetSetVector(DrvIrqVector); + CZetSetIRQLine(0, CZET_IRQSTATUS_NONE); + } else { + // CZetSetVector(DrvIrqVector); + CZetSetIRQLine(0, CZET_IRQSTATUS_ACK); + }; */ +// CZetRaiseIrq(interrupt_mode); // ZetSetIRQLine(0, ZET_IRQSTATUS_AUTO); - CZetSetIRQLine(0, CZET_IRQSTATUS_AUTO); +// CZetSetIRQLine(0, CZET_IRQSTATUS_AUTO); + CZetRaiseIrq(interrupt_mode); + CZetRun(100); + CZetLowerIrq(); } // if (pBurnSoundOut) @@ -763,7 +890,7 @@ static INT32 DrvFrame() DrvDraw(); } */ - DrvDraw(); + DrvDrawPacMan(); if(nSoundBufferPos>=RING_BUF_SIZE/2)//0x4800-nSegmentLength)// { PCM_Task(pcm); @@ -794,6 +921,11 @@ static INT32 pengouInit() { return DrvInit(PengoMap, PengouCallback, PENGO); } + +static INT32 puckmanInit() +{ + return DrvInit(StandardMap, NULL, PACMAN); +} /*static void MspacmanDecode() { #define ADD0SWAP(x) BITSWAP16(x,15,14,13,12,11,3,7,9,10,8,6,5,4,2,1,0) diff --git a/d_pacman.h b/d_pacman.h index 1973795..0ce4f46 100644 --- a/d_pacman.h +++ b/d_pacman.h @@ -14,46 +14,47 @@ int ovlInit(char *szShortName) __attribute__ ((boot,section(".boot"))); /*static*/ INT32 mspacmanInit(); -/*static*/ INT32 puckmanInit(); +static INT32 puckmanInit(); /*static*/// INT32 pengoInit(); static INT32 pengouInit(); /*static*/ //INT32 pengobInit(); static INT32 DrvExit(); static INT32 DrvFrame(); static INT32 DrvDraw(); +static INT32 DrvDrawPacMan(); static void make_lut(void); -/*static*/ UINT8 *AllMem = NULL; -/*static*/ UINT8 *MemEnd = NULL; -/*static*/ UINT8 *AllRam = NULL; -/*static*/ UINT8 *RamEnd = NULL; -/*static*/ UINT8 *PengoStart = NULL; -/*static*/ UINT8 *DrvZ80ROM = NULL; -/*static*/ UINT8 *DrvQROM = NULL; -/*static*/ UINT8 *DrvGfxROM = NULL; -/*static*/ UINT8 *DrvZ80RAM = NULL; -/*static*/ UINT8 *DrvVidRAM = NULL; -/*static*/ UINT8 *DrvColRAM = NULL; -/*static*/ UINT8 *DrvSprRAM = NULL; -/*static*/ UINT8 *DrvSprRAM2 = NULL; -/*static*/ UINT8 *DrvColPROM = NULL; -/*static*/ UINT8 *bg_dirtybuffer = NULL; -/*static*/ UINT16 *map_offset_lut = NULL; -/*static*/ UINT16 *ofst_lut = NULL; +static UINT8 *AllMem = NULL; +static UINT8 *MemEnd = NULL; +static UINT8 *AllRam = NULL; +static UINT8 *RamEnd = NULL; +static UINT8 *PengoStart = NULL; +static UINT8 *DrvZ80ROM = NULL; +static UINT8 *DrvQROM = NULL; +static UINT8 *DrvGfxROM = NULL; +static UINT8 *DrvZ80RAM = NULL; +static UINT8 *DrvVidRAM = NULL; +static UINT8 *DrvColRAM = NULL; +static UINT8 *DrvSprRAM = NULL; +static UINT8 *DrvSprRAM2 = NULL; +static UINT8 *DrvColPROM = NULL; +static UINT8 *bg_dirtybuffer = NULL; +static UINT16 *map_offset_lut = NULL; +static UINT16 *ofst_lut = NULL; /*static*/ //INT16 pBurnSoundOut[0x8000]; ///*static*/ INT16 *pAY8910Buffer[3]; /*static*/ //UINT32 *Palette = NULL;; /*static*/ //UINT8 DrvRecalc = 0; -/*static*/ UINT8 DrvReset = 0; -/*static*/ UINT8 DrvJoy1[8] = {0,0,0,0,0,0,0,0}; -/*static*/ UINT8 DrvJoy2[8] = {0,0,0,0,0,0,0,0}; -/*static*/ UINT8 DrvInputs[2] = {0,0}; -/*static*/ UINT8 DrvDips[4] = {0,0,0,0}; -/*static*/ INT16 DrvAxis[2] = { 0, 0 }; -/*static*/ INT16 nAnalogAxis[2] = {0,0}; -/*static*/ UINT8 nCharAxis[2] = {0,0}; +static UINT8 DrvReset = 0; +static UINT8 DrvJoy1[8] = {0,0,0,0,0,0,0,0}; +static UINT8 DrvJoy2[8] = {0,0,0,0,0,0,0,0}; +static UINT8 DrvInputs[2] = {0,0}; +static UINT8 DrvDips[4] = {0,0,0,0}; +static INT16 DrvAxis[2] = { 0, 0 }; +static INT16 nAnalogAxis[2] = {0,0}; +static UINT8 nCharAxis[2] = {0,0}; enum { PACMAN=0, PENGO }; @@ -72,6 +73,33 @@ enum { PACMAN=0, PENGO }; /*static*/ INT32 nPacBank = 0; /*static*/ UINT32 watchdog = 0; //------------------------------------------------------------------------------------------------------ +/*static*/ struct BurnInputInfo DrvInputList[] = { + {"Coin 1", BIT_DIGITAL, DrvJoy1 + 5, "p1 coin"}, + {"Coin 2", BIT_DIGITAL, DrvJoy1 + 6, "p2 coin"}, + {"Start 1", BIT_DIGITAL, DrvJoy2 + 5, "p1 start"}, + {"Start 2", BIT_DIGITAL, DrvJoy2 + 6, "p2 start"}, + + {"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up"}, + {"P1 Left", BIT_DIGITAL, DrvJoy1 + 1, "p1 left"}, + {"P1 Right", BIT_DIGITAL, DrvJoy1 + 2, "p1 right"}, + {"P1 Down", BIT_DIGITAL, DrvJoy1 + 3, "p1 down"}, + + {"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up"}, + {"P2 Left", BIT_DIGITAL, DrvJoy2 + 1, "p2 left"}, + {"P2 Right", BIT_DIGITAL, DrvJoy2 + 2, "p2 right"}, + {"P2 Down", BIT_DIGITAL, DrvJoy2 + 3, "p2 down"}, + + {"Reset", BIT_DIGITAL, &DrvReset, "reset"}, + {"Service Mode", BIT_DIGITAL, DrvJoy1 + 7, "diag"}, + + {"Dip Switches 1 ", BIT_DIPSWITCH, DrvDips + 2, "dip"}, + {"Dip Switches 2", BIT_DIPSWITCH, DrvDips + 0, "dip"}, + {"Dip Switches 3", BIT_DIPSWITCH, DrvDips + 1, "dip"}, + {"Dip Switches 4", BIT_DIPSWITCH, DrvDips + 3, "dip"}, +}; + +STDINPUTINFO(Drv) + /*static*/ struct BurnInputInfo PengoInputList[] = { {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 4, "p1 coin"}, {"P1 Start", BIT_DIGITAL, DrvJoy2 + 5, "p1 start"}, @@ -175,6 +203,49 @@ STDINPUTINFO(Pengo) STDDIPINFO(Pengo) +static struct BurnDIPInfo DrvDIPList[]= +{ + {0x0e, 0xff, 0xff, 0xc9, NULL }, + {0x0f, 0xff, 0xff, 0xff, NULL }, + {0x10, 0xff, 0xff, 0xff, NULL }, + + {0 , 0xfe, 0 , 4 , "Coinage" }, + {0x0e, 0x01, 0x03, 0x03, "2C 1C" }, + {0x0e, 0x01, 0x03, 0x01, "1C 1C" }, + {0x0e, 0x01, 0x03, 0x02, "1C 2C" }, + {0x0e, 0x01, 0x03, 0x00, "Free Play" }, + + {0 , 0xfe, 0 , 4 , "Lives" }, + {0x0e, 0x01, 0x0c, 0x00, "1" }, + {0x0e, 0x01, 0x0c, 0x04, "2" }, + {0x0e, 0x01, 0x0c, 0x08, "3" }, + {0x0e, 0x01, 0x0c, 0x0c, "5" }, + + {0 , 0xfe, 0 , 4 , "Bonus Life" }, + {0x0e, 0x01, 0x30, 0x00, "10000" }, + {0x0e, 0x01, 0x30, 0x10, "15000" }, + {0x0e, 0x01, 0x30, 0x20, "20000" }, + {0x0e, 0x01, 0x30, 0x30, "None" }, + + {0 , 0xfe, 0 , 2 , "Difficulty" }, + {0x0e, 0x01, 0x40, 0x40, "Normal" }, + {0x0e, 0x01, 0x40, 0x00, "Hard" }, + + {0 , 0xfe, 0 , 2 , "Ghost Names" }, + {0x0e, 0x01, 0x80, 0x80, "Normal" }, + {0x0e, 0x01, 0x80, 0x00, "Alternate" }, + + {0 , 0xfe, 0 , 2 , "Rack Test (Cheat)" }, + {0x0f, 0x01, 0x10, 0x10, "Off" }, + {0x0f, 0x01, 0x10, 0x00, "On" }, + + {0 , 0xfe, 0 , 2 , "Cabinet" }, + {0x10, 0x01, 0x80, 0x80, "Upright" }, + {0x10, 0x01, 0x80, 0x00, "Cocktail" }, +}; + +STDDIPINFO(Drv) + // Pengo (set 2 not encrypted) /*static*/ struct BurnRomInfo pengo2uRomDesc[] = { @@ -200,4 +271,31 @@ STDDIPINFO(Pengo) STD_ROM_PICK(pengo2u) STD_ROM_FN(pengo2u) + +// Puck Man (Japan set 1) + +static struct BurnRomInfo puckmanRomDesc[] = { + { "pm1prg1.6e", 0x0800, 0xf36e88ab, 1 | BRF_ESS | BRF_PRG }, // 0 Z80 Code + { "pm1prg2.6k", 0x0800, 0x618bd9b3, 1 | BRF_ESS | BRF_PRG }, // 1 + { "pm1prg3.6f", 0x0800, 0x7d177853, 1 | BRF_ESS | BRF_PRG }, // 2 + { "pm1prg4.6m", 0x0800, 0xd3e8914c, 1 | BRF_ESS | BRF_PRG }, // 3 + { "pm1prg5.6h", 0x0800, 0x6bf4f625, 1 | BRF_ESS | BRF_PRG }, // 4 + { "pm1prg6.6n", 0x0800, 0xa948ce83, 1 | BRF_ESS | BRF_PRG }, // 5 + { "pm1prg7.6j", 0x0800, 0xb6289b26, 1 | BRF_ESS | BRF_PRG }, // 6 + { "pm1prg8.6p", 0x0800, 0x17a88c13, 1 | BRF_ESS | BRF_PRG }, // 7 + + { "pm1chg1.5e", 0x0800, 0x2066a0b7, 2 | BRF_GRA }, // 8 Graphics + { "pm1chg2.5h", 0x0800, 0x3591b89d, 2 | BRF_GRA }, // 9 + { "pm1chg3.5f", 0x0800, 0x9e39323a, 2 | BRF_GRA }, // 10 + { "pm1chg4.5j", 0x0800, 0x1b1d9096, 2 | BRF_GRA }, // 11 + + { "pm11.7f", 0x0020, 0x2fc650bd, 3 | BRF_GRA }, // 12 Color Proms + { "pm14.4a", 0x0100, 0x3eb3a8e4, 3 | BRF_GRA }, // 13 + + { "pm13.1m", 0x0100, 0xa9cc86bf, 4 | BRF_SND }, // 14 Sound Prom + { "pm12.3m", 0x0100, 0x77245b66, 0 | BRF_SND | BRF_OPT }, // 15 Timing Prom (not used) +}; + +STD_ROM_PICK(puckman) +STD_ROM_FN(puckman) #endif \ No newline at end of file diff --git a/d_sys1_common.c b/d_sys1_common.c index 25cbd90..bd4a1c1 100644 --- a/d_sys1_common.c +++ b/d_sys1_common.c @@ -307,7 +307,7 @@ Memory Handlers void System1BankRom() { - int BankAddress = (System1RomBank << 14) + 0x10000; + INT32 BankAddress = (System1RomBank * 0x4000) + 0x10000; CZetMapArea(0x8000, 0xbfff, 0, System1Rom1 + BankAddress); // CZetMapArea2(0x8000, 0xbfff, 2, System1Fetch1 + BankAddress, System1Rom1 + BankAddress); CZetMapArea2(0x8000, 0xbfff, 2, System1Rom1 + BankAddress + 0x20000, System1Rom1 + BankAddress); @@ -718,8 +718,11 @@ void dummy() int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2Size, int nTileRomNum, int nTileRomSize, int nSpriteRomNum, int nSpriteRomSize, bool bReset) { int nRet = 0, nLen, i, RomOffset; - System1NumTiles = (nTileRomNum * nTileRomSize) / 24; + struct BurnRomInfo ri; + + System1NumTiles = (((nTileRomNum * nTileRomSize) / 3) * 8) / (8 * 8); System1SpriteRomSize = nSpriteRomNum * nSpriteRomSize; + DrvInitSaturn(); CollisionFunction = updateCollisions; @@ -744,6 +747,7 @@ int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2 RomOffset = 0; for (i = 0; i < nZ80Rom1Num; i++) { nRet = BurnLoadRom(System1Rom1 + (i * nZ80Rom1Size), i + RomOffset, 1); if (nRet != 0) return 1; + BurnDrvGetRomInfo(&ri, i); } if (System1BankedRom) { @@ -762,6 +766,11 @@ int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2 memcpy (System1Rom1 + 0x10000, System1TempRom + 0x18000, 0x8000); memcpy (System1Rom1 + 0x38000, System1TempRom + 0x20000, 0x8000);//fetch memcpy (System1Rom1 + 0x18000, System1TempRom + 0x28000, 0x8000); + + if (nZ80Rom1Size == (ri.nLen * 2)) + { // last rom half the size, reload it into the last slot + memcpy (System1Rom1 + 0x18000, System1TempRom + 0x20000, 0x8000); + } } } if (DecodeFunction) DecodeFunction(); @@ -779,7 +788,8 @@ int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2 nRet = BurnLoadRom(System1TempRom + (i * nTileRomSize), i + RomOffset, 1); } - int TilePlaneOffsets[3] = { 0, 0x20000, 0x40000 }; + int TilePlaneOffsets[3] = { RGN_FRAC((nTileRomSize * nTileRomNum), 0, 3), RGN_FRAC((nTileRomSize * nTileRomNum), 1, 3), RGN_FRAC((nTileRomSize * nTileRomNum), 2, 3) }; + int TileXOffsets[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; int TileYOffsets[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; @@ -799,7 +809,7 @@ int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2 else if(flipscreen==2) rotate_tile(System1NumTiles,1,System1Tiles); spriteCache = (UINT16*)(0x00200000); -// memset4_fast((void*)spriteCache,0xFFFFFFFF,0x80000); + memset((unsigned char *)spriteCache,0xFF,0x80000); if(System1SpriteRomSize!=0x20000) System1Sprites = (UINT8 *)malloc(System1SpriteRomSize); @@ -813,6 +823,7 @@ int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2 { nRet = BurnLoadRom(System1Sprites + (i * nSpriteRomSize), i + RomOffset, 1); } + // Load Colour proms if (System1ColourProms) { RomOffset += nSpriteRomNum; @@ -836,7 +847,9 @@ int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2 { CZetMapArea2(0x0000, 0x7fff, 2, System1Fetch1, System1Rom1); CZetMapArea2(0x8000, 0xbfff, 2, System1Fetch1 + 0x10000, System1Rom1 + 0x10000); - } else { + } + else + { CZetMapArea(0x0000, 0x7fff, 2, System1Rom1); CZetMapArea(0x8000, 0xbfff, 2, System1Rom1 + 0x8000); } @@ -903,10 +916,9 @@ int System1Init(int nZ80Rom1Num, int nZ80Rom1Size, int nZ80Rom2Num, int nZ80Rom2 nCyclesTotal[0] = 2000000 / hz ;//3500000 nCyclesTotal[1] = 2000000 / hz ;//3500000 + SN76489AInit(0, 2000000, 0); //2000000 -// PSG_Init(0, 2000000, nBurnSoundRate); SN76489AInit(1, 4000000, 1);//4000000 -// PSG_Init(1, 4000000, nBurnSoundRate); make_lut(); make_cram_lut(); diff --git a/d_sys2.c b/d_sys2.c index fbd8b79..181a814 100644 --- a/d_sys2.c +++ b/d_sys2.c @@ -38,17 +38,25 @@ int ovlInit(char *szShortName) WbmljbInit, System1Exit, System1Frame, NULL }; + struct BurnDriver nBurnDrvWbmlvc = { + "wbmlvc", "sys2", + "Wonder Boy in Monster Land (EN VC)", + wbmlvcRomInfo, wbmlvcRomName, MyheroInputInfo, WbmlDIPInfo, + WbmljbInit, System1Exit, System1Frame, NULL + }; + if (strcmp(nBurnDrvChplftb.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvChplftb,sizeof(struct BurnDriver)); if (strcmp(nBurnDrvWbml.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvWbml,sizeof(struct BurnDriver)); if (strcmp(nBurnDrvWbmlb.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvWbmlb,sizeof(struct BurnDriver)); + if (strcmp(nBurnDrvWbmlvc.szShortName, szShortName) == 0)memcpy(shared,&nBurnDrvWbmlvc,sizeof(struct BurnDriver)); ss_reg = (SclNorscl *)SS_REG; ss_regs = (SclSysreg *)SS_REGS; } -/*static*/ UINT8 __fastcall WbmlZ801PortRead(unsigned short a) +/*static*/ UINT8 __fastcall System2Z801PortRead(unsigned short a) { - a &= 0xff; + a &= 0x1f; switch (a) { case 0x00: return 0xff - System1Input[0]; @@ -61,23 +69,19 @@ int ovlInit(char *szShortName) case 0x15: case 0x16: case 0x17: return ppi8255_r(0, a & 3); - case 0x19: return System1BankSwitch; + //case 0x19: return System1BankSwitch; } return 0; } inline void wbml_videoram_bank_latch_w (UINT8 d) { -// if(System1BgBankLatch != d) + if(System1BgBankLatch != d) { System1BgBankLatch = d; - System1BgBank = (d >> 1) & 0x03; /* Select 4 banks of 4k, bit 2,1 */ + System1BgBank = (d >> 1) & 0x03; // Select 4 banks of 4k, bit 2,1 UINT8 *CurrentBank = (UINT8 *)(System1VideoRam + System1BgBank * 0x1000); RamStart1 = CurrentBank - 0xe000; - // iq_132 - CZetMapArea(0xe000, 0xefff, 0, CurrentBank); - CZetMapArea(0xe800, 0xefff, 1, CurrentBank+0x800); - CZetMapArea(0xe000, 0xefff, 2, CurrentBank); } } @@ -97,27 +101,7 @@ void system2_foregroundram_w(unsigned short a, UINT8 d) } } -void system2_backgroundram_w(unsigned short a, UINT8 d, unsigned char start) -{ -// UINT8 *source = System1VideoRam + (System1VideoRam[0x0740 + page*2] & 0x07)*0x800; -// if(RamStart[a]!=d) - { - RamStart[a] = d; - a&=~1; - int Code;//, Colour; - Code = (RamStart[a + 1] << 8) | RamStart[a + 0]; - Code = ((Code >> 4) & 0x800) | (Code & 0x7ff); - - unsigned int x = map_offset_lut[a&0x7ff]; - UINT16 *map = &ss_map[x]; - map[start] = ((Code >> 5) & 0x3f)|(((RamStart[a + 1] & 0x08)==8)?0x2000:0x0000);//color_lut[Code]; - map[start+1] = Code & (System1NumTiles-1); - } -} - - - -void __fastcall WbmlZ801PortWrite(unsigned short a, UINT8 d) +static void __fastcall System2Z801PortWrite(UINT16 a, UINT8 d) { a &= 0x1f; switch (a) @@ -131,7 +115,27 @@ void __fastcall WbmlZ801PortWrite(unsigned short a, UINT8 d) } } -void __fastcall WbmlZ801ProgWrite(UINT16 a, UINT8 d) +static void __fastcall System2Z801ProgWrite(UINT16 a, UINT8 d) +{ + if (a >= 0xf000 && a <= 0xf3ff) { System1BgCollisionRam[a - 0xf000] = 0x7e; return; } + if (a >= 0xf800 && a <= 0xfbff) { System1SprCollisionRam[a - 0xf800] = 0x7e; return; } + if (a >= 0xe000 && a <= 0xefff) + { + if(!System1BgBank && a <= 0xe7ff) + { + system2_foregroundram_w(a, d); + return; + } + System1VideoRam[(0x1000*System1BgBank) + (a & 0xfff)] = d; + return; + } + if (a >= 0xd800 && a <= 0xd9ff) { system1_paletteram_w(a,d); return; } + if (a >= 0xda00 && a <= 0xdbff) { system1_paletteram2_w(a,d); return; } + if (a >= 0xdc00 && a <= 0xddff) { system1_paletteram3_w(a,d); return; } +} + +/* +void __fastcall System2Z801ProgWrite(UINT16 a, UINT8 d) { if (a >= 0xf000 && a <= 0xf3ff) { System1BgCollisionRam[a - 0xf000] = 0x7e; return; } if (a >= 0xf800 && a <= 0xfbff) { System1SprCollisionRam[a - 0xf800] = 0x7e; return; } @@ -157,8 +161,9 @@ void __fastcall WbmlZ801ProgWrite(UINT16 a, UINT8 d) if (a >= 0xda00 && a <= 0xdbff) { system1_paletteram2_w(a,d); return; } if (a >= 0xdc00 && a <= 0xddff) { system1_paletteram3_w(a,d); return; } } +*/ -UINT8 __fastcall WbmlZ801ProgRead(unsigned short a) +static UINT8 __fastcall System2Z801ProgRead(UINT16 a) { if (a >= 0xe000 && a <= 0xefff) { @@ -167,32 +172,44 @@ UINT8 __fastcall WbmlZ801ProgRead(unsigned short a) return 0; } -static void WbmlPPI0WriteA(UINT8 data) +static void System2PPI0WriteA(UINT8 data) { system1_soundport_w(data); } -static void WbmlPPI0WriteB(UINT8 data) +static void System2PPI0WriteB(UINT8 data) { chplft_bankswitch_w(data); } -static void WbmlPPI0WriteC(UINT8 data) +static void System2PPI0WriteC(UINT8 data) { // refaire avec raze - CZetClose(); +/* CZetClose(); CZetOpen(1); CZetSetIRQLine(0x20, (data & 0x80) ? CZET_IRQSTATUS_NONE : CZET_IRQSTATUS_ACK); CZetClose(); +xxxxx CZetOpen(0); +*/ + if(data & 0x80) + { + z80_raise_IRQ(0x20); +// z80_emulate(0); + } + else + { + z80_lower_IRQ(); +// z80_emulate(0); + } wbml_videoram_bank_latch_w(data); } /*static*/ inline void chplft_bankswitch_w (UINT8 d) { - System1RomBank = (((d & 0x0c)>>2) ); - System1BankRomNoDecode(); + System1RomBank = (d & 0x0c) >> 2; + System1BankRom(); System1BankSwitch = d; } @@ -268,7 +285,7 @@ static void wbml_decode() CZetMapArea(0xe7c0, 0xe7ff, 2, System1ScrollXRam); - CZetMapArea(0xe000, 0xe7ff, 0, System1VideoRam); //read +// CZetMapArea(0xe000, 0xe7ff, 0, System1VideoRam); //read // CZetMapArea(0xe000, 0xe7ff, 1, System1VideoRam); //write CZetMapArea(0xe000, 0xe7ff, 2, System1VideoRam); //fetch CZetMapArea(0xe800, 0xeeff, 0, System1BgRam); @@ -277,13 +294,13 @@ static void wbml_decode() CZetSetWriteHandler(ChplftZ801ProgWrite); - CZetSetInHandler (WbmlZ801PortRead); - CZetSetOutHandler(WbmlZ801PortWrite); + CZetSetInHandler (System2Z801PortRead); + CZetSetOutHandler(System2Z801PortWrite); CZetClose(); ppi8255_init(1); - PPI0PortWriteA = WbmlPPI0WriteA; - PPI0PortWriteB = WbmlPPI0WriteB; + PPI0PortWriteA = System2PPI0WriteA; + PPI0PortWriteB = System2PPI0WriteB; PPI0PortWriteC = NULL; #endif @@ -303,56 +320,326 @@ void CommonWbmlInit() // nBurnFunction = System1CalcPalette; // nBurnFunction = System1CalcSprPalette;//System1CalcPalette; ss_reg->n1_move_x = 4<<16; - RamStart = System1VideoRam-0xe000; // bg RamStart1 = System1VideoRam-0xe000; // fg drawWindow(0,224,0,0,65); CZetOpen(0); + + CZetMemCallback(0xd000, 0xd1ff, 0); + CZetMemCallback(0xd000, 0xd1ff, 1); + CZetMemCallback(0xd000, 0xd1ff, 2); + CZetMemCallback(0xd200, 0xd7ff, 0); + CZetMemCallback(0xd200, 0xd7ff, 1); + CZetMemCallback(0xd200, 0xd7ff, 2); + CZetMemCallback(0xe000, 0xefff, 0); + CZetMemCallback(0xe000, 0xefff, 1); + CZetMemCallback(0xe000, 0xefff, 2); + CZetMemCallback(0xf000, 0xf3ff, 0); + CZetMemCallback(0xf000, 0xf3ff, 1); + CZetMemCallback(0xf000, 0xf3ff, 2); + CZetMemCallback(0xf800, 0xfbff, 0); + CZetMemCallback(0xf800, 0xfbff, 1); + CZetMemCallback(0xf800, 0xfbff, 2); + + CZetMapArea(0x0000, 0x7fff, 0, System1Rom1); + CZetMapArea(0x8000, 0xbfff, 0, System1Rom1 + 0x8000); + CZetMapArea2(0x0000, 0x7fff, 2, System1Rom1 + 0x20000, System1Rom1); CZetMapArea2(0x8000, 0xbfff, 2, System1Rom1 + 0x30000, System1Rom1 + 0x10000); // 30 fetch et 10 pour code ? - CZetMapArea(0xd800, 0xddff, 0, System1PaletteRam); - CZetMemCallback(0xd800, 0xddff, 1); + CZetMapArea(0xc000, 0xcfff, 0, System1Ram1); + CZetMapArea(0xc000, 0xcfff, 1, System1Ram1); + CZetMapArea(0xc000, 0xcfff, 2, System1Ram1); - CZetMapArea(0xd000, 0xd1ff, 1, System1SpriteRam); + CZetMapArea(0xd000, 0xd7ff, 0, System1SpriteRam); + CZetMapArea(0xd000, 0xd7ff, 1, System1SpriteRam); + CZetMapArea(0xd000, 0xd7ff, 2, System1SpriteRam); - CZetMemCallback(0xe000, 0xefff, 0); - CZetMemCallback(0xe000, 0xefff, 1); - CZetMemCallback(0xe000, 0xefff, 2); + CZetMapArea(0xd800, 0xddff, 0, System1PaletteRam); +// CZetMapArea(0xd800, 0xddff, 1, System1PaletteRam); +// CZetMapArea(0xd800, 0xddff, 2, System1PaletteRam); +// CZetMapArea(0xd800, 0xddff, 0, System1PaletteRam); +// CZetMemCallback(0xd800, 0xddff, 1); +// CZetMapArea(0xd000, 0xd1ff, 1, System1SpriteRam); CZetMapArea(0xe000, 0xefff, 0, System1VideoRam); //read // CZetMapArea(0xe000, 0xefff, 1, System1VideoRam); //write CZetMapArea(0xe000, 0xefff, 2, System1VideoRam); //fetch - CZetMemCallback(0xf000, 0xf3ff, 1); - CZetMemCallback(0xf800, 0xfbff, 1); + CZetMapArea(0xf400, 0xf7ff, 0, System1f4Ram); + CZetMapArea(0xf400, 0xf7ff, 1, System1f4Ram); + CZetMapArea(0xf400, 0xf7ff, 2, System1f4Ram); + CZetMapArea(0xf800, 0xfbff, 0, System1SprCollisionRam); + CZetMapArea(0xf800, 0xfbff, 2, System1SprCollisionRam); + CZetMapArea(0xfc00, 0xffff, 0, System1fcRam); + CZetMapArea(0xfc00, 0xffff, 1, System1fcRam); + CZetMapArea(0xfc00, 0xffff, 2, System1fcRam); - CZetSetReadHandler(WbmlZ801ProgRead); - CZetSetWriteHandler(WbmlZ801ProgWrite); + CZetSetReadHandler(System2Z801ProgRead); + CZetSetWriteHandler(System2Z801ProgWrite); - CZetSetInHandler (WbmlZ801PortRead); - CZetSetOutHandler(WbmlZ801PortWrite); + CZetSetInHandler (System2Z801PortRead); + CZetSetOutHandler(System2Z801PortWrite); CZetClose(); ppi8255_init(1); - PPI0PortWriteA = WbmlPPI0WriteA; - PPI0PortWriteB = WbmlPPI0WriteB; - PPI0PortWriteC = WbmlPPI0WriteC; + PPI0PortWriteA = System2PPI0WriteA; + PPI0PortWriteB = System2PPI0WriteB; + PPI0PortWriteC = System2PPI0WriteC; // System1Draw = WbmlRender; memset(System1VideoRam,0x00,0x4000); } + + +static INT32 System2Init(INT32 nZ80Rom1Num, INT32 nZ80Rom1Size, INT32 nZ80Rom2Num, INT32 nZ80Rom2Size, INT32 nTileRomNum, INT32 nTileRomSize, INT32 nSpriteRomNum, INT32 nSpriteRomSize, bool bReset) +{ + INT32 TilePlaneOffsets[3] = { RGN_FRAC((nTileRomSize * nTileRomNum), 0, 3), RGN_FRAC((nTileRomSize * nTileRomNum), 1, 3), RGN_FRAC((nTileRomSize * nTileRomNum), 2, 3) }; + INT32 TileXOffsets[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; + INT32 TileYOffsets[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; + INT32 nRet = 0, nLen, i, RomOffset; + struct BurnRomInfo ri; + + System1NumTiles = (((nTileRomNum * nTileRomSize) / 3) * 8) / (8 * 8); + System1SpriteRomSize = nSpriteRomNum * nSpriteRomSize; + + DrvInitSaturn(); + + CollisionFunction = updateCollisions; + //System1BgRamSize = 0x800; + // Allocate and Blank all required memory + Mem = NULL; + MemIndex(); + nLen = MemEnd - (UINT8 *)0; + + if ((Mem = (UINT8 *)malloc(nLen)) == NULL) + { + FNT_Print256_2bpp((volatile unsigned char *)SS_FONT,(unsigned char *)"malloc failed",4,80); + return 1; + } +// if ((SpriteOnScreenMap = (UINT8 *)malloc(256 * 256)) == NULL) {return 1;} + memset(Mem, 0, nLen); + MemIndex(); + + UINT8 * System1TempRom = (UINT8*)0x00200000; + memset(System1TempRom, 0, 0x40000); + // Load Z80 #1 Program roms + RomOffset = 0; + for (i = 0; i < nZ80Rom1Num; i++) { + nRet = BurnLoadRom(System1Rom1 + (i * nZ80Rom1Size), i + RomOffset, 1); if (nRet != 0) return 1; + BurnDrvGetRomInfo(&ri, i); + } + + if (System1BankedRom) + { + memcpy(System1TempRom, System1Rom1, 0x40000); + memset(System1Rom1, 0, 0x40000); + + if (System1BankedRom == 1) + { // Encrypted, banked + memcpy(System1Rom1 + 0x00000, System1TempRom + 0x00000, 0x8000); + memcpy(System1Rom1 + 0x10000, System1TempRom + 0x08000, 0x8000); + memcpy(System1Rom1 + 0x18000, System1TempRom + 0x10000, 0x8000); + } + + if (System1BankedRom == 2) + { // Unencrypted, banked + memcpy(System1Rom1 + 0x20000, System1TempRom + 0x00000, 0x8000); + memcpy(System1Rom1 + 0x00000, System1TempRom + 0x08000, 0x8000); + memcpy(System1Rom1 + 0x30000, System1TempRom + 0x10000, 0x8000);//fetch + memcpy(System1Rom1 + 0x10000, System1TempRom + 0x18000, 0x8000); + memcpy(System1Rom1 + 0x38000, System1TempRom + 0x20000, 0x8000);//fetch + memcpy(System1Rom1 + 0x18000, System1TempRom + 0x28000, 0x8000); + + if (nZ80Rom1Size == (ri.nLen * 2)) + { // last rom half the size, reload it into the last slot + memcpy (System1Rom1 + 0x18000, System1TempRom + 0x20000, 0x8000); + } + } + } + + memset(System1Rom2, 0, 0x10000); + + if (DecodeFunction) DecodeFunction(); + + // Load Z80 #2 Program roms + RomOffset += nZ80Rom1Num; + for (i = 0; i < nZ80Rom2Num; i++) { + nRet = BurnLoadRom(System1Rom2 + (i * nZ80Rom2Size), i + RomOffset, 1); if (nRet != 0) return 1; + } + + // Load and decode tiles + memset(System1TempRom, 0, 0x20000); + RomOffset += nZ80Rom2Num; + for (i = 0; i < nTileRomNum; i++) { + nRet = BurnLoadRom(System1TempRom + (i * nTileRomSize), i + RomOffset, 1); if (nRet != 0) return 1; + } + + GfxDecode4Bpp(System1NumTiles, 3, 8, 8, TilePlaneOffsets, TileXOffsets, TileYOffsets, 0x40, System1TempRom, System1Tiles); + + System1TempRom = NULL; + + memset(&ss_map2[2048],0,768); + + if(flipscreen==1) rotate_tile(System1NumTiles,0,System1Tiles); + else if(flipscreen==2) rotate_tile(System1NumTiles,1,System1Tiles); + + spriteCache = (UINT16*)(0x00200000); + + memset((unsigned char *)spriteCache,0xFF,0x80000); + if(System1SpriteRomSize!=0x20000) + System1Sprites = (UINT8 *)malloc(System1SpriteRomSize); + else + System1Sprites = (UINT8 *)0x02E0000; + + memset(System1Sprites, 0x00, System1SpriteRomSize); + + // Load Sprite roms + RomOffset += nTileRomNum; + for (i = 0; i < nSpriteRomNum; i++) + { + nRet = BurnLoadRom(System1Sprites + (i * nSpriteRomSize), i + RomOffset, 1); + } + + // Load Colour proms + if (System1ColourProms) { + RomOffset += nSpriteRomNum; + nRet = BurnLoadRom(System1PromRed, 0 + RomOffset, 1); + nRet = BurnLoadRom(System1PromGreen, 1 + RomOffset, 1); + nRet = BurnLoadRom(System1PromBlue, 2 + RomOffset, 1); + } + + // Setup the Z80 emulation + CZetInit2(2,CZ80Context); + + CZetOpen(0); + CZetSetReadHandler(System2Z801ProgRead); + CZetSetWriteHandler(System2Z801ProgWrite); + CZetSetInHandler(System2Z801PortRead); + CZetSetOutHandler(System2Z801PortWrite); + + CZetMapArea(0x0000, 0x7fff, 0, System1Rom1); + CZetMapArea(0x8000, 0xbfff, 0, System1Rom1 + 0x8000); + if (DecodeFunction) + { + CZetMapArea2(0x0000, 0x7fff, 2, System1Rom1 + 0x20000, System1Rom1); + CZetMapArea2(0x8000, 0xbfff, 2, System1Rom1 + 0x30000, System1Rom1 + 0x10000); // 30 fetch, 10 for code(?) + } + else + { + CZetMapArea(0x0000, 0x7fff, 2, System1Rom1); + CZetMapArea(0x8000, 0xbfff, 2, System1Rom1 + 0x8000); + } + CZetMapArea(0xc000, 0xcfff, 0, System1Ram1); + CZetMapArea(0xc000, 0xcfff, 1, System1Ram1); + CZetMapArea(0xc000, 0xcfff, 2, System1Ram1); + CZetMapArea(0xd000, 0xd7ff, 0, System1SpriteRam); + CZetMapArea(0xd000, 0xd7ff, 1, System1SpriteRam); + CZetMapArea(0xd000, 0xd7ff, 2, System1SpriteRam); + CZetMapArea(0xd800, 0xdfff, 0, System1PaletteRam); +// CZetMapArea(0xd800, 0xdfff, 1, System1PaletteRam); +// CZetMapArea(0xd800, 0xdfff, 2, System1PaletteRam); +//---------- +// vbt ajout pour s2 + CZetMapArea(0xe000, 0xefff, 0, System1VideoRam); //read +// CZetMapArea(0xe000, 0xefff, 1, System1VideoRam); //write + CZetMapArea(0xe000, 0xefff, 2, System1VideoRam); //fetch +//--------- + CZetMapArea(0xf000, 0xf3ff, 0, System1BgCollisionRam); + CZetMapArea(0xf000, 0xf3ff, 2, System1BgCollisionRam); + CZetMapArea(0xf400, 0xf7ff, 0, System1f4Ram); + CZetMapArea(0xf400, 0xf7ff, 1, System1f4Ram); + CZetMapArea(0xf400, 0xf7ff, 2, System1f4Ram); + CZetMapArea(0xf800, 0xfbff, 0, System1SprCollisionRam); + CZetMapArea(0xf800, 0xfbff, 2, System1SprCollisionRam); + CZetMapArea(0xfc00, 0xffff, 0, System1fcRam); + CZetMapArea(0xfc00, 0xffff, 1, System1fcRam); + CZetMapArea(0xfc00, 0xffff, 2, System1fcRam); + CZetClose(); + + z80_init_memmap(); + z80_add_read(0xe000, 0xe001, 1, (void *)&System1Z802ProgRead); + z80_add_write(0xa000, 0xa003, 1, (void *)&System1Z802ProgWrite); + z80_add_write(0xc000, 0xc003, 1, (void *)&System1Z802ProgWrite); + z80_map_read (0x0000, 0x7fff, System1Rom2); + z80_map_fetch (0x0000, 0x7fff, System1Rom2); + z80_map_read (0x8000, 0x87ff, System1Ram2); + z80_map_write (0x8000, 0x87ff, System1Ram2); //ajout + z80_map_fetch (0x8000, 0x87ff, System1Ram2); +// derek fix for wbml sound :) + z80_map_read (0x8800, 0x8fff, System1Ram2); + z80_map_write (0x8800, 0x8fff, System1Ram2); //ajout + z80_map_fetch (0x8800, 0x8fff, System1Ram2); + + z80_end_memmap(); + z80_reset(); + + memset(SpriteOnScreenMap, 255, 256 * 256); + +// System1SpriteXOffset = 1; + + nCyclesTotal[0] = 2000000 / hz; + nCyclesTotal[1] = 2000000 / hz; + + SN76489AInit(0, 2000000, 0); + SN76489AInit(1, 4000000, 1); + + make_lut(); + make_cram_lut(); + MakeInputsFunction = System1MakeInputs; + + System1BgRam = NULL; +// System1SpriteXOffset = 15; + + CZetOpen(0); + CZetMemCallback(0xf000, 0xf3ff, 1); // collision ram written through write handler + CZetMemCallback(0xf800, 0xfbff, 1); // "" + CZetClose(); + + ppi8255_init(1); + PPI0PortWriteA = System2PPI0WriteA; + PPI0PortWriteB = System2PPI0WriteB; + PPI0PortWriteC = System2PPI0WriteC; + +// System1Draw = System2Render; + memset(System1VideoRam, 0x00, 0x4000); // mapped through bank_latch + + if (bReset) + { + ppi8255_init(1); + System1DoReset(); + } + // VBT saturn S2 + System1SpriteRam = &System1Ram1[0x1000]; + System1PaletteRam = &System1Ram1[0x1800]; // ? garder + + make_cram_lut(); + System1CalcPalette(); + + ss_reg->n1_move_x = 4<<16; + RamStart1 = System1VideoRam-0xe000; // fg + drawWindow(0,224,0,0,65); + + return 0; +} //------------------------------------------------------------------------------------------------------------------------------------- /*static*/ int WbmljbInit() { int nRet; System1ColourProms = 1; - System1BankedRom = 2; // 2 + System1BankedRom = 2; DecodeFunction = wbmljb_decode; - nRet = System1Init(3, 0x10000, 1, 0x8000, 3, 0x8000, 4, 0x8000, 1); + nRet = System1Init(3, 0x10000, 1, 0x8000, 3, 0x8000, 4, 0x8000, 1); +// nRet = System2Init(3, 0x8000, 1, 0x8000, 3, 0x8000, 4, 0x8000, 1); + CommonWbmlInit(); + System1ScrollXRam = NULL; + RamStart = NULL; //System1VideoRam-0xe000; // bg + + +// System1DoReset(); return nRet; } //------------------------------------------------------------------------------------------------------------------------------------- @@ -372,91 +659,78 @@ void CommonWbmlInit() void renderTile(UINT32 offs,UINT32 code,UINT32 current_map) { - UINT32 color = (code >> 5) & 0x3f; -// UINT32 priority = code & 0x800; code = ((code >> 4) & 0x800) | (code & 0x7ff); unsigned int x = map_offset_lut[offs]; - UINT16 *map = &ss_map[x]; - map[current_map] = ((code >> 5) & 0x3f); //|((code & 0x800)?0x3000:0x1000);//color_lut[Code]; - map[current_map+1] = code & (System1NumTiles-1); + UINT16 *map = &ss_map[x+current_map]; + map[0] = ((code >> 5) & 0x3f); //|((code & 0x800)?0x3000:0x1000);//color_lut[Code]; + map[1] = code & 0xfff; } unsigned int map_cache[4][0x800]; static void wbml_draw_bg( int trasp) { - ss_reg->n2_move_x = (260-(((System1VideoRam[0x7c0] >> 1) + ((System1VideoRam[0x7c1] & 1) << 7) - 256+5))) & 0xff; - ss_reg->n2_move_y = System1VideoRam[0x7ba] & 0xff; +// ss_reg->n2_move_x = (-(((System1VideoRam[0x7c0] >> 1) + ((System1VideoRam[0x7c1] & 1) << 7) +1))) & 0xff; + ss_reg->n2_move_x = (255-((System1VideoRam[0x7c0] >> 1) + ((System1VideoRam[0x7c1] & 1) << 7))) &0xff; + ss_reg->n2_move_y = System1VideoRam[0x7ba]; // & 0x1f; const unsigned int v[] = { 0, 0x40, 0x1000, 0x1040 }; +#if 1 for (unsigned int page=0; page < 4; page++) { unsigned int current_map=v[page]; - UINT8 *source = System1VideoRam + (System1VideoRam[0x0740 + page*2] & 0x07)*0x800; +// UINT8 *source = System1VideoRam + (System1VideoRam[0x0740 + page*2] & 0x07)*0x800; + UINT8 *source = System1VideoRam + ((System1VideoRam[0x0740 + page*2] & 0x07)<<11); +// UINT16 *source = (UINT16 *)source1; + UINT32 *curr_cache = &map_cache[page]; - for(UINT32 offs = 0; offs <0x800;) + for(UINT32 offs = 0; offs <0x400;) { - UINT32 code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) - { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); - } - offs+=2; - code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) - { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); - } - offs+=2; - code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) - { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); - } - offs+=2; - code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) - { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); - } - offs+=2; + UINT32 code = source[0] + (source[1] << 8); - code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) + if(curr_cache[offs]!=code) { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); + curr_cache[offs]=code; + renderTile(offs*2,code,current_map); } - offs+=2; - code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) + source+=2; + ++offs; + + code = source[0] + (source[1] << 8); + + if(curr_cache[offs]!=code) { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); + curr_cache[offs]=code; + renderTile(offs*2,code,current_map); } - offs+=2; - code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) + source+=2; + ++offs; + /* + code = source[0] + (source[1] << 8); + + if(curr_cache[offs]!=code) { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); + curr_cache[offs]=code; + renderTile(offs*2,code,current_map); } - offs+=2; - code = source[offs + 0] + (source[offs + 1] << 8); - if(map_cache[page][offs]!=code) + source+=2; + offs++; + + code = source[0] + (source[1] << 8); + + if(curr_cache[offs]!=code) { - map_cache[page][offs]=code; - renderTile(offs,code,current_map); + curr_cache[offs]=code; + renderTile(offs*2,code,current_map); } - offs+=2; + source+=2; + offs++; */ + } } +#endif } //------------------------------------------------------------------------------------------------------------------------------------- /*static*/ void System1Render() diff --git a/d_sys2.h b/d_sys2.h index 5504d86..7131fef 100644 --- a/d_sys2.h +++ b/d_sys2.h @@ -302,6 +302,28 @@ static struct BurnRomInfo wbmlbRomDesc[] = { STD_ROM_PICK(wbmlb) STD_ROM_FN(wbmlb) + +// Wonder Boy in Monster Land (English, Virtual Console) +static struct BurnRomInfo wbmlvcRomDesc[] = { + + { "vc.90", 0x10000, 0x093c4852, BRF_ESS | BRF_PRG }, // 0 Z80 #1 Program Code + { "vc.91", 0x10000, 0x7e973ece, BRF_ESS | BRF_PRG }, // 1 + { "vc.92", 0x08000, 0x32661e7e, BRF_ESS | BRF_PRG }, // 2 + { "epr11037.126", 0x08000, 0x7a4ee585, BRF_ESS | BRF_PRG }, // 3 Z80 #2 Program Code + { "vc.ic4", 0x08000, 0x820bee59, BRF_GRA }, // 4 Tiles + { "vc.ic6", 0x08000, 0xa9a1447e, BRF_GRA }, // 5 + { "vc.ic5", 0x08000, 0x359026a0, BRF_GRA }, // 6 + { "epr11028.87", 0x08000, 0xaf0b3972, BRF_GRA }, // 7 Sprites + { "epr11027.86", 0x08000, 0x277d8f1d, BRF_GRA }, // 8 + { "epr11030.89", 0x08000, 0xf05ffc76, BRF_GRA }, // 9 + { "epr11029.88", 0x08000, 0xcedc9c61, BRF_GRA }, // 10 + { "pr11026.20", 0x00100, 0x27057298, BRF_GRA }, // 11 Red PROM + { "pr11025.14", 0x00100, 0x41e4d86b, BRF_GRA }, // 12 Blue + { "pr11024.8", 0x00100, 0x08d71954, BRF_GRA }, // 13 Green + { "pr5317.37", 0x00100, 0x648350b8, BRF_GRA }, // 14 Timing PROM +}; +STD_ROM_PICK(wbmlvc) +STD_ROM_FN(wbmlvc) /*============================================================================================== Driver defs ===============================================================================================*/ diff --git a/d_zaxxon.c b/d_zaxxon.c index 0b75a5b..d9ee27c 100644 --- a/d_zaxxon.c +++ b/d_zaxxon.c @@ -2,7 +2,7 @@ //#define RAZE 1 #define draw_background(x) draw_background_test2() //#define draw_background(x) draw_background_not_rotated(x) - +/* unsigned char buffer[100]; int vspfunc(char *format, ...) @@ -16,29 +16,29 @@ int vspfunc(char *format, ...) return(ret); } - +*/ int ovlInit(char *szShortName) { - struct BurnDriver nBurnDrvCongo = { +/* struct BurnDriver nBurnDrvCongo = { "congo", "zaxxon", "Congo Bongo\0", congoRomInfo, congoRomName, CongoBongoInputInfo, ZaxxonDIPInfo, CongoInit, DrvExit, DrvFrame, NULL, }; - +*/ struct BurnDriver nBurnDrvZaxxon = { "zaxxon", NULL, "Zaxxon (set 1)\0", zaxxonRomInfo, zaxxonRomName, ZaxxonInputInfo, ZaxxonDIPInfo, DrvInit, DrvExit, DrvFrame, NULL, }; - struct BurnDriver nBurnDrvZaxxonb = { +/* struct BurnDriver nBurnDrvZaxxonb = { "zaxxonb", "zaxxon", "Jackson\0", zaxxonRomInfo, zaxxonRomName, ZaxxonInputInfo, ZaxxonDIPInfo, ZaxxonbInit, DrvExit, DrvFrame, NULL, }; - +*/ struct BurnDriver nBurnDrvSzaxxon = { "szaxxon", "zaxxon", "Super Zaxxon\0", @@ -46,9 +46,9 @@ struct BurnDriver nBurnDrvSzaxxon = { sZaxxonInit, DrvExit, DrvFrame, NULL, }; - if (strcmp(nBurnDrvCongo.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvCongo,sizeof(struct BurnDriver)); +// if (strcmp(nBurnDrvCongo.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvCongo,sizeof(struct BurnDriver)); if (strcmp(nBurnDrvZaxxon.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvZaxxon,sizeof(struct BurnDriver)); - if (strcmp(nBurnDrvZaxxonb.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvZaxxonb,sizeof(struct BurnDriver)); +// if (strcmp(nBurnDrvZaxxonb.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvZaxxonb,sizeof(struct BurnDriver)); if (strcmp(nBurnDrvSzaxxon.szShortName, szShortName) == 0) memcpy(shared,&nBurnDrvSzaxxon,sizeof(struct BurnDriver)); ss_reg = (SclNorscl *)SS_REG; @@ -1010,7 +1010,7 @@ void GfxDecode(INT32 num, INT32 numPlanes, INT32 xSize, INT32 ySize, INT32 plane zaxxon_flipscreen = zaxxon_coin_enable = soundlatch = NULL; zaxxon_coin_status = zaxxon_coin_last = sound_state = NULL; zaxxon_bg_scroll = 0; -// free (AllMem); + free (AllMem); AllMem = NULL; ss_map264 = NULL; @@ -1029,6 +1029,7 @@ void GfxDecode(INT32 num, INT32 numPlanes, INT32 xSize, INT32 ySize, INT32 plane // DrvPalette = Palette = NULL; futspy_sprite = 0; hardware_type = 0; + zaxxon_bg_scroll_x2=0; DrvReset = 0; // GenericTilesExit(); return 0; diff --git a/d_zaxxon.h b/d_zaxxon.h index e59c978..334ae61 100644 --- a/d_zaxxon.h +++ b/d_zaxxon.h @@ -16,7 +16,7 @@ int DrvDraw(); void make_lut(); static UINT8 *SaturnMem = NULL; -UINT8 *bitmap = NULL; +static UINT8 *bitmap = NULL; static UINT8 *ss_map264 = NULL; static INT16 *sx_lut = NULL; static INT16 *sy_lut = NULL; diff --git a/root/sl.cti b/root/sl.cti index df86958..9874100 100644 --- a/root/sl.cti +++ b/root/sl.cti @@ -2936,6 +2936,55 @@ EndFile EndDirectory + Directory WBMLVC + + File VC.90;1 + Source WBMLVC\VC.90 + EndFile + File VC.91;1 + Source WBMLVC\VC.91 + EndFile + File VC.92;1 + Source WBMLVC\VC.92 + EndFile + File EPR11037.126;1 + Source WBMLVC\EPR11037.126 + EndFile + File VC.IC4;1 + Source WBMLVC\VC.IC4 + EndFile + File VC.IC6;1 + Source WBMLVC\VC.IC6 + EndFile + File VC.IC5;1 + Source WBMLVC\VC.IC5 + EndFile + File EPR11028.87;1 + Source WBMLVC\EPR11028.87 + EndFile + File EPR11027.86;1 + Source WBMLVC\EPR11027.86 + EndFile + File EPR11030.89;1 + Source WBMLVC\EPR11030.89 + EndFile + File EPR11029.88;1 + Source WBMLVC\EPR11029.88 + EndFile + File PR11026.20;1 + Source WBMLVC\PR11026.20 + EndFile + File PR11025.14;1 + Source WBMLVC\PR11025.14 + EndFile + File PR11024.8;1 + Source WBMLVC\PR11024.8 + EndFile + File PR5317.37;1 + Source WBMLVC\PR5317.37 + EndFile + EndDirectory + Directory HANGONJR File ROM1.IC2;1 diff --git a/saturn/file.c b/saturn/file.c index 70df369..65bbd99 100644 --- a/saturn/file.c +++ b/saturn/file.c @@ -36,7 +36,7 @@ static GfsDirName dir_name[MAX_DIR]; static Uint32 lib_work[GFS_WORK_SIZE(MAX_OPEN) / sizeof(Uint32)]; #endif -#define VBT +//#define VBT #ifdef VBT #define SYS_CDINIT1(i) \ diff --git a/saturn/saturn.c b/saturn/saturn.c index b29eb26..43b9d59 100644 --- a/saturn/saturn.c +++ b/saturn/saturn.c @@ -322,10 +322,8 @@ static void ss_main(void) InitCD(); #endif hz = get_hz(); -// nBurnMallocAddr = 0; initSound(); CSH_Init(CSH_4WAY); -// SPR_InitSlaveSH(); initSaturn(); BurnDrvAssignList(); @@ -1756,8 +1754,8 @@ static void run_fba_emulator() _spr2_transfercommand(); frame_x++; -// if(frame_x>=frame_y) -// wait_vblank(); + if(frame_x>=frame_y) + wait_vblank(); } } if(drvquit==1) @@ -1775,14 +1773,11 @@ static void run_fba_emulator() //------------------------------------------------------------------------------------------------------------------------------------- void initSprites(int sx,int sy,int sx2, int sy2,int lx,int ly) { - //SPR_InitSlaveSH(); _spr2_initialize(); SPR_WRITE_REG(SPR_W_TVMR, 0x0007 & SPR_TV_NORMAL);//SPR_TV_ROT8);//SPR_TV_NORMAL); SPR_SetEraseData( 0x0000, 0, 0, sx, sy ); -// SPR_SetEraseData( RGB(31,0,0), 0, 0, sx, sy ); -// CSH_Init(CSH_4WAY); -// SPR_InitSlaveSH(); + memset(smsSprite,0,sizeof(SprSpCmd)*131); smsSprite[0].control = (JUMP_NEXT | FUNC_SCLIP);