Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/emulator/xnes/snem/main.c
28515 views
1
//1b15a
2
#include <stdio.h>
3
#include <stdlib.h>
4
#include "snes.h"
5
6
int sblankchk=0;
7
int soundupdate=0;
8
static int speed_count=0;
9
#ifdef SOUND
10
static void soundcheck()
11
{
12
soundupdate=1;
13
}
14
#endif
15
static int incspeedcount()
16
{
17
speed_count++;
18
//printf("%d\n",speed_count);
19
return 0;
20
}
21
int spcemu,palf;
22
int reboot_emulator (char *) __attribute__((used));
23
int reboot_emulator (char *romfilename){
24
if(loadsmc(romfilename)==-1){
25
printf("can not find rom file %s\n",romfilename);
26
exit(1);
27
return 0;
28
}
29
makeopcodetable();
30
makeromtable();
31
reset65816();
32
//resetppu();
33
resetspc();
34
initppu();
35
speed_count=0;
36
return palf;
37
}
38
39
#ifdef EMCCHACK
40
#if 0
41
#include "romlist.h"
42
//char *roms[2]={"roms/smw.smc", "roms/Angel Eyes (PD).fig"};
43
int reboot_romnum=-1;
44
int js_callback(){
45
if(reboot_romnum>=0 && reboot_romnum<NROMS) {
46
char *file=roms[reboot_romnum];
47
reboot_romnum=-1;
48
printf("reboot %s\n", file);
49
reboot_emulator(file);
50
}
51
52
native_poll_keyboard();
53
mainloop(palf ? 312 : 262);
54
renderscreen();
55
return 0;
56
}
57
void reboot (int i) __attribute__((used));
58
void reboot (int i){
59
reboot_romnum=i;
60
}
61
#endif
62
#endif
63
64
65
void dumpregs();
66
67
68
69
int main(int argc, char *argv[])
70
{
71
int fps, end_loop;
72
spcemu=0;
73
native_hardware_init(spcemu);
74
#ifndef EMCCHACK
75
if(argc==1)
76
reboot_emulator("smw.smc");
77
else
78
reboot_emulator(argv[1]);
79
printf("palf=%d\n",palf);
80
#ifdef SET_BY_SOURCE
81
//#define BENCHMARK
82
#endif
83
#ifdef BENCHMARK
84
for(end_loop=0;end_loop<5000;end_loop++){
85
mainloop(palf ? 312 : 262);
86
renderscreen();
87
}
88
#else
89
90
native_tick_callback(incspeedcount, palf ? 50 : 60);
91
end_loop=0;
92
while (!end_loop)
93
{
94
end_loop= native_poll_keyboard()==-1;
95
if(speed_count>0)
96
{
97
mainloop(palf ? 312 : 262);
98
speed_count--;
99
vbl=0;
100
//dumpregs();
101
}
102
renderscreen();
103
UPDATE_SOUND;
104
}
105
#endif
106
#else
107
//reboot(0);
108
//native_tick_callback(js_callback, 200);
109
#endif
110
native_set_joypad_state(0x80000000);
111
return 0;
112
}
113
114