--- Screen.pm 2007/08/06 11:40:21 171 +++ Screen.pm 2007/09/30 19:31:14 183 @@ -17,17 +17,25 @@ our @EXPORT = qw'$white $black @flip'; use base qw(Class::Accessor Prefs); -__PACKAGE__->mk_accessors(qw(app event)); +__PACKAGE__->mk_accessors(qw(app event screen_width screen_height)); =head1 NAME -Screen - simulated 256*256 pixels monochrome screen using SDL +Screen - simulated monochrome screen using SDL =head1 Architecture dependent You may override following methods if you want to implement keyboard on each keypress event. Alternative is to use hook and trap memory access. +=head2 screen_width + +Width of emulated screen (256 by default) + +=head2 screen_height + +Height of emulated screen (256 by default) + =head2 key_down $self->key_down( 'a' ); @@ -68,9 +76,12 @@ warn "using default unscaled display\n"; } + $self->screen_width( 256 ) unless defined $self->screen_width; + $self->screen_height( 256 ) unless defined $self->screen_height; + $app = SDL::App->new( - -width => 256 * $self->scale + ( $self->show_mem ? 256 : 0 ), - -height => 256 * $self->scale, + -width => $self->screen_width * $self->scale + ( $self->show_mem ? 256 : 0 ), + -height => $self->screen_height * $self->scale, -depth => 16, -flags=>SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWACCEL, ); @@ -83,7 +94,7 @@ my $event = SDL::Event->new(); $self->event( $event ); - warn "# created SDL::App\n"; + warn "# created SDL::App with screen ", $self->screen_width, "x", $self->screen_height, "\n"; } our $white = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff ); @@ -105,7 +116,7 @@ my $self = shift; my $offset = shift; my $x = $offset & 0xff; - $x += 256 * $self->scale; + $x += $self->screen_width * $self->scale; my $y = $offset >> 8; return ($x,$y); } @@ -181,8 +192,9 @@ my $scale = $self->scale || confess "no scale?"; - my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256 * $scale, -height => 256 * $scale ); - my $rect_screen = SDL::Rect->new( -x => 0, -y => 0, -width => 256 * $scale, -height => 256 * $scale ); + my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => $self->screen_width * $scale, -height => $self->screen_height * $scale + ); + my $rect_screen = SDL::Rect->new( -x => 0, -y => 0, -width => $self->screen_width * $scale, -height => $self->screen_height * $scale ); if ( $scale > 1 ) { use SDL::Tool::Graphic; @@ -223,8 +235,8 @@ $vram->display_format; - my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 ); - my $rect_mem = SDL::Rect->new( -x => 256 * $self->scale, -y => 0, -width => 256, -height => 256 ); + my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => $self->screen_width, -height => $self->screen_height ); + my $rect_mem = SDL::Rect->new( -x => $self->screen_width * $self->scale, -y => 0, -width => 256, -height => 256 ); $vram->blit( $rect, $app, $rect_mem );