1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-28 07:29:45 +00:00

Attempt real blank reporting.

This commit is contained in:
Thomas Harte 2023-01-20 22:29:49 -05:00
parent 9b7a925816
commit 191cf4829b
2 changed files with 30 additions and 10 deletions

View File

@ -292,7 +292,7 @@ void TMS9918<personality>::run_for(const HalfCycles cycles) {
if( if(
(this->screen_mode_ == ScreenMode::Blank) || (this->screen_mode_ == ScreenMode::Blank) ||
(this->fetch_pointer_.row >= this->mode_timing_.pixel_lines && this->fetch_pointer_.row != this->mode_timing_.total_lines-1)) this->is_vertical_blank())
next_line_buffer.line_mode = LineMode::Refresh; next_line_buffer.line_mode = LineMode::Refresh;
} }
} }
@ -521,7 +521,7 @@ void Base<personality>::output_border(int cycles, [[maybe_unused]] uint32_t cram
// MARK: - External interface. // MARK: - External interface.
template <Personality personality> template <Personality personality>
int Base<personality>::masked_address(int address) { int Base<personality>::masked_address(int address) const {
if constexpr (is_yamaha_vdp(personality)) { if constexpr (is_yamaha_vdp(personality)) {
return address & 3; return address & 3;
} else { } else {
@ -728,9 +728,9 @@ uint8_t Base<personality>::read_register() {
// b1 = display field odd/even // b1 = display field odd/even
// b0 = command ongoing // b0 = command ongoing
return return
queued_access_ == MemoryAccess::None ? 0x80 : 0x00 | (queued_access_ == MemoryAccess::None ? 0x80 : 0x00) |
0x40 | (is_vertical_blank() ? 0x40 : 0x00) |
0x20; (is_horizontal_blank() ? 0x20 : 0x00);
break; break;
} }
@ -772,13 +772,29 @@ uint8_t TMS9918<personality>::read(int address) {
// MARK: - Ephemeral state. // MARK: - Ephemeral state.
template <Personality personality> template <Personality personality>
uint8_t TMS9918<personality>::get_current_line() const { int Base<personality>::fetch_line() const {
// Determine the row to return. // This is the proper Master System value; TODO: what's correct for Yamaha, etc?
constexpr int row_change_position = 63; // This is the proper Master System value; substitute if any other VDPs turn out to have this functionality. constexpr int row_change_position = 63;
int source_row =
return
(this->fetch_pointer_.column < row_change_position) (this->fetch_pointer_.column < row_change_position)
? (this->fetch_pointer_.row + this->mode_timing_.total_lines - 1) % this->mode_timing_.total_lines ? (this->fetch_pointer_.row + this->mode_timing_.total_lines - 1) % this->mode_timing_.total_lines
: this->fetch_pointer_.row; : this->fetch_pointer_.row;
}
template <Personality personality>
bool Base<personality>::is_vertical_blank() const {
return fetch_pointer_.row >= mode_timing_.pixel_lines && fetch_pointer_.row != mode_timing_.total_lines - 1;
}
template <Personality personality>
bool Base<personality>::is_horizontal_blank() const {
return fetch_pointer_.column < StandardTiming<personality>::FirstPixelCycle;
}
template <Personality personality>
uint8_t TMS9918<personality>::get_current_line() const {
int source_row = this->fetch_line();
if(this->tv_standard_ == TVStandard::NTSC) { if(this->tv_standard_ == TVStandard::NTSC) {
if(this->mode_timing_.pixel_lines == 240) { if(this->mode_timing_.pixel_lines == 240) {

View File

@ -302,7 +302,11 @@ template <Personality personality> struct Base: public Storage<personality> {
// with the beginning of writing the next, hence the two separate line buffers. // with the beginning of writing the next, hence the two separate line buffers.
LineBufferPointer output_pointer_, fetch_pointer_; LineBufferPointer output_pointer_, fetch_pointer_;
int masked_address(int address); int fetch_line() const;
bool is_vertical_blank() const;
bool is_horizontal_blank() const;
int masked_address(int address) const;
void write_vram(uint8_t); void write_vram(uint8_t);
void write_register(uint8_t); void write_register(uint8_t);
void write_palette(uint8_t); void write_palette(uint8_t);