From db35bd65188922d8ce1b3ed40db939eb51205a76 Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Sun, 11 Aug 2019 11:45:05 +0200 Subject: [PATCH] [Disk] Handle Sector & Sector Size in AddressBlock function (for future D64 support) --- Source/Project64-core/N64System/Mips/Disk.cpp | 4 +--- Source/Project64-core/N64System/N64DiskClass.cpp | 6 +++--- Source/Project64-core/N64System/N64DiskClass.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/Disk.cpp b/Source/Project64-core/N64System/Mips/Disk.cpp index 8a9e70155..92c5c1039 100644 --- a/Source/Project64-core/N64System/Mips/Disk.cpp +++ b/Source/Project64-core/N64System/Mips/Disk.cpp @@ -261,13 +261,11 @@ void DiskBMUpdate() void DiskBMRead() { DiskBMReadWrite(false); - return; } void DiskBMWrite() { DiskBMReadWrite(true); - return; } void DiskBMReadWrite(bool write) @@ -278,7 +276,7 @@ void DiskBMReadWrite(bool write) uint16_t sector = dd_current; uint16_t sectorsize = (((g_Reg->ASIC_HOST_SECBYTE & 0x00FF0000) >> 16) + 1); - uint32_t addr = g_Disk->GetDiskAddressBlock(head, track, block) + (sector * sectorsize); + uint32_t addr = g_Disk->GetDiskAddressBlock(head, track, block, sector, sectorsize); g_Disk->SetDiskAddressBuffer(addr); } diff --git a/Source/Project64-core/N64System/N64DiskClass.cpp b/Source/Project64-core/N64System/N64DiskClass.cpp index 88c17155c..9ce30b75f 100644 --- a/Source/Project64-core/N64System/N64DiskClass.cpp +++ b/Source/Project64-core/N64System/N64DiskClass.cpp @@ -392,7 +392,7 @@ void CN64Disk::UnallocateDiskImage() m_DiskImage = NULL; } -uint32_t CN64Disk::GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t block) +uint32_t CN64Disk::GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t block, uint16_t sector, uint16_t sectorsize) { uint32_t offset = 0; if (m_DiskFormat == DiskFormatMAME) @@ -441,11 +441,11 @@ uint32_t CN64Disk::GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t b tr_off = track; } - offset = MAMEStartOffset[dd_zone] + tr_off * TRACKSIZE(dd_zone) + block * BLOCKSIZE(dd_zone); + offset = MAMEStartOffset[dd_zone] + tr_off * TRACKSIZE(dd_zone) + block * BLOCKSIZE(dd_zone) + sector * sectorsize; } else if (m_DiskFormat == DiskFormatSDK) { - offset = LBAToByte(0, PhysToLBA(head, track, block)); + offset = LBAToByte(0, PhysToLBA(head, track, block)) + sector * sectorsize; } //WriteTrace(TraceN64System, TraceDebug, "Head %d Track %d Block %d - LBA %d - Address %08X", head, track, block, PhysToLBA(head, track, block), offset); return offset; diff --git a/Source/Project64-core/N64System/N64DiskClass.h b/Source/Project64-core/N64System/N64DiskClass.h index 22d94d39a..3cd7c5bab 100644 --- a/Source/Project64-core/N64System/N64DiskClass.h +++ b/Source/Project64-core/N64System/N64DiskClass.h @@ -30,7 +30,7 @@ public: uint8_t * GetDiskAddressSys() { return m_DiskImage; } uint8_t * GetDiskHeader() { return m_DiskHeader; } void SetDiskAddressBuffer(uint32_t address) { m_DiskBufAddress = address; } - uint32_t GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t block); + uint32_t GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t block, uint16_t sector, uint16_t sectorsize); stdstr GetRomName() const { return m_RomName; } stdstr GetFileName() const { return m_FileName; } stdstr GetDiskIdent() const { return m_DiskIdent; }