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

Diff of /M6502/M6502.xs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 82 by dpavlin, Wed Aug 1 21:40:17 2007 UTC revision 87 by dpavlin, Thu Aug 2 11:08:10 2007 UTC
# Line 8  Line 8 
8  #include "config.h"  #include "config.h"
9    
10  M6502 *R;  M6502 *R;
11    int debug = 0;
12    
13  void  void update_C_R(void) {
14  run (void) {          R->A = SvIV( get_sv("M6502::A", FALSE) );
15          debugf(("M6502::run"));          R->P = SvIV( get_sv("M6502::P", FALSE) );
16          run_forever();          R->X = SvIV( get_sv("M6502::X", FALSE) );
17            R->Y = SvIV( get_sv("M6502::Y", FALSE) );
18            R->S = SvIV( get_sv("M6502::S", FALSE) );
19            R->PC.W = SvIV( get_sv("M6502::PC", FALSE) );
20            R->IPeriod = SvIV( get_sv("M6502::IPeriod", FALSE) );
21            R->IRequest = SvIV( get_sv("M6502::IRequest", FALSE) );
22            R->IAutoReset = SvIV( get_sv("M6502::IAutoReset", FALSE) );
23            R->TrapBadOps = SvIV( get_sv("M6502::TrapBadOps", FALSE) );
24            R->Trap = SvIV( get_sv("M6502::Trap", FALSE) );
25            R->Trace = SvIV( get_sv("M6502::Trace", FALSE) );
26            debugf(("pull_R finished"));
27            dump_R;
28  }  }
29    
30  void  void update_perl_R(void) {
31            debugf(("update_perl_R"));
32            dSP;
33            ENTER;
34            SAVETMPS;
35            PUSHMARK(SP);
36            XPUSHs( sv_2mortal( newSViv( R->A ) ) );
37            XPUSHs( sv_2mortal( newSViv( R->P ) ) );
38            XPUSHs( sv_2mortal( newSViv( R->X ) ) );
39            XPUSHs( sv_2mortal( newSViv( R->Y ) ) );
40            XPUSHs( sv_2mortal( newSViv( R->S ) ) );
41            XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) );
42            XPUSHs( sv_2mortal( newSViv( R->IPeriod ) ) );
43            XPUSHs( sv_2mortal( newSViv( R->ICount ) ) );
44            XPUSHs( sv_2mortal( newSViv( R->IRequest ) ) );
45            XPUSHs( sv_2mortal( newSViv( R->IAutoReset ) ) );
46            XPUSHs( sv_2mortal( newSViv( R->TrapBadOps ) ) );
47            XPUSHs( sv_2mortal( newSViv( R->Trap ) ) );
48            XPUSHs( sv_2mortal( newSViv( R->Trace ) ) );
49            PUTBACK;
50            call_pv("M6502::_update_perl_R", G_DISCARD );
51            debugf(("_update_perl_R returned to C"));
52            dump_R;
53            FREETMPS;
54            LEAVE;
55    }
56    
57    int
58  reset (void) {  reset (void) {
59          debugf(("M6502::reset called"));          debugf(("M6502::reset called"));
60            if ( ! R ) {
61                    debugf(("allocating space for R"));
62                    R = malloc(sizeof(M6502));
63                    if (!R) {
64                            PerlIO_stderrf("can't alloc %d bytes for M6502", sizeof(M6502));
65                            exit(1);
66                    }
67            }
68          Reset6502(R);          Reset6502(R);
69            debugf(("Reset6502 over"));
70            update_perl_R();
71          dump_R;          dump_R;
72            return 1;
73    }
74    
75    int set_debug(int state) {
76            debug = state;
77            return debug;
78    }
79    
80    int get_debug(void) {
81            return debug;
82  }  }
83    
84  MODULE = M6502          PACKAGE = M6502  MODULE = M6502          PACKAGE = M6502
85    
86  PROTOTYPES: DISABLE  PROTOTYPES: DISABLE
87    
88    int
89    set_debug(int state)
90    
91    int
92    get_debug()
93    
94    int
95    reset()
96    
97  void  void
98  run()  update_C_R()
99    
100  void  void
101  reset()  update_perl_R()
102    

Legend:
Removed from v.82  
changed lines
  Added in v.87

  ViewVC Help
Powered by ViewVC 1.1.26