/[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 29 by dpavlin, Mon Jul 30 17:32:41 2007 UTC revision 36 by dpavlin, Mon Jul 30 22:06:13 2007 UTC
# Line 9  use SDL::App; Line 9  use SDL::App;
9  use SDL::Rect;  use SDL::Rect;
10  use SDL::Color;  use SDL::Color;
11    
12    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 run_for mem_dump trace));  __PACKAGE__->mk_accessors(qw(debug scale show_mem mem_dump trace app));
16    
17  =head2 init  =head2 open_screen
18    
19  Open simulated screen  Open simulated screen
20    
# Line 20  Open simulated screen Line 22  Open simulated screen
22    
23  our $app;  our $app;
24    
25  sub init {  sub open_screen {
26          my $self = shift;          my $self = shift;
27    
28            if ( ! $self->scale ) {
29                    $self->scale( 1 );
30                    warn "using default unscaled display\n";
31            }
32    
33          $app = SDL::App->new(          $app = SDL::App->new(
34                  -width  => 256 * $self->scale + ( $self->show_mem ? 256 : 0 ),                  -width  => 256 * $self->scale + ( $self->show_mem ? 256 : 0 ),
35                  -height => 256 * $self->scale,                  -height => 256 * $self->scale,
# Line 30  sub init { Line 38  sub init {
38          #$app->grab_input( 0 );          #$app->grab_input( 0 );
39    
40          warn "# created SDL::App\n";          warn "# created SDL::App\n";
41            $self->app( $app );
42  }  }
43    
44  my $white       = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff );  my $white       = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff );
# Line 98  sub vram { Line 107  sub vram {
107          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;
108    
109          foreach ( 0 .. 7 ) {          foreach ( 0 .. 7 ) {
110                  p($x + $_, $y, $byte & $mask );                  $self->p($x + $_, $y, $byte & $mask );
111                  $mask = $mask << 1;                  $mask = $mask << 1;
112          }          }
113  }  }
114    
115    =head2 mmap_pixel
116    
117    Draw pixel in memory map
118    
119      $self->mmap_pixel( $addr, $r, $g, $b );
120    
121    =cut
122    
123    # keep accesses to memory
124    my $_mem_stat;
125    
126    sub mmap_pixel {
127            my ( $self, $addr, $r, $g, $b ) = @_;
128            return unless $self->show_mem && $self->app;
129    
130            my ( $x, $y ) = $self->mem_xy( $addr );
131            warn sprintf "## mem %04x %02x %02x %02d*%02d\n", $addr, $r, $g, $x, $y if $self->trace;
132    
133            my $col = SDL::Color->new( -r => $r, -g => $g, -b => $b );
134            $self->app->pixel( $x, $y, $col );
135    
136            $_mem_stat++;
137            if ( $_mem_stat % 1000 == 0 ) {
138                    $self->app->sync;
139            }
140    }
141    
142    
143    =head2 sync
144    
145      $self->sync;
146    
147    =cut
148    
149    sub sync {
150            $app->sync;
151    }
152    
153    1;

Legend:
Removed from v.29  
changed lines
  Added in v.36

  ViewVC Help
Powered by ViewVC 1.1.26