2021-04-28 20:32:46 +02:00
|
|
|
#include "pcdrv.h"
|
|
|
|
|
|
|
|
int waitForSIODone( int * flag ){
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
// This should wait for a signal from the SIO to tell when it's done
|
2021-04-28 10:45:24 +02:00
|
|
|
// Returns val < 0 if wrong
|
2021-04-28 20:32:46 +02:00
|
|
|
|
|
|
|
uint timeOut = 1000;
|
|
|
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
for ( uint t = 0; t < timeOut; t ++){
|
|
|
|
|
|
|
|
if ( * flag == 1 ){
|
|
|
|
|
|
|
|
result = * flag;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2021-04-28 10:45:24 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
void PCload( u_long * loadAddress, u_short * flagAddress, const char * filename ) {
|
|
|
|
|
|
|
|
// Send filename , load address, and flag address
|
|
|
|
// flag address points to an int16 that when set to 1 enable lvl/pointers/screen refresh
|
|
|
|
// Returns 1 if all good, 0 else
|
|
|
|
|
|
|
|
//~ int flag = 0;
|
|
|
|
|
|
|
|
printf("load:%08x:%08x:%s", loadAddress, flagAddress, filename);
|
|
|
|
|
|
|
|
//~ return ; // If all is well, returns a positive int . If -1, wrong
|
|
|
|
|
|
|
|
};
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int PCopen(const char * filename, int attributes) {
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ // Send filename and attributes (ro,wo,rw..)
|
|
|
|
//~ // expects an int referring to a file descriptor on the PC
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int fd = 0; // File Descriptor https://en.wikipedia.org/wiki/File_descriptor
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ printf("open:%s:%i:%08x", filename, attributes, &fd);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ waitForSIODone(0);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ return fd; // If all is well, returns a positive int . If -1, wrong
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ };
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int PCcreate(const char * filename, int attributes) {
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ // Send filename and attributes (ro,wo,rw..)
|
|
|
|
//~ // expects an int referring to a file descriptor on the PC
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int fd = 0; // File Descriptor https://en.wikipedia.org/wiki/File_descriptor
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ printf("create:%s:%i:%08x", filename, attributes, &fd);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ waitForSIODone(5); // Should return int fd, -1 else
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ return fd; // If all is well, returns a positive int . If -1, wrong
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ };
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int PCclose( int fd ) {
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ // Send the close command and fd as int
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ printf("close:%d", fd);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ return waitForSIODone(1); // Should return 1 if ok, 0 if wrong, or -1 if wrong ?
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ };
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int PCseek( int fd, int offset, int accessMode){
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ // Move file pointer in fd at offset
|
|
|
|
//~ // Access mode can be 0 abs, 1 rel to start, 2 rel to end
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ printf("seek:%i:%08x:%i", fd, offset, accessMode);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ return waitForSIODone(2);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ };
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int PCread( int fd, int len, char * buffer ){
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ // Read len bytes of fd and put them in buff
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ int count = 0;
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ printf("read:%i:%08x:%i", fd, len, buffer, count);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ waitForSIODone(3);
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ return count;
|
2021-04-28 10:45:24 +02:00
|
|
|
|
2021-04-28 20:32:46 +02:00
|
|
|
//~ };
|
2021-04-28 10:45:24 +02:00
|
|
|
|