amigalib.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005-2015 Karoly Balogh
  4. abox.lib implementation for MorphOS/PowerPC
  5. MorphOS port was done on a free Pegasos II/G4 machine
  6. provided by Genesi
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$INLINE ON}
  14. unit amigalib
  15. {$IFNDEF FPC_DOTTEDUNITS}
  16. deprecated 'Unit will be removed. Functions are moved to intuition, utility unit.';
  17. {$ENDIF FPC_DOTTEDUNITS}
  18. interface
  19. function DoMethod(obj : longword; const msg : array of LongWord): longword; inline;
  20. function DoMethod(obj : pointer; const msg : array of LongWord): longword; inline;
  21. function DoMethodA(obj : longword; msg1 : Pointer): longword; inline;
  22. function DoSuperMethod(class_: longword; obj : longword; const msg : array of LongWord): longword; inline;
  23. function DoSuperMethodA(class_: longword; obj : longword; msg1 : Pointer): longword; inline;
  24. function DoSuperMethodA(class_: pointer; obj : pointer; msg1 : Pointer): longword; inline;
  25. function DoSuperNew(class_: pointer; obj: pointer; const tags: array of LongWord): longword;
  26. { This procedure is used to pop Dispatcher arguments from the EmulHandle }
  27. procedure DISPATCHERARG(var cl; var obj; var msg);
  28. function HookEntry: PtrUInt;
  29. implementation
  30. {$IFDEF FPC_DOTTEDUNITS}
  31. uses
  32. Amiga.Core.Exec, Amiga.Core.Intuition, Amiga.Core.Utility;
  33. {$ELSE FPC_DOTTEDUNITS}
  34. uses
  35. exec, intuition, utility;
  36. {$ENDIF FPC_DOTTEDUNITS}
  37. function DoMethod(obj : longword; const msg : array of LongWord): longword; inline;
  38. begin
  39. DoMethod := Intuition.DoMethod(PObject_(Obj), Msg);
  40. end;
  41. function DoMethod(obj : pointer; const msg : array of LongWord): longword; inline;
  42. begin
  43. DoMethod := Intuition.DoMethod(PObject_(Obj), Msg);
  44. end;
  45. function DoMethodA(obj : longword; msg1 : Pointer): longword; inline;
  46. begin
  47. DoMethodA := Intuition.DoMethodA(PObject_(Obj), msg1);
  48. end;
  49. function DoSuperMethod(class_: longword; obj : longword; const msg : array of LongWord): longword; inline;
  50. begin
  51. DoSuperMethod := Intuition.DoSuperMethod(PIClass(Class_), PObject_(Obj), Msg);
  52. end;
  53. function DoSuperMethodA(class_: longword; obj : longword; msg1 : Pointer): longword; inline;
  54. begin
  55. DoSuperMethodA := Intuition.DoSuperMethodA(PIClass(class_), PObject_(obj), msg1);
  56. end;
  57. function DoSuperMethodA(class_: pointer; obj : pointer; msg1 : Pointer): longword; inline;
  58. begin
  59. DoSuperMethodA := Intuition.DoSuperMethodA(PIClass(class_), PObject_(Obj), Msg1);
  60. end;
  61. function DoSuperNew(class_: pointer; obj: pointer; const tags: array of LongWord): longword;
  62. begin
  63. DoSuperNew := Intuition.DoSuperNew(PIClass(class_), PObject_(Obj), Tags);
  64. end;
  65. { This procedure is used to pop Dispatcher arguments from the EmulHandle }
  66. procedure DISPATCHERARG(var cl; var obj; var msg);
  67. begin
  68. with GetEmulHandle^ do
  69. begin
  70. PtrUInt(cl) := reg[regA0];
  71. PtrUInt(obj) := reg[regA2];
  72. PtrUInt(msg) := reg[regA1];
  73. end;
  74. end;
  75. {
  76. // assembler implementation, kept for reference
  77. asm
  78. lwz r6,32(r2) // REG_a0
  79. stw r6,(r3) // cl
  80. lwz r6,40(r2) // REG_a2
  81. stw r6,(r4) // obj
  82. lwz r6,36(r2) // REG_a1
  83. stw r6,(r5) // msg
  84. end;}
  85. type
  86. THookSubEntryFunc = function(a, b, c: Pointer): PtrUInt;
  87. function HookEntry: PtrUInt;
  88. var
  89. hook: PHook;
  90. begin
  91. hook := REG_A0;
  92. HookEntry := THookSubEntryFunc(hook^.h_SubEntry)(hook, REG_A2, REG_A1);
  93. end;
  94. end.