Explorar o código

AROS: rtl-console, fv, FP-IDE added

git-svn-id: trunk@28552 -
marcus %!s(int64=11) %!d(string=hai) anos
pai
achega
49b0c18c53

+ 4 - 0
.gitattributes

@@ -6586,6 +6586,10 @@ packages/rtl-console/Makefile svneol=native#text/plain
 packages/rtl-console/Makefile.fpc svneol=native#text/plain
 packages/rtl-console/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/rtl-console/fpmake.pp svneol=native#text/plain
+packages/rtl-console/src/aros/keyboard.pp svneol=native#text/plain
+packages/rtl-console/src/aros/mouse.pp svneol=native#text/plain
+packages/rtl-console/src/aros/video.pp svneol=native#text/plain
+packages/rtl-console/src/aros/videodata.inc svneol=native#text/plain
 packages/rtl-console/src/emx/crt.pp svneol=native#text/plain
 packages/rtl-console/src/go32v2/crt.pp svneol=native#text/plain
 packages/rtl-console/src/go32v2/keyboard.pp svneol=native#text/plain

+ 1 - 1
ide/fpmake.pp

@@ -165,7 +165,7 @@ begin
     { This one is only needed if DEBUG is set }
     P.Dependencies.Add('regexpr');
     if not (NoGDBOption) then
-      P.Dependencies.Add('gdbint',AllOSes-[morphos]);
+      P.Dependencies.Add('gdbint',AllOSes-[morphos,aros]);
     P.Dependencies.Add('graph',[go32v2]);
 
     P.SupportBuildModes:=[bmOneByOne];

+ 5 - 0
ide/fpusrscr.pas

@@ -86,6 +86,11 @@ type
   {$DEFINE AMIGASCREEN}
 {$ENDIF}
 
+{$IFDEF AROS}
+  {$DEFINE AMIGASCREEN}
+{$ENDIF}
+
+
 {$IFDEF AMIGASCREEN}
     PAmigaScreen = ^TAmigaScreen;
     TAmigaScreen = object(TScreen)

+ 3 - 0
ide/wconsole.pas

@@ -43,6 +43,9 @@ interface
 {$ifdef morphos}
       longint
 {$endif morphos}
+{$ifdef aros}
+      longint
+{$endif aros}
     ;
 Procedure SaveConsoleMode(var ConsoleMode : TConsoleMode);
 Procedure RestoreConsoleMode(const ConsoleMode : TConsoleMode);

+ 18 - 0
ide/whelp.pas

@@ -191,6 +191,9 @@ uses
 {$endif}
 {$ifdef netware_clib}
   nwserv,
+{$endif}
+{$ifdef aros}
+  dos,
 {$endif}
   Strings,
   WConsts;
@@ -202,6 +205,11 @@ type
     procedure FreeItem(Item: Pointer); virtual;
   end;
 
+{$ifdef AROS}
+var
+  StartupTicks: Int64;
+{$endif}
+
 const
   HelpFileTypes : PHelpFileTypeCollection = nil;
 
@@ -316,6 +324,11 @@ begin
   GetDosTicks := -1;
 end;
 {$endif}
+{$ifdef AROS}
+begin
+  GetDosTicks := ((dos.GetMsCount div 55) - StartupTicks) and $7FFFFFFF;
+end;
+{$endif}
 
 
 procedure DisposeRecord(var R: TRecord);
@@ -992,4 +1005,9 @@ begin
   Dispose(HelpFiles, Done);
 end;
 
+{$ifdef AROS}
+INITIALIZATION
+  StartupTicks := dos.GetMsCount div 55;
+{$endif}
+
 END.

+ 1 - 1
packages/Makefile.fpc.fpcmake

@@ -64,7 +64,7 @@ dirs_palmos=palmunits
 dirs_go32v2=rtl-console fv graph unzip gdbint
 dirs_amiga=amunits
 dirs_morphos=morphunits rtl-console fv opengl sdl
-dirs_aros=arosunits
+dirs_aros=arosunits rtl-console fv
 dirs_wii=libogcfpc
 dirs_arm_nds=libndsfpc
 

+ 1 - 1
packages/arosunits/src/agraphics.pas

@@ -2165,7 +2165,7 @@ procedure LoadView(View: PView); syscall GfxBase 37;
 procedure LockLayerRom(l: PLayer); syscall GfxBase 72;
 function MakeVPort(View: PView; ViewPort: PViewPort): LongWord; syscall GfxBase 36;
 function ModeNotAvailable(ModeID: LongWord): LongWord; syscall GfxBase 133;
-procedure Move(Rp: PRastPort; x, y: SmallInt); syscall GfxBase 40;
+procedure GfxMove(Rp: PRastPort; x, y: SmallInt); syscall GfxBase 40;
 procedure MoveSprite(Vp: PViewPort; Sprite: PSimpleSprite; x, y: SmallInt); syscall GfxBase 71;
 function MrgCop(View: PView): LongWord; syscall GfxBase 35;
 function NewRectRegion(MinX, MinY, MaxX, MaxY: SmallInt): PRegion; syscall GfxBase 194;

+ 3 - 3
packages/arosunits/src/intuition.pas

@@ -562,11 +562,11 @@ type
     Width,
     Height: SmallInt;      // screen dimensions of window
 {$ifdef AROS_FLAVOUR_BINCOMPAT}
-    MouseX,
-    MouseY: SmallInt;      // relative to upper-left of window
-{$else}
     MouseY,
     MouseX: SmallInt;      // relative to upper-left of window
+{$else}
+    MouseX,
+    MouseY: SmallInt;      // relative to upper-left of window
 {$endif}
     MinWidth,
     MinHeight: SmallInt;   // minimum sizes

+ 2 - 1
packages/fv/fpmake.pp

@@ -20,7 +20,7 @@ begin
     P.Author := 'Leon De Boer and Pierre Mueller';
     P.License := 'LGPL with modification, ';
     P.HomepageURL := 'www.freepascal.org';
-    P.OSes := [beos,haiku,freebsd,darwin,iphonesim,solaris,netbsd,openbsd,linux,win32,win64,os2,emx,netware,netwlibc,go32v2,morphos,aix];
+    P.OSes := [beos,haiku,freebsd,darwin,iphonesim,solaris,netbsd,openbsd,linux,win32,win64,os2,emx,netware,netwlibc,go32v2,morphos,aros,aix];
     P.Email := '';
     P.Description := 'Free Vision, a portable Turbo Vision clone.';
     P.NeedLibC:= false;
@@ -30,6 +30,7 @@ begin
     P.Dependencies.add('rtl-console');
     P.Dependencies.add('rtl-extra');
     P.Dependencies.add('morphunits',[morphos]);
+    P.Dependencies.add('arosunits',[aros]);
 
     T:=P.Targets.AddUnit('app.pas');
       with T.Dependencies do

+ 12 - 4
packages/fv/src/drivers.pas

@@ -94,7 +94,7 @@ USES
    {$ENDIF}
 
    {$IFDEF OS_AMIGA}
-      amigados,
+      dos, amigados,
    {$ENDIF}
 
    video,
@@ -718,7 +718,9 @@ VAR
    EventQueue : Array [0..EventQSize - 1] Of TEvent;  { Event queue }
    EventQLast : RECORD END;                           { Simple end marker }
    StartupScreenMode : TVideoMode;
-
+   {$ifdef OS_AMIGA}
+   StartupTicks: Int64; // ticks at Startup for GetDOSTicks
+   {$endif}
 {---------------------------------------------------------------------------}
 {  GetDosTicks (18.2 Hz)                                                    }
 {---------------------------------------------------------------------------}
@@ -769,8 +771,7 @@ var
 {$ENDIF}
 {$IFDEF OS_AMIGA}
   begin
-{$WARNING FIXME: dummy implementation}
-    GetDosTicks:=-1;
+    GetDosTicks:= ((dos.GetMsCount div 55) - StartupTicks) and $7FFFFFFF;
   end;
 {$ENDIF OS_AMIGA}
 
