9 |
use SDL::Rect; |
use SDL::Rect; |
10 |
use SDL::Color; |
use SDL::Color; |
11 |
|
|
12 |
|
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 run_for mem_dump trace)); |
__PACKAGE__->mk_accessors(qw(debug scale show_mem mem_dump trace app)); |
16 |
|
|
17 |
=head2 open_screen |
=head2 open_screen |
18 |
|
|
38 |
#$app->grab_input( 0 ); |
#$app->grab_input( 0 ); |
39 |
|
|
40 |
warn "# created SDL::App\n"; |
warn "# created SDL::App\n"; |
41 |
|
$self->app( $app ); |
42 |
} |
} |
43 |
|
|
44 |
my $white = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff ); |
my $white = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff ); |
107 |
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; |
108 |
|
|
109 |
foreach ( 0 .. 7 ) { |
foreach ( 0 .. 7 ) { |
110 |
p($x + $_, $y, $byte & $mask ); |
$self->p($x + $_, $y, $byte & $mask ); |
111 |
$mask = $mask << 1; |
$mask = $mask << 1; |
112 |
} |
} |
113 |
} |
} |
125 |
|
|
126 |
sub mmap_pixel { |
sub mmap_pixel { |
127 |
my ( $self, $addr, $r, $g, $b ) = @_; |
my ( $self, $addr, $r, $g, $b ) = @_; |
128 |
|
return unless $self->show_mem && $self->app; |
129 |
|
|
130 |
my ( $x, $y ) = mem_xy( $addr ); |
my ( $x, $y ) = $self->mem_xy( $addr ); |
131 |
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->trace; |
132 |
|
|
133 |
my $col = sdl::color->new( -r => $r, -g => $g, -b => $b ); |
my $col = SDL::Color->new( -r => $r, -g => $g, -b => $b ); |
134 |
$app->pixel( $x, $y, $col ); |
$self->app->pixel( $x, $y, $col ); |
135 |
|
|
136 |
$_mem_stat++; |
$_mem_stat++; |
137 |
if ( $_mem_stat % 1000 == 0 ) { |
if ( $_mem_stat % 1000 == 0 ) { |
138 |
$app->sync; |
$self->app->sync; |
139 |
} |
} |
140 |
} |
} |
141 |
|
|
142 |
|
|
143 |
|
=head2 sync |
144 |
|
|
145 |
|
$self->sync; |
146 |
|
|
147 |
|
=cut |
148 |
|
|
149 |
|
sub sync { |
150 |
|
$app->sync; |
151 |
|
} |
152 |
|
|
153 |
1; |
1; |