/[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 39 by dpavlin, Mon Jul 30 23:39:57 2007 UTC revision 60 by dpavlin, Tue Jul 31 16:20:06 2007 UTC
# Line 5  Line 5 
5    
6  #if DEBUGF  #if DEBUGF
7  #define debugf(x)  do {         \  #define debugf(x)  do {         \
8            PerlIO_stdoutf("#> ");  \
9          PerlIO_stdoutf x ;      \          PerlIO_stdoutf x ;      \
10  } while (0)  } while (0)
11  #else  #else
# Line 111  byte Op6502(register word Addr) { Line 112  byte Op6502(register word Addr) {
112          byte Op;          byte Op;
113          Op = mem(Addr);          Op = mem(Addr);
114          debugf(("Op6502(%04x,%02x) PC:%04x\n", Addr, Op, R->PC.W));          debugf(("Op6502(%04x,%02x) PC:%04x\n", Addr, Op, R->PC.W));
115            return Op;
116  }  }
117    
118  /** Loop6502() ***********************************************/  /** Loop6502() ***********************************************/
# Line 120  byte Op6502(register word Addr) { Line 122  byte Op6502(register word Addr) {
122  /** INT_NONE, INT_IRQ, INT_NMI, or INT_QUIT to exit the     **/  /** INT_NONE, INT_IRQ, INT_NMI, or INT_QUIT to exit the     **/
123  /** emulation loop.                                         **/  /** emulation loop.                                         **/
124  /************************************ TO BE WRITTEN BY USER **/  /************************************ TO BE WRITTEN BY USER **/
125    
126    int hw_int = INT_NONE;
127    
128  byte Loop6502(register M6502 *R) {  byte Loop6502(register M6502 *R) {
129          debugf(("Loop6502\n"));          debugf(("Loop6502\n"));
130          dump_R;          dump_R;
131          return INT_NONE;          return hw_int;
132  }  }
133    
134  /** Patch6502() **********************************************/  /** Patch6502() **********************************************/
# Line 170  int main(int argc, char **argv) { Line 175  int main(int argc, char **argv) {
175                  dSP;                  dSP;
176                  PUSHMARK(SP);                  PUSHMARK(SP);
177                  call_pv("Arch::init", G_DISCARD | G_NOARGS );                  call_pv("Arch::init", G_DISCARD | G_NOARGS );
178                    FREETMPS;
179                    LEAVE;
180    
181                  pull_R(R);                  int cycles = 1;
182                  printf("run CPU\n");                  while ( cycles ) {
183                  dump_R;                          dSP;
184                  //Run6502(R);                          PUSHMARK(SP);
185                  Exec6502(R, DEFAULT_RUN);                          call_pv("Arch::cli", G_DISCARD | G_NOARGS );
186                  dump_R;                          pull_R(R);
187                  push_R(R);                          FREETMPS;
188                  printf("end of CPU run\n");                          LEAVE;
189                            cycles = SvIV( get_sv("M6502::run_for", FALSE) );
190                            if ( cycles > 0 ) {
191                                    printf("run CPU for %d cycles\n", cycles);
192                                    dump_R;
193                                    //Run6502(R);
194                                    Exec6502(R, cycles);
195                                    dump_R;
196                                    push_R(R);
197                                    printf("end of %d cycles CPU run\n", cycles);
198                            } else {
199                                    printf("no cpu cycles set for run\n");
200                                    cycles = 1; // never exit, prevents segfault
201                            }
202                    }
203          }          }
204          free(R);          free(R);
205          perl_destruct(my_perl);          perl_destruct(my_perl);

Legend:
Removed from v.39  
changed lines
  Added in v.60

  ViewVC Help
Powered by ViewVC 1.1.26