--- M6502/Screen.pm 2007/07/30 18:37:37 32 +++ M6502/Screen.pm 2007/07/30 21:00:36 33 @@ -9,8 +9,10 @@ use SDL::Rect; use SDL::Color; +use Carp qw/confess/; + use base qw(Class::Accessor); -__PACKAGE__->mk_accessors(qw(debug scale show_mem run_for mem_dump trace)); +__PACKAGE__->mk_accessors(qw(debug scale show_mem mem_dump trace app)); =head2 open_screen @@ -36,6 +38,7 @@ #$app->grab_input( 0 ); warn "# created SDL::App\n"; + $self->app( $app ); } my $white = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff ); @@ -122,17 +125,29 @@ sub mmap_pixel { my ( $self, $addr, $r, $g, $b ) = @_; + return unless $self->show_mem && $self->app; - my ( $x, $y ) = mem_xy( $addr ); + my ( $x, $y ) = $self->mem_xy( $addr ); warn sprintf "## mem %04x %02x %02x %02d*%02d\n", $addr, $r, $g, $x, $y if $self->trace; - my $col = sdl::color->new( -r => $r, -g => $g, -b => $b ); - $app->pixel( $x, $y, $col ); + my $col = SDL::Color->new( -r => $r, -g => $g, -b => $b ); + $self->app->pixel( $x, $y, $col ); $_mem_stat++; if ( $_mem_stat % 1000 == 0 ) { - $app->sync; + $self->app->sync; } } + +=head2 sync + + $self->sync; + +=cut + +sub sync { + $app->sync; +} + 1;