Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
pacman working
  • Loading branch information
vbt1 committed Nov 30, 2015
1 parent 40a3ae2 commit 8ddc85e
Show file tree
Hide file tree
Showing 13 changed files with 808 additions and 191 deletions.
15 changes: 14 additions & 1 deletion burn.c
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions burnint.h
Expand Up @@ -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))
Expand Down
26 changes: 21 additions & 5 deletions 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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
162 changes: 147 additions & 15 deletions d_pacman.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -421,15 +500,21 @@ 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();

make_lut();
memset(bg_dirtybuffer,1,0x400);

if (pacman_load()) return 1;
if (pacman_load())
{
return 1;
}

if (pInitCallback) {
pInitCallback();
Expand Down Expand Up @@ -581,6 +666,8 @@ static INT32 DrvExit()
{
NamcoSoundExit();
CZetExit();
PCM_Task(pcm);
nSoundBufferPos=0;

game_select = PACMAN;
nPacBank = -1;
Expand All @@ -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;
}

Expand All @@ -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)
Expand Down Expand Up @@ -650,6 +764,14 @@ static INT32 DrvDraw()
return 0;
}

static INT32 DrvDrawPacMan()
{
DrawPacManBackground();
DrawSprites();

return 0;
}

static INT32 DrvFrame()
{
watchdog++;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -763,7 +890,7 @@ static INT32 DrvFrame()
DrvDraw();
}
*/
DrvDraw();
DrvDrawPacMan();
if(nSoundBufferPos>=RING_BUF_SIZE/2)//0x4800-nSegmentLength)//
{
PCM_Task(pcm);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8ddc85e

Please sign in to comment.