diff --git a/devices/video/atimach64gx.cpp b/devices/video/atimach64gx.cpp index a4ec6f4..310ed05 100644 --- a/devices/video/atimach64gx.cpp +++ b/devices/video/atimach64gx.cpp @@ -378,8 +378,7 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size) break; case ATI_CRTC_OFF_PITCH: new_value = value; - this->fb_pitch = extract_bits(new_value, ATI_CRTC_PITCH, ATI_CRTC_PITCH_size) * 8; - this->fb_ptr = &this->vram_ptr[extract_bits(new_value, ATI_CRTC_OFFSET, ATI_CRTC_OFFSET_size) * 8]; + this->crtc_update(); return; case ATI_CRTC_INT_CNTL: { @@ -609,6 +608,19 @@ void AtiMach64Gx::crtc_update() need_recalc = true; } + static uint8_t bits_per_pixel[8] = {0, 0, 4, 8, 16, 24, 32, 0}; + + int new_fb_pitch = extract_bits(this->regs[ATI_CRTC_OFF_PITCH], ATI_CRTC_PITCH, ATI_CRTC_PITCH_size) * bits_per_pixel[this->pixel_format]; + if (new_fb_pitch != this->fb_pitch) { + this->fb_pitch = new_fb_pitch; + need_recalc = true; + } + uint8_t* new_fb_ptr = &this->vram_ptr[extract_bits(this->regs[ATI_CRTC_OFF_PITCH], ATI_CRTC_OFFSET, ATI_CRTC_OFFSET_size) * 8]; + if (new_fb_ptr != this->fb_ptr) { + this->fb_ptr = new_fb_ptr; + need_recalc = true; + } + // pixel clock = source_freq / post_div int m = 8 >> (this->dac_regs[Rgb514::F0_M0] >> 6); int vco_div = (this->dac_regs[Rgb514::F0_M0] & 0x3F) + 65;