Skip to content

Commit 60c9523

Browse files
Wack0dingusdev
authored andcommitted
atimach64gx: Don't allow pitch to be zero.
1 parent 130beab commit 60c9523

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

devices/video/atimach64gx.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,13 @@ void AtiMach64Gx::crtc_update()
703703

704704
static uint8_t bits_per_pixel[8] = {0, 0, 4, 8, 16, 24, 32, 0};
705705

706-
int new_fb_pitch = extract_bits<uint32_t>(this->regs[ATI_CRTC_OFF_PITCH],
707-
ATI_CRTC_PITCH, ATI_CRTC_PITCH_size) * bits_per_pixel[this->pixel_format];
706+
int new_fb_pitch_reg = extract_bits<uint32_t>(this->regs[ATI_CRTC_OFF_PITCH],
707+
ATI_CRTC_PITCH, ATI_CRTC_PITCH_size);
708+
// HACK: should not be zero!
709+
if (new_fb_pitch_reg == 0) {
710+
new_fb_pitch_reg = active_width / 8; // "Display pitch in pixels * 8"
711+
}
712+
int new_fb_pitch = new_fb_pitch_reg * bits_per_pixel[this->pixel_format];
708713
if (new_fb_pitch != this->fb_pitch) {
709714
this->fb_pitch = new_fb_pitch;
710715
need_recalc = true;

0 commit comments

Comments
 (0)