Skip to content

Instantly share code, notes, and snippets.

@simias
Created June 12, 2016 23:50
Show Gist options
  • Select an option

  • Save simias/fe48ca10f76f4c67042db79b1b10fde0 to your computer and use it in GitHub Desktop.

Select an option

Save simias/fe48ca10f76f4c67042db79b1b10fde0 to your computer and use it in GitHub Desktop.
//! This file is automatically generated using psxunittest:
//! https://github.com/daeken/psxunittest
//!
//! /!\ DO NOT EDIT DIRECTLY /!\
use gpu::{Gpu, VideoClock};
use memory::{Interconnect, Addressable};
use memory;
use bios::Bios;
use super::Cpu;
fn load_blob(cpu: &mut Cpu,
load_address: u32,
blob: &[u32]) {
let ram = cpu.interconnect_mut().ram_mut();
for (i, &w) in blob.iter().enumerate() {
ram.store::<memory::Word>(load_address + i as u32, w);
}
}
fn load<T: Addressable>(cpu: &mut Cpu,
load_address: u32,
v: u32) {
let ram = cpu.interconnect_mut().ram_mut();
ram.store::<T>(load_address, v);
}
#[test]
fn test_beq() {
let bios = Bios::dummy();
let gpu = Gpu::new(VideoClock::Ntsc);
let inter = Interconnect::new(bios, gpu, None);
let mut cpu = Cpu::new(inter);
cpu.regs[1] = 0x1;
cpu.regs[2] = 0x2;
cpu.regs[3] = -1i32 as u32;
cpu.regs[4] = 0xffffffff;
load_blob(&mut cpu, 0x80100000,
&[0x10220005,
0x00000000,
0x200a0001,
0x10640004,
0x00000000,
0x200b0001,
0x200a0002,
0x00000000,
0x00000000,
0x0bab6fb8,
0x00000000]);
}
#[test]
fn test_branch_in_branch_delay() {
let bios = Bios::dummy();
let gpu = Gpu::new(VideoClock::Ntsc);
let inter = Interconnect::new(bios, gpu, None);
let mut cpu = Cpu::new(inter);
load_blob(&mut cpu, 0x80100000,
&[0x10000002,
0x10000004,
0x20030001,
0x20010001,
0x10000002,
0x00000000,
0x20020001,
0x00000000,
0x0bab6fb8,
0x00000000]);
}
#[test]
fn test_add_1() {
let bios = Bios::dummy();
let gpu = Gpu::new(VideoClock::Ntsc);
let inter = Interconnect::new(bios, gpu, None);
let mut cpu = Cpu::new(inter);
cpu.regs[1] = 0xa;
cpu.regs[2] = -15i32 as u32;
load_blob(&mut cpu, 0x80100000,
&[0x00201820,
0x00222020,
0x00412820,
0x00423020,
0x0bab6fb8,
0x00000000]);
}
#[test]
fn test_arithmetic_branching_test() {
let bios = Bios::dummy();
let gpu = Gpu::new(VideoClock::Ntsc);
let inter = Interconnect::new(bios, gpu, None);
let mut cpu = Cpu::new(inter);
cpu.regs[2] = 0xdead;
cpu.regs[3] = 0;
cpu.regs[5] = 0x1;
load_blob(&mut cpu, 0x80100000,
&[0x00451023,
0x24630001,
0x1c40fffd,
0x00000000,
0x0bab6fb8,
0x00000000]);
}
#[test]
fn test_unaligned_loads() {
let bios = Bios::dummy();
let gpu = Gpu::new(VideoClock::Ntsc);
let inter = Interconnect::new(bios, gpu, None);
let mut cpu = Cpu::new(inter);
load::<memory::Word>(&mut cpu, 48864, 0xdeadbeef);
cpu.regs[30] = 0xbee1;
load_blob(&mut cpu, 0x80100000,
&[0x83c10000,
0x93c20000,
0x0bab6fb8,
0x00000000]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment