/[VRac]/Orao.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Orao.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

M6502/Orao.pm revision 82 by dpavlin, Wed Aug 1 21:40:17 2007 UTC Orao.pm revision 213 by dpavlin, Mon Apr 14 21:27:19 2008 UTC
# Line 4  use warnings; Line 4  use warnings;
4  use strict;  use strict;
5    
6  use Carp qw/confess/;  use Carp qw/confess/;
 use lib './lib';  
 #use Time::HiRes qw(time);  
7  use File::Slurp;  use File::Slurp;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9  use List::Util qw/first/;  use M6502 '0.0.3';
10  use M6502;  use Screen;
11    
12  use base qw(Class::Accessor M6502 Screen Prefs);  use base qw(Class::Accessor VRac M6502 Screen Prefs Tape Session);
13  __PACKAGE__->mk_accessors(qw(run_for));  #__PACKAGE__->mk_accessors(qw());
14    
15  =head1 NAME  =head1 NAME
16    
# Line 20  Orao - Orao emulator Line 18  Orao - Orao emulator
18    
19  =head1 VERSION  =head1 VERSION
20    
21  Version 0.02  Version 0.06
22    
23  =cut  =cut
24    
25  our $VERSION = '0.02';  our $VERSION = '0.06';
26    
27  =head1 SUMMARY  =head1 SUMMARY
28    
29  Emulator or Orao 8-bit 6502 machine popular in Croatia  Emulator for Orao 8-bit 6502 machine popular in Croatia (especially schools)
30    
31  =cut  =cut
32    
33  my @kbd_ports = (  =head1 FUNCTIONS
     0x87FC,0x87FD,0x87FA,0x87FB,0x87F6,0x87F7,  
     0x87EE,0x87EF,0x87DE,0x87DF,0x87BE,0x87BF,  
     0x877E,0x877F,0x86FE,0x86FF,0x85FE,0x85FF,  
     0x83FE,0x83FF,  
 );  
34    
35  =head2 boot  =head2 run
36    
37  Start emulator, open L<Screen>, load initial ROM images, and render memory  Start emulator, open L<Screen>, load initial ROM images, and start emulator loop
   
   my $orao = Orao->new({});  
   $orao->boot;  
38    
39  =cut  =cut
40    
41  our $orao;  our $emu;
   
 select(STDERR); $| = 1;  
