-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathmain.c
More file actions
46 lines (41 loc) · 1.25 KB
/
main.c
File metadata and controls
46 lines (41 loc) · 1.25 KB
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
#include "sfc_famicom.h"
#include "sfc_cpu.h"
#include <stdio.h>
void sfc_log_exec(void* arg, sfc_famicom_t* famicom) {
static int line = 0;
line++;
char buf[SFC_DISASSEMBLY_BUF_LEN2];
const uint16_t pc = famicom->registers.program_counter;
sfc_fc_disassembly(pc, famicom, buf);
printf(
"%4d - %s A:%02X X:%02X Y:%02X P:%02X SP:%02X\n",
line, buf,
(int)famicom->registers.accumulator,
(int)famicom->registers.x_index,
(int)famicom->registers.y_index,
(int)famicom->registers.status,
(int)famicom->registers.stack_pointer
);
}
/// <summary>
/// 应用程序入口
/// </summary>
/// <returns></returns>
int main() {
sfc_interface_t interfaces = { NULL };
interfaces.before_execute = sfc_log_exec;
sfc_famicom_t famicom;
sfc_famicom_init(&famicom, NULL, &interfaces);
printf(
"ROM: PRG-ROM: %d x 16kb CHR-ROM %d x 8kb Mapper: %03d\n",
(int)famicom.rom_info.count_prgrom16kb,
(int)famicom.rom_info.count_chrrom_8kb,
(int)famicom.rom_info.mapper_number
);
do {
for(int i = 0; i != 1000; ++i)
sfc_cpu_execute_one(&famicom);
} while (getchar() != -1);
sfc_famicom_uninit(&famicom);
return 0;
}