Working Read (Interpreter only)
Write is slightly buggy for some reason. Conflicts: Source/Project64-core/N64System/Mips/Disk.cpp Source/Project64-core/N64System/Mips/Dma.cpp Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp
This commit is contained in:
parent
305f4cfb16
commit
b31d18d8c4
|
@ -15,6 +15,7 @@
|
|||
#include <Project64-core/N64System/N64DiskClass.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
|
||||
bool dd_write;
|
||||
bool dd_reset_hold;
|
||||
|
@ -29,7 +30,6 @@ void DiskCommand()
|
|||
#ifdef _WIN32
|
||||
SYSTEMTIME sysTime;
|
||||
::GetLocalTime(&sysTime);
|
||||
//stdstr_f timestamp("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d,", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds, GetCurrentThreadId());
|
||||
|
||||
//BCD format needed for 64DD RTC
|
||||
uint8_t year = (uint8_t)(((sysTime.wYear / 10) << 4) | (sysTime.wYear % 10));
|
||||
|
@ -45,8 +45,6 @@ void DiskCommand()
|
|||
struct tm result = { 0 };
|
||||
localtime_r(<ime, &result);
|
||||
|
||||
//stdstr_f timestamp("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d,", result.tm_year + 1900, result.tm_mon + 1, result.tm_mday, result.tm_hour, result.tm_min, result.tm_sec, milliseconds, GetCurrentThreadId());
|
||||
|
||||
//BCD format needed for 64DD RTC
|
||||
uint8_t year = (uint8_t)(((result.tm_year / 10) << 4) | (result.tm_year % 10));
|
||||
uint8_t month = (uint8_t)(((result.tm_mon / 10) << 4) | (result.tm_mon % 10));
|
||||
|
@ -148,8 +146,8 @@ void DiskGapSectorCheck()
|
|||
if (SECTORS_PER_BLOCK < dd_current)
|
||||
{
|
||||
g_Reg->ASIC_STATUS &= ~DD_STATUS_BM_INT;
|
||||
if (!(g_Reg->ASIC_STATUS & DD_STATUS_MECHA_INT) && !(g_Reg->ASIC_STATUS & DD_STATUS_BM_INT))
|
||||
g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP3;
|
||||
g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP3;
|
||||
g_Reg->CheckInterrupts();
|
||||
DiskBMUpdate();
|
||||
}
|
||||
}
|
||||
|
@ -159,25 +157,19 @@ void DiskBMUpdate()
|
|||
{
|
||||
if (!(g_Reg->ASIC_BM_STATUS & DD_BM_STATUS_RUNNING))
|
||||
return;
|
||||
/*
|
||||
uint16_t testsector = (uint16_t)(g_Reg->ASIC_CUR_SECTOR >> 16);
|
||||
if (testsector >= 0x5A)
|
||||
testsector -= 0x5A;
|
||||
*/
|
||||
|
||||
if (dd_write)
|
||||
{
|
||||
//Write Data
|
||||
if (dd_current == 0)
|
||||
{
|
||||
dd_current += 1;
|
||||
//g_Reg->ASIC_CUR_SECTOR += 0x00010000;
|
||||
g_Reg->ASIC_STATUS |= DD_STATUS_DATA_RQ;
|
||||
}
|
||||
else if (dd_current < SECTORS_PER_BLOCK)
|
||||
{
|
||||
DiskBMWrite();
|
||||
dd_current += 1;
|
||||
//g_Reg->ASIC_CUR_SECTOR += 0x00010000;
|
||||
g_Reg->ASIC_STATUS |= DD_STATUS_DATA_RQ;
|
||||
}
|
||||
else if (dd_current < SECTORS_PER_BLOCK + 1)
|
||||
|
@ -186,7 +178,6 @@ void DiskBMUpdate()
|
|||
{
|
||||
DiskBMWrite();
|
||||
dd_current += 1;
|
||||
//g_Reg->ASIC_CUR_SECTOR += 0x00010000;
|
||||
dd_start_block = 1 - dd_start_block;
|
||||
dd_current = 1;
|
||||
g_Reg->ASIC_BM_STATUS &= ~DD_BM_STATUS_BLOCK;
|
||||
|
@ -196,7 +187,6 @@ void DiskBMUpdate()
|
|||
{
|
||||
DiskBMWrite();
|
||||
dd_current += 1;
|
||||
//g_Reg->ASIC_CUR_SECTOR += 0x00010000;
|
||||
g_Reg->ASIC_BM_STATUS &= ~DD_BM_STATUS_RUNNING;
|
||||
}
|
||||
}
|
||||
|
@ -218,14 +208,12 @@ void DiskBMUpdate()
|
|||
{
|
||||
DiskBMRead();
|
||||
dd_current += 1;
|
||||
//g_Reg->ASIC_CUR_SECTOR += 0x00010000;
|
||||
g_Reg->ASIC_STATUS |= DD_STATUS_DATA_RQ;
|
||||
}
|
||||
else if (dd_current < SECTORS_PER_BLOCK + 4)
|
||||
{
|
||||
//READ C2 (00!)
|
||||
dd_current += 1;
|
||||
//g_Reg->ASIC_CUR_SECTOR += 0x00010000;
|
||||
if (dd_current == SECTORS_PER_BLOCK + 4)
|
||||
g_Reg->ASIC_STATUS |= DD_STATUS_C2_XFER;
|
||||
}
|
||||
|
@ -252,41 +240,22 @@ void DiskBMUpdate()
|
|||
void DiskBMRead()
|
||||
{
|
||||
uint32_t sector = 0;
|
||||
//sector = (uint8_t*)g_Disk->GetDiskAddress();
|
||||
sector += dd_track_offset;
|
||||
sector += dd_start_block * SECTORS_PER_BLOCK * ddZoneSecSize[dd_zone];
|
||||
sector += (dd_current) * ((g_Reg->ASIC_SEC_BYTE >> 16) + 1);
|
||||
|
||||
sector += (dd_current) * (((g_Reg->ASIC_HOST_SECBYTE & 0x00FF0000) >> 16) + 1);
|
||||
WriteTrace(TraceN64System, TraceDebug, "READ Block %d Sector %02X - %08X", ((g_Reg->ASIC_CUR_TK & 0x0FFF0000) >> 15) | dd_start_block, dd_current, sector);
|
||||
g_Disk->SetDiskAddressBuffer(sector);
|
||||
|
||||
/*
|
||||
for (int i = 0; i < ((g_Reg->ASIC_SEC_BYTE >> 16) + 1) / 4; i++)
|
||||
{
|
||||
dd_buffer[i] = sector[(i * 4 + 0)] << 24 | sector[(i * 4 + 1)] << 16 |
|
||||
sector[(i * 4 + 2)] << 8 | sector[(i * 4 + 3)];
|
||||
}
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
void DiskBMWrite()
|
||||
{
|
||||
uint32_t sector = 0;
|
||||
//sector = (uint8_t*)g_Disk->GetDiskAddress();
|
||||
sector += dd_track_offset;
|
||||
sector += dd_start_block * SECTORS_PER_BLOCK * ddZoneSecSize[dd_zone];
|
||||
sector += (dd_current - 1) * ((g_Reg->ASIC_SEC_BYTE >> 16) + 1);
|
||||
|
||||
sector += (dd_current - 1) * (((g_Reg->ASIC_HOST_SECBYTE & 0x00FF0000) >> 16) + 1);
|
||||
WriteTrace(TraceN64System, TraceDebug, "WRITE Block %d Sector %02X - %08X", ((g_Reg->ASIC_CUR_TK & 0x0FFF0000) >> 15) | dd_start_block, dd_current - 1, sector);
|
||||
g_Disk->SetDiskAddressBuffer(sector);
|
||||
/*
|
||||
for (int i = 0; i < ddZoneSecSize[dd_zone] / 4; i++)
|
||||
{
|
||||
sector[i * 4 + 0] = (dd_buffer[i] >> 24) & 0xFF;
|
||||
sector[i * 4 + 1] = (dd_buffer[i] >> 16) & 0xFF;
|
||||
sector[i * 4 + 2] = (dd_buffer[i] >> 8) & 0xFF;
|
||||
sector[i * 4 + 3] = (dd_buffer[i] >> 0) & 0xFF;
|
||||
}
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,7 @@ void CDMA::PI_DMA_READ()
|
|||
if (g_Reg->PI_CART_ADDR_REG >= 0x05000000 && g_Reg->PI_CART_ADDR_REG <= 0x050003FF)
|
||||
{
|
||||
//64DD C2 Sectors (don't care)
|
||||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
g_SystemTimer->SetTimer(g_SystemTimer->DDPiTimer, (PI_RD_LEN_REG * 63) / 25, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,9 +89,7 @@ void CDMA::PI_DMA_READ()
|
|||
{
|
||||
*(DISK + (i ^ 3)) = *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3));
|
||||
}
|
||||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
g_SystemTimer->SetTimer(g_SystemTimer->DDPiTimer, (PI_RD_LEN_REG * 63) / 25, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -229,9 +225,9 @@ void CDMA::PI_DMA_WRITE()
|
|||
{
|
||||
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
|
||||
}
|
||||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
|
||||
//Timer is needed for Track Read
|
||||
g_SystemTimer->SetTimer(g_SystemTimer->DDPiTimer, (PI_WR_LEN_REG * 63) / 25, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -245,9 +241,9 @@ void CDMA::PI_DMA_WRITE()
|
|||
{
|
||||
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(DISK + (i ^ 3));
|
||||
}
|
||||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
|
||||
//Timer is needed for Track Read
|
||||
g_SystemTimer->SetTimer(g_SystemTimer->DDPiTimer, (PI_WR_LEN_REG * 63) / 25, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5412,7 +5412,21 @@ void CMipsMemoryVM::Write32PeripheralInterface(void)
|
|||
switch (m_MemLookupAddress & 0xFFFFFFF)
|
||||
{
|
||||
case 0x04600000: g_Reg->PI_DRAM_ADDR_REG = m_MemLookupValue.UW[0]; break;
|
||||
case 0x04600004: g_Reg->PI_CART_ADDR_REG = m_MemLookupValue.UW[0]; break;
|
||||
case 0x04600004:
|
||||
g_Reg->PI_CART_ADDR_REG = m_MemLookupValue.UW[0];
|
||||
if (g_Reg->PI_CART_ADDR_REG == 0x05000000)
|
||||
{
|
||||
g_Reg->ASIC_STATUS &= ~(DD_STATUS_BM_INT | DD_STATUS_BM_ERR | DD_STATUS_C2_XFER);
|
||||
g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP3;
|
||||
g_Reg->CheckInterrupts();
|
||||
}
|
||||
else if (g_Reg->PI_CART_ADDR_REG == 0x05000400)
|
||||
{
|
||||
g_Reg->ASIC_STATUS &= ~(DD_STATUS_BM_INT | DD_STATUS_BM_ERR | DD_STATUS_DATA_RQ);
|
||||
g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP3;
|
||||
g_Reg->CheckInterrupts();
|
||||
}
|
||||
break;
|
||||
case 0x04600008:
|
||||
g_Reg->PI_RD_LEN_REG = m_MemLookupValue.UW[0];
|
||||
g_MMU->PI_DMA_READ();
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#include <Project64-core/N64System/Mips/Disk.h>
|
||||
#include <Project64-core/N64System/N64Class.h>
|
||||
#include <Project64-core/3rdParty/zip.h>
|
||||
|
||||
|
@ -207,6 +208,13 @@ void CSystemTimer::TimerDone()
|
|||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
break;
|
||||
case CSystemTimer::DDPiTimer:
|
||||
g_SystemTimer->StopTimer(CSystemTimer::DDPiTimer);
|
||||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
DiskBMUpdate();
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
break;
|
||||
case CSystemTimer::ViTimer:
|
||||
try
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
PiTimer,
|
||||
RspTimer,
|
||||
RSPTimerDlist,
|
||||
DDPiTimer,
|
||||
MaxTimer
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue