mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +00:00
Clarify and slightly improve state machine.
No more using the visible flag to permit a DMA control fetch.
This commit is contained in:
parent
0c6d7e07ee
commit
830704b4a9
@ -611,7 +611,7 @@ template <int cycle, bool stop_if_cpu> bool Chipset::perform_cycle() {
|
||||
constexpr auto sprite_id = (cycle - 0x16) >> 2;
|
||||
static_assert(sprite_id >= 0 && sprite_id < std::tuple_size<decltype(sprites_)>::value);
|
||||
|
||||
if(sprites_[sprite_id].advance_dma(!(cycle&2))) {
|
||||
if(sprites_[sprite_id].advance_dma((~cycle&2) >> 1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -59,35 +59,35 @@ void Sprite::advance_line(int y, bool is_end_of_blank) {
|
||||
}
|
||||
if(is_end_of_blank || y == v_stop_) {
|
||||
dma_state_ = DMAState::FetchControl;
|
||||
visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Sprite::advance_dma(int offset) {
|
||||
if(!visible) return false;
|
||||
assert(offset == 0 || offset == 1);
|
||||
|
||||
// Fetch another word.
|
||||
// Determine which word would be fetched, if DMA occurs.
|
||||
// A bit of a cheat.
|
||||
const uint16_t next_word = ram_[pointer_[0] & ram_mask_];
|
||||
++pointer_[0];
|
||||
|
||||
// Put the fetched word somewhere appropriate and update the DMA state.
|
||||
switch(dma_state_) {
|
||||
// i.e. stopped.
|
||||
default: return false;
|
||||
|
||||
case DMAState::FetchControl:
|
||||
if(offset) {
|
||||
set_stop_and_control(next_word);
|
||||
} else {
|
||||
set_start_position(next_word);
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
|
||||
case DMAState::FetchImage:
|
||||
set_image_data(1 - bool(offset), next_word);
|
||||
return true;
|
||||
if(!visible) return false;
|
||||
set_image_data(1 - offset, next_word);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
// Acknowledge the fetch.
|
||||
++pointer_[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
template <int sprite> void TwoSpriteShifter::load(
|
||||
|
Loading…
x
Reference in New Issue
Block a user