/[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

revision 32 by dpavlin, Mon Jul 30 18:37:37 2007 UTC revision 34 by dpavlin, Mon Jul 30 21:34:30 2007 UTC
# Line 8  use lib './lib'; Line 8  use lib './lib';
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 M6502;
12    
13  use base qw(Class::Accessor M6502 Screen);  use base qw(Class::Accessor M6502 Screen);
14  __PACKAGE__->mk_accessors(qw(debug trace run_for mem_dump trace));  __PACKAGE__->mk_accessors(qw(debug trace run_for mem_dump trace));
# Line 38  Start emulator Line 39  Start emulator
39    
40  our $orao;  our $orao;
41    
42    our $PC = 0x1000;
43    
44  sub init {  sub init {
45          my $self = shift;          my $self = shift;
46          warn "call upstream init\n";          warn "Orao calling upstream init\n";
47          $self->SUPER::init( @_ );          $self->SUPER::init( $self, @_ );
48    
49          warn "staring Orao $Orao::VERSION emulation\n";          warn "staring Orao $Orao::VERSION emulation\n";
50    
51          $self->open_screen;          $self->open_screen;
52          $self->load_rom;          $self->load_rom({
53                    0x1000 => 'dump/SCRINV.BIN',
54                    0xC000 => 'rom/BAS12.ROM',
55                    0xE000 => 'rom/CRT12.ROM',
56            });
57    
58          $orao = $self;          $orao = $self;
59    
60          $self->prompt( 0x1000 );  #       $self->prompt( 0x1000 );
 }  
61    
62  my $loaded_files = {          warn "rendering memory map\n";
63          0xC000 => 'rom/BAS12.ROM',  
64          0xE000 => 'rom/CRT12.ROM',          my @mmap = (
65  };                  0x0000, 0x03FF, 'nulti blok',
66                    0x0400, 0x5FFF, 'korisnički RAM (23K)',
67                    0x6000, 0x7FFF, 'video RAM',
68                    0x8000, 0x9FFF, 'sistemske lokacije',
69                    0xA000, 0xAFFF, 'ekstenzija',
70                    0xB000, 0xBFFF, 'DOS',
71                    0xC000, 0xDFFF, 'BASIC ROM',
72                    0xE000, 0xFFFF, 'sistemski ROM',
73            );
74    
75            foreach my $i ( 0 .. $#mmap / 3 ) {
76                    my $o = $i * 3;
77                    my ( $from, $to, $desc ) = @mmap[$o,$o+1,$o+2];
78                    printf "%04x - %04x - %s\n", $from, $to, $desc;
79                    for my $a ( $from .. $to ) {
80                            $orao->read( $a );
81                    }
82                    $self->sync;
83            }
84    
85            warn "Orao init finished\n";
86    
87    }
88    
89  =head2 load_rom  =head2 load_rom
90    
# Line 67  called to init memory and load initial r Line 95  called to init memory and load initial r
95  =cut  =cut
96    
97  sub load_rom {  sub load_rom {
98      my ($self) = @_;      my ($self, $loaded_files) = @_;
99    
100      #my $time_base = time();      #my $time_base = time();
101    
102          foreach my $addr ( sort keys %$loaded_files ) {          foreach my $addr ( sort keys %$loaded_files ) {
103                  my $path = $loaded_files->{$addr};                  my $path = $loaded_files->{$addr};
                 warn sprintf "loading '%s' at %04x\n", $path, $addr;  
104                  $self->load_oraoemu( $path, $addr );                  $self->load_oraoemu( $path, $addr );
105          }          }
106  }  }
# Line 93  sub load_oraoemu { Line 120  sub load_oraoemu {
120    
121          if ( $size == 65538 ) {          if ( $size == 65538 ) {
122                  $addr = 0;                  $addr = 0;
123                  warn sprintf "loading oraoemu 64k dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size, $size;                  warn sprintf "loading oraoemu 64k dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
124                  $self->write_chunk( $addr, substr($buff,2) );                  $self->write_chunk( $addr, substr($buff,2) );
125                  return;                  return;
126          } elsif ( $size == 32800 ) {          } elsif ( $size == 32800 ) {
127                  $addr = 0;                  $addr = 0;
128                  warn sprintf "loading oraoemu 1.3 dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size, $size;                  warn sprintf "loading oraoemu 1.3 dump %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
129                  #$self->write_chunk( $addr, substr($buff,0x20) );                  #$self->write_chunk( $addr, substr($buff,0x20) );
130                  $self->poke_code( $addr, map { ord($_) } split(//,substr($buff,0x20)) );                  $self->poke_code( $addr, map { ord($_) } split(//,substr($buff,0x20)) );
131                  return;                  return;
132          }          }
133          printf "loading %s at %04x - %04x %02x\n", $path, $addr, $addr+$size, $size;          printf "loading %s at %04x - %04x %02x\n", $path, $addr, $addr+$size-1, $size;
134            return $self->poke_code( $addr, map { ord($_) } split(//,$buff) );
135          return $self->write_chunk( $addr, $buff );          return $self->write_chunk( $addr, $buff );
136    
137          my $chunk;          my $chunk;
# Line 191  L<Acme::6502> was just too slow to handl Line 219  L<Acme::6502> was just too slow to handl
219    
220  =cut  =cut
221    
 my @mem = (0xff) x 0x100000; # 64Mb  
   
222  =head2 read  =head2 read
223    
224  Read from memory  Read from memory
# Line 202  Read from memory Line 228  Read from memory
228  =cut  =cut
229    
230  sub read {  sub read {
231          my $self = $orao;          my $self = shift;
232          my ($addr) = @_;          my ($addr) = @_;
233          my $byte = $mem[$addr];          my $byte = $mem[$addr];
234          warn "# Orao::read(",dump(@_),") = ",dump( $byte ),"\n" if $self->debug;          warn "# Orao::read(",dump(@_),") = ",dump( $byte ),"\n" if $self->debug;
235          mmap_pixel( $addr, 0, $byte, 0 );          $self->mmap_pixel( $addr, 0, $byte, 0 );
236          return $byte;          return $byte;
237  }  }
238    
# Line 219  Write into emory Line 245  Write into emory
245  =cut  =cut
246    
247  sub write {  sub write {
248          my $self = $orao;          my $self = shift;
249          warn "# Orao::write(",dump(@_),")\n" if $self->debug;          warn "# Orao::write(",dump(@_),")\n" if $self->debug;
250          my ($addr,$byte) = @_;          my ($addr,$byte) = @_;
251    
# Line 235  sub write { Line 261  sub write {
261                  warn sprintf "sound ignored: %x\n", $byte;                  warn sprintf "sound ignored: %x\n", $byte;
262          }          }
263    
264          mmap_pixel( $addr, $byte, 0, 0 );          $self->mmap_pixel( $addr, $byte, 0, 0 );
265    
266          $mem[$addr] = $byte;          $mem[$addr] = $byte;
267  }  }

Legend:
Removed from v.32  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26