Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable all Framebuffer NTSC / PAL screen modes #32

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion psx/src/framebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ impl Framebuffer {
],
swapped: false,
};
let interlace = match res.1 {
480 | 512 => true,
_ => false
};
GP1::skip_load()
.reset_gpu()
.dma_mode(Some(DMAMode::GP0))
.display_mode(res, video_mode, Depth::Bits15, false)?
.display_mode(res, video_mode, Depth::Bits15, interlace)?
.enable_display(true);
fb.irq_mask.enable_irq(IRQ::Vblank).store();
//fb.wait_vblank();
Expand Down
5 changes: 2 additions & 3 deletions psx/src/gpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,14 @@ impl DispEnv {
offset: (i16, i16), size: (i16, i16), video_mode: VideoMode,
) -> Result<Self, VertexError> {
let offset = Vertex::new(offset);
let size = Vertex::new(size);
let offset = PackedVertex::try_from(offset)?;
let (center, range) = if video_mode == VideoMode::NTSC {
(0x88, 240)
} else {
(0xA3, 256)
};
let ntsc_vrange = Vertex(center - (range / 2), center + (range / 2));
let hrange = Vertex(0x260, 0x260 + (size.0 * 8));
let hrange = Vertex(0x260, 0x260 + (320 * 8));

let horizontal_range = PackedVertex::try_from(hrange)?;
let vertical_range = PackedVertex::try_from(ntsc_vrange)?;
Expand Down Expand Up @@ -245,7 +244,7 @@ impl DrawEnv {
let size = Vertex::new(size);
let bg_color = bg_color.unwrap_or(colors::BLACK);
let upper_left = PackedVertex::try_from(offset)?;
let lower_right = PackedVertex::try_from(offset + size)?;
let lower_right = PackedVertex::try_from(offset + size - Vertex::new((1, 1)))?;
Ok(DrawEnv {
texpage_cmd: 0xE1,
upper_left_cmd: 0xE3,
Expand Down
11 changes: 6 additions & 5 deletions psx/src/hw/gpu/gp1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ impl GP1 {
self
}

/// The x resolution is restricted to 256, 320, 512, 640 or 368. The y
/// resolution is restricted to 240 or 480.
/// The x resolution is restricted to 256, 320, 512, 640 or 368.
/// The y resolution is restricted to 240 or 480 for NTSC,
/// 256 or 512 for PAL.
pub fn display_mode(
&mut self, res: (i16, i16), mode: VideoMode, depth: Depth, interlace: bool,
) -> Result<&mut Self, VertexError> {
Expand All @@ -72,9 +73,9 @@ impl GP1 {
368 => 1 << 6,
_ => return Err(VertexError::InvalidX),
};
let vres = match res.1 {
240 => 0,
480 => 1,
let vres = match (mode, res.1) {
(VideoMode::NTSC, 240) | (VideoMode::PAL, 256) => 0,
(VideoMode::NTSC, 480) | (VideoMode::PAL, 512) => 1,
_ => return Err(VertexError::InvalidY),
};
let settings =
Expand Down
Loading