I am running figForth on a 6502 emulator, running on an ESP32, M5Stack-Core2 with screen and sd-card. (Arduino IDE)
The system runs well, even a simple file system with 128 sectors works.
But when I expand the files system to 512 bytes / sector and 2 buffers per screen,
On the SD card are 256*2 blocks as 256*2 files of 512 byte.
The code shows the R/W routine.
RAM is the memory of the 6502 simulation (0x0000-0xFFFF)
Code:
void RW(int adr, int blk, int f)
{
int bytes_per_block = 512;
if (f==1) /* read from disk to memory */
{
file = sd.open("/dr1/"+String(blk)+".blk", O_RDWR);
if (!file) Serial.println("File open error");
if (bytes_per_block != file.read(buf, bytes_per_block)) Serial.println("read failed");
file.close();
for (int i=0; i<bytes_per_block; i++) RAM[adr+i] = buf[i];
}
else /* write to disk to memory */
{
for (int i=0; i<bytes_per_block; i++) buf[i] = RAM[adr+i];
file = sd.open("/dr1/"+String(blk)+".blk", O_RDWR);
if (bytes_per_block != file.write(buf,bytes_per_block)) Serial.println("write failed");
file.close();
}
}
I can read and write the data. Stored well. But when I load a file, the first block is loaded and the system hangs.
Does anyone have experience with 512 bytes / sector, when a word is loaded that this is also be compiled!Or can figForth only be operated with 128 bytes / sector?
Maybe someone can help me out with this.
Cheers,
Jan