8 |
#use Time::HiRes qw(time); |
#use Time::HiRes qw(time); |
9 |
use File::Slurp; |
use File::Slurp; |
10 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
11 |
|
use List::Util qw/first/; |
12 |
use M6502; |
use M6502; |
13 |
|
|
14 |
use base qw(Class::Accessor M6502 Screen Prefs); |
use base qw(Class::Accessor M6502 Screen Prefs); |
32 |
|
|
33 |
=cut |
=cut |
34 |
|
|
35 |
|
my @kbd_ports = ( |
36 |
|
0x87FC,0x87FD,0x87FA,0x87FB,0x87F6,0x87F7, |
37 |
|
0x87EE,0x87EF,0x87DE,0x87DF,0x87BE,0x87BF, |
38 |
|
0x877E,0x877F,0x86FE,0x86FF,0x85FE,0x85FF, |
39 |
|
0x83FE,0x83FF, |
40 |
|
); |
41 |
|
|
42 |
=head2 init |
=head2 init |
43 |
|
|
44 |
Start emulator, open L<Screen>, load initial ROM images, and render memory |
Start emulator, open L<Screen>, load initial ROM images, and render memory |
68 |
# $PC = 0xDD11; # BC |
# $PC = 0xDD11; # BC |
69 |
# $PC = 0xC274; # MC |
# $PC = 0xC274; # MC |
70 |
|
|
71 |
|
$PC = 0xff89; |
72 |
|
|
73 |
$orao = $self; |
$orao = $self; |
74 |
|
|
75 |
# $self->prompt( 0x1000 ); |
# $self->prompt( 0x1000 ); |
97 |
0xE000, 0xFFFF, 'sistemski ROM', |
0xE000, 0xFFFF, 'sistemski ROM', |
98 |
); |
); |
99 |
|
|
|
if(0){ |
|
|
foreach my $i ( 0 .. $#mmap / 3 ) { |
|
|
my $o = $i * 3; |
|
|
my ( $from, $to, $desc ) = @mmap[$o,$o+1,$o+2]; |
|
|
printf "%04x - %04x - %s\n", $from, $to, $desc; |
|
|
for my $a ( $from .. $to ) { |
|
|
if ( $a >= 0x6000 && $a < 0x8000 ) { |
|
|
my $b = $self->read( $a ); |
|
|
$self->vram( $a - 0x6000, $b ); |
|
|
} else { |
|
|
$self->read( $a ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
100 |
} else { |
} else { |
101 |
|
|
102 |
warn "rendering video memory\n"; |
warn "rendering video memory\n"; |
|
# for my $a ( 0x6000 .. 0x7fff ) { |
|
|
# $self->vram( $a - 0x6000, $mem[$a] ); |
|
|
# } |
|
103 |
$self->render( @mem[ 0x6000 .. 0x7fff ] ); |
$self->render( @mem[ 0x6000 .. 0x7fff ] ); |
104 |
|
|
105 |
} |
} |
156 |
# $self->vram( $a - 0x6000 , $mem[ $a ] ); |
# $self->vram( $a - 0x6000 , $mem[ $a ] ); |
157 |
# } |
# } |
158 |
$self->render( @mem[ 0x6000 .. 0x7fff ] ); |
$self->render( @mem[ 0x6000 .. 0x7fff ] ); |
159 |
|
$self->render_mem( @mem ) if $self->show_mem; |
160 |
} |
} |
161 |
|
|
162 |
=head2 load_oraoemu |
=head2 load_oraoemu |
280 |
my ($addr) = @_; |
my ($addr) = @_; |
281 |
my $byte = $mem[$addr]; |
my $byte = $mem[$addr]; |
282 |
warn sprintf("# Orao::read(%04x) = %02x\n", $addr, $byte) if $self->trace; |
warn sprintf("# Orao::read(%04x) = %02x\n", $addr, $byte) if $self->trace; |
283 |
|
|
284 |
|
# keyboard |
285 |
|
|
286 |
|
if ( first { $addr == $_ } @kbd_ports ) { |
287 |
|
warn sprintf("keyboard port: %04x\n",$addr); |
288 |
|
} elsif ( $addr == 0x87fc ) { |
289 |
|
warn "0x87fc - arrows/back\n"; |
290 |
|
=for pascal |
291 |
|
if VKey=VK_RIGHT then Result:=16; |
292 |
|
if VKey=VK_DOWN then Result:=128; |
293 |
|
if VKey=VK_UP then Result:=192; |
294 |
|
if VKey=VK_LEFT then Result:=224; |
295 |
|
if Ord(KeyPressed)=VK_BACK then Result:=224; |
296 |
|
=cut |
297 |
|
} elsif ( $addr == 0x87fd ) { |
298 |
|
warn "0x87fd - enter\n"; |
299 |
|
=for pascal |
300 |
|
if KeyPressed=Chr(13) then begin |
301 |
|
Mem[$FC]:=13; |
302 |
|
Result:=0; |
303 |
|
end; |
304 |
|
=cut |
305 |
|
} elsif ( $addr == 0x87fa ) { |
306 |
|
warn "0x87fa = F1 - F4\n"; |
307 |
|
=for pascal |
308 |
|
if VKey=VK_F4 then Result:=16; |
309 |
|
if VKey=VK_F3 then Result:=128; |
310 |
|
if VKey=VK_F2 then Result:=192; |
311 |
|
if VKey=VK_F1 then Result:=224; |
312 |
|
=cut |
313 |
|
} elsif ( $addr == 0x87fb ) { |
314 |
|
warn "0x87fb\n"; |
315 |
|
=for pascal |
316 |
|
if KeyPressed=Chr(32) then Result:=32; |
317 |
|
if KeyPressed='"' then Result:=16; |
318 |
|
if KeyPressed='!' then Result:=16; |
319 |
|
if KeyPressed='$' then Result:=16; |
320 |
|
if KeyPressed='%' then Result:=16; |
321 |
|
if KeyPressed='&' then Result:=16; |
322 |
|
if KeyPressed='(' then Result:=16; |
323 |
|
if KeyPressed=')' then Result:=16; |
324 |
|
if KeyPressed='=' then Result:=16; |
325 |
|
if KeyPressed='#' then Result:=16; |
326 |
|
if KeyPressed='+' then Result:=16; |
327 |
|
if KeyPressed='*' then Result:=16; |
328 |
|
if KeyPressed='?' then Result:=16; |
329 |
|
if KeyPressed='<' then Result:=16; |
330 |
|
if KeyPressed='>' then Result:=16; |
331 |
|
if VKey=191 then Result:=16; |
332 |
|
=cut |
333 |
|
} |
334 |
|
|
335 |
$self->mmap_pixel( $addr, 0, $byte, 0 ); |
$self->mmap_pixel( $addr, 0, $byte, 0 ); |
336 |
return $byte; |
return $byte; |
337 |
} |
} |