1 |
dpavlin |
24 |
#include <EXTERN.h> |
2 |
|
|
#include <perl.h> |
3 |
|
|
#include "M6502.h" |
4 |
|
|
#include "config.h" |
5 |
|
|
|
6 |
|
|
static PerlInterpreter *my_perl; |
7 |
|
|
|
8 |
|
|
static M6502 *R; |
9 |
|
|
|
10 |
|
|
void Reset6502(M6502 *R) { |
11 |
|
|
R->PC.W = atoi( SvPV_nolen( get_sv("M6502::PC", TRUE) ) ); |
12 |
|
|
printf("PC: %04x\n", R->PC.W); |
13 |
|
|
} |
14 |
|
|
|
15 |
|
|
int main(int argc, char **argv) { |
16 |
|
|
char *command_line[] = {"", "-e", |
17 |
|
|
"use M6502; print \"Loaded M6502 module\n\";"}; |
18 |
|
|
my_perl = perl_alloc(); |
19 |
|
|
perl_construct(my_perl); |
20 |
|
|
if (perl_parse(my_perl, NULL, 3, command_line, (char **)NULL)) { |
21 |
|
|
printf("Failed to parse\n"); |
22 |
|
|
return 0; |
23 |
|
|
} |
24 |
|
|
perl_run(my_perl); |
25 |
|
|
if (SvTRUE(ERRSV)) { |
26 |
|
|
printf("Failed to execute\n"); |
27 |
|
|
return 0; |
28 |
|
|
} else { |
29 |
|
|
R = malloc(sizeof(M6502)); |
30 |
|
|
if (!R) { |
31 |
|
|
printf("can't alloc %d bytes for M6502", sizeof(M6502)); |
32 |
|
|
exit(1); |
33 |
|
|
} |
34 |
|
|
printf("reset CPU\n"); |
35 |
|
|
Reset6502(R); |
36 |
|
|
|
37 |
|
|
} |
38 |
|
|
free(R); |
39 |
|
|
perl_destruct(my_perl); |
40 |
|
|
perl_free(my_perl); |
41 |
|
|
return 0; |
42 |
|
|
} |