/[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

Diff of /M6502/perl.c

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

revision 33 by dpavlin, Mon Jul 30 21:00:36 2007 UTC revision 34 by dpavlin, Mon Jul 30 21:34:30 2007 UTC
# Line 3  Line 3 
3  #include "M6502.h"  #include "M6502.h"
4  #include "config.h"  #include "config.h"
5    
6  #ifdef DEBUGF  #if DEBUGF
7  #define debugf(x)  do {         \  #define debugf(x)  do {         \
8          PerlIO_stdoutf x ;      \          PerlIO_stdoutf x ;      \
9  } while (0)  } while (0)
# Line 15  static PerlInterpreter *my_perl; Line 15  static PerlInterpreter *my_perl;
15    
16  static M6502 *R;  static M6502 *R;
17    
18  #if 0  #if DUMP_R
19  #define dump_R printf("# PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", R->PC.W, R->A, R->P, R->X, R->Y, R->S );  #define dump_R printf("# PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", R->PC.W, R->A, R->P, R->X, R->Y, R->S );
20  #else  #else
21  #define dump_R  #define dump_R
22  #endif  #endif
23    
24  void update_R(M6502 *R) {  void update_R(M6502 *R) {
         printf("--0\n");  
25          R->A = SvIV( get_sv("M6502::A", FALSE) );          R->A = SvIV( get_sv("M6502::A", FALSE) );
26          printf("--1\n");          printf("--%d", get_sv("M6502::A", FALSE) );
27          R->P = atoi( SvPV_nolen( get_sv("M6502::P", FALSE) ) );          R->P = SvIV( get_sv("M6502::P", FALSE) );
28          R->X = atoi( SvPV_nolen( get_sv("M6502::X", FALSE) ) );          R->X = atoi( SvPV_nolen( get_sv("M6502::X", FALSE) ) );
29          R->Y = atoi( SvPV_nolen( get_sv("M6502::Y", FALSE) ) );          R->Y = atoi( SvPV_nolen( get_sv("M6502::Y", FALSE) ) );
30          R->S = atoi( SvPV_nolen( get_sv("M6502::S", FALSE) ) );          R->S = atoi( SvPV_nolen( get_sv("M6502::S", FALSE) ) );
# Line 64  byte mem(word Addr) { Line 63  byte mem(word Addr) {
63          byte = SvIV(sv);          byte = SvIV(sv);
64          FREETMPS;          FREETMPS;
65          LEAVE;          LEAVE;
66          debugf(("Rd6502(%04x) = %02x\n", Addr, byte));          //debugf(("mem(%04x) = %02x\n", Addr, byte));
67          return byte;          return byte;
68  }  }
69    
70  byte Rd6502(register word Addr) {  byte Rd6502(register word Addr) {
71          byte Value;          byte Value;
72          Value = mem(Addr);          Value = mem(Addr);
73            debugf(("Rd6502(%04x) = %02x\n", Addr, Value));
74          return Value;          return Value;
75  }  }
76    
# Line 145  int main(int argc, char **argv) { Line 145  int main(int argc, char **argv) {
145                          exit(1);                          exit(1);
146                  }                  }
147    
                 update_R(R);  
   
148                  printf("reset CPU\n");                  printf("reset CPU\n");
149                  Reset6502(R);                  Reset6502(R);
150    
# Line 155  int main(int argc, char **argv) { Line 153  int main(int argc, char **argv) {
153                  PUSHMARK(SP);                  PUSHMARK(SP);
154                  call_pv("Arch::init", G_DISCARD | G_NOARGS );                  call_pv("Arch::init", G_DISCARD | G_NOARGS );
155    
156                    update_R(R);
157                  printf("run CPU\n");                  printf("run CPU\n");
158                  Run6502(R);                  Run6502(R);
159    

Legend:
Removed from v.33  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26