42    
43  sub boot {  sub run {
44          my $self = shift;          my $self = shift;
45    
46            M6502::reset();
47            $self->_init_callbacks;
48    
49          warn "Orao calling upstream init\n";          warn "Orao calling upstream init\n";
50          $self->SUPER::init( $self, @_ );          $self->SUPER::init(
51                    read => sub { $self->read( @_ ) },
52                    write => sub { $self->write( @_ ) },
53            );
54    
55          warn "Orao $Orao::VERSION emulation starting\n";          warn "Orao $Orao::VERSION emulation starting\n";
56    
57            warn "emulating ", $#mem, " bytes of memory\n";
58    
59    #       $self->scale( 2 );
60            $self->show_mem( 1 );
61            $self->load_session( 'sess/current' );
62    
63          $self->open_screen;          $self->open_screen;
64          $self->load_rom({          $self->load_rom({
65                  0x1000 => 'dump/SCRINV.BIN',  #               0x1000 => 'dump/SCRINV.BIN',
66                  # should be 0x6000, but oraoemu has 2 byte prefix                  # should be 0x6000, but oraoemu has 2 byte prefix
67                  0x5FFE => 'dump/screen.dmp',  #               0x5FFE => '/home/dpavlin/orao/dump/screen.dmp',
68                  0xC000 => 'rom/BAS12.ROM',  #               0xC000 => 'rom/Orao/BAS12.ROM',
69                  0xE000 => 'rom/CRT12.ROM',  #               0xE000 => 'rom/Orao/CRT12.ROM',
70                    0xC000 => 'rom/Orao/BAS13.ROM',
71                    0xE000 => 'rom/Orao/CRT13.ROM',
72          });          });
73    
74  #       $PC = 0xDD11;   # BC  #       $PC = 0xDD11;   # BC
# Line 73  sub boot { Line 76  sub boot {
76    
77          $PC = 0xff89;          $PC = 0xff89;
78    
79          $orao = $self;          $emu = $self;
80    
81  #       $self->prompt( 0x1000 );  #       $self->prompt( 0x1000 );
82    
# Line 81  sub boot { Line 84  sub boot {
84          $self->trace( 0 );          $self->trace( 0 );
85          $self->debug( 0 );          $self->debug( 0 );
86    
87          $self->render( @mem[ 0x6000 .. 0x7fff ] );          warn "rendering memory\n";
88            $self->render_mem( M6502::mem_peek_region(0x0000,0xffff) );
89    
90          if ( $self->show_mem ) {          if ( $self->show_mem ) {
91    
                 warn "rendering memory map\n";  
   
                 $self->render_mem( @mem );  
   
92                  my @mmap = (                  my @mmap = (
93                          0x0000, 0x03FF, 'nulti blok',                          0x0000, 0x03FF, 'nulti blok',
94                          0x0400, 0x5FFF, 'korisnički RAM (23K)',                          0x0400, 0x5FFF, 'korisnički RAM (23K)',
# Line 100  sub boot { Line 100  sub boot {
100                          0xE000, 0xFFFF, 'sistemski ROM',                          0xE000, 0xFFFF, 'sistemski ROM',
101                  );                  );
102    
103          } else {                  print "Orao memory map:";
104    
105                    while ( @mmap ) {
106                            my ( $from, $to, $desc ) = splice(@mmap, 0, 3);
107                            printf("%04x-%04x %s\n", $from, $to, $desc);
108                    }
109    
                 warn "rendering video memory\n";  
                 $self->render( @mem[ 0x6000 .. 0x7fff ] );  
           
110          }          }
111          $self->sync;  
112          $self->trace( $trace );          $self->trace( $trace );
113          $self->debug( $debug );          $self->debug( $debug );
114    
         #( $A, $P, $X, $Y, $S, $IPeriod ) = ( 1, 2, 3, 4, 5, 6 );  
   
115          warn "Orao boot finished",          warn "Orao boot finished",
116                  $self->trace ? ' trace' : '',                  $self->trace ? ' trace' : '',
117                  $self->debug ? ' debug' : '',                  $self->debug ? ' debug' : '',
118                  "\n";                  "\n";
119    
120          M6502::reset();  #       $self->load_tape( 'tapes/Orao/bdash.tap' );
121    #       $self->load_tape( 'tapes/Orao/crtanje.tap' );
122          warn dump( M6502->run );  #       $self->load_tape( 'tapes/Orao/jjack.tap', 0x168 );
123  }          $self->load_tape( 'tapes/Orao/muzika.tap', 0x168 );
124    
125            $self->render_vram;
126    
127            $self->loop( sub {
128                    my $run_for = shift;
129                    warn sprintf("about to exec from PC %04x for %d cycles\n", $PC, $run_for) if $self->trace;
130                    M6502::exec( $run_for );
131                    $self->render_vram;
132                    $self->render_mem( M6502::mem_peek_region(0x0000,0xffff) ) if $self->show_mem;
133            });
134    };
135    
 =head2 load_rom  
136    
137  called to init memory and load initial rom images  =head1 Helper functions
138    
139    $orao->load_rom;  =head2 write_chunk
140    
141  =cut  Write chunk directly into memory, updateing vram if needed
142    
143  sub load_rom {    $emu->write_chunk( 0x1000, $chunk_data );
     my ($self, $loaded_files) = @_;  
144    
145      #my $time_base = time();  =cut
   
         foreach my $addr ( sort keys %$loaded_files ) {  
                 my $path = $loaded_files->{$addr};  
                 $self->load_oraoemu( $path, $addr );  
         }  
 }  
146    
147  # write chunk directly into memory, updateing vram if needed  sub write_chunk {
 sub _write_chunk {  
148          my $self = shift;          my $self = shift;
149          my ( $addr, $chunk ) = @_;          my ( $addr, $chunk ) = @_;
150          $self->write_chunk( $addr, $chunk );          $self->SUPER::write_chunk( $addr, $chunk );
151          my $end = $addr + length($chunk);          my $end = $addr + length($chunk);
152          my ( $f, $t ) = ( 0x6000, 0x7fff );          my ( $f, $t ) = ( 0x6000, 0x7fff );
153    
# Line 158  sub _write_chunk { Line 160  sub _write_chunk {
160          $t = $end if ( $end < $t );          $t = $end if ( $end < $t );
161    
162          warn sprintf("refresh video ram %04x-%04x\n", $f, $t);          warn sprintf("refresh video ram %04x-%04x\n", $f, $t);
163  #       foreach my $a ( $f .. $t ) {          $self->render_vram;
164  #               $self->vram( $a - 0x6000 , $mem[ $a ] );          $self->render_mem( @mem );
 #       }  
         $self->render( @mem[ 0x6000 .. 0x7fff ] );  
         $self->render_mem( @mem ) if $self->show_mem;  
165  }  }
166    
167  =head2 load_oraoemu  =head2 load_image
168    
169  Load binary files, ROM images and Orao Emulator files  Load binary files, ROM images and Orao Emulator files
170    
171    $orao->load_oraoemu( '/path/to/file', 0x1000 );    $emu->load_image( '/path/to/file', 0x1000 );
172    
173  Returns true on success.  Returns true on success.
174    
175  =cut  =cut
176    
177  sub load_oraoemu {  sub load_image {
178          my $self = shift;          my $self = shift;
179          my ( $path, $addr ) = @_;          my ( $path, $addr ) = @_;
180    
# Line 191  sub load_oraoemu { Line 190  sub load_oraoemu {
190          if ( $size == 65538 ) {          if ( $size == 65538 ) {
191                  $addr = 0;                  $addr = 0;
192                  warn sprintf "loading oraoemu 64k dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;                  warn sprintf "loading oraoemu 64k dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
193                  $self->_write_chunk( $addr, substr($buff,2) );                  $self->write_chunk( $addr, substr($buff,2) );
194                  return 1;                  return 1;
195          } elsif ( $size == 32800 ) {          } elsif ( $size == 32800 ) {
196                  $addr = 0;                  $addr = 0;
197                  warn sprintf "loading oraoemu 1.3 dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;                  warn sprintf "loading oraoemu 1.3 dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
198                  $self->_write_chunk( $addr, substr($buff,0x20) );                  $self->write_chunk( $addr, substr($buff,0x20) );
199                  return 1;                  return 1;
200          }          }
         printf "loading %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;  
         $self->_write_chunk( $addr, $buff );  
         return 1;  
   
         my $chunk;  
   
         my $pos = 0;  
   
         while ( my $long = substr($buff,$pos,4) ) {  
                 my @b = split(//, $long, 4);  
                 $chunk .=  
                         ( $b[3] || '' ) .  
                         ( $b[2] || '' ) .  
                         ( $b[1] || '' ) .  
                         ( $b[0] || '' );  
                 $pos += 4;  
         }  
   
         $self->_write_chunk( $addr, $chunk );  
201    
202            printf "loading %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
203            $self->write_chunk( $addr, $buff );
204          return 1;          return 1;
205  };  };
206    
 =head2 save_dump  
   
   $orao->save_dump( 'filename', $from, $to );  
   
 =cut  
   
 sub save_dump {  
         my $self = shift;  
   
         my ( $path, $from, $to ) = @_;  
   
         $from ||= 0;  
         $to ||= 0xffff;  
   
         open(my $fh, '>', $path) || die "can't open $path: $!";  
         print $fh $self->read_chunk( $from, $to );  
         close($fh);  
   
         my $size = -s $path;  
         warn sprintf "saved %s %d %x bytes\n", $path, $size, $size;  
 }  
   
 =head2 hexdump  
   
   $orao->hexdump( $address );  
   
 =cut  
   
 sub hexdump {  
         my $self = shift;  
         my $a = shift;  
         return sprintf(" %04x %s\n", $a,  
                 join(" ",  
                         map {  
                                 if ( defined($_) ) {  
                                         sprintf( "%02x", $_ )  
                                 } else {  
                                         '  '  
                                 }  
                         } @mem[ $a .. $a+8 ]  
                 )  
         );  
 }  
207    
208  =head1 Memory management  =head1 Memory management
209    
# Line 281  Read from memory Line 220  Read from memory
220    
221  =cut  =cut
222    
223    my $keyboard_none = 255;
224    
225    my $keyboard = {
226            0x87FC => {
227                    'right'         => 16,
228                    'down'          => 128,
229                    'up'            => 192,
230                    'left'          => 224,
231                    'backspace' => 224,
232            },
233            0x87FD => sub {
234                    my $self = shift;
235                    if ( $self->key_active('return') ) {
236    #                       M6502::_write( 0xfc, 13 );
237                            warn "return\n";
238                            return 0;
239                    } elsif ( $self->key_active('left ctrl','right ctrl') ) {
240                            warn "ctrl\n";
241                            return 16;
242                    }
243                    return $keyboard_none;
244            },
245            0x87FA => {
246                    'f4' => 16,
247                    'f3' => 128,
248                    'f2' => 192,
249                    'f1' => 224,
250            },
251            0x87FB => sub {
252                    my $self = shift;
253                    if ( $self->key_active('space') ) {
254                            warn "space\n";
255                            return 32;
256                    } elsif ( $self->key_active('left shift','right shift') ) {
257                            warn "shift\n";
258                            return 16;
259    #               } elsif ( $self->tape ) {
260    #                       warn "has tape!";
261    #                       return 0;
262                    }
263                    return $keyboard_none;
264            },
265            0x87F6 => {
266                    '6' => 16,
267                    't' => 128,
268                    'y' => 192,     # hr: z
269                    'r' => 224,
270            },
271            0x87F7 => {
272                    '5' => 32,
273                    '4' => 16,
274            },
275            0x87EE => {
276                    '7' => 16,
277                    'u' => 128,
278                    'i' => 192,
279                    'o' => 224,
280            },
281            0x87EF => {
282                    '8' => 32,
283                    '9' => 16,
284            },
285            0x87DE => {
286                    '1' => 16,
287                    'w' => 128,
288                    'q' => 192,
289                    'e' => 224,
290            },
291            0x87DF => {
292                    '2' => 32,
293                    '3' => 16,
294            },
295            0x87BE => {
296                    'm' => 16,
297                    'k' => 128,
298                    'j' => 192,
299                    'l' => 224,
300            },
301            0x87BF => {
302                    ',' => 32,      # <
303                    '.' => 16,      # >
304            },
305            0x877E => {
306                    'z' => 16,      # hr:y
307                    's' => 128,
308                    'a' => 192,
309                    'd' => 224,
310            },
311            0x877F => {
312                    'x' => 32,
313                    'c' => 16,
314            },
315            0x86FE => {
316                    'n' => 16,
317                    'g' => 128,
318                    'h' => 192,
319                    'f' => 224,
320            },
321            0x86FF => {
322                    'b' => 32,
323                    'v' => 16,
324            },
325            0x85FE => {
326                    '<' => 16,              # :
327                    '\\' => 128,    # ľ
328                    '\'' => 192,    # ć
329                    ';' => 224,             # č
330            },
331            0x85FF => {
332                    '/' => 32,
333                    'f11' => 16,    # ^
334            },
335            0x83FE => {
336                    'f12' => 16,    # ;
337                    '[' => 128,             # ą
338                    ']' => 192,             # đ
339                    'p' => 224,
340            },
341            0x83FF => {
342                    '-' => 32,
343                    '0' => 16,
344            },
345    };
346    
347  sub read {  sub read {
348          my $self = shift;          my $self = shift;
349          my ($addr) = @_;          my ($addr) = @_;
350            die "address over 64k: $addr" if ( $addr > 0xffff );
351          my $byte = $mem[$addr];          my $byte = $mem[$addr];
352            confess sprintf("can't find memory at address %04x",$addr) unless defined($byte);
353          warn sprintf("# Orao::read(%04x) = %02x\n", $addr, $byte) if $self->trace;          warn sprintf("# Orao::read(%04x) = %02x\n", $addr, $byte) if $self->trace;
354    
355          # keyboard          # keyboard
356    
357          if ( first { $addr == $_ } @kbd_ports ) {          if ( defined( $keyboard->{$addr} ) ) {
358                  warn sprintf("keyboard port: %04x\n",$addr);                  warn sprintf("keyboard port: %04x\n",$addr) if $self->trace;
359          } elsif ( $addr == 0x87fc ) {          
360                  warn "0x87fc - arrows/back\n";                  my $ret = $keyboard_none;
361  =for pascal                  my $r = $keyboard->{$addr} || confess "no definition for keyboard port found";
362                  if VKey=VK_RIGHT then Result:=16;                  if ( ref($r) eq 'CODE' ) {
363                  if VKey=VK_DOWN then Result:=128;                          $ret = $r->($self);
364                  if VKey=VK_UP then Result:=192;                  } else {
365                  if VKey=VK_LEFT then Result:=224;                          foreach my $k ( keys %$r ) {
366                  if Ord(KeyPressed)=VK_BACK then Result:=224;                                  my $return = 0;
367  =cut                                  if ( $self->key_active($k) ) {
368          } elsif ( $addr == 0x87fd ) {                                          warn "key '$k' is active\n";
369                  warn "0x87fd - enter\n";                                          $return ||= $r->{$k};
370  =for pascal                                  }
371      if KeyPressed=Chr(13) then begin                                  $ret = $return if $return;
372        Mem[$FC]:=13;                          }
373        Result:=0;                  }
374      end;                  warn sprintf("keyboard port: %04x code: %d\n",$addr,$ret) if ( $ret != $keyboard_none );
375  =cut                  return $ret;
376          } elsif ( $addr == 0x87fa ) {          }
377                  warn "0x87fa = F1 - F4\n";  
378  =for pascal          if ( $addr == 0x87ff ) {
379      if VKey=VK_F4 then Result:=16;                  return $self->read_tape;
     if VKey=VK_F3 then Result:=128;  
     if VKey=VK_F2 then Result:=192;  
     if VKey=VK_F1 then Result:=224;  
 =cut  
         } elsif ( $addr == 0x87fb ) {  
                 warn "0x87fb\n";  
 =for pascal  
     if KeyPressed=Chr(32) then Result:=32;  
     if KeyPressed='"' then Result:=16;  
     if KeyPressed='!' then Result:=16;  
     if KeyPressed='$' then Result:=16;  
     if KeyPressed='%' then Result:=16;  
     if KeyPressed='&' then Result:=16;  
     if KeyPressed='(' then Result:=16;  
     if KeyPressed=')' then Result:=16;  
     if KeyPressed='=' then Result:=16;  
     if KeyPressed='#' then Result:=16;  
     if KeyPressed='+' then Result:=16;  
     if KeyPressed='*' then Result:=16;  
     if KeyPressed='?' then Result:=16;  
     if KeyPressed='<' then Result:=16;  
     if KeyPressed='>' then Result:=16;  
     if VKey=191 then Result:=16;  
 =cut  
380          }          }
381    
382          $self->mmap_pixel( $addr, 0, $byte, 0 );  #       $self->mmap_pixel( $addr, 0, $byte, 0 ) if $self->show_mem;
383          return $byte;          return $byte;
384  }  }
385    
# Line 355  sub write { Line 396  sub write {
396          my ($addr,$byte) = @_;          my ($addr,$byte) = @_;
397          warn sprintf("# Orao::write(%04x,%02x)\n", $addr, $byte) if $self->trace;          warn sprintf("# Orao::write(%04x,%02x)\n", $addr, $byte) if $self->trace;
398    
         if ( $addr >= 0x6000 && $addr < 0x8000 ) {  
                 $self->vram( $addr - 0x6000 , $byte );  
         }  
   
399          if ( $addr == 0x8800 ) {          if ( $addr == 0x8800 ) {
400                    $self->write_tape( $byte );
401                  warn sprintf "sound ignored: %x\n", $byte;                  warn sprintf "sound ignored: %x\n", $byte;
402          }          }
403    
404          if ( $addr > 0xafff ) {          if ( $addr > 0xafff ) {
405                  warn sprintf "write access 0x%04x > 0xafff aborting\n", $addr;                  confess sprintf "write access 0x%04x > 0xafff aborting\n", $addr;
                 return;  
406          }          }
407    
408          $self->mmap_pixel( $addr, $byte, 0, 0 );          $self->render_vram if ( $addr >= 0x6000 && $addr <= 0x7fff );
409    
410          $mem[$addr] = $byte;          $self->mmap_pixel( $addr, $byte, 0, 0 ) if $self->show_mem;
411    #       $mem[$addr] = $byte;
412          return;          return;
413  }  }
414    
415  =head1 Command Line  =head1 Architecture specific
416    
417  Command-line debugging intrerface is implemented for communication with  =head2 render_vram
 emulated device  
