/[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 96 by dpavlin, Thu Aug 2 13:58:26 2007 UTC revision 106 by dpavlin, Fri Aug 3 08:44:45 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/;
 use List::Util qw/first/;  
11  use M6502;  use M6502;
12    
13  use base qw(Class::Accessor M6502 Screen Prefs);  use base qw(Class::Accessor M6502 Screen Prefs);
# Line 32  Emulator or Orao 8-bit 6502 machine popu Line 31  Emulator or Orao 8-bit 6502 machine popu
31    
32  =cut  =cut
33    
 my @kbd_ports = (  
     0x87FC,0x87FD,0x87FA,0x87FB,0x87F6,0x87F7,  
     0x87EE,0x87EF,0x87DE,0x87DF,0x87BE,0x87BF,  
     0x877E,0x877F,0x86FE,0x86FF,0x85FE,0x85FF,  
     0x83FE,0x83FF,  
 );  
   
34  =head1 FUNCTIONS  =head1 FUNCTIONS
35    
36  =head2 boot  =head2 boot
# Line 71  sub boot { Line 63  sub boot {
63                  0x1000 => 'dump/SCRINV.BIN',                  0x1000 => 'dump/SCRINV.BIN',
64                  # should be 0x6000, but oraoemu has 2 byte prefix                  # should be 0x6000, but oraoemu has 2 byte prefix
65                  0x5FFE => 'dump/screen.dmp',                  0x5FFE => 'dump/screen.dmp',
66                  0xC000 => 'rom/BAS12.ROM',  #               0xC000 => 'rom/BAS12.ROM',
67                  0xE000 => 'rom/CRT12.ROM',  #               0xE000 => 'rom/CRT12.ROM',
68                    0xC000 => 'rom/BAS13.ROM',
69                    0xE000 => 'rom/CRT13.ROM',
70          });          });
71    
72  #       $PC = 0xDD11;   # BC  #       $PC = 0xDD11;   # BC
# Line 305  Read from memory Line 299  Read from memory
299    
300  =cut  =cut
301    
302    my $keyboard_none = 255;
303    
304    my $keyboard = {
305            0x87FC => {
306                    'right'         => 16,
307                    'down'          => 128,
308                    'up'            => 192,
309                    'left'          => 224,
310                    'backspace' => 224,
311            },
312            0x87FD => sub {
313                    my ( $self, $key ) = @_;
314                    if ( $key eq 'return' ) {
315                            M6502::_write( 0xfc, 13 );
316                            warn "return\n";
317                            return 0;
318                    } elsif ( $key =~ m/ ctrl/ || $self->key_down( 'left ctrl' ) || $self->key_down( 'right ctrl' ) ) {
319                            warn "ctrl\n";
320                            return 16;
321                    }
322                    return $keyboard_none;
323            },
324            0x87FA => {
325                    'f4' => 16,
326                    'f3' => 128,
327                    'f2' => 192,
328                    'f1' => 224,
329            },
330            0x87FB => sub {
331                    my ( $self, $key ) = @_;
332                    if ( $key eq 'space' ) {
333                            return 32;
334                    } elsif ( $self->key_down( 'left shift' ) || $self->key_down( 'right shift' ) ) {
335                            warn "shift\n";
336                            return 16;
337                    }
338                    return $keyboard_none;
339            },
340            0x87F6 => {
341                    '6' => 16,
342                    't' => 128,
343                    'y' => 192,     # hr: z
344                    'r' => 224,
345            },
346            0x87F7 => {
347                    '5' => 32,
348                    '4' => 16,
349            },
350            0x87EE => {
351                    '7' => 16,
352                    'u' => 128,
353                    'i' => 192,
354                    'o' => 224,
355            },
356            0x87EF => {
357                    '8' => 32,
358                    '9' => 16,
359            },
360            0x87DE => {
361                    '1' => 16,
362                    'w' => 128,
363                    'q' => 192,
364                    'e' => 224,
365            },
366            0x87DF => {
367                    '2' => 32,
368                    '3' => 16,
369            },
370            0x87BE => {
371                    'm' => 16,
372                    'k' => 128,
373                    'j' => 192,
374                    'l' => 224,
375            },
376            0x87BF => {
377                    ',' => 32,      # <
378                    '.' => 16,      # >
379            },
380            0x877E => {
381                    'z' => 16,      # hr:y
382                    's' => 128,
383                    'a' => 192,
384                    'd' => 224,
385            },
386            0x877F => {
387                    'x' => 32,
388                    'c' => 16,
389            },
390            0x86FE => {
391                    'n' => 16,
392                    'g' => 128,
393                    'h' => 192,
394                    'f' => 224,
395            },
396            0x86FF => {
397                    'b' => 32,
398                    'v' => 16,
399            },
400            0x85FE => {
401                    '<' => 16,              # :
402                    '\\' => 128,    # ¾
403                    '\'' => 192,    # æ
404                    ';' => 224,             # è
405            },
406            0x85FF => {
407                    '/' => 32,
408                    'f11' => 16,    # ^
409            },
410            0x83FE => {
411                    'f12' => 16,    # ;
412                    '[' => 128,             # ¹
413                    ']' => 192,             # ð
414                    'p' => 224,
415            },
416            0x83FF => {
417                    '-' => 32,
418                    '0' => 16,
419            },
420    };
421    
422  sub read {  sub read {
423          my $self = shift;          my $self = shift;
424          my ($addr) = @_;          my ($addr) = @_;
# Line 314  sub read { Line 428  sub read {
428    
429          # keyboard          # keyboard
430    
431          if ( first { $addr == $_ } @kbd_ports ) {          if ( defined( $keyboard->{$addr} ) ) {
432                  warn sprintf("keyboard port: %04x\n",$addr);                  warn sprintf("keyboard port: %04x\n",$addr) if $self->trace;
433          } elsif ( $addr == 0x87fc ) {                  my $key = $self->key_pressed;
434                  warn "0x87fc - arrows/back\n";                  if ( defined($key) ) {
435  =for pascal                          my $ret = $keyboard_none;
436                  if VKey=VK_RIGHT then Result:=16;                          my $r = $keyboard->{$addr} || confess "no definition for keyboard port found";
437                  if VKey=VK_DOWN then Result:=128;                          if ( ref($r) eq 'CODE' ) {
438                  if VKey=VK_UP then Result:=192;                                  $ret = $r->($self, $key);
439                  if VKey=VK_LEFT then Result:=224;                          } elsif ( defined($r->{$key}) ) {
440                  if Ord(KeyPressed)=VK_BACK then Result:=224;                                  $ret = $r->{$key};
441  =cut                                  if ( ref($ret) eq 'CODE' ) {
442          } elsif ( $addr == 0x87fd ) {                                          $ret = $ret->($self);
443                  warn "0x87fd - enter\n";                                  }
444  =for pascal                          } else {
445      if KeyPressed=Chr(13) then begin                                  warn sprintf("keyboard port: %04x unknown key: '%s'\n", $addr, $key) if $debug;
446        Mem[$FC]:=13;                          }
447        Result:=0;                          warn sprintf("keyboard port: %04x key:%s code:%d\n",$addr,$key,$ret) if ( $ret != $keyboard_none );
448      end;                          return $ret;
449  =cut                  }
450          } elsif ( $addr == 0x87fa ) {                  return $keyboard_none;
                 warn "0x87fa = F1 - F4\n";  
 =for pascal  
     if VKey=VK_F4 then Result:=16;  
     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  
451          }          }
452    
453          $self->mmap_pixel( $addr, 0, $byte, 0 );          $self->mmap_pixel( $addr, 0, $byte, 0 );
# Line 381  sub write { Line 468  sub write {
468          warn sprintf("# Orao::write(%04x,%02x)\n", $addr, $byte) if $self->trace;          warn sprintf("# Orao::write(%04x,%02x)\n", $addr, $byte) if $self->trace;
469    
470          if ( $addr >= 0x6000 && $addr < 0x8000 ) {          if ( $addr >= 0x6000 && $addr < 0x8000 ) {
471                  $self->vram( $addr - 0x6000 , $byte );  #               $self->vram( $addr - 0x6000 , $byte );
472          }          }
473    
474          if ( $addr == 0x8800 ) {          if ( $addr == 0x8800 ) {
# Line 415  sub prompt { Line 502  sub prompt {
502          my $self = shift;          my $self = shift;
503          $self->app->sync;          $self->app->sync;
504          my $a = shift;          my $a = shift;
505          print STDERR $self->hexdump( $a ),          print $self->hexdump( $a ),
506                  $last ? "[$last] " : '',                  $last ? "[$last] " : '',
507                  "> ";                  "> ";
508          my $in = <STDIN>;          my $in = <STDIN>;
# Line 464  d\t\tdebug [$d] Line 551  d\t\tdebug [$d]
551    
552  __USAGE__  __USAGE__
553                          warn $self->dump_R;                          warn $self->dump_R;
554                            $last = '';
555                  } elsif ( $c =~ m/^e/i ) {                  } elsif ( $c =~ m/^e/i ) {
556                          $a = $v if defined($v);                          $a = $v if defined($v);
557                          my $to = shift @v;                          my $to = shift @v;

Legend:
Removed from v.96  
changed lines
  Added in v.106

  ViewVC Help
Powered by ViewVC 1.1.26