[BS-X] Support for bigger SatData files

This commit is contained in:
LuigiBlood 2017-12-16 17:52:35 +01:00
parent 54d7fe404d
commit 99e678f049
2 changed files with 26 additions and 8 deletions

33
bsx.cpp
View File

@ -893,7 +893,7 @@ void S9xBSXSetStream1 (uint8 count)
long str1size = BSX.sat_stream1.tellg();
BSX.sat_stream1.seekg(0, BSX.sat_stream1.beg);
float QueueSize = str1size / 22.;
BSX.PPU[0x218A - BSXPPUBASE] = (uint8)(ceil(QueueSize));
BSX.sat_stream1_queue = (uint16)(ceil(QueueSize));
BSX.PPU[0x218D - BSXPPUBASE] = 0;
BSX.sat_stream1_first = TRUE;
BSX.sat_stream1_loaded = TRUE;
@ -925,7 +925,7 @@ void S9xBSXSetStream2 (uint8 count)
long str2size = BSX.sat_stream2.tellg();
BSX.sat_stream2.seekg(0, BSX.sat_stream2.beg);
float QueueSize = str2size / 22.;
BSX.PPU[0x2190 - BSXPPUBASE] = (uint8)(ceil(QueueSize));
BSX.sat_stream2_queue = (uint16)(ceil(QueueSize));
BSX.PPU[0x2193 - BSXPPUBASE] = 0;
BSX.sat_stream2_first = TRUE;
BSX.sat_stream2_loaded = TRUE;
@ -1005,7 +1005,7 @@ uint8 S9xGetBSXPPU (uint16 address)
break;
}
if (BSX.PPU[0x218A - BSXPPUBASE] <= 0)
if (BSX.sat_stream1_queue <= 0)
{
BSX.sat_stream1_count++;
S9xBSXSetStream1(BSX.sat_stream1_count - 1);
@ -1018,7 +1018,14 @@ uint8 S9xGetBSXPPU (uint16 address)
}
if (BSX.sat_stream1_loaded)
{
//Lock at 0x7F for bigger packets
if (BSX.sat_stream1_queue >= 128)
BSX.PPU[0x218A - BSXPPUBASE] = 0x7F;
else
BSX.PPU[0x218A - BSXPPUBASE] = BSX.sat_stream1_queue;
t = BSX.PPU[0x218A - BSXPPUBASE];
}
else
t = 0;
break;
@ -1042,9 +1049,9 @@ uint8 S9xGetBSXPPU (uint16 address)
BSX.sat_stream1_first = FALSE;
}
BSX.PPU[0x218A - BSXPPUBASE]--;
BSX.sat_stream1_queue--;
if (BSX.PPU[0x218A - BSXPPUBASE] == 0)
if (BSX.sat_stream1_queue == 0)
{
//Last packet
temp |= 0x80;
@ -1116,7 +1123,7 @@ uint8 S9xGetBSXPPU (uint16 address)
break;
}
if (BSX.PPU[0x2190 - BSXPPUBASE] <= 0)
if (BSX.sat_stream2_queue <= 0)
{
BSX.sat_stream2_count++;
S9xBSXSetStream2(BSX.sat_stream2_count - 1);
@ -1129,7 +1136,13 @@ uint8 S9xGetBSXPPU (uint16 address)
}
if (BSX.sat_stream2_loaded)
{
if (BSX.sat_stream2_queue >= 128)
BSX.PPU[0x2190 - BSXPPUBASE] = 0x7F;
else
BSX.PPU[0x2190 - BSXPPUBASE] = BSX.sat_stream2_queue;
t = BSX.PPU[0x2190 - BSXPPUBASE];
}
else
t = 0;
break;
@ -1153,9 +1166,9 @@ uint8 S9xGetBSXPPU (uint16 address)
BSX.sat_stream2_first = FALSE;
}
BSX.PPU[0x2190 - BSXPPUBASE]--;
BSX.sat_stream2_queue--;
if (BSX.PPU[0x2190 - BSXPPUBASE] == 0)
if (BSX.sat_stream2_queue == 0)
{
//Last packet
temp |= 0x80;
@ -1488,6 +1501,10 @@ void S9xResetBSX (void)
BSX.MMC[0x07] = BSX.MMC[0x08] = 0x80;
BSX.MMC[0x0E] = 0x80;
// default register values
BSX.PPU[0x2196 - BSXPPUBASE] = 0x10;
BSX.PPU[0x2197 - BSXPPUBASE] = 0x80;
// stream reset
BSX.sat_pf_latch1_enable = BSX.sat_dt_latch1_enable = FALSE;
BSX.sat_pf_latch2_enable = BSX.sat_dt_latch2_enable = FALSE;

1
bsx.h
View File

@ -227,6 +227,7 @@ struct SBSX
bool sat_stream1_loaded, sat_stream2_loaded;
bool sat_stream1_first, sat_stream2_first;
uint8 sat_stream1_count, sat_stream2_count;
uint16 sat_stream1_queue, sat_stream2_queue;
};
extern struct SBSX BSX;