/[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 75 by dpavlin, Wed Aug 1 12:40:20 2007 UTC revision 96 by dpavlin, Thu Aug 2 13:58:26 2007 UTC
# Line 57  my $red                = SDL::Color->new( -r => 0xff, Line 57  my $red                = SDL::Color->new( -r => 0xff,
57  my $green       = SDL::Color->new( -r => 0x00, -g => 0xff, -b => 0x00 );  my $green       = SDL::Color->new( -r => 0x00, -g => 0xff, -b => 0x00 );
58  my $blue        = SDL::Color->new( -r => 0x00, -g => 0x00, -b => 0xff );  my $blue        = SDL::Color->new( -r => 0x00, -g => 0x00, -b => 0xff );
59    
60    my $rect_screen = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 );
61    my $rect_mem = SDL::Rect->new( -x => 256, -y => 0, -width => 256, -height => 256 );
62    
63  =head2 p  =head2 p
64    
65   $screen->p( $x, $y, 1 );   $screen->p( $x, $y, 1 );
# Line 171  sub sync { Line 174  sub sync {
174    
175  =head2 render  =head2 render
176    
177    Render one frame of video ram
178    
179    $self->render( @video_memory );    $self->render( @video_memory );
180    
181  =cut  =cut
# Line 193  sub render { Line 198  sub render {
198          $vram->display_format;          $vram->display_format;
199    
200          my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 );          my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 );
201          $vram->blit( $rect, $app, $rect );          $vram->blit( $rect, $app, $rect_screen );
202    
203          $app->sync;          $app->sync;
204  }  }
205    
206    =head2 render_mem
207    
208      $self->render_mem( @ram );
209    
210    =cut
211    
212    sub render_mem {
213            my $self = shift;
214    
215            return unless $self->show_mem;
216    
217            my $pixels = pack("C*", @_);
218    
219            my $vram = SDL::Surface->new(
220                    -width => 256,
221                    -height => 256,
222                    -depth => 8,    # 1 bit per pixel
223                    -pitch => 256,  # bytes per line
224                    -from => $pixels,
225                    -Rmask => 0xffff00ff,
226                    -Gmask => 0xffff00ff,
227                    -Bmask => 0xffff00ff,
228            );
229    
230            $vram->display_format;
231    
232            my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 );
233            $vram->blit( $rect, $app, $rect_mem );
234    
235            $app->sync;
236    }
237    
238    =head2 loop
239    
240    Implement SDL event loop
241    
242    =cut
243    
244    sub loop {
245            my $self = shift;
246            my $event = SDL::Event->new();
247    
248            my $run_for = 2000;
249    
250            MAIN_LOOP:
251            while ( 1 ) {
252                    while ($event->poll) {
253                            my $type = $event->type();
254    
255                            last MAIN_LOOP if ($type == SDL_QUIT);
256                            last MAIN_LOOP if ($type == SDL_KEYDOWN && $event->key_name() eq 'escape');
257    
258                            if ($type == SDL_KEYDOWN) {
259                                    $run_for = $self->cli;
260                            }
261                    }
262                    M6502::exec($run_for);
263            }
264    }
265    
266  =head1 SEE ALSO  =head1 SEE ALSO
267    
268  L<Orao> is sample implementation using this module  L<Orao> is sample implementation using this module

Legend:
Removed from v.75  
changed lines
  Added in v.96

  ViewVC Help
Powered by ViewVC 1.1.26