More updates to MovieCart to match Stella style.

This commit is contained in:
Stephen Anthony 2021-04-22 16:07:09 -02:30
parent b385907427
commit eed96c6065
1 changed files with 163 additions and 215 deletions

View File

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