--- Orao.pm 2007/08/04 14:13:28 124 +++ Orao.pm 2007/08/04 15:09:44 125 @@ -4,11 +4,10 @@ use strict; use Carp qw/confess/; -use lib './lib'; -#use Time::HiRes qw(time); use File::Slurp; use Data::Dump qw/dump/; use M6502; +use Screen qw/$white $black/; use base qw(Class::Accessor VRac M6502 Screen Prefs Tape); #__PACKAGE__->mk_accessors(qw()); @@ -19,11 +18,11 @@ =head1 VERSION -Version 0.04 +Version 0.05 =cut -our $VERSION = '0.04'; +our $VERSION = '0.05'; =head1 SUMMARY @@ -58,11 +57,13 @@ warn "emulating ", $#mem, " bytes of memory\n"; +# $self->scale( 2 ); + $self->open_screen; $self->load_rom({ # 0x1000 => 'dump/SCRINV.BIN', # should be 0x6000, but oraoemu has 2 byte prefix -# 0x5FFE => 'dump/screen.dmp', +# 0x5FFE => '/home/dpavlin/orao/dump/screen.dmp', # 0xC000 => 'rom/Orao/BAS12.ROM', # 0xE000 => 'rom/Orao/CRT12.ROM', 0xC000 => 'rom/Orao/BAS13.ROM', @@ -424,6 +425,53 @@ return; } +=head2 render_vram + +Render one frame of video ram + + $self->render_vram( @video_memory ); + +=cut + +my @flip; + +foreach my $i ( 0 .. 255 ) { + my $t = 0; + $i & 0b00000001 and $t = $t | 0b10000000; + $i & 0b00000010 and $t = $t | 0b01000000; + $i & 0b00000100 and $t = $t | 0b00100000; + $i & 0b00001000 and $t = $t | 0b00010000; + $i & 0b00010000 and $t = $t | 0b00001000; + $i & 0b00100000 and $t = $t | 0b00000100; + $i & 0b01000000 and $t = $t | 0b00000010; + $i & 0b10000000 and $t = $t | 0b00000001; + #warn "$i = $t\n"; + $flip[$i] = $t; +} + + +sub render_vram { + my $self = shift; + + confess "no data?" unless (@_); + confess "screen size not 256*256/8 but ",($#_+1) unless (($#_+1) == (256*256/8)); + + return unless $self->booted; + + my $pixels = pack("C*", map { $flip[$_] } @_); + + my $vram = SDL::Surface->new( + -width => 256, + -height => 256, + -depth => 1, # 1 bit per pixel + -pitch => 32, # bytes per line + -from => $pixels, + ); + $vram->set_colors( 0, $black, $white ); + + $self->render_frame( $vram ); +} + =head1 AUTHOR Dobrica Pavlinusic, C<< >>