--- Galeb.pm 2007/08/06 18:17:12 174 +++ Galeb.pm 2007/09/30 20:05:20 188 @@ -51,7 +51,7 @@ warn "Galeb $Galeb::VERSION emulation starting\n"; - $self->scale( 2 ); +# $self->scale( 2 ); $self->show_mem( 1 ); $self->load_session( 'sess/current' ); @@ -70,9 +70,8 @@ $emu = $self; - my ( $trace, $debug ) = ( $self->trace, $self->debug ); - $self->trace( 0 ); - $self->debug( 0 ); +# $self->trace( 1 ); +# $self->debug( 1 ); warn "rendering memory\n"; $self->render_mem( @mem ); @@ -182,8 +181,20 @@ =cut +my $char_rom = 'rom/Galeb/CHRGEN.rom'; + +my @chars = map { ord($_) } split(//, read_file( $char_rom )); +warn "loaded ", $#chars, " characters from $char_rom\n"; + my $last_dump = ''; +my $x_size = 48; +my $y_size = 16; +my $c_h = 8; + +sub screen_width { $x_size * 8 } +sub screen_height { $y_size * $c_h } + sub render_vram { my $self = shift; @@ -191,14 +202,36 @@ my $dump; - for my $y ( 0 .. 15 ) { + my @pixels = ("\x00") x ( $x_size * $y_size * 8 ); + + for my $y ( 0 .. $y_size - 1 ) { $dump .= sprintf "%2d: %s\n",$y, join('', map { chr( $_ ) } @mem[ $addr+15 .. $addr+62 ] ); + + foreach my $x ( 0 .. $x_size - 1 ) { + my $c = $mem[ $addr + 15 + $x ]; + my $l = $x_size * $c_h; + foreach my $o ( 0 .. $c_h - 1 ) { + $pixels[ ( $y * $l ) + $x + ( $o * $x_size ) ] = $chars[ ( $c * $c_h ) + $o ]; + } + } + $addr += 64; } if ( $dump ne $last_dump ) { - print $dump; +# print $dump; $last_dump = $dump; + + my $vram = SDL::Surface->new( + -width => $x_size * 8, + -height => $y_size * $c_h, + -depth => 1, # 1 bit per pixel + -pitch => $x_size, # bytes per line + -from => pack("C*", @pixels), + ); + $vram->set_colors( 0, $white, $black ); + + $self->render_frame( $vram ); } }