summaryrefslogtreecommitdiff
path: root/src/main.c
blob: f1dfada94de7b294122e1a6a68216b9c7ff9707a (plain)
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
#include "apple.h"
#include "video/interface.h"
#include <unistd.h>
#include "cpu/6502.h"


int main() {

	AppleOn();
	
	DisplayInit();

	FILE *Log = fopen("log/log.raw", "w+");
	int Time = 0;
	
	while(1) {
		// Computing
		CallInstructionTable();

		// Logging
		if (Time >= 0x2000)
			// Stop logging after an arbitrary amount of time, so as to not create a huge file.
			fclose(Log);
		else {
			fprintf(Log,
				"%04x : %04x : %02x : %02x : %02x : %c%c_%c%c%c%c%c : %02x\n",
				Time, PC, acc, X, Y,
				GetFlag(flag_N) ? 'N':'.' ,
				GetFlag(flag_V) ? 'V':'.' ,
				GetFlag(flag_B) ? 'B':'.' ,
				GetFlag(flag_D) ? 'D':'.' ,
				GetFlag(flag_I) ? 'I':'.' ,
				GetFlag(flag_Z) ? 'Z':'.' ,
				GetFlag(flag_C) ? 'C':'.' ,
				S);
			fflush(Log);
			Time++;
		}
					
		// Display information
		PrintInfo();
	}

	DisplayClose();

	return 0;
}