mirror of https://github.com/jscrane/r65emu.git
Compare commits
4 Commits
b3e9fb9c2f
...
2b31012100
Author | SHA1 | Date |
---|---|---|
steve | 2b31012100 | |
steve | 53a16b3a29 | |
steve | 78e3fff5c3 | |
steve | 279bbc6b5a |
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
4
pia.cpp
4
pia.cpp
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue