-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b5e53f0
Showing
6 changed files
with
799 additions
and
0 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,4 @@ | ||
*.bin | ||
*.tap | ||
*.def | ||
*.mmc |
Large diffs are not rendered by default.
Oops, something went wrong.
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,7 @@ | ||
all: scl2trd.tap | ||
|
||
scl2trd.tap: scl2trd.c | ||
zcc +zxn -v -clib=new scl2trd.c -o scl2trd -Cz"--clean" -create-app | ||
|
||
clean: | ||
rm *.bin *.tap *.def |
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,27 @@ | ||
# SCL2TRD utility for esxDOS | ||
|
||
## What is it? | ||
|
||
This is tool for converting your SCL files to TRD on your real speccy with esxDOS(divMMC/divIDE hardware, ZX-Uno, ZX Spectrum next etc). | ||
|
||
This tool makes cutted trd-file that can be used only for read-only. If you need write access - you may copy it into normal trd file or you may make PR where you will fix it. | ||
|
||
## How to use it? | ||
|
||
Simple way - copy this file to folder that contains SCL files and run it. Enter file name without extension(for ex. if file named "test.scl" just write "test"). | ||
|
||
When conversion will be completed you may enter next file name and convert it, or you may go to NMI commander and try to load TRD file. | ||
|
||
 | ||
|
||
## If you want contribute? | ||
|
||
Please, fork repo, make your changes and make PR. | ||
|
||
Any kind of PRs are welcome - misspell fix, code improvement, usability extendions, documentation etc. | ||
|
||
If it possible - please send all your improvments to me as PR. I'll be very glad! | ||
|
||
## Legals | ||
|
||
Copyleft (L) 2019 Alexander Sharikhin aka Nihirash |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,139 @@ | ||
#include <stdio.h> | ||
#include <arch/zxn/esxdos.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
|
||
unsigned char iStream; | ||
unsigned char oStream; | ||
unsigned freeTrack = 1; | ||
unsigned freeSec = 0; | ||
unsigned char count; | ||
|
||
void openFile() | ||
{ | ||
unsigned char *name[ESX_FILENAME_MAX]; | ||
unsigned char *inputName[ESX_FILENAME_MAX + 1]; | ||
unsigned char *outputName[ESX_FILENAME_MAX + 1]; | ||
printf("Enter filename(without ext):\n"); | ||
scanf("%s", name); | ||
sprintf(inputName, "%s.SCL", name); | ||
sprintf(outputName, "%s.TRD", name); | ||
iStream = esx_f_open(inputName, ESX_MODE_READ | ESX_MODE_OPEN_EXIST); | ||
if (!errno) | ||
oStream = esx_f_open(outputName, ESX_MODE_WRITE | ESX_MODE_OPEN_CREAT_TRUNC); | ||
if (errno) { | ||
esx_f_close(iStream); | ||
esx_f_close(oStream); | ||
printf("\n Failed to open streams!\n"); | ||
exit(0); | ||
} | ||
} | ||
|
||
void validateScl() | ||
{ | ||
unsigned char *header[9] = {0,0,0,0,0,0,0,0,0}; | ||
unsigned char *expected[9] = "SINCLAIR"; | ||
esx_f_read(iStream, header, 8); | ||
if (strcmp(header, expected)) { | ||
printf("Wrong file header: %s", header); | ||
exit(1); | ||
} | ||
} | ||
/** | ||
* In SCL file absent info about starting sector/track. We read headers as is and just append absent info | ||
*/ | ||
void importCatalog() | ||
{ | ||
unsigned char trdHeader[16]; | ||
unsigned char name[10] = {0,0,0,0,0,0,0,0,0,0}; | ||
unsigned char i; | ||
esx_f_read(iStream, &count, 1); | ||
printf("Contains %i files\n", count); | ||
for (i=0;i<count;i++) { | ||
esx_f_read(iStream, &trdHeader, 14); | ||
strncpy(name, trdHeader, 9); | ||
printf("%s ", name); | ||
trdHeader[14] = freeSec; | ||
trdHeader[15] = freeTrack; | ||
freeSec += trdHeader[0xd]; | ||
freeTrack += freeSec / 16; | ||
freeSec = freeSec % 16; | ||
esx_f_write(oStream, &trdHeader, 16); | ||
} | ||
for (i=0;i<16;i++) trdHeader[i] = 0; | ||
for (i=count;i<128;i++) esx_f_write(oStream, &trdHeader, 16); | ||
} | ||
|
||
/** | ||
* This function writes only really need to run info | ||
* | ||
* Cause TRD will be cutted - it will be read only and I don't write "free sectors" info. | ||
*/ | ||
void writeDiskInfo() | ||
{ | ||
unsigned char data[255]; | ||
unsigned char i; | ||
for (i=0;i<255;data[i++]=0) ; | ||
data[0xe3] = 0x16; // IMPORTANT! 80 track double sided | ||
data[0xe4] = count; | ||
data[0xe1] = freeSec; | ||
data[0xe2] = freeTrack; | ||
data[0xe7] = 0x10; | ||
data[0xea] = 32; | ||
data[0xf5] = 's'; | ||
data[0xf6] = 'c'; | ||
data[0xf7] = 'l'; | ||
data[0xf8] = '2'; | ||
data[0xf9] = 't'; | ||
data[0xfa] = 'r'; | ||
data[0xfb] = 'd'; | ||
esx_f_write(oStream, &data, 256); | ||
for (i=0;i<255;i++) data[i] = 0; | ||
esx_f_write(oStream, 0, 1792); | ||
} | ||
|
||
/** | ||
* In SCL data already written by sectors - just copy as is! | ||
*/ | ||
void writeData() | ||
{ | ||
unsigned char buf[256]; | ||
int r = esx_f_read(iStream, &buf, 255); | ||
while (r > 4 && !errno) { | ||
esx_f_write(oStream, &buf, r); | ||
r = esx_f_read(iStream, &buf, 255); | ||
} | ||
} | ||
|
||
void showSclFiles() | ||
{ | ||
char *ext = ".SCL"; | ||
unsigned char dirDescr; | ||
unsigned char cwd[ESX_PATHNAME_MAX+1]; | ||
struct esx_dirent file; | ||
|
||
esx_f_getcwd(cwd); | ||
dirDescr = esx_f_opendir_ex(cwd, ESX_DIR_USE_HEADER); | ||
printf("Current directory %s.\nYou may convert:\n", cwd); | ||
|
||
while ((esx_f_readdir(dirDescr, &file)) && (errno == 0)) | ||
{ | ||
if (strcmp(&file.name[9], ext) == 0) printf("%s\n", file.name); | ||
} | ||
} | ||
|
||
void main(void) | ||
{ | ||
printf("scl2trd converter\n(L) 2019 Alexander Sharikhin\n\n"); | ||
showSclFiles(); | ||
while (1) { | ||
openFile(); | ||
validateScl(); | ||
importCatalog(); | ||
writeDiskInfo(); | ||
writeData(); | ||
esx_f_close(oStream); | ||
esx_f_close(iStream); | ||
printf("\nReady\n"); | ||
} | ||
} |