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

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

revision 33 by dpavlin, Mon Jul 30 21:00:36 2007 UTC revision 55 by dpavlin, Tue Jul 31 13:56:50 2007 UTC
# Line 12  use SDL::Color; Line 12  use SDL::Color;
12  use Carp qw/confess/;  use Carp qw/confess/;
13    
14  use base qw(Class::Accessor);  use base qw(Class::Accessor);
15  __PACKAGE__->mk_accessors(qw(debug scale show_mem mem_dump trace app));  #__PACKAGE__->mk_accessors(qw(debug scale show_mem trace 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 98  Push byte to video memory and draw it Line 102  Push byte to video memory and draw it
102    
103  =cut  =cut
104    
105    my $_vram_counter;
106    
107  sub vram {  sub vram {
108          my ( $self, $offset, $byte ) = @_;          my ( $self, $offset, $byte ) = @_;
109          my $x = ( $offset % 32 ) << 3;          my $x = ( $offset % 32 ) << 3;
110          my $y = $offset >> 5;          my $y = $offset >> 5;
111          my $mask = 1;          my $mask = 1;
112            my $scale = $self->scale;
113    
114          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;
115    
116          foreach ( 0 .. 7 ) {          foreach ( 0 .. 7 ) {
117                  p($x + $_, $y, $byte & $mask );                  my $on = $byte & $mask;
118                    if ( $scale == 1 ) {
119                            $app->pixel( $x + $_, $y, $on ? $white : $black );
120                    } else {
121                            $self->p($x + $_, $y, $on );
122                    }
123                  $mask = $mask << 1;                  $mask = $mask << 1;
124          }          }
125    
126            $app->sync if ( $_vram_counter++ % 10 == 0 );
127  }  }
128    
129  =head2 mmap_pixel  =head2 mmap_pixel
# Line 128  sub mmap_pixel { Line 142  sub mmap_pixel {
142          return unless $self->show_mem && $self->app;          return unless $self->show_mem && $self->app;
143    
144          my ( $x, $y ) = $self->mem_xy( $addr );          my ( $x, $y ) = $self->mem_xy( $addr );
145          warn sprintf "## mem %04x %02x %02x %02d*%02d\n", $addr, $r, $g, $x, $y if $self->trace;          warn sprintf "## mem %04x %02x %02x %02d*%02d\n", $addr, $r, $g, $x, $y if $self->debug;
146    
147          my $col = SDL::Color->new( -r => $r, -g => $g, -b => $b );          my $col = SDL::Color->new( -r => $r, -g => $g, -b => $b );
148          $self->app->pixel( $x, $y, $col );          $self->app->pixel( $x, $y, $col );
# Line 150  sub sync { Line 164  sub sync {
164          $app->sync;          $app->sync;
165  }  }
166    
167    =head1 SEE ALSO
168    
169    L<Orao> is sample implementation using this module
170    
171    =head1 AUTHOR
172    
173    Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
174    
175    =head1 COPYRIGHT & LICENSE
176    
177    Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
178    
179    This program is free software; you can redistribute it and/or modify it
180    under the same terms as Perl itself.
181    
182    =cut
183  1;  1;

Legend:
Removed from v.33  
changed lines
  Added in v.55

  ViewVC Help
Powered by ViewVC 1.1.26