/[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 79 by dpavlin, Tue Jul 31 23:48:19 2007 UTC revision 80 by dpavlin, Wed Aug 1 15:34:43 2007 UTC
# Line 156  byte Patch6502(register byte Op,register Line 156  byte Patch6502(register byte Op,register
156          return 0;          return 0;
157  }  }
158    
159    void run_forever(void) {
160            printf("entered run_forever\n");
161    
162            R = malloc(sizeof(M6502));
163            if (!R) {
164                    printf("can't alloc %d bytes for M6502", sizeof(M6502));
165                    exit(1);
166            }
167    
168            printf("reset CPU\n");
169            Reset6502(R);
170    
171            printf("call Arch::init\n");
172            dSP;
173            PUSHMARK(SP);
174            call_pv("Arch::init", G_DISCARD | G_NOARGS );
175            FREETMPS;
176            LEAVE;
177    
178            int cycles = 1;
179            while ( cycles ) {
180                    dSP;
181                    PUSHMARK(SP);
182                    call_pv("Arch::cli", G_DISCARD | G_NOARGS );
183                    pull_R(R);
184                    FREETMPS;
185                    LEAVE;
186                    cycles = SvIV( get_sv("M6502::run_for", FALSE) );
187                    if ( cycles > 0 ) {
188                            printf("run CPU for %d cycles\n", cycles);
189                            dump_R;
190                            //Run6502(R);
191                            Exec6502(R, cycles);
192                            dump_R;
193                            push_R(R);
194                            printf("end of %d cycles CPU run\n", cycles);
195                    } else {
196                            printf("no cpu cycles set for run\n");
197                            cycles = 1; // never exit, prevents segfault
198                    }
199            }
200            free(R);
201    }
202    
203  /**  /**
204   * main code   * main code
205   *   *
# Line 174  int main(int argc, char **argv) { Line 218  int main(int argc, char **argv) {
218                  printf("Failed to execute\n");                  printf("Failed to execute\n");
219                  return 0;                  return 0;
220          } else {          } else {
221                  R = malloc(sizeof(M6502));                  run_forever();
                 if (!R) {  
                         printf("can't alloc %d bytes for M6502", sizeof(M6502));  
                         exit(1);  
                 }  
   
                 printf("reset CPU\n");  
                 Reset6502(R);  
   
                 printf("call Arch::init\n");  
                 dSP;  
                 PUSHMARK(SP);  
                 call_pv("Arch::init", G_DISCARD | G_NOARGS );  
                 FREETMPS;  
                 LEAVE;  
   
                 int cycles = 1;  
                 while ( cycles ) {  
                         dSP;  
                         PUSHMARK(SP);  
                         call_pv("Arch::cli", G_DISCARD | G_NOARGS );  
                         pull_R(R);  
                         FREETMPS;  
                         LEAVE;  
                         cycles = SvIV( get_sv("M6502::run_for", FALSE) );  
                         if ( cycles > 0 ) {  
                                 printf("run CPU for %d cycles\n", cycles);  
                                 dump_R;  
                                 //Run6502(R);  
                                 Exec6502(R, cycles);  
                                 dump_R;  
                                 push_R(R);  
                                 printf("end of %d cycles CPU run\n", cycles);  
                         } else {  
                                 printf("no cpu cycles set for run\n");  
                                 cycles = 1; // never exit, prevents segfault  
                         }  
                 }  
222          }          }
         free(R);  
223          perl_destruct(my_perl);          perl_destruct(my_perl);
224          perl_free(my_perl);          perl_free(my_perl);
225          return 0;          return 0;

Legend:
Removed from v.79  
changed lines
  Added in v.80

  ViewVC Help
Powered by ViewVC 1.1.26