File read trouble in ZX CP/M 2.2 by M.Williams
Posted: Tue Jan 14, 2020 7:53 am
I try to compile my project for Locomotive CP/M Plus and ZX CP/M 2.2 by Williams (https://www.worldofspectrum.org/infosee ... id=0023486) .
In Locomotive CP/M Plus file I/O works fine, I successfully read what I need right into memory address. But in ZX CP/M 2.2 I have a trouble with fread.
Code fragment is here:
If file exists and have the right size, output is always "ROM "myfile": 16384 bytes read", in both OS, but actually in ZX CP/M 2.2 nothing is read.
If I change fread code to
then in Locomotive CP/M Plus it still works well (memory is filled with file contents), but in ZX CP/M 2.2 output is "ROM "myfile": 1 bytes read", and actually that one byte is not read.
What I'm doing wrong? How to solve this trouble? Please help!
In Locomotive CP/M Plus file I/O works fine, I successfully read what I need right into memory address. But in ZX CP/M 2.2 I have a trouble with fread.
Code fragment is here:
Code: Select all
FILE * f = fopen(rom_file, "rb");
if (f == 0)
{
printf("ROM not found: \"%s\"\n", rom_file);
return;
}
const int bytes = fread(0x8000, 1, 0x4000, f); // read ROM to RAM2
fclose(f);
printf("ROM \"%s\": %d bytes read\n", rom_file, bytes);
If I change fread code to
Code: Select all
fread(0x8000, 0x4000, 1, f)
What I'm doing wrong? How to solve this trouble? Please help!