1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-11 08:30:55 +00:00

Apply clock conversion to existing usages of do_external_slot.

This commit is contained in:
Thomas Harte 2023-01-09 13:54:49 -05:00
parent 4d9d684618
commit c0fe88a5bb
2 changed files with 21 additions and 9 deletions

View File

@ -182,6 +182,24 @@ template <Personality personality> class ClockConverter {
}
}
/*!
Converts a position in TMS access cycles back to one at the native
clock rate.
*/
static constexpr int from_tms_access_clock(int source) {
switch(personality) {
default:
return source << 1;
case Personality::V9938:
case Personality::V9958:
return source << 3;
case Personality::MDVDP:
return source * 20;
}
}
/*!
Converts a position in internal cycles to its corresponding position
on the TMS pixel clock, i.e. scales to 342 clocks per line.

View File

@ -41,19 +41,13 @@
for the exceptions.
*/
// TODO: external_slot needs to do a proper conversion back to the internal clock,
// not assume a multiply by two.
//
// (and, for MSX 2 purposes, it would ideally know how many cycles since the last access
// slot, probably, but I'm not completely sure that's necessary yet)
#define slot(n) \
if(use_end && end == n) return; \
[[fallthrough]]; \
case n
#define external_slot(n) \
slot(n): do_external_slot((n)*2);
slot(n): do_external_slot(clock_converter_.from_tms_access_clock(n));
#define external_slots_2(n) \
external_slot(n); \
@ -286,7 +280,7 @@ template<bool use_end> void Base<personality>::fetch_tms_character(int start, in
slot(31):
sprite_selection_buffer.reset_sprite_collection();
do_external_slot(31*2);
do_external_slot(clock_converter_.from_tms_access_clock(31));
external_slots_2(32);
external_slot(34);
@ -437,7 +431,7 @@ template<bool use_end> void Base<personality>::fetch_sms(int start, int end) {
slot(29):
sprite_selection_buffer.reset_sprite_collection();
do_external_slot(29*2);
do_external_slot(clock_converter_.from_tms_access_clock(29));
external_slot(30);
sprite_y_read(31, 0);