2017-03-03 07:47:14 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "emu.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2017-03-08 12:29:10 +00:00
|
|
|
#include "tmeconfig.h"
|
2017-10-17 13:43:20 +00:00
|
|
|
#include "snd.h"
|
2017-03-03 07:47:14 +00:00
|
|
|
|
|
|
|
static void *loadRom(char *file) {
|
2017-03-04 14:06:00 +00:00
|
|
|
int i;
|
2017-03-03 07:47:14 +00:00
|
|
|
char *ret=malloc(TME_ROMSIZE);
|
|
|
|
int f=open(file, O_RDONLY);
|
2017-03-04 14:06:00 +00:00
|
|
|
i=read(f, ret, TME_ROMSIZE);
|
|
|
|
if (i!=TME_ROMSIZE) {
|
|
|
|
perror("reading rom");
|
|
|
|
exit(1);
|
|
|
|
}
|
2017-03-03 07:47:14 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-09-04 01:25:24 +00:00
|
|
|
void saveRtcMem(char *data) {
|
|
|
|
FILE *f=fopen("pram.dat", "wb");
|
|
|
|
if (f!=NULL) {
|
|
|
|
fwrite(data, 32, 1, f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-03 07:47:14 +00:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
void *rom=loadRom("rom.bin");
|
2017-09-04 01:25:24 +00:00
|
|
|
FILE *f=fopen("pram.dat", "r");
|
|
|
|
if (f!=NULL) {
|
|
|
|
char data[32];
|
|
|
|
fread(data, 32, 1, f);
|
|
|
|
rtcInit(data);
|
|
|
|
fclose(f);
|
|
|
|
}
|
2017-09-03 08:02:16 +00:00
|
|
|
tmeStartEmu(rom);
|
2017-03-03 07:47:14 +00:00
|
|
|
}
|