/[VRac]/M6502/perl.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /M6502/perl.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (hide annotations)
Mon Jul 30 13:29:57 2007 UTC (16 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 862 byte(s)
beginning of embedding perl into M6502 emulator
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     }

  ViewVC Help
Powered by ViewVC 1.1.26