@@ -824,7 +825,11 @@ end;
 {$IFDEF OS_AMIGA}
   begin
     { AmigaOS Delay() wait's argument in 1/50 seconds }
+    {$IFDEF AROS}
+    DOSDelay(2);
+    {$ELSE}
     AmigaDOS.Delay(2);
+    {$ENDIF}
   end;
 {$ENDIF OS_AMIGA}
 
@@ -1583,6 +1588,9 @@ END;
 {                      UNIT INITIALIZATION ROUTINE                          }
 {***************************************************************************}
 BEGIN
+{$IFDEF OS_AMIGA}
+  StartupTicks := (dos.GetMsCount div 55);
+{$ENDIF}
    ButtonCount := DetectMouse;                        { Detect mouse }
    DetectVideo;                                       { Detect video }
 {   InitKeyboard;}

+ 6 - 0
packages/fv/src/platform.inc

@@ -420,6 +420,12 @@ FOR FPC THESE ARE THE TRANSLATIONS
   {$ENDIF}
 {$ENDIF}
 
+{ AROS has AmigaOS API, so define OS_AMIGA }
+{$IFDEF AROS}
+  {$UNDEF OS_DOS}
+  {$DEFINE OS_AMIGA}
+{$ENDIF}
+
 {---------------------------------------------------------------------------}
 {  FPC ATARI COMPILER changes op system and CPU type - Updated 27Aug98 LdB  }
 {---------------------------------------------------------------------------}

+ 4 - 0
packages/fv/src/sysmsg.pas

@@ -90,6 +90,10 @@ implementation
 {$i amismsg.inc}
 {$define HAS_SYSMSG}
 {$endif morphos}
+{$ifdef aros}
+{$i amismsg.inc}
+{$define HAS_SYSMSG}
+{$endif aros}
 
 {$ifdef HAS_SYSMSG}
 

+ 1 - 0
packages/rtl-console/Makefile.fpc.fpcmake

@@ -30,6 +30,7 @@ units_os2=crt video mouse keyboard
 units_netware=crt video mouse keyboard
 units_netwlibc=crt video mouse keyboard
 units_morphos=video mouse keyboard
+units_aros=video mouse keyboard
 
 [compiler]
 includedir=src/$(OS_TARGET) src/inc

+ 3 - 2
packages/rtl-console/fpmake.pp

@@ -13,10 +13,10 @@ Const
   UnixLikes = AllUnixOSes -[QNX];
  
   WinEventOSes = [win32,win64];
-  KVMAll       = [emx,go32v2,MorphOS,netware,netwlibc,os2,win32,win64]+UnixLikes;
+  KVMAll       = [emx,go32v2,MorphOS,aros,netware,netwlibc,os2,win32,win64]+UnixLikes;
   
   // all full KVMers have crt too, except MorphOS
-  CrtOSes      = KVMALL+[msdos,WatCom]-[MorphOS];
+  CrtOSes      = KVMALL+[msdos,WatCom]-[MorphOS,aros];
   KbdOSes      = KVMALL+[msdos];
   VideoOSes    = KVMALL;
   MouseOSes    = KVMALL;
@@ -45,6 +45,7 @@ begin
     P.NeedLibC:= false;
     P.Dependencies.Add('rtl-extra'); // linux,android gpm.
     P.Dependencies.Add('morphunits',[morphos]);
+    P.Dependencies.Add('arosunits',[aros]);
 
     P.SourcePath.Add('src/inc');
     P.SourcePath.Add('src/$(OS)');

+ 470 - 0
packages/rtl-console/src/aros/keyboard.pp

@@ -0,0 +1,470 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2006 by Karoly Balogh
+
+    Keyboard unit for MorphOS and Amiga and AROS
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+unit Keyboard;
+interface
+
+{$i keybrdh.inc}
+
+implementation
+
+uses
+   video, exec,intuition, inputevent, mouse, sysutils, keymap;
+
+{$i keyboard.inc}
+{$i keyscan.inc}
+var
+   LastShiftState : Byte;               {set by handler for PollShiftStateEvent}
+   OldMouseX : LongInt;
+   OldmouseY : LongInt;
+   OldButtons: Word;
+
+procedure SysInitKeyboard;
+begin
+//  writeln('sysinitkeyboard');
+  LastShiftState := 0;
+  OldMouseX := -1;
+  OldmouseY := -1;
+  OldButtons := 0;
+end;
+
+procedure SysDoneKeyboard;
+begin
+
+end;
+
+function IsMsgPortEmpty(Port: PMsgPort): Boolean; inline;
+begin
+  IsMsgPortEmpty := (Port^.mp_MsgList.lh_TailPred = @(Port^.mp_MsgList));
+end;
+
+var
+  KeyQueue: TKeyEvent;
+
+type 
+  RawCodeEntry = record
+    rc,n,s,c,a : Word; { raw code, normal, shift, ctrl, alt }
+  end;
+
+const
+  RCTABLE_MAXIDX = 24;
+  RawCodeTable : array[0..RCTABLE_MAXIDX] of RawCodeEntry =
+    (
+     (rc: 66; n: $0F09; s: $0F00; c: $9400; a: $A500; ), // TAB
+     (rc: 68; n: $1C0D; s: $1C0D; c: $1C0A; a: $1C0D; ), // Enter  // shift, alt?
+     (rc: 69; n: $011B; s: $011B; c: $011B; a: $0100; ), // ESC    // shift?
+     (rc: 70; n: $5300; s: $0700; c: $A300; a: $A200; ), // Delete
+     (rc: 71; n: $5200; s: $0500; c: $0400; a: $A200; ), // Insert
+     (rc: 72; n: $4900; s: $4900; c: $8400; a: $9900; ), // PgUP   // shift?
+     (rc: 73; n: $5100; s: $5100; c: $7600; a: $A100; ), // PgDOWN // shift?
+
+     (rc: 76; n: $4800; s: $4800; c: $8D00; a: $9800; ), // UP     // shift?
+     (rc: 77; n: $5000; s: $5000; c: $9100; a: $A000; ), // DOWN   // shift?
+     (rc: 78; n: $4D00; s: $4D00; c: $7400; a: $9D00; ), // RIGHT  // shift?
+     (rc: 79; n: $4B00; s: $4B00; c: $7300; a: $9B00; ), // LEFT   // shift?
+ 
+     (rc: 80; n: $3B00; s: $5400; c: $5E00; a: $6800; ), // F1
+     (rc: 81; n: $3C00; s: $5500; c: $5F00; a: $6900; ), // F2
+     (rc: 82; n: $3D00; s: $5600; c: $6000; a: $6A00; ), // F3
+     (rc: 83; n: $3E00; s: $5700; c: $6100; a: $6B00; ), // F4
+     (rc: 84; n: $3F00; s: $5800; c: $6200; a: $6C00; ), // F5
+     (rc: 85; n: $4000; s: $5900; c: $6300; a: $6D00; ), // F6
+     (rc: 86; n: $4100; s: $5A00; c: $6400; a: $6E00; ), // F7
+     (rc: 87; n: $4200; s: $5B00; c: $6500; a: $6F00; ), // F8
+     (rc: 88; n: $4300; s: $5C00; c: $6600; a: $7000; ), // F9
+     (rc: 89; n: $4400; s: $5D00; c: $6700; a: $7100; ), // F10
+     (rc: 75; n: $8500; s: $8700; c: $8900; a: $8B00; ), // F11
+     (rc: 76; n: $8600; s: $8800; c: $8A00; a: $8C00; ), // F12
+
+     (rc: 112; n: $4700; s: $4700; c: $7700; a: $9700; ),// Home    // shift?
+     (rc: 113; n: $4F00; s: $4F00; c: $7500; a: $9F00; ) // End     // shift?
+    );
+
+function rcTableIdx(rc: LongInt): LongInt;
+var
+  Counter: LongInt;
+begin
+  rcTableIdx := -1;
+  Counter := 0;
+  while (RawCodeTable[Counter].rc <> rc) and (Counter <= RCTABLE_MAXIDX) do
+    Inc(Counter);
+  if (Counter <= RCTABLE_MAXIDX) then
+    rcTableIdx := Counter;
+end;
+
+function HasShift(IQual: Word): Boolean; inline;
+begin
+  HasShift := ((IQual and IEQUALIFIER_LSHIFT) <> 0) or
+     ((IQual and IEQUALIFIER_RSHIFT) <> 0);
+end;
+
+function HasCtrl(IQual: Word): Boolean; inline;
+begin
+  HasCtrl := ((IQual and IEQUALIFIER_CONTROL) <> 0);
+end;
+
+function HasAlt(IQual: Word): Boolean; inline;
+begin
+  HasAlt := ((IQual and IEQUALIFIER_LALT) <> 0) or
+     ((IQual and IEQUALIFIER_RALT) <> 0);
+end;
+
+function rcTableCode(IQual: Word; Idx: LongInt): LongInt;
+begin
+  if (Idx < 0) or (Idx > RCTABLE_MAXIDX) then
+  begin
+    rcTableCode := -1;
+    Exit;
+  end;
+
+  if HasShift(IQual) then
+    rcTableCode:=RawCodeTable[Idx].s
+  else
+    if HasCtrl(IQual) then
+      rcTableCode:=RawCodeTable[Idx].c
+    else
+      if HasAlt(IQual) then
+        rcTableCode:=RawCodeTable[Idx].a
+      else
+        rcTableCode:=RawCodeTable[Idx].n;
+end;
+
+procedure setShiftState(IQual: Word);
+begin
+  LastShiftState := 0;
+  if ((IQual and IEQUALIFIER_LSHIFT) <> 0) then
+    LastShiftState := LastShiftState or $01;
+  if ((IQual and IEQUALIFIER_RSHIFT) <> 0) then
+    LastShiftState := LastShiftState or $02;
+  if HasCtrl(IQual) then
+    LastShiftState := LastShiftState or $04;
+  if HasAlt(IQual) then
+    LastShiftState := LastShiftState or $08;
+  if ((IQual and IEQUALIFIER_NUMERICPAD) <> 0) then
+    LastShiftState := LastShiftState or $20;
+  if ((IQual and IEQUALIFIER_CAPSLOCK) <> 0) then
+    LastShiftState := LastShiftState or $40;
+end;
+
+function SysPollKeyEvent: TKeyEvent;
+var
+  MouseEvent: Boolean;   // got a mouseevent -> do not leave cycle
+  SendMouse: Boolean;    // we got a (or many) mouse move  send the last one
+  mes: TMouseEvent;      // save mouse message send after cycle -> prevent mouse move stacking
+  me: TMouseEvent;
+  KeyCode: LongInt;
+  OldKeyCode: LongInt;
+  KeySet: ^TKeyRecord;   // points to result to set fields directly
+  Ret: LongInt;
+  //
+  iMsg: PIntuiMessage;
+  ICode: Word;           // save items from Message
+  IQual: Word;
+  IClass: Longword;
+  MouseX: Integer;
+  MouseY: Integer;
+  KeyUp: Boolean;        // Event is a key up event
+  Buff: array[0..19] of Char;
+  ie: TInputEvent;       // for mapchar
+begin
+  KeyCode := 0;
+  SysPollKeyEvent := 0;
+  KeySet := @SysPollKeyEvent;
+  FillChar(me, SizeOf(TMouseEvent), 0);
+
+  if KeyQueue <> 0 then
+  begin
+    SysPollKeyEvent := KeyQueue;
+    Exit;
+  end;
+  SendMouse := False;
+  repeat
+    MouseEvent := False;
+    if VideoWindow <> nil then
+    begin
+      if IsMsgPortEmpty(videoWindow^.UserPort) then
+        Break;
+    end else
+      Exit;
+    PMessage(iMsg) := GetMsg(VideoWindow^.UserPort);
+    if (iMsg <> nil) then
+    begin
+      ICode := iMsg^.Code;
+      IQual := iMsg^.Qualifier;
+      IClass := iMsg^.iClass;
+      MouseX := iMsg^.MouseX;
+      MouseY := iMsg^.MouseY;
+      ReplyMsg(PMessage(iMsg)); // fast reply to system
+      SetShiftState(IQual); // set Shift state qualifiers. do this for all messages we get.
+      // main event case
+      case (IClass) of
+        IDCMP_CLOSEWINDOW: begin
+            //writeln('got close');
+            GotCloseWindow;
+          end;
+        IDCMP_CHANGEWINDOW: begin
+            GotResizeWindow;
+          end;
+        IDCMP_MOUSEBUTTONS: begin
+            MouseEvent := True;
+            me.x := (MouseX - videoWindow^.BorderLeft) div 8;  // calculate char position
+            me.y := (MouseY - videoWindow^.BorderTop) div 16;
+            case ICode of
+              SELECTDOWN: begin
+                  //writeln('left down!');
+                  me.Action := MouseActionDown;
+                  OldButtons := OldButtons or MouseLeftButton;
+                  me.Buttons := OldButtons;
+                  PutMouseEvent(me);
+                end;
+              SELECTUP: begin
+                  //writeln('left up!');
+                  me.Action := MouseActionUp;
+                  OldButtons := OldButtons and (not MouseLeftButton);
+                  me.Buttons := OldButtons;
+                  PutMouseEvent(me);
+                end;
+              MENUDOWN: begin
+                  //writeln('right down!');
+                  me.Action := MouseActionDown;
+                  OldButtons := OldButtons or MouseRightButton;
+                  me.Buttons := OldButtons;
+                  PutMouseEvent(me);
+                end;
+              MENUUP: begin
+                  //writeln('right up!');
+                  me.Action := MouseActionUp;
+                  OldButtons := OldButtons and (not MouseRightButton);
+                  me.Buttons := OldButtons;
+                  PutMouseEvent(me);
+                end;
+            end;
+            //writeln('Buttons: ' , me.Buttons);
+          end;
+        IDCMP_MOUSEMOVE: begin
+            MouseX := (MouseX - VideoWindow^.BorderLeft) div 8;
+            MouseY := (MouseY - VideoWindow^.BorderTop) div 16;
+            if (MouseX >= 0) and (MouseY >= 0) and
+               (MouseX < Video.ScreenWidth) and (MouseY < Video.ScreenHeight) and
+               ((MouseX <> OldMouseX) or (MouseY <> OldmouseY))
+              then begin
+//              //writeln('mousemove:',Mousex,'/',Mousey,' oldbutt:',OldButtons);
+              // Drawing is very slow so when moving window it will drag behind
+              // because the mouse events stack in the messageport
+              // -> so we override move until messageport is empty or keyevent is fired
+              SendMouse := True;
+              MouseEvent := True;
+              mes.Action := MouseActionMove;
+              mes.Buttons := OldButtons;
+              mes.X := MouseX;
+              mes.Y := MouseY;
+              //PutMouseEvent(me);
+            end;
+          end;
+        IDCMP_RAWKEY: begin
+          // mouse wheel up or down -> pgup and pgdown
+          if ICode = 122 then
+            ICode := 72;
+          if ICode = 123 then
+            ICode := 73;
+          // get char from rawkey
+          KeyUp := (ICode and IECODE_UP_PREFIX) <> 0;   // is key up
+          ICode := ICode and not IECODE_UP_PREFIX;      // remove key up from ICode
+          ie.ie_Class := IECLASS_RAWKEY;
+          ie.ie_SubClass := 0;
+          ie.ie_Code := ICode;
+          ie.ie_Qualifier := IQual;
+          ie.ie_NextEvent := nil;
+          Buff[0] := #0;
+          Ret := MapRawKey(@ie, @Buff[0], 1, nil);
+          KeyCode := Ord(Buff[0]);
+          KeySet^.KeyCode := Ord(Buff[0]);         // if maprawkey does not work it still is 0
+          KeySet^.ShiftState := LastShiftState;    // shift state set before the case
+          KeySet^.Flags := 0;
+          if keyup then                            // we do not need key up events up to now
+          begin
+            KeySet^.Flags := KeySet^.Flags or kbReleased; // kbReleased does work but make strange effects
+            SysPollKeyEvent := 0;
+            Exit;
+          end;
+          // check our hard coed list if there is an entry -> leave it must be right ;)
+          // F-keys, cursor, esc, del, ins, del, pgup, pgdown, pos, end, enter, tab
+          if rcTableCode(IQual,rcTableIdx(ICode)) >= 0 then
+          begin
+            KeyCode := rcTableCode(IQual,rcTableIdx(ICode));
+            KeySet^.KeyCode := KeyCode;
+            KeySet^.Flags := kbPhys;
+          end else
+          begin
+            // left alt or ctrl is pressed -> check for alternative Scancode -> commando
+            if ((IQual and IEQUALIFIER_LALT) <> 0) or  HasCtrl(IQual) then
+            begin
+              OldKeyCode := KeyCode;  // save keycode if nothing found
+              KeyCode := 0;
+              ie.ie_Class := IECLASS_RAWKEY;    // get keycode without qualifier easier case
+              ie.ie_SubClass := 0;
+              ie.ie_Code := ICode;
+              ie.ie_Qualifier := 0;
+              ie.ie_NextEvent := nil;
+              Buff[0] := #0;
+              Ret := MapRawKey(@ie, @Buff[0], 1, nil);
+              if Ret > 0 then
+              begin
+                if ((IQual and IEQUALIFIER_LALT) <> 0) then   // check left alt keycodes
+                begin
+                  case Buff[0] of        // Alt - keys already defined
+                    'a': KeyCode := kbAltA shl 8;
+                    'b': KeyCode := kbAltB shl 8;
+                    'c': KeyCode := kbAltC shl 8;
+                    'd': KeyCode := kbAltD shl 8;
+                    'e': KeyCode := kbAltE shl 8;
+                    'f': KeyCode := kbAltF shl 8;
+                    'g': KeyCode := kbAltG shl 8;
+                    'h': KeyCode := kbAltH shl 8;
+                    'i': KeyCode := kbAltI shl 8;
+                    'j': KeyCode := kbAltJ shl 8;
+                    'k': KeyCode := kbAltK shl 8;
+                    'l': KeyCode := kbAltL shl 8;
+                    'm': KeyCode := kbAltM shl 8;
+                    'n': KeyCode := kbAltN shl 8;
+                    'o': KeyCode := kbAltO shl 8;
+                    'p': KeyCode := kbAltP shl 8;
+                    'q': KeyCode := kbAltQ shl 8;
+                    'r': KeyCode := kbAltR shl 8;
+                    's': KeyCode := kbAltS shl 8;
+                    't': KeyCode := kbAltT shl 8;
+                    'u': KeyCode := kbAltU shl 8;
+                    'v': KeyCode := kbAltV shl 8;
+                    'w': KeyCode := kbAltW shl 8;
+                    'x': KeyCode := kbAltX shl 8;
+                    'y': KeyCode := kbAltY shl 8;
+                    'z': KeyCode := kbAltZ shl 8;
+                  end;
+                end else
+                begin
+                  case Buff[0] of      // ctrl - keys defined in FreeVision/drivers.pas -> so here direct numbers
+                    'a': KeyCode := $1E01;
+                    'b': KeyCode := $3002;
+                    'c': KeyCode := $2E03;
+                    'd': KeyCode := $2004;
+                    'e': KeyCode := $1205;
+                    'f': KeyCode := $2106;
+                    'g': KeyCode := $2207;
+                    'h': KeyCode := $2308;
+                    'i': KeyCode := $1709;
+                    'j': KeyCode := $240a;
+                    'k': KeyCode := $250b;
+                    'l': KeyCode := $260c;
+                    'm': KeyCode := $320d;
+                    'n': KeyCode := $310e;
+                    'o': KeyCode := $180f;
+                    'p': KeyCode := $1910;
+                    'q': KeyCode := $1011;
+                    'r': KeyCode := $1312;
+                    's': KeyCode := $1F13;
+                    't': KeyCode := $1414;
+                    'u': KeyCode := $1615;
+                    'v': KeyCode := $2F16;
+                    'w': KeyCode := $1117;
+                    'x': KeyCode := $2D18;
+                    'y': KeyCode := $1519;
+                    'z': KeyCode := $2C1A;
+                  end;
+                end;
+              end;
+              if KeyCode <= 0 then      // nothing found restore keycode
+                KeyCode := OldKeyCode;
+              KeySet^.KeyCode := KeyCode;
+              KeySet^.Flags := kbPhys;
+            end;
+          end;
+          if keycode <= 0 then
+          begin
+            KeySet^.KeyCode := 0;
+            KeyCode := 0;
+          end;
+          //writeln('raw keycode: ',iMsg^.code, ' -> $', IntToHex(keycode,4), ' ret: ', ret);
+        end;
+        else begin
+          KeyCode := 0;
+        end;
+      end;
+    end else
+      Break;
+  until (not MouseEvent);
+  //
+  if SendMouse then
+  begin
+    PutMouseEvent(mes);
+    OldMouseX:=Mousex;
+    OldmouseY:=Mousey;
+  end;
+  if KeyCode <= 0 then     // no keycode found then also delete flags and shiftstate
+    SysPollKeyEvent := 0
+  else
+    KeyQueue:=SysPollKeyEvent;
+end;
+
+function SysGetKeyEvent: TKeyEvent;
+var
+  Res: TKeyEvent;
+  me: TMouseEvent;
+begin
+  Res := 0;
+  if VideoWindow <> nil then
+  begin
+    if KeyQueue <> 0 then
+    begin
+      SysGetKeyEvent := KeyQueue;
+      KeyQueue := 0;
+      Exit;
+    end;
+    repeat
+      WaitPort(VideoWindow^.UserPort);
+      Res := SysPollKeyEvent;
+    until Res <> 0;
+  end else
+  begin
+    me.Action := MouseActionDown;
+    me.Buttons := MouseRightButton;
+    PutMouseEvent(me);
+  end;
+  SysGetKeyEvent := Res;
+end;
+
+{function SysTranslateKeyEvent(KeyEvent: TKeyEvent): TKeyEvent;
+begin
+end;}
+
+function SysGetShiftState: Byte;
+begin
+  //writeln('SysgetShiftState:',hexstr(LastShiftState,2));
+  SysGetShiftState := LastShiftState;
+end;
+
+const
+  SysKeyboardDriver : TKeyboardDriver = (
+    InitDriver : @SysInitKeyBoard;
+    DoneDriver : @SysDoneKeyBoard;
+    GetKeyevent : @SysGetKeyEvent;
+    PollKeyEvent : @SysPollKeyEvent;
+    GetShiftState : @SysGetShiftState;
+//    TranslateKeyEvent : @SysTranslateKeyEvent;
+    TranslateKeyEvent : Nil;
+    TranslateKeyEventUnicode : Nil;
+  );
+
+begin
+  SetKeyBoardDriver(SysKeyBoardDriver);
+end.

+ 61 - 0
packages/rtl-console/src/aros/mouse.pp

@@ -0,0 +1,61 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2006 Karoly Balogh
+    member of the Free Pascal development team
+
+    Mouse unit for Amiga/MorphOS
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+unit Mouse;
+interface
+
+{$i mouseh.inc}
+
+implementation
+
+{$i mouse.inc}
+
+function SysDetectMouse:byte;
+var
+  num : dword;
+begin
+  // Under Amiga/MorphOS, mouse is always there, and it's unable to easily
+  // detect number of buttons. So lets report 3, which is common nowadays. (KB)
+  SysDetectMouse:=3;
+end;
+
+
+
+
+
+
+
+
+
+const
+  SysMouseDriver : TMouseDriver = (
+    UseDefaultQueue : True;
+    InitDriver      : Nil;
+    DoneDriver      : Nil;
+    DetectMouse     : @SysDetectMouse;
+    ShowMouse       : Nil;
+    HideMouse       : Nil;
+    GetMouseX       : Nil;
+    GetMouseY       : Nil;
+    GetMouseButtons : Nil;
+    SetMouseXY      : Nil;
+    GetMouseEvent   : Nil;
+    PollMouseEvent  : Nil;
+    PutMouseEvent   : Nil;
+  );
+
+begin
+  SetMouseDriver(SysMouseDriver);
+end.

+ 606 - 0
packages/rtl-console/src/aros/video.pp

@@ -0,0 +1,606 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2006 by Karoly Balogh
+    member of the Free Pascal development team
+
+    Video unit for Amiga and MorphOS
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit Video;
+
+{.$define VIDEODEBUG}
+{.$define WITHBUFFERING}
+
+
+{
+  Date: 2013-01-09
+  What: Adjusted FPC video unit for AROS (/AmigaOS?)
+
+  goal:
+  ---------------------------------------------------------------------------
+  Attempt to add user-on-demand support for AROS Fullscreen to the FPC video 
+  unit.
+}
+
+
+interface
+
+uses
+  amigados, intuition, tagsarray, utility, sysutils;
+
+{$i videoh.inc}
+
+
+{ Amiga specific calls, to help interaction between Keyboard, Mouse and
+  Video units, and Free Vision }
+procedure GotCloseWindow;
+function  HasCloseWindow: boolean;
+procedure GotResizeWindow;
+function  HasResizeWindow(var winw:longint; var winh: longint): boolean;
+
+var
+  VideoWindow: PWindow;
+
+implementation
+
+uses
+   exec, agraphics;
+
+{$i video.inc}
+
+{$i videodata.inc}
+
+const
+  VIDEOSCREENNAME = 'FPC Video Screen Output';
+
+var
+  OS_Screen             : PScreen   = nil;    // To hold our screen, when necessary
+  FPC_VIDEO_FULLSCREEN  : Boolean   = False;  // Global that defines when we need to attempt opening on own scren
+
+var
+  VideoColorMap         : PColorMap;
+  VideoPens             : array[0..15] of LongInt;
+
+  OldCursorX, 
+  OldCursorY            : LongInt;
+  CursorType            : Word;
+  OldCursorType         : Word;
+
+  {$ifdef WITHBUFFERING}
+  BitmapWidth, BitmapHeight: Integer;
+  BufRp: PRastPort;
+  {$endif}
+
+  GotCloseWindowMsg     : Boolean;
+  GotResizeWindowMsg    : Boolean;
+  LastL, LastT: Integer;
+  LastW, LastH: Integer;
+  WindowForReqSave: PWindow;
+  Process: PProcess;
+(*
+  GetScreen: pScreen;
+
+  Tries to open a custom screen, which attempt to clone the workbench,
+  and returns the pointer to the screen. Result can be nil when failed
+  otherwise the screen got opened correctly.
+*)
+Function GetScreen: pScreen;
+var
+  ScreenTags: TTagsList;
+  Tags: PTagItem;
+begin
+  AddTags(ScreenTags,[
+    SA_Title          , VIDEOSCREENNAME,
+    SA_Left           , 0,
+    SA_Top            , 0,
+    SA_ShowTitle      , 0,    // Do not show the screen's TitleBar
+    SA_Type           , 1 shl 1, // pubscreen
+    SA_PubName        , VIDEOSCREENNAME,
+    SA_Quiet          , True,
+    SA_LikeWorkbench  , 1     // Let OS  
+  ]);
+  Tags := GetTagPtr(ScreenTags);
+  GetScreen := OpenScreenTagList(nil, Tags);
+  {$ifdef VIDEODEBUG}
+  if (GetScreen <> nil) then
+    Writeln('DEBUG: Opened a new screen')
+  else
+    Writeln('ERROR: Failed to open new screen');
+  {$endif}
+end;
+
+(*
+  GetWindow: pWindow;
+  
+  Tries to create and open a window. Returns the pointer to
+  the window or nil in case of failure.
+
+  The routine keeps the global FPC_FULL_SCREEM option into 
+  account and act accordingly.
+  
+  In windowed mode it returns a window with another kind of 
+  settings then when it has to reside on it's own customscreen.
+*)
+Function GetWindow: PWindow;
+Var
+  WindowTags: TTagsList;
+  Tags: PTagItem;
+begin  
+  if FPC_VIDEO_FULLSCREEN then
+  begin
+    OS_Screen := GetScreen;
+    If OS_Screen = nil then
+      Exit;
+
+    {$ifdef VIDEODEBUG}
+    WriteLn('DEBUG: Opened customscreen succesfully');
+    {$endif}
+    Addtags(WindowTags, [
+      WA_CustomScreen, OS_Screen,
+      WA_Left       , 0,
+      WA_Top        , 0,
+      WA_InnerWidth , (OS_Screen^.Width div 8) * 8,
+      WA_InnerHeight, (OS_Screen^.Height div 16) * 16,
+      WA_AutoAdjust , 1,
+      WA_Activate   , 1,
+      WA_Borderless , 1,
+      WA_BackDrop   , 1,
+      WA_FLAGS      , (WFLG_GIMMEZEROZERO or WFLG_REPORTMOUSE   or WFLG_RMBTRAP or
+                       WFLG_SMART_REFRESH or WFLG_NOCAREREFRESH),
+      WA_IDCMP      , (IDCMP_RAWKEY       or
+                       IDCMP_MOUSEMOVE    or IDCMP_MOUSEBUTTONS or
+                       IDCMP_CHANGEWINDOW or IDCMP_CLOSEWINDOW)
+    ]); 
+  end else  
+  begin      // Windowed Mode
+    AddTags(WindowTags, [
+      WA_Left       , LastL,
+      WA_Top        , LastT,
+      WA_InnerWidth , LastW*8,
+      WA_InnerHeight, LastH*16,
+      WA_MaxWidth   , 32768,
+      WA_MaxHeight  , 32768,
+      WA_Title      , PChar('FPC Video Window Output'),
+      WA_Activate   , 1,
+      WA_FLAGS      , (WFLG_GIMMEZEROZERO or WFLG_REPORTMOUSE   or
+                       WFLG_SMART_REFRESH or WFLG_NOCAREREFRESH or 
+                       WFLG_DRAGBAR       or WFLG_DEPTHGADGET   or WFLG_SIZEGADGET or
+                       WFLG_SIZEBBOTTOM   or WFLG_RMBTRAP       or WFLG_CLOSEGADGET),
+      WA_IDCMP      , (IDCMP_RAWKEY       or
+                       IDCMP_MOUSEMOVE    or IDCMP_MOUSEBUTTONS or
+                       IDCMP_CHANGEWINDOW or IDCMP_CLOSEWINDOW)//,
+    ]);  
+  end;
+
+  Tags := GetTagPtr(WindowTags);
+  GetWindow := OpenWindowTagList(nil, Tags);
+
+  Process := PProcess(FindTask(nil));
+  WindowForReqSave := Process^.pr_WindowPtr;
+  Process^.pr_WindowPtr := GetWindow;
+
+  {$ifdef VIDEODEBUG}
+  If GetWindow <> nil then
+    WriteLn('DEBUG: Sucessfully opened videounit Window')
+  else
+    WriteLn('ERROR: Failed to open videounit Window');
+  {$endif}
+end;
+
+
+// ==========================================================================
+// ==
+// ==  Original source code continues, with minor adjustments
+// ==
+// ==========================================================================
+
+
+procedure SysInitVideo;
+var
+  Counter: LongInt;
+begin
+  {$ifdef VIDEODEBUG}
+  WriteLn('FULLSCREEN VIDEO UNIT MODIFICATION v2');  
+  if FPC_VIDEO_FULLSCREEN then
+    WriteLn('DEBUG: Recognized fullscreen mode')
+  else
+    WriteLn('DEBUG: Recognized windowed mode');
+  {$endif}
+
+  // fill videobuf and oldvideobuf with different bytes, to allow proper first draw
+  FillDword(VideoBuf^, VideoBufSize div 4, $1234D3AD);
+  FillDword(OldVideoBuf^, VideoBufSize div 4, $4321BEEF);
+
+  VideoWindow := GetWindow;
+
+  // nice hardcode values are probably going to screw up things
+  // so wee neeed a way to detrmined how many chars could be on
+  // the screen in both directions. And a bit accurate.
+  if FPC_VIDEO_FULLSCREEN then
+  begin
+    // just to make sure that we are going to use the window width 
+    // and height instead of the one from the screen. 
+    // This is to circumvent that the window (or virtual window from
+    // vision based on characters pixels * characters in both 
+    // dimensions) is actually smaller then the window it resides on.
+    //
+    // Can happen for instance when the window does not hide it's 
+    // borders or title as intended.
+    ScreenWidth := VideoWindow^.GZZWidth div 8;
+    ScreenHeight := VideoWindow^.GZZHeight div 16;
+    ScreenColor := False;
+
+    {$ifdef VIDEODEBUG}
+    Writeln('DEBUG: Fullscreen - windowed - Width * Heigth = ',ScreenWidth,' * ',ScreenHeight);
+    {$endif}
+   end else
+   begin
+     ScreenWidth := LastW;
+     ScreenHeight := LastH;
+     ScreenColor := True;
+   end;
+   {$ifdef WITHBUFFERING}
+   BufRp^.Bitmap := AllocBitmap(VideoWindow^.GZZWidth, VideoWindow^.GZZHeight, VideoWindow^.RPort^.Bitmap^.Depth, BMF_CLEAR, VideoWindow^.RPort^.Bitmap);
+   BitmapWidth := VideoWindow^.GZZWidth;
+   BitmapHeight := VideoWindow^.GZZHeight;
+   {$endif}
+   { viewpostcolormap info }
+   videoColorMap := pScreen(videoWindow^.WScreen)^.ViewPort.ColorMap;
+   
+   for Counter := 0 to 15 do 
+   begin
+     VideoPens[Counter] := ObtainPen(VideoColorMap, LongWord(-1),
+         vgacolors[counter, 0] shl 24, vgacolors[counter, 1] shl 24, vgacolors[counter, 2] shl 24,
+         PEN_EXCLUSIVE);
+     {$ifdef VIDEODEBUG}
+     If VideoPens[Counter] = -1 then
+       WriteLn('errr color[',Counter,'] = ', VideoPens[Counter])
+     else
+       WriteLn('good color[',Counter,'] = ', VideoPens[Counter]);
+     {$endif}        
+   end;   
+   
+   CursorX := 0;
+   CursorY := 0;
+   OldCursorX := 0;
+   OldCursorY := 0;
+   CursorType := crHidden;
+   OldCursorType := crHidden;
+
+   GotCloseWindowMsg := false;
+   GotResizeWindowMsg := false;
+end;
+
+procedure SysDoneVideo;
+var
+  Counter: LongInt;
+begin
+  if VideoWindow <> nil then
+  begin
+    Process^.pr_WindowPtr := WindowForReqSave;
+    if not FPC_VIDEO_FULLSCREEN then
+    begin
+      LastL := VideoWindow^.LeftEdge;
+      LastT := VideoWindow^.TopEdge;
+    end;
+    CloseWindow(videoWindow);
+  end;
+  {$ifdef WITHBUFFERING}
+  FreeBitmap(BufRp^.Bitmap);
+  BufRp^.Bitmap := nil;
+  {$endif}
+  VideoWindow := nil;
+  for Counter := 0 to 15 do
+    ReleasePen(VideoColorMap, VideoPens[Counter]);
+  if ((FPC_VIDEO_FULLSCREEN) and (OS_Screen <> nil)) then
+  begin
+    CloseScreen(OS_Screen);
+  end;
+end;
+
+function SysSetVideoMode(const Mode: TVideoMode): Boolean;
+var
+  dx: integer;
+  dy: integer;
+begin
+  if ScreenColor <> Mode.Color then
+  begin
+    SysDoneVideo;
+    FPC_VIDEO_FULLSCREEN := not Mode.color;
+    if not FPC_VIDEO_FULLSCREEN then
+    begin
+      LastT := 50;
+      LastL := 50;
+      LastW := 80;
+      LastH := 25;
+    end;
+    SysInitVideo;
+  end else
+    if not FPC_VIDEO_FULLSCREEN then
+    begin
+      dx := (Mode.col * 8) - VideoWindow^.GZZWidth;
+      dy := (Mode.row * 16) - VideoWindow^.GZZHeight;
+      SizeWindow(videoWindow, dx, dy);
+    end;
+  ScreenWidth := Mode.col;
+  ScreenHeight := Mode.row;
+  LastW := Mode.Col;
+  LastH := Mode.Row;
+  ScreenColor := Mode.color;
+  SysSetVideoMode := True;
+end;
+
+var
+  OldSH, OldSW : longint;
+
+procedure SysClearScreen;
+begin
+  oldSH := -1;
+  oldSW := -1;
+  UpdateScreen(True);
+end;
+
+procedure DrawChar(rp: PRastPort; x, y: LongInt; crType: Word);
+var
+  TmpCharData: Word;
+  TmpChar: Byte;
+  TmpFGColor: Byte;
+  TmpBGColor: Byte;
+  sX, sY: LongInt;
+begin
+  TmpCharData := VideoBuf^[y * ScreenWidth + x];
+  TmpChar    := TmpCharData and $0ff;
+  TmpFGColor := (TmpCharData shr 8) and %00001111;
+  TmpBGColor := (TmpCharData shr 12) and %00000111;
+
+  sX := x * 8;
+  sY := y * 16;
+
+  if crType <> crBlock then
+  begin
+    SetABPenDrMd(rp, VideoPens[TmpFGColor], VideoPens[tmpBGColor], JAM2);
+  end else
+  begin
+    { in case of block cursor, swap fg/bg colors
+      and BltTemplate() below will take care of everything }
+    SetABPenDrMd(rp, VideoPens[tmpBGColor], VideoPens[tmpFGColor], JAM2);
+  end;
+
+  BltTemplate(@Vgafont[tmpChar, 0], 0, 1, rp, sX, sY, 8, 16);
+
+  if crType = crUnderLine then
+  begin
+    { draw two lines at the bottom of the char, in case of underline cursor }
+    GfxMove(rp, sX, sY + 14); Draw(rp, sX + 7, sY + 14);
+    GfxMove(rp, sX, sY + 15); Draw(rp, sX + 7, sY + 15);
+  end;
+end;
+
+procedure SysUpdateScreen(Force: Boolean);
+var
+  BufCounter: Longint;
+  SmallForce: Boolean;
+  Counter, CounterX, CounterY: LongInt;
+  //BufRp: PRastPort;
+  t: Double;
+  NumChanged: Integer;
+begin
+  SmallForce := False;
+
+  // override forced update when screen dimensions haven't changed
+  if Force then
+  begin
+    if (OldSH = ScreenHeight) and (OldSW = ScreenWidth) then
+      Force:=false
+    else
+    begin
+      OldSH := ScreenHeight;
+      OldSW := ScreenWidth;
+    end;
+  end;
+
+  if Force then
+  begin
+    SmallForce:=true;
+  end else
+  begin
+    Counter:=0;
+    while not smallforce and (Counter < (VideoBufSize div 4) - 1) do
+    begin
+      SmallForce := (PDWord(VideoBuf)[Counter] <> PDWord(OldVideoBuf)[Counter]);
+      inc(Counter);
+    end;
+  end;
+
+  {$ifdef WITHBUFFERING}
+  if (VideoWindow^.GZZWidth > BitmapWidth) or (VideoWindow^.GZZHeight > BitmapHeight) then
+  begin
+    FreeBitmap(BufRp^.Bitmap);
+    BufRp^.Bitmap := AllocBitmap(VideoWindow^.GZZWidth, VideoWindow^.GZZHeight, VideoWindow^.RPort^.Bitmap^.Depth, BMF_CLEAR, VideoWindow^.RPort^.Bitmap);
+    BitmapWidth := VideoWindow^.GZZWidth;
+    BitmapHeight := VideoWindow^.GZZHeight;
+    Force := True;
+    Smallforce := True;
+  end;
+  {$endif}
+
+  BufCounter:=0;
+  NumChanged:=0;
+  if Smallforce then
+  begin
+    //t := now();
+    for CounterY := 0 to ScreenHeight - 1 do
+    begin
+      for CounterX := 0 to ScreenWidth - 1 do
+      begin
+        if (VideoBuf^[BufCounter] <> OldVideoBuf^[BufCounter]) or Force then
+        begin
+          {$ifdef WITHBUFFERING}
+          DrawChar(BufRp, CounterX, CounterY, crHidden);
+          {$else}
+          DrawChar(VideoWindow^.RPort, CounterX, CounterY, crHidden);
+          {$endif}
+          OldVideoBuf^[BufCounter] := VideoBuf^[BufCounter];
+          Inc(NumChanged);
+        end;
+        Inc(BufCounter);
+      end;
+    end;
+    //if NumChanged > 100 then
+    //  writeln('redraw time: ', floattoStrF((Now-t)* 24 * 60 * 60 * 1000000 / NumChanged, fffixed, 8,3), ' us/char' ); // ms
+  end;
+
+  if (CursorType <> OldCursorType) or
+     (CursorX <> OldCursorX) or (CursorY <> OldCursorY) or
+     SmallForce then
+  begin
+    {$ifdef WITHBUFFERING}
+    DrawChar(BufRp, OldCursorY, OldCursorX, crHidden);
+    DrawChar(BufRp, CursorY, CursorX, CursorType);
+    {$else}
+    DrawChar(VideoWindow^.RPort, OldCursorY, OldCursorX, crHidden);
+    DrawChar(VideoWindow^.RPort, CursorY, CursorX, CursorType);
+    {$endif}
+    OldCursorX := CursorX;
+    OldCursorY := CursorY;
+    OldcursorType := CursorType;
+  end;
+  {$ifdef WITHBUFFERING}
+  BltBitMapRastPort(BufRp^.Bitmap, 0, 0, VideoWindow^.RPort, 0, 0, ScreenWidth * 8, ScreenHeight * 16, $00C0);
+  {$endif}
+end;
+
+
+procedure SysSetCursorPos(NewCursorX, NewCursorY: Word);
+begin
+  CursorX := NewCursorY;
+  CursorY := NewCursorX;
+  SysUpdateScreen(False);
+end;
+
+function SysGetCapabilities: Word;
+begin
+  SysGetCapabilities := cpColor or cpChangeCursor;
+end;
+
+function SysGetCursorType: Word;
+begin
+  SysGetCursorType := cursorType;
+end;
+
+
+procedure SysSetCursorType(NewType: Word);
+begin
+  cursorType := newType;
+  { FIXME: halfBlock cursors are not supported for now
+           by the rendering code }
+  if CursorType = crHalfBlock then
+    cursorType := crBlock;
+
+  SysUpdateScreen(False);
+end;
+
+
+// Amiga specific calls
+procedure GotCloseWindow;
+begin
+  GotCloseWindowMsg := True;
+end;
+
+function HasCloseWindow: Boolean;
+begin
+  HasCloseWindow := GotCloseWindowMsg;
+  GotCloseWindowMsg := False;
+end;
+
+procedure GotResizeWindow;
+begin
+  GotResizeWindowMsg := True;
+end;
+
+function HasResizeWindow(var WinW: LongInt; var WinH: LongInt): Boolean;
+begin
+  //writeln('Has resize ', GotResizeWindowMsg);
+  WinW := 0;
+  WinH := 0;
+  HasResizeWindow := GotResizeWindowMsg;
+  if Assigned(VideoWindow) then
+  begin
+    //writeln('resize');
+    WinW := VideoWindow^.GZZWidth div 8;
+    WinH := VideoWindow^.GZZHeight div 16;
+    LastW := WinW;
+    LastH := WinH;
+  end;
+  GotResizeWindowMsg := False;
+end;
+
+function SysGetVideoModeCount: Word;
+begin
+  SysGetVideoModeCount := 2;
+end;
+
+function SysGetVideoModeData(Index: Word; var Mode: TVideoMode): Boolean;
+var
+   Screen: PScreen;
+begin
+  case Index of
+    0: begin
+         Mode.Col := 80;
+         Mode.Row := 25;
+         Mode.Color := True;
+       end;
+    1: begin
+        Screen := LockPubScreen('Workbench');
+        Mode.Col := Screen^.Width div 8;
+        Mode.Row := Screen^.Height div 16;
+        UnlockPubScreen('Workbench', Screen);
+        Mode.Color := False;
+      end;
+  end;
+  SysGetVideoModeData := True;
+end;
+
+
+const
+  SysVideoDriver : TVideoDriver = (
+    InitDriver : @SysInitVideo;
+    DoneDriver : @SysDoneVideo;
+    UpdateScreen : @SysUpdateScreen;
+    ClearScreen : @SysClearScreen;
+    SetVideoMode : @SysSetVideoMode;
+    GetVideoModeCount : @SysGetVideoModeCount;
+    GetVideoModeData : @SysGetVideoModeData;
+    SetCursorPos : @SysSetCursorPos;
+    GetCursorType : @SysGetCursorType;
+    SetCursorType : @SysSetCursorType;
+    GetCapabilities : @SysGetCapabilities
+  );
+
+
+initialization
+  SetVideoDriver(SysVideoDriver);
+  LastT := 50;
+  LastL := 50;
+  LastW := 80;
+  LastH := 25;
+  {$ifdef WITHBUFFERING}
+  BufRp := CreateRastPort;
+  BufRp^.Layer := nil;
+  BufRp^.Bitmap := nil;
+  {$endif}
+finalization
+  {$ifdef WITHBUFFERING}
+  if Assigned(BufRp^.Bitmap) then
+    FreeBitmap(BufRp^.Bitmap);
+  FreeRastPort(BufRp);
+  {$endif}
+end.

+ 281 - 0
packages/rtl-console/src/aros/videodata.inc

@@ -0,0 +1,281 @@
+
+const
+   vgacolors : array[0..15,0..2] of byte = (
+      (   0,   0,   0 ), // black
+      (   0,   0, 153 ), // blue
+      (   0, 153,   0 ), // green
+      (   0, 153, 153 ), // cyan
+      ( 153,   0,   0 ), // red
+      ( 153,   0, 153 ), // magenta
+      ( 153, 102,   0 ), // brown
+      ( 153, 153, 153 ), // lightgray   
+
+      ( 102, 102, 102 ), // darkgray
+      ( 102, 102, 255 ), // lightblue
+      ( 102, 255, 102 ), // lightgreen
+      ( 102, 255, 255 ), // lightcyan
+      ( 255, 102, 102 ), // lightred
+      ( 255, 102, 255 ), // lightmagenta
+      ( 255, 255, 102 ), // yellow
+      ( 255, 255, 255 )  // white
+   );
+
+const
+   vgafont : array[0..255,0..15] of byte = (
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $7E, $81, $A5, $81, $81, $A5, $99, $81, $81, $7E, $00, $00, $00, $00 ),
+      ( $00, $00, $7E, $FF, $DB, $FF, $FF, $DB, $E7, $FF, $FF, $7E, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $6C, $FE, $FE, $FE, $FE, $7C, $38, $10, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $10, $38, $7C, $FE, $7C, $38, $10, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $18, $3C, $3C, $E7, $E7, $E7, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $18, $3C, $7E, $FF, $FF, $7E, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $18, $3C, $3C, $18, $00, $00, $00, $00, $00, $00 ),
+      ( $FF, $FF, $FF, $FF, $FF, $FF, $E7, $C3, $C3, $E7, $FF, $FF, $FF, $FF, $FF, $FF ),
+      ( $00, $00, $00, $00, $00, $3C, $66, $42, $42, $66, $3C, $00, $00, $00, $00, $00 ),
+      ( $FF, $FF, $FF, $FF, $FF, $C3, $99, $BD, $BD, $99, $C3, $FF, $FF, $FF, $FF, $FF ),
+      ( $00, $00, $1E, $06, $0E, $1A, $78, $CC, $CC, $CC, $CC, $78, $00, $00, $00, $00 ),
+      ( $00, $00, $3C, $66, $66, $66, $66, $3C, $18, $7E, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $3F, $33, $3F, $30, $30, $30, $30, $70, $F0, $E0, $00, $00, $00, $00 ),
+      ( $00, $00, $7F, $63, $7F, $63, $63, $63, $63, $67, $E7, $E6, $C0, $00, $00, $00 ),
+      ( $00, $00, $00, $18, $18, $DB, $3C, $E7, $3C, $DB, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $80, $C0, $E0, $F0, $F8, $FE, $F8, $F0, $E0, $C0, $80, $00, $00, $00, $00 ),
+      ( $00, $02, $06, $0E, $1E, $3E, $FE, $3E, $1E, $0E, $06, $02, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $3C, $7E, $18, $18, $18, $7E, $3C, $18, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $66, $66, $66, $66, $66, $66, $66, $00, $66, $66, $00, $00, $00, $00 ),
+      ( $00, $00, $7F, $DB, $DB, $DB, $7B, $1B, $1B, $1B, $1B, $1B, $00, $00, $00, $00 ),
+      ( $00, $7C, $C6, $60, $38, $6C, $C6, $C6, $6C, $38, $0C, $C6, $7C, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $FE, $FE, $FE, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $3C, $7E, $18, $18, $18, $7E, $3C, $18, $7E, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $3C, $7E, $18, $18, $18, $18, $18, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $18, $18, $18, $18, $18, $18, $7E, $3C, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $18, $0C, $FE, $0C, $18, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $30, $60, $FE, $60, $30, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $C0, $C0, $C0, $FE, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $28, $6C, $FE, $6C, $28, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $10, $38, $38, $7C, $7C, $FE, $FE, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $FE, $FE, $7C, $7C, $38, $38, $10, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $3C, $3C, $3C, $18, $18, $18, $00, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $66, $66, $66, $24, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $6C, $6C, $FE, $6C, $6C, $6C, $FE, $6C, $6C, $00, $00, $00, $00 ),
+      ( $18, $18, $7C, $C6, $C2, $C0, $7C, $06, $06, $86, $C6, $7C, $18, $18, $00, $00 ),
+      ( $00, $00, $00, $00, $C2, $C6, $0C, $18, $30, $60, $C6, $86, $00, $00, $00, $00 ),
+      ( $00, $00, $38, $6C, $6C, $38, $76, $DC, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $30, $30, $30, $60, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $0C, $18, $30, $30, $30, $30, $30, $30, $18, $0C, $00, $00, $00, $00 ),
+      ( $00, $00, $30, $18, $0C, $0C, $0C, $0C, $0C, $0C, $18, $30, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $66, $3C, $FF, $3C, $66, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $18, $18, $7E, $18, $18, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $00, $18, $18, $18, $30, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $FE, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $02, $06, $0C, $18, $30, $60, $C0, $80, $00, $00, $00, $00 ),
+      ( $00, $00, $38, $6C, $C6, $C6, $D6, $D6, $C6, $C6, $6C, $38, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $38, $78, $18, $18, $18, $18, $18, $18, $7E, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $06, $0C, $18, $30, $60, $C0, $C6, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $06, $06, $3C, $06, $06, $06, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $0C, $1C, $3C, $6C, $CC, $FE, $0C, $0C, $0C, $1E, $00, $00, $00, $00 ),
+      ( $00, $00, $FE, $C0, $C0, $C0, $FC, $06, $06, $06, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $38, $60, $C0, $C0, $FC, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $FE, $C6, $06, $06, $0C, $18, $30, $30, $30, $30, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $C6, $C6, $7C, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $C6, $C6, $7E, $06, $06, $06, $0C, $78, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $18, $18, $00, $00, $00, $18, $18, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $18, $18, $00, $00, $00, $18, $18, $30, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $06, $0C, $18, $30, $60, $30, $18, $0C, $06, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $7E, $00, $00, $7E, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $60, $30, $18, $0C, $06, $0C, $18, $30, $60, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $C6, $0C, $18, $18, $18, $00, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $7C, $C6, $C6, $DE, $DE, $DE, $DC, $C0, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $10, $38, $6C, $C6, $C6, $FE, $C6, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $FC, $66, $66, $66, $7C, $66, $66, $66, $66, $FC, $00, $00, $00, $00 ),
+      ( $00, $00, $3C, $66, $C2, $C0, $C0, $C0, $C0, $C2, $66, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $F8, $6C, $66, $66, $66, $66, $66, $66, $6C, $F8, $00, $00, $00, $00 ),
+      ( $00, $00, $FE, $66, $62, $68, $78, $68, $60, $62, $66, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $FE, $66, $62, $68, $78, $68, $60, $60, $60, $F0, $00, $00, $00, $00 ),
+      ( $00, $00, $3C, $66, $C2, $C0, $C0, $DE, $C6, $C6, $66, $3A, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $C6, $C6, $C6, $FE, $C6, $C6, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $3C, $18, $18, $18, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $1E, $0C, $0C, $0C, $0C, $0C, $CC, $CC, $CC, $78, $00, $00, $00, $00 ),
+      ( $00, $00, $E6, $66, $66, $6C, $78, $78, $6C, $66, $66, $E6, $00, $00, $00, $00 ),
+      ( $00, $00, $F0, $60, $60, $60, $60, $60, $60, $62, $66, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $EE, $FE, $FE, $D6, $C6, $C6, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $E6, $F6, $FE, $DE, $CE, $C6, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $FC, $66, $66, $66, $7C, $60, $60, $60, $60, $F0, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $C6, $C6, $C6, $C6, $C6, $D6, $DE, $7C, $0C, $0E, $00, $00 ),
+      ( $00, $00, $FC, $66, $66, $66, $7C, $6C, $66, $66, $66, $E6, $00, $00, $00, $00 ),
+      ( $00, $00, $7C, $C6, $C6, $60, $38, $0C, $06, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $7E, $7E, $5A, $18, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $6C, $38, $10, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $C6, $C6, $C6, $D6, $D6, $D6, $FE, $EE, $6C, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $C6, $6C, $7C, $38, $38, $7C, $6C, $C6, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $66, $66, $66, $66, $3C, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $FE, $C6, $86, $0C, $18, $30, $60, $C2, $C6, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $3C, $30, $30, $30, $30, $30, $30, $30, $30, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $80, $C0, $E0, $70, $38, $1C, $0E, $06, $02, $00, $00, $00, $00 ),
+      ( $00, $00, $3C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $3C, $00, $00, $00, $00 ),
+      ( $10, $38, $6C, $C6, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $FF, $00, $00 ),
+      ( $30, $30, $18, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $78, $0C, $7C, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $E0, $60, $60, $78, $6C, $66, $66, $66, $66, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $7C, $C6, $C0, $C0, $C0, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $1C, $0C, $0C, $3C, $6C, $CC, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $7C, $C6, $FE, $C0, $C0, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $38, $6C, $64, $60, $F0, $60, $60, $60, $60, $F0, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $76, $CC, $CC, $CC, $CC, $CC, $7C, $0C, $CC, $78, $00 ),
+      ( $00, $00, $E0, $60, $60, $6C, $76, $66, $66, $66, $66, $E6, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $18, $00, $38, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $06, $06, $00, $0E, $06, $06, $06, $06, $06, $06, $66, $66, $3C, $00 ),
+      ( $00, $00, $E0, $60, $60, $66, $6C, $78, $78, $6C, $66, $E6, $00, $00, $00, $00 ),
+      ( $00, $00, $38, $18, $18, $18, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $EC, $FE, $D6, $D6, $D6, $D6, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $DC, $66, $66, $66, $66, $66, $66, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $7C, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $DC, $66, $66, $66, $66, $66, $7C, $60, $60, $F0, $00 ),
+      ( $00, $00, $00, $00, $00, $76, $CC, $CC, $CC, $CC, $CC, $7C, $0C, $0C, $1E, $00 ),
+      ( $00, $00, $00, $00, $00, $DC, $76, $66, $60, $60, $60, $F0, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $7C, $C6, $60, $38, $0C, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $10, $30, $30, $FC, $30, $30, $30, $30, $36, $1C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $CC, $CC, $CC, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $66, $66, $66, $66, $66, $3C, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $C6, $C6, $D6, $D6, $D6, $FE, $6C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $C6, $6C, $38, $38, $38, $6C, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $C6, $C6, $C6, $C6, $C6, $C6, $7E, $06, $0C, $F8, $00 ),
+      ( $00, $00, $00, $00, $00, $FE, $CC, $18, $30, $60, $C6, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $0E, $18, $18, $18, $70, $18, $18, $18, $18, $0E, $00, $00, $00, $00 ),
+      ( $00, $00, $18, $18, $18, $18, $00, $18, $18, $18, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $70, $18, $18, $18, $0E, $18, $18, $18, $18, $70, $00, $00, $00, $00 ),
+      ( $00, $00, $76, $DC, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $10, $38, $6C, $C6, $C6, $C6, $FE, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $3C, $66, $C2, $C0, $C0, $C0, $C2, $66, $3C, $0C, $06, $7C, $00, $00 ),
+      ( $00, $00, $CC, $00, $00, $CC, $CC, $CC, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $0C, $18, $30, $00, $7C, $C6, $FE, $C0, $C0, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $10, $38, $6C, $00, $78, $0C, $7C, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $CC, $00, $00, $78, $0C, $7C, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $60, $30, $18, $00, $78, $0C, $7C, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $38, $6C, $38, $00, $78, $0C, $7C, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $3C, $66, $60, $60, $66, $3C, $0C, $06, $3C, $00, $00, $00 ),
+      ( $00, $10, $38, $6C, $00, $7C, $C6, $FE, $C0, $C0, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $00, $00, $7C, $C6, $FE, $C0, $C0, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $60, $30, $18, $00, $7C, $C6, $FE, $C0, $C0, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $66, $00, $00, $38, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $18, $3C, $66, $00, $38, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $60, $30, $18, $00, $38, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $C6, $00, $10, $38, $6C, $C6, $C6, $FE, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $38, $6C, $38, $00, $38, $6C, $C6, $C6, $FE, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $18, $30, $60, $00, $FE, $66, $60, $7C, $60, $60, $66, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $CC, $76, $36, $7E, $D8, $D8, $6E, $00, $00, $00, $00 ),
+      ( $00, $00, $3E, $6C, $CC, $CC, $FE, $CC, $CC, $CC, $CC, $CE, $00, $00, $00, $00 ),
+      ( $00, $10, $38, $6C, $00, $7C, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $00, $00, $7C, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $60, $30, $18, $00, $7C, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $30, $78, $CC, $00, $CC, $CC, $CC, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $60, $30, $18, $00, $CC, $CC, $CC, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $C6, $00, $00, $C6, $C6, $C6, $C6, $C6, $C6, $7E, $06, $0C, $78, $00 ),
+      ( $00, $C6, $00, $7C, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $C6, $00, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $18, $18, $3C, $66, $60, $60, $60, $66, $3C, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $38, $6C, $64, $60, $F0, $60, $60, $60, $60, $E6, $FC, $00, $00, $00, $00 ),
+      ( $00, $00, $66, $66, $3C, $18, $7E, $18, $7E, $18, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $F8, $CC, $CC, $F8, $C4, $CC, $DE, $CC, $CC, $CC, $C6, $00, $00, $00, $00 ),
+      ( $00, $0E, $1B, $18, $18, $18, $7E, $18, $18, $18, $18, $18, $D8, $70, $00, $00 ),
+      ( $00, $18, $30, $60, $00, $78, $0C, $7C, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $0C, $18, $30, $00, $38, $18, $18, $18, $18, $18, $3C, $00, $00, $00, $00 ),
+      ( $00, $18, $30, $60, $00, $7C, $C6, $C6, $C6, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $18, $30, $60, $00, $CC, $CC, $CC, $CC, $CC, $CC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $76, $DC, $00, $DC, $66, $66, $66, $66, $66, $66, $00, $00, $00, $00 ),
+      ( $76, $DC, $00, $C6, $E6, $F6, $FE, $DE, $CE, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $00, $3C, $6C, $6C, $3E, $00, $7E, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $38, $6C, $6C, $38, $00, $7C, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $30, $30, $00, $30, $30, $60, $C0, $C6, $C6, $7C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $FE, $C0, $C0, $C0, $C0, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $FE, $06, $06, $06, $06, $00, $00, $00, $00, $00 ),
+      ( $00, $C0, $C0, $C2, $C6, $CC, $18, $30, $60, $DC, $86, $0C, $18, $3E, $00, $00 ),
+      ( $00, $C0, $C0, $C2, $C6, $CC, $18, $30, $66, $CE, $9E, $3E, $06, $06, $00, $00 ),
+      ( $00, $00, $18, $18, $00, $18, $18, $18, $3C, $3C, $3C, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $36, $6C, $D8, $6C, $36, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $D8, $6C, $36, $6C, $D8, $00, $00, $00, $00, $00, $00 ),
+      ( $11, $44, $11, $44, $11, $44, $11, $44, $11, $44, $11, $44, $11, $44, $11, $44 ),
+      ( $55, $AA, $55, $AA, $55, $AA, $55, $AA, $55, $AA, $55, $AA, $55, $AA, $55, $AA ),
+      ( $DD, $77, $DD, $77, $DD, $77, $DD, $77, $DD, $77, $DD, $77, $DD, $77, $DD, $77 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $F8, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $18, $18, $18, $18, $18, $F8, $18, $F8, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $36, $36, $36, $36, $36, $36, $36, $F6, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $FE, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $00, $00, $00, $00, $00, $F8, $18, $F8, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $36, $36, $36, $36, $36, $F6, $06, $F6, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $36, $36, $36, $36, $36, $36, $36, $36, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $00, $00, $00, $00, $00, $FE, $06, $F6, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $36, $36, $36, $36, $36, $F6, $06, $FE, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $36, $36, $36, $36, $36, $36, $36, $FE, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $18, $18, $18, $18, $18, $F8, $18, $F8, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $F8, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $1F, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $FF, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $FF, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $1F, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $FF, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $FF, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $18, $18, $18, $18, $18, $1F, $18, $1F, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $36, $36, $36, $36, $36, $36, $36, $37, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $36, $36, $36, $36, $36, $37, $30, $3F, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $3F, $30, $37, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $36, $36, $36, $36, $36, $F7, $00, $FF, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $FF, $00, $F7, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $36, $36, $36, $36, $36, $37, $30, $37, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $00, $00, $00, $00, $00, $FF, $00, $FF, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $36, $36, $36, $36, $36, $F7, $00, $F7, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $18, $18, $18, $18, $18, $FF, $00, $FF, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $36, $36, $36, $36, $36, $36, $36, $FF, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $FF, $00, $FF, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $FF, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $36, $36, $36, $36, $36, $36, $36, $3F, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $18, $18, $18, $18, $18, $1F, $18, $1F, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $1F, $18, $1F, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $3F, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $36, $36, $36, $36, $36, $36, $36, $FF, $36, $36, $36, $36, $36, $36, $36, $36 ),
+      ( $18, $18, $18, $18, $18, $FF, $18, $FF, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $F8, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $1F, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ),
+      ( $00, $00, $00, $00, $00, $00, $00, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ),
+      ( $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0 ),
+      ( $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F ),
+      ( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $76, $DC, $D8, $D8, $D8, $DC, $76, $00, $00, $00, $00 ),
+      ( $00, $00, $78, $CC, $CC, $CC, $D8, $CC, $C6, $C6, $C6, $CC, $00, $00, $00, $00 ),
+      ( $00, $00, $FE, $C6, $C6, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $FE, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $FE, $C6, $60, $30, $18, $30, $60, $C6, $FE, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $7E, $D8, $D8, $D8, $D8, $D8, $70, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $66, $66, $66, $66, $66, $7C, $60, $60, $C0, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $76, $DC, $18, $18, $18, $18, $18, $18, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $7E, $18, $3C, $66, $66, $66, $3C, $18, $7E, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $38, $6C, $C6, $C6, $FE, $C6, $C6, $6C, $38, $00, $00, $00, $00 ),
+      ( $00, $00, $38, $6C, $C6, $C6, $C6, $6C, $6C, $6C, $6C, $EE, $00, $00, $00, $00 ),
+      ( $00, $00, $1E, $30, $18, $0C, $3E, $66, $66, $66, $66, $3C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $7E, $DB, $DB, $DB, $7E, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $03, $06, $7E, $DB, $DB, $F3, $7E, $60, $C0, $00, $00, $00, $00 ),
+      ( $00, $00, $1C, $30, $60, $60, $7C, $60, $60, $60, $30, $1C, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $7C, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $C6, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $FE, $00, $00, $FE, $00, $00, $FE, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $18, $18, $7E, $18, $18, $00, $00, $FF, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $30, $18, $0C, $06, $0C, $18, $30, $00, $7E, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $0C, $18, $30, $60, $30, $18, $0C, $00, $7E, $00, $00, $00, $00 ),
+      ( $00, $00, $0E, $1B, $1B, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18, $18 ),
+      ( $18, $18, $18, $18, $18, $18, $18, $18, $D8, $D8, $D8, $70, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $18, $18, $00, $7E, $00, $18, $18, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $76, $DC, $00, $76, $DC, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $38, $6C, $6C, $38, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $18, $18, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $18, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $0F, $0C, $0C, $0C, $0C, $0C, $EC, $6C, $6C, $3C, $1C, $00, $00, $00, $00 ),
+      ( $00, $D8, $6C, $6C, $6C, $6C, $6C, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $70, $D8, $30, $60, $C8, $F8, $00, $00, $00, $00, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $7C, $7C, $7C, $7C, $7C, $7C, $7C, $00, $00, $00, $00, $00 ),
+      ( $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 )
+   );