minimacplus/components/tme/sdl/main.c

43 lines
729 B
C
Raw Normal View History

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) {
int i;
2017-03-03 07:47:14 +00:00
char *ret=malloc(TME_ROMSIZE);
int f=open(file, O_RDONLY);
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;
}
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");
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
}