mirror of
https://github.com/FranLMSP/rultra64.git
synced 2026-01-01 07:51:34 -05:00
Struct for RCP and VideoInterface registers
This commit is contained in:
@@ -4,3 +4,4 @@ pub mod mmu;
|
||||
pub mod rom;
|
||||
pub mod rdram;
|
||||
pub mod emulator;
|
||||
pub mod rcp;
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::ops::RangeInclusive;
|
||||
|
||||
use crate::rdram::RDRAM;
|
||||
use crate::rom::ROM;
|
||||
use crate::rcp::RCP;
|
||||
|
||||
pub const KUSEG: RangeInclusive<i64> = 0x00000000..=0x7FFFFFFF;
|
||||
pub const KSEG0: RangeInclusive<i64> = 0x80000000..=0x9FFFFFFF;
|
||||
@@ -39,6 +40,7 @@ pub const EXTERNAL_SYSAD_DEVICE_BUS: RangeInclusive<i64> = 0x80000000..=0xFFF
|
||||
pub struct MMU {
|
||||
rdram: RDRAM,
|
||||
rom: ROM,
|
||||
rcp: RCP,
|
||||
}
|
||||
|
||||
impl MMU {
|
||||
@@ -58,6 +60,7 @@ impl MMU {
|
||||
};
|
||||
Self {
|
||||
rdram: RDRAM::new(),
|
||||
rcp: RCP::new(),
|
||||
rom,
|
||||
}
|
||||
}
|
||||
@@ -141,7 +144,7 @@ impl MMU {
|
||||
} else if MIPS_INTERFACE.contains(&address) {
|
||||
return 0;
|
||||
} else if VIDEO_INTERFACE.contains(&address) {
|
||||
return 0;
|
||||
return self.rcp.video_interface.get_register(address);
|
||||
} else if AUDIO_INTERFACE.contains(&address) {
|
||||
return 0;
|
||||
} else if PERIPHERAL_INTERFACE.contains(&address) {
|
||||
@@ -151,7 +154,7 @@ impl MMU {
|
||||
} else if SERIAL_INTERFACE.contains(&address) {
|
||||
return 0;
|
||||
} else if UNUSED.contains(&address) {
|
||||
return 0;
|
||||
return 0xFF;
|
||||
} else if CARTRIDGE_DOMAIN_2_ADDRESS_1.contains(&address) {
|
||||
return 0;
|
||||
} else if CARTRIDGE_DOMAIN_1_ADDRESS_1.contains(&address) {
|
||||
@@ -189,6 +192,7 @@ impl MMU {
|
||||
} else if RDP_SPAN_REGISTERS.contains(&address) {
|
||||
} else if MIPS_INTERFACE.contains(&address) {
|
||||
} else if VIDEO_INTERFACE.contains(&address) {
|
||||
self.rcp.video_interface.set_register(address, data);
|
||||
} else if AUDIO_INTERFACE.contains(&address) {
|
||||
} else if PERIPHERAL_INTERFACE.contains(&address) {
|
||||
} else if RDRAM_INTERFACE.contains(&address) {
|
||||
|
||||
40
src/rcp.rs
Normal file
40
src/rcp.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
pub struct VideoInterface {
|
||||
registers: [u8; 0x100000],
|
||||
}
|
||||
|
||||
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;
|
||||
// Initialize VI_BURST 0x0440 0014: https://n64brew.dev/wiki/Video_Interface#0x0440_0014_-_VI_BURST
|
||||
registers[0x04400014] = 0x01;
|
||||
// Initialize VI_H_SYNC 0x0440 001C: https://n64brew.dev/wiki/Video_Interface#0x0440_001C_-_VI_H_SYNC
|
||||
registers[0x0440001C] = 0xFF;
|
||||
registers[0x0440001B] = 0x07;
|
||||
Self {
|
||||
registers,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_register(&self, address: i64) -> u8 {
|
||||
self.registers[(address - 0x04400000) as usize]
|
||||
}
|
||||
|
||||
pub fn set_register(&mut self, address: i64, data: u8) {
|
||||
self.registers[(address - 0x04400000) as usize] = data;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RCP {
|
||||
pub video_interface: VideoInterface,
|
||||
}
|
||||
|
||||
impl RCP {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
video_interface: VideoInterface::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user