mirror of https://github.com/stella-emu/stella.git
More updates to MovieCart to match Stella style.
This commit is contained in:
parent
b385907427
commit
eed96c6065
|
@ -634,27 +634,21 @@ static constexpr uInt8 levelBarsOddData[] = {
|
|||
class MovieCart
|
||||
{
|
||||
public:
|
||||
MovieCart() = default;
|
||||
~MovieCart() = default;
|
||||
|
||||
MovieCart();
|
||||
~MovieCart();
|
||||
bool init(const string& path);
|
||||
bool process(uInt16 address);
|
||||
|
||||
bool init(const std::string& path);
|
||||
bool process(uint16_t address);
|
||||
|
||||
uInt8
|
||||
readROM(uint16_t address)
|
||||
{
|
||||
uInt8 readROM(uInt16 address) const {
|
||||
return myROM[address & 1023];
|
||||
}
|
||||
|
||||
void
|
||||
writeROM(uint16_t address, uInt8 data)
|
||||
{
|
||||
void writeROM(uInt16 address, uInt8 data) {
|
||||
myROM[address & 1023] = data;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
Volume,
|
||||
|
@ -663,20 +657,19 @@ private:
|
|||
Last = Time
|
||||
};
|
||||
|
||||
enum TitleState
|
||||
enum class TitleState
|
||||
{
|
||||
Display,
|
||||
Exiting,
|
||||
Stream
|
||||
};
|
||||
|
||||
|
||||
void stopTitleScreen();
|
||||
|
||||
void writeColor(uint16_t address, uint8_t val);
|
||||
void writeAudioData(uint16_t address, uInt8 val);
|
||||
void writeAudio(uint16_t address);
|
||||
void writeGraph(uint16_t address);
|
||||
void writeColor(uInt16 address, uInt8 val);
|
||||
void writeAudioData(uInt16 address, uInt8 val);
|
||||
void writeAudio(uInt16 address);
|
||||
void writeGraph(uInt16 address);
|
||||
|
||||
void runStateMachine();
|
||||
|
||||
|
@ -687,70 +680,54 @@ private:
|
|||
|
||||
void updateTransport();
|
||||
|
||||
|
||||
StreamReader myStream;
|
||||
|
||||
// data
|
||||
|
||||
uInt8 myROM[1024];
|
||||
|
||||
// full line of color
|
||||
uint8_t myColor[10];
|
||||
uInt8 myColor[10];
|
||||
|
||||
// title screen state
|
||||
int myTitleCycles;
|
||||
uInt8 myTitleState;
|
||||
|
||||
int myTitleCycles{0};
|
||||
TitleState myTitleState{TitleState::Display};
|
||||
|
||||
// address info
|
||||
bool myA7;
|
||||
bool myA10;
|
||||
uInt8 myA10_Count;
|
||||
bool myA7{false};
|
||||
bool myA10{false};
|
||||
uInt8 myA10_Count{0};
|
||||
|
||||
// state machine info
|
||||
uInt8 myState{3};
|
||||
bool myPlaying{true};
|
||||
bool myOdd{true};
|
||||
bool myBufferIndex{false};
|
||||
|
||||
uInt8 myState;
|
||||
bool myPlaying;
|
||||
bool myOdd;
|
||||
bool myBufferIndex;
|
||||
uInt8 myLines{0};
|
||||
Int32 myFrameNumber{1}; // signed
|
||||
|
||||
|
||||
uInt8 myLines;
|
||||
int32_t myFrameNumber; // signed
|
||||
|
||||
uInt8 myMode;
|
||||
uInt8 myBright;
|
||||
uInt8 myForceColor;
|
||||
uInt8 myMode{Mode::Volume};
|
||||
uInt8 myBright{DEFAULT_LEVEL};
|
||||
uInt8 myForceColor{0};
|
||||
|
||||
// expressed in frames
|
||||
uInt8 myDrawLevelBars;
|
||||
uInt8 myDrawTimeCode;
|
||||
uInt8 myDrawLevelBars{0};
|
||||
uInt8 myDrawTimeCode{0};
|
||||
|
||||
MovieInputs myInputs;
|
||||
MovieInputs myLastInputs;
|
||||
|
||||
int8_t mySpeed; // signed
|
||||
uInt8 myJoyRepeat;
|
||||
uInt8 myDirectionValue;
|
||||
uInt8 myButtonsValue;
|
||||
|
||||
uInt8 myVolume;
|
||||
const uInt8* myVolumeScale;
|
||||
uInt8 myFirstAudioVal;
|
||||
Int8 mySpeed{1}; // signed
|
||||
uInt8 myJoyRepeat{0};
|
||||
uInt8 myDirectionValue{0};
|
||||
uInt8 myButtonsValue{0};
|
||||
|
||||
uInt8 myVolume{DEFAULT_LEVEL};
|
||||
const uInt8* myVolumeScale{scales[DEFAULT_LEVEL]};
|
||||
uInt8 myFirstAudioVal{0};
|
||||
};
|
||||
|
||||
|
||||
MovieCart::MovieCart()
|
||||
{
|
||||
}
|
||||
|
||||
MovieCart::~MovieCart()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
MovieCart::init(const std::string& path)
|
||||
bool MovieCart::init(const string& path)
|
||||
{
|
||||
memcpy(myROM, kernelROM, 1024);
|
||||
|
||||
|
@ -793,15 +770,13 @@ MovieCart::init(const std::string& path)
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::stopTitleScreen()
|
||||
void MovieCart::stopTitleScreen()
|
||||
{
|
||||
writeROM(addr_title_loop + 0, 0x18); // clear carry, one bit difference from 0x38 sec
|
||||
// clear carry, one bit difference from 0x38 sec
|
||||
writeROM(addr_title_loop + 0, 0x18);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MovieCart::writeColor(uint16_t address, uint8_t v)
|
||||
void MovieCart::writeColor(uInt16 address, uInt8 v)
|
||||
{
|
||||
v = (v & 0xf0) | shiftBright[(v & 0x0f) + myBright];
|
||||
|
||||
|
@ -813,37 +788,28 @@ MovieCart::writeColor(uint16_t address, uint8_t v)
|
|||
writeROM(address, v);
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::writeAudioData(uint16_t address, uInt8 val)
|
||||
void MovieCart::writeAudioData(uInt16 address, uInt8 val)
|
||||
{
|
||||
uInt8 v;
|
||||
v = myVolumeScale[val];
|
||||
writeROM(address, v);
|
||||
writeROM(address, myVolumeScale[val]);
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::writeAudio(uint16_t address)
|
||||
void MovieCart::writeAudio(uInt16 address)
|
||||
{
|
||||
uInt8 v = myStream.readAudio();
|
||||
writeAudioData(address, v);
|
||||
writeAudioData(address, myStream.readAudio());
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::writeGraph(uint16_t address)
|
||||
void MovieCart::writeGraph(uInt16 address)
|
||||
{
|
||||
uInt8 v = myStream.readGraph();
|
||||
writeROM(address, v);
|
||||
writeROM(address, myStream.readGraph());
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::updateTransport()
|
||||
void MovieCart::updateTransport()
|
||||
{
|
||||
myStream.overrideGraph(nullptr);
|
||||
|
||||
|
||||
// have to cut rate in half, to remove glitches...todo..
|
||||
{
|
||||
if (myBufferIndex == true)
|
||||
if(myBufferIndex)
|
||||
{
|
||||
uInt8 temp = ~(myA10_Count & 0x1e) & 0x1e;
|
||||
|
||||
|
@ -903,7 +869,6 @@ MovieCart::updateTransport()
|
|||
mySpeed = 1;
|
||||
}
|
||||
|
||||
|
||||
if(myJoyRepeat & 16)
|
||||
{
|
||||
myJoyRepeat = 0;
|
||||
|
@ -950,7 +915,6 @@ MovieCart::updateTransport()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if(myInputs.select && !myLastInputs.select)
|
||||
{
|
||||
myDrawTimeCode = OSD_FRAMES;
|
||||
|
@ -990,8 +954,7 @@ MovieCart::updateTransport()
|
|||
myVolumeScale = scales[0];
|
||||
|
||||
// update frame
|
||||
|
||||
int8_t step = 1;
|
||||
Int8 step = 1;
|
||||
|
||||
if(!myPlaying) // step while paused
|
||||
{
|
||||
|
@ -1034,8 +997,7 @@ MovieCart::updateTransport()
|
|||
myLastInputs = myInputs;
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::fill_addr_right_line()
|
||||
void MovieCart::fill_addr_right_line()
|
||||
{
|
||||
writeAudio(addr_set_aud_right + 1);
|
||||
|
||||
|
@ -1053,8 +1015,7 @@ MovieCart::fill_addr_right_line()
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::fill_addr_left_line(bool again)
|
||||
void MovieCart::fill_addr_left_line(bool again)
|
||||
{
|
||||
writeAudio(addr_set_aud_left + 1);
|
||||
|
||||
|
@ -1064,7 +1025,7 @@ MovieCart::fill_addr_left_line(bool again)
|
|||
writeGraph(addr_set_gdata3 + 1);
|
||||
writeGraph(addr_set_gdata4 + 1);
|
||||
|
||||
for (int i=0; i<10; i++)
|
||||
for(int i = 0; i < 10; ++i)
|
||||
myColor[i] = myStream.readColor();
|
||||
|
||||
writeColor(addr_set_gcol0 + 1, myColor[3]); // col 0/9
|
||||
|
@ -1088,9 +1049,7 @@ MovieCart::fill_addr_left_line(bool again)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MovieCart::fill_addr_end_lines()
|
||||
void MovieCart::fill_addr_end_lines()
|
||||
{
|
||||
writeAudio(addr_set_aud_endlines + 1);
|
||||
|
||||
|
@ -1110,7 +1069,7 @@ MovieCart::fill_addr_end_lines()
|
|||
writeROM(addr_set_vblank_size + 1, 37);
|
||||
}
|
||||
|
||||
if (myBufferIndex == false)
|
||||
if(!myBufferIndex)
|
||||
{
|
||||
writeROM(addr_pick_transport + 1, LO_JUMP_BYTE(addr_transport_direction));
|
||||
writeROM(addr_pick_transport + 2, HI_JUMP_BYTE(addr_transport_direction));
|
||||
|
@ -1123,12 +1082,8 @@ MovieCart::fill_addr_end_lines()
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::fill_addr_blank_lines()
|
||||
void MovieCart::fill_addr_blank_lines()
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t v;
|
||||
|
||||
// version number
|
||||
myStream.readVersion();
|
||||
myStream.readVersion();
|
||||
|
@ -1138,7 +1093,7 @@ MovieCart::fill_addr_blank_lines()
|
|||
// frame number
|
||||
myStream.readFrame();
|
||||
myStream.readFrame();
|
||||
v = myStream.readFrame();
|
||||
uInt8 v = myStream.readFrame();
|
||||
|
||||
// make sure we're in sync with frame data
|
||||
myOdd = (v & 1);
|
||||
|
@ -1150,18 +1105,17 @@ MovieCart::fill_addr_blank_lines()
|
|||
if(myOdd)
|
||||
{
|
||||
writeAudioData(addr_audio_bank + 0, myFirstAudioVal);
|
||||
for (i = 1; i < (BLANK_LINE_SIZE + 1); i++)
|
||||
for(uInt8 i = 1; i < (BLANK_LINE_SIZE + 1); i++)
|
||||
writeAudio(addr_audio_bank + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < (BLANK_LINE_SIZE -1); i++)
|
||||
for(uInt8 i = 0; i < (BLANK_LINE_SIZE -1); i++)
|
||||
writeAudio(addr_audio_bank + i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MovieCart::runStateMachine()
|
||||
void MovieCart::runStateMachine()
|
||||
{
|
||||
switch(myState)
|
||||
{
|
||||
|
@ -1214,7 +1168,7 @@ MovieCart::runStateMachine()
|
|||
{
|
||||
if(myDrawLevelBars)
|
||||
{
|
||||
uInt8 levelValue;
|
||||
uInt8 levelValue = 0;
|
||||
|
||||
switch(myMode)
|
||||
{
|
||||
|
@ -1246,7 +1200,6 @@ MovieCart::runStateMachine()
|
|||
}
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
if(!myA7)
|
||||
{
|
||||
|
@ -1277,7 +1230,8 @@ MovieCart::runStateMachine()
|
|||
if(myA7)
|
||||
{
|
||||
// hit end? rewind just before end
|
||||
while (myFrameNumber >= 2 && !myStream.readField(myFrameNumber, myBufferIndex))
|
||||
while (myFrameNumber >= 2 &&
|
||||
!myStream.readField(myFrameNumber, myBufferIndex))
|
||||
{
|
||||
myFrameNumber -= 2;
|
||||
myJoyRepeat = 0;
|
||||
|
@ -1294,10 +1248,8 @@ MovieCart::runStateMachine()
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MovieCart::process(uint16_t address)
|
||||
bool MovieCart::process(uInt16 address)
|
||||
{
|
||||
|
||||
bool a12 = (address & (1 << 12)) ? 1:0;
|
||||
bool a11 = (address & (1 << 11)) ? 1:0;
|
||||
|
||||
|
@ -1362,10 +1314,6 @@ void CartridgeMVC::install(System& system)
|
|||
|
||||
// Map all of the accesses to call peek and poke
|
||||
System::PageAccess access(this, System::PageAccessType::READWRITE);
|
||||
|
||||
access.directPeekBase = nullptr;
|
||||
access.directPokeBase = nullptr;
|
||||
|
||||
for(uInt16 addr = 0x1000; addr < 0x2000; addr += System::PAGE_SIZE)
|
||||
mySystem->setPageAccess(addr, access);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue