12 |
use Carp qw/confess/; |
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 mem_dump trace app)); |
#__PACKAGE__->mk_accessors(qw(debug scale show_mem trace app)); |
16 |
|
|
17 |
|
=head1 NAME |
18 |
|
|
19 |
|
Screen - simulated 256*256 pixels monochrome screen using SDL |
20 |
|
|
21 |
=head2 open_screen |
=head2 open_screen |
22 |
|
|
102 |
|
|
103 |
=cut |
=cut |
104 |
|
|
105 |
|
my $_vram_counter; |
106 |
|
|
107 |
sub vram { |
sub vram { |
108 |
my ( $self, $offset, $byte ) = @_; |
my ( $self, $offset, $byte ) = @_; |
109 |
my $x = ( $offset % 32 ) << 3; |
my $x = ( $offset % 32 ) << 3; |
110 |
my $y = $offset >> 5; |
my $y = $offset >> 5; |
111 |
my $mask = 1; |
my $mask = 1; |
112 |
|
my $scale = $self->scale; |
113 |
|
|
114 |
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; |
115 |
|
|
116 |
foreach ( 0 .. 7 ) { |
foreach ( 0 .. 7 ) { |
117 |
$self->p($x + $_, $y, $byte & $mask ); |
my $on = $byte & $mask; |
118 |
|
if ( $scale == 1 ) { |
119 |
|
$app->pixel( $x + $_, $y, $on ? $white : $black ); |
120 |
|
} else { |
121 |
|
$self->p($x + $_, $y, $on ); |
122 |
|
} |
123 |
$mask = $mask << 1; |
$mask = $mask << 1; |
124 |
} |
} |
125 |
|
|
126 |
|
$app->sync if ( $_vram_counter++ % 10 == 0 ); |
127 |
} |
} |
128 |
|
|
129 |
=head2 mmap_pixel |
=head2 mmap_pixel |
142 |
return unless $self->show_mem && $self->app; |
return unless $self->show_mem && $self->app; |
143 |
|
|
144 |
my ( $x, $y ) = $self->mem_xy( $addr ); |
my ( $x, $y ) = $self->mem_xy( $addr ); |
145 |
warn sprintf "## mem %04x %02x %02x %02d*%02d\n", $addr, $r, $g, $x, $y if $self->trace; |
warn sprintf "## mem %04x %02x %02x %02d*%02d\n", $addr, $r, $g, $x, $y if $self->debug; |
146 |
|
|
147 |
my $col = SDL::Color->new( -r => $r, -g => $g, -b => $b ); |
my $col = SDL::Color->new( -r => $r, -g => $g, -b => $b ); |
148 |
$self->app->pixel( $x, $y, $col ); |
$self->app->pixel( $x, $y, $col ); |
164 |
$app->sync; |
$app->sync; |
165 |
} |
} |
166 |
|
|
167 |
|
=head1 SEE ALSO |
168 |
|
|
169 |
|
L<Orao> is sample implementation using this module |
170 |
|
|
171 |
|
=head1 AUTHOR |
172 |
|
|
173 |
|
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |
174 |
|
|
175 |
|
=head1 COPYRIGHT & LICENSE |
176 |
|
|
177 |
|
Copyright 2007 Dobrica Pavlinusic, All Rights Reserved. |
178 |
|
|
179 |
|
This program is free software; you can redistribute it and/or modify it |
180 |
|
under the same terms as Perl itself. |
181 |
|
|
182 |
|
=cut |
183 |
1; |
1; |