From c8dc5e2db9aa209fc647243022e05de11f5d1dd6 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Wed, 16 Nov 2016 23:19:54 +0100 Subject: [PATCH] Fix delay queue, add delay to pfx writes. --- src/emucore/tia/core_6502ts/DelayQueue.cxx | 3 +- src/emucore/tia/core_6502ts/DelayQueue.hxx | 2 +- .../tia/core_6502ts/DelayQueueMember.cxx | 4 +- .../tia/core_6502ts/DelayQueueMember.hxx | 2 +- src/emucore/tia/core_6502ts/TIA.cxx | 55 ++++++++++++++----- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/emucore/tia/core_6502ts/DelayQueue.cxx b/src/emucore/tia/core_6502ts/DelayQueue.cxx index 5229593a5..1f66d226c 100644 --- a/src/emucore/tia/core_6502ts/DelayQueue.cxx +++ b/src/emucore/tia/core_6502ts/DelayQueue.cxx @@ -29,8 +29,7 @@ DelayQueue::DelayQueue(uInt8 length, uInt8 size) for (uInt16 i = 0; i < length; i++) myMembers.emplace_back(size); - for (uInt8& i : myIndices) - i = 0xFF; + memset(myIndices, 0xFF, 0xFF); } void DelayQueue::push(uInt8 address, uInt8 value, uInt8 delay) diff --git a/src/emucore/tia/core_6502ts/DelayQueue.hxx b/src/emucore/tia/core_6502ts/DelayQueue.hxx index 59705fd9d..71086f63c 100644 --- a/src/emucore/tia/core_6502ts/DelayQueue.hxx +++ b/src/emucore/tia/core_6502ts/DelayQueue.hxx @@ -71,7 +71,7 @@ template void DelayQueue::execute(T executor) { currentMember.clear(); - myIndex = (myIndex + 1) & myMembers.size(); + myIndex = (myIndex + 1) % myMembers.size(); } } // namespace TIA6502tsCore diff --git a/src/emucore/tia/core_6502ts/DelayQueueMember.cxx b/src/emucore/tia/core_6502ts/DelayQueueMember.cxx index fba037744..f853a6ea5 100644 --- a/src/emucore/tia/core_6502ts/DelayQueueMember.cxx +++ b/src/emucore/tia/core_6502ts/DelayQueueMember.cxx @@ -21,8 +21,8 @@ namespace TIA6502tsCore { -DelayQueueMember::DelayQueueMember(uInt8 capacity) - : myEntries(capacity), +DelayQueueMember::DelayQueueMember(uInt8 size) + : myEntries(size), mySize(0) {} diff --git a/src/emucore/tia/core_6502ts/DelayQueueMember.hxx b/src/emucore/tia/core_6502ts/DelayQueueMember.hxx index 68d6f3fc2..b3a358664 100644 --- a/src/emucore/tia/core_6502ts/DelayQueueMember.hxx +++ b/src/emucore/tia/core_6502ts/DelayQueueMember.hxx @@ -35,7 +35,7 @@ class DelayQueueMember { public: - DelayQueueMember(uInt8 capacity); + DelayQueueMember(uInt8 size); DelayQueueMember(DelayQueueMember&&) = default; diff --git a/src/emucore/tia/core_6502ts/TIA.cxx b/src/emucore/tia/core_6502ts/TIA.cxx index f1dca641b..3c0ae98bd 100644 --- a/src/emucore/tia/core_6502ts/TIA.cxx +++ b/src/emucore/tia/core_6502ts/TIA.cxx @@ -22,12 +22,23 @@ #include "M6502.hxx" enum CollisionMask : uInt32 { - player0 = 0b0111110000000000, - player1 = 0b0100001111000000, - missile0 = 0b0010001000111000, - missile1 = 0b0001000100100110, - ball = 0b0000100010010101, - playfield = 0b0000010001001011 + player0 = 0b0111110000000000, + player1 = 0b0100001111000000, + missile0 = 0b0010001000111000, + missile1 = 0b0001000100100110, + ball = 0b0000100010010101, + playfield = 0b0000010001001011 +}; + +enum Delay: uInt8 { + hmove = 6, + pf = 2, + grp = 1, + shufflePlayer = 1, + hmp = 2, + hmm = 2, + hmbl = 2, + hmclr = 2 }; namespace TIA6502tsCore { @@ -174,20 +185,17 @@ bool TIA::poke(uInt16 address, uInt8 value) break; case PF0: - myLinesSinceChange = 0; - myPlayfield.pf0(value); + myDelayQueue.push(PF0, value, Delay::pf); break; case PF1: - myLinesSinceChange = 0; - myPlayfield.pf1(value); + myDelayQueue.push(PF1, value, Delay::pf); break; case PF2: - myLinesSinceChange = 0; - myPlayfield.pf2(value); + myDelayQueue.push(PF2, value, Delay::pf); break; } @@ -464,8 +472,27 @@ void TIA::onFrameStart() myCurrentFrameBuffer.swap(myPreviousFrameBuffer); } -// TODO: stub void TIA::delayedWrite(uInt8 address, uInt8 value) -{} +{ + switch (address) { + case PF0: + myLinesSinceChange = 0; + myPlayfield.pf0(value); + + break; + + case PF1: + myLinesSinceChange = 0; + myPlayfield.pf1(value); + + break; + + case PF2: + myLinesSinceChange = 0; + myPlayfield.pf2(value); + + break; + } +} } // namespace TIA6502tsCore \ No newline at end of file