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

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

  ViewVC Help
Powered by ViewVC 1.1.26