Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support of UDI, TRD, SCL, FDI, TD0, FDD formats via built-in trx2x
- Loading branch information
Artem Prilutskiy
authored and
Artem Prilutskiy
committed
Sep 17, 2020
1 parent
aff155a
commit 2162f10
Showing
6 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "trx2x"] | ||
path = trx2x | ||
url = https://github.com/atsidaev/trx2x.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
#include "DiskImage.h" | ||
|
||
bool LoadDiskImage(const char* path, uint8_t* buffer) | ||
{ | ||
TDiskImage image; | ||
VGFIND_SECTOR data; | ||
|
||
int side; | ||
int track; | ||
int sector; | ||
|
||
image.AddBOOT = false; | ||
image.Open(const_cast<char*>(path), true); | ||
|
||
if (image.DiskPresent) | ||
{ | ||
for (track = 0; track <= image.MaxTrack; track ++) | ||
{ | ||
for (side = 0; side <= image.MaxSide; side ++) | ||
{ | ||
for (sector = 1; sector <= 16; sector ++) | ||
{ | ||
if (image.FindSector(track, side, sector, &data)) | ||
{ | ||
if (!data.CRCOK || | ||
!data.vgfa.CRCOK || | ||
(data.SectorLength != 256)) | ||
{ | ||
// Unsupported data format or CRC | ||
return false; | ||
} | ||
|
||
memcpy(buffer, data.SectorPointer, data.SectorLength); | ||
buffer += data.SectorLength; | ||
|
||
continue; | ||
} | ||
|
||
memset(buffer, '*', 256); | ||
buffer += 256; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return image.DiskPresent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters