/[VRac]/VRac.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 /VRac.pm

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

revision 128 by dpavlin, Sat Aug 4 20:28:51 2007 UTC revision 145 by dpavlin, Sun Aug 5 13:27:27 2007 UTC
# Line 12  __PACKAGE__->mk_accessors(qw(booted)); Line 12  __PACKAGE__->mk_accessors(qw(booted));
12    
13  =head1 NAME  =head1 NAME
14    
15  VRac - Virtualno Računalo  VRac - Virtualno Računalo
16    
17  =head1 VERSION  =head1 VERSION
18    
# Line 27  our $VERSION = '0.00'; Line 27  our $VERSION = '0.00';
27  Emulator of 8-bit architectures based on L<M6502> or L<Z80> emulation.  Emulator of 8-bit architectures based on L<M6502> or L<Z80> emulation.
28    
29  This project is homage to 8-bit computers in Croatia and former Yugoslavia  This project is homage to 8-bit computers in Croatia and former Yugoslavia
30  from 1980-1990. Word B<vrac> means also I<wizzard> in Croatian.  from 1980-1990. Word B<vrac> means also I<wizard> in Croatian.
31    
32  =cut  =cut
33    
# Line 49  sub run { Line 49  sub run {
49          confess "please implement $self::run\n";          confess "please implement $self::run\n";
50  }  }
51    
 =head2 jump  
52    
53  Start execution from some location (modify PC)  =head1 Memory management
54    
55    VRac implements callback for all I/O operations. This was main reason why
56    L<Acme::6502> module with tied memory was too slow to emulate L<Orao>, so I
57    had to write C binding for L<M6502>.
58    
59    B<This functions will die with stack trace when called>. They should be
60    implemented for each architecture.
61    
62  =cut  =cut
63    
64  sub jump {  =head2 read
65    
66    Read from memory
67    
68      $byte = read( $address );
69    
70    =cut
71    
72    sub read {
73          my $self = shift;          my $self = shift;
74          confess "please implement $self::jump\n";          confess "please implement $self::read()";
75  }  }
76    
77    =head2 write
78    
79    Write into emory
80    
81      write( $address, $byte );
82    
83    =cut
84    
85    sub write {
86            my $self = shift;
87            confess "please implement $self::write()";
88    }
89    
90  =head1 Helper functions  =head1 Helper functions
91    
# Line 121  sub save_dump { Line 147  sub save_dump {
147          $from ||= 0;          $from ||= 0;
148          $to ||= 0xffff;          $to ||= 0xffff;
149    
150          open(my $fh, '>', $path) || die "can't open $path: $!";          if ( open(my $fh, '>', $path) ) {
151          print $fh $self->read_chunk( $from, $to );                  print $fh $self->read_chunk( $from, $to );
152          close($fh);                  close($fh);
153    
154                    my $size = -s $path;
155                    warn sprintf "saved %s %04x-%04x %d %x bytes\n", $path, $from, $to, $size, $size;
156            } else {
157                    warn "can't create $path: $!";
158            }
159    
         my $size = -s $path;  
         warn sprintf "saved %s %d %x bytes\n", $path, $size, $size;  
160  }  }
161    
162  =head2 hexdump  =head2 hexdump
# Line 152  sub hexdump { Line 182  sub hexdump {
182          );          );
183  }  }
184    
185  =head1 Memory management  =head2 append_to_file
186    
187  VRac implements all I/O using mmap addresses. This was main reason why    $self->append_to_file( '/path/to/file', $byte, $byte ... );
 L<Acme::6502> was just too slow to handle it.  
188    
189  =cut  =cut
190    
191  =head2 read  sub append_to_file {
   
 Read from memory  
   
   $byte = read( $address );  
   
 =cut  
   
 sub read {  
192          my $self = shift;          my $self = shift;
193          confess "please implement $self::read()";          my $path = shift || confess "no path?";
194  }          my $bytes = join('', @_);
195    
196  =head2 write          open(my $fh, '>>', $path) || confess "can't open $path: $!";
197    
198  Write into emory          print $fh $bytes;
199            warn sprintf("## append_to_file('%s',%s)\n", $path, dump($bytes));
   write( $address, $byte );  
   
 =cut  
   
 sub write {  
         my $self = shift;  
         confess "please implement $self::write()";  
200  }  }
201    
202  =head1 Command Line  =head1 Command Line
# Line 330  __USAGE__ Line 344  __USAGE__
344          return $run_for;          return $run_for;
345  }  }
346    
347    =head1 SEE ALSO
348    
349    Components: L<M6502>, L<Z80>, L<Screen>, L<Tape>
350    
351    Emulators: L<Orao>, L<Galaksija>
352    
353  =head1 AUTHOR  =head1 AUTHOR
354    
355  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>

Legend:
Removed from v.128  
changed lines
  Added in v.145

  ViewVC Help
Powered by ViewVC 1.1.26