--- M6502/Orao.pm 2007/08/01 13:01:17 77 +++ M6502/Orao.pm 2007/08/01 13:52:39 78 @@ -8,6 +8,7 @@ #use Time::HiRes qw(time); use File::Slurp; use Data::Dump qw/dump/; +use List::Util qw/first/; use M6502; use base qw(Class::Accessor M6502 Screen Prefs); @@ -31,6 +32,13 @@ =cut +my @kbd_ports = ( + 0x87FC,0x87FD,0x87FA,0x87FB,0x87F6,0x87F7, + 0x87EE,0x87EF,0x87DE,0x87DF,0x87BE,0x87BF, + 0x877E,0x877F,0x86FE,0x86FF,0x85FE,0x85FF, + 0x83FE,0x83FF, +); + =head2 init Start emulator, open L, load initial ROM images, and render memory @@ -60,6 +68,8 @@ # $PC = 0xDD11; # BC # $PC = 0xC274; # MC + $PC = 0xff89; + $orao = $self; # $self->prompt( 0x1000 ); @@ -270,6 +280,58 @@ my ($addr) = @_; my $byte = $mem[$addr]; warn sprintf("# Orao::read(%04x) = %02x\n", $addr, $byte) if $self->trace; + + # keyboard + + if ( first { $addr == $_ } @kbd_ports ) { + warn sprintf("keyboard port: %04x\n",$addr); + } elsif ( $addr == 0x87fc ) { + warn "0x87fc - arrows/back\n"; +=for pascal + if VKey=VK_RIGHT then Result:=16; + if VKey=VK_DOWN then Result:=128; + if VKey=VK_UP then Result:=192; + if VKey=VK_LEFT then Result:=224; + if Ord(KeyPressed)=VK_BACK then Result:=224; +=cut + } elsif ( $addr == 0x87fd ) { + warn "0x87fd - enter\n"; +=for pascal + if KeyPressed=Chr(13) then begin + Mem[$FC]:=13; + Result:=0; + end; +=cut + } elsif ( $addr == 0x87fa ) { + 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 + } + $self->mmap_pixel( $addr, 0, $byte, 0 ); return $byte; }