418    
419  =head2 prompt  Render one frame of video ram
420    
421    my ( $entered_line, @p ) = $orao->prompt( $address, $last_command );    $self->render_vram;
422    
423  =cut  =cut
424    
425  my $last = 'r 1';  sub render_vram {
   
 sub prompt {  
426          my $self = shift;          my $self = shift;
427          $self->app->sync;  
428          my $a = shift;  #       my $pixels = pack("C*", map { $flip[$_] } @mem[ 0x6000 .. 0x7fff ]);
429          print STDERR $self->hexdump( $a ),  #       my $pixels = pack("C*", map { $flip[$_] } $self->ram( 0x6000, 0x7fff ));
430                  $last ? "[$last] " : '',  #       my $pixels = M6502::mem_peek_region( 0x6000, 0x7fff );
431                  "> ";          my $pixels = pack('C*', map { $flip[$_] } unpack('C*', M6502::mem_peek_region( 0x6000, 0x7fff ) ) );
432          my $in = <STDIN>;  
433          chomp($in);          my $vram = SDL::Surface->new(
434          warn "## prompt got: $in\n" if $self->debug;                  -width => 256,
435          $in ||= $last;                  -height => 256,
436          $last = $in;                  -depth => 1,    # 1 bit per pixel
437          return ( $in, split(/\s+/, $in) ) if $in;                  -pitch => 32,   # bytes per line
438                    -from => $pixels,
439            );
440            $vram->set_colors( 0, $black, $white );
441    
442            $self->render_frame( $vram );
443  }  }
444    
445  =head2 cli  =head2 cpu_PC
446    
447    $orao->cli();  Helper metod to set or get PC for current architecture
448    
449  =cut  =cut
450    
451  my $show_R = 0;  sub cpu_PC {
452            my ( $self, $addr ) = @_;
453            if ( defined($addr) ) {
454                    $PC = $addr;
455                    warn sprintf("running from PC %04x\n", $PC);
456            };
457            return $PC;
458    }
459    
460    
461    =head2 _init_callbacks
462    
463    Mark memory areas for which we want to get callbacks to perl
464    
465    =cut
466    
467  sub cli {  sub _init_callbacks {
468          my $self = shift;          my $self = shift;
469          my $a = $PC || confess "no pc?";          warn "set calbacks to perl for memory areas...\n";
470          warn $self->dump_R() if $show_R;  
471          while ( my ($line, @v) = $self->prompt( $a, $last ) ) {          # don't call for anything
472                  my $c = shift @v;          M6502::set_all_callbacks( 0x00 );
                 next unless defined($c);  
                 my $v = shift @v;  
                 $v = hex($v) if $v && $v =~ m/^[0-9a-f]+$/;  
                 @v = map { hex($_) } @v;  
                 printf "## a: %04x parsed cli: c:%s v:%s %s\n", $a, $c, ($v || 'undef'), join(",",@v) if $self->debug;  
                 if ( $c =~ m/^[qx]/i ) {  
                         exit;  
                 } elsif ( $c eq '?' ) {  
                         my $t = $self->trace ? 'on' : 'off' ;  
                         my $d = $self->debug ? 'on' : 'off' ;  
                         warn <<__USAGE__;  
 Usage:  
   
 x|q\t\texit  
 e 6000 6010\tdump memory, +/- to walk forward/backward  
 m 1000 ff 00\tput ff 00 on 1000  
 j|u 1000\t\tjump (change pc)  
 r 42\t\trun 42 instruction opcodes  
 t\t\ttrace [$t]  
 d\t\tdebug [$d]  
   
 __USAGE__  
                         warn $self->dump_R;  
                 } elsif ( $c =~ m/^e/i ) {  
                         $a = $v if defined($v);  
                         my $to = shift @v;  
                         $to = $a + 32 if ( ! $to || $to <= $a );  
                         $to = 0xffff if ( $to > 0xffff );  
                         my $lines = int( ($to - $a + 8) / 8 );  
                         printf "## e %04x %04x (%d bytes) lines: %d\n", $a, $to, ($to-$a), $lines;  
                         while ( --$lines ) {  
                                 print $self->hexdump( $a );  
                                 $a += 8;  
                         }  
                         $last = '+';  
                         $show_R = 0;  
                 } elsif ( $c =~ m/^\+/ ) {  
                         $a += 8;  
                         $show_R = 0;  
                 } elsif ( $c =~ m/^\-/ ) {  
                         $a -= 8;  
                         $show_R = 0;  
                 } elsif ( $c =~ m/^m/i ) {  
                         $a = $v if defined($v);  
                         $self->poke_code( $a, @v );  
                         printf "poke %d bytes at %04x\n", $#v + 1, $a;  
                         $last = '+';  
                         $show_R = 0;  
                 } elsif ( $c =~ m/^l/i ) {  
                         my $to = shift @v || 0x1000;  
                         $a = $to;  
                         $self->load_oraoemu( $v, $a );  
                         $last = '';  
                 } elsif ( $c =~ m/^s/i ) {  
                         $self->save_dump( $v || 'mem.dump', @v );  
                         $last = '';  
                 } elsif ( $c =~ m/^r/i ) {  
                         $run_for = $v || 1;  
                         print "run_for $run_for instructions\n";  
                         $show_R = 1;  
                         last;  
                 } elsif ( $c =~ m/^(u|j)/ ) {  
                         my $to = $v || $a;  
                         printf "set pc to %04x\n", $to;  
                         $PC = $to;      # remember for restart  
                         $run_for = 1;  
                         $last = "r $run_for";  
                         $show_R = 1;  
                         last;  
                 } elsif ( $c =~ m/^t/ ) {  
                         $self->trace( not $self->trace );  
                         print "trace ", $self->trace ? 'on' : 'off', "\n";  
                         $last = '';  
                 } elsif ( $c =~ m/^d/ ) {  
                         $self->debug( not $self->debug );  
                         print "debug ", $self->debug ? 'on' : 'off', "\n";  
                         $last = '';  
                 } else {  
                         warn "# ignored $line\n" if ($line);  
                         $last = '';  
                 }  
         }  
473    
474            # video ram
475    #       M6502::set_write_callback( $_ ) foreach ( 0x6000 .. 0x7fff );
476            # keyboard
477            M6502::set_read_callback( $_ ) foreach ( keys %$keyboard );
478            # tape
479            M6502::set_read_callback( 0x87ff );
480            M6502::set_write_callback( 0x8800 );
481    
482            my $map = '';
483            foreach ( 0 .. 0xffff ) {
484                    my $cb = M6502::get_callback( $_ );
485                    $map .= sprintf( "%04x: %02x\n", $_, $cb ) if $cb;
486            }
487            warn "callback map:\n$map\n";
488  }  }
489    
490    =head1 SEE ALSO
491    
492    L<VRac>, L<M6502>, L<Screen>, L<Tape>
493    
494  =head1 AUTHOR  =head1 AUTHOR
495    
496  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
497    
 =head1 BUGS  
   
498  =head1 ACKNOWLEDGEMENTS  =head1 ACKNOWLEDGEMENTS
499    
500  See also L<http://www.foing.hr/~fng_josip/orao.htm> which is source of all  See also L<http://www.foing.hr/~fng_josip/orao.htm> which is source of all

Legend:
Removed from v.82  
changed lines
  Added in v.213

  ViewVC Help
Powered by ViewVC 1.1.26