-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.c
61 lines (54 loc) · 1.5 KB
/
app.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "emulator.h"
#include "emulator_mmio.h"
/**
* The Apple //gs Clements Emulator
*
* CPU
* Mega II emulation
* Memory
* ROM
* RAM
* I/O
* IWM
* ADB (keyboard + mouse)
* Ports 1-7
* Ensoniq
*
* Approach:
*
*/
int main(int argc, char *argv[]) {
ClemensMachine machine;
ClemensMMIO mmio;
/* ROM 3 only */
FILE *fp = fopen("gs_rom_3.rom", "rb");
// FILE* fp = fopen("testrom.rom", "rb");
void *rom = NULL;
if (fp == NULL) {
fprintf(stderr, "No ROM\n");
return 1;
}
rom = malloc(CLEM_IIGS_ROM3_SIZE);
if (fread(rom, 1, CLEM_IIGS_ROM3_SIZE, fp) != CLEM_IIGS_ROM3_SIZE) {
fprintf(stderr, "Bad ROM\n");
return 1;
}
fclose(fp);
memset(&machine, 0, sizeof(machine));
memset(&mmio, 0, sizeof(mmio));
clemens_init(&machine, 1000, 1000, rom, CLEM_IIGS_ROM3_SIZE >> 16, malloc(CLEM_IIGS_BANK_SIZE),
malloc(CLEM_IIGS_BANK_SIZE), malloc(CLEM_IIGS_BANK_SIZE * 16), 16);
clem_mmio_init(&mmio, &machine.dev_debug, machine.mem.bank_page_map, malloc(2048 * 7), 16,
CLEM_IIGS_ROM3_SIZE >> 16, machine.mem.mega2_bank_map[0],
machine.mem.mega2_bank_map[1], &machine.tspec);
machine.cpu.pins.resbIn = false;
machine.resb_counter = 3;
while (machine.cpu.cycles_spent < 1024) {
clemens_emulate_cpu(&machine);
clemens_emulate_mmio(&machine, &mmio);
}
return 0;
}