/[VRac]/M6502/Orao.pm
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/Orao.pm

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

revision 38 by dpavlin, Mon Jul 30 23:28:25 2007 UTC revision 43 by dpavlin, Tue Jul 31 09:43:21 2007 UTC
# Line 39  Start emulator Line 39  Start emulator
39    
40  our $orao;  our $orao;
41    
42    select(STDERR); $| = 1;
43    
44  sub init {  sub init {
45          my $self = shift;          my $self = shift;
46          warn "Orao calling upstream init\n";          warn "Orao calling upstream init\n";
# Line 54  sub init { Line 56  sub init {
56          });          });
57    
58          $self->load_oraoemu( 'dump/orao-1.2' );          $self->load_oraoemu( 'dump/orao-1.2' );
59          $self->load_oraoemu( 'dump/SCRINV.BIN' );          $self->load_oraoemu( 'dump/SCRINV.BIN', 0x1000 );
60          $PC = 0x1000;          $PC = 0x1000;
61    
62          $orao = $self;          $orao = $self;
# Line 104  sub init { Line 106  sub init {
106          $self->sync;          $self->sync;
107          $self->trace( $trace );          $self->trace( $trace );
108    
109          ( $A, $P, $X, $Y, $S, $IPeriod ) = ( 1, 2, 3, 4, 5, 6 );          #( $A, $P, $X, $Y, $S, $IPeriod ) = ( 1, 2, 3, 4, 5, 6 );
110    
111          warn "Orao init finished", $self->trace ? ' trace on' : '', "\n";          warn "Orao init finished", $self->trace ? ' trace on' : '', "\n";
112    
# Line 150  sub load_oraoemu { Line 152  sub load_oraoemu {
152          } elsif ( $size == 32800 ) {          } elsif ( $size == 32800 ) {
153                  $addr = 0;                  $addr = 0;
154                  warn sprintf "loading oraoemu 1.3 dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;                  warn sprintf "loading oraoemu 1.3 dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
155                  #$self->write_chunk( $addr, substr($buff,0x20) );                  $self->write_chunk( $addr, substr($buff,0x20) );
                 $self->poke_code( $addr, map { ord($_) } split(//,substr($buff,0x20)) );  
156                  return;                  return;
157          }          }
158          printf "loading %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;          printf "loading %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
         return $self->poke_code( $addr, map { ord($_) } split(//,$buff) );  
159          return $self->write_chunk( $addr, $buff );          return $self->write_chunk( $addr, $buff );
160    
161          my $chunk;          my $chunk;
# Line 224  sub hexdump { Line 224  sub hexdump {
224    
225  sub prompt {  sub prompt {
226          my $self = shift;          my $self = shift;
227            $self->app->sync;
228          my $a = shift;          my $a = shift;
229          my $last = shift;          my $last = shift;
230          print STDERR $self->hexdump( $a ),          print STDERR $self->hexdump( $a ),
# Line 255  sub read { Line 256  sub read {
256          my $self = shift;          my $self = shift;
257          my ($addr) = @_;          my ($addr) = @_;
258          my $byte = $mem[$addr];          my $byte = $mem[$addr];
259          warn "# Orao::read(",dump(@_),") = ",dump( $byte ),"\n" if $self->debug;          warn sprintf("# Orao::read(%04x) = %02x\n", $addr, $byte) if $self->trace;
260          $self->mmap_pixel( $addr, 0, $byte, 0 );          $self->mmap_pixel( $addr, 0, $byte, 0 );
261          return $byte;          return $byte;
262  }  }
# Line 270  Write into emory Line 271  Write into emory
271    
272  sub write {  sub write {
273          my $self = shift;          my $self = shift;
         warn "# Orao::write(",dump(@_),")\n" if $self->debug;  
274          my ($addr,$byte) = @_;          my ($addr,$byte) = @_;
275            warn sprintf("# Orao::write(%04x,%02x)\n", $addr, $byte) if $self->trace;
276    
277          if ( $addr >= 0x6000 && $addr < 0x8000 ) {          if ( $addr >= 0x6000 && $addr < 0x8000 ) {
278                  $self->vram( $addr - 0x6000 , $byte );                  $self->vram( $addr - 0x6000 , $byte );
# Line 291  sub write { Line 292  sub write {
292          return;          return;
293  }  }
294    
295    =head1 Command Line
296    
297    Command-line debugging intrerface is implemented for communication with
298    emulated device
299    
300    =head2 cli
301    
302      $orao->cli();
303    
304    =cut
305    
306    my $last = 'r 1';
307    
308    sub cli {
309            my $self = shift;
310            my $a = $PC || confess "no pc?";
311            while ( my @v = $self->prompt( $a, $last ) ) {
312                    my $c = shift @v;
313                    my $v = shift @v;
314                    $v = hex($v) if $v && $v =~ m/^[0-9a-f]+$/;
315                    printf "## [%s] %s\n", ($v || 'undef'), join(",",@v) if $self->debug;
316                    @v = map { hex($_) } @v;
317                    if ( $c =~ m/^[qx]/i ) {
318                            exit;
319                    } elsif ( $c eq '?' ) {
320                            warn <<__USAGE__;
321    uage:
322    x|q\t\texit
323    e 6000 6010\tdump memory, +/- to walk forward/backward
324    m 1000 ff 00\tput ff 00 on 1000
325    j|u 1000\t\tjump (change pc)
326    r 42\t\trun 42 instruction opcodes
327    __USAGE__
328                    } elsif ( $c =~ m/^e/i ) {
329                            $a ||= $v;
330                            my $to = shift @v;
331                            $to = $a + 32 if ( ! $to || $to <= $a );
332                            my $lines = int( ($to - $a - 8) / 8 );
333                            printf "## m %04x %04x lines: %d\n", $a, $to, $lines;
334                            while ( $lines ) {
335                                    print $self->hexdump( $a );
336                                    $a += 8;
337                                    $lines--;
338                            }
339                            $last = '+';
340                    } elsif ( $c =~ m/^\+/ ) {
341                            $a += 8;
342                    } elsif ( $c =~ m/^\-/ ) {
343                            $a -= 8;
344                    } elsif ( $c =~ m/^m/i ) {
345                            $a = $v;
346                            $self->poke_code( $a, @v );
347                            printf "poke %d bytes at %04x\n", $#v + 1, $a;
348                    } elsif ( $c =~ m/^l/i ) {
349                            my $to = shift @v || 0x1000;
350                            $a = $to;
351                            $self->load_oraoemu( $v, $a );
352                    } elsif ( $c =~ m/^s/i ) {
353                            $self->save_dump( $v || 'mem.dump', @v );
354                    } elsif ( $c =~ m/^r/i ) {
355                            $run_for = $v || 1;
356                            print "run_for $run_for instructions\n";
357                            last;
358                    } elsif ( $c =~ m/^(u|j)/ ) {
359                            my $to = $v || $a;
360                            printf "set pc to %04x\n", $to;
361                            $PC = $to;      # remember for restart
362                            $run_for = 1;
363                            last;
364                    } elsif ( $c =~ m/^t/ ) {
365                            $self->trace( not $self->trace );
366                            print "trace ", $self->trace ? 'on' : 'off', "\n";
367                    } else {
368                            warn "# ignore $c\n";
369                            last;
370                    }
371            }
372    
373    
374    }
375    
376  =head1 AUTHOR  =head1 AUTHOR
377    

Legend:
Removed from v.38  
changed lines
  Added in v.43

  ViewVC Help
Powered by ViewVC 1.1.26