Compare commits

...

4 Commits

Author SHA1 Message Date
steve 2b31012100 flush on write 2023-09-30 15:57:25 +01:00
steve 53a16b3a29 bugfixes 2023-09-30 13:37:08 +01:00
steve 78e3fff5c3 minor change 2023-09-30 12:51:46 +01:00
steve 279bbc6b5a remove unnecessary buffer 2023-09-30 12:51:19 +01:00
3 changed files with 25 additions and 16 deletions

View File

@ -25,10 +25,10 @@ static Dir dir;
bool flash_filer::seek(uint32_t pos)
{
#if defined(USE_SD) || defined(USE_SPIFFS) || defined(USE_FS)
_pos = _len = 0;
return file.seek(pos);
#endif
#else
return false;
#endif
}
bool flash_filer::start()
@ -41,7 +41,6 @@ bool flash_filer::start()
return false;
#endif
_pos = _len = 0;
return true;
}
@ -54,15 +53,26 @@ void flash_filer::stop()
bool flash_filer::more()
{
if (_pos >= _len) {
_pos = 0;
#if defined(USE_SD) || defined(USE_SPIFFS) || defined(USE_FS)
_len = file.read(_buf, sizeof(_buf));
return file.available() > 0;
#else
return false;
#endif
}
uint8_t flash_filer::read() {
#if defined(USE_SD) || defined(USE_SPIFFS) || defined(USE_FS)
return file.read();
#else
return 0xff;
#endif
}
void flash_filer::write(uint8_t b) {
#if defined(USE_SD) || defined(USE_SPIFFS) || defined(USE_FS)
file.write(b);
file.flush();
#endif
if (_len == 0) // eof
return false;
}
return true;
}
const char *flash_filer::advance() {
@ -73,7 +83,7 @@ const char *flash_filer::advance() {
static char buf[32];
while (true) {
if (dir.next()) {
file = dir.openFile("r");
file = dir.openFile("r+");
break;
}
dir = SPIFFS.openDir(_programs);

View File

@ -17,12 +17,11 @@ public:
void stop();
bool seek(uint32_t pos);
uint8_t read() { return _buf[_pos++]; }
bool more();
uint8_t read();
void write(uint8_t);
private:
const char *_programs;
unsigned _pos, _len;
uint8_t _buf[128];
};
#endif

View File

@ -27,7 +27,7 @@ void PIA::write(Memory::address a, uint8_t b) {
Serial.print(' ');
Serial.println(b, 16);
#endif
switch(a % 4) {
switch(a & 3) {
case 0:
output_selected(cra)? write_porta(b): write_ddra(b);
break;
@ -49,7 +49,7 @@ uint8_t PIA::read(Memory::address a) {
Serial.print(" < ");
Serial.println(a, 16);
#endif
switch (a % 4) {
switch (a & 3) {
case 0:
return output_selected(cra)? read_porta(): read_ddra();
case 1: