--- M6502/Orao.pm 2007/07/31 16:22:10 61 +++ M6502/Orao.pm 2007/07/31 21:43:57 73 @@ -51,11 +51,12 @@ $self->open_screen; $self->load_rom({ 0x1000 => 'dump/SCRINV.BIN', +# 0x6000 => 'dump/screen.dmp', 0xC000 => 'rom/BAS12.ROM', 0xE000 => 'rom/CRT12.ROM', }); - $PC = 0xDD11; # BC +# $PC = 0xDD11; # BC # $PC = 0xC274; # MC $orao = $self; @@ -66,6 +67,8 @@ $self->trace( 0 ); $self->debug( 0 ); + $self->render( @mem[ 0x6000 .. 0x7fff ] ); + if ( $self->show_mem ) { warn "rendering memory map\n"; @@ -98,9 +101,10 @@ } else { warn "rendering video memory\n"; - for my $a ( 0x6000 .. 0x7fff ) { - $self->vram( $a - 0x6000, $mem[$a] ); - } +# for my $a ( 0x6000 .. 0x7fff ) { +# $self->vram( $a - 0x6000, $mem[$a] ); +# } + $self->render( @mem[ 0x6000 .. 0x7fff ] ); } $self->sync; @@ -152,9 +156,10 @@ $t = $end if ( $end < $t ); warn sprintf("refresh video ram %04x-%04x\n", $f, $t); - foreach my $a ( $f .. $t ) { - $self->vram( $a - 0x6000 , $mem[ $a ] ); - } +# foreach my $a ( $f .. $t ) { +# $self->vram( $a - 0x6000 , $mem[ $a ] ); +# } + $self->render( @mem[ 0x6000 .. 0x7fff ] ); } =head2 load_oraoemu @@ -248,7 +253,11 @@ return sprintf(" %04x %s\n", $a, join(" ", map { - sprintf( "%02x", $_ ) + if ( defined($_) ) { + sprintf( "%02x", $_ ) + } else { + ' ' + } } @mem[ $a .. $a+8 ] ) ); @@ -300,7 +309,8 @@ } if ( $addr > 0xafff ) { - confess sprintf "write access 0x%04x > 0xafff aborting\n", $addr; + warn sprintf "write access 0x%04x > 0xafff aborting\n", $addr; + return; } $self->mmap_pixel( $addr, $byte, 0, 0 ); @@ -343,9 +353,12 @@ =cut +my $show_R = 0; + sub cli { my $self = shift; my $a = $PC || confess "no pc?"; + warn $self->dump_R() if $show_R; while ( my ($line, @v) = $self->prompt( $a, $last ) ) { my $c = shift @v; next unless defined($c); @@ -370,11 +383,12 @@ d\t\tdebug [$d] __USAGE__ - warn sprintf(" PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S); + warn $self->dump_R; } elsif ( $c =~ m/^e/i ) { $a = $v if defined($v); my $to = shift @v; $to = $a + 32 if ( ! $to || $to <= $a ); + $to = 0xffff if ( $to > 0xffff ); my $lines = int( ($to - $a + 8) / 8 ); printf "## e %04x %04x (%d bytes) lines: %d\n", $a, $to, ($to-$a), $lines; while ( --$lines ) { @@ -382,15 +396,19 @@ $a += 8; } $last = '+'; + $show_R = 0; } elsif ( $c =~ m/^\+/ ) { $a += 8; + $show_R = 0; } elsif ( $c =~ m/^\-/ ) { $a -= 8; + $show_R = 0; } elsif ( $c =~ m/^m/i ) { - $a = $v; + $a = $v if defined($v); $self->poke_code( $a, @v ); printf "poke %d bytes at %04x\n", $#v + 1, $a; $last = '+'; + $show_R = 0; } elsif ( $c =~ m/^l/i ) { my $to = shift @v || 0x1000; $a = $to; @@ -402,20 +420,24 @@ } elsif ( $c =~ m/^r/i ) { $run_for = $v || 1; print "run_for $run_for instructions\n"; + $show_R = 1; last; } elsif ( $c =~ m/^(u|j)/ ) { my $to = $v || $a; printf "set pc to %04x\n", $to; $PC = $to; # remember for restart $run_for = 1; - $last = sprintf('m %04x', $to); + $last = "r $run_for"; + $show_R = 1; last; } elsif ( $c =~ m/^t/ ) { $self->trace( not $self->trace ); print "trace ", $self->trace ? 'on' : 'off', "\n"; + $last = ''; } elsif ( $c =~ m/^d/ ) { $self->debug( not $self->debug ); print "debug ", $self->debug ? 'on' : 'off', "\n"; + $last = ''; } else { warn "# ignored $line\n" if ($line); $last = '';