/[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 42 by dpavlin, Tue Jul 31 09:37:01 2007 UTC revision 74 by dpavlin, Tue Jul 31 23:48:19 2007 UTC
# Line 30  void pull_R(M6502 *R) { Line 30  void pull_R(M6502 *R) {
30          R->S = SvIV( get_sv("M6502::S", FALSE) );          R->S = SvIV( get_sv("M6502::S", FALSE) );
31          R->PC.W = SvIV( get_sv("M6502::PC", FALSE) );          R->PC.W = SvIV( get_sv("M6502::PC", FALSE) );
32          R->IPeriod = SvIV( get_sv("M6502::IPeriod", FALSE) );          R->IPeriod = SvIV( get_sv("M6502::IPeriod", FALSE) );
33          // ICount IRequest IAutoReset TrapBadOps Trap Trace          R->IRequest = SvIV( get_sv("M6502::IRequest", FALSE) );
34            R->IAutoReset = SvIV( get_sv("M6502::IAutoReset", FALSE) );
35            R->TrapBadOps = SvIV( get_sv("M6502::TrapBadOps", FALSE) );
36            R->Trap = SvIV( get_sv("M6502::Trap", FALSE) );
37            R->Trace = SvIV( get_sv("M6502::Trace", FALSE) );
38          printf("pull_R finished\n");          printf("pull_R finished\n");
39          dump_R;          dump_R;
40  }  }
# Line 46  void push_R(M6502 *R) { Line 50  void push_R(M6502 *R) {
50          XPUSHs( sv_2mortal( newSViv( R->Y ) ) );          XPUSHs( sv_2mortal( newSViv( R->Y ) ) );
51          XPUSHs( sv_2mortal( newSViv( R->S ) ) );          XPUSHs( sv_2mortal( newSViv( R->S ) ) );
52          XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) );          XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) );
53            XPUSHs( sv_2mortal( newSViv( R->IPeriod ) ) );
54            XPUSHs( sv_2mortal( newSViv( R->ICount ) ) );
55            XPUSHs( sv_2mortal( newSViv( R->IRequest ) ) );
56            XPUSHs( sv_2mortal( newSViv( R->IAutoReset ) ) );
57            XPUSHs( sv_2mortal( newSViv( R->TrapBadOps ) ) );
58            XPUSHs( sv_2mortal( newSViv( R->Trap ) ) );
59            XPUSHs( sv_2mortal( newSViv( R->Trace ) ) );
60          PUTBACK;          PUTBACK;
61          call_pv("M6502::push_R", G_DISCARD );          call_pv("M6502::push_R", G_DISCARD );
62          printf("push_R called\n");          printf("push_R called\n");
# Line 141  byte Loop6502(register M6502 *R) { Line 152  byte Loop6502(register M6502 *R) {
152  byte Patch6502(register byte Op,register M6502 *R) {  byte Patch6502(register byte Op,register M6502 *R) {
153          debugf(("Patch6502(%02x)\n", Op));          debugf(("Patch6502(%02x)\n", Op));
154          dump_R;          dump_R;
155            hw_int = INT_QUIT;
156          return 0;          return 0;
157  }  }
158    
# Line 175  int main(int argc, char **argv) { Line 187  int main(int argc, char **argv) {
187                  dSP;                  dSP;
188                  PUSHMARK(SP);                  PUSHMARK(SP);
189                  call_pv("Arch::init", G_DISCARD | G_NOARGS );                  call_pv("Arch::init", G_DISCARD | G_NOARGS );
190                    FREETMPS;
191                    LEAVE;
192    
193                  int cycles = 1;                  int cycles = 1;
194                  while ( cycles ) {                  while ( cycles ) {
195                            dSP;
196                            PUSHMARK(SP);
197                          call_pv("Arch::cli", G_DISCARD | G_NOARGS );                          call_pv("Arch::cli", G_DISCARD | G_NOARGS );
198                          pull_R(R);                          pull_R(R);
199                            FREETMPS;
200                            LEAVE;
201                          cycles = SvIV( get_sv("M6502::run_for", FALSE) );                          cycles = SvIV( get_sv("M6502::run_for", FALSE) );
202                          printf("run CPU for %d cycles\n", cycles);                          if ( cycles > 0 ) {
203                          dump_R;                                  printf("run CPU for %d cycles\n", cycles);
204                          //Run6502(R);                                  dump_R;
205                          Exec6502(R, cycles);                                  //Run6502(R);
206                          dump_R;                                  Exec6502(R, cycles);
207                          push_R(R);                                  dump_R;
208                          printf("end of %d cycles CPU run\n", cycles);                                  push_R(R);
209                                    printf("end of %d cycles CPU run\n", cycles);
210                            } else {
211                                    printf("no cpu cycles set for run\n");
212                                    cycles = 1; // never exit, prevents segfault
213                            }
214                  }                  }
215          }          }
216          free(R);          free(R);

Legend:
Removed from v.42  
changed lines
  Added in v.74

  ViewVC Help
Powered by ViewVC 1.1.26