mirror of
https://github.com/liuk7071/ChonkyStation.git
synced 2024-05-20 12:57:52 -04:00
[Interrupt] Rename INTC to Interrupt and move interrupt files to the cpu folder
This commit is contained in:
parent
82a054f4e9
commit
405ca405a1
|
@ -8,7 +8,6 @@ add_subdirectory(src)
|
|||
|
||||
include_directories(src/common)
|
||||
include_directories(src/cpu)
|
||||
include_directories(src/intc)
|
||||
include_directories(src/memory)
|
||||
include_directories(src/dma)
|
||||
include_directories(src/gpu)
|
||||
|
|
|
@ -4,8 +4,7 @@ set(SOURCE_FILES
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/cpu.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/backends/interpreter/interpreter.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/backends/old_interpreter/old_interpreter.cpp"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/intc/intc.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/interrupt.cpp"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/disassembler/disassembler.cpp"
|
||||
|
||||
|
@ -25,8 +24,7 @@ set(HEADER_FILES
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/cpu.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/backends/interpreter/interpreter.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/backends/old_interpreter/old_interpreter.hpp"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/intc/intc.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/interrupt.hpp"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/disassembler/disassembler.hpp"
|
||||
|
||||
|
|
18
src/cpu/interrupt.cpp
Normal file
18
src/cpu/interrupt.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <interrupt.hpp>
|
||||
|
||||
|
||||
void Interrupt::writeImask(u16 data) {
|
||||
imask = data;
|
||||
}
|
||||
|
||||
void Interrupt::writeIstat(u16 data) {
|
||||
istat &= data;
|
||||
}
|
||||
|
||||
u16 Interrupt::readImask() {
|
||||
return imask;
|
||||
}
|
||||
|
||||
u16 Interrupt::readIstat() {
|
||||
return istat;
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
#include <helpers.hpp>
|
||||
|
||||
|
||||
class INTC {
|
||||
class Interrupt {
|
||||
public:
|
||||
void writeImask(u16 data);
|
||||
void writeIstat(u16 data);
|
|
@ -1,18 +0,0 @@
|
|||
#include <intc.hpp>
|
||||
|
||||
|
||||
void INTC::writeImask(u16 data) {
|
||||
imask = data;
|
||||
}
|
||||
|
||||
void INTC::writeIstat(u16 data) {
|
||||
istat &= data;
|
||||
}
|
||||
|
||||
u16 INTC::readImask() {
|
||||
return imask;
|
||||
}
|
||||
|
||||
u16 INTC::readIstat() {
|
||||
return istat;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
#include <memory.hpp>
|
||||
|
||||
|
||||
Memory::Memory(INTC* intc, DMA* dma, Gpu* gpu) : intc(intc), dma(dma), gpu(gpu) {
|
||||
Memory::Memory(Interrupt* interrupt, DMA* dma, Gpu* gpu) : interrupt(interrupt), dma(dma), gpu(gpu) {
|
||||
std::memset(ram, 0, 2MB);
|
||||
std::memset(scratchpad, 0, 1KB);
|
||||
|
||||
|
@ -82,8 +82,8 @@ u16 Memory::read(u32 vaddr) {
|
|||
|
||||
u32 paddr = maskAddress(vaddr);
|
||||
|
||||
// INTC
|
||||
if (paddr == 0x1f801074) return intc->readImask();
|
||||
// Interrupt
|
||||
if (paddr == 0x1f801074) return interrupt->readImask();
|
||||
// SPU
|
||||
else if (Helpers::inRangeSized<u32>(paddr, (u32)MemoryBase::SPU, (u32)MemorySize::SPU)) return 0;
|
||||
else
|
||||
|
@ -104,8 +104,8 @@ u32 Memory::read(u32 vaddr) {
|
|||
|
||||
// GPU
|
||||
if (paddr == 0x1f801814) return gpu->getStat();
|
||||
// INTC
|
||||
else if (paddr == 0x1f801074) return intc->readImask();
|
||||
// Interrupt
|
||||
else if (paddr == 0x1f801074) return interrupt->readImask();
|
||||
// DMA
|
||||
else if (Helpers::inRange<u32>(paddr, 0x1f801080, 0x1f8010e8)) {
|
||||
const auto channel = ((paddr >> 4) & 0xf) - 8;
|
||||
|
@ -156,8 +156,8 @@ void Memory::write(u32 vaddr, u16 data) {
|
|||
|
||||
u32 paddr = maskAddress(vaddr);
|
||||
|
||||
// INTC
|
||||
if (paddr == 0x1f801074) intc->writeImask(data);
|
||||
// Interrupt
|
||||
if (paddr == 0x1f801074) interrupt->writeImask(data);
|
||||
// SPU
|
||||
else if (Helpers::inRangeSized<u32>(paddr, (u32)MemoryBase::SPU, (u32)MemorySize::SPU)) return;
|
||||
// Timers
|
||||
|
@ -181,9 +181,9 @@ void Memory::write(u32 vaddr, u32 data) {
|
|||
|
||||
// GPU
|
||||
if (paddr == 0x1f801810) gpu->writeGp0(data);
|
||||
// INTC
|
||||
else if (paddr == 0x1f801070) intc->writeIstat(data);
|
||||
else if (paddr == 0x1f801074) intc->writeImask(data);
|
||||
// Interrupt
|
||||
else if (paddr == 0x1f801070) interrupt->writeIstat(data);
|
||||
else if (paddr == 0x1f801074) interrupt->writeImask(data);
|
||||
// DMA
|
||||
else if (Helpers::inRange<u32>(paddr, 0x1f801080, 0x1f8010e8)) {
|
||||
const auto channel = ((paddr >> 4) & 0xf) - 8;
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include <helpers.hpp>
|
||||
#include <intc.hpp>
|
||||
#include <interrupt.hpp>
|
||||
#include <dma.hpp>
|
||||
#include <gpu.hpp>
|
||||
|
||||
|
||||
class Memory {
|
||||
public:
|
||||
Memory(INTC* intc, DMA* dma, Gpu* gpu);
|
||||
Memory(Interrupt* interrupt, DMA* dma, Gpu* gpu);
|
||||
void loadBios(const fs::path& biosPath);
|
||||
|
||||
u8* ram = new u8[2MB];
|
||||
u8* scratchpad = new u8[1KB];
|
||||
u8* bios = new u8[512KB];
|
||||
|
||||
INTC* intc;
|
||||
Interrupt* interrupt;
|
||||
DMA* dma;
|
||||
Gpu* gpu;
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
#include <helpers.hpp>
|
||||
#include <cpu.hpp>
|
||||
#include <memory.hpp>
|
||||
#include <intc.hpp>
|
||||
#include <interrupt.hpp>
|
||||
#include <dma.hpp>
|
||||
#include <gpu.hpp>
|
||||
|
||||
|
||||
class PlayStation {
|
||||
public:
|
||||
PlayStation(const fs::path& biosPath) : intc(), gpu(), dma(), mem(&intc, &dma, &gpu), cpu(&mem) {
|
||||
PlayStation(const fs::path& biosPath) : interrupt(), gpu(), dma(), mem(&interrupt, &dma, &gpu), cpu(&mem) {
|
||||
mem.loadBios(biosPath);
|
||||
//cpu.switchBackend(Cpu::Backend::OldInterpreter);
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ private:
|
|||
Cpu cpu;
|
||||
DMA dma;
|
||||
Memory mem;
|
||||
INTC intc;
|
||||
Interrupt interrupt;
|
||||
Gpu gpu;
|
||||
};
|
Loading…
Reference in a new issue