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

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

revision 124 by dpavlin, Sat Aug 4 14:13:28 2007 UTC revision 126 by dpavlin, Sat Aug 4 15:43:28 2007 UTC
# Line 4  use warnings; Line 4  use warnings;
4  use strict;  use strict;
5    
6  use Carp qw/confess/;  use Carp qw/confess/;
 use lib './lib';  
 #use Time::HiRes qw(time);  
7  use File::Slurp;  use File::Slurp;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9  use M6502;  use M6502; # import @mem $PC and friends
10    use Screen qw/$white $black/;
11    
12  use base qw(Class::Accessor VRac M6502 Screen Prefs Tape);  use base qw(Class::Accessor VRac M6502 Screen Prefs Tape);
13  #__PACKAGE__->mk_accessors(qw());  #__PACKAGE__->mk_accessors(qw());
# Line 19  Orao - Orao emulator Line 18  Orao - Orao emulator
18    
19  =head1 VERSION  =head1 VERSION
20    
21  Version 0.04  Version 0.05
22    
23  =cut  =cut
24    
25  our $VERSION = '0.04';  our $VERSION = '0.05';
26    
27  =head1 SUMMARY  =head1 SUMMARY
28    
# Line 58  sub boot { Line 57  sub boot {
57    
58          warn "emulating ", $#mem, " bytes of memory\n";          warn "emulating ", $#mem, " bytes of memory\n";
59    
60    #       $self->scale( 2 );
61    
62          $self->open_screen;          $self->open_screen;
63          $self->load_rom({          $self->load_rom({
64  #               0x1000 => 'dump/SCRINV.BIN',  #               0x1000 => 'dump/SCRINV.BIN',
65                  # should be 0x6000, but oraoemu has 2 byte prefix                  # should be 0x6000, but oraoemu has 2 byte prefix
66  #               0x5FFE => 'dump/screen.dmp',  #               0x5FFE => '/home/dpavlin/orao/dump/screen.dmp',
67  #               0xC000 => 'rom/Orao/BAS12.ROM',  #               0xC000 => 'rom/Orao/BAS12.ROM',
68  #               0xE000 => 'rom/Orao/CRT12.ROM',  #               0xE000 => 'rom/Orao/CRT12.ROM',
69                  0xC000 => 'rom/Orao/BAS13.ROM',                  0xC000 => 'rom/Orao/BAS13.ROM',
# Line 134  sub run { Line 135  sub run {
135    
136  #       $self->load_tape( '../oraoigre/bdash.tap' );  #       $self->load_tape( '../oraoigre/bdash.tap' );
137    
138          $self->loop;          $self->loop( sub {
139                    M6502::exec( $_[0] );
140                    $self->render_vram;
141            });
142  };  };
143    
144  =head1 Helper functions  =head1 Helper functions
# Line 424  sub write { Line 428  sub write {
428          return;          return;
429  }  }
430    
431    =head2 render_vram
432    
433    Render one frame of video ram
434    
435      $self->render_vram;
436    
437    =cut
438    
439    my @flip;
440    
441    foreach my $i ( 0 .. 255 ) {
442            my $t = 0;
443            $i & 0b00000001 and $t = $t | 0b10000000;
444            $i & 0b00000010 and $t = $t | 0b01000000;
445            $i & 0b00000100 and $t = $t | 0b00100000;
446            $i & 0b00001000 and $t = $t | 0b00010000;
447            $i & 0b00010000 and $t = $t | 0b00001000;
448            $i & 0b00100000 and $t = $t | 0b00000100;
449            $i & 0b01000000 and $t = $t | 0b00000010;
450            $i & 0b10000000 and $t = $t | 0b00000001;
451            #warn "$i = $t\n";
452            $flip[$i] = $t;
453    }
454    
455    
456    sub render_vram {
457            my $self = shift;
458    
459            return unless $self->booted;
460    
461            my $pixels = pack("C*", map { $flip[$_] } @mem[ 0x6000 .. 0x7fff ]);
462    
463            my $vram = SDL::Surface->new(
464                    -width => 256,
465                    -height => 256,
466                    -depth => 1,    # 1 bit per pixel
467                    -pitch => 32,   # bytes per line
468                    -from => $pixels,
469            );
470            $vram->set_colors( 0, $black, $white );
471    
472            $self->render_frame( $vram );
473    }
474    
475  =head1 AUTHOR  =head1 AUTHOR
476    
477  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>

Legend:
Removed from v.124  
changed lines
  Added in v.126

  ViewVC Help
Powered by ViewVC 1.1.26