mirror of
https://github.com/FranLMSP/rultra64.git
synced 2026-01-01 07:51:34 -05:00
Small fixes
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ impl Emulator {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tick(&mut self) {
|
||||
pub fn tick(&mut self, _framebuffer: &mut [u8]) {
|
||||
self.cpu.fetch_and_exec_opcode(&mut self.mmu);
|
||||
}
|
||||
}
|
||||
@@ -69,8 +69,8 @@ impl MMU {
|
||||
let mut mmu = Self::new();
|
||||
// Skip IPL1 and IPL2
|
||||
for i in 0..0x1000 {
|
||||
let byte = mmu.read_virtual(0x10001000 + i, 1);
|
||||
mmu.write_virtual(0x00001000 + i, vec![byte]);
|
||||
let byte = mmu.read_virtual(0xB0000000 + i, 1);
|
||||
mmu.write_virtual(0xA4000000 + i, &byte);
|
||||
}
|
||||
// Skip IPL3
|
||||
for i in 0..0x100000 {
|
||||
|
||||
42
src/rcp.rs
42
src/rcp.rs
@@ -1,3 +1,5 @@
|
||||
use crate::rdram::RDRAM;
|
||||
|
||||
pub struct VideoInterface {
|
||||
registers: [u8; 0x100000],
|
||||
}
|
||||
@@ -6,13 +8,13 @@ impl VideoInterface {
|
||||
pub fn new() -> Self {
|
||||
let mut registers = [0; 0x100000];
|
||||
// Initialize VI_V_INTR 0x0440 000C: https://n64brew.dev/wiki/Video_Interface#0x0440_000C_-_VI_V_INTR
|
||||
registers[0x0440000C] = 0xFF;
|
||||
registers[0x0440000B] = 0x03;
|
||||
registers[0x0440000C - 0x04400000] = 0xFF;
|
||||
registers[0x0440000B - 0x04400000] = 0x03;
|
||||
// Initialize VI_BURST 0x0440 0014: https://n64brew.dev/wiki/Video_Interface#0x0440_0014_-_VI_BURST
|
||||
registers[0x04400014] = 0x01;
|
||||
registers[0x04400014 - 0x04400000] = 0x01;
|
||||
// Initialize VI_H_SYNC 0x0440 001C: https://n64brew.dev/wiki/Video_Interface#0x0440_001C_-_VI_H_SYNC
|
||||
registers[0x0440001C] = 0xFF;
|
||||
registers[0x0440001B] = 0x07;
|
||||
registers[0x0440001C - 0x04400000] = 0xFF;
|
||||
registers[0x0440001B - 0x04400000] = 0x07;
|
||||
Self {
|
||||
registers,
|
||||
}
|
||||
@@ -25,6 +27,28 @@ impl VideoInterface {
|
||||
pub fn set_register(&mut self, address: i64, data: u8) {
|
||||
self.registers[(address - 0x04400000) as usize] = data;
|
||||
}
|
||||
|
||||
/*
|
||||
RDRAM base address of the video output Frame Buffer. This can be changed as needed to implement double or triple buffering.
|
||||
https://n64brew.dev/wiki/Video_Interface#0x0440_0004_-_VI_ORIGIN
|
||||
*/
|
||||
pub fn get_vi_origin(&self) -> u32 {
|
||||
((self.get_register(0x04400005) as u32) << 16) | ((self.get_register(0x04400006) as u32) << 8) | (self.get_register(0x04400007) as u32)
|
||||
}
|
||||
|
||||
/*
|
||||
This is the width in pixels of the frame buffer if you draw to the frame buffer based on a different width than what
|
||||
is given here the image will drift with each line to the left or right. The common values are 320 and 640,
|
||||
the maximum value is 640. The minimum value depends on the TV set, 160 would probably be a safe minimum but no guarantee.
|
||||
The same value would also be used on drawing commands for clipping or scissors.
|
||||
This can also be used with High Res interlacing modes to change the odd and even lines of the frame buffer to be drawn
|
||||
to screen by doubling the width of this value and changing the VI_ORIGIN register to the odd or even field being displayed.
|
||||
RDRAM base address of the video output Frame Buffer. This can be changed as needed to implement double or triple buffering.
|
||||
https://n64brew.dev/wiki/Video_Interface#0x0440_0008_-_VI_WIDTH
|
||||
*/
|
||||
pub fn get_vi_width(&self) -> u16 {
|
||||
(((self.get_register(0x04400010) as u16) << 8) & 0b1111) | (self.get_register(0x04400011) as u16)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RCP {
|
||||
@@ -37,4 +61,12 @@ impl RCP {
|
||||
video_interface: VideoInterface::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_framebuffer(&self, rdram: &RDRAM, dest: &mut [u8]) {
|
||||
let mut addr = self.video_interface.get_vi_origin() as i64;
|
||||
for elem in dest {
|
||||
*elem = rdram.read8(addr);
|
||||
addr += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user