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

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

revision 41 by dpavlin, Tue Jul 31 08:49:22 2007 UTC revision 73 by dpavlin, Tue Jul 31 21:43:57 2007 UTC
# Line 11  use SDL::Color; Line 11  use SDL::Color;
11    
12  use Carp qw/confess/;  use Carp qw/confess/;
13    
14  use base qw(Class::Accessor);  use base qw(Class::Accessor Prefs);
15  __PACKAGE__->mk_accessors(qw(debug scale show_mem mem_dump trace app));  __PACKAGE__->mk_accessors(qw(app));
16    
17    =head1 NAME
18    
19    Screen - simulated 256*256 pixels monochrome screen using SDL
20    
21  =head2 open_screen  =head2 open_screen
22    
# Line 25  our $app; Line 29  our $app;
29  sub open_screen {  sub open_screen {
30          my $self = shift;          my $self = shift;
31    
32            $self->prefs;
33    
34          if ( ! $self->scale ) {          if ( ! $self->scale ) {
35                  $self->scale( 1 );                  $self->scale( 1 );
36                  warn "using default unscaled display\n";                  warn "using default unscaled display\n";
# Line 107  sub vram { Line 113  sub vram {
113          my $mask = 1;          my $mask = 1;
114          my $scale = $self->scale;          my $scale = $self->scale;
115    
116  #       printf "## vram %04x %02x*%02x %02x\n", $offset, $x, $y, $byte if $self->trace;          printf "## vram %04x %02x*%02x %02x\n", $offset, $x, $y, $byte if $self->trace;
117    
118          foreach ( 0 .. 7 ) {          foreach ( 0 .. 7 ) {
119                  my $on = $byte & $mask;                  my $on = $byte & $mask;
# Line 160  sub sync { Line 166  sub sync {
166          $app->sync;          $app->sync;
167  }  }
168    
169    =head2 render
170    
171      $self->render( @video_memory );
172    
173    =cut
174    
175    sub render {
176            my $self = shift;
177    
178            die "this function isn't supported if scale isn't 1" unless $self->scale == 1;
179    
180            $app->lock;
181    
182            my ( $x, $y ) = ( 0,0 );
183    
184            foreach my $b ( @_ ) {
185                    foreach my $p ( split(//, unpack("B8",pack("C",$b)) ) ) {
186                            $app->pixel( $x, $y, $p ? $white : $black );
187                            $x++;
188                    }
189                    if ( $x == 256 ) {
190                            $x = 0;
191                            $y++;
192                    }
193            }
194    
195            $app->unlock;
196            $app->sync;
197    
198            warn "Screen::render over\n";
199    }
200    
201    =head1 SEE ALSO
202    
203    L<Orao> is sample implementation using this module
204    
205    =head1 AUTHOR
206    
207    Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
208    
209    =head1 COPYRIGHT & LICENSE
210    
211    Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
212    
213    This program is free software; you can redistribute it and/or modify it
214    under the same terms as Perl itself.
215    
216    =cut
217  1;  1;

Legend:
Removed from v.41  
changed lines
  Added in v.73

  ViewVC Help
Powered by ViewVC 1.1.26