mirror of https://github.com/stenzek/duckstation
Partial implementation of DMA controller and GPU stubs
parent
2149ab4d69
commit
27913cd20a
@ -0,0 +1,65 @@
|
||||
#include "gpu.h"
|
||||
#include "YBaseLib/Log.h"
|
||||
#include "bus.h"
|
||||
Log_SetChannel(GPU);
|
||||
|
||||
GPU::GPU() = default;
|
||||
|
||||
GPU::~GPU() = default;
|
||||
|
||||
bool GPU::Initialize(Bus* bus, DMA* dma)
|
||||
{
|
||||
m_bus = bus;
|
||||
m_dma = dma;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GPU::Reset()
|
||||
{
|
||||
SoftReset();
|
||||
}
|
||||
|
||||
void GPU::SoftReset()
|
||||
{
|
||||
m_GPUSTAT.bits = 0x14802000;
|
||||
}
|
||||
|
||||
u32 GPU::ReadRegister(u32 offset)
|
||||
{
|
||||
if (offset == 0x00)
|
||||
{
|
||||
// GPUREAD
|
||||
Log_ErrorPrintf("GPUREAD");
|
||||
return 0;
|
||||
}
|
||||
else if (offset == 0x04)
|
||||
{
|
||||
// GPUSTAT
|
||||
return m_GPUSTAT.bits;
|
||||
}
|
||||
|
||||
Log_ErrorPrintf("Unhandled register read: %02X", offset);
|
||||
return UINT32_C(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void GPU::WriteRegister(u32 offset, u32 value)
|
||||
{
|
||||
if (offset == 0x00)
|
||||
WriteGP0(value);
|
||||
else if (offset == 0x04)
|
||||
WriteGP1(value);
|
||||
else
|
||||
Log_ErrorPrintf("Unhandled register write: %02X <- %08X", offset, value);
|
||||
}
|
||||
|
||||
void GPU::WriteGP0(u32 value)
|
||||
{
|
||||
const u8 command = Truncate8(value >> 24);
|
||||
Log_ErrorPrintf("Unimplemented GP0 command 0x%02X", command);
|
||||
}
|
||||
|
||||
void GPU::WriteGP1(u32 value)
|
||||
{
|
||||
const u8 command = Truncate8(value >> 24);
|
||||
Log_ErrorPrintf("Unimplemented GP1 command 0x%02X", command);
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include "common/bitfield.h"
|
||||
#include "types.h"
|
||||
#include <array>
|
||||
|
||||
class Bus;
|
||||
class DMA;
|
||||
|
||||
class GPU
|
||||
{
|
||||
public:
|
||||
GPU();
|
||||
~GPU();
|
||||
|
||||
bool Initialize(Bus* bus, DMA* dma);
|
||||
void Reset();
|
||||
|
||||
u32 ReadRegister(u32 offset);
|
||||
void WriteRegister(u32 offset, u32 value);
|
||||
|
||||
private:
|
||||
void SoftReset();
|
||||
void WriteGP0(u32 value);
|
||||
void WriteGP1(u32 value);
|
||||
|
||||
Bus* m_bus = nullptr;
|
||||
DMA* m_dma = nullptr;
|
||||
|
||||
union GPUSTAT
|
||||
{
|
||||
u32 bits;
|
||||
BitField<u32, u8, 0, 4> texture_page_x_base;
|
||||
BitField<u32, u8, 4, 1> texture_page_y_base;
|
||||
BitField<u32, u8, 5, 2> semi_transparency;
|
||||
BitField<u32, u8, 7, 2> texture_page_colors;
|
||||
BitField<u32, bool, 9, 1> dither_enable;
|
||||
BitField<u32, bool, 10, 1> draw_to_display_area;
|
||||
BitField<u32, bool, 11, 1> draw_set_mask_bit;
|
||||
BitField<u32, bool, 12, 1> draw_to_masked_pixels;
|
||||
BitField<u32, bool, 13, 1> interlaced_field;
|
||||
BitField<u32, bool, 14, 1> reverse_flag;
|
||||
BitField<u32, bool, 15, 1> texture_disable;
|
||||
BitField<u32, u8, 16, 1> horizontal_resolution_2;
|
||||
BitField<u32, u8, 17, 2> horizontal_resolution_1;
|
||||
BitField<u32, u8, 19, 1> vetical_resolution;
|
||||
BitField<u32, bool, 20, 1> pal_mode;
|
||||
BitField<u32, bool, 21, 1> display_area_color_depth_24;
|
||||
BitField<u32, bool, 22, 1> vertical_interlace;
|
||||
BitField<u32, bool, 23, 1> display_enable;
|
||||
BitField<u32, bool, 24, 1> interrupt_request;
|
||||
BitField<u32, bool, 25, 1> dma_data_request;
|
||||
BitField<u32, bool, 26, 1> ready_to_recieve_cmd;
|
||||
BitField<u32, bool, 27, 1> ready_to_send_vram;
|
||||
BitField<u32, bool, 28, 1> ready_to_recieve_dma;
|
||||
BitField<u32, u8, 29, 2> dma_direction;
|
||||
BitField<u32, bool, 31, 1> drawing_even_line;
|
||||
} m_GPUSTAT = {};
|
||||
};
|
||||
Loading…
Reference in New Issue