--- M6502/Screen.pm 2007/07/31 23:48:19 74 +++ M6502/Screen.pm 2007/08/01 12:40:20 75 @@ -8,8 +8,10 @@ use SDL::App; use SDL::Rect; use SDL::Color; +use SDL::Constants; use Carp qw/confess/; +use Data::Dump qw/dump/; use base qw(Class::Accessor Prefs); __PACKAGE__->mk_accessors(qw(app)); @@ -41,7 +43,8 @@ -height => 256 * $self->scale, -depth => 16, ); - #$app->grab_input( 0 ); + #$app->grab_input( SDL_GRAB_QUERY ); + $app->grab_input( SDL_GRAB_OFF ); warn "# created SDL::App\n"; $self->app( $app ); @@ -177,25 +180,22 @@ die "this function isn't supported if scale isn't 1" unless $self->scale == 1; - $app->lock; + my $pixels = pack("C*", @_); - my ( $x, $y ) = ( 0,0 ); + my $vram = SDL::Surface->new( + -width => 256, + -height => 256, + -depth => 1, # 1 bit per pixel + -pitch => 32, # bytes per line + -from => $pixels, + ); + $vram->set_colors( 0, $black, $white, $red ); + $vram->display_format; - foreach my $b ( @_ ) { - foreach my $p ( split(//, unpack("B8",pack("C",$b)) ) ) { - $app->pixel( $x, $y, $p ? $white : $black ); - $x++; - } - if ( $x == 256 ) { - $x = 0; - $y++; - } - } + my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 ); + $vram->blit( $rect, $app, $rect ); - $app->unlock; $app->sync; - - warn "Screen::render over\n"; } =head1 SEE ALSO