Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudreadmon committed Oct 18, 2018
1 parent 1846fbd commit bf50f42
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 159 deletions.
38 changes: 21 additions & 17 deletions src/burn/drv/cps3/cps3run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Port to FBA by OopsWare
#include "sh2_intf.h"

#define BE_GFX 1
#define BE_GFX_CRAM 0 // do not touch!
//#define FAST_BOOT 1
#define SPEED_HACK 1 // Default should be 1, if not FPS would drop.

Expand Down Expand Up @@ -290,7 +291,7 @@ static UINT32 process_byte( UINT8 real_byte, UINT32 destination, INT32 max_lengt
INT32 cps3_rle_length = (real_byte&0x3f)+1;
//printf("RLE Operation (length %08x\n", cps3_rle_length );
while (cps3_rle_length) {
#if BE_GFX
#if BE_GFX_CRAM
dest[((destination+tranfercount)&0x7fffff)] = (last_normal_byte&0x3f);
#else
dest[((destination+tranfercount)&0x7fffff)^3] = (last_normal_byte&0x3f);
Expand All @@ -308,7 +309,7 @@ static UINT32 process_byte( UINT8 real_byte, UINT32 destination, INT32 max_lengt
return tranfercount;
} else {
//printf("Write Normal Data\n");
#if BE_GFX
#if BE_GFX_CRAM
dest[(destination&0x7fffff)] = real_byte;
#else
dest[(destination&0x7fffff)^3] = real_byte;
Expand All @@ -326,23 +327,23 @@ static void cps3_do_char_dma( UINT32 real_source, UINT32 real_destination, UINT3
INT32 length_remaining = real_length;
last_normal_byte = 0;
while (length_remaining) {
UINT8 current_byte = sourcedata[ real_source ^ 0 ];
UINT8 current_byte = sourcedata[ real_source ];
real_source++;

if (current_byte & 0x80) {
UINT8 real_byte;
UINT32 length_processed;
current_byte &= 0x7f;

real_byte = sourcedata[ (chardma_table_address+current_byte*2+0) ^ 0 ];
real_byte = sourcedata[ (chardma_table_address+current_byte*2+0) ];
//if (real_byte&0x80) return;
length_processed = process_byte( real_byte, real_destination, length_remaining );
length_remaining -= length_processed; // subtract the number of bytes the operation has taken
real_destination += length_processed; // add it onto the destination
if (real_destination>0x7fffff) return;
if (length_remaining<=0) return; // if we've expired, exit

real_byte = sourcedata[ (chardma_table_address+current_byte*2+1) ^ 0 ];
real_byte = sourcedata[ (chardma_table_address+current_byte*2+1) ];
//if (real_byte&0x80) return;
length_processed = process_byte( real_byte, real_destination, length_remaining );
length_remaining -= length_processed; // subtract the number of bytes the operation has taken
Expand Down Expand Up @@ -372,7 +373,7 @@ static UINT32 ProcessByte8(UINT8 b, UINT32 dst_offset)
INT32 rle=(b+1)&0xff;

for(INT32 i=0;i<rle;++i) {
#if BE_GFX
#if BE_GFX_CRAM
destRAM[(dst_offset&0x7fffff)] = lastb;
#else
destRAM[(dst_offset&0x7fffff)^3] = lastb;
Expand All @@ -388,7 +389,7 @@ static UINT32 ProcessByte8(UINT8 b, UINT32 dst_offset)
} else {
lastb2=lastb;
lastb=b;
#if BE_GFX
#if BE_GFX_CRAM
destRAM[(dst_offset&0x7fffff)] = b;
#else
destRAM[(dst_offset&0x7fffff)^3] = b;
Expand All @@ -409,18 +410,18 @@ static void cps3_do_alt_char_dma(UINT32 src, UINT32 real_dest, UINT32 real_lengt
lastb2=0xffff;

while(1) {
UINT8 ctrl=px[ src ^ 0 ];
UINT8 ctrl=px[ src ];
++src;

for(INT32 i=0;i<8;++i) {
UINT8 p = px[ src ^ 0 ];
UINT8 p = px[ src ];

if(ctrl&0x80) {
UINT8 real_byte;
p &= 0x7f;
real_byte = px[ (chardma_table_address+p*2+0) ^ 0 ];
real_byte = px[ (chardma_table_address+p*2+0) ];
ds += ProcessByte8(real_byte,ds);
real_byte = px[ (chardma_table_address+p*2+1) ^ 0 ];
real_byte = px[ (chardma_table_address+p*2+1) ];
ds += ProcessByte8(real_byte,ds);
} else {
ds += ProcessByte8(p,ds);
Expand Down Expand Up @@ -467,7 +468,10 @@ static void cps3_process_character_dma(UINT32 address)
// Red Earth need this. 8192 byte trans to 0x00003000 (from 0x007ec000???)
// seems some stars(6bit alpha) without compress
//bprintf(PRINT_NORMAL, _T("Character DMA (redearth) start %08x to %08x with %d\n"), real_source, real_destination, real_length);
memcpy( (UINT8 *)RamCRam + real_destination, RomUser + real_source, real_length );

//memcpy( (UINT8 *)RamCRam + real_destination, RomUser + real_source, real_length );
for (INT32 j = 0; j < real_length; j++)
((UINT8 *)RamCRam)[real_destination + j] = RomUser[(real_source + j) ^ 3];
Sh2SetIRQLine(10, CPU_IRQSTATUS_ACK);
break;
default:
Expand Down Expand Up @@ -1386,7 +1390,7 @@ static void cps3_drawgfxzoom_1(UINT32 code, UINT32 pal, INT32 flipx, INT32 flipy
UINT8 * src = (UINT8 *) RamCRam;
dst += (drawline * 1024 + x);

#if BE_GFX
#if BE_GFX_CRAM

if ( flipy ) {
src += code * 256 + 16 * (15 - (drawline - y));
Expand Down Expand Up @@ -1609,7 +1613,7 @@ static void cps3_drawgfxzoom_2(UINT32 code, UINT32 pal, INT32 flipx, INT32 flipy
UINT32 * dest = RamScreen + y * 512 * 2;
INT32 x_index = x_index_base;
for(INT32 x=sx; x<ex; x++ ) {
#if BE_GFX
#if BE_GFX_CRAM
UINT8 c = source[ (x_index>>16) ];
#else
UINT8 c = source[ (x_index>>16) ^ 3 ];
Expand All @@ -1626,7 +1630,7 @@ static void cps3_drawgfxzoom_2(UINT32 code, UINT32 pal, INT32 flipx, INT32 flipy
UINT32 * dest = RamScreen + y * 512 * 2;
INT32 x_index = x_index_base;
for(INT32 x=sx; x<ex; x++ ) {
#if BE_GFX
#if BE_GFX_CRAM
UINT8 c = source[ (x_index>>16)];
#else
UINT8 c = source[ (x_index>>16) ^ 3 ];
Expand All @@ -1643,7 +1647,7 @@ static void cps3_drawgfxzoom_2(UINT32 code, UINT32 pal, INT32 flipx, INT32 flipy
UINT32 * dest = RamScreen + y * 512 * 2;
INT32 x_index = x_index_base;
for(INT32 x=sx; x<ex; x++ ) {
#if BE_GFX
#if BE_GFX_CRAM
UINT8 c = source[ (x_index>>16) ];
#else
UINT8 c = source[ (x_index>>16) ^ 3 ];
Expand Down Expand Up @@ -2095,7 +2099,7 @@ INT32 cps3Scan(INT32 nAction, INT32 *pnMin)
ba.nLen = 0x0000400 * 2;
ba.nAddress = 0;
ba.szName = "RAM C000";
BurnAcb(&ba);
BurnAcb(&ba);

ba.Data = RamPal;
ba.nLen = 0x0040000;
Expand Down
49 changes: 23 additions & 26 deletions src/burn/drv/irem/d_m72.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static UINT8 DrvDips[2];
static UINT8 DrvInputs[5];
static UINT8 DrvReset;

static INT32 nExtraCycles;
static INT32 nCurrentCycles;
static INT32 nCyclesDone[2];
static INT32 nCyclesTotal[2];
Expand Down Expand Up @@ -1261,11 +1262,6 @@ static void m72YM2151IRQHandler(INT32 nStatus)
setvector_callback(nStatus ? YM2151_ASSERT : YM2151_CLEAR);
}

static INT32 m72SyncDAC()
{ // Note: the FPS is 55, but when calculating the sync, we use 4 less FPS - this gets rid of clicks in the sample output. -dink dec. 2, 2014
return (INT32)(float)(nBurnSoundLen * (ZetTotalCycles() / (3579545.000 / 51/*(nBurnFPS / 100.000)*/)));
}

static INT32 DrvDoReset()
{
memset (AllRam, 0, RamEnd - AllRam);
Expand All @@ -1290,6 +1286,8 @@ static INT32 DrvDoReset()
if (!CosmicCop) m72_irq_base = 0;
majtitle_rowscroll_enable = 0;

nExtraCycles = 0;

return 0;
}

Expand Down Expand Up @@ -1738,7 +1736,7 @@ static INT32 DrvInit(void (*pCPUMapCallback)(), void (*pSNDMapCallback)(), INT32
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);

DACInit(0, 0, 1, m72SyncDAC);
DACInit(0, 0, 1, ZetTotalCycles, 3579545);
DACSetRoute(0, 0.40, BURN_SND_ROUTE_BOTH);

DrvDoReset();
Expand Down Expand Up @@ -2079,8 +2077,6 @@ static void scanline_interrupts(INT32 scanline)

static INT32 DrvFrame()
{
INT32 nSoundBufferPos = 0;

if (DrvReset) {
DrvDoReset();
}
Expand All @@ -2092,13 +2088,16 @@ static INT32 DrvFrame()

INT32 multiplier = 3;
INT32 nInterleave = 256 * multiplier;
INT32 nSoundBufferPos = 0;
INT32 z80samplecount = 0;

if (Clock_16mhz) // Ken-go, Cosmic Cop
nCyclesTotal[0] = (INT32)((INT64)(16000000 / 55) * nBurnCPUSpeedAdjust / 0x0100);
else
nCyclesTotal[0] = (INT32)((INT64)(8000000 / 55) * nBurnCPUSpeedAdjust / 0x0100);
nCyclesTotal[1] = (INT32)((INT64)(3579545 / 55) * nBurnCPUSpeedAdjust / 0x0100);
nCyclesDone[0] = nCyclesDone[1] = 0;
nCyclesDone[0] = 0;
nCyclesDone[1] = nExtraCycles;

if (pBurnDraw) {
DrvDrawInitFrame();
Expand All @@ -2116,10 +2115,10 @@ static INT32 DrvFrame()
scanline_interrupts(i/multiplier);

if (z80_reset == 0) {
nCyclesDone[1] += ZetRun(nCyclesTotal[1] / nInterleave);

if (i%multiplier==0 && i/multiplier & 1) {
nCyclesDone[1] += ZetRun((nCyclesTotal[1] * (i + 1) / nInterleave) - nCyclesDone[1]);
if (i%multiplier==2 && i/multiplier & 1 && z80samplecount < 128) {
if (z80_nmi_enable == Z80_FAKE_NMI) {
z80samplecount++;
if (DrvSndROM[sample_address]) {
DACSignedWrite(0, DrvSndROM[sample_address]);
sample_address = (sample_address + 1) & 0x3ffff;
Expand All @@ -2128,7 +2127,8 @@ static INT32 DrvFrame()
}

} else if (z80_nmi_enable == Z80_REAL_NMI) {
ZetNmi();
z80samplecount++;
ZetNmi();
}
}
} else {
Expand All @@ -2146,6 +2146,7 @@ static INT32 DrvFrame()
}
}
}
nExtraCycles = nCyclesDone[1] - nCyclesTotal[1]; // just for sound

if (pBurnSoundOut) {
INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
Expand Down Expand Up @@ -2198,15 +2199,6 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
SCAN_VAR(z80_reset);
SCAN_VAR(majtitle_rowscroll_enable);
}

if (nAction & ACB_WRITE) {
#if 0
// this probably isn't needed anymore - keeping for a while just incase. -dink Nov 27, 2017
ZetOpen(0); // Kick-start the ym2151 after state load.
m72YM2151IRQHandler(1);
ZetClose();
#endif
}

return 0;
}
Expand Down Expand Up @@ -3134,6 +3126,11 @@ static struct BurnRomInfo rtype2jRomDesc[] = {

{ "rt2_b-4n-.bin", 0x00100, 0xb460c438, 0x00 | BRF_OPT }, // 18 Proms
{ "rt2_b-4p-.bin", 0x00100, 0xa4f2c4bc, 0x00 | BRF_OPT }, // 19

{ "rt2-a-2h-.5", 0x00104, 0x00000000, 0x00 | BRF_OPT | BRF_NODUMP },
{ "rt2-a-5l-.33", 0x00104, 0x00000000, 0x00 | BRF_OPT | BRF_NODUMP },
{ "rt2-b-3a-.9", 0x00104, 0x00000000, 0x00 | BRF_OPT | BRF_NODUMP },
{ "rt2-a-7d-.45", 0x00104, 0x53c1e087, 0x00 | BRF_OPT },
};

STD_ROM_PICK(rtype2j)
Expand Down Expand Up @@ -3624,7 +3621,7 @@ struct BurnDriver BurnDrvLoht = {
"loht", NULL, NULL, NULL, "1989",
"Legend of Hero Tonma\0", NULL, "Irem", "Irem M72",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_IREM_M72, GBF_SCRFIGHT, 0,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_IREM_M72, GBF_RUNGUN, 0,
NULL, lohtRomInfo, lohtRomName, NULL, NULL, CommonInputInfo, LohtDIPInfo,
lohtInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
384, 256, 4, 3
Expand Down Expand Up @@ -3666,7 +3663,7 @@ struct BurnDriver BurnDrvLohtj = {
"lohtj", "loht", NULL, NULL, "1989",
"Legend of Hero Tonma (Japan)\0", NULL, "Irem", "Irem M72",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED | BDF_CLONE, 2, HARDWARE_IREM_M72, GBF_SCRFIGHT, 0,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED | BDF_CLONE, 2, HARDWARE_IREM_M72, GBF_RUNGUN, 0,
NULL, lohtjRomInfo, lohtjRomName, NULL, NULL, CommonInputInfo, LohtDIPInfo,
lohtInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
384, 256, 4, 3
Expand Down Expand Up @@ -3809,7 +3806,7 @@ struct BurnDriver BurnDrvLohtb = {
"lohtb", "loht", NULL, NULL, "1989",
"Legend of Hero Tonma (bootleg, set 1)\0", NULL, "bootleg", "Irem M72",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_IREM_M72, GBF_SCRFIGHT, 0,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_IREM_M72, GBF_RUNGUN, 0,
NULL, lohtbRomInfo, lohtbRomName, NULL, NULL, CommonInputInfo, LohtDIPInfo,
lohtbInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
384, 256, 4, 3
Expand Down Expand Up @@ -3859,7 +3856,7 @@ struct BurnDriver BurnDrvLohtb2 = {
"lohtb2", "loht", NULL, NULL, "1989",
"Legend of Hero Tonma (bootleg, set 2)\0", NULL, "bootleg", "Irem M72",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_IREM_M72, GBF_SCRFIGHT, 0,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_IREM_M72, GBF_RUNGUN, 0,
NULL, lohtb2RomInfo, lohtb2RomName, NULL, NULL, CommonInputInfo, LohtDIPInfo,
lohtInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
384, 256, 4, 3
Expand Down
6 changes: 3 additions & 3 deletions src/burn/drv/irem/d_m90.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,13 @@ static void __fastcall m90_sound_write_port(UINT16 port, UINT8 data)

case 0x80:
sample_address >>= 5;
sample_address = (sample_address & 0x00ff) | (data << 8);
sample_address = (sample_address & 0xff00) | (data << 0);
sample_address <<= 5;
return;

case 0x81:
sample_address >>= 5;
sample_address = (sample_address & 0xff00) | (data << 0);
sample_address = (sample_address & 0x00ff) | (data << 8);
sample_address <<= 5;
return;

Expand Down Expand Up @@ -1401,7 +1401,7 @@ static INT32 DrvFrame()
VezSetIRQLineAndVector(NEC_INPUT_LINE_INTP0, 0xff, CPU_IRQSTATUS_NONE);
}

nCyclesDone[1] += ZetRun(nCyclesTotal[1] / nInterleave);
nCyclesDone[1] += ZetRun(((i + 1) * nCyclesTotal[1] / nInterleave) - nCyclesDone[1]);
ZetNmi();

if (pBurnSoundOut && i&1) {
Expand Down
Loading

0 comments on commit bf50f42

Please sign in to comment.