Browse Source

Rebase to revision 16827
adjusted nflw.pas to compile again

git-svn-id: branches/svenbarth/classhelpers@16831 -

svenbarth 14 years ago
parent
commit
07eebff55c
100 changed files with 10285 additions and 8881 deletions
  1. 40 27
      .gitattributes
  2. 3 1
      compiler/aasmtai.pas
  3. 31 0
      compiler/arm/aasmcpu.pas
  4. 7 0
      compiler/arm/agarmgas.pas
  5. 3 0
      compiler/arm/armatt.inc
  6. 3 0
      compiler/arm/armatts.inc
  7. 4 0
      compiler/arm/armins.dat
  8. 3 0
      compiler/arm/armop.inc
  9. 3 0
      compiler/arm/cpubase.pas
  10. 40 3
      compiler/arm/raarmgas.pas
  11. 4 4
      compiler/cgobj.pas
  12. 118 90
      compiler/dbgdwarf.pas
  13. 3 15
      compiler/defcmp.pas
  14. 10 2
      compiler/globtype.pas
  15. 27 10
      compiler/htypechk.pas
  16. 3 0
      compiler/i386/cputarg.pas
  17. 1 1
      compiler/i386/i386tab.inc
  18. 5 6
      compiler/msg/errore.msg
  19. 1 1
      compiler/msgidx.inc
  20. 218 217
      compiler/msgtxt.inc
  21. 36 19
      compiler/ncal.pas
  22. 1 3
      compiler/ncginl.pas
  23. 47 57
      compiler/ncgmem.pas
  24. 9 4
      compiler/ncgutil.pas
  25. 1 0
      compiler/ncnv.pas
  26. 10 7
      compiler/nflw.pas
  27. 12 3
      compiler/ninl.pas
  28. 2 2
      compiler/nld.pas
  29. 2 2
      compiler/nutils.pas
  30. 1 1
      compiler/ogelf.pas
  31. 1 2
      compiler/pdecl.pas
  32. 20 17
      compiler/pdecobj.pas
  33. 25 13
      compiler/pdecsub.pas
  34. 99 54
      compiler/pdecvar.pas
  35. 39 82
      compiler/pexpr.pas
  36. 3 3
      compiler/pmodules.pas
  37. 14 8
      compiler/pp.lpi
  38. 1 1
      compiler/ppcgen/ngppcset.pas
  39. 21 19
      compiler/ptype.pas
  40. 4 1
      compiler/rautils.pas
  41. 5 3
      compiler/symconst.pas
  42. 123 10
      compiler/symdef.pas
  43. 2 2
      compiler/symsym.pas
  44. 28 4
      compiler/symtable.pas
  45. 67 0
      compiler/systems/i_embed.pas
  46. 44 4
      compiler/systems/t_embed.pas
  47. 1 1
      compiler/x86/x86ins.dat
  48. 1 1
      compiler/x86_64/x8664tab.inc
  49. 50 0
      packages/fcl-base/src/base64.pp
  50. 1 0
      packages/fcl-base/src/win/fileinfo.pp
  51. 6 2
      packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp
  52. 8 8
      packages/fcl-image/src/fpcanvas.inc
  53. 13 0
      packages/fcl-process/src/process.pp
  54. 2 0
      packages/fcl-process/src/unix/process.inc
  55. 1 0
      packages/fcl-res/src/elfwriter.pp
  56. 5 0
      packages/fcl-web/src/base/fphtml.pp
  57. 35 2
      packages/fcl-web/src/base/webpage.pp
  58. 1 1
      packages/fcl-xml/src/xmlcfg.pp
  59. 1 1
      packages/fcl-xml/src/xmlread.pp
  60. 1 1
      packages/fftw/fpmake.pp
  61. 7 7
      packages/fpvectorial/examples/fpvc_mainform.lfm
  62. 1 5
      packages/fpvectorial/examples/fpvectorialconverter.lpr
  63. 623 0
      packages/fpvectorial/src/dxfvectorialreader.pas
  64. 146 1
      packages/fpvectorial/src/fpvectorial.pas
  65. 75 4
      packages/fpvectorial/src/fpvtocanvas.pas
  66. 1 72
      packages/hermes/Makefile
  67. 0 56
      packages/hermes/Makefile.fpc
  68. 9 51
      packages/hermes/src/i386/headi386.inc
  69. 4 19
      packages/hermes/src/i386/headmmx.inc
  70. 0 269
      packages/hermes/src/i386/mmx_clr.as
  71. 276 0
      packages/hermes/src/i386/mmx_clr.inc
  72. 0 67
      packages/hermes/src/i386/mmx_main.as
  73. 83 0
      packages/hermes/src/i386/mmx_main.inc
  74. 0 383
      packages/hermes/src/i386/mmxp2_32.as
  75. 391 0
      packages/hermes/src/i386/mmxp2_32.inc
  76. 0 163
      packages/hermes/src/i386/mmxp_32.as
  77. 168 0
      packages/hermes/src/i386/mmxp_32.inc
  78. 0 2059
      packages/hermes/src/i386/x8616lut.as
  79. 2088 0
      packages/hermes/src/i386/x8616lut.inc
  80. 0 297
      packages/hermes/src/i386/x86_clr.as
  81. 305 0
      packages/hermes/src/i386/x86_clr.inc
  82. 0 182
      packages/hermes/src/i386/x86_main.as
  83. 182 0
      packages/hermes/src/i386/x86_main.inc
  84. 0 1154
      packages/hermes/src/i386/x86p_16.as
  85. 1143 0
      packages/hermes/src/i386/x86p_16.inc
  86. 0 1043
      packages/hermes/src/i386/x86p_32.as
  87. 1041 0
      packages/hermes/src/i386/x86p_32.inc
  88. 0 120
      packages/hermes/src/i386/x86p_cpy.as
  89. 148 0
      packages/hermes/src/i386/x86p_cpy.inc
  90. 0 224
      packages/hermes/src/i386/x86p_i8.as
  91. 238 0
      packages/hermes/src/i386/x86p_i8.inc
  92. 0 114
      packages/hermes/src/i386/x86p_s32.as
  93. 140 0
      packages/hermes/src/i386/x86p_s32.inc
  94. 0 40
      packages/hermes/src/i386/x86pscpy.as
  95. 60 0
      packages/hermes/src/i386/x86pscpy.inc
  96. 63 63
      packages/libxml/Makefile
  97. 1 1
      packages/libxml/Makefile.fpc
  98. 3 0
      packages/libxml/fpmake.pp
  99. 51 1772
      packages/libxml/src/xmlxsd.pas
  100. 1768 0
      packages/libxml/src/xmlxsdparser.pas

+ 40 - 27
.gitattributes

@@ -2507,18 +2507,19 @@ packages/fpvectorial/examples/fpvectorialconverter.lpr svneol=native#text/plain
 packages/fpvectorial/examples/fpvwritetest.lpi svneol=native#text/plain
 packages/fpvectorial/examples/fpvwritetest.lpi svneol=native#text/plain
 packages/fpvectorial/examples/fpvwritetest.pas svneol=native#text/plain
 packages/fpvectorial/examples/fpvwritetest.pas svneol=native#text/plain
 packages/fpvectorial/fpmake.pp svneol=native#text/plain
 packages/fpvectorial/fpmake.pp svneol=native#text/plain
-packages/fpvectorial/src/avisocncgcodereader.pas svneol=native#text/plain
-packages/fpvectorial/src/avisocncgcodewriter.pas svneol=native#text/plain
-packages/fpvectorial/src/avisozlib.pas svneol=native#text/plain
-packages/fpvectorial/src/cdrvectorialreader.pas svneol=native#text/plain
-packages/fpvectorial/src/fpvectbuildunit.pas svneol=native#text/plain
-packages/fpvectorial/src/fpvectorial.pas svneol=native#text/plain
-packages/fpvectorial/src/fpvtocanvas.pas svneol=native#text/plain
-packages/fpvectorial/src/pdfvectorialreader.pas svneol=native#text/plain
-packages/fpvectorial/src/pdfvrlexico.pas svneol=native#text/plain
-packages/fpvectorial/src/pdfvrsemantico.pas svneol=native#text/plain
-packages/fpvectorial/src/pdfvrsintatico.pas svneol=native#text/plain
-packages/fpvectorial/src/svgvectorialwriter.pas svneol=native#text/plain
+packages/fpvectorial/src/avisocncgcodereader.pas svneol=native#text/pascal
+packages/fpvectorial/src/avisocncgcodewriter.pas svneol=native#text/pascal
+packages/fpvectorial/src/avisozlib.pas svneol=native#text/pascal
+packages/fpvectorial/src/cdrvectorialreader.pas svneol=native#text/pascal
+packages/fpvectorial/src/dxfvectorialreader.pas svneol=native#text/pascal
+packages/fpvectorial/src/fpvectbuildunit.pas svneol=native#text/pascal
+packages/fpvectorial/src/fpvectorial.pas svneol=native#text/pascal
+packages/fpvectorial/src/fpvtocanvas.pas svneol=native#text/pascal
+packages/fpvectorial/src/pdfvectorialreader.pas svneol=native#text/pascal
+packages/fpvectorial/src/pdfvrlexico.pas svneol=native#text/pascal
+packages/fpvectorial/src/pdfvrsemantico.pas svneol=native#text/pascal
+packages/fpvectorial/src/pdfvrsintatico.pas svneol=native#text/pascal
+packages/fpvectorial/src/svgvectorialwriter.pas svneol=native#text/pascal
 packages/fuse/Makefile svneol=native#text/plain
 packages/fuse/Makefile svneol=native#text/plain
 packages/fuse/Makefile.fpc svneol=native#text/plain
 packages/fuse/Makefile.fpc svneol=native#text/plain
 packages/fuse/fpmake_disabled.pp svneol=native#text/plain
 packages/fuse/fpmake_disabled.pp svneol=native#text/plain
@@ -3404,21 +3405,21 @@ packages/hermes/src/hermes_format.inc svneol=native#text/plain
 packages/hermes/src/hermes_list.inc svneol=native#text/plain
 packages/hermes/src/hermes_list.inc svneol=native#text/plain
 packages/hermes/src/hermes_palette.inc svneol=native#text/plain
 packages/hermes/src/hermes_palette.inc svneol=native#text/plain
 packages/hermes/src/hermes_utility.inc svneol=native#text/plain
 packages/hermes/src/hermes_utility.inc svneol=native#text/plain
-packages/hermes/src/i386/headi386.inc -text
-packages/hermes/src/i386/headmmx.inc -text
-packages/hermes/src/i386/mmx_clr.as -text
-packages/hermes/src/i386/mmx_main.as -text
-packages/hermes/src/i386/mmxp2_32.as -text
-packages/hermes/src/i386/mmxp_32.as -text
-packages/hermes/src/i386/x8616lut.as -text
-packages/hermes/src/i386/x86_clr.as -text
-packages/hermes/src/i386/x86_main.as -text
-packages/hermes/src/i386/x86p_16.as -text
-packages/hermes/src/i386/x86p_32.as -text
-packages/hermes/src/i386/x86p_cpy.as -text
-packages/hermes/src/i386/x86p_i8.as -text
-packages/hermes/src/i386/x86p_s32.as -text
-packages/hermes/src/i386/x86pscpy.as -text
+packages/hermes/src/i386/headi386.inc svneol=native#text/plain
+packages/hermes/src/i386/headmmx.inc svneol=native#text/plain
+packages/hermes/src/i386/mmx_clr.inc svneol=native#text/plain
+packages/hermes/src/i386/mmx_main.inc svneol=native#text/plain
+packages/hermes/src/i386/mmxp2_32.inc svneol=native#text/plain
+packages/hermes/src/i386/mmxp_32.inc svneol=native#text/plain
+packages/hermes/src/i386/x8616lut.inc svneol=native#text/plain
+packages/hermes/src/i386/x86_clr.inc svneol=native#text/plain
+packages/hermes/src/i386/x86_main.inc svneol=native#text/plain
+packages/hermes/src/i386/x86p_16.inc svneol=native#text/plain
+packages/hermes/src/i386/x86p_32.inc svneol=native#text/plain
+packages/hermes/src/i386/x86p_cpy.inc svneol=native#text/plain
+packages/hermes/src/i386/x86p_i8.inc svneol=native#text/plain
+packages/hermes/src/i386/x86p_s32.inc svneol=native#text/plain
+packages/hermes/src/i386/x86pscpy.inc svneol=native#text/plain
 packages/hermes/src/p_16.inc svneol=native#text/plain
 packages/hermes/src/p_16.inc svneol=native#text/plain
 packages/hermes/src/p_24.inc svneol=native#text/plain
 packages/hermes/src/p_24.inc svneol=native#text/plain
 packages/hermes/src/p_32.inc svneol=native#text/plain
 packages/hermes/src/p_32.inc svneol=native#text/plain
@@ -4442,6 +4443,7 @@ packages/libxml/src/xmlunicode.inc svneol=native#text/plain
 packages/libxml/src/xmlversion.inc svneol=native#text/plain
 packages/libxml/src/xmlversion.inc svneol=native#text/plain
 packages/libxml/src/xmlwriter.inc svneol=native#text/plain
 packages/libxml/src/xmlwriter.inc svneol=native#text/plain
 packages/libxml/src/xmlxsd.pas svneol=native#text/plain
 packages/libxml/src/xmlxsd.pas svneol=native#text/plain
+packages/libxml/src/xmlxsdparser.pas svneol=native#text/plain
 packages/libxml/src/xpath.inc svneol=native#text/plain
 packages/libxml/src/xpath.inc svneol=native#text/plain
 packages/libxml/src/xpathInternals.inc svneol=native#text/plain
 packages/libxml/src/xpathInternals.inc svneol=native#text/plain
 packages/libxml/src/xpointer.inc svneol=native#text/plain
 packages/libxml/src/xpointer.inc svneol=native#text/plain
@@ -7467,6 +7469,7 @@ rtl/qnx/signal.inc svneol=native#text/plain
 rtl/qnx/system.pp svneol=native#text/plain
 rtl/qnx/system.pp svneol=native#text/plain
 rtl/solaris/Makefile svneol=native#text/plain
 rtl/solaris/Makefile svneol=native#text/plain
 rtl/solaris/Makefile.fpc svneol=native#text/plain
 rtl/solaris/Makefile.fpc svneol=native#text/plain
+rtl/solaris/clocale.inc svneol=native#text/plain
 rtl/solaris/errno.inc svneol=native#text/plain
 rtl/solaris/errno.inc svneol=native#text/plain
 rtl/solaris/errnostr.inc svneol=native#text/plain
 rtl/solaris/errnostr.inc svneol=native#text/plain
 rtl/solaris/i386/sighnd.inc svneol=native#text/plain
 rtl/solaris/i386/sighnd.inc svneol=native#text/plain
@@ -9434,6 +9437,7 @@ tests/test/tforin21.pp svneol=native#text/pascal
 tests/test/tforin22.pp svneol=native#text/pascal
 tests/test/tforin22.pp svneol=native#text/pascal
 tests/test/tforin23.pp svneol=native#text/pascal
 tests/test/tforin23.pp svneol=native#text/pascal
 tests/test/tforin24.pp svneol=native#text/pascal
 tests/test/tforin24.pp svneol=native#text/pascal
+tests/test/tforin25.pp svneol=native#text/pascal
 tests/test/tforin3.pp svneol=native#text/pascal
 tests/test/tforin3.pp svneol=native#text/pascal
 tests/test/tforin4.pp svneol=native#text/pascal
 tests/test/tforin4.pp svneol=native#text/pascal
 tests/test/tforin5.pp svneol=native#text/pascal
 tests/test/tforin5.pp svneol=native#text/pascal
@@ -9477,6 +9481,7 @@ tests/test/tgeneric31.pp svneol=native#text/pascal
 tests/test/tgeneric32.pp svneol=native#text/pascal
 tests/test/tgeneric32.pp svneol=native#text/pascal
 tests/test/tgeneric33.pp svneol=native#text/pascal
 tests/test/tgeneric33.pp svneol=native#text/pascal
 tests/test/tgeneric34.pp svneol=native#text/pascal
 tests/test/tgeneric34.pp svneol=native#text/pascal
+tests/test/tgeneric35.pp svneol=native#text/pascal
 tests/test/tgeneric4.pp svneol=native#text/plain
 tests/test/tgeneric4.pp svneol=native#text/plain
 tests/test/tgeneric5.pp svneol=native#text/plain
 tests/test/tgeneric5.pp svneol=native#text/plain
 tests/test/tgeneric6.pp svneol=native#text/plain
 tests/test/tgeneric6.pp svneol=native#text/plain
@@ -9667,6 +9672,7 @@ tests/test/tobject8.pp svneol=native#text/plain
 tests/test/toperator1.pp svneol=native#text/plain
 tests/test/toperator1.pp svneol=native#text/plain
 tests/test/toperator10.pp svneol=native#text/pascal
 tests/test/toperator10.pp svneol=native#text/pascal
 tests/test/toperator11.pp svneol=native#text/pascal
 tests/test/toperator11.pp svneol=native#text/pascal
+tests/test/toperator12.pp svneol=native#text/pascal
 tests/test/toperator2.pp svneol=native#text/plain
 tests/test/toperator2.pp svneol=native#text/plain
 tests/test/toperator3.pp svneol=native#text/plain
 tests/test/toperator3.pp svneol=native#text/plain
 tests/test/toperator4.pp svneol=native#text/plain
 tests/test/toperator4.pp svneol=native#text/plain
@@ -10019,6 +10025,7 @@ tests/test/units/sysutils/tfile1.pp svneol=native#text/plain
 tests/test/units/sysutils/tfile2.pp svneol=native#text/plain
 tests/test/units/sysutils/tfile2.pp svneol=native#text/plain
 tests/test/units/sysutils/tfilename.pp svneol=native#text/plain
 tests/test/units/sysutils/tfilename.pp svneol=native#text/plain
 tests/test/units/sysutils/tfloattostr.pp svneol=native#text/plain
 tests/test/units/sysutils/tfloattostr.pp svneol=native#text/plain
+tests/test/units/sysutils/tformat.pp svneol=native#text/plain
 tests/test/units/sysutils/tlocale.pp svneol=native#text/plain
 tests/test/units/sysutils/tlocale.pp svneol=native#text/plain
 tests/test/units/sysutils/trwsync.pp svneol=native#text/plain
 tests/test/units/sysutils/trwsync.pp svneol=native#text/plain
 tests/test/units/sysutils/tsscanf.pp svneol=native#text/plain
 tests/test/units/sysutils/tsscanf.pp svneol=native#text/plain
@@ -10197,6 +10204,7 @@ tests/webtbf/tw17646a.pp svneol=native#text/plain
 tests/webtbf/tw1782.pp svneol=native#text/plain
 tests/webtbf/tw1782.pp svneol=native#text/plain
 tests/webtbf/tw18096.pp svneol=native#text/pascal
 tests/webtbf/tw18096.pp svneol=native#text/pascal
 tests/webtbf/tw18096c.pp svneol=native#text/pascal
 tests/webtbf/tw18096c.pp svneol=native#text/pascal
+tests/webtbf/tw18267.pp svneol=native#text/plain
 tests/webtbf/tw1827.pp svneol=native#text/plain
 tests/webtbf/tw1827.pp svneol=native#text/plain
 tests/webtbf/tw1830.pp svneol=native#text/plain
 tests/webtbf/tw1830.pp svneol=native#text/plain
 tests/webtbf/tw1842.pp svneol=native#text/plain
 tests/webtbf/tw1842.pp svneol=native#text/plain
@@ -11004,9 +11012,14 @@ tests/webtbs/tw1820.pp svneol=native#text/plain
 tests/webtbs/tw18222.pp svneol=native#text/pascal
 tests/webtbs/tw18222.pp svneol=native#text/pascal
 tests/webtbs/tw1825.pp svneol=native#text/plain
 tests/webtbs/tw1825.pp svneol=native#text/plain
 tests/webtbs/tw18266.pp svneol=native#text/plain
 tests/webtbs/tw18266.pp svneol=native#text/plain
+tests/webtbs/tw18334.pp svneol=native#text/plain
+tests/webtbs/tw18443.pp svneol=native#text/pascal
 tests/webtbs/tw1850.pp svneol=native#text/plain
 tests/webtbs/tw1850.pp svneol=native#text/plain
 tests/webtbs/tw1851.pp svneol=native#text/plain
 tests/webtbs/tw1851.pp svneol=native#text/plain
+tests/webtbs/tw18512.pp svneol=native#text/pascal
 tests/webtbs/tw1856.pp svneol=native#text/plain
 tests/webtbs/tw1856.pp svneol=native#text/plain
+tests/webtbs/tw18567 svneol=native#text/pascal
+tests/webtbs/tw18610.pp svneol=native#text/pascal
 tests/webtbs/tw1862.pp svneol=native#text/plain
 tests/webtbs/tw1862.pp svneol=native#text/plain
 tests/webtbs/tw1863.pp svneol=native#text/plain
 tests/webtbs/tw1863.pp svneol=native#text/plain
 tests/webtbs/tw1867.pp svneol=native#text/plain
 tests/webtbs/tw1867.pp svneol=native#text/plain

+ 3 - 1
compiler/aasmtai.pas

@@ -179,6 +179,7 @@ interface
        ,top_regset
        ,top_regset
        ,top_shifterop
        ,top_shifterop
        ,top_conditioncode
        ,top_conditioncode
+       ,top_modeflags
 {$endif arm}
 {$endif arm}
 {$ifdef m68k}
 {$ifdef m68k}
        { m68k only }
        { m68k only }
@@ -214,7 +215,8 @@ interface
       {$ifdef arm}
       {$ifdef arm}
           top_regset : (regset:^tcpuregisterset; regtyp: tregistertype; subreg: tsubregister);
           top_regset : (regset:^tcpuregisterset; regtyp: tregistertype; subreg: tsubregister);
           top_shifterop : (shifterop : pshifterop);
           top_shifterop : (shifterop : pshifterop);
-          top_conditioncode: (cc: TAsmCond);
+          top_conditioncode : (cc : TAsmCond);
+          top_modeflags : (modeflags : tcpumodeflags);
       {$endif arm}
       {$endif arm}
       {$ifdef m68k}
       {$ifdef m68k}
           top_regset : (regset:^tcpuregisterset);
           top_regset : (regset:^tcpuregisterset);

+ 31 - 0
compiler/arm/aasmcpu.pas

@@ -163,6 +163,7 @@ uses
          procedure loadshifterop(opidx:longint;const so:tshifterop);
          procedure loadshifterop(opidx:longint;const so:tshifterop);
          procedure loadregset(opidx:longint; regsetregtype: tregistertype; regsetsubregtype: tsubregister; const s:tcpuregisterset);
          procedure loadregset(opidx:longint; regsetregtype: tregistertype; regsetsubregtype: tsubregister; const s:tcpuregisterset);
          procedure loadconditioncode(opidx:longint;const cond:tasmcond);
          procedure loadconditioncode(opidx:longint;const cond:tasmcond);
+         procedure loadmodeflags(opidx:longint;const flags:tcpumodeflags);
          constructor op_none(op : tasmop);
          constructor op_none(op : tasmop);
 
 
          constructor op_reg(op : tasmop;_op1 : tregister);
          constructor op_reg(op : tasmop;_op1 : tregister);
@@ -187,6 +188,10 @@ uses
          { ITxxx }
          { ITxxx }
          constructor op_cond(op: tasmop; cond: tasmcond);
          constructor op_cond(op: tasmop; cond: tasmcond);
 
 
+         { CPSxx }
+         constructor op_modeflags(op: tasmop; flags: tcpumodeflags);
+         constructor op_modeflags_const(op: tasmop; flags: tcpumodeflags; a: aint);
+
          { *M*LL }
          { *M*LL }
          constructor op_reg_reg_reg_reg(op : tasmop;_op1,_op2,_op3,_op4 : tregister);
          constructor op_reg_reg_reg_reg(op : tasmop;_op1,_op2,_op3,_op4 : tregister);
 
 
@@ -328,6 +333,17 @@ implementation
          end;
          end;
       end;
       end;
 
 
+    procedure taicpu.loadmodeflags(opidx: longint; const flags: tcpumodeflags);
+      begin
+        allocate_oper(opidx+1);
+        with oper[opidx]^ do
+         begin
+           if typ<>top_modeflags then
+             clearop(opidx);
+           modeflags:=flags;
+           typ:=top_modeflags;
+         end;
+      end;
 
 
 {*****************************************************************************
 {*****************************************************************************
                                  taicpu Constructors
                                  taicpu Constructors
@@ -448,6 +464,21 @@ implementation
         condition := cond;
         condition := cond;
       end;
       end;
 
 
+    constructor taicpu.op_modeflags(op: tasmop; flags: tcpumodeflags);
+      begin
+        inherited create(op);
+        ops := 1;
+        loadmodeflags(0,flags);
+      end;
+
+    constructor taicpu.op_modeflags_const(op: tasmop; flags: tcpumodeflags; a: aint);
+      begin
+        inherited create(op);
+        ops := 2;
+        loadmodeflags(0,flags);
+        loadconst(1,a);
+      end;
+
 
 
      constructor taicpu.op_reg_reg_sym_ofs(op : tasmop;_op1,_op2 : tregister; _op3: tasmsymbol;_op3ofs: longint);
      constructor taicpu.op_reg_reg_sym_ofs(op : tasmop;_op1,_op2 : tregister; _op3: tasmsymbol;_op3ofs: longint);
        begin
        begin

+ 7 - 0
compiler/arm/agarmgas.pas

@@ -204,6 +204,13 @@ unit agarmgas;
             end;
             end;
           top_conditioncode:
           top_conditioncode:
             getopstr:=cond2str[o.cc];
             getopstr:=cond2str[o.cc];
+          top_modeflags:
+            begin
+              getopstr:='';
+              if mfA in o.modeflags then getopstr:=getopstr+'a';
+              if mfI in o.modeflags then getopstr:=getopstr+'i';
+              if mfF in o.modeflags then getopstr:=getopstr+'f';
+            end;
           top_ref:
           top_ref:
             if o.ref^.refaddr=addr_full then
             if o.ref^.refaddr=addr_full then
               begin
               begin

+ 3 - 0
compiler/arm/armatt.inc

@@ -23,6 +23,9 @@
 'clz',
 'clz',
 'cnf',
 'cnf',
 'cos',
 'cos',
+'cps',
+'cpsid',
+'cpsie',
 'dvf',
 'dvf',
 'eor',
 'eor',
 'exp',
 'exp',

+ 3 - 0
compiler/arm/armatts.inc

@@ -199,5 +199,8 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
 attsufNONE
 attsufNONE
 );
 );

+ 4 - 0
compiler/arm/armins.dat

@@ -162,6 +162,10 @@ reg32,reg32              \x27\x01\x01                   ARM7
 
 
 [COScc]
 [COScc]
 
 
+[CPS]
+[CPSID]
+[CPSIE]
+
 [DVFcc]
 [DVFcc]
 
 
 [EORcc]
 [EORcc]

+ 3 - 0
compiler/arm/armop.inc

@@ -23,6 +23,9 @@ A_CMP,
 A_CLZ,
 A_CLZ,
 A_CNF,
 A_CNF,
 A_COS,
 A_COS,
+A_CPS,
+A_CPSID,
+A_CPSIE,
 A_DVF,
 A_DVF,
 A_EOR,
 A_EOR,
 A_EXP,
 A_EXP,

+ 3 - 0
compiler/arm/cpubase.pas

@@ -203,6 +203,9 @@ unit cpubase;
         shiftimm : byte;
         shiftimm : byte;
       end;
       end;
 
 
+      tcpumodeflag = (mfA, mfI, mfF);
+      tcpumodeflags = set of tcpumodeflag;
+
 {*****************************************************************************
 {*****************************************************************************
                                  Constants
                                  Constants
 *****************************************************************************}
 *****************************************************************************}

+ 40 - 3
compiler/arm/raarmgas.pas

@@ -672,6 +672,38 @@ Unit raarmgas;
               end;
               end;
           end;
           end;
 
 
+
+        function is_modeflag(hs : string): boolean;
+          var
+            i: longint;
+            flags: tcpumodeflags;
+          begin
+            is_modeflag := false;
+
+            flags:=[];
+            hs:=lower(hs);
+
+            if (actopcode in [A_CPSID,A_CPSIE]) and (length(hs) >= 1) then
+              begin
+                for i:=1 to length(hs) do
+                  begin
+                    case hs[i] of
+                      'a':
+                        Include(flags,mfA);
+                      'f':
+                        Include(flags,mfF);
+                      'i':
+                        Include(flags,mfI);
+                    else
+                      exit;
+                    end;
+                  end;
+                oper.opr.typ := OPR_MODEFLAGS;
+                oper.opr.flags := flags;
+                exit(true);
+              end;
+          end;
+
       var
       var
         tempreg : tregister;
         tempreg : tregister;
         ireg : tsuperregister;
         ireg : tsuperregister;
@@ -716,11 +748,16 @@ Unit raarmgas;
           *)
           *)
           AS_ID: { A constant expression, or a Variable ref.  }
           AS_ID: { A constant expression, or a Variable ref.  }
             Begin
             Begin
+              if is_modeflag(actasmpattern) then
+                begin
+                  consume(AS_ID);
+                end
+              else
               { Condition code? }
               { Condition code? }
               if is_conditioncode(actasmpattern) then
               if is_conditioncode(actasmpattern) then
-              begin
-                consume(AS_ID);
-              end
+                begin
+                  consume(AS_ID);
+                end
               else
               else
               { Local Label ? }
               { Local Label ? }
               if is_locallabel(actasmpattern) then
               if is_locallabel(actasmpattern) then

+ 4 - 4
compiler/cgobj.pas

@@ -3473,7 +3473,7 @@ implementation
          cgpara2.init;
          cgpara2.init;
          paramanager.getintparaloc(pocall_default,1,cgpara1);
          paramanager.getintparaloc(pocall_default,1,cgpara1);
          paramanager.getintparaloc(pocall_default,2,cgpara2);
          paramanager.getintparaloc(pocall_default,2,cgpara2);
-         if is_interfacecom(t) then
+         if is_interfacecom_or_dispinterface(t) then
            incrfunc:='FPC_INTF_INCR_REF'
            incrfunc:='FPC_INTF_INCR_REF'
          else if is_ansistring(t) then
          else if is_ansistring(t) then
            incrfunc:='FPC_ANSISTR_INCR_REF'
            incrfunc:='FPC_ANSISTR_INCR_REF'
@@ -3529,7 +3529,7 @@ implementation
         paramanager.getintparaloc(pocall_default,1,cgpara1);
         paramanager.getintparaloc(pocall_default,1,cgpara1);
         paramanager.getintparaloc(pocall_default,2,cgpara2);
         paramanager.getintparaloc(pocall_default,2,cgpara2);
         needrtti:=false;
         needrtti:=false;
-        if is_interfacecom(t) then
+        if is_interfacecom_or_dispinterface(t) then
           decrfunc:='FPC_INTF_DECR_REF'
           decrfunc:='FPC_INTF_DECR_REF'
         else if is_ansistring(t) then
         else if is_ansistring(t) then
           decrfunc:='FPC_ANSISTR_DECR_REF'
           decrfunc:='FPC_ANSISTR_DECR_REF'
@@ -3593,7 +3593,7 @@ implementation
          if is_ansistring(t) or
          if is_ansistring(t) or
             is_widestring(t) or
             is_widestring(t) or
             is_unicodestring(t) or
             is_unicodestring(t) or
-            is_interfacecom(t) or
+            is_interfacecom_or_dispinterface(t) or
             is_dynamic_array(t) then
             is_dynamic_array(t) then
            a_load_const_ref(list,OS_ADDR,0,ref)
            a_load_const_ref(list,OS_ADDR,0,ref)
          else
          else
@@ -3624,7 +3624,7 @@ implementation
          if is_ansistring(t) or
          if is_ansistring(t) or
             is_widestring(t) or
             is_widestring(t) or
             is_unicodestring(t) or
             is_unicodestring(t) or
-            is_interfacecom(t) then
+            is_interfacecom_or_dispinterface(t) then
             begin
             begin
               g_decrrefcount(list,t,ref);
               g_decrrefcount(list,t,ref);
               a_load_const_ref(list,OS_ADDR,0,ref);
               a_load_const_ref(list,OS_ADDR,0,ref);

+ 118 - 90
compiler/dbgdwarf.pas

@@ -351,6 +351,7 @@ interface
         procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
         procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
         { used for fields and properties mapped to fields }
         { used for fields and properties mapped to fields }
         procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
         procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
+        procedure appendsym_const_member(list:TAsmList;sym:tconstsym;ismember:boolean);
 
 
         procedure beforeappendsym(list:TAsmList;sym:tsym);override;
         procedure beforeappendsym(list:TAsmList;sym:tsym);override;
         procedure appendsym_staticvar(list:TAsmList;sym:tstaticvarsym);override;
         procedure appendsym_staticvar(list:TAsmList;sym:tstaticvarsym);override;
@@ -387,6 +388,7 @@ interface
       private
       private
       protected
       protected
         procedure appenddef_set_intern(list:TAsmList;def:tsetdef; force_tag_set: boolean);
         procedure appenddef_set_intern(list:TAsmList;def:tsetdef; force_tag_set: boolean);
+        procedure append_object_struct(def: tobjectdef; const createlabel: boolean; const objectname: PShortString);
 
 
         procedure appenddef_file(list:TAsmList;def:tfiledef); override;
         procedure appenddef_file(list:TAsmList;def:tfiledef); override;
         procedure appenddef_formal(list:TAsmList;def:tformaldef); override;
         procedure appenddef_formal(list:TAsmList;def:tformaldef); override;
@@ -605,6 +607,9 @@ implementation
         DW_OP_push_object_address := $97,DW_OP_call2 := $98,
         DW_OP_push_object_address := $97,DW_OP_call2 := $98,
         DW_OP_call4 := $99,DW_OP_call_ref := $9a,
         DW_OP_call4 := $99,DW_OP_call_ref := $9a,
 
 
+        { DWARF 4 extensions.   }
+        DW_OP_implicit_value := $9e, DW_OP_stack_value := $9f,
+
         { GNU extensions.   }
         { GNU extensions.   }
         DW_OP_GNU_push_tls_address := $e0,
         DW_OP_GNU_push_tls_address := $e0,
 
 
@@ -1019,6 +1024,8 @@ implementation
             appendsym_fieldvar(TAsmList(arg),tfieldvarsym(p));
             appendsym_fieldvar(TAsmList(arg),tfieldvarsym(p));
           propertysym:
           propertysym:
             appendsym_property(TAsmList(arg),tpropertysym(p));
             appendsym_property(TAsmList(arg),tpropertysym(p));
+          constsym:
+            appendsym_const_member(TAsmList(arg),tconstsym(p),true);
         end;
         end;
       end;
       end;
 
 
@@ -2505,8 +2512,12 @@ implementation
         finish_entry;
         finish_entry;
       end;
       end;
 
 
-
     procedure TDebugInfoDwarf.appendsym_const(list:TAsmList;sym:tconstsym);
     procedure TDebugInfoDwarf.appendsym_const(list:TAsmList;sym:tconstsym);
+    begin
+      appendsym_const_member(list,sym,false);
+    end;
+
+    procedure TDebugInfoDwarf.appendsym_const_member(list:TAsmList;sym:tconstsym;ismember:boolean);
       var
       var
         i,
         i,
         size: aint;
         size: aint;
@@ -2520,9 +2531,20 @@ implementation
         if (sym.owner.symtabletype=parasymtable) then
         if (sym.owner.symtabletype=parasymtable) then
           exit;
           exit;
 
 
-        append_entry(DW_TAG_variable,false,[
-          DW_AT_name,DW_FORM_string,symname(sym)+#0
-          ]);
+        if ismember then
+          append_entry(DW_TAG_member,false,[
+            DW_AT_name,DW_FORM_string,symname(sym)+#0,
+          { The DW_AT_declaration tag is invalid according to the DWARF specifications.
+            But gcc adds this to static const members and gdb checks
+            for this flag. So we have to set it also.
+          }
+            DW_AT_declaration,DW_FORM_flag,true,
+            DW_AT_external,DW_FORM_flag,true
+            ])
+        else
+          append_entry(DW_TAG_variable,false,[
+            DW_AT_name,DW_FORM_string,symname(sym)+#0
+            ]);
         { for string constants, constdef isn't set because they have no real type }
         { for string constants, constdef isn't set because they have no real type }
         case sym.consttyp of
         case sym.consttyp of
           conststring:
           conststring:
@@ -3392,103 +3414,103 @@ implementation
         finish_entry;
         finish_entry;
       end;
       end;
 
 
-    procedure TDebugInfoDwarf2.appenddef_object(list:TAsmList;def: tobjectdef);
-      procedure doappend;
-        begin
-          { Objective-C class: same as regular class, except for
-              a) Apple-specific tag that identifies it as an Objective-C class
-              b) use extname^ instead of objname
-          }
-          if (def.objecttype=odt_objcclass) then
-            append_entry(DW_TAG_structure_type,true,[
-              DW_AT_name,DW_FORM_string,def.objextname^+#0,
-              DW_AT_byte_size,DW_FORM_udata,tobjectsymtable(def.symtable).datasize,
-              DW_AT_APPLE_runtime_class,DW_FORM_data1,DW_LANG_ObjC
-              ])
-          else if assigned(def.objname) then
-            append_entry(DW_TAG_structure_type,true,[
-              DW_AT_name,DW_FORM_string,def.objname^+#0,
-              DW_AT_byte_size,DW_FORM_udata,tobjectsymtable(def.symtable).datasize
-              ])
-          else
-            append_entry(DW_TAG_structure_type,true,[
-              DW_AT_byte_size,DW_FORM_udata,tobjectsymtable(def.symtable).datasize
-              ]);
-          finish_entry;
-          if assigned(def.childof) then
-            begin
-              append_entry(DW_TAG_inheritance,false,[
-                DW_AT_accessibility,DW_FORM_data1,DW_ACCESS_public,
-                DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
-              ]);
-              current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
-              current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
-              if (def.childof.dbg_state=dbg_state_unused) then
-                def.childof.dbg_state:=dbg_state_used;
-              if is_implicit_pointer_object_type(def) then
-                append_labelentry_ref(DW_AT_type,def_dwarf_class_struct_lab(def.childof))
-              else
-                append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.childof));
-              finish_entry;
-            end;
-          if (oo_has_vmt in def.objectoptions) and
-             (not assigned(def.childof) or
-              not(oo_has_vmt in def.childof.objectoptions)) then
-            begin
-              { vmt field }
-              append_entry(DW_TAG_member,false,[
-                  DW_AT_artificial,DW_FORM_flag,true,
-                  DW_AT_name,DW_FORM_string,'_vptr$'+def.objname^+#0,
-                  DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(def.vmt_offset)
-              ]);
-              current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
-              current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(def.vmt_offset));
-              { should be changed into a pointer to a function returning an }
-              { int and with TAG_unspecified_parameters                     }
-              if (voidpointertype.dbg_state=dbg_state_unused) then
-                voidpointertype.dbg_state:=dbg_state_used;
-              append_labelentry_ref(DW_AT_type,def_dwarf_lab(voidpointertype));
-              finish_entry;
-            end;
+    procedure TDebugInfoDwarf2.append_object_struct(def: tobjectdef; const createlabel: boolean; const objectname: PShortString);
+      begin
+        if createlabel then
+          begin
+            if not(tf_dwarf_only_local_labels in target_info.flags) then
+              current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create_global(def_dwarf_class_struct_lab(def),0))
+            else
+              current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(def_dwarf_class_struct_lab(def),0));
+          end;
+        if assigned(objectname) then
+          append_entry(DW_TAG_structure_type,true,[
+            DW_AT_name,DW_FORM_string,objectname^+#0,
+            DW_AT_byte_size,DW_FORM_udata,tobjectsymtable(def.symtable).datasize
+            ])
+        else
+          append_entry(DW_TAG_structure_type,true,[
+            DW_AT_byte_size,DW_FORM_udata,tobjectsymtable(def.symtable).datasize
+            ]);
+        { Apple-specific tag that identifies it as an Objective-C class }
+        if (def.objecttype=odt_objcclass) then
+          append_attribute(DW_AT_APPLE_runtime_class,DW_FORM_data1,[DW_LANG_ObjC]);
+
+        finish_entry;
+        if assigned(def.childof) then
+          begin
+            append_entry(DW_TAG_inheritance,false,[
+              DW_AT_accessibility,DW_FORM_data1,DW_ACCESS_public,
+              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
+            ]);
+            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
+            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
+            if (def.childof.dbg_state=dbg_state_unused) then
+              def.childof.dbg_state:=dbg_state_used;
+            if is_implicit_pointer_object_type(def) then
+              append_labelentry_ref(DW_AT_type,def_dwarf_class_struct_lab(def.childof))
+            else
+              append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.childof));
+            finish_entry;
+          end;
+        if (oo_has_vmt in def.objectoptions) and
+           (not assigned(def.childof) or
+            not(oo_has_vmt in def.childof.objectoptions)) then
+          begin
+            { vmt field }
+            append_entry(DW_TAG_member,false,[
+                DW_AT_artificial,DW_FORM_flag,true,
+                DW_AT_name,DW_FORM_string,'_vptr$'+def.objname^+#0,
+                DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(def.vmt_offset)
+            ]);
+            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
+            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(def.vmt_offset));
+            { should be changed into a pointer to a function returning an }
+            { int and with TAG_unspecified_parameters                     }
+            if (voidpointertype.dbg_state=dbg_state_unused) then
+              voidpointertype.dbg_state:=dbg_state_used;
+            append_labelentry_ref(DW_AT_type,def_dwarf_lab(voidpointertype));
+            finish_entry;
+          end;
+
+        def.symtable.symList.ForEachCall(@enum_membersyms_callback,nil);
+        { Write the methods in the scope of the class/object, except for Objective-C.  }
+        if is_objc_class_or_protocol(def) then
+          finish_children;
+        { don't write procdefs of externally defined classes, gcc doesn't
+          either (info is probably gotten from ObjC runtime)  }
+        if not(oo_is_external in def.objectoptions) then
+          write_symtable_procdefs(current_asmdata.asmlists[al_dwarf_info],def.symtable);
+        if not is_objc_class_or_protocol(def) then
+          finish_children;
+      end;
 
 
-          def.symtable.symList.ForEachCall(@enum_membersyms_callback,nil);
-          { Write the methods in the scope of the class/object, except for Objective-C.  }
-          if is_objc_class_or_protocol(def) then
-            finish_children;
-          { don't write procdefs of externally defined classes, gcc doesn't
-            either (info is probably gotten from ObjC runtime)  }
-          if not(oo_is_external in def.objectoptions) then
-            write_symtable_procdefs(current_asmdata.asmlists[al_dwarf_info],def.symtable);
-          if not is_objc_class_or_protocol(def) then
-            finish_children;
-        end;
 
 
+    procedure TDebugInfoDwarf2.appenddef_object(list:TAsmList;def: tobjectdef);
 
 
       begin
       begin
         case def.objecttype of
         case def.objecttype of
           odt_cppclass,
           odt_cppclass,
           odt_object:
           odt_object:
-            doappend;
+            append_object_struct(def,false,def.objname);
           odt_interfacecom,
           odt_interfacecom,
           odt_interfacecorba,
           odt_interfacecorba,
           odt_dispinterface,
           odt_dispinterface,
-          odt_class,
-          odt_objcclass:
+          odt_class:
             begin
             begin
-              if (def.objecttype<>odt_objcclass) then
-                begin
-                  { implicit pointer }
-                  append_entry(DW_TAG_pointer_type,false,[]);
-                  append_labelentry_ref(DW_AT_type,def_dwarf_class_struct_lab(def));
-                  finish_entry;
-                end;
+              { implicit pointer }
+              append_entry(DW_TAG_pointer_type,false,[]);
+              append_labelentry_ref(DW_AT_type,def_dwarf_class_struct_lab(def));
+              finish_entry;
 
 
-              if not(tf_dwarf_only_local_labels in target_info.flags) then
-                current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create_global(def_dwarf_class_struct_lab(def),0))
-              else
-                current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(def_dwarf_class_struct_lab(def),0));
-              doappend;
+              append_object_struct(def,true,def.objname);
             end;
             end;
+          odt_objcclass:
+            { Objective-C class: same as regular class, except for
+                a) Apple-specific tag that identifies it as an Objective-C class
+                b) use extname^ instead of objname
+            }
+            append_object_struct(def,true,def.objextname);
           odt_objcprotocol:
           odt_objcprotocol:
             begin
             begin
               append_entry(DW_TAG_pointer_type,false,[]);
               append_entry(DW_TAG_pointer_type,false,[]);
@@ -3882,8 +3904,14 @@ implementation
             end;
             end;
           odt_class:
           odt_class:
             begin
             begin
-              dostruct(DW_TAG_class_type);
-              doparent(false);
+              //dostruct(DW_TAG_class_type);
+              //doparent(false);
+              append_entry(DW_TAG_pointer_type,false,[]);
+              append_labelentry_ref(DW_AT_type,def_dwarf_class_struct_lab(def));
+              finish_entry;
+
+              append_object_struct(def,true,def.objrealname);
+              Exit;
             end;
             end;
         else
         else
           internalerror(200609171);
           internalerror(200609171);

+ 3 - 15
compiler/defcmp.pas

@@ -29,7 +29,7 @@ interface
        cclasses,
        cclasses,
        globtype,globals,
        globtype,globals,
        node,
        node,
-       symconst,symtype,symbase,symdef;
+       symconst,symtype,symdef;
 
 
      type
      type
        { if acp is cp_all the var const or nothing are considered equal }
        { if acp is cp_all the var const or nothing are considered equal }
@@ -1445,7 +1445,7 @@ implementation
              begin
              begin
                { interface -> guid }
                { interface -> guid }
                if (def_to=rec_tguid) and
                if (def_to=rec_tguid) and
-                  (is_interfacecom(def_from) or is_dispinterface(def_from)) then
+                  (is_interfacecom_or_dispinterface(def_from)) then
                 begin
                 begin
                   doconv:=tc_intf_2_guid;
                   doconv:=tc_intf_2_guid;
                   eq:=te_convert_l1;
                   eq:=te_convert_l1;
@@ -1487,19 +1487,7 @@ implementation
             )
             )
            ) then
            ) then
           begin
           begin
-            { search record/object symtable first for a sutable operator }
-            if def_from.typ in [recorddef,objectdef] then
-              symtablestack.push(tabstractrecorddef(def_from).symtable);
-            { if type conversion is explicit then search first for explicit 
-              operator overload and if not found then use implicit operator }
-            if cdo_explicit in cdoptions then
-              operatorpd:=search_assignment_operator(def_from,def_to,true)
-            else
-              operatorpd:=nil;
-            if operatorpd=nil then
-              operatorpd:=search_assignment_operator(def_from,def_to,false);
-            if def_from.typ in [recorddef,objectdef] then
-              symtablestack.pop(tabstractrecorddef(def_from).symtable);
+            operatorpd:=search_assignment_operator(def_from,def_to,cdo_explicit in cdoptions);
             if assigned(operatorpd) then
             if assigned(operatorpd) then
              eq:=te_convert_operator;
              eq:=te_convert_operator;
           end;
           end;

+ 10 - 2
compiler/globtype.pas

@@ -297,8 +297,16 @@ interface
        );
        );
 
 
        { currently parsed block type }
        { currently parsed block type }
-       tblock_type = (bt_none,
-         bt_general,bt_type,bt_const,bt_const_type,bt_var,bt_var_type,bt_except,bt_body
+       tblock_type = (
+         bt_none,        { not assigned                              }
+         bt_general,     { default                                   }
+         bt_type,        { type section                              }
+         bt_const,       { const section                             }
+         bt_const_type,  { const part of type. e.g.: ": Integer = 1" }
+         bt_var,         { variable declaration                      }
+         bt_var_type,    { type of variable                          }
+         bt_except,      { except section                            }
+         bt_body         { procedure body                            }
        );
        );
 
 
        { Temp types }
        { Temp types }

+ 27 - 10
compiler/htypechk.pas

@@ -426,22 +426,39 @@ implementation
                   begin
                   begin
                     eq:=compare_defs_ext(ld,pf.returndef,nothingn,conv,pd,[cdo_explicit]);
                     eq:=compare_defs_ext(ld,pf.returndef,nothingn,conv,pd,[cdo_explicit]);
                     result:=
                     result:=
-                      (eq=te_incompatible) and
-                      { don't allow overloading assigning to custom shortstring
-                        types, because we also don't want to differentiate based
-                        on different shortstring types (e.g.,
-                        "operator :=(const v: variant) res: shorstring" also
-                        has to work for assigning a variant to a string[80])
-                      }
-                      (not is_shortstring(pf.returndef) or
-                       (tstringdef(pf.returndef).len=255));
+                      (eq=te_exact) or
+                      (
+                        (eq=te_incompatible) and
+                        { don't allow overloading assigning to custom shortstring
+                          types, because we also don't want to differentiate based
+                          on different shortstring types (e.g.,
+                          "operator :=(const v: variant) res: shorstring" also
+                          has to work for assigning a variant to a string[80])
+                        }
+                        (not is_shortstring(pf.returndef) or
+                         (tstringdef(pf.returndef).len=255))
+                      );
                   end
                   end
                 else
                 else
                 { enumerator is a special case too }
                 { enumerator is a special case too }
                 if optoken=_OP_ENUMERATOR then
                 if optoken=_OP_ENUMERATOR then
                   begin
                   begin
                     result:=
                     result:=
-                      is_class_or_interface_or_object(pf.returndef);
+                      is_class_or_interface_or_object(pf.returndef) or
+                      is_record(pf.returndef);
+                    if result then
+                      begin
+                        if not assigned(tabstractrecorddef(pf.returndef).search_enumerator_move) then
+                          begin
+                            Message1(sym_e_no_enumerator_move, pf.returndef.typename);
+                            result:=false;
+                          end;
+                        if not assigned(tabstractrecorddef(pf.returndef).search_enumerator_current) then
+                          begin
+                            Message1(sym_e_no_enumerator_current,pf.returndef.typename);
+                            result:=false;
+                          end;
+                      end;
                   end
                   end
                 else
                 else
                   begin
                   begin

+ 3 - 0
compiler/i386/cputarg.pas

@@ -80,6 +80,9 @@ implementation
     {$ifndef NOTARGETNATIVENT}
     {$ifndef NOTARGETNATIVENT}
       ,t_nativent
       ,t_nativent
     {$endif}
     {$endif}
+    {$ifndef NOTARGETEMBEDDED}
+      ,t_embed
+    {$endif}
 
 
 {**************************************
 {**************************************
              Assemblers
              Assemblers

+ 1 - 1
compiler/i386/i386tab.inc

@@ -2706,7 +2706,7 @@
     opcode  : A_LJMP;
     opcode  : A_LJMP;
     ops     : 1;
     ops     : 1;
     optypes : (ot_regmem or ot_bits16 or ot_bits32 or ot_bits64,ot_none,ot_none);
     optypes : (ot_regmem or ot_bits16 or ot_bits32 or ot_bits64,ot_none,ot_none);
-    code    : #192#208#1#255#132;
+    code    : #192#208#1#255#133;
     flags   : if_8086
     flags   : if_8086
   ),
   ),
   (
   (

+ 5 - 6
compiler/msg/errore.msg

@@ -1078,7 +1078,7 @@ parser_e_protected_or_private_expected=03214_E_Protected or private expected
 parser_e_illegal_slice=03215_E_SLICE can't be used outside of parameter list
 parser_e_illegal_slice=03215_E_SLICE can't be used outside of parameter list
 % \var{slice} can be used only for arguments accepting an open array parameter.
 % \var{slice} can be used only for arguments accepting an open array parameter.
 parser_e_dispinterface_cant_have_parent=03216_E_A DISPINTERFACE can't have a parent class
 parser_e_dispinterface_cant_have_parent=03216_E_A DISPINTERFACE can't have a parent class
-% A DISPINTERFACE is a special type of interface which can't have a parent class.
+% A DISPINTERFACE is a special type of interface which can't have a parent class. Dispinterface always derive from IDispatch type.
 parser_e_dispinterface_needs_a_guid=03217_E_A DISPINTERFACE needs a guid
 parser_e_dispinterface_needs_a_guid=03217_E_A DISPINTERFACE needs a guid
 % A DISPINTERFACE always needs an interface identification (a GUID).
 % A DISPINTERFACE always needs an interface identification (a GUID).
 parser_w_overridden_methods_not_same_ret=03218_W_Overridden methods must have a related return type. This code may crash, it depends on a Delphi parser bug ("$2" is overridden by "$1" which has another return type)
 parser_w_overridden_methods_not_same_ret=03218_W_Overridden methods must have a related return type. This code may crash, it depends on a Delphi parser bug ("$2" is overridden by "$1" which has another return type)
@@ -1359,10 +1359,9 @@ parser_e_class_methods_only_static_in_records=03301_E_Class methods must be stat
 % Records have no inheritance and therefore non static class methods have no sence for them.
 % Records have no inheritance and therefore non static class methods have no sence for them.
 parser_e_no_constructor_in_records=03302_E_Constructors aren't allowed in records
 parser_e_no_constructor_in_records=03302_E_Constructors aren't allowed in records
 % Constructor declarations aren't allowed in records.
 % Constructor declarations aren't allowed in records.
-% \end{description}
-parser_e_at_least_one_argument_must_be_of_type=03303_E_At least one argument must be of type "$1"
-% It is required that at least one argument be of type of structure where this method is defined.
-% For example class operators must contain at least one argument of the structure where they are defined.
+parser_e_at_least_one_argument_must_be_of_type=03303_E_Either the result or at least one parameter must be of type "$1"
+% It is required that either the result of the routine or at least one of its parameters be of the specified type.
+% For example class operators either take an instance of the structured type in which they are defined, or they return one.
 parser_e_cant_use_type_parameters_here=03304_E_Type parameters may require initialization/finalization - can't be used in variant records
 parser_e_cant_use_type_parameters_here=03304_E_Type parameters may require initialization/finalization - can't be used in variant records
 % Type parameters may be specialized with types which (e.g. \var{ansistring}) need initialization/finalization
 % Type parameters may be specialized with types which (e.g. \var{ansistring}) need initialization/finalization
 % code which is implicitly generated by the compiler.
 % code which is implicitly generated by the compiler.
@@ -1377,7 +1376,7 @@ parser_e_classhelper_not_allowed_here=03307_E_A class helper is not allowed here
 parser_e_not_allowed_in_classhelper=03308_E_"$1" is not allowed in class helpers
 parser_e_not_allowed_in_classhelper=03308_E_"$1" is not allowed in class helpers
 % Some directives and specifiers like "virtual", "dynamic", "published" aren't
 % Some directives and specifiers like "virtual", "dynamic", "published" aren't
 % allowed inside class helpers in mode ObjFPC (they are ignored in mode Delphi).
 % allowed inside class helpers in mode ObjFPC (they are ignored in mode Delphi).
-#
+% \end{description}
 # Type Checking
 # Type Checking
 #
 #
 # 04095 is the last used one
 # 04095 is the last used one

+ 1 - 1
compiler/msgidx.inc

@@ -886,7 +886,7 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 58927;
+  MsgTxtSize = 58949;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
     24,88,309,99,84,54,111,22,202,63,
     24,88,309,99,84,54,111,22,202,63,

File diff suppressed because it is too large
+ 218 - 217
compiler/msgtxt.inc


+ 36 - 19
compiler/ncal.pas

@@ -220,8 +220,14 @@ interface
        end;
        end;
        tcallparanodeclass = class of tcallparanode;
        tcallparanodeclass = class of tcallparanode;
 
 
+       tdispcalltype = (
+         dct_method,
+         dct_propget,
+         dct_propput
+       );
+
     function reverseparameters(p: tcallparanode): tcallparanode;
     function reverseparameters(p: tcallparanode): tcallparanode;
-    function translate_disp_call(selfnode,parametersnode,putvalue : tnode;const methodname : ansistring;dispid : longint;resultdef : tdef) : tnode;
+    function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring;dispid : longint;resultdef : tdef) : tnode;
 
 
     var
     var
       ccallnode : tcallnodeclass = tcallnode;
       ccallnode : tcallnodeclass = tcallnode;
@@ -273,7 +279,7 @@ implementation
         reverseparameters:=hp1;
         reverseparameters:=hp1;
       end;
       end;
 
 
-    function translate_disp_call(selfnode,parametersnode,putvalue : tnode; const methodname : ansistring;dispid : longint;resultdef : tdef) : tnode;
+    function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring;dispid : longint;resultdef : tdef) : tnode;
       const
       const
         DISPATCH_METHOD = $1;
         DISPATCH_METHOD = $1;
         DISPATCH_PROPERTYGET = $2;
         DISPATCH_PROPERTYGET = $2;
@@ -281,8 +287,8 @@ implementation
         DISPATCH_PROPERTYPUTREF = $8;
         DISPATCH_PROPERTYPUTREF = $8;
         DISPATCH_CONSTRUCT = $4000;
         DISPATCH_CONSTRUCT = $4000;
 
 
-        calltypes: array[Boolean] of byte = (
-          DISPATCH_METHOD, DISPATCH_PROPERTYPUT
+        calltypes: array[tdispcalltype] of byte = (
+          DISPATCH_METHOD, DISPATCH_PROPERTYGET, DISPATCH_PROPERTYPUT
         );
         );
       var
       var
         statements : tstatementnode;
         statements : tstatementnode;
@@ -421,7 +427,7 @@ implementation
           calldescnode.appendbyte(restype);
           calldescnode.appendbyte(restype);
         end;
         end;
 
 
-        calldescnode.appendbyte(calltypes[assigned(putvalue)]);
+        calldescnode.appendbyte(calltypes[calltype]);
         calldescnode.appendbyte(paracount);
         calldescnode.appendbyte(paracount);
         calldescnode.appendbyte(namedparacount);
         calldescnode.appendbyte(namedparacount);
 
 
@@ -1172,20 +1178,24 @@ implementation
           callcleanupblock.derefimpl;
           callcleanupblock.derefimpl;
         if assigned(funcretnode) then
         if assigned(funcretnode) then
           funcretnode.derefimpl;
           funcretnode.derefimpl;
-        { Connect parasyms }
-        pt:=tcallparanode(left);
-        while assigned(pt) and
-              (cpf_varargs_para in pt.callparaflags) do
-          pt:=tcallparanode(pt.right);
-        for i:=procdefinition.paras.count-1 downto 0 do
+        { generic method has no procdefinition }
+        if assigned(procdefinition) then
           begin
           begin
-            if not assigned(pt) then
-              internalerror(200311077);
-            pt.parasym:=tparavarsym(procdefinition.paras[i]);
-            pt:=tcallparanode(pt.right);
+            { Connect parasyms }
+            pt:=tcallparanode(left);
+            while assigned(pt) and
+                  (cpf_varargs_para in pt.callparaflags) do
+              pt:=tcallparanode(pt.right);
+            for i:=procdefinition.paras.count-1 downto 0 do
+              begin
+                if not assigned(pt) then
+                  internalerror(200311077);
+                pt.parasym:=tparavarsym(procdefinition.paras[i]);
+                pt:=tcallparanode(pt.right);
+              end;
+            if assigned(pt) then
+              internalerror(200311078);
           end;
           end;
-        if assigned(pt) then
-          internalerror(200311078);
       end;
       end;
 
 
 
 
@@ -2591,6 +2601,7 @@ implementation
         is_const : boolean;
         is_const : boolean;
         statements : tstatementnode;
         statements : tstatementnode;
         converted_result_data : ttempcreatenode;
         converted_result_data : ttempcreatenode;
+        calltype: tdispcalltype;
       label
       label
         errorexit;
         errorexit;
       begin
       begin
@@ -2984,6 +2995,12 @@ implementation
          { dispinterface methode invoke? }
          { dispinterface methode invoke? }
          if assigned(methodpointer) and is_dispinterface(methodpointer.resultdef) then
          if assigned(methodpointer) and is_dispinterface(methodpointer.resultdef) then
            begin
            begin
+             case procdefinition.proctypeoption of
+               potype_propgetter: calltype:=dct_propget;
+               potype_propsetter: calltype:=dct_propput;
+             else
+               calltype:=dct_method;
+             end;
              { if the result is used, we've to insert a call to convert the type to be on the "safe side" }
              { if the result is used, we've to insert a call to convert the type to be on the "safe side" }
              if (cnf_return_value_used in callnodeflags) and not is_void(procdefinition.returndef) then
              if (cnf_return_value_used in callnodeflags) and not is_void(procdefinition.returndef) then
                begin
                begin
@@ -2991,13 +3008,13 @@ implementation
                  converted_result_data:=ctempcreatenode.create(procdefinition.returndef,sizeof(procdefinition.returndef),tt_persistent,true);
                  converted_result_data:=ctempcreatenode.create(procdefinition.returndef,sizeof(procdefinition.returndef),tt_persistent,true);
                  addstatement(statements,converted_result_data);
                  addstatement(statements,converted_result_data);
                  addstatement(statements,cassignmentnode.create(ctemprefnode.create(converted_result_data),
                  addstatement(statements,cassignmentnode.create(ctemprefnode.create(converted_result_data),
-                   ctypeconvnode.create_internal(translate_disp_call(methodpointer,parameters,nil,'',tprocdef(procdefinition).dispid,procdefinition.returndef),
+                   ctypeconvnode.create_internal(translate_disp_call(methodpointer,parameters,calltype,'',tprocdef(procdefinition).dispid,procdefinition.returndef),
                    procdefinition.returndef)));
                    procdefinition.returndef)));
                  addstatement(statements,ctempdeletenode.create_normal_temp(converted_result_data));
                  addstatement(statements,ctempdeletenode.create_normal_temp(converted_result_data));
                  addstatement(statements,ctemprefnode.create(converted_result_data));
                  addstatement(statements,ctemprefnode.create(converted_result_data));
                end
                end
              else
              else
-               result:=translate_disp_call(methodpointer,parameters,nil,'',tprocdef(procdefinition).dispid,voidtype);
+               result:=translate_disp_call(methodpointer,parameters,calltype,'',tprocdef(procdefinition).dispid,voidtype);
 
 
              { don't free reused nodes }
              { don't free reused nodes }
              methodpointer:=nil;
              methodpointer:=nil;

+ 1 - 3
compiler/ncginl.pas

@@ -640,9 +640,7 @@ implementation
     procedure tcginlinenode.second_assigned;
     procedure tcginlinenode.second_assigned;
       begin
       begin
         secondpass(tcallparanode(left).left);
         secondpass(tcallparanode(left).left);
-        { force left to be an OS_ADDR, since in case of method procvars }
-        { the size is 2*OS_ADDR (JM)                                    }
-        cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,OS_ADDR,OC_NE,0,tcallparanode(left).left.location,current_procinfo.CurrTrueLabel);
+        cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,def_cgsize(left.resultdef),OC_NE,0,tcallparanode(left).left.location,current_procinfo.CurrTrueLabel);
         cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
         cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
         location_reset(location,LOC_JUMP,OS_NO);
         location_reset(location,LOC_JUMP,OS_NO);
       end;
       end;

+ 47 - 57
compiler/ncgmem.pas

@@ -294,67 +294,57 @@ implementation
          { several object types must be dereferenced implicitly }
          { several object types must be dereferenced implicitly }
          if is_implicit_pointer_object_type(left.resultdef) then
          if is_implicit_pointer_object_type(left.resultdef) then
            begin
            begin
-             { the contents of a class are aligned to a sizeof(pointer) }
-             location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),sizeof(pint));
-             case left.location.loc of
-                LOC_CREGISTER,
-                LOC_REGISTER:
-                  begin
-                  {$ifdef cpu_uses_separate_address_registers}
-                    if getregtype(left.location.register)<>R_ADDRESSREGISTER then
+             if not is_managed_type(left.resultdef) then
+               begin
+                 { the contents of a class are aligned to a sizeof(pointer) }
+                 location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),sizeof(pint));
+                 case left.location.loc of
+                    LOC_CREGISTER,
+                    LOC_REGISTER:
                       begin
                       begin
-                        location.reference.base:=rg.getaddressregister(current_asmdata.CurrAsmList);
-                        cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,
-                          left.location.register,location.reference.base);
-                      end
+                      {$ifdef cpu_uses_separate_address_registers}
+                        if getregtype(left.location.register)<>R_ADDRESSREGISTER then
+                          begin
+                            location.reference.base:=rg.getaddressregister(current_asmdata.CurrAsmList);
+                            cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,
+                              left.location.register,location.reference.base);
+                          end
+                        else
+                      {$endif}
+                          location.reference.base := left.location.register;
+                      end;
+                    LOC_CREFERENCE,
+                    LOC_REFERENCE:
+                      begin
+                         location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
+                         cg.a_load_loc_reg(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference.base);
+                      end;
+                    LOC_CONSTANT:
+                      begin
+                        { can happen with @classtype(pointerconst).field }
+                        location.reference.offset:=left.location.value;
+                      end;
                     else
                     else
-                  {$endif}
-                      location.reference.base := left.location.register;
-                  end;
-                LOC_CREFERENCE,
-                LOC_REFERENCE:
-                  begin
-                     location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
-                     cg.a_load_loc_reg(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference.base);
-                  end;
-                LOC_CONSTANT:
+                      internalerror(2009092401);
+                 end;
+                 { implicit deferencing }
+                 if (cs_use_heaptrc in current_settings.globalswitches) and
+                    (cs_checkpointer in current_settings.localswitches) and
+                    not(cs_compilesystem in current_settings.moduleswitches) then
                   begin
                   begin
-                    { can happen with @classtype(pointerconst).field }
-                    location.reference.offset:=left.location.value;
+                    paramanager.getintparaloc(pocall_default,1,paraloc1);
+                    cg.a_load_reg_cgpara(current_asmdata.CurrAsmList, OS_ADDR,location.reference.base,paraloc1);
+                    paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
+                    cg.allocallcpuregisters(current_asmdata.CurrAsmList);
+                    cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CHECKPOINTER',false);
+                    cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
                   end;
                   end;
-                else
-                  internalerror(2009092401);
-             end;
-             { implicit deferencing }
-             if (cs_use_heaptrc in current_settings.globalswitches) and
-                (cs_checkpointer in current_settings.localswitches) and
-                not(cs_compilesystem in current_settings.moduleswitches) then
-              begin
-                paramanager.getintparaloc(pocall_default,1,paraloc1);
-                cg.a_load_reg_cgpara(current_asmdata.CurrAsmList, OS_ADDR,location.reference.base,paraloc1);
-                paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CHECKPOINTER',false);
-                cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-              end;
-           end
-         else if is_interfacecom(left.resultdef) then
-           begin
-             location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),sizeof(pint));
-             tg.GetTempTyped(current_asmdata.CurrAsmList,left.resultdef,tt_normal,location.reference);
-             cg.a_load_loc_ref(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference);
-             { implicit deferencing also for interfaces }
-             if (cs_use_heaptrc in current_settings.globalswitches) and
-                (cs_checkpointer in current_settings.localswitches) and
-                not(cs_compilesystem in current_settings.moduleswitches) then
-              begin
-                paramanager.getintparaloc(pocall_default,1,paraloc1);
-                cg.a_load_reg_cgpara(current_asmdata.CurrAsmList, OS_ADDR,location.reference.base,paraloc1);
-                paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CHECKPOINTER',false);
-                cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-              end;
+               end
+             else
+               { reference-counted implicit pointer object types don't have
+                 fields -> cannot be subscripted (calls are handled via call
+                 nodes) }
+               internalerror(2011011901);
            end
            end
          else
          else
            begin
            begin

+ 9 - 4
compiler/ncgutil.pas

@@ -101,7 +101,7 @@ interface
     procedure gen_load_return_value(list:TAsmList);
     procedure gen_load_return_value(list:TAsmList);
 
 
     procedure gen_external_stub(list:TAsmList;pd:tprocdef;const externalname:string);
     procedure gen_external_stub(list:TAsmList;pd:tprocdef;const externalname:string);
-    procedure gen_intf_wrappers(list:TAsmList;st:TSymtable);
+    procedure gen_intf_wrappers(list:TAsmList;st:TSymtable;nested:boolean);
     procedure gen_load_vmt_register(list:TAsmList;objdef:tobjectdef;selfloc:tlocation;var vmtreg:tregister);
     procedure gen_load_vmt_register(list:TAsmList;objdef:tobjectdef;selfloc:tlocation;var vmtreg:tregister);
 
 
     procedure get_used_regvars(n: tnode; var rv: tusedregvars);
     procedure get_used_regvars(n: tnode; var rv: tusedregvars);
@@ -2963,19 +2963,24 @@ implementation
       end;
       end;
 
 
 
 
-    procedure gen_intf_wrappers(list:TAsmList;st:TSymtable);
+    procedure gen_intf_wrappers(list:TAsmList;st:TSymtable;nested:boolean);
       var
       var
         i   : longint;
         i   : longint;
         def : tdef;
         def : tdef;
       begin
       begin
-        create_codegen;
+        if not nested then
+          create_codegen;
         for i:=0 to st.DefList.Count-1 do
         for i:=0 to st.DefList.Count-1 do
           begin
           begin
             def:=tdef(st.DefList[i]);
             def:=tdef(st.DefList[i]);
+            { if def can contain nested types then handle it symtable }
+            if def.typ in [objectdef,recorddef] then
+              gen_intf_wrappers(list,tabstractrecorddef(def).symtable,true);
             if is_class(def) then
             if is_class(def) then
               gen_intf_wrapper(list,tobjectdef(def));
               gen_intf_wrapper(list,tobjectdef(def));
           end;
           end;
-        destroy_codegen;
+        if not nested then
+          destroy_codegen;
       end;
       end;
 
 
 
 

+ 1 - 0
compiler/ncnv.pas

@@ -1962,6 +1962,7 @@ implementation
                                 (
                                 (
                                  not(is_open_array(left.resultdef)) and
                                  not(is_open_array(left.resultdef)) and
                                  not(is_array_constructor(left.resultdef)) and
                                  not(is_array_constructor(left.resultdef)) and
+                                 not(is_array_of_const(left.resultdef)) and
                                  (left.resultdef.size=resultdef.size) and
                                  (left.resultdef.size=resultdef.size) and
                                  { disallow casts of const nodes }
                                  { disallow casts of const nodes }
                                  (not is_constnode(left) or
                                  (not is_constnode(left) or

+ 10 - 7
compiler/nflw.pas

@@ -861,22 +861,25 @@ implementation
                 // search for operator first
                 // search for operator first
                 pd:=search_enumerator_operator(expr.resultdef, hloopvar.resultdef);
                 pd:=search_enumerator_operator(expr.resultdef, hloopvar.resultdef);
                 // if there is no operator then search for class/object enumerator method
                 // if there is no operator then search for class/object enumerator method
-                if (pd=nil) and (expr.resultdef.typ=objectdef) then
+                if (pd=nil) and (expr.resultdef.typ in [objectdef,recorddef]) then
                   begin
                   begin
-                    { first search using the class helper hierarchy }
-                    if search_last_objectpascal_classhelper(tobjectdef(expr.resultdef),classhelper) then
+                    { first search using the class helper hierarchy if it's a
+                      class }
+                    if (expr.resultdef.typ=objectdef) and
+                        search_last_objectpascal_classhelper(tobjectdef(expr.resultdef),classhelper) then
                       repeat
                       repeat
                         pd:=classhelper.search_enumerator_get;
                         pd:=classhelper.search_enumerator_get;
                         classhelper:=classhelper.helperparent;
                         classhelper:=classhelper.helperparent;
                       until (pd<>nil) or (classhelper=nil);
                       until (pd<>nil) or (classhelper=nil);
-                    { not found in class helper, so search in the class itself }
+                    { we didn't found a class helper, so search in the
+                      class/record/object itself }
                     if pd=nil then
                     if pd=nil then
-                      pd:=tobjectdef(expr.resultdef).search_enumerator_get;
+                      pd:=tabstractrecorddef(expr.resultdef).search_enumerator_get;
                   end;
                   end;
                 if pd<>nil then
                 if pd<>nil then
                   begin
                   begin
                     // seach movenext and current symbols
                     // seach movenext and current symbols
-                    movenext:=tobjectdef(pd.returndef).search_enumerator_move;
+                    movenext:=tabstractrecorddef(pd.returndef).search_enumerator_move;
                     if movenext = nil then
                     if movenext = nil then
                       begin
                       begin
                         result:=cerrornode.create;
                         result:=cerrornode.create;
@@ -886,7 +889,7 @@ implementation
                       end
                       end
                     else
                     else
                       begin
                       begin
-                        current:=tpropertysym(tobjectdef(pd.returndef).search_enumerator_current);
+                        current:=tpropertysym(tabstractrecorddef(pd.returndef).search_enumerator_current);
                         if current = nil then
                         if current = nil then
                           begin
                           begin
                             result:=cerrornode.create;
                             result:=cerrornode.create;

+ 12 - 3
compiler/ninl.pas

@@ -2258,9 +2258,18 @@ implementation
                 begin
                 begin
                   { the parser has already made sure the expression is valid }
                   { the parser has already made sure the expression is valid }
 
 
-                  { there could be a procvar, which is 2*sizeof(pointer), while we }
-                  { must only check the first pointer -> can't just convert to an  }
-                  { add node in all cases                                          }
+                  { in case of a complex procvar, only check the "code" pointer }
+                  if (tcallparanode(left).left.resultdef.typ=procvardef) and
+                     not tprocvardef(tcallparanode(left).left.resultdef).is_addressonly then
+                    begin
+                      inserttypeconv_explicit(tcallparanode(left).left,search_system_type('TMETHOD').typedef);
+                      tcallparanode(left).left:=csubscriptnode.create(tsym(tabstractrecorddef(tcallparanode(left).left.resultdef).symtable.find('CODE')),tcallparanode(left).left);
+                      tcallparanode(left).get_paratype;
+                    end;
+
+                  { converting to an add node is tricky because of differences
+                    in procvar handling between FPC and Delphi handling, so
+                    handle specially }
                   set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
                   set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
                   resultdef:=booltype;
                   resultdef:=booltype;
                 end;
                 end;

+ 2 - 2
compiler/nld.pas

@@ -626,7 +626,7 @@ implementation
           end;
           end;
 
 
         { call helpers for interface }
         { call helpers for interface }
-        if is_interfacecom(left.resultdef) then
+        if is_interfacecom_or_dispinterface(left.resultdef) then
          begin
          begin
 	   { Normal interface assignments are handled by the generic refcount incr/decr }
 	   { Normal interface assignments are handled by the generic refcount incr/decr }
            if not right.resultdef.is_related(left.resultdef) then
            if not right.resultdef.is_related(left.resultdef) then
@@ -712,7 +712,7 @@ implementation
         { call helpers for composite types containing automated types }
         { call helpers for composite types containing automated types }
         else if is_managed_type(left.resultdef) and
         else if is_managed_type(left.resultdef) and
             (left.resultdef.typ in [arraydef,objectdef,recorddef]) and
             (left.resultdef.typ in [arraydef,objectdef,recorddef]) and
-            not is_interfacecom(left.resultdef) and
+            not is_interfacecom_or_dispinterface(left.resultdef) and
             not is_dynamic_array(left.resultdef) then
             not is_dynamic_array(left.resultdef) then
          begin
          begin
            hp:=ccallparanode.create(caddrnode.create_internal(
            hp:=ccallparanode.create(caddrnode.create_internal(

+ 2 - 2
compiler/nutils.pas

@@ -592,7 +592,7 @@ implementation
           typecheckpass(p);
           typecheckpass(p);
         if is_ansistring(p.resultdef) or
         if is_ansistring(p.resultdef) or
            is_wide_or_unicode_string(p.resultdef) or
            is_wide_or_unicode_string(p.resultdef) or
-           is_interfacecom(p.resultdef) or
+           is_interfacecom_or_dispinterface(p.resultdef) or
            is_dynamic_array(p.resultdef) then
            is_dynamic_array(p.resultdef) then
           begin
           begin
             result:=cassignmentnode.create(
             result:=cassignmentnode.create(
@@ -656,7 +656,7 @@ implementation
                cnilnode.create
                cnilnode.create
                ));
                ));
           end
           end
-        else if is_interfacecom(p.resultdef) then
+        else if is_interfacecom_or_dispinterface(p.resultdef) then
           begin
           begin
             result:=internalstatements(newstatement);
             result:=internalstatements(newstatement);
             addstatement(newstatement,ccallnode.createintern('fpc_intf_decr_ref',
             addstatement(newstatement,ccallnode.createintern('fpc_intf_decr_ref',

+ 1 - 1
compiler/ogelf.pas

@@ -1229,7 +1229,7 @@ implementation
             asmbin : '';
             asmbin : '';
             asmcmd : '';
             asmcmd : '';
             supported_targets : [system_i386_linux,system_i386_beos,system_i386_freebsd,system_i386_haiku,system_i386_Netware,system_i386_netwlibc,
             supported_targets : [system_i386_linux,system_i386_beos,system_i386_freebsd,system_i386_haiku,system_i386_Netware,system_i386_netwlibc,
-	    system_i386_solaris];
+	                              system_i386_solaris,system_i386_embedded];
             flags : [af_outputbinary,af_smartlink_sections,af_supports_dwarf];
             flags : [af_outputbinary,af_smartlink_sections,af_supports_dwarf];
             labelprefix : '.L';
             labelprefix : '.L';
             comment : '';
             comment : '';

+ 1 - 2
compiler/pdecl.pas

@@ -657,9 +657,8 @@ implementation
                tstoreddef(hdef).generictokenbuf:=generictokenbuf;
                tstoreddef(hdef).generictokenbuf:=generictokenbuf;
                { Generic is never a type renaming }
                { Generic is never a type renaming }
                hdef.typesym:=newtype;
                hdef.typesym:=newtype;
+               generictypelist.free;
              end;
              end;
-           if assigned(generictypelist) then
-             generictypelist.free;
          until (token<>_ID)or(in_structure and (idtoken in [_PRIVATE,_PROTECTED,_PUBLIC,_PUBLISHED,_STRICT]));
          until (token<>_ID)or(in_structure and (idtoken in [_PRIVATE,_PROTECTED,_PUBLIC,_PUBLISHED,_STRICT]));
          { resolve type block forward declarations and restore a unit
          { resolve type block forward declarations and restore a unit
            container for them }
            container for them }

+ 20 - 17
compiler/pdecobj.pas

@@ -306,7 +306,7 @@ implementation
         while try_to_consume(_COMMA) do
         while try_to_consume(_COMMA) do
           begin
           begin
              { use single_type instead of id_type for specialize support }
              { use single_type instead of id_type for specialize support }
-             single_type(hdef,[stoAllowTypeDef,stoParseClassParent]);
+             single_type(hdef,[stoAllowSpecialization,stoParseClassParent]);
              if (hdef.typ<>objectdef) then
              if (hdef.typ<>objectdef) then
                begin
                begin
                   if intf then
                   if intf then
@@ -462,7 +462,7 @@ implementation
             if not is_objectpascal_classhelper(current_structdef) then
             if not is_objectpascal_classhelper(current_structdef) then
               consume(_LKLAMMER);
               consume(_LKLAMMER);
             { use single_type instead of id_type for specialize support }
             { use single_type instead of id_type for specialize support }
-            single_type(hdef,[stoAllowTypeDef, stoParseClassParent]);
+            single_type(hdef,[stoAllowSpecialization, stoParseClassParent]);
             if (not assigned(hdef)) or
             if (not assigned(hdef)) or
                (hdef.typ<>objectdef) then
                (hdef.typ<>objectdef) then
               begin
               begin
@@ -566,6 +566,8 @@ implementation
               odt_interfacecom:
               odt_interfacecom:
                 if current_objectdef<>interface_iunknown then
                 if current_objectdef<>interface_iunknown then
                   childof:=interface_iunknown;
                   childof:=interface_iunknown;
+              odt_dispinterface:
+                childof:=interface_idispatch;
               odt_objcclass:
               odt_objcclass:
                 CGMessage(parser_h_no_objc_parent);
                 CGMessage(parser_h_no_objc_parent);
             end;
             end;
@@ -837,20 +839,18 @@ implementation
             _CLASS:
             _CLASS:
               begin
               begin
                 is_classdef:=false;
                 is_classdef:=false;
-                { read class method }
-                if try_to_consume(_CLASS) then
-                 begin
-                   { class modifier is only allowed for procedures, functions, }
-                   { constructors, destructors, fields and properties          }
-                   if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR]) then
-                     Message(parser_e_procedure_or_function_expected);
-
-                   if is_interface(current_structdef) then
-                     Message(parser_e_no_static_method_in_interfaces)
-                   else
-                     { class methods are also allowed for Objective-C protocols }
-                     is_classdef:=true;
-                 end;
+                { read class method/field/property }
+                consume(_CLASS);
+                { class modifier is only allowed for procedures, functions, }
+                { constructors, destructors, fields and properties          }
+                if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR]) then
+                  Message(parser_e_procedure_or_function_expected);
+
+                if is_interface(current_structdef) then
+                  Message(parser_e_no_static_method_in_interfaces)
+                else
+                  { class methods are also allowed for Objective-C protocols }
+                  is_classdef:=true;
               end;
               end;
             _PROCEDURE,
             _PROCEDURE,
             _FUNCTION:
             _FUNCTION:
@@ -1072,7 +1072,10 @@ implementation
                 case current_objectdef.objecttype of
                 case current_objectdef.objecttype of
                   odt_interfacecom :
                   odt_interfacecom :
                     if (current_structdef.objname^='IUNKNOWN') then
                     if (current_structdef.objname^='IUNKNOWN') then
-                      interface_iunknown:=current_objectdef;
+                      interface_iunknown:=current_objectdef
+                    else
+                    if (current_structdef.objname^='IDISPATCH') then
+                      interface_idispatch:=current_objectdef;
                   odt_class :
                   odt_class :
                     if (current_structdef.objname^='TOBJECT') then
                     if (current_structdef.objname^='TOBJECT') then
                       class_tobject:=current_objectdef;
                       class_tobject:=current_objectdef;

+ 25 - 13
compiler/pdecsub.pas

@@ -656,7 +656,7 @@ implementation
                 else
                 else
                   begin
                   begin
                     block_type:=bt_var_type;
                     block_type:=bt_var_type;
-                    single_type(hdef,[]);
+                    single_type(hdef,[stoAllowSpecialization]);
                     block_type:=bt_var;
                     block_type:=bt_var;
                   end;
                   end;
 
 
@@ -916,9 +916,8 @@ implementation
                    (ttypesym(srsym).typedef.typ in [objectdef,recorddef]) then
                    (ttypesym(srsym).typedef.typ in [objectdef,recorddef]) then
                 begin
                 begin
                   astruct:=tabstractrecorddef(ttypesym(srsym).typedef);
                   astruct:=tabstractrecorddef(ttypesym(srsym).typedef);
-                  if (df_generic in astruct.defoptions) then
+                  if (df_generic in astruct.defoptions) and try_to_consume(_LT) then
                     begin
                     begin
-                      consume(_LT);
                       ok:=true;
                       ok:=true;
                       i:=0;
                       i:=0;
                       repeat
                       repeat
@@ -955,13 +954,22 @@ implementation
                       consume(_GT);
                       consume(_GT);
                     end
                     end
                   else
                   else
-                  if try_to_consume(_LT) then
+                  if (df_generic in astruct.defoptions) and (token=_POINT) then
                     begin
                     begin
-                      Message(type_e_type_parameters_are_not_allowed_here);
-                      repeat
-                        consume(_ID);
-                      until not try_to_consume(_COMMA);
-                      consume(_GT);
+                      Message1(type_e_generic_declaration_does_not_match,astruct.RttiName);
+                    end
+                  else
+                    begin
+                      { not a method. routine name just accidentally match some structure name }
+                      astruct:=nil;
+                      if try_to_consume(_LT) then
+                        begin
+                          Message(type_e_type_parameters_are_not_allowed_here);
+                          repeat
+                            consume(_ID);
+                          until not try_to_consume(_COMMA);
+                          consume(_GT);
+                        end;
                     end;
                     end;
                 end;
                 end;
               end;
               end;
@@ -1272,7 +1280,7 @@ implementation
                 if assigned(current_structdef) and (df_specialization in current_structdef.defoptions) then
                 if assigned(current_structdef) and (df_specialization in current_structdef.defoptions) then
                   current_specializedef:=current_structdef;
                   current_specializedef:=current_structdef;
               end;
               end;
-            single_type(pd.returndef,[]);
+            single_type(pd.returndef,[stoAllowSpecialization]);
 
 
             if is_dispinterface(pd.struct) and not is_automatable(pd.returndef) then
             if is_dispinterface(pd.struct) and not is_automatable(pd.returndef) then
               Message1(type_e_not_automatable,pd.returndef.typename);
               Message1(type_e_not_automatable,pd.returndef.typename);
@@ -1436,7 +1444,10 @@ implementation
                   else
                   else
                    begin
                    begin
                      read_returndef(pd);
                      read_returndef(pd);
-                     if (po_classmethod in pd.procoptions) then
+                     { check that class operators have either return type of structure or }
+                     { at least one argument of that type                                 }
+                     if (po_classmethod in pd.procoptions) and
+                        (pd.returndef <> pd.struct) then
                        begin
                        begin
                          found:=false;
                          found:=false;
                          for i := 0 to pd.parast.SymList.Count - 1 do
                          for i := 0 to pd.parast.SymList.Count - 1 do
@@ -1453,7 +1464,8 @@ implementation
                          (torddef(pd.returndef).ordtype<>pasbool)) then
                          (torddef(pd.returndef).ordtype<>pasbool)) then
                         Message(parser_e_comparative_operator_return_boolean);
                         Message(parser_e_comparative_operator_return_boolean);
                      if (optoken in [_ASSIGNMENT,_OP_EXPLICIT]) and
                      if (optoken in [_ASSIGNMENT,_OP_EXPLICIT]) and
-                        equal_defs(pd.returndef,tparavarsym(pd.parast.SymList[0]).vardef) then
+                        equal_defs(pd.returndef,tparavarsym(pd.parast.SymList[0]).vardef) and
+                        (pd.returndef.typ<>undefineddef) and (tparavarsym(pd.parast.SymList[0]).vardef.typ<>undefineddef) then
                        message(parser_e_no_such_assignment)
                        message(parser_e_no_such_assignment)
                      else if not isoperatoracceptable(pd,optoken) then
                      else if not isoperatoracceptable(pd,optoken) then
                        Message(parser_e_overload_impossible);
                        Message(parser_e_overload_impossible);
@@ -2473,7 +2485,7 @@ const
       mutexclpo     : [po_public,po_exports,po_interrupt,po_assembler,po_inline]
       mutexclpo     : [po_public,po_exports,po_interrupt,po_assembler,po_inline]
     ),(
     ),(
       idtok:_ENUMERATOR;
       idtok:_ENUMERATOR;
-      pd_flags : [pd_interface,pd_object];
+      pd_flags : [pd_interface,pd_object,pd_record];
       handler  : @pd_enumerator;
       handler  : @pd_enumerator;
       pocall   : pocall_none;
       pocall   : pocall_none;
       pooption : [];
       pooption : [];

+ 99 - 54
compiler/pdecvar.pas

@@ -241,13 +241,30 @@ implementation
                (ppo_hasparameters in p.propoptions);
                (ppo_hasparameters in p.propoptions);
           end;
           end;
 
 
-          procedure parse_dispinterface(p : tpropertysym);
+          procedure create_accessor_procsym(p: tpropertysym; pd: tprocdef; const prefix: string;
+              accesstype: tpropaccesslisttypes);
+            var
+              sym: tprocsym;
+            begin
+              handle_calling_convention(pd);
+              sym:=tprocsym.create(prefix+lower(p.realname));
+              symtablestack.top.insert(sym);
+              pd.procsym:=sym;
+              include(pd.procoptions,po_dispid);
+              include(pd.procoptions,po_global);
+              pd.visibility:=vis_private;
+              proc_add_definition(pd);
+              p.propaccesslist[accesstype].addsym(sl_call,sym);
+              p.propaccesslist[accesstype].procdef:=pd;
+            end;
+
+          procedure parse_dispinterface(p : tpropertysym; readpd,writepd: tprocdef;
+              var paranr: word);
             var
             var
-              {procsym: tprocsym;
-              procdef: tprocdef;
-              valuepara: tparavarsym;}
               hasread, haswrite: boolean;
               hasread, haswrite: boolean;
               pt: tnode;
               pt: tnode;
+              hdispid: longint;
+              hparavs: tparavarsym;
             begin
             begin
               p.propaccesslist[palt_read].clear;
               p.propaccesslist[palt_read].clear;
               p.propaccesslist[palt_write].clear;
               p.propaccesslist[palt_write].clear;
@@ -260,12 +277,6 @@ implementation
               else if try_to_consume(_WRITEONLY) then
               else if try_to_consume(_WRITEONLY) then
                 hasread:=false;
                 hasread:=false;
 
 
-              if hasread then
-                include(p.propoptions, ppo_dispid_read);
-
-              if haswrite then
-                include(p.propoptions, ppo_dispid_write);
-
               if try_to_consume(_DISPID) then
               if try_to_consume(_DISPID) then
                 begin
                 begin
                   pt:=comp_expr(true,false);
                   pt:=comp_expr(true,false);
@@ -273,16 +284,39 @@ implementation
                     if (Tordconstnode(pt).value<int64(low(longint))) or (Tordconstnode(pt).value>int64(high(longint))) then
                     if (Tordconstnode(pt).value<int64(low(longint))) or (Tordconstnode(pt).value>int64(high(longint))) then
                       message(parser_e_range_check_error)
                       message(parser_e_range_check_error)
                     else
                     else
-                      p.dispid:=Tordconstnode(pt).value.svalue
+                      hdispid:=Tordconstnode(pt).value.svalue
                   else
                   else
                     Message(parser_e_dispid_must_be_ord_const);
                     Message(parser_e_dispid_must_be_ord_const);
                   pt.free;
                   pt.free;
                 end
                 end
               else
               else
-                p.dispid:=tobjectdef(astruct).get_next_dispid;
+                hdispid:=tobjectdef(astruct).get_next_dispid;
+
+              { COM property is simply a pair of methods, tagged with 'propertyget'
+                and 'propertyset' flags (or a single method if access is restricted).
+                Creating these implicit accessor methods also allows the rest of compiler
+                to handle dispinterface properties the same way as regular ones. }
+              if hasread then
+                begin
+                  readpd.returndef:=p.propdef;
+                  readpd.dispid:=hdispid;
+                  readpd.proctypeoption:=potype_propgetter;
+                  create_accessor_procsym(p,readpd,'get$',palt_read);
+                end;
+              if haswrite then
+                begin
+                  { add an extra parameter, a placeholder of the value to set }
+                  inc(paranr);
+                  hparavs:=tparavarsym.create('$value',10*paranr,vs_value,p.propdef,[]);
+                  writepd.parast.insert(hparavs);
+
+                  writepd.proctypeoption:=potype_propsetter;
+                  writepd.dispid:=hdispid;
+                  create_accessor_procsym(p,writepd,'put$',palt_write);
+                end;
             end;
             end;
 
 
-          procedure add_index_parameter(var paranr: word; p: tpropertysym; readprocdef, writeprocdef, storedprocdef: tprocvardef);
+          procedure add_index_parameter(var paranr: word; p: tpropertysym; readprocdef, writeprocdef: tprocdef);
             var
             var
               hparavs: tparavarsym;
               hparavs: tparavarsym;
             begin
             begin
@@ -291,8 +325,6 @@ implementation
               readprocdef.parast.insert(hparavs);
               readprocdef.parast.insert(hparavs);
               hparavs:=tparavarsym.create('$index',10*paranr,vs_value,p.indexdef,[]);
               hparavs:=tparavarsym.create('$index',10*paranr,vs_value,p.indexdef,[]);
               writeprocdef.parast.insert(hparavs);
               writeprocdef.parast.insert(hparavs);
-              hparavs:=tparavarsym.create('$index',10*paranr,vs_value,p.indexdef,[]);
-              storedprocdef.parast.insert(hparavs);
             end;
             end;
 
 
       var
       var
@@ -312,28 +344,25 @@ implementation
          found        : boolean;
          found        : boolean;
          hreadparavs,
          hreadparavs,
          hparavs      : tparavarsym;
          hparavs      : tparavarsym;
-         storedprocdef,
+         storedprocdef: tprocvardef;
          readprocdef,
          readprocdef,
-         writeprocdef : tprocvardef;
+         writeprocdef : tprocdef;
       begin
       begin
-         { Generate temp procvardefs to search for matching read/write
+         { Generate temp procdefs to search for matching read/write
            procedures. the readprocdef will store all definitions }
            procedures. the readprocdef will store all definitions }
          paranr:=0;
          paranr:=0;
-         readprocdef:=tprocvardef.create(normal_function_level);
-         writeprocdef:=tprocvardef.create(normal_function_level);
-         storedprocdef:=tprocvardef.create(normal_function_level);
+         readprocdef:=tprocdef.create(normal_function_level);
+         writeprocdef:=tprocdef.create(normal_function_level);
 
 
-         { make them method pointers }
-         if assigned(astruct) and not is_classproperty then
+         readprocdef.struct:=astruct;
+         writeprocdef.struct:=astruct;
+
+         if assigned(astruct) and is_classproperty then
            begin
            begin
-             include(readprocdef.procoptions,po_methodpointer);
-             include(writeprocdef.procoptions,po_methodpointer);
-             include(storedprocdef.procoptions,po_methodpointer);
+             readprocdef.procoptions:=[po_staticmethod,po_classmethod];
+             writeprocdef.procoptions:=[po_staticmethod,po_classmethod];
            end;
            end;
 
 
-         { method for stored must return boolean }
-         storedprocdef.returndef:=booltype;
-
          if token<>_ID then
          if token<>_ID then
            begin
            begin
               consume(_ID);
               consume(_ID);
@@ -448,7 +477,7 @@ implementation
                    p.indexdef:=pt.resultdef;
                    p.indexdef:=pt.resultdef;
                    include(p.propoptions,ppo_indexed);
                    include(p.propoptions,ppo_indexed);
                    { concat a longint to the para templates }
                    { concat a longint to the para templates }
-                   add_index_parameter(paranr,p,readprocdef,writeprocdef,storedprocdef);
+                   add_index_parameter(paranr,p,readprocdef,writeprocdef);
                    pt.free;
                    pt.free;
                 end;
                 end;
            end
            end
@@ -471,7 +500,7 @@ implementation
                   p.default:=tpropertysym(overridden).default;
                   p.default:=tpropertysym(overridden).default;
                   p.propoptions:=tpropertysym(overridden).propoptions;
                   p.propoptions:=tpropertysym(overridden).propoptions;
                   if ppo_indexed in p.propoptions then
                   if ppo_indexed in p.propoptions then
-                    add_index_parameter(paranr,p,readprocdef,writeprocdef,storedprocdef);
+                    add_index_parameter(paranr,p,readprocdef,writeprocdef);
                 end
                 end
               else
               else
                 begin
                 begin
@@ -584,7 +613,7 @@ implementation
                end;
                end;
            end
            end
          else
          else
-           parse_dispinterface(p);
+           parse_dispinterface(p,readprocdef,writeprocdef,paranr);
 
 
          { stored is not allowed for dispinterfaces, records or class properties }
          { stored is not allowed for dispinterfaces, records or class properties }
          if assigned(astruct) and not(is_dispinterface(astruct) or is_record(astruct)) and not is_classproperty then
          if assigned(astruct) and not(is_dispinterface(astruct) or is_record(astruct)) and not is_classproperty then
@@ -641,11 +670,25 @@ implementation
                             case sym.typ of
                             case sym.typ of
                               procsym :
                               procsym :
                                 begin
                                 begin
+                                   { Create a temporary procvardef to handle parameters }
+                                   storedprocdef:=tprocvardef.create(normal_function_level);
+                                   include(storedprocdef.procoptions,po_methodpointer);
+                                   { Return type must be boolean }
+                                   storedprocdef.returndef:=booltype;
+                                   { Add index parameter if needed }
+                                   if ppo_indexed in p.propoptions then
+                                     begin
+                                       hparavs:=tparavarsym.create('$index',10,vs_value,p.indexdef,[]);
+                                       storedprocdef.parast.insert(hparavs);
+                                     end;
+
                                    { Insert hidden parameters }
                                    { Insert hidden parameters }
                                    handle_calling_convention(storedprocdef);
                                    handle_calling_convention(storedprocdef);
                                    p.propaccesslist[palt_stored].procdef:=Tprocsym(sym).Find_procdef_bypara(storedprocdef.paras,storedprocdef.returndef,[cpo_allowdefaults,cpo_ignorehidden]);
                                    p.propaccesslist[palt_stored].procdef:=Tprocsym(sym).Find_procdef_bypara(storedprocdef.paras,storedprocdef.returndef,[cpo_allowdefaults,cpo_ignorehidden]);
                                    if not assigned(p.propaccesslist[palt_stored].procdef) then
                                    if not assigned(p.propaccesslist[palt_stored].procdef) then
                                      message(parser_e_ill_property_storage_sym);
                                      message(parser_e_ill_property_storage_sym);
+                                   { Not needed anymore }
+                                   storedprocdef.owner.deletedef(storedprocdef);
                                 end;
                                 end;
                               fieldvarsym :
                               fieldvarsym :
                                 begin
                                 begin
@@ -828,9 +871,11 @@ implementation
                message1(parser_e_implements_uses_non_implemented_interface,def.typename);
                message1(parser_e_implements_uses_non_implemented_interface,def.typename);
          end;
          end;
 
 
-         { remove temporary procvardefs }
-         readprocdef.owner.deletedef(readprocdef);
-         writeprocdef.owner.deletedef(writeprocdef);
+         { remove unneeded procdefs }
+         if readprocdef.proctypeoption<>potype_propgetter then
+           readprocdef.owner.deletedef(readprocdef);
+         if writeprocdef.proctypeoption<>potype_propsetter then
+           writeprocdef.owner.deletedef(writeprocdef);
 
 
          result:=p;
          result:=p;
       end;
       end;
@@ -1540,25 +1585,25 @@ implementation
                      include(options, vd_class);
                      include(options, vd_class);
                    end;
                    end;
                end;
                end;
-                 if vd_class in options then
-                 begin
-                   { add static flag and staticvarsyms }
-                   for i:=0 to sc.count-1 do
-                     begin
-                       fieldvs:=tfieldvarsym(sc[i]);
-                       include(fieldvs.symoptions,sp_static);
-                       { generate the symbol which reserves the space }
-                       static_name:=lower(generate_nested_name(recst,'_'))+'_'+fieldvs.name;
-                       hstaticvs:=tstaticvarsym.create('$_static_'+static_name,vs_value,hdef,[]);
-                       include(hstaticvs.symoptions,sp_internal);
-                       recst.get_unit_symtable.insert(hstaticvs);
-                       insertbssdata(hstaticvs);
-                       { generate the symbol for the access }
-                       sl:=tpropaccesslist.create;
-                       sl.addsym(sl_load,hstaticvs);
-                       recst.insert(tabsolutevarsym.create_ref('$'+static_name,hdef,sl));
-                     end;
-                 end;
+             if vd_class in options then
+               begin
+                 { add static flag and staticvarsyms }
+                 for i:=0 to sc.count-1 do
+                   begin
+                     fieldvs:=tfieldvarsym(sc[i]);
+                     include(fieldvs.symoptions,sp_static);
+                     { generate the symbol which reserves the space }
+                     static_name:=lower(generate_nested_name(recst,'_'))+'_'+fieldvs.name;
+                     hstaticvs:=tstaticvarsym.create('$_static_'+static_name,vs_value,hdef,[]);
+                     include(hstaticvs.symoptions,sp_internal);
+                     recst.get_unit_symtable.insert(hstaticvs);
+                     insertbssdata(hstaticvs);
+                     { generate the symbol for the access }
+                     sl:=tpropaccesslist.create;
+                     sl.addsym(sl_load,hstaticvs);
+                     recst.insert(tabsolutevarsym.create_ref('$'+static_name,hdef,sl));
+                   end;
+               end;
              if (visibility=vis_published) and
              if (visibility=vis_published) and
                 not(is_class(hdef)) then
                 not(is_class(hdef)) then
                begin
                begin

+ 39 - 82
compiler/pexpr.pas

@@ -535,8 +535,6 @@ implementation
               in_args:=true;
               in_args:=true;
               p1:=comp_expr(true,false);
               p1:=comp_expr(true,false);
               p1:=caddrnode.create(p1);
               p1:=caddrnode.create(p1);
-              if cs_typed_addresses in current_settings.localswitches then
-                include(p1.flags,nf_typedaddr);
               consume(_RKLAMMER);
               consume(_RKLAMMER);
               statement_syssym:=p1;
               statement_syssym:=p1;
             end;
             end;
@@ -1016,6 +1014,36 @@ implementation
       end;
       end;
 
 
 
 
+    { checks whether sym is a static field and if so, translates the access
+      to the appropriate node tree }
+    function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean;
+      var
+        static_name: shortstring;
+        srsymtable: tsymtable;
+      begin
+        result:=false;
+        { generate access code }
+        if (sp_static in sym.symoptions) then
+          begin
+            result:=true;
+            if not nested then
+              static_name:=lower(sym.owner.name^)+'_'+sym.name
+            else
+             static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name;
+            if sym.owner.defowner.typ=objectdef then
+              searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable)
+            else
+              searchsym_in_record(trecorddef(sym.owner.defowner),static_name,sym,srsymtable);
+            if assigned(sym) then
+              check_hints(sym,sym.symoptions,sym.deprecatedmsg);
+            p1.free;
+            p1:=nil;
+            { static syms are always stored as absolutevarsym to handle scope and storage properly }
+            propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref);
+          end;
+      end;
+
+
     { the following procedure handles the access to a property symbol }
     { the following procedure handles the access to a property symbol }
     procedure handle_propertysym(propsym : tpropertysym;st : TSymtable;var p1 : tnode);
     procedure handle_propertysym(propsym : tpropertysym;st : TSymtable;var p1 : tnode);
       var
       var
@@ -1024,11 +1052,7 @@ implementation
          membercall : boolean;
          membercall : boolean;
          callflags  : tcallnodeflags;
          callflags  : tcallnodeflags;
          propaccesslist : tpropaccesslist;
          propaccesslist : tpropaccesslist;
-         static_name : shortstring;
          sym: tsym;
          sym: tsym;
-         srsymtable : tsymtable;
-         statements : tstatementnode;
-         converted_result_data : ttempcreatenode;
       begin
       begin
          { property parameters? read them only if the property really }
          { property parameters? read them only if the property really }
          { has parameters                                             }
          { has parameters                                             }
@@ -1080,21 +1104,7 @@ implementation
                      fieldvarsym :
                      fieldvarsym :
                        begin
                        begin
                          { generate access code }
                          { generate access code }
-                         if (sp_static in sym.symoptions) then
-                           begin
-                             static_name:=lower(sym.owner.name^)+'_'+sym.name;
-                             if sym.owner.defowner.typ=objectdef then
-                               searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable)
-                             else
-                               searchsym_in_record(trecorddef(sym.owner.defowner),static_name,sym,srsymtable);
-                             if assigned(sym) then
-                               check_hints(sym,sym.symoptions,sym.deprecatedmsg);
-                             p1.free;
-                             p1:=nil;
-                             { static syms are always stored as absolutevarsym to handle scope and storage properly }
-                             propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref);
-                           end
-                         else
+                         if not handle_staticfield_access(sym,false,p1) then
                            propaccesslist_to_node(p1,st,propaccesslist);
                            propaccesslist_to_node(p1,st,propaccesslist);
                          include(p1.flags,nf_isproperty);
                          include(p1.flags,nf_isproperty);
                          consume(_ASSIGNMENT);
                          consume(_ASSIGNMENT);
@@ -1109,16 +1119,6 @@ implementation
                       end;
                       end;
                   end;
                   end;
                 end
                 end
-              else
-              if (ppo_dispid_write in propsym.propoptions) then
-                begin
-                  consume(_ASSIGNMENT);
-                  p2:=comp_expr(true,false);
-                  { concat value parameter too }
-                  p2:=ccallparanode.create(p2,nil);
-                  { passing p3 here is only for information purposes }
-                  p1:=translate_disp_call(p1,p2,p2,'',propsym.dispid,voidtype);
-                end
               else
               else
                 begin
                 begin
                    p1:=cerrornode.create;
                    p1:=cerrornode.create;
@@ -1134,21 +1134,7 @@ implementation
                      fieldvarsym :
                      fieldvarsym :
                        begin
                        begin
                          { generate access code }
                          { generate access code }
-                         if (sp_static in sym.symoptions) then
-                           begin
-                             static_name:=lower(sym.owner.name^)+'_'+sym.name;
-                             if sym.owner.defowner.typ=objectdef then
-                               searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable)
-                             else
-                               searchsym_in_record(trecorddef(sym.owner.defowner),static_name,sym,srsymtable);
-                             if assigned(sym) then
-                               check_hints(sym,sym.symoptions,sym.deprecatedmsg);
-                             p1.free;
-                             p1:=nil;
-                             { static syms are always stored as absolutevarsym to handle scope and storage properly }
-                             propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref);
-                           end
-                         else
+                         if not handle_staticfield_access(sym,false,p1) then
                            propaccesslist_to_node(p1,st,propaccesslist);
                            propaccesslist_to_node(p1,st,propaccesslist);
                          include(p1.flags,nf_isproperty);
                          include(p1.flags,nf_isproperty);
                        end;
                        end;
@@ -1170,19 +1156,6 @@ implementation
                        end;
                        end;
                   end;
                   end;
                 end
                 end
-              else
-              if (ppo_dispid_read in propsym.propoptions) then
-                begin
-                  p2:=internalstatements(statements);
-                  converted_result_data:=ctempcreatenode.create(propsym.propdef,sizeof(propsym.propdef),tt_persistent,true);
-                  addstatement(statements,converted_result_data);
-                  addstatement(statements,cassignmentnode.create(ctemprefnode.create(converted_result_data),
-                    ctypeconvnode.create_internal(translate_disp_call(p1,nil,nil,'',propsym.dispid,propsym.propdef),
-                    propsym.propdef)));
-                  addstatement(statements,ctempdeletenode.create_normal_temp(converted_result_data));
-                  addstatement(statements,ctemprefnode.create(converted_result_data));
-                  p1:=p2;
-                end
               else
               else
                 begin
                 begin
                    { error, no function to read property }
                    { error, no function to read property }
@@ -1199,9 +1172,7 @@ implementation
     { the ID token has to be consumed before calling this function }
     { the ID token has to be consumed before calling this function }
     procedure do_member_read(structh:tabstractrecorddef;getaddr:boolean;sym:tsym;var p1:tnode;var again:boolean;callflags:tcallnodeflags);
     procedure do_member_read(structh:tabstractrecorddef;getaddr:boolean;sym:tsym;var p1:tnode;var again:boolean;callflags:tcallnodeflags);
       var
       var
-         static_name : string;
          isclassref  : boolean;
          isclassref  : boolean;
-         srsymtable  : TSymtable;
       begin
       begin
          if sym=nil then
          if sym=nil then
            begin
            begin
@@ -1244,21 +1215,7 @@ implementation
                    end;
                    end;
                  fieldvarsym:
                  fieldvarsym:
                    begin
                    begin
-                      if (sp_static in sym.symoptions) then
-                        begin
-                          static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name;
-                          if sym.Owner.defowner.typ=objectdef then
-                            searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable)
-                          else
-                            searchsym_in_record(trecorddef(sym.owner.defowner),static_name,sym,srsymtable);
-                          if assigned(sym) then
-                            check_hints(sym,sym.symoptions,sym.deprecatedmsg);
-                          p1.free;
-                          p1:=nil;
-                          { static syms are always stored as absolutevarsym to handle scope and storage properly }
-                          propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref);
-                        end
-                      else
+                      if not handle_staticfield_access(sym,true,p1) then
                         begin
                         begin
                           if isclassref then
                           if isclassref then
                             if assigned(p1) and
                             if assigned(p1) and
@@ -1949,7 +1906,8 @@ implementation
 
 
                _LECKKLAMMER:
                _LECKKLAMMER:
                   begin
                   begin
-                    if is_class_or_interface_or_object(p1.resultdef) then
+                    if is_class_or_interface_or_object(p1.resultdef) or
+                      is_dispinterface(p1.resultdef) then
                       begin
                       begin
                         { default property }
                         { default property }
                         protsym:=search_default_property(tobjectdef(p1.resultdef));
                         protsym:=search_default_property(tobjectdef(p1.resultdef));
@@ -2141,16 +2099,15 @@ implementation
                                    p3:=comp_expr(true,false);
                                    p3:=comp_expr(true,false);
                                    { concat value parameter too }
                                    { concat value parameter too }
                                    p2:=ccallparanode.create(p3,p2);
                                    p2:=ccallparanode.create(p3,p2);
-                                   { passing p3 here is only for information purposes }
-                                   p1:=translate_disp_call(p1,p2,p3,dispatchstring,0,voidtype);
+                                   p1:=translate_disp_call(p1,p2,dct_propput,dispatchstring,0,voidtype);
                                  end
                                  end
                                else
                                else
                                { this is only an approximation
                                { this is only an approximation
                                  setting useresult if not necessary is only a waste of time, no more, no less (FK) }
                                  setting useresult if not necessary is only a waste of time, no more, no less (FK) }
                                if afterassignment or in_args or (token<>_SEMICOLON) then
                                if afterassignment or in_args or (token<>_SEMICOLON) then
-                                 p1:=translate_disp_call(p1,p2,nil,dispatchstring,0,cvarianttype)
+                                 p1:=translate_disp_call(p1,p2,dct_method,dispatchstring,0,cvarianttype)
                                else
                                else
-                                 p1:=translate_disp_call(p1,p2,nil,dispatchstring,0,voidtype);
+                                 p1:=translate_disp_call(p1,p2,dct_method,dispatchstring,0,voidtype);
                              end
                              end
                            else { Error }
                            else { Error }
                              Consume(_ID);
                              Consume(_ID);
@@ -2383,7 +2340,7 @@ implementation
                       hclassdef:=hclassdef.childof;
                       hclassdef:=hclassdef.childof;
                     { if inherited; only then we need the method with
                     { if inherited; only then we need the method with
                       the same name }
                       the same name }
-                    if token in endtokens then
+                    if token <> _ID then
                      begin
                      begin
                        hs:=current_procinfo.procdef.procsym.name;
                        hs:=current_procinfo.procdef.procsym.name;
                        hsorg:=current_procinfo.procdef.procsym.realname;
                        hsorg:=current_procinfo.procdef.procsym.realname;

+ 3 - 3
compiler/pmodules.pas

@@ -1360,8 +1360,8 @@ implementation
          maybeloadvariantsunit;
          maybeloadvariantsunit;
 
 
          { generate wrappers for interfaces }
          { generate wrappers for interfaces }
-         gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.globalsymtable);
-         gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.localsymtable);
+         gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.globalsymtable,false);
+         gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.localsymtable,false);
 
 
          { generate pic helpers to load eip if necessary }
          { generate pic helpers to load eip if necessary }
          gen_pic_helpers(current_asmdata.asmlists[al_procedures]);
          gen_pic_helpers(current_asmdata.asmlists[al_procedures]);
@@ -2333,7 +2333,7 @@ implementation
          MaybeGenerateObjectiveCImageInfo(nil,current_module.localsymtable);
          MaybeGenerateObjectiveCImageInfo(nil,current_module.localsymtable);
 
 
          { generate wrappers for interfaces }
          { generate wrappers for interfaces }
-         gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.localsymtable);
+         gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.localsymtable,false);
 
 
          { generate imports }
          { generate imports }
          if current_module.ImportLibraryList.Count>0 then
          if current_module.ImportLibraryList.Count>0 then

+ 14 - 8
compiler/pp.lpi

@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
 <?xml version="1.0"?>
 <CONFIG>
 <CONFIG>
   <ProjectOptions>
   <ProjectOptions>
+    <Version Value="9"/>
     <PathDelim Value="\"/>
     <PathDelim Value="\"/>
-    <Version Value="7"/>
     <General>
     <General>
       <Flags>
       <Flags>
         <MainUnitHasUsesSectionForAllUnits Value="False"/>
         <MainUnitHasUsesSectionForAllUnits Value="False"/>
@@ -12,9 +12,11 @@
       </Flags>
       </Flags>
       <SessionStorage Value="InProjectDir"/>
       <SessionStorage Value="InProjectDir"/>
       <MainUnit Value="0"/>
       <MainUnit Value="0"/>
-      <TargetFileExt Value=".exe"/>
       <Title Value="pp"/>
       <Title Value="pp"/>
     </General>
     </General>
+    <BuildModes Count="1">
+      <Item1 Name="default" Default="True"/>
+    </BuildModes>
     <PublishOptions>
     <PublishOptions>
       <Version Value="2"/>
       <Version Value="2"/>
       <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
       <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
@@ -23,8 +25,9 @@
     <RunParams>
     <RunParams>
       <local>
       <local>
         <FormatVersion Value="1"/>
         <FormatVersion Value="1"/>
-        <CommandLineParams Value="-n @\home\florian\bin\fpc.cfg \home\florian\fpc\tests\test\cg\tsar1.pp"/>
+        <CommandLineParams Value="-n -Fuc:\svn\fpcbranches\classhelpers\rtl\units\i386-win32 -Fu. c:\svn\fpcbranches\classhelpers\tests\test\tchlp42.pp"/>
         <LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
         <LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
+        <WorkingDirectory Value="c:\svn\fpcbranches\classhelpers\tests\test"/>
       </local>
       </local>
     </RunParams>
     </RunParams>
     <Units Count="2">
     <Units Count="2">
@@ -41,14 +44,14 @@
     </Units>
     </Units>
   </ProjectOptions>
   </ProjectOptions>
   <CompilerOptions>
   <CompilerOptions>
-    <Version Value="8"/>
+    <Version Value="9"/>
     <PathDelim Value="\"/>
     <PathDelim Value="\"/>
     <Target>
     <Target>
       <Filename Value="i386\pp"/>
       <Filename Value="i386\pp"/>
     </Target>
     </Target>
     <SearchPaths>
     <SearchPaths>
-      <IncludeFiles Value="i386\"/>
-      <OtherUnitFiles Value="i386\;x86\;systems\"/>
+      <IncludeFiles Value="i386"/>
+      <OtherUnitFiles Value="i386;x86;systems"/>
       <UnitOutputDirectory Value="i386\lazbuild"/>
       <UnitOutputDirectory Value="i386\lazbuild"/>
     </SearchPaths>
     </SearchPaths>
     <Parsing>
     <Parsing>
@@ -56,6 +59,7 @@
         <CStyleOperator Value="False"/>
         <CStyleOperator Value="False"/>
         <AllowLabel Value="False"/>
         <AllowLabel Value="False"/>
         <CPPInline Value="False"/>
         <CPPInline Value="False"/>
+        <UseAnsiStrings Value="False"/>
       </SyntaxOptions>
       </SyntaxOptions>
     </Parsing>
     </Parsing>
     <Linking>
     <Linking>
@@ -72,8 +76,10 @@
       <ConfigFile>
       <ConfigFile>
         <StopAfterErrCount Value="50"/>
         <StopAfterErrCount Value="50"/>
       </ConfigFile>
       </ConfigFile>
-      <CustomOptions Value="-di386
-"/>
+      <CompilerMessages>
+        <UseMsgFile Value="True"/>
+      </CompilerMessages>
+      <CustomOptions Value="-di386"/>
       <CompilerPath Value="$(CompPath)"/>
       <CompilerPath Value="$(CompPath)"/>
     </Other>
     </Other>
   </CompilerOptions>
   </CompilerOptions>

+ 1 - 1
compiler/ppcgen/ngppcset.pas

@@ -184,7 +184,7 @@ implementation
            if t^._low=t^._high then
            if t^._low=t^._high then
              begin
              begin
                 if t^._low-last=0 then
                 if t^._low-last=0 then
-                  cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_EQ,0,hregister,blocklabel(t^.blockid))
+                  cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_EQ,0,hregister,blocklabel(t^.blockid))
                 else
                 else
                   gensub(longint(int64(t^._low-last)));
                   gensub(longint(int64(t^._low-last)));
                 tcgppc(cg).a_jmp_cond(current_asmdata.CurrAsmList,OC_EQ,blocklabel(t^.blockid));
                 tcgppc(cg).a_jmp_cond(current_asmdata.CurrAsmList,OC_EQ,blocklabel(t^.blockid));

+ 21 - 19
compiler/ptype.pas

@@ -30,7 +30,12 @@ interface
        symtype,symdef,symbase;
        symtype,symdef,symbase;
 
 
     type
     type
-      TSingleTypeOption=(stoIsForwardDef,stoAllowTypeDef,stoParseClassParent);
+      TSingleTypeOption=(
+        stoIsForwardDef,          { foward declaration         }
+        stoAllowTypeDef,          { allow type definitions     }
+        stoAllowSpecialization,   { allow type specialization  }
+        stoParseClassParent       { parse of parent class type }
+      );
       TSingleTypeOptions=set of TSingleTypeOption;
       TSingleTypeOptions=set of TSingleTypeOption;
 
 
     procedure resolve_forward_types;
     procedure resolve_forward_types;
@@ -401,8 +406,7 @@ implementation
          sorg:=orgpattern;
          sorg:=orgpattern;
          pos:=current_tokenpos;
          pos:=current_tokenpos;
          { use of current parsed object:
          { use of current parsed object:
-            - classes can be used also in classes
-            - objects can be parameters }
+           classes, objects, records can be used also in themself }
          structdef:=current_structdef;
          structdef:=current_structdef;
          while assigned(structdef) and (structdef.typ in [objectdef,recorddef]) do
          while assigned(structdef) and (structdef.typ in [objectdef,recorddef]) do
            begin
            begin
@@ -414,7 +418,7 @@ implementation
                end;
                end;
              structdef:=tabstractrecorddef(structdef.owner.defowner);
              structdef:=tabstractrecorddef(structdef.owner.defowner);
            end;
            end;
-         { Use the special searchsym_type that ignores records and parameters }
+         { Use the special searchsym_type that search only types }
          searchsym_type(s,srsym,srsymtable);
          searchsym_type(s,srsym,srsymtable);
          { handle unit specification like System.Writeln }
          { handle unit specification like System.Writeln }
          is_unit_specific:=try_consume_unitsym(srsym,srsymtable,t);
          is_unit_specific:=try_consume_unitsym(srsym,srsymtable,t);
@@ -497,7 +501,7 @@ implementation
                  begin
                  begin
                    if try_to_consume(_SPECIALIZE) then
                    if try_to_consume(_SPECIALIZE) then
                      begin
                      begin
-                       if not(stoAllowTypeDef in options) then
+                       if ([stoAllowSpecialization,stoAllowTypeDef] * options = []) then
                          begin
                          begin
                            Message(parser_e_no_local_para_def);
                            Message(parser_e_no_local_para_def);
 
 
@@ -544,7 +548,8 @@ implementation
                  end;
                  end;
             end;
             end;
         until not again;
         until not again;
-        if (stoAllowTypeDef in options)and(m_delphi in current_settings.modeswitches) then
+        if ([stoAllowSpecialization,stoAllowTypeDef] * options <> []) and
+           (m_delphi in current_settings.modeswitches) then
           dospecialize:=token=_LSHARPBRACKET;
           dospecialize:=token=_LSHARPBRACKET;
         if dospecialize then
         if dospecialize then
           generate_specialization(def,stoParseClassParent in options)
           generate_specialization(def,stoParseClassParent in options)
@@ -753,17 +758,15 @@ implementation
             _CLASS:
             _CLASS:
               begin
               begin
                 is_classdef:=false;
                 is_classdef:=false;
-                { read class method }
-                if try_to_consume(_CLASS) then
-                 begin
-                   { class modifier is only allowed for procedures, functions, }
-                   { constructors, destructors, fields and properties          }
-                   if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR,_OPERATOR]) and
-                      not((token=_ID) and (idtoken=_OPERATOR)) then
-                     Message(parser_e_procedure_or_function_expected);
-
-                   is_classdef:=true;
-                 end;
+                { read class method/field/property }
+                consume(_CLASS);
+                { class modifier is only allowed for procedures, functions, }
+                { constructors, destructors, fields and properties          }
+                if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR,_OPERATOR]) and
+                   not((token=_ID) and (idtoken=_OPERATOR)) then
+                  Message(parser_e_procedure_or_function_expected);
+
+                is_classdef:=true;
               end;
               end;
             _PROCEDURE,
             _PROCEDURE,
             _FUNCTION:
             _FUNCTION:
@@ -940,8 +943,7 @@ implementation
            old_block_type:=block_type;
            old_block_type:=block_type;
            dospecialize:=false;
            dospecialize:=false;
            { use of current parsed object:
            { use of current parsed object:
-              - classes can be used also in classes
-              - objects can be parameters }
+             classes, objects, records can be used also in themself }
            if (token=_ID) then
            if (token=_ID) then
              begin
              begin
                structdef:=current_structdef;
                structdef:=current_structdef;

+ 4 - 1
compiler/rautils.pas

@@ -65,7 +65,7 @@ Function SearchLabel(const s: string; var hl: tasmlabel;emit:boolean): boolean;
 
 
 type
 type
   TOprType=(OPR_NONE,OPR_CONSTANT,OPR_SYMBOL,OPR_LOCAL,
   TOprType=(OPR_NONE,OPR_CONSTANT,OPR_SYMBOL,OPR_LOCAL,
-            OPR_REFERENCE,OPR_REGISTER,OPR_REGLIST,OPR_COND,OPR_REGSET,OPR_SHIFTEROP);
+            OPR_REFERENCE,OPR_REGISTER,OPR_REGLIST,OPR_COND,OPR_REGSET,OPR_SHIFTEROP,OPR_MODEFLAGS);
 
 
   TOprRec = record
   TOprRec = record
     case typ:TOprType of
     case typ:TOprType of
@@ -88,6 +88,7 @@ type
       OPR_REGSET    : (regset : tcpuregisterset; regtype: tregistertype; subreg: tsubregister);
       OPR_REGSET    : (regset : tcpuregisterset; regtype: tregistertype; subreg: tsubregister);
       OPR_SHIFTEROP : (shifterop : tshifterop);
       OPR_SHIFTEROP : (shifterop : tshifterop);
       OPR_COND      : (cc : tasmcond);
       OPR_COND      : (cc : tasmcond);
+      OPR_MODEFLAGS : (flags : tcpumodeflags);
 {$endif arm}
 {$endif arm}
   end;
   end;
 
 
@@ -1067,6 +1068,8 @@ end;
                 ai.loadshifterop(i-1,shifterop);
                 ai.loadshifterop(i-1,shifterop);
               OPR_COND:
               OPR_COND:
                 ai.loadconditioncode(i-1,cc);
                 ai.loadconditioncode(i-1,cc);
+              OPR_MODEFLAGS:
+                ai.loadmodeflags(i-1,flags);
 {$endif ARM}
 {$endif ARM}
               { ignore wrong operand }
               { ignore wrong operand }
               OPR_NONE:
               OPR_NONE:

+ 5 - 3
compiler/symconst.pas

@@ -239,7 +239,9 @@ type
     potype_procedure,
     potype_procedure,
     potype_function,
     potype_function,
     potype_class_constructor, { class constructor }
     potype_class_constructor, { class constructor }
-    potype_class_destructor   { class destructor  }
+    potype_class_destructor,  { class destructor  }
+    potype_propgetter,        { Dispinterface property accessors }
+    potype_propsetter
   );
   );
   tproctypeoptions=set of tproctypeoption;
   tproctypeoptions=set of tproctypeoption;
 
 
@@ -389,8 +391,8 @@ type
     ppo_hasparameters,
     ppo_hasparameters,
     ppo_implements,
     ppo_implements,
     ppo_enumerator_current,
     ppo_enumerator_current,
-    ppo_dispid_read,
-    ppo_dispid_write
+    ppo_dispid_read,              { no longer used }
+    ppo_dispid_write              { no longer used }
   );
   );
   tpropertyoptions=set of tpropertyoption;
   tpropertyoptions=set of tpropertyoption;
 
 

+ 123 - 10
compiler/symdef.pas

@@ -186,9 +186,13 @@ interface
           destructor destroy; override;
           destructor destroy; override;
           procedure check_forwards; virtual;
           procedure check_forwards; virtual;
           function find_procdef_bytype(pt:tproctypeoption): tprocdef;
           function find_procdef_bytype(pt:tproctypeoption): tprocdef;
-          function  GetSymtable(t:tGetSymtable):TSymtable;override;
+          function GetSymtable(t:tGetSymtable):TSymtable;override;
           function is_packed:boolean;
           function is_packed:boolean;
           function RttiName: string;
           function RttiName: string;
+          { enumerator support }
+          function search_enumerator_get: tprocdef; virtual;
+          function search_enumerator_move: tprocdef; virtual;
+          function search_enumerator_current: tsym; virtual;
        end;
        end;
 
 
        trecorddef = class(tabstractrecorddef)
        trecorddef = class(tabstractrecorddef)
@@ -322,9 +326,9 @@ interface
           { dispinterface support }
           { dispinterface support }
           function get_next_dispid: longint;
           function get_next_dispid: longint;
           { enumerator support }
           { enumerator support }
-          function search_enumerator_get: tprocdef;
-          function search_enumerator_move: tprocdef;
-          function search_enumerator_current: tsym;
+          function search_enumerator_get: tprocdef; override;
+          function search_enumerator_move: tprocdef; override;
+          function search_enumerator_current: tsym; override;
           { WPO }
           { WPO }
           procedure register_created_object_type;override;
           procedure register_created_object_type;override;
           procedure register_maybe_created_object_type;
           procedure register_maybe_created_object_type;
@@ -714,6 +718,8 @@ interface
        class_tobject : tobjectdef;
        class_tobject : tobjectdef;
        { pointer to the ancestor of all COM interfaces }
        { pointer to the ancestor of all COM interfaces }
        interface_iunknown : tobjectdef;
        interface_iunknown : tobjectdef;
+       { pointer to the ancestor of all dispinterfaces }
+       interface_idispatch : tobjectdef;
        { pointer to the TGUID type
        { pointer to the TGUID type
          of all interfaces         }
          of all interfaces         }
        rec_tguid : trecorddef;
        rec_tguid : trecorddef;
@@ -775,6 +781,7 @@ interface
 
 
     { should be in the types unit, but the types unit uses the node stuff :( }
     { should be in the types unit, but the types unit uses the node stuff :( }
     function is_interfacecom(def: tdef): boolean;
     function is_interfacecom(def: tdef): boolean;
+    function is_interfacecom_or_dispinterface(def: tdef): boolean;
     function is_interfacecorba(def: tdef): boolean;
     function is_interfacecorba(def: tdef): boolean;
     function is_interface(def: tdef): boolean;
     function is_interface(def: tdef): boolean;
     function is_dispinterface(def: tdef): boolean;
     function is_dispinterface(def: tdef): boolean;
@@ -2687,6 +2694,101 @@ implementation
         until tmp=nil;
         until tmp=nil;
       end;
       end;
 
 
+    function tabstractrecorddef.search_enumerator_get: tprocdef;
+      var
+        sym : tsym;
+        i : integer;
+        pd : tprocdef;
+        hashedid : THashedIDString;
+      begin
+        result:=nil;
+        hashedid.id:='GETENUMERATOR';
+        sym:=tsym(symtable.FindWithHash(hashedid));
+        if assigned(sym) and (sym.typ=procsym) then
+          begin
+            for i := 0 to Tprocsym(sym).ProcdefList.Count - 1 do
+            begin
+              pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
+              if (pd.proctypeoption = potype_function) and
+                 (is_class_or_interface_or_object(pd.returndef) or is_record(pd.returndef)) and
+                 (pd.visibility >= vis_public) then
+              begin
+                result:=pd;
+                exit;
+              end;
+            end;
+          end;
+      end;
+
+    function tabstractrecorddef.search_enumerator_move: tprocdef;
+      var
+        sym : tsym;
+        i : integer;
+        pd : tprocdef;
+        hashedid : THashedIDString;
+      begin
+        result:=nil;
+        // first search for po_enumerator_movenext method modifier
+        // then search for public function MoveNext: Boolean
+        for i:=0 to symtable.SymList.Count-1 do
+          begin
+            sym:=TSym(symtable.SymList[i]);
+            if (sym.typ=procsym) then
+            begin
+              pd:=Tprocsym(sym).find_procdef_byoptions([po_enumerator_movenext]);
+              if assigned(pd) then
+                begin
+                  result:=pd;
+                  exit;
+                end;
+            end;
+          end;
+        hashedid.id:='MOVENEXT';
+        sym:=tsym(symtable.FindWithHash(hashedid));
+        if assigned(sym) and (sym.typ=procsym) then
+          begin
+            for i:=0 to Tprocsym(sym).ProcdefList.Count-1 do
+            begin
+              pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
+              if (pd.proctypeoption = potype_function) and
+                 is_boolean(pd.returndef) and
+                 (pd.minparacount = 0) and
+                 (pd.visibility >= vis_public) then
+              begin
+                result:=pd;
+                exit;
+              end;
+            end;
+          end;
+      end;
+
+    function tabstractrecorddef.search_enumerator_current: tsym;
+      var
+        sym: tsym;
+        i: integer;
+        hashedid : THashedIDString;
+      begin
+        result:=nil;
+        // first search for ppo_enumerator_current property modifier
+        // then search for public property Current
+        for i:=0 to symtable.SymList.Count-1 do
+          begin
+            sym:=TSym(symtable.SymList[i]);
+            if (sym.typ=propertysym) and (ppo_enumerator_current in tpropertysym(sym).propoptions) then
+            begin
+              result:=sym;
+              exit;
+            end;
+          end;
+        hashedid.id:='CURRENT';
+        sym:=tsym(symtable.FindWithHash(hashedid));
+        if assigned(sym) and (sym.typ=propertysym) and
+           (sym.visibility >= vis_public) and not tpropertysym(sym).propaccesslist[palt_read].empty then
+          begin
+            result:=sym;
+            exit;
+          end;
+      end;
 
 
 {***************************************************************************
 {***************************************************************************
                                   trecorddef
                                   trecorddef
@@ -4145,9 +4247,12 @@ implementation
             (objname^='TOBJECT') then
             (objname^='TOBJECT') then
            class_tobject:=self;
            class_tobject:=self;
          if (childof=nil) and
          if (childof=nil) and
-            (objecttype=odt_interfacecom) and
-            (objname^='IUNKNOWN') then
-           interface_iunknown:=self;
+            (objecttype=odt_interfacecom) then
+            if (objname^='IUNKNOWN') then
+              interface_iunknown:=self
+            else
+            if (objname^='IDISPATCH') then
+              interface_idispatch:=self;
          if (childof=nil) and
          if (childof=nil) and
             (objecttype=odt_objcclass) and
             (objecttype=odt_objcclass) and
             (objname^='PROTOCOL') then
             (objname^='PROTOCOL') then
@@ -4669,7 +4774,7 @@ implementation
         odt_objcclass,
         odt_objcclass,
         odt_objcprotocol:
         odt_objcprotocol:
           vmtmethodoffset:=0;
           vmtmethodoffset:=0;
-        odt_interfacecom,odt_interfacecorba:
+        odt_interfacecom,odt_interfacecorba,odt_dispinterface:
           vmtmethodoffset:=index*sizeof(pint);
           vmtmethodoffset:=index*sizeof(pint);
         else
         else
 {$ifdef WITHDMT}
 {$ifdef WITHDMT}
@@ -4692,9 +4797,9 @@ implementation
     function tobjectdef.needs_inittable : boolean;
     function tobjectdef.needs_inittable : boolean;
       begin
       begin
          case objecttype of
          case objecttype of
-            odt_dispinterface,
             odt_class :
             odt_class :
               needs_inittable:=false;
               needs_inittable:=false;
+            odt_dispinterface,
             odt_interfacecom:
             odt_interfacecom:
               needs_inittable:=true;
               needs_inittable:=true;
             odt_interfacecorba:
             odt_interfacecorba:
@@ -4852,7 +4957,7 @@ implementation
                 begin
                 begin
                   pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
                   pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
                   if (pd.proctypeoption = potype_function) and
                   if (pd.proctypeoption = potype_function) and
-                     is_class_or_interface_or_object(pd.returndef) and
+                     (is_class_or_interface_or_object(pd.returndef) or is_record(pd.returndef)) and
                      (pd.visibility >= vis_public) then
                      (pd.visibility >= vis_public) then
                   begin
                   begin
                     result:=pd;
                     result:=pd;
@@ -5388,6 +5493,14 @@ implementation
           (tobjectdef(def).objecttype=odt_interfacecom);
           (tobjectdef(def).objecttype=odt_interfacecom);
       end;
       end;
 
 
+    function is_interfacecom_or_dispinterface(def: tdef): boolean;
+      begin
+        is_interfacecom_or_dispinterface:=
+          assigned(def) and
+          (def.typ=objectdef) and
+          (tobjectdef(def).objecttype in [odt_interfacecom,odt_dispinterface]);
+      end;
+
     function is_interfacecorba(def: tdef): boolean;
     function is_interfacecorba(def: tdef): boolean;
       begin
       begin
         is_interfacecorba:=
         is_interfacecorba:=

+ 2 - 2
compiler/symsym.pas

@@ -812,9 +812,9 @@ implementation
             pd:=tprocdef(ProcdefList[i]);
             pd:=tprocdef(ProcdefList[i]);
             if (pd.owner.symtabletype=staticsymtable) and not pd.owner.iscurrentunit then
             if (pd.owner.symtabletype=staticsymtable) and not pd.owner.iscurrentunit then
               continue;
               continue;
-            if not is_class_or_interface_or_object(pd.returndef) then
+            if not (is_class_or_interface_or_object(pd.returndef) or is_record(pd.returndef)) then
               continue;
               continue;
-            current := tpropertysym(tobjectdef(pd.returndef).search_enumerator_current);
+            current := tpropertysym(tabstractrecorddef(pd.returndef).search_enumerator_current);
             if (current = nil) then
             if (current = nil) then
               continue;
               continue;
             // compare current result def with the todef
             // compare current result def with the todef

+ 28 - 4
compiler/symtable.pas

@@ -2297,9 +2297,7 @@ implementation
       end;
       end;
 
 
 
 
-    function search_assignment_operator(from_def,to_def:Tdef;explicit:boolean):Tprocdef;
-      const
-        op_token:array[boolean] of ttoken=(_ASSIGNMENT,_OP_EXPLICIT);
+    function search_specific_assignment_operator(assignment_type:ttoken;from_def,to_def:Tdef):Tprocdef;
       var
       var
         sym : Tprocsym;
         sym : Tprocsym;
         hashedid : THashedIDString;
         hashedid : THashedIDString;
@@ -2309,7 +2307,7 @@ implementation
         bestpd : tprocdef;
         bestpd : tprocdef;
         stackitem : psymtablestackitem;
         stackitem : psymtablestackitem;
       begin
       begin
-        hashedid.id:=overloaded_names[op_token[explicit]];
+        hashedid.id:=overloaded_names[assignment_type];
         besteq:=te_incompatible;
         besteq:=te_incompatible;
         bestpd:=nil;
         bestpd:=nil;
         stackitem:=symtablestack.stack;
         stackitem:=symtablestack.stack;
@@ -2337,6 +2335,31 @@ implementation
       end;
       end;
 
 
 
 
+    function search_assignment_operator(from_def,to_def:Tdef;explicit:boolean):Tprocdef;
+      begin
+        { search record/object symtable first for a suitable operator }
+        if from_def.typ in [recorddef,objectdef] then
+          symtablestack.push(tabstractrecorddef(from_def).symtable);
+        if to_def.typ in [recorddef,objectdef] then
+          symtablestack.push(tabstractrecorddef(to_def).symtable);
+
+        { if type conversion is explicit then search first for explicit
+          operator overload and if not found then use implicit operator }
+        if explicit then
+          result:=search_specific_assignment_operator(_OP_EXPLICIT,from_def,to_def)
+        else
+          result:=nil;
+        if result=nil then
+          result:=search_specific_assignment_operator(_ASSIGNMENT,from_def,to_def);
+
+        { restore symtable stack }
+        if to_def.typ in [recorddef,objectdef] then
+          symtablestack.pop(tabstractrecorddef(to_def).symtable);
+        if from_def.typ in [recorddef,objectdef] then
+          symtablestack.pop(tabstractrecorddef(from_def).symtable);
+      end;
+
+
     function search_enumerator_operator(from_def,to_def:Tdef): Tprocdef;
     function search_enumerator_operator(from_def,to_def:Tdef): Tprocdef;
       var
       var
         sym : Tprocsym;
         sym : Tprocsym;
@@ -2905,6 +2928,7 @@ implementation
        { set some global vars to nil, might be important for the ide }
        { set some global vars to nil, might be important for the ide }
        class_tobject:=nil;
        class_tobject:=nil;
        interface_iunknown:=nil;
        interface_iunknown:=nil;
+       interface_idispatch:=nil;
        rec_tguid:=nil;
        rec_tguid:=nil;
        dupnr:=0;
        dupnr:=0;
      end;
      end;

+ 67 - 0
compiler/systems/i_embed.pas

@@ -152,6 +152,68 @@ unit i_embed;
             abi : abi_default
             abi : abi_default
           );
           );
 
 
+       system_i386_embedded_info : tsysteminfo =
+          (
+            system       : system_i386_embedded;
+            name         : 'Embedded';
+            shortname    : 'embedded';
+            flags        : [tf_needs_symbol_size,tf_files_case_sensitive
+	                          ,tf_smartlink_sections];
+            cpu          : cpu_i386;
+            unit_env     : '';
+            extradefines : '';
+            exeext       : '';
+            defext       : '.def';
+            scriptext    : '.sh';
+            smartext     : '.sl';
+            unitext      : '.ppu';
+            unitlibext   : '.ppl';
+            asmext       : '.s';
+            objext       : '.o';
+            resext       : '.res';
+            resobjext    : '.or';
+            sharedlibext : '.so';
+            staticlibext : '.a';
+            staticlibprefix : 'libp';
+            sharedlibprefix : 'lib';
+            sharedClibext : '.so';
+            staticClibext : '.a';
+            staticClibprefix : 'lib';
+            sharedClibprefix : 'lib';
+            importlibprefix : 'libimp';
+            importlibext : '.a';
+            Cprefix      : '';
+            newline      : #10;
+            dirsep       : '/';
+            assem        : as_i386_elf32;
+            assemextern  : as_gas;
+            link         : nil;
+            linkextern   : nil;
+            ar           : ar_gnu_ar;
+            res          : res_none;
+            dbg          : dbg_stabs;
+            script       : script_unix;
+            endian       : endian_little;
+            alignment    :
+              (
+                procalign       : 16;
+                loopalign       : 4;
+                jumpalign       : 0;
+                constalignmin   : 0;
+                constalignmax   : 8;
+                varalignmin     : 0;
+                varalignmax     : 16;
+                localalignmin   : 4;
+                localalignmax   : 8;
+                recordalignmin  : 0;
+                recordalignmax  : 16;
+                maxCrecordalign : 4
+              );
+            first_parm_offset : 8;
+            stacksize    : 4096;
+            abi : abi_default
+          );
+
   implementation
   implementation
 
 
 initialization
 initialization
@@ -165,4 +227,9 @@ initialization
     set_source_info(system_avr_embedded_info);
     set_source_info(system_avr_embedded_info);
   {$endif embedded}
   {$endif embedded}
 {$endif CPUAVR}
 {$endif CPUAVR}
+{$ifdef CPUI386}
+  {$ifdef embedded}
+    set_source_info(system_i386_embedded_info);
+  {$endif embedded}
+{$endif CPUI386}
 end.
 end.

+ 44 - 4
compiler/systems/t_embed.pas

@@ -82,11 +82,11 @@ Var
 begin
 begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
   linklibc:=(SharedLibFiles.Find('c')<>nil);
   linklibc:=(SharedLibFiles.Find('c')<>nil);
-{$ifdef ARM}
+{$if defined(ARM) or defined(i386)}
   prtobj:='';
   prtobj:='';
-{$else ARM}
+{$else}
   prtobj:='prt0';
   prtobj:='prt0';
-{$endif ARM}
+{$endif}
   cprtobj:='cprt0';
   cprtobj:='cprt0';
   if linklibc then
   if linklibc then
     prtobj:=cprtobj;
     prtobj:=cprtobj;
@@ -293,6 +293,41 @@ begin
       Add('_end = .;');
       Add('_end = .;');
     end;
     end;
 {$endif ARM}
 {$endif ARM}
+{$ifdef i386}
+  with linkres do
+    begin
+      Add('ENTRY(_START)');
+      Add('SECTIONS');
+      Add('{');
+      Add('     . = 0x100000;');
+      Add('     .text ALIGN (0x1000) :');
+      Add('    {');
+      Add('    KEEP(*(.init, .init.*))');
+      Add('    *(.text, .text.*)');
+      Add('    *(.strings)');
+      Add('    *(.rodata, .rodata.*)');
+      Add('    *(.comment)');
+      Add('    _etext = .;');
+      Add('    }');
+      Add('    .data ALIGN (0x1000) :');
+      Add('    {');
+      Add('    _data = .;');
+      Add('    *(.data, .data.*)');
+      Add('    KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
+      Add('    _edata = .;');
+      Add('    }');
+      Add('    . = ALIGN(4);');
+      Add('    .bss :');
+      Add('    {');
+      Add('    _bss_start = .;');
+      Add('    *(.bss, .bss.*)');
+      Add('    *(COMMON)');
+      Add('    }');
+      Add('_bss_end = . ;');
+      Add('}');
+      Add('_end = .;');
+    end;
+{$endif I386}
 
 
   { Write and Close response }
   { Write and Close response }
   linkres.writetodisk;
   linkres.writetodisk;
@@ -354,7 +389,7 @@ begin
    DeleteFile(outputexedir+Info.ResName);
    DeleteFile(outputexedir+Info.ResName);
 
 
 { Post process }
 { Post process }
-  if success then
+  if success and (target_info.system=system_arm_embedded) then
     begin
     begin
       success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O ihex '+
       success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O ihex '+
         ChangeFileExt(current_module.exefilename^,'.elf')+' '+
         ChangeFileExt(current_module.exefilename^,'.elf')+' '+
@@ -379,4 +414,9 @@ initialization
   RegisterExternalLinker(system_avr_embedded_info,TlinkerEmbedded);
   RegisterExternalLinker(system_avr_embedded_info,TlinkerEmbedded);
   RegisterTarget(system_avr_embedded_info);
   RegisterTarget(system_avr_embedded_info);
 {$endif avr}
 {$endif avr}
+
+{$ifdef i386}
+  RegisterExternalLinker(system_i386_embedded_info,TlinkerEmbedded);
+  RegisterTarget(system_i386_embedded_info);
+{$endif i386}
 end.
 end.

+ 1 - 1
compiler/x86/x86ins.dat

@@ -930,7 +930,7 @@ mem                   \300\2\x0F\x01\203              286,PRIV
 
 
 [LJMP,ljmp]
 [LJMP,ljmp]
 (Ch_ROp1, Ch_None, Ch_None)
 (Ch_ROp1, Ch_None, Ch_None)
-rm16|32|64            \300\320\1\xFF\204              8086
+rm16|32|64            \300\320\1\xFF\205              8086
 mem|far               \300\320\1\xFF\205              8086
 mem|far               \300\320\1\xFF\205              8086
 mem|near              \300\320\1\xFF\204              8086
 mem|near              \300\320\1\xFF\204              8086
 
 

+ 1 - 1
compiler/x86_64/x8664tab.inc

@@ -2692,7 +2692,7 @@
     opcode  : A_LJMP;
     opcode  : A_LJMP;
     ops     : 1;
     ops     : 1;
     optypes : (ot_regmem or ot_bits16 or ot_bits32 or ot_bits64,ot_none,ot_none);
     optypes : (ot_regmem or ot_bits16 or ot_bits32 or ot_bits64,ot_none,ot_none);
-    code    : #192#208#1#255#132;
+    code    : #192#208#1#255#133;
     flags   : if_8086
     flags   : if_8086
   ),
   ),
   (
   (

+ 50 - 0
packages/fcl-base/src/base64.pp

@@ -87,6 +87,9 @@ type
   EBase64DecodingException = class(Exception)
   EBase64DecodingException = class(Exception)
   end;
   end;
 
 
+function EncodeStringBase64(const s:string):String;
+function DecodeStringBase64(const s:string):String;
+
 implementation
 implementation
 
 
 uses
 uses
@@ -420,5 +423,52 @@ begin
   raise EStreamError.Create('Invalid stream operation');
   raise EStreamError.Create('Invalid stream operation');
 end;
 end;
 
 
+function DecodeStringBase64(const s:string):String;
+
+var 
+  Instream, 
+  Outstream : TStringStream;
+  Decoder   : TBase64DecodingStream;
+begin
+  Instream:=TStringStream.Create(s);
+  try
+    Outstream:=TStringStream.Create('');
+    try 
+      Decoder:=TBase64DecodingStream.Create(Instream,bdmMIME);
+      try
+         Outstream.CopyFrom(Decoder,Decoder.Size);
+         Outstream.Position:=0;
+         Result:=Outstream.ReadString(Outstream.Size);
+      finally
+        Decoder.Free;
+        end;
+    finally 
+     Outstream.Free;
+     end;
+  finally 
+    Instream.Free;
+    end;
+end;
+
+function EncodeStringBase64(const s:string):String;
+
+var
+  Outstream : TStringStream;
+  Encoder   : TBase64EncodingStream;
+begin
+  Outstream:=TStringStream.Create('');
+  try
+    Encoder:=TBase64EncodingStream.create(outstream);
+    try 
+      Encoder.Write(s[1],Length(s));
+    finally 
+      Encoder.Free;
+      end;
+    Outstream.Position:=0;
+    Result:=Outstream.ReadString(Outstream.Size);
+  finally
+    Outstream.free;
+    end;
+end;
 
 
 end.
 end.

+ 1 - 0
packages/fcl-base/src/win/fileinfo.pp

@@ -110,6 +110,7 @@ var struSize : Dword;
 begin
 begin
   ts := TStringList.Create;
   ts := TStringList.Create;
   try
   try
+    ts.add('Comments');
     ts.add('CompanyName');
     ts.add('CompanyName');
     ts.add('FileDescription');
     ts.add('FileDescription');
     ts.add('FileVersion');
     ts.add('FileVersion');

+ 6 - 2
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -99,7 +99,7 @@ Var
 implementation
 implementation
 
 
 uses
 uses
-  dbconst, sysutils, typinfo, dateutils;
+  dbconst, sysutils, dateutils;
  
  
 type
 type
 
 
@@ -190,7 +190,7 @@ begin
                 checkerror(sqlite3_bind_blob(fstatement,I,pcharstr(str1), length(str1),@freebindstring));
                 checkerror(sqlite3_bind_blob(fstatement,I,pcharstr(str1), length(str1),@freebindstring));
                 end; 
                 end; 
       else 
       else 
-        databaseerror('Parameter type '+getenumname(typeinfo(tfieldtype),ord(P.datatype))+' not supported.');
+        DatabaseErrorFmt(SUnsupportedParameter, [Fieldtypenames[P.DataType], Self]);
       end; { Case }
       end; { Case }
     end;   
     end;   
 end;
 end;
@@ -722,6 +722,7 @@ var
 
 
 begin
 begin
   PKFields:=TStringList.Create;
   PKFields:=TStringList.Create;
+  PKFields.Delimiter:=';';
   IXFields:=TStringList.Create;
   IXFields:=TStringList.Create;
   IXFields.Delimiter:=';';
   IXFields.Delimiter:=';';
 
 
@@ -751,6 +752,9 @@ begin
     IndexDefs.Add(IndexName, IXFields.DelimitedText, IndexOptions);
     IndexDefs.Add(IndexName, IXFields.DelimitedText, IndexOptions);
     end;
     end;
 
 
+  if PKFields.Count > 0 then //in special case for INTEGER PRIMARY KEY column, unique index is not created
+    IndexDefs.Add('$PRIMARY_KEY$', PKFields.DelimitedText, [ixPrimary,ixUnique]);
+
   PKFields.Free;
   PKFields.Free;
   IXFields.Free;
   IXFields.Free;
 end;
 end;

+ 8 - 8
packages/fcl-image/src/fpcanvas.inc

@@ -582,16 +582,16 @@ end;
 
 
 procedure TFPCustomCanvas.CopyRect (x,y:integer; canvas:TFPCustomCanvas;
 procedure TFPCustomCanvas.CopyRect (x,y:integer; canvas:TFPCustomCanvas;
   SourceRect:TRect);
   SourceRect:TRect);
-var xx,r,t : integer;
+var yy,r,t : integer;
 begin
 begin
   SortRect (SourceRect);
   SortRect (SourceRect);
-  with SourceRect do
-    for r := left to right do
-      begin
-      xx := r - left + x;
-      for t := bottom to top do
-        colors[xx,(t - bottom + y)] := canvas.colors[r,t];
-      end;
+  with SourceRect do begin
+    for t := top to bottom do begin
+      yy := t - top + y;
+      for r := left to right do
+        colors[r - left + x,yy] := canvas.colors[r,t];
+    end;
+  end;
 end;
 end;
 
 
 procedure TFPCustomCanvas.Draw (x,y:integer; image:TFPCustomImage);
 procedure TFPCustomCanvas.Draw (x,y:integer; image:TFPCustomImage);

+ 13 - 0
packages/fcl-process/src/process.pp

@@ -41,6 +41,10 @@ Type
 
 
 
 
 Type
 Type
+  {$ifdef UNIX}
+  TProcessForkEvent = procedure;
+  {$endif UNIX}
+
   TProcess = Class (TComponent)
   TProcess = Class (TComponent)
   Private
   Private
     FProcessOptions : TProcessOptions;
     FProcessOptions : TProcessOptions;
@@ -58,6 +62,9 @@ Type
     FEnvironment : Tstrings;
     FEnvironment : Tstrings;
     FShowWindow : TShowWindowOptions;
     FShowWindow : TShowWindowOptions;
     FInherithandles : Boolean;
     FInherithandles : Boolean;
+    {$ifdef UNIX}
+    FForkEvent : TProcessForkEvent;
+    {$endif UNIX}
     FProcessPriority : TProcessPriority;
     FProcessPriority : TProcessPriority;
     dwXCountchars,
     dwXCountchars,
     dwXSize,
     dwXSize,
@@ -113,6 +120,9 @@ Type
     Property Stderr : TinputPipeStream  Read FStderrStream;
     Property Stderr : TinputPipeStream  Read FStderrStream;
     Property ExitStatus : Integer Read GetExitStatus;
     Property ExitStatus : Integer Read GetExitStatus;
     Property InheritHandles : Boolean Read FInheritHandles Write FInheritHandles;
     Property InheritHandles : Boolean Read FInheritHandles Write FInheritHandles;
+    {$ifdef UNIX}
+    property OnForkEvent : TProcessForkEvent Read FForkEvent Write FForkEvent;
+    {$endif UNIX}
   Published
   Published
     Property Active : Boolean Read GetRunning Write SetActive;
     Property Active : Boolean Read GetRunning Write SetActive;
     Property ApplicationName : String Read FApplicationName Write SetApplicationName;
     Property ApplicationName : String Read FApplicationName Write SetApplicationName;
@@ -163,6 +173,9 @@ begin
   FProcessPriority:=ppNormal;
   FProcessPriority:=ppNormal;
   FShowWindow:=swoNone;
   FShowWindow:=swoNone;
   FInheritHandles:=True;
   FInheritHandles:=True;
+  {$ifdef UNIX}
+  FForkEvent:=nil;
+  {$endif UNIX}
   FEnvironment:=TStringList.Create;
   FEnvironment:=TStringList.Create;
 end;
 end;
 
 

+ 2 - 0
packages/fcl-process/src/unix/process.inc

@@ -360,6 +360,8 @@ begin
                 safefpdup2(fd,1);
                 safefpdup2(fd,1);
                 safefpdup2(fd,2);
                 safefpdup2(fd,2);
               end;
               end;
+            if Assigned(FForkEvent) then
+              FForkEvent;
             if (poRunSuspended in Options) then
             if (poRunSuspended in Options) then
               sigraise(SIGSTOP);
               sigraise(SIGSTOP);
             if FEnv<>Nil then
             if FEnv<>Nil then

+ 1 - 0
packages/fcl-res/src/elfwriter.pp

@@ -487,6 +487,7 @@ begin
   fSections.Add('.text',SHT_PROGBITS,SHF_ALLOC or SHF_EXECINSTR,aStream.Position,0,4);
   fSections.Add('.text',SHT_PROGBITS,SHF_ALLOC or SHF_EXECINSTR,aStream.Position,0,4);
   fSections.Add('.data',SHT_PROGBITS,SHF_ALLOC or SHF_WRITE,aStream.Position,0,4);
   fSections.Add('.data',SHT_PROGBITS,SHF_ALLOC or SHF_WRITE,aStream.Position,0,4);
   fSections.Add('.bss', SHT_NOBITS,SHF_ALLOC or SHF_WRITE,aStream.Position,0,4);
   fSections.Add('.bss', SHT_NOBITS,SHF_ALLOC or SHF_WRITE,aStream.Position,0,4);
+  fSections.Add('.note.GNU-stack', SHT_PROGBITS,0,aStream.Position,0,1);
 end;
 end;
 
 
 procedure TAbstractElfSubWriter.WriteStrTab(aStream: TStream);
 procedure TAbstractElfSubWriter.WriteStrTab(aStream: TStream);

+ 5 - 0
packages/fcl-web/src/base/fphtml.pp

@@ -145,6 +145,8 @@ type
 
 
   TForeachContentProducerProc = procedure(const AContentProducer: THTMLContentProducer) of object;
   TForeachContentProducerProc = procedure(const AContentProducer: THTMLContentProducer) of object;
 
 
+  { IHTMLContentProducerContainer }
+
   IHTMLContentProducerContainer = interface
   IHTMLContentProducerContainer = interface
    ['{8B4D8AE0-4873-49BF-B677-D03C8A02CDA5}']
    ['{8B4D8AE0-4873-49BF-B677-D03C8A02CDA5}']
     procedure AddContentProducer(AContentProducer: THTMLContentProducer);
     procedure AddContentProducer(AContentProducer: THTMLContentProducer);
@@ -152,6 +154,8 @@ type
     function ExchangeContentProducers(Child1, Child2: THTMLContentProducer) : boolean;
     function ExchangeContentProducers(Child1, Child2: THTMLContentProducer) : boolean;
     function MoveContentProducer(MoveElement, MoveBeforeElement: THTMLContentProducer) : boolean;
     function MoveContentProducer(MoveElement, MoveBeforeElement: THTMLContentProducer) : boolean;
     procedure ForeachContentProducer(AForeachChildsProc: TForeachContentProducerProc; Recursive: boolean);
     procedure ForeachContentProducer(AForeachChildsProc: TForeachContentProducerProc; Recursive: boolean);
+
+    function ProduceContent : string;
   end;
   end;
 
 
   { THTMLContentProducer }
   { THTMLContentProducer }
@@ -739,6 +743,7 @@ begin
   ChildIndex2:=GetContentProducerList.IndexOf(MoveBeforeElement);
   ChildIndex2:=GetContentProducerList.IndexOf(MoveBeforeElement);
   if (ChildIndex2=-1) then
   if (ChildIndex2=-1) then
     Exit;
     Exit;
+  if ChildIndex2>ChildIndex1 then dec(ChildIndex2);
   GetContentProducerList.Move(ChildIndex1,ChildIndex2);
   GetContentProducerList.Move(ChildIndex1,ChildIndex2);
   result := true;
   result := true;
 end;
 end;

+ 35 - 2
packages/fcl-web/src/base/webpage.pp

@@ -14,10 +14,23 @@ type
   TAjaxRequestResponseEvent = procedure(Sender: TObject; ARequest: TRequest; AResponse: TAjaxResponse) of object;
   TAjaxRequestResponseEvent = procedure(Sender: TObject; ARequest: TRequest; AResponse: TAjaxResponse) of object;
 
 
 type
 type
+
+  { IWebPageDesigner }
+
   IWebPageDesigner = interface(IUnknown)
   IWebPageDesigner = interface(IUnknown)
+  ['{25629DEA-79D5-4165-A0A3-BE6E2BA74442}']
     procedure Invalidate;
     procedure Invalidate;
   end;
   end;
 
 
+  { IHTMLDesignable }
+
+  IHTMLDesignable = interface(IUnknown)
+  ['{C75546D6-9C93-49F0-809F-D29C52CD306D}']
+    function GetDesigner: IWebPageDesigner;
+    procedure SetDesigner(const AValue: IWebPageDesigner);
+    property Designer: IWebPageDesigner read GetDesigner write SetDesigner;
+  end;
+
   { TStandardWebController }
   { TStandardWebController }
 
 
   TStandardWebController = class(TWebController)
   TStandardWebController = class(TWebController)
@@ -41,7 +54,7 @@ type
 
 
   { TWebPage }
   { TWebPage }
 
 
-  TWebPage = class(TDataModule, IHTMLContentProducerContainer)
+  TWebPage = class(TDataModule, IHTMLContentProducerContainer, IHTMLDesignable)
   private
   private
     FAfterAjaxRequest: TAjaxRequestResponseEvent;
     FAfterAjaxRequest: TAjaxRequestResponseEvent;
     FBaseURL: string;
     FBaseURL: string;
@@ -56,8 +69,10 @@ type
     function GetContentProducer(Index: integer): THTMLContentProducer;
     function GetContentProducer(Index: integer): THTMLContentProducer;
     function GetContentProducerList: TFPList;
     function GetContentProducerList: TFPList;
     function GetContentProducers(Index: integer): THTMLContentProducer;
     function GetContentProducers(Index: integer): THTMLContentProducer;
+    function GetDesigner: IWebPageDesigner;
     function GetHasWebController: boolean;
     function GetHasWebController: boolean;
     function GetWebController: TWebController;
     function GetWebController: TWebController;
+    procedure SetDesigner(const AValue: IWebPageDesigner);
   protected
   protected
     procedure DoAfterAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse); virtual;
     procedure DoAfterAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse); virtual;
     procedure DoHandleAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse; var Handled: boolean); virtual;
     procedure DoHandleAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse; var Handled: boolean); virtual;
@@ -69,6 +84,7 @@ type
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
     property ContentProducerList: TFPList read GetContentProducerList;
     property ContentProducerList: TFPList read GetContentProducerList;
   public
   public
+    destructor Destroy; override;
     function ContentProducerCount: integer;
     function ContentProducerCount: integer;
 
 
     function ProduceContent : string;
     function ProduceContent : string;
@@ -82,7 +98,7 @@ type
     procedure HandlePage(ARequest: TRequest; AResponse: TResponse; AWriter: THTMLwriter; AWebModule: TFPWebModule = nil); virtual;
     procedure HandlePage(ARequest: TRequest; AResponse: TResponse; AWriter: THTMLwriter; AWebModule: TFPWebModule = nil); virtual;
     procedure DoBeforeGenerateXML; virtual;
     procedure DoBeforeGenerateXML; virtual;
     procedure CleanupAfterRequest; virtual;
     procedure CleanupAfterRequest; virtual;
-    property Designer: IWebPageDesigner read FDesigner write FDesigner;
+    property Designer: IWebPageDesigner read GetDesigner write SetDesigner;
     property Request: TRequest read FRequest;
     property Request: TRequest read FRequest;
     property ContentProducers[Index: integer]: THTMLContentProducer read GetContentProducer;
     property ContentProducers[Index: integer]: THTMLContentProducer read GetContentProducer;
     property HasWebController: boolean read GetHasWebController;
     property HasWebController: boolean read GetHasWebController;
@@ -246,6 +262,13 @@ begin
       Proc(ContentProducers[i]);
       Proc(ContentProducers[i]);
 end;
 end;
 
 
+destructor TWebPage.Destroy;
+begin
+  inherited Destroy;
+  if assigned(FContentProducers) then
+    FreeAndNil(FContentProducers);
+end;
+
 function TWebPage.ContentProducerCount: integer;
 function TWebPage.ContentProducerCount: integer;
 begin
 begin
   if assigned(FContentProducers) then
   if assigned(FContentProducers) then
@@ -259,6 +282,11 @@ begin
   Result:=THTMLContentProducer(ContentProducerList[Index]);
   Result:=THTMLContentProducer(ContentProducerList[Index]);
 end;
 end;
 
 
+function TWebPage.GetDesigner: IWebPageDesigner;
+begin
+  result := FDesigner;
+end;
+
 function TWebPage.GetHasWebController: boolean;
 function TWebPage.GetHasWebController: boolean;
 begin
 begin
   result := assigned(FWebController);
   result := assigned(FWebController);
@@ -271,6 +299,11 @@ begin
   result := FWebController;
   result := FWebController;
 end;
 end;
 
 
+procedure TWebPage.SetDesigner(const AValue: IWebPageDesigner);
+begin
+  FDesigner := AValue;
+end;
+
 function TWebPage.GetContentProducerList: TFPList;
 function TWebPage.GetContentProducerList: TFPList;
 begin
 begin
   if not assigned(FContentProducers) then
   if not assigned(FContentProducers) then

+ 1 - 1
packages/fcl-xml/src/xmlcfg.pp

@@ -354,7 +354,7 @@ begin
       if not (s[i] in AllowedChars) then
       if not (s[i] in AllowedChars) then
       begin
       begin
         EscapingNecessary := True;
         EscapingNecessary := True;
-	exit;
+        break;
       end;
       end;
   end;
   end;
 
 

+ 1 - 1
packages/fcl-xml/src/xmlread.pp

@@ -1194,7 +1194,7 @@ begin
       Result := True;
       Result := True;
     until False;
     until False;
     FSource.FBuf := p;
     FSource.FBuf := p;
-  until (p^ <> #0) or (not FSource.Reload);
+  until (FSource.FBuf < FSource.FBufEnd) or (not FSource.Reload);
   if (not Result) and Required then
   if (not Result) and Required then
     FatalError('Expected whitespace');
     FatalError('Expected whitespace');
 end;
 end;

+ 1 - 1
packages/fftw/fpmake.pp

@@ -20,7 +20,7 @@ begin
 
 
     P.Version:='2.2.2-0';
     P.Version:='2.2.2-0';
     P.Author := 'Library: Matteo Frigo and Steven G. Johnson, header: Daniel Mantione';
     P.Author := 'Library: Matteo Frigo and Steven G. Johnson, header: Daniel Mantione';
-    P.License := 'Library: MIT, header: LGPL with modification, ';
+    P.License := 'Library: GPL or commercial, header: LGPL with modification, ';
     P.HomepageURL := 'www.freepascal.org';
     P.HomepageURL := 'www.freepascal.org';
     P.Email := '';
     P.Email := '';
     P.Description := 'Library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data';
     P.Description := 'Library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data';

+ 7 - 7
packages/fpvectorial/examples/fpvc_mainform.lfm

@@ -7,12 +7,12 @@ object formVectorialConverter: TformVectorialConverter
   Caption = 'FP Vectorial Converter'
   Caption = 'FP Vectorial Converter'
   ClientHeight = 439
   ClientHeight = 439
   ClientWidth = 240
   ClientWidth = 240
-  LCLVersion = '0.9.29'
+  LCLVersion = '0.9.31'
   object Label1: TLabel
   object Label1: TLabel
     Left = 8
     Left = 8
-    Height = 17
+    Height = 18
     Top = 112
     Top = 112
-    Width = 160
+    Width = 172
     Caption = 'Location of the Input file:'
     Caption = 'Location of the Input file:'
     ParentColor = False
     ParentColor = False
   end
   end
@@ -30,7 +30,7 @@ object formVectorialConverter: TformVectorialConverter
   end
   end
   object editInput: TFileNameEdit
   object editInput: TFileNameEdit
     Left = 8
     Left = 8
-    Height = 22
+    Height = 25
     Top = 128
     Top = 128
     Width = 192
     Width = 192
     DialogOptions = []
     DialogOptions = []
@@ -43,15 +43,15 @@ object formVectorialConverter: TformVectorialConverter
   end
   end
   object Label3: TLabel
   object Label3: TLabel
     Left = 8
     Left = 8
-    Height = 17
+    Height = 18
     Top = 152
     Top = 152
-    Width = 173
+    Width = 184
     Caption = 'Full path of the Output file:'
     Caption = 'Full path of the Output file:'
     ParentColor = False
     ParentColor = False
   end
   end
   object editOutput: TFileNameEdit
   object editOutput: TFileNameEdit
     Left = 8
     Left = 8
-    Height = 22
+    Height = 25
     Top = 168
     Top = 168
     Width = 192
     Width = 192
     DialogOptions = []
     DialogOptions = []

+ 1 - 5
packages/fpvectorial/examples/fpvectorialconverter.lpr

@@ -3,12 +3,8 @@ program fpvectorialconverter;
 {$mode objfpc}{$H+}
 {$mode objfpc}{$H+}
 
 
 uses
 uses
-  {$IFDEF UNIX}{$IFDEF UseCThreads}
-  cthreads,
-  {$ENDIF}{$ENDIF}
   Interfaces, // this includes the LCL widgetset
   Interfaces, // this includes the LCL widgetset
-  Forms, fpvc_mainform
-  { you can add units after this };
+  Forms, fpvc_mainform;
 
 
 {$R *.res}
 {$R *.res}
 
 

+ 623 - 0
packages/fpvectorial/src/dxfvectorialreader.pas

@@ -0,0 +1,623 @@
+{
+Reads DXF files
+
+License: The same modified LGPL as the Free Pascal RTL
+         See the file COPYING.modifiedLGPL for more details
+
+AUTHORS: Felipe Monteiro de Carvalho
+
+DXF is composed by records written in ASCII with the following structure:
+
+0
+SECTION
+section_number
+SECTION_NAME
+<data>
+0
+ENDSEC
+0
+
+after all sections there is:
+
+EOF
+
+}
+unit dxfvectorialreader;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils,
+  fpvectorial;
+
+type
+
+  { Used by tcutils.SeparateString }
+  T10Strings = array[0..9] of shortstring;
+
+  TDXFToken = class;
+
+  TDXFTokens = TFPList;// TDXFToken;
+
+  TDXFToken = class
+    GroupCode: Integer;
+    StrValue: string;
+    FloatValue: double;
+    IntValue: Integer;
+    Childs: TDXFTokens;
+    constructor Create;
+    Destructor Destroy; override;
+  end;
+
+  { TDXFTokenizer }
+
+  TDXFTokenizer = class
+  public
+    Tokens: TDXFTokens;
+    constructor Create;
+    Destructor Destroy; override;
+    procedure ReadFromStrings(AStrings: TStrings);
+    function  IsENTITIES_Subsection(AStr: string): Boolean;
+  end;
+
+  { TvDXFVectorialReader }
+
+  TvDXFVectorialReader = class(TvCustomVectorialReader)
+  private
+    //
+    function  SeparateString(AString: string; ASeparator: Char): T10Strings;
+    procedure ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialDocument);
+    procedure ReadENTITIES_LINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
+    procedure ReadENTITIES_ARC(ATokens: TDXFTokens; AData: TvVectorialDocument);
+    procedure ReadENTITIES_CIRCLE(ATokens: TDXFTokens; AData: TvVectorialDocument);
+    procedure ReadENTITIES_ELLIPSE(ATokens: TDXFTokens; AData: TvVectorialDocument);
+    procedure ReadENTITIES_TEXT(ATokens: TDXFTokens; AData: TvVectorialDocument);
+    function  GetCoordinateValue(AStr: shortstring): Double;
+  public
+    { General reading methods }
+    Tokenizer: TDXFTokenizer;
+    constructor Create; override;
+    Destructor Destroy; override;
+    procedure ReadFromStrings(AStrings: TStrings; AData: TvVectorialDocument); override;
+  end;
+
+implementation
+
+{$define FPVECTORIALDEBUG}
+
+const
+  // Group Codes for ENTITIES
+  DXF_ENTITIES_TYPE = 0;
+  DXF_ENTITIES_HANDLE = 5;
+  DXF_ENTITIES_APPLICATION_GROUP = 102;
+  DXF_ENTITIES_AcDbEntity = 100;
+  DXF_ENTITIES_MODEL_OR_PAPER_SPACE = 67; // default=0=model, 1=paper
+  DXF_ENTITIES_VISIBILITY = 60; // default=0 = Visible, 1 = Invisible
+
+{ TDXFToken }
+
+constructor TDXFToken.Create;
+begin
+  inherited Create;
+
+  Childs := TDXFTokens.Create;
+end;
+
+destructor TDXFToken.Destroy;
+begin
+  Childs.Free;
+
+  inherited Destroy;
+end;
+
+{ TDXFTokenizer }
+
+constructor TDXFTokenizer.Create;
+begin
+  inherited Create;
+
+  Tokens := TDXFTokens.Create;
+end;
+
+destructor TDXFTokenizer.Destroy;
+begin
+  Tokens.Free;
+
+  inherited Destroy;
+end;
+
+procedure TDXFTokenizer.ReadFromStrings(AStrings: TStrings);
+var
+  i: Integer;
+  StrSectionGroupCode, StrSectionName: string;
+  IntSectionGroupCode: Integer;
+  CurTokenBase, NextTokenBase, SectionTokenBase: TDXFTokens;
+  NewToken: TDXFToken;
+  ParserState: Integer;
+begin
+  //  Tokens.ForEachCall(); deletecallback
+  Tokens.Clear;
+
+  CurTokenBase := Tokens;
+  NextTokenBase := Tokens;
+  i := 0;
+  ParserState := 0;
+
+  while i < AStrings.Count - 1 do
+  begin
+    CurTokenBase := NextTokenBase;
+
+    // Now read and process the section name
+    StrSectionGroupCode := AStrings.Strings[i];
+    IntSectionGroupCode := StrToInt(Trim(StrSectionGroupCode));
+    StrSectionName := AStrings.Strings[i+1];
+
+    NewToken := TDXFToken.Create;
+    NewToken.GroupCode := IntSectionGroupCode;
+    NewToken.StrValue := StrSectionName;
+
+    // Waiting for a section
+    if ParserState = 0 then
+    begin
+      if (StrSectionName = 'SECTION') then
+      begin
+        ParserState := 1;
+        NextTokenBase := NewToken.Childs;
+      end
+      else if (StrSectionName = 'EOF') then
+      begin
+        Exit;
+      end
+      else
+      begin
+        raise Exception.Create(Format(
+          'TDXFTokenizer.ReadFromStrings: Expected SECTION, but got: %s', [StrSectionname]));
+      end;
+    end
+    // Processing the section name
+    else if ParserState = 1 then
+    begin
+      if (StrSectionName = 'HEADER') or
+        (StrSectionName = 'CLASSES') or
+        (StrSectionName = 'TABLES') or
+        (StrSectionName = 'BLOCKS') or
+        (StrSectionName = 'OBJECTS') or
+        (StrSectionName = 'THUMBNAILIMAGE') then
+      begin
+        ParserState := 2;
+        SectionTokenBase := CurTokenBase;
+      end
+      else if (StrSectionName = 'ENTITIES') then
+      begin
+        ParserState := 3;
+        SectionTokenBase := CurTokenBase;
+      end
+      else
+      begin
+        raise Exception.Create(Format(
+          'TDXFTokenizer.ReadFromStrings: Invalid section name: %s', [StrSectionname]));
+      end;
+    end
+    // Reading a generic section
+    else if ParserState = 2 then
+    begin
+      if StrSectionName = 'ENDSEC' then
+      begin
+        ParserState := 0;
+        CurTokenBase := SectionTokenBase;
+        NextTokenBase := Tokens;
+      end;
+    end
+    // Reading the ENTITIES section
+    else if ParserState = 3 then
+    begin
+      if IsENTITIES_Subsection(StrSectionName) then
+      begin
+        CurTokenBase := SectionTokenBase;
+        NextTokenBase := NewToken.Childs;
+      end
+      else if StrSectionName = 'ENDSEC' then
+      begin
+        ParserState := 0;
+        CurTokenBase := SectionTokenBase;
+        NextTokenBase := Tokens;
+      end;
+    end;
+
+    CurTokenBase.Add(NewToken);
+
+    Inc(i, 2);
+  end;
+end;
+
+function TDXFTokenizer.IsENTITIES_Subsection(AStr: string): Boolean;
+begin
+  Result :=
+    (AStr = '3DFACE') or
+    (AStr = '3DSOLID') or
+    (AStr = 'ACAD_PROXY_ENTITY') or
+    (AStr = 'ARC') or
+    (AStr = 'ATTDEF') or
+    (AStr = 'ATTRIB') or
+    (AStr = 'BODY') or
+    (AStr = 'CIRCLE') or
+    (AStr = 'DIMENSION') or
+    (AStr = 'ELLIPSE') or
+    (AStr = 'HATCH') or
+    (AStr = 'IMAGE') or
+    (AStr = 'INSERT') or
+    (AStr = 'LEADER') or
+    (AStr = 'LINE') or
+    (AStr = 'LWPOLYLINE') or
+    (AStr = 'MLINE') or
+    (AStr = 'MTEXT') or
+    (AStr = 'OLEFRAME') or
+    (AStr = 'OLE2FRAME') or
+    (AStr = 'POINT') or
+    (AStr = 'POLYLINE') or
+    (AStr = 'RAY') or
+    (AStr = 'REGION') or
+    (AStr = 'SEQEND') or
+    (AStr = 'SHAPE') or
+    (AStr = 'SOLID') or
+    (AStr = 'SPLINE') or
+    (AStr = 'TEXT') or
+    (AStr = 'TOLERANCE') or
+    (AStr = 'TRACE') or
+    (AStr = 'VERTEX') or
+    (AStr = 'VIEWPORT') or
+    (AStr = 'XLINE');
+end;
+
+{ TvDXFVectorialReader }
+
+{@@
+  Reads a string and separates it in substring
+  using ASeparator to delimite them.
+
+  Limits:
+
+  Number of substrings: 10 (indexed 0 to 9)
+  Length of each substring: 255 (they are shortstrings)
+}
+function TvDXFVectorialReader.SeparateString(AString: string; ASeparator: Char): T10Strings;
+var
+  i, CurrentPart: Integer;
+begin
+  CurrentPart := 0;
+
+  { Clears the result }
+  for i := 0 to 9 do Result[i] := '';
+
+  { Iterates througth the string, filling strings }
+  for i := 1 to Length(AString) do
+  begin
+    if Copy(AString, i, 1) = ASeparator then
+    begin
+      Inc(CurrentPart);
+
+      { Verifies if the string capacity wasn't exceeded }
+      if CurrentPart > 9 then Exit;
+    end
+    else
+      Result[CurrentPart] := Result[CurrentPart] + Copy(AString, i, 1);
+  end;
+end;
+
+procedure TvDXFVectorialReader.ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialDocument);
+var
+  i: Integer;
+  CurToken: TDXFToken;
+begin
+  for i := 0 to ATokens.Count - 1 do
+  begin
+    CurToken := TDXFToken(ATokens.Items[i]);
+    if CurToken.StrValue = 'CIRCLE' then ReadENTITIES_CIRCLE(CurToken.Childs, AData)
+    else if CurToken.StrValue = 'ELLIPSE' then ReadENTITIES_ELLIPSE(CurToken.Childs, AData)
+    else if CurToken.StrValue = 'LINE' then ReadENTITIES_LINE(CurToken.Childs, AData)
+    else if CurToken.StrValue = 'TEXT' then
+    begin
+      // ...
+    end;
+  end;
+end;
+
+procedure TvDXFVectorialReader.ReadENTITIES_LINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
+var
+  CurToken: TDXFToken;
+  i: Integer;
+  // LINE
+  LineStartX, LineStartY, LineStartZ: Double;
+  LineEndX, LineEndY, LineEndZ: Double;
+begin
+  // Initial values
+  LineStartX := 0;
+  LineStartY := 0;
+  LineStartZ := 0;
+  LineEndX := 0;
+  LineEndY := 0;
+  LineEndZ := 0;
+
+  for i := 0 to ATokens.Count - 1 do
+  begin
+    // Now read and process the item name
+    CurToken := TDXFToken(ATokens.Items[i]);
+
+    // Avoid an exception by previously checking if the conversion can be made
+    if (CurToken.GroupCode = DXF_ENTITIES_HANDLE) or
+      (CurToken.GroupCode = DXF_ENTITIES_AcDbEntity) then Continue;
+
+    CurToken.FloatValue :=  StrToFloat(Trim(CurToken.StrValue));
+
+    case CurToken.GroupCode of
+      10: LineStartX := CurToken.FloatValue;
+      20: LineStartY := CurToken.FloatValue;
+      30: LineStartZ := CurToken.FloatValue;
+      11: LineEndX := CurToken.FloatValue;
+      21: LineEndY := CurToken.FloatValue;
+      31: LineEndZ := CurToken.FloatValue;
+    end;
+  end;
+
+  // And now write it
+  {$ifdef FPVECTORIALDEBUG}
+  WriteLn(Format('Adding Line from %f,%f to %f,%f', [LineStartX, LineStartY, LineEndX, LineEndY]));
+  {$endif}
+  AData.StartPath(LineStartX, LineStartY);
+  AData.AddLineToPath(LineEndX, LineEndY);
+  AData.EndPath();
+end;
+
+{
+100 Subclass marker (AcDbCircle)
+39 Thickness (optional; default = 0)
+10 Center point (in OCS) DXF: X value; APP: 3D point
+20, 30 DXF: Y and Z values of center point (in OCS)
+40 Radius
+100 Subclass marker (AcDbArc)
+50 Start angle
+51 End angle
+210 Extrusion direction. (optional; default = 0, 0, 1) DXF: X value; APP: 3D vector
+220, 230 DXF: Y and Z values of extrusion direction (optional)
+}
+procedure TvDXFVectorialReader.ReadENTITIES_ARC(ATokens: TDXFTokens;
+  AData: TvVectorialDocument);
+var
+  CurToken: TDXFToken;
+  i: Integer;
+  CenterX, CenterY, CenterZ, Radius, StartAngle, EndAngle: Double;
+begin
+  CenterX := 0.0;
+  CenterY := 0.0;
+  CenterZ := 0.0;
+  Radius := 0.0;
+  StartAngle := 0.0;
+  EndAngle := 0.0;
+
+  for i := 0 to ATokens.Count - 1 do
+  begin
+    // Now read and process the item name
+    CurToken := TDXFToken(ATokens.Items[i]);
+
+    // Avoid an exception by previously checking if the conversion can be made
+    if (CurToken.GroupCode = DXF_ENTITIES_HANDLE) or
+      (CurToken.GroupCode = DXF_ENTITIES_AcDbEntity) then Continue;
+
+    CurToken.FloatValue :=  StrToFloat(Trim(CurToken.StrValue));
+
+    case CurToken.GroupCode of
+      10: CenterX := CurToken.FloatValue;
+      20: CenterY := CurToken.FloatValue;
+      30: CenterZ := CurToken.FloatValue;
+      40: Radius := CurToken.FloatValue;
+    end;
+  end;
+
+  AData.AddCircularArc(CenterX, CenterY, CenterZ, Radius, StartAngle, EndAngle);
+end;
+
+{
+Group codes	Description
+100 Subclass marker (AcDbCircle)
+39 Thickness (optional; default = 0)
+10 Center point (in OCS) DXF: X value; APP: 3D point
+20, 30 DXF: Y and Z values of center point (in OCS)
+40 Radius
+210 Extrusion direction (optional; default = 0, 0, 1) DXF: X value; APP: 3D vector
+220, 230 DXF: Y and Z values of extrusion direction  (optional)
+}
+procedure TvDXFVectorialReader.ReadENTITIES_CIRCLE(ATokens: TDXFTokens;
+  AData: TvVectorialDocument);
+var
+  CurToken: TDXFToken;
+  i: Integer;
+  CircleCenterX, CircleCenterY, CircleCenterZ, CircleRadius: Double;
+begin
+  CircleCenterX := 0.0;
+  CircleCenterY := 0.0;
+  CircleCenterZ := 0.0;
+  CircleRadius := 0.0;
+
+  for i := 0 to ATokens.Count - 1 do
+  begin
+    // Now read and process the item name
+    CurToken := TDXFToken(ATokens.Items[i]);
+
+    // Avoid an exception by previously checking if the conversion can be made
+    if (CurToken.GroupCode = DXF_ENTITIES_HANDLE) or
+      (CurToken.GroupCode = DXF_ENTITIES_AcDbEntity) then Continue;
+
+    CurToken.FloatValue :=  StrToFloat(Trim(CurToken.StrValue));
+
+    case CurToken.GroupCode of
+      10: CircleCenterX := CurToken.FloatValue;
+      20: CircleCenterY := CurToken.FloatValue;
+      30: CircleCenterZ := CurToken.FloatValue;
+      40: CircleRadius := CurToken.FloatValue;
+    end;
+  end;
+
+  AData.AddCircle(CircleCenterX, CircleCenterY,
+    CircleCenterZ, CircleRadius);
+end;
+
+{
+100 Subclass marker (AcDbEllipse)
+10 Center point (in WCS) DXF: X value; APP: 3D point
+20, 30 DXF: Y and Z values of center point (in WCS)
+11 Endpoint of major axis, relative to the center (in WCS) DXF: X value; APP: 3D point
+21, 31 DXF: Y and Z values of endpoint of major axis, relative to the center (in WCS)
+210 Extrusion direction (optional; default = 0, 0, 1) DXF: X value; APP: 3D vector
+220, 230 DXF: Y and Z values of extrusion direction  (optional)
+40 Ratio of minor axis to major axis
+41 Start parameter (this value is 0.0 for a full ellipse)
+42 End parameter (this value is 2pi for a full ellipse)
+}
+procedure TvDXFVectorialReader.ReadENTITIES_ELLIPSE(ATokens: TDXFTokens;
+  AData: TvVectorialDocument);
+var
+  CurToken: TDXFToken;
+  i: Integer;
+  CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis, Angle: Double;
+begin
+  for i := 0 to ATokens.Count - 1 do
+  begin
+    // Now read and process the item name
+    CurToken := TDXFToken(ATokens.Items[i]);
+
+    // Avoid an exception by previously checking if the conversion can be made
+    if (CurToken.GroupCode = DXF_ENTITIES_HANDLE) or
+      (CurToken.GroupCode = DXF_ENTITIES_AcDbEntity) then Continue;
+
+    CurToken.FloatValue :=  StrToFloat(Trim(CurToken.StrValue));
+
+    case CurToken.GroupCode of
+      10: CenterX := CurToken.FloatValue;
+      20: CenterY := CurToken.FloatValue;
+      30: CenterZ := CurToken.FloatValue;
+    end;
+
+  end;
+
+  //
+  AData.AddEllipse(CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis, Angle);
+end;
+
+{
+100 Subclass marker (AcDbText)
+39 Thickness (optional; default = 0)
+10 First alignment point (in OCS) DXF: X value; APP: 3D point
+20, 30 DXF: Y and Z values of first alignment point (in OCS)
+40 Text height
+1 Default value (the string itself)
+50 Text rotation (optional; default = 0)
+41 Relative X scale factor-width (optional; default = 1)
+  This value is also adjusted when fit-type text is used.
+51 Oblique angle (optional; default = 0)
+7 Text style name (optional, default = STANDARD)
+71 Text generation flags (optional, default = 0):
+  2 = Text is backward (mirrored in X).
+  4 = Text is upside down (mirrored in Y).
+72 Horizontal text justification type (optional, default = 0) integer codes (not bit-coded)
+  0 = Left; 1= Center; 2 = Right
+  3 = Aligned (if vertical alignment = 0)
+  4 = Middle (if vertical alignment = 0)
+  5 = Fit (if vertical alignment = 0)
+  See the Group 72 and 73 integer codes table for clarification.
+11 Second alignment point (in OCS) (optional)
+  DXF: X value; APP: 3D point
+  This value is meaningful only if the value of a 72 or 73 group is nonzero (if the justification is anything other than baseline/left).
+21, 31 DXF: Y and Z values of second alignment point (in OCS) (optional)
+210 Extrusion direction (optional; default = 0, 0, 1)
+  DXF: X value; APP: 3D vector
+220, 230 DXF: Y and Z values of extrusion direction (optional)
+73 Vertical text justification type (optional, default = 0): integer codes (not bit- coded):
+  0 = Baseline; 1 = Bottom; 2 = Middle; 3 = Top
+  See the Group 72 and 73 integer codes table for clarification.
+}
+procedure TvDXFVectorialReader.ReadENTITIES_TEXT(ATokens: TDXFTokens;
+  AData: TvVectorialDocument);
+var
+  CurToken: TDXFToken;
+  i: Integer;
+  PosX, PosY, PosZ: Double;
+  Str: string;
+begin
+  for i := 0 to ATokens.Count - 1 do
+  begin
+    // Now read and process the item name
+    CurToken := TDXFToken(ATokens.Items[i]);
+
+    // Avoid an exception by previously checking if the conversion can be made
+    if (CurToken.GroupCode = DXF_ENTITIES_HANDLE) or
+      (CurToken.GroupCode = 1) or
+      (CurToken.GroupCode = DXF_ENTITIES_AcDbEntity) then Continue;
+
+    CurToken.FloatValue :=  StrToFloat(Trim(CurToken.StrValue));
+
+    case CurToken.GroupCode of
+      1:  Str := CurToken.StrValue;
+      10: PosX := CurToken.FloatValue;
+      20: PosY := CurToken.FloatValue;
+      30: PosZ := CurToken.FloatValue;
+    end;
+
+  end;
+
+  //
+//  AData.AddEllipse(CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis, Angle);
+end;
+
+function TvDXFVectorialReader.GetCoordinateValue(AStr: shortstring): Double;
+begin
+  Result := 0.0;
+
+{  if Length(AStr) <= 1 then Exit;
+
+  Result := StrToFloat(Copy(AStr, 2, Length(AStr) - 1));}
+end;
+
+constructor TvDXFVectorialReader.Create;
+begin
+  inherited Create;
+
+  Tokenizer := TDXFTokenizer.Create;
+end;
+
+destructor TvDXFVectorialReader.Destroy;
+begin
+  Tokenizer.Free;
+
+  inherited Destroy;
+end;
+
+{@@
+  The information of each separate path is lost in G-Code files
+  Only one path uniting all of them is created when reading G-Code
+}
+procedure TvDXFVectorialReader.ReadFromStrings(AStrings: TStrings;
+  AData: TvVectorialDocument);
+var
+  i: Integer;
+  CurToken, CurTokenFirstChild: TDXFToken;
+begin
+  Tokenizer.ReadFromStrings(AStrings);
+
+  for i := 0 to Tokenizer.Tokens.Count - 1 do
+  begin
+    CurToken := TDXFToken(Tokenizer.Tokens.Items[i]);
+    CurTokenFirstChild := TDXFToken(CurToken.Childs.Items[0]);
+
+    if CurTokenFirstChild.StrValue = 'ENTITIES' then
+      ReadENTITIES(CurToken.Childs, AData);
+  end;
+end;
+
+initialization
+
+  RegisterVectorialReader(TvDXFVectorialReader, vfDXF);
+
+end.
+

+ 146 - 1
packages/fpvectorial/src/fpvectorial.pas

@@ -18,7 +18,7 @@ unit fpvectorial;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils;
+  Classes, SysUtils, Math;
 
 
 type
 type
   TvVectorialFormat = (
   TvVectorialFormat = (
@@ -121,6 +121,43 @@ type
     Value: utf8string;
     Value: utf8string;
   end;
   end;
 
 
+  {@@
+  }
+  TvEntity = class
+  public
+  end;
+
+  {@@
+  }
+  TvCircle = class(TvEntity)
+  public
+    CenterX, CenterY, CenterZ, Radius: Double;
+  end;
+
+  {@@
+  }
+  TvCircularArc = class(TvEntity)
+  public
+    CenterX, CenterY, CenterZ, Radius: Double;
+    StartAngle, EndAngle: Double;
+  end;
+
+  {@@
+  }
+
+  { TvEllipse }
+
+  TvEllipse = class(TvEntity)
+  public
+    // Mandatory fields
+    CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis: Double;
+    {@@ The Angle is measured in radians in relation to the positive X axis }
+    Angle: Double;
+    // Calculated fields
+    BoundingRect: TRect;
+    procedure CalculateBoundingRectangle;
+  end;
+
 type
 type
 
 
   TvCustomVectorialWriter = class;
   TvCustomVectorialWriter = class;
@@ -132,6 +169,7 @@ type
   private
   private
     FPaths: TFPList;
     FPaths: TFPList;
     FTexts: TFPList;
     FTexts: TFPList;
+    FEntities: TFPList;
     FTmpPath: TPath;
     FTmpPath: TPath;
     FTmpText: TvText;
     FTmpText: TvText;
     procedure RemoveCallback(data, arg: pointer);
     procedure RemoveCallback(data, arg: pointer);
@@ -158,6 +196,8 @@ type
     function  GetPathCount: Integer;
     function  GetPathCount: Integer;
     function  GetText(ANum: Cardinal): TvText;
     function  GetText(ANum: Cardinal): TvText;
     function  GetTextCount: Integer;
     function  GetTextCount: Integer;
+    function  GetEntity(ANum: Cardinal): TvEntity;
+    function  GetEntityCount: Integer;
     { Data removing methods }
     { Data removing methods }
     procedure Clear;
     procedure Clear;
     procedure RemoveAllPaths;
     procedure RemoveAllPaths;
@@ -172,6 +212,9 @@ type
     procedure EndPath();
     procedure EndPath();
     procedure AddText(AX, AY, AZ: Double; FontName: string; FontSize: integer; AText: utf8string); overload;
     procedure AddText(AX, AY, AZ: Double; FontName: string; FontSize: integer; AText: utf8string); overload;
     procedure AddText(AX, AY, AZ: Double; AStr: utf8string); overload;
     procedure AddText(AX, AY, AZ: Double; AStr: utf8string); overload;
+    procedure AddCircle(ACenterX, ACenterY, ACenterZ, ARadius: Double);
+    procedure AddCircularArc(ACenterX, ACenterY, ACenterZ, ARadius, AStartAngle, AEndAngle: Double);
+    procedure AddEllipse(CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis, Angle: Double);
     { properties }
     { properties }
     property PathCount: Integer read GetPathCount;
     property PathCount: Integer read GetPathCount;
     property Paths[Index: Cardinal]: TPath read GetPath;
     property Paths[Index: Cardinal]: TPath read GetPath;
@@ -186,6 +229,7 @@ type
   TvCustomVectorialReader = class
   TvCustomVectorialReader = class
   public
   public
     { General reading methods }
     { General reading methods }
+    constructor Create; virtual;
     procedure ReadFromFile(AFileName: string; AData: TvVectorialDocument); virtual;
     procedure ReadFromFile(AFileName: string; AData: TvVectorialDocument); virtual;
     procedure ReadFromStream(AStream: TStream; AData: TvVectorialDocument); virtual;
     procedure ReadFromStream(AStream: TStream; AData: TvVectorialDocument); virtual;
     procedure ReadFromStrings(AStrings: TStrings; AData: TvVectorialDocument); virtual;
     procedure ReadFromStrings(AStrings: TStrings; AData: TvVectorialDocument); virtual;
@@ -202,6 +246,7 @@ type
   TvCustomVectorialWriter = class
   TvCustomVectorialWriter = class
   public
   public
     { General writing methods }
     { General writing methods }
+    constructor Create; virtual;
     procedure WriteToFile(AFileName: string; AData: TvVectorialDocument); virtual;
     procedure WriteToFile(AFileName: string; AData: TvVectorialDocument); virtual;
     procedure WriteToStream(AStream: TStream; AData: TvVectorialDocument); virtual;
     procedure WriteToStream(AStream: TStream; AData: TvVectorialDocument); virtual;
     procedure WriteToStrings(AStrings: TStrings; AData: TvVectorialDocument); virtual;
     procedure WriteToStrings(AStrings: TStrings; AData: TvVectorialDocument); virtual;
@@ -316,6 +361,38 @@ begin
   end;
   end;
 end;
 end;
 
 
+{ TvEllipse }
+
+procedure TvEllipse.CalculateBoundingRectangle;
+var
+  t, tmp: Double;
+begin
+  {
+    To calculate the bounding rectangle we can do this:
+
+    Ellipse equations:You could try using the parametrized equations for an ellipse rotated at an arbitrary angle:
+
+    x = CenterX + MajorHalfAxis*cos(t)*cos(Angle) - MinorHalfAxis*sin(t)*sin(Angle)
+    y = CenterY + MinorHalfAxis*sin(t)*cos(Angle) + MajorHalfAxis*cos(t)*sin(Angle)
+
+    You can then differentiate and solve for gradient = 0:
+    0 = dx/dt = -MajorHalfAxis*sin(t)*cos(Angle) - MinorHalfAxis*cos(t)*sin(Angle)
+    =>
+    tan(t) = -MinorHalfAxis*tan(Angle)/MajorHalfAxis
+    =>
+    t = cotang(-MinorHalfAxis*tan(Angle)/MajorHalfAxis)
+
+    On the other axis:
+
+    0 = dy/dt = b*cos(t)*cos(phi) - a*sin(t)*sin(phi)
+    =>
+    tan(t) = b*cot(phi)/a
+  }
+  t := cotan(-MinorHalfAxis*tan(Angle)/MajorHalfAxis);
+  tmp := CenterX + MajorHalfAxis*cos(t)*cos(Angle) - MinorHalfAxis*sin(t)*sin(Angle);
+  BoundingRect.Right := Round(tmp);
+end;
+
 { TsWorksheet }
 { TsWorksheet }
 
 
 {@@
 {@@
@@ -339,6 +416,7 @@ begin
 
 
   FPaths := TFPList.Create;
   FPaths := TFPList.Create;
   FTexts := TFPList.Create;
   FTexts := TFPList.Create;
+  FEntities := TFPList.Create;
   FTmpPath := TPath.Create;
   FTmpPath := TPath.Create;
 end;
 end;
 
 
@@ -351,6 +429,7 @@ begin
 
 
   FPaths.Free;
   FPaths.Free;
   FTexts.Free;
   FTexts.Free;
+  FEntities.Free;
 
 
   inherited Destroy;
   inherited Destroy;
 end;
 end;
@@ -520,6 +599,48 @@ begin
   AddText(AX, AY, AZ, '', 10, AStr);
   AddText(AX, AY, AZ, '', 10, AStr);
 end;
 end;
 
 
+procedure TvVectorialDocument.AddCircle(ACenterX, ACenterY, ACenterZ, ARadius: Double);
+var
+  lCircle: TvCircle;
+begin
+  lCircle := TvCircle.Create;
+  lCircle.CenterX := ACenterX;
+  lCircle.CenterY := ACenterY;
+  lCircle.CenterZ := ACenterZ;
+  lCircle.Radius := ARadius;
+  FEntities.Add(lCircle);
+end;
+
+procedure TvVectorialDocument.AddCircularArc(ACenterX, ACenterY, ACenterZ,
+  ARadius, AStartAngle, AEndAngle: Double);
+var
+  lCircularArc: TvCircularArc;
+begin
+  lCircularArc := TvCircularArc.Create;
+  lCircularArc.CenterX := ACenterX;
+  lCircularArc.CenterY := ACenterY;
+  lCircularArc.CenterZ := ACenterZ;
+  lCircularArc.Radius := ARadius;
+  lCircularArc.StartAngle := AStartAngle;
+  lCircularArc.EndAngle := AEndAngle;
+  FEntities.Add(lCircularArc);
+end;
+
+procedure TvVectorialDocument.AddEllipse(CenterX, CenterY, CenterZ,
+  MajorHalfAxis, MinorHalfAxis, Angle: Double);
+var
+  lEllipse: TvEllipse;
+begin
+  lEllipse := TvEllipse.Create;
+  lEllipse.CenterX := CenterX;
+  lEllipse.CenterY := CenterY;
+  lEllipse.CenterZ := CenterZ;
+  lEllipse.MajorHalfAxis := MajorHalfAxis;
+  lEllipse.MinorHalfAxis := MinorHalfAxis;
+  lEllipse.Angle := Angle;
+  FEntities.Add(lEllipse);
+end;
+
 {@@
 {@@
   Convenience method which creates the correct
   Convenience method which creates the correct
   writer object for a given vector graphics document format.
   writer object for a given vector graphics document format.
@@ -747,6 +868,20 @@ begin
   Result := FTexts.Count;
   Result := FTexts.Count;
 end;
 end;
 
 
+function TvVectorialDocument.GetEntity(ANum: Cardinal): TvEntity;
+begin
+  if ANum >= FEntities.Count then raise Exception.Create('TvVectorialDocument.GetEntity: Entity number out of bounds');
+
+  if FEntities.Items[ANum] = nil then raise Exception.Create('TvVectorialDocument.GetEntity: Invalid Entity number');
+
+  Result := TvEntity(FEntities.Items[ANum]);
+end;
+
+function TvVectorialDocument.GetEntityCount: Integer;
+begin
+  Result := FEntities.Count;
+end;
+
 {@@
 {@@
   Clears all data in the document
   Clears all data in the document
 }
 }
@@ -758,6 +893,11 @@ end;
 
 
 { TvCustomVectorialReader }
 { TvCustomVectorialReader }
 
 
+constructor TvCustomVectorialReader.Create;
+begin
+  inherited Create;
+end;
+
 procedure TvCustomVectorialReader.ReadFromFile(AFileName: string; AData: TvVectorialDocument);
 procedure TvCustomVectorialReader.ReadFromFile(AFileName: string; AData: TvVectorialDocument);
 var
 var
   FileStream: TFileStream;
   FileStream: TFileStream;
@@ -806,6 +946,11 @@ end;
 
 
 { TsCustomSpreadWriter }
 { TsCustomSpreadWriter }
 
 
+constructor TvCustomVectorialWriter.Create;
+begin
+  inherited Create;
+end;
+
 {@@
 {@@
   Default file writting method.
   Default file writting method.
 
 

+ 75 - 4
packages/fpvectorial/src/fpvtocanvas.pas

@@ -14,6 +14,42 @@ procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument; ADest: TFPCustom
 
 
 implementation
 implementation
 
 
+{function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
+var
+  sinus, cosinus : Extended;
+begin
+  SinCos(alpha, sinus, cosinus);
+  P.x := P.x - Fix.x;
+  P.y := P.y - Fix.y;
+  result.x := Round(p.x*cosinus + p.y*sinus)  +  fix.x ;
+  result.y := Round(-p.x*sinus + p.y*cosinus) +  Fix.y;
+end;}
+
+procedure DrawRotatedEllipse(ADest: TFPCustomCanvas; CurEllipse: TvEllipse);
+{var
+  PointList: array[0..6] of TPoint;
+  f: TPoint;
+  dk: Integer;}
+begin
+{  dk := Round(0.654 * Abs(y2-y1));
+  f.x := CurEllipse.CenterX;
+  f.y := CurEllipse.CenterY - 1;
+  PointList[0] := Rotate2DPoint(Point(x1, f.y), f, Alpha) ;  // Startpoint
+  PointList[1] := Rotate2DPoint(Point(x1,  f.y - dk), f, Alpha);
+  //Controlpoint of Startpoint first part
+  PointList[2] := Rotate2DPoint(Point(x2- 1,  f.y - dk), f, Alpha);
+  //Controlpoint of secondpoint first part
+  PointList[3] := Rotate2DPoint(Point(x2 -1 , f.y), f, Alpha);
+  // Firstpoint of secondpart
+  PointList[4] := Rotate2DPoint(Point(x2-1 , f.y + dk), f, Alpha);
+  // Controllpoint of secondpart firstpoint
+  PointList[5] := Rotate2DPoint(Point(x1, f.y +  dk), f, Alpha);
+  // Conrollpoint of secondpart endpoint
+  PointList[6] := PointList[0];   // Endpoint of
+   // Back to the startpoint
+  PolyBezier(canvas.handle, Pointlist[0], 7);}
+end;
+
 {@@
 {@@
   This function draws a FPVectorial vectorial image to a TFPCustomCanvas
   This function draws a FPVectorial vectorial image to a TFPCustomCanvas
   descendent, such as TCanvas from the LCL.
   descendent, such as TCanvas from the LCL.
@@ -40,6 +76,11 @@ var
   CurX, CurY: Integer; // Not modified by ADestX, etc
   CurX, CurY: Integer; // Not modified by ADestX, etc
   CurveLength: Integer;
   CurveLength: Integer;
   t: Double;
   t: Double;
+  // For entities
+  CurEntity: TvEntity;
+  CurCircle: TvCircle;
+  CurEllipse: TvEllipse;
+  CurCircularArc: TvCircularArc;
 begin
 begin
   {$ifdef FPVECTORIALDEBUG}
   {$ifdef FPVECTORIALDEBUG}
   WriteLn(':>DrawFPVectorialToCanvas');
   WriteLn(':>DrawFPVectorialToCanvas');
@@ -61,13 +102,18 @@ begin
       CurSegment := TPathSegment(ASource.Paths[i].Next());
       CurSegment := TPathSegment(ASource.Paths[i].Next());
 
 
       case CurSegment.SegmentType of
       case CurSegment.SegmentType of
+      stMoveTo:
+      begin
+        ADest.MoveTo(
+          Round(ADestX + AMulX * Cur2DSegment.X),
+          Round(ADestY + AMulY * Cur2DSegment.Y)
+          );
+      end;
       st2DLine, st3DLine:
       st2DLine, st3DLine:
       begin
       begin
-        PosX := Round(Cur2DSegment.X);
-        PosY := Round(Cur2DSegment.Y);
         ADest.LineTo(
         ADest.LineTo(
-          Round(ADestX + AMulX * PosX),
-          Round(ADestY + AMulY * PosY)
+          Round(ADestX + AMulX * Cur2DSegment.X),
+          Round(ADestY + AMulY * Cur2DSegment.Y)
           );
           );
       end;
       end;
       { To draw a bezier we need to divide the interval in parts and make
       { To draw a bezier we need to divide the interval in parts and make
@@ -95,6 +141,31 @@ begin
     end;
     end;
   end;
   end;
 
 
+  for i := 0 to ASource.GetEntityCount - 1 do
+  begin
+    CurEntity := ASource.GetEntity(i);
+    if CurEntity is TvCircle then
+    begin
+      CurCircle := CurEntity as TvCircle;
+      ADest.Ellipse(
+        Round(ADestX + AmulX * (CurCircle.CenterX - CurCircle.Radius)),
+        Round(ADestY + AMulY * (CurCircle.CenterY - CurCircle.Radius)),
+        Round(ADestX + AmulX * (CurCircle.CenterX + CurCircle.Radius)),
+        Round(ADestY + AMulY * (CurCircle.CenterY + CurCircle.Radius))
+        );
+    end
+    else if CurEntity is TvEllipse then
+    begin
+      CurEllipse := CurEntity as TvEllipse;
+      DrawRotatedEllipse(ADest, CurEllipse);
+    end
+    else if CurEntity is TvCircularArc then
+    begin
+      CurCircularArc := CurEntity as TvCircularArc;
+//      ADest.Arc(ADest, CurEllipse);
+    end;
+  end;
+
   {$ifdef FPVECTORIALDEBUG}
   {$ifdef FPVECTORIALDEBUG}
   WriteLn(':<DrawFPVectorialToCanvas');
   WriteLn(':<DrawFPVectorialToCanvas');
   {$endif}
   {$endif}

+ 1 - 72
packages/hermes/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/01/03]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/01/28]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -452,24 +452,6 @@ endif
 ifeq ($(FULL_TARGET),mipsel-linux)
 ifeq ($(FULL_TARGET),mipsel-linux)
 override TARGET_UNITS+=hermes
 override TARGET_UNITS+=hermes
 endif
 endif
-ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_LOADERS+=mmx_clr mmx_main mmxp2_32 mmxp_32 x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy x86p_i8 x86p_s32 x86pscpy
-endif
-ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_LOADERS+=mmx_clr mmx_main mmxp2_32 mmxp_32 x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy x86p_i8 x86p_s32 x86pscpy
-endif
-ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_LOADERS+=mmx_clr mmx_main mmxp2_32 mmxp_32 x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy x86p_i8 x86p_s32 x86pscpy
-endif
-ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_LOADERS+=mmx_clr mmx_main mmxp2_32 mmxp_32 x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy x86p_i8 x86p_s32 x86pscpy
-endif
-ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_LOADERS+=mmx_clr mmx_main mmxp2_32 mmxp_32 x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy x86p_i8 x86p_s32 x86pscpy
-endif
-ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_LOADERS+=mmx_clr mmx_main mmxp2_32 mmxp_32 x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy x86p_i8 x86p_s32 x86pscpy
-endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_OPTIONS+=-dI386_ASSEMBLER
 override COMPILER_OPTIONS+=-dI386_ASSEMBLER
@@ -2183,33 +2165,6 @@ EXECPPAS:=@$(PPAS)
 endif
 endif
 endif
 endif
 endif
 endif
-.PHONY: fpc_loaders
-ifneq ($(TARGET_LOADERS),)
-override ALLTARGET+=fpc_loaders
-override CLEANTARGET+=fpc_loaders_clean
-override INSTALLTARGET+=fpc_loaders_install
-override LOADEROFILES:=$(addsuffix $(OEXT),$(TARGET_LOADERS))
-endif
-%$(OEXT): %$(LOADEREXT)
-ifdef COMPILER_UNITTARGETDIR
-	$(AS) -o $(COMPILER_UNITTARGETDIR)/$*$(OEXT) $<
-else
-	$(AS) -o $*$(OEXT) $<
-endif
-fpc_loaders: $(COMPILER_UNITTARGETDIR) $(LOADEROFILES)
-fpc_loaders_clean:
-ifdef COMPILER_UNITTARGETDIR
-	-$(DEL) $(addprefix $(COMPILER_UNITTARGETDIR)/,$(LOADEROFILES))
-else
-	-$(DEL) $(LOADEROFILES)
-endif
-fpc_loaders_install:
-	$(MKDIR) $(INSTALL_UNITDIR)
-ifdef COMPILER_UNITTARGETDIR
-	$(INSTALL) $(addprefix $(COMPILER_UNITTARGETDIR)/,$(LOADEROFILES)) $(INSTALL_UNITDIR)
-else
-	$(INSTALL) $(LOADEROFILES) $(INSTALL_UNITDIR)
-endif
 .PHONY: fpc_units
 .PHONY: fpc_units
 ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),)
 ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),)
 override ALLTARGET+=fpc_units
 override ALLTARGET+=fpc_units
@@ -2657,29 +2612,3 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 include fpcmake.loc
 endif
 endif
 .NOTPARALLEL:
 .NOTPARALLEL:
-mmx_clr$(OEXT): src/$(CPU_TARGET)/mmx_clr.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)mmx_clr$(OEXT) src/$(CPU_TARGET)/mmx_clr.as
-mmx_main$(OEXT): src/$(CPU_TARGET)/mmx_main.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)mmx_main$(OEXT) src/$(CPU_TARGET)/mmx_main.as
-mmxp2_32$(OEXT): src/$(CPU_TARGET)/mmxp2_32.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)mmxp2_32$(OEXT) src/$(CPU_TARGET)/mmxp2_32.as
-mmxp_32$(OEXT): src/$(CPU_TARGET)/mmxp_32.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)mmxp_32$(OEXT) src/$(CPU_TARGET)/mmxp_32.as
-x8616lut$(OEXT): src/$(CPU_TARGET)/x8616lut.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x8616lut$(OEXT) src/$(CPU_TARGET)/x8616lut.as
-x86_clr$(OEXT): src/$(CPU_TARGET)/x86_clr.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86_clr$(OEXT) src/$(CPU_TARGET)/x86_clr.as
-x86_main$(OEXT): src/$(CPU_TARGET)/x86_main.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86_main$(OEXT) src/$(CPU_TARGET)/x86_main.as
-x86p_16$(OEXT): src/$(CPU_TARGET)/x86p_16.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_16$(OEXT) src/$(CPU_TARGET)/x86p_16.as
-x86p_32$(OEXT): src/$(CPU_TARGET)/x86p_32.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_32$(OEXT) src/$(CPU_TARGET)/x86p_32.as
-x86p_cpy$(OEXT): src/$(CPU_TARGET)/x86p_cpy.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_cpy$(OEXT) src/$(CPU_TARGET)/x86p_cpy.as
-x86p_i8$(OEXT): src/$(CPU_TARGET)/x86p_i8.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_i8$(OEXT) src/$(CPU_TARGET)/x86p_i8.as
-x86p_s32$(OEXT): src/$(CPU_TARGET)/x86p_s32.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_s32$(OEXT) src/$(CPU_TARGET)/x86p_s32.as
-x86pscpy$(OEXT): src/$(CPU_TARGET)/x86pscpy.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)x86pscpy$(OEXT) src/$(CPU_TARGET)/x86pscpy.as

+ 0 - 56
packages/hermes/Makefile.fpc

@@ -8,24 +8,6 @@ version=2.5.1
 
 
 [target]
 [target]
 units=hermes
 units=hermes
-loaders_i386_linux=mmx_clr mmx_main mmxp2_32 mmxp_32 \
-             x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy \
-             x86p_i8 x86p_s32 x86pscpy
-loaders_i386_win32=mmx_clr mmx_main mmxp2_32 mmxp_32 \
-             x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy \
-             x86p_i8 x86p_s32 x86pscpy
-loaders_i386_go32v2=mmx_clr mmx_main mmxp2_32 mmxp_32 \
-             x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy \
-             x86p_i8 x86p_s32 x86pscpy
-loaders_i386_freebsd=mmx_clr mmx_main mmxp2_32 mmxp_32 \
-             x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy \
-             x86p_i8 x86p_s32 x86pscpy
-loaders_i386_haiku=mmx_clr mmx_main mmxp2_32 mmxp_32 \
-             x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy \
-             x86p_i8 x86p_s32 x86pscpy
-loaders_i386_beos=mmx_clr mmx_main mmxp2_32 mmxp_32 \
-             x8616lut x86_clr x86_main x86p_16 x86p_32 x86p_cpy \
-             x86p_i8 x86p_s32 x86pscpy
 
 
 [compiler]
 [compiler]
 options_i386_linux=-dI386_ASSEMBLER
 options_i386_linux=-dI386_ASSEMBLER
@@ -48,41 +30,3 @@ fpcdir=../..
 
 
 [rules]
 [rules]
 .NOTPARALLEL:
 .NOTPARALLEL:
-mmx_clr$(OEXT): src/$(CPU_TARGET)/mmx_clr.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)mmx_clr$(OEXT) src/$(CPU_TARGET)/mmx_clr.as
-
-mmx_main$(OEXT): src/$(CPU_TARGET)/mmx_main.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)mmx_main$(OEXT) src/$(CPU_TARGET)/mmx_main.as
-
-mmxp2_32$(OEXT): src/$(CPU_TARGET)/mmxp2_32.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)mmxp2_32$(OEXT) src/$(CPU_TARGET)/mmxp2_32.as
-
-mmxp_32$(OEXT): src/$(CPU_TARGET)/mmxp_32.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)mmxp_32$(OEXT) src/$(CPU_TARGET)/mmxp_32.as
-
-x8616lut$(OEXT): src/$(CPU_TARGET)/x8616lut.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x8616lut$(OEXT) src/$(CPU_TARGET)/x8616lut.as
-
-x86_clr$(OEXT): src/$(CPU_TARGET)/x86_clr.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86_clr$(OEXT) src/$(CPU_TARGET)/x86_clr.as
-
-x86_main$(OEXT): src/$(CPU_TARGET)/x86_main.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86_main$(OEXT) src/$(CPU_TARGET)/x86_main.as
-
-x86p_16$(OEXT): src/$(CPU_TARGET)/x86p_16.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_16$(OEXT) src/$(CPU_TARGET)/x86p_16.as
-
-x86p_32$(OEXT): src/$(CPU_TARGET)/x86p_32.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_32$(OEXT) src/$(CPU_TARGET)/x86p_32.as
-
-x86p_cpy$(OEXT): src/$(CPU_TARGET)/x86p_cpy.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_cpy$(OEXT) src/$(CPU_TARGET)/x86p_cpy.as
-
-x86p_i8$(OEXT): src/$(CPU_TARGET)/x86p_i8.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_i8$(OEXT) src/$(CPU_TARGET)/x86p_i8.as
-
-x86p_s32$(OEXT): src/$(CPU_TARGET)/x86p_s32.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86p_s32$(OEXT) src/$(CPU_TARGET)/x86p_s32.as
-
-x86pscpy$(OEXT): src/$(CPU_TARGET)/x86pscpy.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)x86pscpy$(OEXT) src/$(CPU_TARGET)/x86pscpy.as

+ 9 - 51
packages/hermes/src/i386/headi386.inc

@@ -29,54 +29,12 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 }
 }
 
 
-{$L x8616lut}
-{$L x86_clr}
-{$L x86_main}
-{$L x86p_16}
-{$L x86p_32}
-{$L x86p_cpy}
-{$L x86p_i8}
-{$L x86p_s32}
-{$L x86pscpy}
-
-procedure ConvertX86(hci: PHermesConverterInterface); cdecl; external name ExternalAsmPrefix+'ConvertX86';
-procedure ConvertX86Stretch(hci: PHermesConverterInterface); cdecl; external name ExternalAsmPrefix+'ConvertX86Stretch';
-procedure ClearX86_32(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearX86_32';
-procedure ClearX86_24(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearX86_24';
-procedure ClearX86_16(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearX86_16';
-procedure ClearX86_8(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearX86_8';
-
-function Hermes_X86_CPU: Integer; cdecl; external name ExternalAsmPrefix+'Hermes_X86_CPU';
-
-procedure ConvertX86p32_32BGR888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_32BGR888';
-procedure ConvertX86p32_32RGBA888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_32RGBA888';
-procedure ConvertX86p32_32BGRA888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_32BGRA888';
-procedure ConvertX86p32_24RGB888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_24RGB888';
-procedure ConvertX86p32_24BGR888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_24BGR888';
-procedure ConvertX86p32_16RGB565(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_16RGB565';
-procedure ConvertX86p32_16BGR565(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_16BGR565';
-procedure ConvertX86p32_16RGB555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_16RGB555';
-procedure ConvertX86p32_16BGR555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_16BGR555';
-procedure ConvertX86p32_8RGB332(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_8RGB332';
-
-procedure ConvertX86p32_16RGB565_S(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p32_16RGB565_S';
-
-procedure ConvertX86p16_32RGB888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_32RGB888';
-procedure ConvertX86p16_32BGR888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_32BGR888';
-procedure ConvertX86p16_32RGBA888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_32RGBA888';
-procedure ConvertX86p16_32BGRA888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_32BGRA888';
-procedure ConvertX86p16_24RGB888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_24RGB888';
-procedure ConvertX86p16_24BGR888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_24BGR888';
-procedure ConvertX86p16_16BGR565(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_16BGR565';
-procedure ConvertX86p16_16RGB555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_16RGB555';
-procedure ConvertX86p16_16BGR555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_16BGR555';
-procedure ConvertX86p16_8RGB332(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86p16_8RGB332';
-
-procedure CopyX86p_4byte(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'CopyX86p_4byte';
-procedure CopyX86p_3byte(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'CopyX86p_3byte';
-procedure CopyX86p_2byte(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'CopyX86p_2byte';
-procedure CopyX86p_1byte(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'CopyX86p_1byte';
-
-procedure ConvertX86pI8_32(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86pI8_32';
-procedure ConvertX86pI8_24(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86pI8_24';
-procedure ConvertX86pI8_16(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertX86pI8_16';
+{$I x8616lut.inc}
+{$I x86_clr.inc}
+{$I x86_main.inc}
+{$I x86p_16.inc}
+{$I x86p_32.inc}
+{$I x86p_cpy.inc}
+{$I x86p_i8.inc}
+{$I x86p_s32.inc}
+{$I x86pscpy.inc}

+ 4 - 19
packages/hermes/src/i386/headmmx.inc

@@ -29,22 +29,7 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 }
 }
 
 
-{$L mmx_clr}
-{$L mmx_main}
-{$L mmxp2_32}
-{$L mmxp_32}
-
-procedure ConvertMMX(hci: PHermesConverterInterface); cdecl; external name ExternalAsmPrefix+'ConvertMMX';
-
-procedure ClearMMX_32(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearMMX_32';
-procedure ClearMMX_24(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearMMX_24';
-procedure ClearMMX_16(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearMMX_16';
-procedure ClearMMX_8(hci: PHermesClearInterface); cdecl; external name ExternalAsmPrefix+'ClearMMX_8';
-
-procedure ConvertMMXpII32_24RGB888(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertMMXpII32_24RGB888';
-procedure ConvertMMXpII32_16RGB565(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertMMXpII32_16RGB565';
-procedure ConvertMMXpII32_16BGR565(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertMMXpII32_16BGR565';
-procedure ConvertMMXpII32_16RGB555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertMMXpII32_16RGB555';
-procedure ConvertMMXpII32_16BGR555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertMMXpII32_16BGR555';
-
-procedure ConvertMMXp32_16RGB555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertMMXp32_16RGB555';
+{$I mmx_main.inc}
+{$I mmx_clr.inc}
+{$I mmxp2_32.inc}
+{$I mmxp_32.inc}

+ 0 - 269
packages/hermes/src/i386/mmx_clr.as

@@ -1,269 +0,0 @@
-#
-# MMX surface clear routines for HERMES
-# Copyright (c) 1998 Christian Nentwich ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-
-
-.globl _ClearMMX_32
-.globl _ClearMMX_24
-.globl _ClearMMX_16
-.globl _ClearMMX_8
-
-.text
-
-##
-## --------------------------------------------------------------------------
-## HermesClearInterface (ebp+..)
-##   0: char8 *dest
-##   4: int32 value
-##   8: unsigned int width (already checked to be >0!)
-##  12: unsigned int height (already checked to be >0!)
-##  16: int add
-
-
-_ClearMMX_32:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl 4(%ebp),%eax       # pixel value
-        movd 4(%ebp),%mm0
-
-        movl 12(%ebp),%edx      # height
-        movq %mm0,%mm1
-
-        psllq $32,%mm0
-        movl (%ebp),%edi        # destination
-
-        por %mm1,%mm0
-_ClearMMX_32.L_y:
-        movl 8(%ebp),%ecx
-
-        movl %ecx,%ebx
-
-        shrl %ecx
-        jz _ClearMMX_32.L_last
-
-_ClearMMX_32.L_x:
-        movq %mm0,(%edi)
-        addl $8,%edi
-
-        decl %ecx
-        jnz _ClearMMX_32.L_x
-
-
-_ClearMMX_32.L_last:
-        testl $1,%ebx
-        jz _ClearMMX_32.L_endline
-
-        movl %eax,(%edi)
-        addl $4,%edi
-
-_ClearMMX_32.L_endline:
-
-        addl 16(%ebp),%edi
-
-        decl %edx
-        jnz _ClearMMX_32.L_y
-
-        emms
-
-        popl %ebp
-        ret
-
-
-
-_ClearMMX_24:
-        ret
-
-
-
-_ClearMMX_16:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl 4(%ebp),%eax       # pixel value
-        movl 4(%ebp),%ebx
-
-        movl 12(%ebp),%edx      # height
-        movl (%ebp),%edi        # destination
-
-        shll $16,%eax           # Duplicate pixel value
-        andl $0x0ffff,%ebx
-
-        orl %ebx,%eax
-
-        movd %eax,%mm0
-        movd %eax,%mm1
-
-        psllq $32,%mm0
-
-        por %mm1,%mm0
-_ClearMMX_16.L_y:
-        movl 8(%ebp),%ecx
-
-        testl $3,%edi           # Check if destination is aligned mod 4
-        jz _ClearMMX_16.L_aligned
-
-        movw %ax,(%edi)         # otherwise write one pixel
-        addl $2,%edi
-
-        decl %ecx
-        jz _ClearMMX_16.L_endline
-
-_ClearMMX_16.L_aligned:
-        movl %ecx,%ebx
-        shrl $2,%ecx
-
-        jz _ClearMMX_16.L_last
-
-_ClearMMX_16.L_x:
-        movq %mm0,(%edi)
-        addl $8,%edi
-
-        decl %ecx
-        jnz _ClearMMX_16.L_x
-
-_ClearMMX_16.L_last:
-        andl $3,%ebx
-        jz _ClearMMX_16.L_endline
-
-        movw %ax,(%edi)         # Write trailing pixels
-        addl $2,%edi
-        decl %ebx
-        jz _ClearMMX_16.L_endline
-
-        movw %ax,(%edi)
-        addl $2,%edi
-        decl %ebx
-        jz _ClearMMX_16.L_endline
-
-        movw %ax,(%edi)
-        addl $2,%edi
-        decl %ebx
-        jnz _ClearMMX_16.L_endline
-
-_ClearMMX_16.L_endline:
-        addl 16(%ebp),%edi
-
-        decl %edx
-        jnz _ClearMMX_16.L_y
-
-        emms
-
-        popl %ebp
-        ret
-
-
-
-## Clear8_x86 isnt optimised fully yet as it seems to be a tiny bit slower
-## than the C routine
-_ClearMMX_8:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl 4(%ebp),%eax       # pixel value
-        movl 4(%ebp),%ebx
-
-        movl 12(%ebp),%edx      # height
-        andl $0x0ff,%ebx
-
-        shll $8,%eax            # Put the byte pixel value in all four bytes
-        movl (%ebp),%edi        # destination
-
-        movb %bl,%al
-        movb %bl,%bh
-
-        shll $16,%eax
-
-        movb %bh,%ah
-        movb %bl,%al
-
-        movd %eax,%mm0
-        movd %eax,%mm1
-
-        psllq $32,%mm0
-
-        por %mm1,%mm0
-
-_ClearMMX_8.L_y:
-        movl 8(%ebp),%ecx
-
-        testl $3,%edi           # Align mod 4
-        jz _ClearMMX_8.L_aligned
-
-        movl %edi,%ebx
-
-        andl $3,%ebx
-
-        movb %al,(%edi)         # Unrolled (copy & paste), align and jump
-        incl %edi               # if finished, faster than a loop...
-        decl %ecx
-        jz _ClearMMX_8.L_endline
-        decl %ebx
-        jz _ClearMMX_8.L_aligned
-
-        movb %al,(%edi)         # Second pixel
-        incl %edi
-        decl %ecx
-        jz _ClearMMX_8.L_endline
-        decl %ebx
-        jz _ClearMMX_8.L_aligned
-
-        movb %al,(%edi)         # Third pixel
-        incl %edi
-        decl %ecx
-        jz _ClearMMX_8.L_endline
-        decl %ebx
-        jz _ClearMMX_8.L_aligned
-
-_ClearMMX_8.L_aligned:
-        movl %ecx,%ebx          # Store ecx for later
-
-        shrl $3,%ecx            # We write 8 pixels at once
-        jz _ClearMMX_8.L_last
-
-_ClearMMX_8.L_x:
-        movq %mm0,(%edi)
-        addl $8,%edi
-
-        decl %ecx
-        jnz _ClearMMX_8.L_x
-
-_ClearMMX_8.L_last:
-        movl %ebx,%ecx          # Clean up trailing pixels
-
-        andl $7,%ecx            # Could be up to 7 left
-        jz _ClearMMX_8.L_endline
-
-        testb $0b100,%cl        # If theres less than four jump
-        jz _ClearMMX_8.L_lessthanfour
-
-        movl %eax,(%edi)        # Otherwise write a dword
-        addl $4,%edi
-
-        subl $4,%ecx
-
-_ClearMMX_8.L_lessthanfour:
-        rep
- stosb              # Clean up the very rest
-
-_ClearMMX_8.L_endline:
-        addl 16(%ebp),%edi
-
-        decl %edx
-        jnz _ClearMMX_8.L_y
-
-        emms
-
-        popl %ebp
-        ret

+ 276 - 0
packages/hermes/src/i386/mmx_clr.inc

@@ -0,0 +1,276 @@
+{
+    MMX surface clear routines for HERMES
+    Copyright (c) 1998 Christian Nentwich ([email protected])
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+{$ASMMODE att}
+
+{
+ --------------------------------------------------------------------------
+ HermesClearInterface (ebp+..)
+   0: char8 *dest
+   4: int32 value
+   8: unsigned int width (already checked to be >0!)
+  12: unsigned int height (already checked to be >0!)
+  16: int add
+}
+procedure ClearMMX_32(hci: PHermesClearInterface); cdecl; assembler;
+asm
+        pushl %ebp
+        movl 8(%ebp),%ebp
+
+        movl 4(%ebp),%eax       // pixel value
+        movd 4(%ebp),%mm0
+
+        movl 12(%ebp),%edx      // height
+        movq %mm0,%mm1
+
+        psllq $32,%mm0
+        movl (%ebp),%edi        // destination
+
+        por %mm1,%mm0
+.L_y:
+        movl 8(%ebp),%ecx
+
+        movl %ecx,%ebx
+
+        shrl $1,%ecx
+        jz .L_last
+
+.L_x:
+        movq %mm0,(%edi)
+        addl $8,%edi
+
+        decl %ecx
+        jnz .L_x
+
+
+.L_last:
+        testl $1,%ebx
+        jz .L_endline
+
+        movl %eax,(%edi)
+        addl $4,%edi
+
+.L_endline:
+
+        addl 16(%ebp),%edi
+
+        decl %edx
+        jnz .L_y
+
+        emms
+        popl %ebp
+end;
+
+procedure ClearMMX_24(hci: PHermesClearInterface); cdecl; assembler;
+asm
+end;
+
+procedure ClearMMX_16(hci: PHermesClearInterface); cdecl; assembler;
+asm
+        pushl %ebp
+        movl 8(%ebp),%ebp
+
+        movl 4(%ebp),%eax       // pixel value
+        movl 4(%ebp),%ebx
+
+        movl 12(%ebp),%edx      // height
+        movl (%ebp),%edi        // destination
+
+        shll $16,%eax           // Duplicate pixel value
+        andl $0x0ffff,%ebx
+
+        orl %ebx,%eax
+
+        movd %eax,%mm0
+        movd %eax,%mm1
+
+        psllq $32,%mm0
+
+        por %mm1,%mm0
+.L_y:
+        movl 8(%ebp),%ecx
+
+        testl $3,%edi           // Check if destination is aligned mod 4
+        jz .L_aligned
+
+        movw %ax,(%edi)         // otherwise write one pixel
+        addl $2,%edi
+
+        decl %ecx
+        jz .L_endline
+
+.L_aligned:
+        movl %ecx,%ebx
+        shrl $2,%ecx
+
+        jz .L_last
+
+.L_x:
+        movq %mm0,(%edi)
+        addl $8,%edi
+
+        decl %ecx
+        jnz .L_x
+
+.L_last:
+        andl $3,%ebx
+        jz .L_endline
+
+        movw %ax,(%edi)         // Write trailing pixels
+        addl $2,%edi
+        decl %ebx
+        jz .L_endline
+
+        movw %ax,(%edi)
+        addl $2,%edi
+        decl %ebx
+        jz .L_endline
+
+        movw %ax,(%edi)
+        addl $2,%edi
+        decl %ebx
+        jnz .L_endline
+
+.L_endline:
+        addl 16(%ebp),%edi
+
+        decl %edx
+        jnz .L_y
+
+        emms
+        popl %ebp
+end;
+
+
+{
+ Clear8_x86 isnt optimised fully yet as it seems to be a tiny bit slower
+ than the C routine
+}
+procedure ClearMMX_8(hci: PHermesClearInterface); cdecl; assembler;
+asm
+        pushl %ebp
+        movl 8(%ebp),%ebp
+
+        movl 4(%ebp),%eax       // pixel value
+        movl 4(%ebp),%ebx
+
+        movl 12(%ebp),%edx      // height
+        andl $0x0ff,%ebx
+
+        shll $8,%eax            // Put the byte pixel value in all four bytes
+        movl (%ebp),%edi        // destination
+
+        movb %bl,%al
+        movb %bl,%bh
+
+        shll $16,%eax
+
+        movb %bh,%ah
+        movb %bl,%al
+
+        movd %eax,%mm0
+        movd %eax,%mm1
+
+        psllq $32,%mm0
+
+        por %mm1,%mm0
+
+.L_y:
+        movl 8(%ebp),%ecx
+
+        testl $3,%edi           // Align mod 4
+        jz .L_aligned
+
+        movl %edi,%ebx
+
+        andl $3,%ebx
+
+        movb %al,(%edi)         // Unrolled (copy & paste), align and jump
+        incl %edi               // if finished, faster than a loop...
+        decl %ecx
+        jz .L_endline
+        decl %ebx
+        jz .L_aligned
+
+        movb %al,(%edi)         // Second pixel
+        incl %edi
+        decl %ecx
+        jz .L_endline
+        decl %ebx
+        jz .L_aligned
+
+        movb %al,(%edi)         // Third pixel
+        incl %edi
+        decl %ecx
+        jz .L_endline
+        decl %ebx
+        jz .L_aligned
+
+.L_aligned:
+        movl %ecx,%ebx          // Store ecx for later
+
+        shrl $3,%ecx            // We write 8 pixels at once
+        jz .L_last
+
+.L_x:
+        movq %mm0,(%edi)
+        addl $8,%edi
+
+        decl %ecx
+        jnz .L_x
+
+.L_last:
+        movl %ebx,%ecx          // Clean up trailing pixels
+
+        andl $7,%ecx            // Could be up to 7 left
+        jz .L_endline
+
+        testb $0b100,%cl        // If theres less than four jump
+        jz .L_lessthanfour
+
+        movl %eax,(%edi)        // Otherwise write a dword
+        addl $4,%edi
+
+        subl $4,%ecx
+
+.L_lessthanfour:
+        rep
+ stosb              // Clean up the very rest
+
+.L_endline:
+        addl 16(%ebp),%edi
+
+        decl %edx
+        jnz .L_y
+
+        emms
+        popl %ebp
+end;

+ 0 - 67
packages/hermes/src/i386/mmx_main.as

@@ -1,67 +0,0 @@
-#
-# x86 format converters for HERMES
-# Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-# Most routines are (c) Glenn Fiedler ([email protected]), used with permission
-#
-
-#BITS 32
-
-.globl _ConvertMMX
-.globl _mmxreturn
-
-
-.text
-
-## _ConvertMMX:
-## [ESP+8] ConverterInfo*
-## --------------------------------------------------------------------------
-## ConverterInfo (ebp+..)
-##   0: void *s_pixels
-##   4: int s_width
-##   8: int s_height
-##  12: int s_add
-##  16: void *d_pixels
-##  20: int d_width
-##  24: int d_height
-##  28: int d_add
-##  32: void (*converter_function)()
-##  36: int32 *lookup
-
-_ConvertMMX:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%eax
-
-        cmpl $0,4(%eax)
-        je endconvert
-
-        movl %eax,%ebp
-
-        movl (%ebp),%esi
-        movl 16(%ebp),%edi
-
-y_loop:
-        movl 4(%ebp),%ecx
-
-        jmp *32(%ebp)
-
-_mmxreturn:
-        addl 12(%ebp),%esi
-        addl 28(%ebp),%edi
-
-        decl 8(%ebp)
-        jnz y_loop
-
-
-        popl %ebp
-
-endconvert:
-        emms
-
-        ret

+ 83 - 0
packages/hermes/src/i386/mmx_main.inc

@@ -0,0 +1,83 @@
+{
+    x86 format converters for HERMES
+    Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
+    Most routines are (c) Glenn Fiedler ([email protected]), used with permission
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+label
+  _MMXRETURN;
+
+{ _ConvertMMX:
+ [ESP+8] ConverterInfo*
+ --------------------------------------------------------------------------
+ ConverterInfo (ebp+..)
+   0: void *s_pixels
+   4: int s_width
+   8: int s_height
+  12: int s_add
+  16: void *d_pixels
+  20: int d_width
+  24: int d_height
+  28: int d_add
+  32: void (*converter_function)()
+  36: int32 *lookup
+}
+procedure ConvertMMX(hci: PHermesConverterInterface); cdecl; assembler;
+label
+  y_loop, endconvert;
+asm
+        movl 8(%ebp),%eax
+
+        cmpl $0,4(%eax)
+        je endconvert
+
+        pushl %ebp
+        movl %eax,%ebp
+
+        movl (%ebp),%esi
+        movl 16(%ebp),%edi
+
+y_loop:
+        movl 4(%ebp),%ecx
+
+        jmp *32(%ebp)
+
+_MMXRETURN:
+        addl 12(%ebp),%esi
+        addl 28(%ebp),%edi
+
+        decl 8(%ebp)
+        jnz y_loop
+
+
+        popl %ebp
+
+endconvert:
+        emms
+end;

+ 0 - 383
packages/hermes/src/i386/mmxp2_32.as

@@ -1,383 +0,0 @@
-#
-# pII-optimised MMX format converters for HERMES
-# Copyright (c) 1998 Christian Nentwich ([email protected])
-#   and (c) 1999 Jonathan Matthew ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-# COPYRIGHT NOTICE
-#
-# This file partly contains code that is (c) Intel Corporation, specifically
-# the mode detection routine, and the converter to 15 bit (8 pixel
-# conversion routine from the mmx programming tutorial pages).
-#
-#
-# These routines aren't exactly pII optimised - it's just that as they
-# are, theyre terrible on p5 MMXs, but less so on pIIs.  Someone needs to
-# optimise them for p5 MMXs..
-
-#BITS 32
-
-
-.globl _ConvertMMXpII32_24RGB888
-.globl _ConvertMMXpII32_16RGB565
-.globl _ConvertMMXpII32_16BGR565
-.globl _ConvertMMXpII32_16RGB555
-.globl _ConvertMMXpII32_16BGR555
-
-.extern _mmxreturn
-
-.data
-
-.align 8
-
-## Constants for conversion routines
-
-mmx32_rgb888_mask: .long 0x00ffffff,0x00ffffff
-
-mmx32_rgb565_b: .long 0x000000f8,0x000000f8
-mmx32_rgb565_g: .long 0x0000fc00,0x0000fc00
-mmx32_rgb565_r: .long 0x00f80000,0x00f80000
-
-mmx32_rgb555_rb: .long 0x00f800f8,0x00f800f8
-mmx32_rgb555_g: .long 0x0000f800,0x0000f800
-mmx32_rgb555_mul: .long 0x20000008,0x20000008
-mmx32_bgr555_mul: .long 0x00082000,0x00082000
-
-
-
-.text
-
-_ConvertMMXpII32_24RGB888:
-
-        # set up mm6 as the mask, mm7 as zero
-        movq mmx32_rgb888_mask,%mm6
-        pxor %mm7,%mm7
-
-        movl %ecx,%edx                  # save ecx
-        andl $0x0fffffffc,%ecx          # clear lower two bits
-        jnz _ConvertMMXpII32_24RGB888.L1
-        jmp _ConvertMMXpII32_24RGB888.L2
-
-_ConvertMMXpII32_24RGB888.L1:
-
-        movq (%esi),%mm0                # A R G B a r g b
-        pand %mm6,%mm0                  # 0 R G B 0 r g b
-        movq 8(%esi),%mm1               # A R G B a r g b
-        pand %mm6,%mm1                  # 0 R G B 0 r g b
-
-        movq %mm0,%mm2                  # 0 R G B 0 r g b
-        punpckhdq %mm7,%mm2             # 0 0 0 0 0 R G B
-        punpckldq %mm7,%mm0             # 0 0 0 0 0 r g b
-        psllq $24,%mm2                  # 0 0 R G B 0 0 0
-        por %mm2,%mm0                   # 0 0 R G B r g b
-
-        movq %mm1,%mm3                  # 0 R G B 0 r g b
-        psllq $48,%mm3                  # g b 0 0 0 0 0 0
-        por %mm3,%mm0                   # g b R G B r g b
-
-        movq %mm1,%mm4                  # 0 R G B 0 r g b
-        punpckhdq %mm7,%mm4             # 0 0 0 0 0 R G B
-        punpckldq %mm7,%mm1             # 0 0 0 0 0 r g b
-        psrlq $16,%mm1                  # 0 0 0 R G B 0 r
-        psllq $8,%mm4                   # 0 0 0 0 R G B 0
-        por %mm4,%mm1                   # 0 0 0 0 R G B r
-
-        movq %mm0,(%edi)
-        addl $16,%esi
-        movd %mm1,8(%edi)
-        addl $12,%edi
-        subl $4,%ecx
-        jnz _ConvertMMXpII32_24RGB888.L1
-
-_ConvertMMXpII32_24RGB888.L2:
-        movl %edx,%ecx
-        andl $3,%ecx
-        jz _ConvertMMXpII32_24RGB888.L4
-_ConvertMMXpII32_24RGB888.L3:
-        movb (%esi),%al
-        movb 1(%esi),%bl
-        movb 2(%esi),%dl
-        movb %al,(%edi)
-        movb %bl,1(%edi)
-        movb %dl,2(%edi)
-        addl $4,%esi
-        addl $3,%edi
-        decl %ecx
-        jnz _ConvertMMXpII32_24RGB888.L3
-_ConvertMMXpII32_24RGB888.L4:
-        jmp _mmxreturn
-
-
-
-_ConvertMMXpII32_16RGB565:
-
-        # set up masks
-        movq mmx32_rgb565_b,%mm5
-        movq mmx32_rgb565_g,%mm6
-        movq mmx32_rgb565_r,%mm7
-
-        movl %ecx,%edx
-        shrl $2,%ecx
-        jnz _ConvertMMXpII32_16RGB565.L1
-        jmp _ConvertMMXpII32_16RGB565.L2 # not necessary at the moment, but doesnt hurt (much)
-
-_ConvertMMXpII32_16RGB565.L1:
-        movq (%esi),%mm0        # argb
-        movq %mm0,%mm1          # argb
-        pand %mm6,%mm0          # 00g0
-        movq %mm1,%mm3          # argb
-        pand %mm5,%mm1          # 000b
-        pand %mm7,%mm3          # 0r00
-        pslld $2,%mm1           # 0 0 000000bb bbb00000
-        por %mm1,%mm0           # 0 0 ggggggbb bbb00000
-        psrld $5,%mm0           # 0 0 00000ggg gggbbbbb
-
-        movq 8(%esi),%mm4       # argb
-        movq %mm4,%mm2          # argb
-        pand %mm6,%mm4          # 00g0
-        movq %mm2,%mm1          # argb
-        pand %mm5,%mm2          # 000b
-        pand %mm7,%mm1          # 0r00
-        pslld $2,%mm2           # 0 0 000000bb bbb00000
-        por %mm2,%mm4           # 0 0 ggggggbb bbb00000
-        psrld $5,%mm4           # 0 0 00000ggg gggbbbbb
-
-        packuswb %mm1,%mm3      # R 0 r 0
-        packssdw %mm4,%mm0      # as above.. ish
-        por %mm3,%mm0           # done.
-        movq %mm0,(%edi)
-
-        addl $16,%esi
-        addl $8,%edi
-        decl %ecx
-        jnz _ConvertMMXpII32_16RGB565.L1
-
-_ConvertMMXpII32_16RGB565.L2:
-        movl %edx,%ecx
-        andl $3,%ecx
-        jz _ConvertMMXpII32_16RGB565.L4
-_ConvertMMXpII32_16RGB565.L3:
-        movb (%esi),%al
-        movb 1(%esi),%bh
-        movb 2(%esi),%ah
-        shrb $3,%al
-        andl $0x0F81F,%eax         # BYTE?
-        shrl $5,%ebx
-        andl $0x07E0,%ebx          # BYTE?
-        addl %ebx,%eax
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-        jnz _ConvertMMXpII32_16RGB565.L3
-
-_ConvertMMXpII32_16RGB565.L4:
-        jmp _mmxreturn
-
-
-_ConvertMMXpII32_16BGR565:
-
-        movq mmx32_rgb565_r,%mm5
-        movq mmx32_rgb565_g,%mm6
-        movq mmx32_rgb565_b,%mm7
-
-        movl %ecx,%edx
-        shrl $2,%ecx
-        jnz _ConvertMMXpII32_16BGR565.L1
-        jmp _ConvertMMXpII32_16BGR565.L2
-
-_ConvertMMXpII32_16BGR565.L1:
-        movq (%esi),%mm0                # a r g b
-        movq %mm0,%mm1                  # a r g b
-        pand %mm6,%mm0                  # 0 0 g 0
-        movq %mm1,%mm3                  # a r g b
-        pand %mm5,%mm1                  # 0 r 0 0
-        pand %mm7,%mm3                  # 0 0 0 b
-
-        psllq $16,%mm3                  # 0 b 0 0
-        psrld $14,%mm1                  # 0 0 000000rr rrr00000
-        por %mm1,%mm0                   # 0 0 ggggggrr rrr00000
-        psrld $5,%mm0                   # 0 0 00000ggg gggrrrrr
-
-        movq 8(%esi),%mm4               # a r g b
-        movq %mm4,%mm2                  # a r g b
-        pand %mm6,%mm4                  # 0 0 g 0
-        movq %mm2,%mm1                  # a r g b
-        pand %mm5,%mm2                  # 0 r 0 0
-        pand %mm7,%mm1                  # 0 0 0 b
-
-        psllq $16,%mm1                  # 0 b 0 0
-        psrld $14,%mm2                  # 0 0 000000rr rrr00000
-        por %mm2,%mm4                   # 0 0 ggggggrr rrr00000
-        psrld $5,%mm4                   # 0 0 00000ggg gggrrrrr
-
-        packuswb %mm1,%mm3              # BBBBB000 00000000 bbbbb000 00000000
-        packssdw %mm4,%mm0              # 00000GGG GGGRRRRR 00000GGG GGGRRRRR
-        por %mm3,%mm0                   # BBBBBGGG GGGRRRRR bbbbbggg gggrrrrr
-        movq %mm0,(%edi)
-
-        addl $16,%esi
-        addl $8,%edi
-        decl %ecx
-        jnz _ConvertMMXpII32_16BGR565.L1
-
-_ConvertMMXpII32_16BGR565.L2:
-        andl $3,%edx
-        jz _ConvertMMXpII32_16BGR565.L4
-_ConvertMMXpII32_16BGR565.L3:
-        movb 2(%esi),%al
-        movb 1(%esi),%bh
-        movb (%esi),%ah
-        shrb $3,%al
-        andl $0x0F81F,%eax                 # BYTE ?
-        shrl $5,%ebx
-        andl $0x07E0,%ebx                  # BYTE ?
-        addl %ebx,%eax
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %edx
-        jnz _ConvertMMXpII32_16BGR565.L3
-
-_ConvertMMXpII32_16BGR565.L4:
-        jmp _mmxreturn
-
-_ConvertMMXpII32_16BGR555:
-
-        # the 16BGR555 converter is identical to the RGB555 one,
-        # except it uses a different multiplier for the pmaddwd
-        # instruction.  cool huh.
-
-        movq mmx32_bgr555_mul,%mm7
-        jmp _convert_bgr555_cheat
-
-# This is the same as the Intel version.. they obviously went to
-# much more trouble to expand/coil the loop than I did, so theirs
-# would almost certainly be faster, even if only a little.
-# I did rename 'mmx32_rgb555_add' to 'mmx32_rgb555_mul', which is
-# (I think) a more accurate name..
-_ConvertMMXpII32_16RGB555:
-
-        movq mmx32_rgb555_mul,%mm7
-_convert_bgr555_cheat:
-        movq mmx32_rgb555_g,%mm6
-
-        movl %ecx,%edx                     # Save ecx
-
-        andl $0x0fffffff8,%ecx             # clear lower three bits
-        jnz _convert_bgr555_cheat.L_OK
-        jmp _convert_bgr555_cheat.L2
-
-_convert_bgr555_cheat.L_OK:
-
-        movq 8(%esi),%mm2
-
-        movq (%esi),%mm0
-        movq %mm2,%mm3
-
-        pand mmx32_rgb555_rb,%mm3
-        movq %mm0,%mm1
-
-        pand mmx32_rgb555_rb,%mm1
-        pmaddwd %mm7,%mm3
-
-        pmaddwd %mm7,%mm1
-        pand %mm6,%mm2
-
-_convert_bgr555_cheat.L1:
-        movq 24(%esi),%mm4
-        pand %mm6,%mm0
-
-        movq 16(%esi),%mm5
-        por %mm2,%mm3
-
-        psrld $6,%mm3
-        por %mm0,%mm1
-
-        movq %mm4,%mm0
-        psrld $6,%mm1
-
-        pand mmx32_rgb555_rb,%mm0
-        packssdw %mm3,%mm1
-
-        movq %mm5,%mm3
-        pmaddwd %mm7,%mm0
-
-        pand mmx32_rgb555_rb,%mm3
-        pand %mm6,%mm4
-
-        movq %mm1,(%edi)
-        pmaddwd %mm7,%mm3
-
-        addl $32,%esi
-        por %mm0,%mm4
-
-        pand %mm6,%mm5
-        psrld $6,%mm4
-
-        movq 8(%esi),%mm2
-        por %mm3,%mm5
-
-        movq (%esi),%mm0
-        psrld $6,%mm5
-
-        movq %mm2,%mm3
-        movq %mm0,%mm1
-
-        pand mmx32_rgb555_rb,%mm3
-        packssdw %mm4,%mm5
-
-        pand mmx32_rgb555_rb,%mm1
-        pand %mm6,%mm2
-
-        movq %mm5,8(%edi)
-        pmaddwd %mm7,%mm3
-
-        pmaddwd %mm7,%mm1
-        addl $16,%edi
-
-        subl $8,%ecx
-        jz _convert_bgr555_cheat.L2
-        jmp _convert_bgr555_cheat.L1
-
-
-_convert_bgr555_cheat.L2:
-        movl %edx,%ecx
-
-        andl $7,%ecx
-        jz _convert_bgr555_cheat.L4
-
-_convert_bgr555_cheat.L3:
-        movl (%esi),%ebx
-        addl $4,%esi
-
-        movl %ebx,%eax
-        movl %ebx,%edx
-
-        shrl $3,%eax
-        shrl $6,%edx
-
-        andl $0b0000000000011111,%eax
-        andl $0b0000001111100000,%edx
-
-        shrl $9,%ebx
-
-        orl %edx,%eax
-
-        andl $0b0111110000000000,%ebx
-
-        orl %ebx,%eax
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-        decl %ecx
-        jnz _convert_bgr555_cheat.L3
-
-_convert_bgr555_cheat.L4:
-        jmp _mmxreturn

+ 391 - 0
packages/hermes/src/i386/mmxp2_32.inc

@@ -0,0 +1,391 @@
+{
+    pII-optimised MMX format converters for HERMES
+    Copyright (c) 1998 Christian Nentwich ([email protected])
+      and (c) 1999 Jonathan Matthew ([email protected])
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    COPYRIGHT NOTICE
+
+    This file partly contains code that is (c) Intel Corporation, specifically
+    the mode detection routine, and the converter to 15 bit (8 pixel
+    conversion routine from the mmx programming tutorial pages).
+
+    These routines aren't exactly pII optimised - it's just that as they
+    are, theyre terrible on p5 MMXs, but less so on pIIs.  Someone needs to
+    optimise them for p5 MMXs..
+}
+
+// Constants for conversion routines
+const
+  mmx32_rgb888_mask: QWord = $00ffffff00ffffff;
+
+  mmx32_rgb565_b: QWord = $000000f8000000f8;
+  mmx32_rgb565_g: QWord = $0000fc000000fc00;
+  mmx32_rgb565_r: QWord = $00f8000000f80000;
+
+  mmx32_rgb555_rb: QWord  = $00f800f800f800f8;
+  mmx32_rgb555_g: QWord   = $0000f8000000f800;
+  mmx32_rgb555_mul: QWord = $2000000820000008;
+  mmx32_bgr555_mul: QWord = $0008200000082000;
+
+procedure ConvertMMXpII32_24RGB888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // set up mm6 as the mask, mm7 as zero
+        movq mmx32_rgb888_mask,%mm6
+        pxor %mm7,%mm7
+
+        movl %ecx,%edx                  // save ecx
+        andl $0x0fffffffc,%ecx          // clear lower two bits
+        jnz .L1
+        jmp .L2
+
+.L1:
+
+        movq (%esi),%mm0                // A R G B a r g b
+        pand %mm6,%mm0                  // 0 R G B 0 r g b
+        movq 8(%esi),%mm1               // A R G B a r g b
+        pand %mm6,%mm1                  // 0 R G B 0 r g b
+
+        movq %mm0,%mm2                  // 0 R G B 0 r g b
+        punpckhdq %mm7,%mm2             // 0 0 0 0 0 R G B
+        punpckldq %mm7,%mm0             // 0 0 0 0 0 r g b
+        psllq $24,%mm2                  // 0 0 R G B 0 0 0
+        por %mm2,%mm0                   // 0 0 R G B r g b
+
+        movq %mm1,%mm3                  // 0 R G B 0 r g b
+        psllq $48,%mm3                  // g b 0 0 0 0 0 0
+        por %mm3,%mm0                   // g b R G B r g b
+
+        movq %mm1,%mm4                  // 0 R G B 0 r g b
+        punpckhdq %mm7,%mm4             // 0 0 0 0 0 R G B
+        punpckldq %mm7,%mm1             // 0 0 0 0 0 r g b
+        psrlq $16,%mm1                  // 0 0 0 R G B 0 r
+        psllq $8,%mm4                   // 0 0 0 0 R G B 0
+        por %mm4,%mm1                   // 0 0 0 0 R G B r
+
+        movq %mm0,(%edi)
+        addl $16,%esi
+        movd %mm1,8(%edi)
+        addl $12,%edi
+        subl $4,%ecx
+        jnz .L1
+
+.L2:
+        movl %edx,%ecx
+        andl $3,%ecx
+        jz .L4
+.L3:
+        movb (%esi),%al
+        movb 1(%esi),%bl
+        movb 2(%esi),%dl
+        movb %al,(%edi)
+        movb %bl,1(%edi)
+        movb %dl,2(%edi)
+        addl $4,%esi
+        addl $3,%edi
+        decl %ecx
+        jnz .L3
+.L4:
+        jmp _MMXRETURN
+end;
+
+procedure ConvertMMXpII32_16RGB565(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // set up masks
+        movq mmx32_rgb565_b,%mm5
+        movq mmx32_rgb565_g,%mm6
+        movq mmx32_rgb565_r,%mm7
+
+        movl %ecx,%edx
+        shrl $2,%ecx
+        jnz .L1
+        jmp .L2 // not necessary at the moment, but doesnt hurt (much)
+
+.L1:
+        movq (%esi),%mm0        // argb
+        movq %mm0,%mm1          // argb
+        pand %mm6,%mm0          // 00g0
+        movq %mm1,%mm3          // argb
+        pand %mm5,%mm1          // 000b
+        pand %mm7,%mm3          // 0r00
+        pslld $2,%mm1           // 0 0 000000bb bbb00000
+        por %mm1,%mm0           // 0 0 ggggggbb bbb00000
+        psrld $5,%mm0           // 0 0 00000ggg gggbbbbb
+
+        movq 8(%esi),%mm4       // argb
+        movq %mm4,%mm2          // argb
+        pand %mm6,%mm4          // 00g0
+        movq %mm2,%mm1          // argb
+        pand %mm5,%mm2          // 000b
+        pand %mm7,%mm1          // 0r00
+        pslld $2,%mm2           // 0 0 000000bb bbb00000
+        por %mm2,%mm4           // 0 0 ggggggbb bbb00000
+        psrld $5,%mm4           // 0 0 00000ggg gggbbbbb
+
+        packuswb %mm1,%mm3      // R 0 r 0
+        packssdw %mm4,%mm0      // as above.. ish
+        por %mm3,%mm0           // done.
+        movq %mm0,(%edi)
+
+        addl $16,%esi
+        addl $8,%edi
+        decl %ecx
+        jnz .L1
+
+.L2:
+        movl %edx,%ecx
+        andl $3,%ecx
+        jz .L4
+.L3:
+        movb (%esi),%al
+        movb 1(%esi),%bh
+        movb 2(%esi),%ah
+        shrb $3,%al
+        andl $0x0F81F,%eax         // BYTE?
+        shrl $5,%ebx
+        andl $0x07E0,%ebx          // BYTE?
+        addl %ebx,%eax
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+        jnz .L3
+
+.L4:
+        jmp _MMXRETURN
+end;
+
+procedure ConvertMMXpII32_16BGR565(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        movq mmx32_rgb565_r,%mm5
+        movq mmx32_rgb565_g,%mm6
+        movq mmx32_rgb565_b,%mm7
+
+        movl %ecx,%edx
+        shrl $2,%ecx
+        jnz .L1
+        jmp .L2
+
+.L1:
+        movq (%esi),%mm0                // a r g b
+        movq %mm0,%mm1                  // a r g b
+        pand %mm6,%mm0                  // 0 0 g 0
+        movq %mm1,%mm3                  // a r g b
+        pand %mm5,%mm1                  // 0 r 0 0
+        pand %mm7,%mm3                  // 0 0 0 b
+
+        psllq $16,%mm3                  // 0 b 0 0
+        psrld $14,%mm1                  // 0 0 000000rr rrr00000
+        por %mm1,%mm0                   // 0 0 ggggggrr rrr00000
+        psrld $5,%mm0                   // 0 0 00000ggg gggrrrrr
+
+        movq 8(%esi),%mm4               // a r g b
+        movq %mm4,%mm2                  // a r g b
+        pand %mm6,%mm4                  // 0 0 g 0
+        movq %mm2,%mm1                  // a r g b
+        pand %mm5,%mm2                  // 0 r 0 0
+        pand %mm7,%mm1                  // 0 0 0 b
+
+        psllq $16,%mm1                  // 0 b 0 0
+        psrld $14,%mm2                  // 0 0 000000rr rrr00000
+        por %mm2,%mm4                   // 0 0 ggggggrr rrr00000
+        psrld $5,%mm4                   // 0 0 00000ggg gggrrrrr
+
+        packuswb %mm1,%mm3              // BBBBB000 00000000 bbbbb000 00000000
+        packssdw %mm4,%mm0              // 00000GGG GGGRRRRR 00000GGG GGGRRRRR
+        por %mm3,%mm0                   // BBBBBGGG GGGRRRRR bbbbbggg gggrrrrr
+        movq %mm0,(%edi)
+
+        addl $16,%esi
+        addl $8,%edi
+        decl %ecx
+        jnz .L1
+
+.L2:
+        andl $3,%edx
+        jz .L4
+.L3:
+        movb 2(%esi),%al
+        movb 1(%esi),%bh
+        movb (%esi),%ah
+        shrb $3,%al
+        andl $0x0F81F,%eax                 // BYTE ?
+        shrl $5,%ebx
+        andl $0x07E0,%ebx                  // BYTE ?
+        addl %ebx,%eax
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %edx
+        jnz .L3
+
+.L4:
+        jmp _MMXRETURN
+end;
+
+label
+  _convert_bgr555_cheat;
+
+procedure ConvertMMXpII32_16BGR555(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // the 16BGR555 converter is identical to the RGB555 one,
+        // except it uses a different multiplier for the pmaddwd
+        // instruction.  cool huh.
+
+        movq mmx32_bgr555_mul,%mm7
+        jmp _convert_bgr555_cheat
+end;
+
+// This is the same as the Intel version.. they obviously went to
+// much more trouble to expand/coil the loop than I did, so theirs
+// would almost certainly be faster, even if only a little.
+// I did rename 'mmx32_rgb555_add' to 'mmx32_rgb555_mul', which is
+// (I think) a more accurate name..
+procedure ConvertMMXpII32_16RGB555(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        movq mmx32_rgb555_mul,%mm7
+_convert_bgr555_cheat:
+        movq mmx32_rgb555_g,%mm6
+
+        movl %ecx,%edx                     // Save ecx
+
+        andl $0x0fffffff8,%ecx             // clear lower three bits
+        jnz .L_OK
+        jmp .L2
+
+.L_OK:
+
+        movq 8(%esi),%mm2
+
+        movq (%esi),%mm0
+        movq %mm2,%mm3
+
+        pand mmx32_rgb555_rb,%mm3
+        movq %mm0,%mm1
+
+        pand mmx32_rgb555_rb,%mm1
+        pmaddwd %mm7,%mm3
+
+        pmaddwd %mm7,%mm1
+        pand %mm6,%mm2
+
+.L1:
+        movq 24(%esi),%mm4
+        pand %mm6,%mm0
+
+        movq 16(%esi),%mm5
+        por %mm2,%mm3
+
+        psrld $6,%mm3
+        por %mm0,%mm1
+
+        movq %mm4,%mm0
+        psrld $6,%mm1
+
+        pand mmx32_rgb555_rb,%mm0
+        packssdw %mm3,%mm1
+
+        movq %mm5,%mm3
+        pmaddwd %mm7,%mm0
+
+        pand mmx32_rgb555_rb,%mm3
+        pand %mm6,%mm4
+
+        movq %mm1,(%edi)
+        pmaddwd %mm7,%mm3
+
+        addl $32,%esi
+        por %mm0,%mm4
+
+        pand %mm6,%mm5
+        psrld $6,%mm4
+
+        movq 8(%esi),%mm2
+        por %mm3,%mm5
+
+        movq (%esi),%mm0
+        psrld $6,%mm5
+
+        movq %mm2,%mm3
+        movq %mm0,%mm1
+
+        pand mmx32_rgb555_rb,%mm3
+        packssdw %mm4,%mm5
+
+        pand mmx32_rgb555_rb,%mm1
+        pand %mm6,%mm2
+
+        movq %mm5,8(%edi)
+        pmaddwd %mm7,%mm3
+
+        pmaddwd %mm7,%mm1
+        addl $16,%edi
+
+        subl $8,%ecx
+        jz .L2
+        jmp .L1
+
+
+.L2:
+        movl %edx,%ecx
+
+        andl $7,%ecx
+        jz .L4
+
+.L3:
+        movl (%esi),%ebx
+        addl $4,%esi
+
+        movl %ebx,%eax
+        movl %ebx,%edx
+
+        shrl $3,%eax
+        shrl $6,%edx
+
+        andl $0b0000000000011111,%eax
+        andl $0b0000001111100000,%edx
+
+        shrl $9,%ebx
+
+        orl %edx,%eax
+
+        andl $0b0111110000000000,%ebx
+
+        orl %ebx,%eax
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+        decl %ecx
+        jnz .L3
+
+.L4:
+        jmp _MMXRETURN
+end;

+ 0 - 163
packages/hermes/src/i386/mmxp_32.as

@@ -1,163 +0,0 @@
-#
-# MMX format converters for HERMES
-# Copyright (c) 1998 Christian Nentwich ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-# COPYRIGHT NOTICE
-#
-# This file partly contains code that is (c) Intel Corporation, specifically
-# the mode detection routine, and the converter to 15 bit (8 pixel
-# conversion routine from the mmx programming tutorial pages).
-#
-
-#BITS 32
-
-
-.globl _ConvertMMXp32_16RGB555
-
-.extern _mmxreturn
-
-.data
-
-.align 8
-
-mmx32_rgb555_rb: .long 0x00f800f8,0x00f800f8 # Constants for conversion routines
-mmx32_rgb555_add: .long 0x20000008,0x20000008
-mmx32_rgb555_g: .long 0x0000f800,0x0000f800
-
-
-
-.text
-
-
-
-## Gone for now, it didnt draw correctly AND was slower than the x86 routine
-_ConvertMMXp32_16RGB565:
-
-        jmp _mmxreturn
-
-
-
-
-_ConvertMMXp32_16RGB555:
-
-        movq mmx32_rgb555_add,%mm7
-        movq mmx32_rgb555_g,%mm6
-
-        movl %ecx,%edx                     # Save ecx
-
-        andl $0x0fffffff8,%ecx             # clear lower three bits
-        jnz _ConvertMMXp32_16RGB555.L_OK
-        jmp _ConvertMMXp32_16RGB555.L2
-
-_ConvertMMXp32_16RGB555.L_OK:
-
-        movq 8(%esi),%mm2
-
-        movq (%esi),%mm0
-        movq %mm2,%mm3
-
-        pand mmx32_rgb555_rb,%mm3
-        movq %mm0,%mm1
-
-        pand mmx32_rgb555_rb,%mm1
-        pmaddwd %mm7,%mm3
-
-        pmaddwd %mm7,%mm1
-        pand %mm6,%mm2
-
-_ConvertMMXp32_16RGB555.L1:
-        movq 24(%esi),%mm4
-        pand %mm6,%mm0
-
-        movq 16(%esi),%mm5
-        por %mm2,%mm3
-
-        psrld $6,%mm3
-        por %mm0,%mm1
-
-        movq %mm4,%mm0
-        psrld $6,%mm1
-
-        pand mmx32_rgb555_rb,%mm0
-        packssdw %mm3,%mm1
-
-        movq %mm5,%mm3
-        pmaddwd %mm7,%mm0
-
-        pand mmx32_rgb555_rb,%mm3
-        pand %mm6,%mm4
-
-        movq %mm1,(%edi)
-        pmaddwd %mm7,%mm3
-
-        addl $32,%esi
-        por %mm0,%mm4
-
-        pand %mm6,%mm5
-        psrld $6,%mm4
-
-        movq 8(%esi),%mm2
-        por %mm3,%mm5
-
-        movq (%esi),%mm0
-        psrld $6,%mm5
-
-        movq %mm2,%mm3
-        movq %mm0,%mm1
-
-        pand mmx32_rgb555_rb,%mm3
-        packssdw %mm4,%mm5
-
-        pand mmx32_rgb555_rb,%mm1
-        pand %mm6,%mm2
-
-        movq %mm5,8(%edi)
-        pmaddwd %mm7,%mm3
-
-        pmaddwd %mm7,%mm1
-        addl $16,%edi
-
-        subl $8,%ecx
-        jz _ConvertMMXp32_16RGB555.L2
-        jmp _ConvertMMXp32_16RGB555.L1
-
-
-_ConvertMMXp32_16RGB555.L2:
-        movl %edx,%ecx
-
-        andl $7,%ecx
-        jz _ConvertMMXp32_16RGB555.L4
-
-_ConvertMMXp32_16RGB555.L3:
-        movl (%esi),%ebx
-        addl $4,%esi
-
-        movl %ebx,%eax
-        movl %ebx,%edx
-
-        shrl $3,%eax
-        shrl $6,%edx
-
-        andl $0b0000000000011111,%eax
-        andl $0b0000001111100000,%edx
-
-        shrl $9,%ebx
-
-        orl %edx,%eax
-
-        andl $0b0111110000000000,%ebx
-
-        orl %ebx,%eax
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-        decl %ecx
-        jnz _ConvertMMXp32_16RGB555.L3
-
-_ConvertMMXp32_16RGB555.L4:
-        jmp _mmxreturn

+ 168 - 0
packages/hermes/src/i386/mmxp_32.inc

@@ -0,0 +1,168 @@
+{
+    MMX format converters for HERMES
+    Copyright (c) 1998 Christian Nentwich ([email protected])
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    COPYRIGHT NOTICE
+
+    This file partly contains code that is (c) Intel Corporation, specifically
+    the mode detection routine, and the converter to 15 bit (8 pixel
+    conversion routine from the mmx programming tutorial pages).
+}
+
+// Constants for conversion routines
+const
+  //mmx32_rgb555_rb: QWord = $00f800f800f800f8;
+  mmx32_rgb555_add: QWord = $2000000820000008;
+  //mmx32_rgb555_g: QWord = $0000f8000000f800;
+
+{## Gone for now, it didnt draw correctly AND was slower than the x86 routine
+_ConvertMMXp32_16RGB565:
+
+        jmp _MMXRETURN}
+
+procedure ConvertMMXp32_16RGB555(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        movq mmx32_rgb555_add,%mm7
+        movq mmx32_rgb555_g,%mm6
+
+        movl %ecx,%edx                     // Save ecx
+
+        andl $0x0fffffff8,%ecx             // clear lower three bits
+        jnz .L_OK
+        jmp .L2
+
+.L_OK:
+
+        movq 8(%esi),%mm2
+
+        movq (%esi),%mm0
+        movq %mm2,%mm3
+
+        pand mmx32_rgb555_rb,%mm3
+        movq %mm0,%mm1
+
+        pand mmx32_rgb555_rb,%mm1
+        pmaddwd %mm7,%mm3
+
+        pmaddwd %mm7,%mm1
+        pand %mm6,%mm2
+
+.L1:
+        movq 24(%esi),%mm4
+        pand %mm6,%mm0
+
+        movq 16(%esi),%mm5
+        por %mm2,%mm3
+
+        psrld $6,%mm3
+        por %mm0,%mm1
+
+        movq %mm4,%mm0
+        psrld $6,%mm1
+
+        pand mmx32_rgb555_rb,%mm0
+        packssdw %mm3,%mm1
+
+        movq %mm5,%mm3
+        pmaddwd %mm7,%mm0
+
+        pand mmx32_rgb555_rb,%mm3
+        pand %mm6,%mm4
+
+        movq %mm1,(%edi)
+        pmaddwd %mm7,%mm3
+
+        addl $32,%esi
+        por %mm0,%mm4
+
+        pand %mm6,%mm5
+        psrld $6,%mm4
+
+        movq 8(%esi),%mm2
+        por %mm3,%mm5
+
+        movq (%esi),%mm0
+        psrld $6,%mm5
+
+        movq %mm2,%mm3
+        movq %mm0,%mm1
+
+        pand mmx32_rgb555_rb,%mm3
+        packssdw %mm4,%mm5
+
+        pand mmx32_rgb555_rb,%mm1
+        pand %mm6,%mm2
+
+        movq %mm5,8(%edi)
+        pmaddwd %mm7,%mm3
+
+        pmaddwd %mm7,%mm1
+        addl $16,%edi
+
+        subl $8,%ecx
+        jz .L2
+        jmp .L1
+
+
+.L2:
+        movl %edx,%ecx
+
+        andl $7,%ecx
+        jz .L4
+
+.L3:
+        movl (%esi),%ebx
+        addl $4,%esi
+
+        movl %ebx,%eax
+        movl %ebx,%edx
+
+        shrl $3,%eax
+        shrl $6,%edx
+
+        andl $0b0000000000011111,%eax
+        andl $0b0000001111100000,%edx
+
+        shrl $9,%ebx
+
+        orl %edx,%eax
+
+        andl $0b0111110000000000,%ebx
+
+        orl %ebx,%eax
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+        decl %ecx
+        jnz .L3
+
+.L4:
+        jmp _MMXRETURN
+end;

+ 0 - 2059
packages/hermes/src/i386/x8616lut.as

@@ -1,2059 +0,0 @@
-
-.data
-
-_ConvertX86p16_32RGB888_LUT_X86:
-                .long 0x00000
-                .long 0x00000
-                .long 0x00008
-                .long 0x02000
-                .long 0x00010
-                .long 0x04000
-                .long 0x00018
-                .long 0x06100
-                .long 0x00020
-                .long 0x08100
-                .long 0x00029
-                .long 0x0a100
-                .long 0x00031
-                .long 0x0c200
-                .long 0x00039
-                .long 0x0e200
-                .long 0x00041
-                .long 0x80000
-                .long 0x0004a
-                .long 0x82000
-                .long 0x00052
-                .long 0x84000
-                .long 0x0005a
-                .long 0x86100
-                .long 0x00062
-                .long 0x88100
-                .long 0x0006a
-                .long 0x8a100
-                .long 0x00073
-                .long 0x8c200
-                .long 0x0007b
-                .long 0x8e200
-                .long 0x00083
-                .long 0x100000
-                .long 0x0008b
-                .long 0x102000
-                .long 0x00094
-                .long 0x104000
-                .long 0x0009c
-                .long 0x106100
-                .long 0x000a4
-                .long 0x108100
-                .long 0x000ac
-                .long 0x10a100
-                .long 0x000b4
-                .long 0x10c200
-                .long 0x000bd
-                .long 0x10e200
-                .long 0x000c5
-                .long 0x180000
-                .long 0x000cd
-                .long 0x182000
-                .long 0x000d5
-                .long 0x184000
-                .long 0x000de
-                .long 0x186100
-                .long 0x000e6
-                .long 0x188100
-                .long 0x000ee
-                .long 0x18a100
-                .long 0x000f6
-                .long 0x18c200
-                .long 0x000ff
-                .long 0x18e200
-                .long 0x00400
-                .long 0x200000
-                .long 0x00408
-                .long 0x202000
-                .long 0x00410
-                .long 0x204000
-                .long 0x00418
-                .long 0x206100
-                .long 0x00420
-                .long 0x208100
-                .long 0x00429
-                .long 0x20a100
-                .long 0x00431
-                .long 0x20c200
-                .long 0x00439
-                .long 0x20e200
-                .long 0x00441
-                .long 0x290000
-                .long 0x0044a
-                .long 0x292000
-                .long 0x00452
-                .long 0x294000
-                .long 0x0045a
-                .long 0x296100
-                .long 0x00462
-                .long 0x298100
-                .long 0x0046a
-                .long 0x29a100
-                .long 0x00473
-                .long 0x29c200
-                .long 0x0047b
-                .long 0x29e200
-                .long 0x00483
-                .long 0x310000
-                .long 0x0048b
-                .long 0x312000
-                .long 0x00494
-                .long 0x314000
-                .long 0x0049c
-                .long 0x316100
-                .long 0x004a4
-                .long 0x318100
-                .long 0x004ac
-                .long 0x31a100
-                .long 0x004b4
-                .long 0x31c200
-                .long 0x004bd
-                .long 0x31e200
-                .long 0x004c5
-                .long 0x390000
-                .long 0x004cd
-                .long 0x392000
-                .long 0x004d5
-                .long 0x394000
-                .long 0x004de
-                .long 0x396100
-                .long 0x004e6
-                .long 0x398100
-                .long 0x004ee
-                .long 0x39a100
-                .long 0x004f6
-                .long 0x39c200
-                .long 0x004ff
-                .long 0x39e200
-                .long 0x00800
-                .long 0x410000
-                .long 0x00808
-                .long 0x412000
-                .long 0x00810
-                .long 0x414000
-                .long 0x00818
-                .long 0x416100
-                .long 0x00820
-                .long 0x418100
-                .long 0x00829
-                .long 0x41a100
-                .long 0x00831
-                .long 0x41c200
-                .long 0x00839
-                .long 0x41e200
-                .long 0x00841
-                .long 0x4a0000
-                .long 0x0084a
-                .long 0x4a2000
-                .long 0x00852
-                .long 0x4a4000
-                .long 0x0085a
-                .long 0x4a6100
-                .long 0x00862
-                .long 0x4a8100
-                .long 0x0086a
-                .long 0x4aa100
-                .long 0x00873
-                .long 0x4ac200
-                .long 0x0087b
-                .long 0x4ae200
-                .long 0x00883
-                .long 0x520000
-                .long 0x0088b
-                .long 0x522000
-                .long 0x00894
-                .long 0x524000
-                .long 0x0089c
-                .long 0x526100
-                .long 0x008a4
-                .long 0x528100
-                .long 0x008ac
-                .long 0x52a100
-                .long 0x008b4
-                .long 0x52c200
-                .long 0x008bd
-                .long 0x52e200
-                .long 0x008c5
-                .long 0x5a0000
-                .long 0x008cd
-                .long 0x5a2000
-                .long 0x008d5
-                .long 0x5a4000
-                .long 0x008de
-                .long 0x5a6100
-                .long 0x008e6
-                .long 0x5a8100
-                .long 0x008ee
-                .long 0x5aa100
-                .long 0x008f6
-                .long 0x5ac200
-                .long 0x008ff
-                .long 0x5ae200
-                .long 0x00c00
-                .long 0x620000
-                .long 0x00c08
-                .long 0x622000
-                .long 0x00c10
-                .long 0x624000
-                .long 0x00c18
-                .long 0x626100
-                .long 0x00c20
-                .long 0x628100
-                .long 0x00c29
-                .long 0x62a100
-                .long 0x00c31
-                .long 0x62c200
-                .long 0x00c39
-                .long 0x62e200
-                .long 0x00c41
-                .long 0x6a0000
-                .long 0x00c4a
-                .long 0x6a2000
-                .long 0x00c52
-                .long 0x6a4000
-                .long 0x00c5a
-                .long 0x6a6100
-                .long 0x00c62
-                .long 0x6a8100
-                .long 0x00c6a
-                .long 0x6aa100
-                .long 0x00c73
-                .long 0x6ac200
-                .long 0x00c7b
-                .long 0x6ae200
-                .long 0x00c83
-                .long 0x730000
-                .long 0x00c8b
-                .long 0x732000
-                .long 0x00c94
-                .long 0x734000
-                .long 0x00c9c
-                .long 0x736100
-                .long 0x00ca4
-                .long 0x738100
-                .long 0x00cac
-                .long 0x73a100
-                .long 0x00cb4
-                .long 0x73c200
-                .long 0x00cbd
-                .long 0x73e200
-                .long 0x00cc5
-                .long 0x7b0000
-                .long 0x00ccd
-                .long 0x7b2000
-                .long 0x00cd5
-                .long 0x7b4000
-                .long 0x00cde
-                .long 0x7b6100
-                .long 0x00ce6
-                .long 0x7b8100
-                .long 0x00cee
-                .long 0x7ba100
-                .long 0x00cf6
-                .long 0x7bc200
-                .long 0x00cff
-                .long 0x7be200
-                .long 0x01000
-                .long 0x830000
-                .long 0x01008
-                .long 0x832000
-                .long 0x01010
-                .long 0x834000
-                .long 0x01018
-                .long 0x836100
-                .long 0x01020
-                .long 0x838100
-                .long 0x01029
-                .long 0x83a100
-                .long 0x01031
-                .long 0x83c200
-                .long 0x01039
-                .long 0x83e200
-                .long 0x01041
-                .long 0x8b0000
-                .long 0x0104a
-                .long 0x8b2000
-                .long 0x01052
-                .long 0x8b4000
-                .long 0x0105a
-                .long 0x8b6100
-                .long 0x01062
-                .long 0x8b8100
-                .long 0x0106a
-                .long 0x8ba100
-                .long 0x01073
-                .long 0x8bc200
-                .long 0x0107b
-                .long 0x8be200
-                .long 0x01083
-                .long 0x940000
-                .long 0x0108b
-                .long 0x942000
-                .long 0x01094
-                .long 0x944000
-                .long 0x0109c
-                .long 0x946100
-                .long 0x010a4
-                .long 0x948100
-                .long 0x010ac
-                .long 0x94a100
-                .long 0x010b4
-                .long 0x94c200
-                .long 0x010bd
-                .long 0x94e200
-                .long 0x010c5
-                .long 0x9c0000
-                .long 0x010cd
-                .long 0x9c2000
-                .long 0x010d5
-                .long 0x9c4000
-                .long 0x010de
-                .long 0x9c6100
-                .long 0x010e6
-                .long 0x9c8100
-                .long 0x010ee
-                .long 0x9ca100
-                .long 0x010f6
-                .long 0x9cc200
-                .long 0x010ff
-                .long 0x9ce200
-                .long 0x01400
-                .long 0xa40000
-                .long 0x01408
-                .long 0xa42000
-                .long 0x01410
-                .long 0xa44000
-                .long 0x01418
-                .long 0xa46100
-                .long 0x01420
-                .long 0xa48100
-                .long 0x01429
-                .long 0xa4a100
-                .long 0x01431
-                .long 0xa4c200
-                .long 0x01439
-                .long 0xa4e200
-                .long 0x01441
-                .long 0xac0000
-                .long 0x0144a
-                .long 0xac2000
-                .long 0x01452
-                .long 0xac4000
-                .long 0x0145a
-                .long 0xac6100
-                .long 0x01462
-                .long 0xac8100
-                .long 0x0146a
-                .long 0xaca100
-                .long 0x01473
-                .long 0xacc200
-                .long 0x0147b
-                .long 0xace200
-                .long 0x01483
-                .long 0xb40000
-                .long 0x0148b
-                .long 0xb42000
-                .long 0x01494
-                .long 0xb44000
-                .long 0x0149c
-                .long 0xb46100
-                .long 0x014a4
-                .long 0xb48100
-                .long 0x014ac
-                .long 0xb4a100
-                .long 0x014b4
-                .long 0xb4c200
-                .long 0x014bd
-                .long 0xb4e200
-                .long 0x014c5
-                .long 0xbd0000
-                .long 0x014cd
-                .long 0xbd2000
-                .long 0x014d5
-                .long 0xbd4000
-                .long 0x014de
-                .long 0xbd6100
-                .long 0x014e6
-                .long 0xbd8100
-                .long 0x014ee
-                .long 0xbda100
-                .long 0x014f6
-                .long 0xbdc200
-                .long 0x014ff
-                .long 0xbde200
-                .long 0x01800
-                .long 0xc50000
-                .long 0x01808
-                .long 0xc52000
-                .long 0x01810
-                .long 0xc54000
-                .long 0x01818
-                .long 0xc56100
-                .long 0x01820
-                .long 0xc58100
-                .long 0x01829
-                .long 0xc5a100
-                .long 0x01831
-                .long 0xc5c200
-                .long 0x01839
-                .long 0xc5e200
-                .long 0x01841
-                .long 0xcd0000
-                .long 0x0184a
-                .long 0xcd2000
-                .long 0x01852
-                .long 0xcd4000
-                .long 0x0185a
-                .long 0xcd6100
-                .long 0x01862
-                .long 0xcd8100
-                .long 0x0186a
-                .long 0xcda100
-                .long 0x01873
-                .long 0xcdc200
-                .long 0x0187b
-                .long 0xcde200
-                .long 0x01883
-                .long 0xd50000
-                .long 0x0188b
-                .long 0xd52000
-                .long 0x01894
-                .long 0xd54000
-                .long 0x0189c
-                .long 0xd56100
-                .long 0x018a4
-                .long 0xd58100
-                .long 0x018ac
-                .long 0xd5a100
-                .long 0x018b4
-                .long 0xd5c200
-                .long 0x018bd
-                .long 0xd5e200
-                .long 0x018c5
-                .long 0xde0000
-                .long 0x018cd
-                .long 0xde2000
-                .long 0x018d5
-                .long 0xde4000
-                .long 0x018de
-                .long 0xde6100
-                .long 0x018e6
-                .long 0xde8100
-                .long 0x018ee
-                .long 0xdea100
-                .long 0x018f6
-                .long 0xdec200
-                .long 0x018ff
-                .long 0xdee200
-                .long 0x01c00
-                .long 0xe60000
-                .long 0x01c08
-                .long 0xe62000
-                .long 0x01c10
-                .long 0xe64000
-                .long 0x01c18
-                .long 0xe66100
-                .long 0x01c20
-                .long 0xe68100
-                .long 0x01c29
-                .long 0xe6a100
-                .long 0x01c31
-                .long 0xe6c200
-                .long 0x01c39
-                .long 0xe6e200
-                .long 0x01c41
-                .long 0xee0000
-                .long 0x01c4a
-                .long 0xee2000
-                .long 0x01c52
-                .long 0xee4000
-                .long 0x01c5a
-                .long 0xee6100
-                .long 0x01c62
-                .long 0xee8100
-                .long 0x01c6a
-                .long 0xeea100
-                .long 0x01c73
-                .long 0xeec200
-                .long 0x01c7b
-                .long 0xeee200
-                .long 0x01c83
-                .long 0xf60000
-                .long 0x01c8b
-                .long 0xf62000
-                .long 0x01c94
-                .long 0xf64000
-                .long 0x01c9c
-                .long 0xf66100
-                .long 0x01ca4
-                .long 0xf68100
-                .long 0x01cac
-                .long 0xf6a100
-                .long 0x01cb4
-                .long 0xf6c200
-                .long 0x01cbd
-                .long 0xf6e200
-                .long 0x01cc5
-                .long 0xff0000
-                .long 0x01ccd
-                .long 0xff2000
-                .long 0x01cd5
-                .long 0xff4000
-                .long 0x01cde
-                .long 0xff6100
-                .long 0x01ce6
-                .long 0xff8100
-                .long 0x01cee
-                .long 0xffa100
-                .long 0x01cf6
-                .long 0xffc200
-                .long 0x01cff
-                .long 0xffe200
-
-_ConvertX86p16_32BGR888_LUT_X86:
-                .long 0x00000
-                .long 0x00000
-                .long 0x80000
-                .long 0x02000
-                .long 0x100000
-                .long 0x04000
-                .long 0x180000
-                .long 0x06100
-                .long 0x200000
-                .long 0x08100
-                .long 0x290000
-                .long 0x0a100
-                .long 0x310000
-                .long 0x0c200
-                .long 0x390000
-                .long 0x0e200
-                .long 0x410000
-                .long 0x00008
-                .long 0x4a0000
-                .long 0x02008
-                .long 0x520000
-                .long 0x04008
-                .long 0x5a0000
-                .long 0x06108
-                .long 0x620000
-                .long 0x08108
-                .long 0x6a0000
-                .long 0x0a108
-                .long 0x730000
-                .long 0x0c208
-                .long 0x7b0000
-                .long 0x0e208
-                .long 0x830000
-                .long 0x00010
-                .long 0x8b0000
-                .long 0x02010
-                .long 0x940000
-                .long 0x04010
-                .long 0x9c0000
-                .long 0x06110
-                .long 0xa40000
-                .long 0x08110
-                .long 0xac0000
-                .long 0x0a110
-                .long 0xb40000
-                .long 0x0c210
-                .long 0xbd0000
-                .long 0x0e210
-                .long 0xc50000
-                .long 0x00018
-                .long 0xcd0000
-                .long 0x02018
-                .long 0xd50000
-                .long 0x04018
-                .long 0xde0000
-                .long 0x06118
-                .long 0xe60000
-                .long 0x08118
-                .long 0xee0000
-                .long 0x0a118
-                .long 0xf60000
-                .long 0x0c218
-                .long 0xff0000
-                .long 0x0e218
-                .long 0x00400
-                .long 0x00020
-                .long 0x80400
-                .long 0x02020
-                .long 0x100400
-                .long 0x04020
-                .long 0x180400
-                .long 0x06120
-                .long 0x200400
-                .long 0x08120
-                .long 0x290400
-                .long 0x0a120
-                .long 0x310400
-                .long 0x0c220
-                .long 0x390400
-                .long 0x0e220
-                .long 0x410400
-                .long 0x00029
-                .long 0x4a0400
-                .long 0x02029
-                .long 0x520400
-                .long 0x04029
-                .long 0x5a0400
-                .long 0x06129
-                .long 0x620400
-                .long 0x08129
-                .long 0x6a0400
-                .long 0x0a129
-                .long 0x730400
-                .long 0x0c229
-                .long 0x7b0400
-                .long 0x0e229
-                .long 0x830400
-                .long 0x00031
-                .long 0x8b0400
-                .long 0x02031
-                .long 0x940400
-                .long 0x04031
-                .long 0x9c0400
-                .long 0x06131
-                .long 0xa40400
-                .long 0x08131
-                .long 0xac0400
-                .long 0x0a131
-                .long 0xb40400
-                .long 0x0c231
-                .long 0xbd0400
-                .long 0x0e231
-                .long 0xc50400
-                .long 0x00039
-                .long 0xcd0400
-                .long 0x02039
-                .long 0xd50400
-                .long 0x04039
-                .long 0xde0400
-                .long 0x06139
-                .long 0xe60400
-                .long 0x08139
-                .long 0xee0400
-                .long 0x0a139
-                .long 0xf60400
-                .long 0x0c239
-                .long 0xff0400
-                .long 0x0e239
-                .long 0x00800
-                .long 0x00041
-                .long 0x80800
-                .long 0x02041
-                .long 0x100800
-                .long 0x04041
-                .long 0x180800
-                .long 0x06141
-                .long 0x200800
-                .long 0x08141
-                .long 0x290800
-                .long 0x0a141
-                .long 0x310800
-                .long 0x0c241
-                .long 0x390800
-                .long 0x0e241
-                .long 0x410800
-                .long 0x0004a
-                .long 0x4a0800
-                .long 0x0204a
-                .long 0x520800
-                .long 0x0404a
-                .long 0x5a0800
-                .long 0x0614a
-                .long 0x620800
-                .long 0x0814a
-                .long 0x6a0800
-                .long 0x0a14a
-                .long 0x730800
-                .long 0x0c24a
-                .long 0x7b0800
-                .long 0x0e24a
-                .long 0x830800
-                .long 0x00052
-                .long 0x8b0800
-                .long 0x02052
-                .long 0x940800
-                .long 0x04052
-                .long 0x9c0800
-                .long 0x06152
-                .long 0xa40800
-                .long 0x08152
-                .long 0xac0800
-                .long 0x0a152
-                .long 0xb40800
-                .long 0x0c252
-                .long 0xbd0800
-                .long 0x0e252
-                .long 0xc50800
-                .long 0x0005a
-                .long 0xcd0800
-                .long 0x0205a
-                .long 0xd50800
-                .long 0x0405a
-                .long 0xde0800
-                .long 0x0615a
-                .long 0xe60800
-                .long 0x0815a
-                .long 0xee0800
-                .long 0x0a15a
-                .long 0xf60800
-                .long 0x0c25a
-                .long 0xff0800
-                .long 0x0e25a
-                .long 0x00c00
-                .long 0x00062
-                .long 0x80c00
-                .long 0x02062
-                .long 0x100c00
-                .long 0x04062
-                .long 0x180c00
-                .long 0x06162
-                .long 0x200c00
-                .long 0x08162
-                .long 0x290c00
-                .long 0x0a162
-                .long 0x310c00
-                .long 0x0c262
-                .long 0x390c00
-                .long 0x0e262
-                .long 0x410c00
-                .long 0x0006a
-                .long 0x4a0c00
-                .long 0x0206a
-                .long 0x520c00
-                .long 0x0406a
-                .long 0x5a0c00
-                .long 0x0616a
-                .long 0x620c00
-                .long 0x0816a
-                .long 0x6a0c00
-                .long 0x0a16a
-                .long 0x730c00
-                .long 0x0c26a
-                .long 0x7b0c00
-                .long 0x0e26a
-                .long 0x830c00
-                .long 0x00073
-                .long 0x8b0c00
-                .long 0x02073
-                .long 0x940c00
-                .long 0x04073
-                .long 0x9c0c00
-                .long 0x06173
-                .long 0xa40c00
-                .long 0x08173
-                .long 0xac0c00
-                .long 0x0a173
-                .long 0xb40c00
-                .long 0x0c273
-                .long 0xbd0c00
-                .long 0x0e273
-                .long 0xc50c00
-                .long 0x0007b
-                .long 0xcd0c00
-                .long 0x0207b
-                .long 0xd50c00
-                .long 0x0407b
-                .long 0xde0c00
-                .long 0x0617b
-                .long 0xe60c00
-                .long 0x0817b
-                .long 0xee0c00
-                .long 0x0a17b
-                .long 0xf60c00
-                .long 0x0c27b
-                .long 0xff0c00
-                .long 0x0e27b
-                .long 0x01000
-                .long 0x00083
-                .long 0x81000
-                .long 0x02083
-                .long 0x101000
-                .long 0x04083
-                .long 0x181000
-                .long 0x06183
-                .long 0x201000
-                .long 0x08183
-                .long 0x291000
-                .long 0x0a183
-                .long 0x311000
-                .long 0x0c283
-                .long 0x391000
-                .long 0x0e283
-                .long 0x411000
-                .long 0x0008b
-                .long 0x4a1000
-                .long 0x0208b
-                .long 0x521000
-                .long 0x0408b
-                .long 0x5a1000
-                .long 0x0618b
-                .long 0x621000
-                .long 0x0818b
-                .long 0x6a1000
-                .long 0x0a18b
-                .long 0x731000
-                .long 0x0c28b
-                .long 0x7b1000
-                .long 0x0e28b
-                .long 0x831000
-                .long 0x00094
-                .long 0x8b1000
-                .long 0x02094
-                .long 0x941000
-                .long 0x04094
-                .long 0x9c1000
-                .long 0x06194
-                .long 0xa41000
-                .long 0x08194
-                .long 0xac1000
-                .long 0x0a194
-                .long 0xb41000
-                .long 0x0c294
-                .long 0xbd1000
-                .long 0x0e294
-                .long 0xc51000
-                .long 0x0009c
-                .long 0xcd1000
-                .long 0x0209c
-                .long 0xd51000
-                .long 0x0409c
-                .long 0xde1000
-                .long 0x0619c
-                .long 0xe61000
-                .long 0x0819c
-                .long 0xee1000
-                .long 0x0a19c
-                .long 0xf61000
-                .long 0x0c29c
-                .long 0xff1000
-                .long 0x0e29c
-                .long 0x01400
-                .long 0x000a4
-                .long 0x81400
-                .long 0x020a4
-                .long 0x101400
-                .long 0x040a4
-                .long 0x181400
-                .long 0x061a4
-                .long 0x201400
-                .long 0x081a4
-                .long 0x291400
-                .long 0x0a1a4
-                .long 0x311400
-                .long 0x0c2a4
-                .long 0x391400
-                .long 0x0e2a4
-                .long 0x411400
-                .long 0x000ac
-                .long 0x4a1400
-                .long 0x020ac
-                .long 0x521400
-                .long 0x040ac
-                .long 0x5a1400
-                .long 0x061ac
-                .long 0x621400
-                .long 0x081ac
-                .long 0x6a1400
-                .long 0x0a1ac
-                .long 0x731400
-                .long 0x0c2ac
-                .long 0x7b1400
-                .long 0x0e2ac
-                .long 0x831400
-                .long 0x000b4
-                .long 0x8b1400
-                .long 0x020b4
-                .long 0x941400
-                .long 0x040b4
-                .long 0x9c1400
-                .long 0x061b4
-                .long 0xa41400
-                .long 0x081b4
-                .long 0xac1400
-                .long 0x0a1b4
-                .long 0xb41400
-                .long 0x0c2b4
-                .long 0xbd1400
-                .long 0x0e2b4
-                .long 0xc51400
-                .long 0x000bd
-                .long 0xcd1400
-                .long 0x020bd
-                .long 0xd51400
-                .long 0x040bd
-                .long 0xde1400
-                .long 0x061bd
-                .long 0xe61400
-                .long 0x081bd
-                .long 0xee1400
-                .long 0x0a1bd
-                .long 0xf61400
-                .long 0x0c2bd
-                .long 0xff1400
-                .long 0x0e2bd
-                .long 0x01800
-                .long 0x000c5
-                .long 0x81800
-                .long 0x020c5
-                .long 0x101800
-                .long 0x040c5
-                .long 0x181800
-                .long 0x061c5
-                .long 0x201800
-                .long 0x081c5
-                .long 0x291800
-                .long 0x0a1c5
-                .long 0x311800
-                .long 0x0c2c5
-                .long 0x391800
-                .long 0x0e2c5
-                .long 0x411800
-                .long 0x000cd
-                .long 0x4a1800
-                .long 0x020cd
-                .long 0x521800
-                .long 0x040cd
-                .long 0x5a1800
-                .long 0x061cd
-                .long 0x621800
-                .long 0x081cd
-                .long 0x6a1800
-                .long 0x0a1cd
-                .long 0x731800
-                .long 0x0c2cd
-                .long 0x7b1800
-                .long 0x0e2cd
-                .long 0x831800
-                .long 0x000d5
-                .long 0x8b1800
-                .long 0x020d5
-                .long 0x941800
-                .long 0x040d5
-                .long 0x9c1800
-                .long 0x061d5
-                .long 0xa41800
-                .long 0x081d5
-                .long 0xac1800
-                .long 0x0a1d5
-                .long 0xb41800
-                .long 0x0c2d5
-                .long 0xbd1800
-                .long 0x0e2d5
-                .long 0xc51800
-                .long 0x000de
-                .long 0xcd1800
-                .long 0x020de
-                .long 0xd51800
-                .long 0x040de
-                .long 0xde1800
-                .long 0x061de
-                .long 0xe61800
-                .long 0x081de
-                .long 0xee1800
-                .long 0x0a1de
-                .long 0xf61800
-                .long 0x0c2de
-                .long 0xff1800
-                .long 0x0e2de
-                .long 0x01c00
-                .long 0x000e6
-                .long 0x81c00
-                .long 0x020e6
-                .long 0x101c00
-                .long 0x040e6
-                .long 0x181c00
-                .long 0x061e6
-                .long 0x201c00
-                .long 0x081e6
-                .long 0x291c00
-                .long 0x0a1e6
-                .long 0x311c00
-                .long 0x0c2e6
-                .long 0x391c00
-                .long 0x0e2e6
-                .long 0x411c00
-                .long 0x000ee
-                .long 0x4a1c00
-                .long 0x020ee
-                .long 0x521c00
-                .long 0x040ee
-                .long 0x5a1c00
-                .long 0x061ee
-                .long 0x621c00
-                .long 0x081ee
-                .long 0x6a1c00
-                .long 0x0a1ee
-                .long 0x731c00
-                .long 0x0c2ee
-                .long 0x7b1c00
-                .long 0x0e2ee
-                .long 0x831c00
-                .long 0x000f6
-                .long 0x8b1c00
-                .long 0x020f6
-                .long 0x941c00
-                .long 0x040f6
-                .long 0x9c1c00
-                .long 0x061f6
-                .long 0xa41c00
-                .long 0x081f6
-                .long 0xac1c00
-                .long 0x0a1f6
-                .long 0xb41c00
-                .long 0x0c2f6
-                .long 0xbd1c00
-                .long 0x0e2f6
-                .long 0xc51c00
-                .long 0x000ff
-                .long 0xcd1c00
-                .long 0x020ff
-                .long 0xd51c00
-                .long 0x040ff
-                .long 0xde1c00
-                .long 0x061ff
-                .long 0xe61c00
-                .long 0x081ff
-                .long 0xee1c00
-                .long 0x0a1ff
-                .long 0xf61c00
-                .long 0x0c2ff
-                .long 0xff1c00
-                .long 0x0e2ff
-
-_ConvertX86p16_32RGBA888_LUT_X86:
-                .long 0x00000
-                .long 0x000ff
-                .long 0x00800
-                .long 0x2000ff
-                .long 0x01000
-                .long 0x4000ff
-                .long 0x01800
-                .long 0x6100ff
-                .long 0x02000
-                .long 0x8100ff
-                .long 0x02900
-                .long 0xa100ff
-                .long 0x03100
-                .long 0xc200ff
-                .long 0x03900
-                .long 0xe200ff
-                .long 0x04100
-                .long 0x80000ff
-                .long 0x04a00
-                .long 0x82000ff
-                .long 0x05200
-                .long 0x84000ff
-                .long 0x05a00
-                .long 0x86100ff
-                .long 0x06200
-                .long 0x88100ff
-                .long 0x06a00
-                .long 0x8a100ff
-                .long 0x07300
-                .long 0x8c200ff
-                .long 0x07b00
-                .long 0x8e200ff
-                .long 0x08300
-                .long 0x100000ff
-                .long 0x08b00
-                .long 0x102000ff
-                .long 0x09400
-                .long 0x104000ff
-                .long 0x09c00
-                .long 0x106100ff
-                .long 0x0a400
-                .long 0x108100ff
-                .long 0x0ac00
-                .long 0x10a100ff
-                .long 0x0b400
-                .long 0x10c200ff
-                .long 0x0bd00
-                .long 0x10e200ff
-                .long 0x0c500
-                .long 0x180000ff
-                .long 0x0cd00
-                .long 0x182000ff
-                .long 0x0d500
-                .long 0x184000ff
-                .long 0x0de00
-                .long 0x186100ff
-                .long 0x0e600
-                .long 0x188100ff
-                .long 0x0ee00
-                .long 0x18a100ff
-                .long 0x0f600
-                .long 0x18c200ff
-                .long 0x0ff00
-                .long 0x18e200ff
-                .long 0x40000
-                .long 0x200000ff
-                .long 0x40800
-                .long 0x202000ff
-                .long 0x41000
-                .long 0x204000ff
-                .long 0x41800
-                .long 0x206100ff
-                .long 0x42000
-                .long 0x208100ff
-                .long 0x42900
-                .long 0x20a100ff
-                .long 0x43100
-                .long 0x20c200ff
-                .long 0x43900
-                .long 0x20e200ff
-                .long 0x44100
-                .long 0x290000ff
-                .long 0x44a00
-                .long 0x292000ff
-                .long 0x45200
-                .long 0x294000ff
-                .long 0x45a00
-                .long 0x296100ff
-                .long 0x46200
-                .long 0x298100ff
-                .long 0x46a00
-                .long 0x29a100ff
-                .long 0x47300
-                .long 0x29c200ff
-                .long 0x47b00
-                .long 0x29e200ff
-                .long 0x48300
-                .long 0x310000ff
-                .long 0x48b00
-                .long 0x312000ff
-                .long 0x49400
-                .long 0x314000ff
-                .long 0x49c00
-                .long 0x316100ff
-                .long 0x4a400
-                .long 0x318100ff
-                .long 0x4ac00
-                .long 0x31a100ff
-                .long 0x4b400
-                .long 0x31c200ff
-                .long 0x4bd00
-                .long 0x31e200ff
-                .long 0x4c500
-                .long 0x390000ff
-                .long 0x4cd00
-                .long 0x392000ff
-                .long 0x4d500
-                .long 0x394000ff
-                .long 0x4de00
-                .long 0x396100ff
-                .long 0x4e600
-                .long 0x398100ff
-                .long 0x4ee00
-                .long 0x39a100ff
-                .long 0x4f600
-                .long 0x39c200ff
-                .long 0x4ff00
-                .long 0x39e200ff
-                .long 0x80000
-                .long 0x410000ff
-                .long 0x80800
-                .long 0x412000ff
-                .long 0x81000
-                .long 0x414000ff
-                .long 0x81800
-                .long 0x416100ff
-                .long 0x82000
-                .long 0x418100ff
-                .long 0x82900
-                .long 0x41a100ff
-                .long 0x83100
-                .long 0x41c200ff
-                .long 0x83900
-                .long 0x41e200ff
-                .long 0x84100
-                .long 0x4a0000ff
-                .long 0x84a00
-                .long 0x4a2000ff
-                .long 0x85200
-                .long 0x4a4000ff
-                .long 0x85a00
-                .long 0x4a6100ff
-                .long 0x86200
-                .long 0x4a8100ff
-                .long 0x86a00
-                .long 0x4aa100ff
-                .long 0x87300
-                .long 0x4ac200ff
-                .long 0x87b00
-                .long 0x4ae200ff
-                .long 0x88300
-                .long 0x520000ff
-                .long 0x88b00
-                .long 0x522000ff
-                .long 0x89400
-                .long 0x524000ff
-                .long 0x89c00
-                .long 0x526100ff
-                .long 0x8a400
-                .long 0x528100ff
-                .long 0x8ac00
-                .long 0x52a100ff
-                .long 0x8b400
-                .long 0x52c200ff
-                .long 0x8bd00
-                .long 0x52e200ff
-                .long 0x8c500
-                .long 0x5a0000ff
-                .long 0x8cd00
-                .long 0x5a2000ff
-                .long 0x8d500
-                .long 0x5a4000ff
-                .long 0x8de00
-                .long 0x5a6100ff
-                .long 0x8e600
-                .long 0x5a8100ff
-                .long 0x8ee00
-                .long 0x5aa100ff
-                .long 0x8f600
-                .long 0x5ac200ff
-                .long 0x8ff00
-                .long 0x5ae200ff
-                .long 0xc0000
-                .long 0x620000ff
-                .long 0xc0800
-                .long 0x622000ff
-                .long 0xc1000
-                .long 0x624000ff
-                .long 0xc1800
-                .long 0x626100ff
-                .long 0xc2000
-                .long 0x628100ff
-                .long 0xc2900
-                .long 0x62a100ff
-                .long 0xc3100
-                .long 0x62c200ff
-                .long 0xc3900
-                .long 0x62e200ff
-                .long 0xc4100
-                .long 0x6a0000ff
-                .long 0xc4a00
-                .long 0x6a2000ff
-                .long 0xc5200
-                .long 0x6a4000ff
-                .long 0xc5a00
-                .long 0x6a6100ff
-                .long 0xc6200
-                .long 0x6a8100ff
-                .long 0xc6a00
-                .long 0x6aa100ff
-                .long 0xc7300
-                .long 0x6ac200ff
-                .long 0xc7b00
-                .long 0x6ae200ff
-                .long 0xc8300
-                .long 0x730000ff
-                .long 0xc8b00
-                .long 0x732000ff
-                .long 0xc9400
-                .long 0x734000ff
-                .long 0xc9c00
-                .long 0x736100ff
-                .long 0xca400
-                .long 0x738100ff
-                .long 0xcac00
-                .long 0x73a100ff
-                .long 0xcb400
-                .long 0x73c200ff
-                .long 0xcbd00
-                .long 0x73e200ff
-                .long 0xcc500
-                .long 0x7b0000ff
-                .long 0xccd00
-                .long 0x7b2000ff
-                .long 0xcd500
-                .long 0x7b4000ff
-                .long 0xcde00
-                .long 0x7b6100ff
-                .long 0xce600
-                .long 0x7b8100ff
-                .long 0xcee00
-                .long 0x7ba100ff
-                .long 0xcf600
-                .long 0x7bc200ff
-                .long 0xcff00
-                .long 0x7be200ff
-                .long 0x100000
-                .long 0x830000ff
-                .long 0x100800
-                .long 0x832000ff
-                .long 0x101000
-                .long 0x834000ff
-                .long 0x101800
-                .long 0x836100ff
-                .long 0x102000
-                .long 0x838100ff
-                .long 0x102900
-                .long 0x83a100ff
-                .long 0x103100
-                .long 0x83c200ff
-                .long 0x103900
-                .long 0x83e200ff
-                .long 0x104100
-                .long 0x8b0000ff
-                .long 0x104a00
-                .long 0x8b2000ff
-                .long 0x105200
-                .long 0x8b4000ff
-                .long 0x105a00
-                .long 0x8b6100ff
-                .long 0x106200
-                .long 0x8b8100ff
-                .long 0x106a00
-                .long 0x8ba100ff
-                .long 0x107300
-                .long 0x8bc200ff
-                .long 0x107b00
-                .long 0x8be200ff
-                .long 0x108300
-                .long 0x940000ff
-                .long 0x108b00
-                .long 0x942000ff
-                .long 0x109400
-                .long 0x944000ff
-                .long 0x109c00
-                .long 0x946100ff
-                .long 0x10a400
-                .long 0x948100ff
-                .long 0x10ac00
-                .long 0x94a100ff
-                .long 0x10b400
-                .long 0x94c200ff
-                .long 0x10bd00
-                .long 0x94e200ff
-                .long 0x10c500
-                .long 0x9c0000ff
-                .long 0x10cd00
-                .long 0x9c2000ff
-                .long 0x10d500
-                .long 0x9c4000ff
-                .long 0x10de00
-                .long 0x9c6100ff
-                .long 0x10e600
-                .long 0x9c8100ff
-                .long 0x10ee00
-                .long 0x9ca100ff
-                .long 0x10f600
-                .long 0x9cc200ff
-                .long 0x10ff00
-                .long 0x9ce200ff
-                .long 0x140000
-                .long 0xa40000ff
-                .long 0x140800
-                .long 0xa42000ff
-                .long 0x141000
-                .long 0xa44000ff
-                .long 0x141800
-                .long 0xa46100ff
-                .long 0x142000
-                .long 0xa48100ff
-                .long 0x142900
-                .long 0xa4a100ff
-                .long 0x143100
-                .long 0xa4c200ff
-                .long 0x143900
-                .long 0xa4e200ff
-                .long 0x144100
-                .long 0xac0000ff
-                .long 0x144a00
-                .long 0xac2000ff
-                .long 0x145200
-                .long 0xac4000ff
-                .long 0x145a00
-                .long 0xac6100ff
-                .long 0x146200
-                .long 0xac8100ff
-                .long 0x146a00
-                .long 0xaca100ff
-                .long 0x147300
-                .long 0xacc200ff
-                .long 0x147b00
-                .long 0xace200ff
-                .long 0x148300
-                .long 0xb40000ff
-                .long 0x148b00
-                .long 0xb42000ff
-                .long 0x149400
-                .long 0xb44000ff
-                .long 0x149c00
-                .long 0xb46100ff
-                .long 0x14a400
-                .long 0xb48100ff
-                .long 0x14ac00
-                .long 0xb4a100ff
-                .long 0x14b400
-                .long 0xb4c200ff
-                .long 0x14bd00
-                .long 0xb4e200ff
-                .long 0x14c500
-                .long 0xbd0000ff
-                .long 0x14cd00
-                .long 0xbd2000ff
-                .long 0x14d500
-                .long 0xbd4000ff
-                .long 0x14de00
-                .long 0xbd6100ff
-                .long 0x14e600
-                .long 0xbd8100ff
-                .long 0x14ee00
-                .long 0xbda100ff
-                .long 0x14f600
-                .long 0xbdc200ff
-                .long 0x14ff00
-                .long 0xbde200ff
-                .long 0x180000
-                .long 0xc50000ff
-                .long 0x180800
-                .long 0xc52000ff
-                .long 0x181000
-                .long 0xc54000ff
-                .long 0x181800
-                .long 0xc56100ff
-                .long 0x182000
-                .long 0xc58100ff
-                .long 0x182900
-                .long 0xc5a100ff
-                .long 0x183100
-                .long 0xc5c200ff
-                .long 0x183900
-                .long 0xc5e200ff
-                .long 0x184100
-                .long 0xcd0000ff
-                .long 0x184a00
-                .long 0xcd2000ff
-                .long 0x185200
-                .long 0xcd4000ff
-                .long 0x185a00
-                .long 0xcd6100ff
-                .long 0x186200
-                .long 0xcd8100ff
-                .long 0x186a00
-                .long 0xcda100ff
-                .long 0x187300
-                .long 0xcdc200ff
-                .long 0x187b00
-                .long 0xcde200ff
-                .long 0x188300
-                .long 0xd50000ff
-                .long 0x188b00
-                .long 0xd52000ff
-                .long 0x189400
-                .long 0xd54000ff
-                .long 0x189c00
-                .long 0xd56100ff
-                .long 0x18a400
-                .long 0xd58100ff
-                .long 0x18ac00
-                .long 0xd5a100ff
-                .long 0x18b400
-                .long 0xd5c200ff
-                .long 0x18bd00
-                .long 0xd5e200ff
-                .long 0x18c500
-                .long 0xde0000ff
-                .long 0x18cd00
-                .long 0xde2000ff
-                .long 0x18d500
-                .long 0xde4000ff
-                .long 0x18de00
-                .long 0xde6100ff
-                .long 0x18e600
-                .long 0xde8100ff
-                .long 0x18ee00
-                .long 0xdea100ff
-                .long 0x18f600
-                .long 0xdec200ff
-                .long 0x18ff00
-                .long 0xdee200ff
-                .long 0x1c0000
-                .long 0xe60000ff
-                .long 0x1c0800
-                .long 0xe62000ff
-                .long 0x1c1000
-                .long 0xe64000ff
-                .long 0x1c1800
-                .long 0xe66100ff
-                .long 0x1c2000
-                .long 0xe68100ff
-                .long 0x1c2900
-                .long 0xe6a100ff
-                .long 0x1c3100
-                .long 0xe6c200ff
-                .long 0x1c3900
-                .long 0xe6e200ff
-                .long 0x1c4100
-                .long 0xee0000ff
-                .long 0x1c4a00
-                .long 0xee2000ff
-                .long 0x1c5200
-                .long 0xee4000ff
-                .long 0x1c5a00
-                .long 0xee6100ff
-                .long 0x1c6200
-                .long 0xee8100ff
-                .long 0x1c6a00
-                .long 0xeea100ff
-                .long 0x1c7300
-                .long 0xeec200ff
-                .long 0x1c7b00
-                .long 0xeee200ff
-                .long 0x1c8300
-                .long 0xf60000ff
-                .long 0x1c8b00
-                .long 0xf62000ff
-                .long 0x1c9400
-                .long 0xf64000ff
-                .long 0x1c9c00
-                .long 0xf66100ff
-                .long 0x1ca400
-                .long 0xf68100ff
-                .long 0x1cac00
-                .long 0xf6a100ff
-                .long 0x1cb400
-                .long 0xf6c200ff
-                .long 0x1cbd00
-                .long 0xf6e200ff
-                .long 0x1cc500
-                .long 0xff0000ff
-                .long 0x1ccd00
-                .long 0xff2000ff
-                .long 0x1cd500
-                .long 0xff4000ff
-                .long 0x1cde00
-                .long 0xff6100ff
-                .long 0x1ce600
-                .long 0xff8100ff
-                .long 0x1cee00
-                .long 0xffa100ff
-                .long 0x1cf600
-                .long 0xffc200ff
-                .long 0x1cff00
-                .long 0xffe200ff
-
-_ConvertX86p16_32BGRA888_LUT_X86:
-                .long 0x00000
-                .long 0x000ff
-                .long 0x8000000
-                .long 0x2000ff
-                .long 0x10000000
-                .long 0x4000ff
-                .long 0x18000000
-                .long 0x6100ff
-                .long 0x20000000
-                .long 0x8100ff
-                .long 0x29000000
-                .long 0xa100ff
-                .long 0x31000000
-                .long 0xc200ff
-                .long 0x39000000
-                .long 0xe200ff
-                .long 0x41000000
-                .long 0x008ff
-                .long 0x4a000000
-                .long 0x2008ff
-                .long 0x52000000
-                .long 0x4008ff
-                .long 0x5a000000
-                .long 0x6108ff
-                .long 0x62000000
-                .long 0x8108ff
-                .long 0x6a000000
-                .long 0xa108ff
-                .long 0x73000000
-                .long 0xc208ff
-                .long 0x7b000000
-                .long 0xe208ff
-                .long 0x83000000
-                .long 0x010ff
-                .long 0x8b000000
-                .long 0x2010ff
-                .long 0x94000000
-                .long 0x4010ff
-                .long 0x9c000000
-                .long 0x6110ff
-                .long 0xa4000000
-                .long 0x8110ff
-                .long 0xac000000
-                .long 0xa110ff
-                .long 0xb4000000
-                .long 0xc210ff
-                .long 0xbd000000
-                .long 0xe210ff
-                .long 0xc5000000
-                .long 0x018ff
-                .long 0xcd000000
-                .long 0x2018ff
-                .long 0xd5000000
-                .long 0x4018ff
-                .long 0xde000000
-                .long 0x6118ff
-                .long 0xe6000000
-                .long 0x8118ff
-                .long 0xee000000
-                .long 0xa118ff
-                .long 0xf6000000
-                .long 0xc218ff
-                .long 0xff000000
-                .long 0xe218ff
-                .long 0x40000
-                .long 0x020ff
-                .long 0x8040000
-                .long 0x2020ff
-                .long 0x10040000
-                .long 0x4020ff
-                .long 0x18040000
-                .long 0x6120ff
-                .long 0x20040000
-                .long 0x8120ff
-                .long 0x29040000
-                .long 0xa120ff
-                .long 0x31040000
-                .long 0xc220ff
-                .long 0x39040000
-                .long 0xe220ff
-                .long 0x41040000
-                .long 0x029ff
-                .long 0x4a040000
-                .long 0x2029ff
-                .long 0x52040000
-                .long 0x4029ff
-                .long 0x5a040000
-                .long 0x6129ff
-                .long 0x62040000
-                .long 0x8129ff
-                .long 0x6a040000
-                .long 0xa129ff
-                .long 0x73040000
-                .long 0xc229ff
-                .long 0x7b040000
-                .long 0xe229ff
-                .long 0x83040000
-                .long 0x031ff
-                .long 0x8b040000
-                .long 0x2031ff
-                .long 0x94040000
-                .long 0x4031ff
-                .long 0x9c040000
-                .long 0x6131ff
-                .long 0xa4040000
-                .long 0x8131ff
-                .long 0xac040000
-                .long 0xa131ff
-                .long 0xb4040000
-                .long 0xc231ff
-                .long 0xbd040000
-                .long 0xe231ff
-                .long 0xc5040000
-                .long 0x039ff
-                .long 0xcd040000
-                .long 0x2039ff
-                .long 0xd5040000
-                .long 0x4039ff
-                .long 0xde040000
-                .long 0x6139ff
-                .long 0xe6040000
-                .long 0x8139ff
-                .long 0xee040000
-                .long 0xa139ff
-                .long 0xf6040000
-                .long 0xc239ff
-                .long 0xff040000
-                .long 0xe239ff
-                .long 0x80000
-                .long 0x041ff
-                .long 0x8080000
-                .long 0x2041ff
-                .long 0x10080000
-                .long 0x4041ff
-                .long 0x18080000
-                .long 0x6141ff
-                .long 0x20080000
-                .long 0x8141ff
-                .long 0x29080000
-                .long 0xa141ff
-                .long 0x31080000
-                .long 0xc241ff
-                .long 0x39080000
-                .long 0xe241ff
-                .long 0x41080000
-                .long 0x04aff
-                .long 0x4a080000
-                .long 0x204aff
-                .long 0x52080000
-                .long 0x404aff
-                .long 0x5a080000
-                .long 0x614aff
-                .long 0x62080000
-                .long 0x814aff
-                .long 0x6a080000
-                .long 0xa14aff
-                .long 0x73080000
-                .long 0xc24aff
-                .long 0x7b080000
-                .long 0xe24aff
-                .long 0x83080000
-                .long 0x052ff
-                .long 0x8b080000
-                .long 0x2052ff
-                .long 0x94080000
-                .long 0x4052ff
-                .long 0x9c080000
-                .long 0x6152ff
-                .long 0xa4080000
-                .long 0x8152ff
-                .long 0xac080000
-                .long 0xa152ff
-                .long 0xb4080000
-                .long 0xc252ff
-                .long 0xbd080000
-                .long 0xe252ff
-                .long 0xc5080000
-                .long 0x05aff
-                .long 0xcd080000
-                .long 0x205aff
-                .long 0xd5080000
-                .long 0x405aff
-                .long 0xde080000
-                .long 0x615aff
-                .long 0xe6080000
-                .long 0x815aff
-                .long 0xee080000
-                .long 0xa15aff
-                .long 0xf6080000
-                .long 0xc25aff
-                .long 0xff080000
-                .long 0xe25aff
-                .long 0xc0000
-                .long 0x062ff
-                .long 0x80c0000
-                .long 0x2062ff
-                .long 0x100c0000
-                .long 0x4062ff
-                .long 0x180c0000
-                .long 0x6162ff
-                .long 0x200c0000
-                .long 0x8162ff
-                .long 0x290c0000
-                .long 0xa162ff
-                .long 0x310c0000
-                .long 0xc262ff
-                .long 0x390c0000
-                .long 0xe262ff
-                .long 0x410c0000
-                .long 0x06aff
-                .long 0x4a0c0000
-                .long 0x206aff
-                .long 0x520c0000
-                .long 0x406aff
-                .long 0x5a0c0000
-                .long 0x616aff
-                .long 0x620c0000
-                .long 0x816aff
-                .long 0x6a0c0000
-                .long 0xa16aff
-                .long 0x730c0000
-                .long 0xc26aff
-                .long 0x7b0c0000
-                .long 0xe26aff
-                .long 0x830c0000
-                .long 0x073ff
-                .long 0x8b0c0000
-                .long 0x2073ff
-                .long 0x940c0000
-                .long 0x4073ff
-                .long 0x9c0c0000
-                .long 0x6173ff
-                .long 0xa40c0000
-                .long 0x8173ff
-                .long 0xac0c0000
-                .long 0xa173ff
-                .long 0xb40c0000
-                .long 0xc273ff
-                .long 0xbd0c0000
-                .long 0xe273ff
-                .long 0xc50c0000
-                .long 0x07bff
-                .long 0xcd0c0000
-                .long 0x207bff
-                .long 0xd50c0000
-                .long 0x407bff
-                .long 0xde0c0000
-                .long 0x617bff
-                .long 0xe60c0000
-                .long 0x817bff
-                .long 0xee0c0000
-                .long 0xa17bff
-                .long 0xf60c0000
-                .long 0xc27bff
-                .long 0xff0c0000
-                .long 0xe27bff
-                .long 0x100000
-                .long 0x083ff
-                .long 0x8100000
-                .long 0x2083ff
-                .long 0x10100000
-                .long 0x4083ff
-                .long 0x18100000
-                .long 0x6183ff
-                .long 0x20100000
-                .long 0x8183ff
-                .long 0x29100000
-                .long 0xa183ff
-                .long 0x31100000
-                .long 0xc283ff
-                .long 0x39100000
-                .long 0xe283ff
-                .long 0x41100000
-                .long 0x08bff
-                .long 0x4a100000
-                .long 0x208bff
-                .long 0x52100000
-                .long 0x408bff
-                .long 0x5a100000
-                .long 0x618bff
-                .long 0x62100000
-                .long 0x818bff
-                .long 0x6a100000
-                .long 0xa18bff
-                .long 0x73100000
-                .long 0xc28bff
-                .long 0x7b100000
-                .long 0xe28bff
-                .long 0x83100000
-                .long 0x094ff
-                .long 0x8b100000
-                .long 0x2094ff
-                .long 0x94100000
-                .long 0x4094ff
-                .long 0x9c100000
-                .long 0x6194ff
-                .long 0xa4100000
-                .long 0x8194ff
-                .long 0xac100000
-                .long 0xa194ff
-                .long 0xb4100000
-                .long 0xc294ff
-                .long 0xbd100000
-                .long 0xe294ff
-                .long 0xc5100000
-                .long 0x09cff
-                .long 0xcd100000
-                .long 0x209cff
-                .long 0xd5100000
-                .long 0x409cff
-                .long 0xde100000
-                .long 0x619cff
-                .long 0xe6100000
-                .long 0x819cff
-                .long 0xee100000
-                .long 0xa19cff
-                .long 0xf6100000
-                .long 0xc29cff
-                .long 0xff100000
-                .long 0xe29cff
-                .long 0x140000
-                .long 0x0a4ff
-                .long 0x8140000
-                .long 0x20a4ff
-                .long 0x10140000
-                .long 0x40a4ff
-                .long 0x18140000
-                .long 0x61a4ff
-                .long 0x20140000
-                .long 0x81a4ff
-                .long 0x29140000
-                .long 0xa1a4ff
-                .long 0x31140000
-                .long 0xc2a4ff
-                .long 0x39140000
-                .long 0xe2a4ff
-                .long 0x41140000
-                .long 0x0acff
-                .long 0x4a140000
-                .long 0x20acff
-                .long 0x52140000
-                .long 0x40acff
-                .long 0x5a140000
-                .long 0x61acff
-                .long 0x62140000
-                .long 0x81acff
-                .long 0x6a140000
-                .long 0xa1acff
-                .long 0x73140000
-                .long 0xc2acff
-                .long 0x7b140000
-                .long 0xe2acff
-                .long 0x83140000
-                .long 0x0b4ff
-                .long 0x8b140000
-                .long 0x20b4ff
-                .long 0x94140000
-                .long 0x40b4ff
-                .long 0x9c140000
-                .long 0x61b4ff
-                .long 0xa4140000
-                .long 0x81b4ff
-                .long 0xac140000
-                .long 0xa1b4ff
-                .long 0xb4140000
-                .long 0xc2b4ff
-                .long 0xbd140000
-                .long 0xe2b4ff
-                .long 0xc5140000
-                .long 0x0bdff
-                .long 0xcd140000
-                .long 0x20bdff
-                .long 0xd5140000
-                .long 0x40bdff
-                .long 0xde140000
-                .long 0x61bdff
-                .long 0xe6140000
-                .long 0x81bdff
-                .long 0xee140000
-                .long 0xa1bdff
-                .long 0xf6140000
-                .long 0xc2bdff
-                .long 0xff140000
-                .long 0xe2bdff
-                .long 0x180000
-                .long 0x0c5ff
-                .long 0x8180000
-                .long 0x20c5ff
-                .long 0x10180000
-                .long 0x40c5ff
-                .long 0x18180000
-                .long 0x61c5ff
-                .long 0x20180000
-                .long 0x81c5ff
-                .long 0x29180000
-                .long 0xa1c5ff
-                .long 0x31180000
-                .long 0xc2c5ff
-                .long 0x39180000
-                .long 0xe2c5ff
-                .long 0x41180000
-                .long 0x0cdff
-                .long 0x4a180000
-                .long 0x20cdff
-                .long 0x52180000
-                .long 0x40cdff
-                .long 0x5a180000
-                .long 0x61cdff
-                .long 0x62180000
-                .long 0x81cdff
-                .long 0x6a180000
-                .long 0xa1cdff
-                .long 0x73180000
-                .long 0xc2cdff
-                .long 0x7b180000
-                .long 0xe2cdff
-                .long 0x83180000
-                .long 0x0d5ff
-                .long 0x8b180000
-                .long 0x20d5ff
-                .long 0x94180000
-                .long 0x40d5ff
-                .long 0x9c180000
-                .long 0x61d5ff
-                .long 0xa4180000
-                .long 0x81d5ff
-                .long 0xac180000
-                .long 0xa1d5ff
-                .long 0xb4180000
-                .long 0xc2d5ff
-                .long 0xbd180000
-                .long 0xe2d5ff
-                .long 0xc5180000
-                .long 0x0deff
-                .long 0xcd180000
-                .long 0x20deff
-                .long 0xd5180000
-                .long 0x40deff
-                .long 0xde180000
-                .long 0x61deff
-                .long 0xe6180000
-                .long 0x81deff
-                .long 0xee180000
-                .long 0xa1deff
-                .long 0xf6180000
-                .long 0xc2deff
-                .long 0xff180000
-                .long 0xe2deff
-                .long 0x1c0000
-                .long 0x0e6ff
-                .long 0x81c0000
-                .long 0x20e6ff
-                .long 0x101c0000
-                .long 0x40e6ff
-                .long 0x181c0000
-                .long 0x61e6ff
-                .long 0x201c0000
-                .long 0x81e6ff
-                .long 0x291c0000
-                .long 0xa1e6ff
-                .long 0x311c0000
-                .long 0xc2e6ff
-                .long 0x391c0000
-                .long 0xe2e6ff
-                .long 0x411c0000
-                .long 0x0eeff
-                .long 0x4a1c0000
-                .long 0x20eeff
-                .long 0x521c0000
-                .long 0x40eeff
-                .long 0x5a1c0000
-                .long 0x61eeff
-                .long 0x621c0000
-                .long 0x81eeff
-                .long 0x6a1c0000
-                .long 0xa1eeff
-                .long 0x731c0000
-                .long 0xc2eeff
-                .long 0x7b1c0000
-                .long 0xe2eeff
-                .long 0x831c0000
-                .long 0x0f6ff
-                .long 0x8b1c0000
-                .long 0x20f6ff
-                .long 0x941c0000
-                .long 0x40f6ff
-                .long 0x9c1c0000
-                .long 0x61f6ff
-                .long 0xa41c0000
-                .long 0x81f6ff
-                .long 0xac1c0000
-                .long 0xa1f6ff
-                .long 0xb41c0000
-                .long 0xc2f6ff
-                .long 0xbd1c0000
-                .long 0xe2f6ff
-                .long 0xc51c0000
-                .long 0x0ffff
-                .long 0xcd1c0000
-                .long 0x20ffff
-                .long 0xd51c0000
-                .long 0x40ffff
-                .long 0xde1c0000
-                .long 0x61ffff
-                .long 0xe61c0000
-                .long 0x81ffff
-                .long 0xee1c0000
-                .long 0xa1ffff
-                .long 0xf61c0000
-                .long 0xc2ffff
-                .long 0xff1c0000
-                .long 0xe2ffff
-

+ 2088 - 0
packages/hermes/src/i386/x8616lut.inc

@@ -0,0 +1,2088 @@
+{
+    x86 format converters for HERMES
+    Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
+    Some routines are (c) Glenn Fiedler ([email protected]), used with permission
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+const
+  ConvertX86p16_32RGB888_LUT_X86: array [0..511] of DWord = (
+                  $00000
+                , $00000
+                , $00008
+                , $02000
+                , $00010
+                , $04000
+                , $00018
+                , $06100
+                , $00020
+                , $08100
+                , $00029
+                , $0a100
+                , $00031
+                , $0c200
+                , $00039
+                , $0e200
+                , $00041
+                , $80000
+                , $0004a
+                , $82000
+                , $00052
+                , $84000
+                , $0005a
+                , $86100
+                , $00062
+                , $88100
+                , $0006a
+                , $8a100
+                , $00073
+                , $8c200
+                , $0007b
+                , $8e200
+                , $00083
+                , $100000
+                , $0008b
+                , $102000
+                , $00094
+                , $104000
+                , $0009c
+                , $106100
+                , $000a4
+                , $108100
+                , $000ac
+                , $10a100
+                , $000b4
+                , $10c200
+                , $000bd
+                , $10e200
+                , $000c5
+                , $180000
+                , $000cd
+                , $182000
+                , $000d5
+                , $184000
+                , $000de
+                , $186100
+                , $000e6
+                , $188100
+                , $000ee
+                , $18a100
+                , $000f6
+                , $18c200
+                , $000ff
+                , $18e200
+                , $00400
+                , $200000
+                , $00408
+                , $202000
+                , $00410
+                , $204000
+                , $00418
+                , $206100
+                , $00420
+                , $208100
+                , $00429
+                , $20a100
+                , $00431
+                , $20c200
+                , $00439
+                , $20e200
+                , $00441
+                , $290000
+                , $0044a
+                , $292000
+                , $00452
+                , $294000
+                , $0045a
+                , $296100
+                , $00462
+                , $298100
+                , $0046a
+                , $29a100
+                , $00473
+                , $29c200
+                , $0047b
+                , $29e200
+                , $00483
+                , $310000
+                , $0048b
+                , $312000
+                , $00494
+                , $314000
+                , $0049c
+                , $316100
+                , $004a4
+                , $318100
+                , $004ac
+                , $31a100
+                , $004b4
+                , $31c200
+                , $004bd
+                , $31e200
+                , $004c5
+                , $390000
+                , $004cd
+                , $392000
+                , $004d5
+                , $394000
+                , $004de
+                , $396100
+                , $004e6
+                , $398100
+                , $004ee
+                , $39a100
+                , $004f6
+                , $39c200
+                , $004ff
+                , $39e200
+                , $00800
+                , $410000
+                , $00808
+                , $412000
+                , $00810
+                , $414000
+                , $00818
+                , $416100
+                , $00820
+                , $418100
+                , $00829
+                , $41a100
+                , $00831
+                , $41c200
+                , $00839
+                , $41e200
+                , $00841
+                , $4a0000
+                , $0084a
+                , $4a2000
+                , $00852
+                , $4a4000
+                , $0085a
+                , $4a6100
+                , $00862
+                , $4a8100
+                , $0086a
+                , $4aa100
+                , $00873
+                , $4ac200
+                , $0087b
+                , $4ae200
+                , $00883
+                , $520000
+                , $0088b
+                , $522000
+                , $00894
+                , $524000
+                , $0089c
+                , $526100
+                , $008a4
+                , $528100
+                , $008ac
+                , $52a100
+                , $008b4
+                , $52c200
+                , $008bd
+                , $52e200
+                , $008c5
+                , $5a0000
+                , $008cd
+                , $5a2000
+                , $008d5
+                , $5a4000
+                , $008de
+                , $5a6100
+                , $008e6
+                , $5a8100
+                , $008ee
+                , $5aa100
+                , $008f6
+                , $5ac200
+                , $008ff
+                , $5ae200
+                , $00c00
+                , $620000
+                , $00c08
+                , $622000
+                , $00c10
+                , $624000
+                , $00c18
+                , $626100
+                , $00c20
+                , $628100
+                , $00c29
+                , $62a100
+                , $00c31
+                , $62c200
+                , $00c39
+                , $62e200
+                , $00c41
+                , $6a0000
+                , $00c4a
+                , $6a2000
+                , $00c52
+                , $6a4000
+                , $00c5a
+                , $6a6100
+                , $00c62
+                , $6a8100
+                , $00c6a
+                , $6aa100
+                , $00c73
+                , $6ac200
+                , $00c7b
+                , $6ae200
+                , $00c83
+                , $730000
+                , $00c8b
+                , $732000
+                , $00c94
+                , $734000
+                , $00c9c
+                , $736100
+                , $00ca4
+                , $738100
+                , $00cac
+                , $73a100
+                , $00cb4
+                , $73c200
+                , $00cbd
+                , $73e200
+                , $00cc5
+                , $7b0000
+                , $00ccd
+                , $7b2000
+                , $00cd5
+                , $7b4000
+                , $00cde
+                , $7b6100
+                , $00ce6
+                , $7b8100
+                , $00cee
+                , $7ba100
+                , $00cf6
+                , $7bc200
+                , $00cff
+                , $7be200
+                , $01000
+                , $830000
+                , $01008
+                , $832000
+                , $01010
+                , $834000
+                , $01018
+                , $836100
+                , $01020
+                , $838100
+                , $01029
+                , $83a100
+                , $01031
+                , $83c200
+                , $01039
+                , $83e200
+                , $01041
+                , $8b0000
+                , $0104a
+                , $8b2000
+                , $01052
+                , $8b4000
+                , $0105a
+                , $8b6100
+                , $01062
+                , $8b8100
+                , $0106a
+                , $8ba100
+                , $01073
+                , $8bc200
+                , $0107b
+                , $8be200
+                , $01083
+                , $940000
+                , $0108b
+                , $942000
+                , $01094
+                , $944000
+                , $0109c
+                , $946100
+                , $010a4
+                , $948100
+                , $010ac
+                , $94a100
+                , $010b4
+                , $94c200
+                , $010bd
+                , $94e200
+                , $010c5
+                , $9c0000
+                , $010cd
+                , $9c2000
+                , $010d5
+                , $9c4000
+                , $010de
+                , $9c6100
+                , $010e6
+                , $9c8100
+                , $010ee
+                , $9ca100
+                , $010f6
+                , $9cc200
+                , $010ff
+                , $9ce200
+                , $01400
+                , $a40000
+                , $01408
+                , $a42000
+                , $01410
+                , $a44000
+                , $01418
+                , $a46100
+                , $01420
+                , $a48100
+                , $01429
+                , $a4a100
+                , $01431
+                , $a4c200
+                , $01439
+                , $a4e200
+                , $01441
+                , $ac0000
+                , $0144a
+                , $ac2000
+                , $01452
+                , $ac4000
+                , $0145a
+                , $ac6100
+                , $01462
+                , $ac8100
+                , $0146a
+                , $aca100
+                , $01473
+                , $acc200
+                , $0147b
+                , $ace200
+                , $01483
+                , $b40000
+                , $0148b
+                , $b42000
+                , $01494
+                , $b44000
+                , $0149c
+                , $b46100
+                , $014a4
+                , $b48100
+                , $014ac
+                , $b4a100
+                , $014b4
+                , $b4c200
+                , $014bd
+                , $b4e200
+                , $014c5
+                , $bd0000
+                , $014cd
+                , $bd2000
+                , $014d5
+                , $bd4000
+                , $014de
+                , $bd6100
+                , $014e6
+                , $bd8100
+                , $014ee
+                , $bda100
+                , $014f6
+                , $bdc200
+                , $014ff
+                , $bde200
+                , $01800
+                , $c50000
+                , $01808
+                , $c52000
+                , $01810
+                , $c54000
+                , $01818
+                , $c56100
+                , $01820
+                , $c58100
+                , $01829
+                , $c5a100
+                , $01831
+                , $c5c200
+                , $01839
+                , $c5e200
+                , $01841
+                , $cd0000
+                , $0184a
+                , $cd2000
+                , $01852
+                , $cd4000
+                , $0185a
+                , $cd6100
+                , $01862
+                , $cd8100
+                , $0186a
+                , $cda100
+                , $01873
+                , $cdc200
+                , $0187b
+                , $cde200
+                , $01883
+                , $d50000
+                , $0188b
+                , $d52000
+                , $01894
+                , $d54000
+                , $0189c
+                , $d56100
+                , $018a4
+                , $d58100
+                , $018ac
+                , $d5a100
+                , $018b4
+                , $d5c200
+                , $018bd
+                , $d5e200
+                , $018c5
+                , $de0000
+                , $018cd
+                , $de2000
+                , $018d5
+                , $de4000
+                , $018de
+                , $de6100
+                , $018e6
+                , $de8100
+                , $018ee
+                , $dea100
+                , $018f6
+                , $dec200
+                , $018ff
+                , $dee200
+                , $01c00
+                , $e60000
+                , $01c08
+                , $e62000
+                , $01c10
+                , $e64000
+                , $01c18
+                , $e66100
+                , $01c20
+                , $e68100
+                , $01c29
+                , $e6a100
+                , $01c31
+                , $e6c200
+                , $01c39
+                , $e6e200
+                , $01c41
+                , $ee0000
+                , $01c4a
+                , $ee2000
+                , $01c52
+                , $ee4000
+                , $01c5a
+                , $ee6100
+                , $01c62
+                , $ee8100
+                , $01c6a
+                , $eea100
+                , $01c73
+                , $eec200
+                , $01c7b
+                , $eee200
+                , $01c83
+                , $f60000
+                , $01c8b
+                , $f62000
+                , $01c94
+                , $f64000
+                , $01c9c
+                , $f66100
+                , $01ca4
+                , $f68100
+                , $01cac
+                , $f6a100
+                , $01cb4
+                , $f6c200
+                , $01cbd
+                , $f6e200
+                , $01cc5
+                , $ff0000
+                , $01ccd
+                , $ff2000
+                , $01cd5
+                , $ff4000
+                , $01cde
+                , $ff6100
+                , $01ce6
+                , $ff8100
+                , $01cee
+                , $ffa100
+                , $01cf6
+                , $ffc200
+                , $01cff
+                , $ffe200);
+
+  ConvertX86p16_32BGR888_LUT_X86: array [0..511] of DWord = (
+                  $00000
+                , $00000
+                , $80000
+                , $02000
+                , $100000
+                , $04000
+                , $180000
+                , $06100
+                , $200000
+                , $08100
+                , $290000
+                , $0a100
+                , $310000
+                , $0c200
+                , $390000
+                , $0e200
+                , $410000
+                , $00008
+                , $4a0000
+                , $02008
+                , $520000
+                , $04008
+                , $5a0000
+                , $06108
+                , $620000
+                , $08108
+                , $6a0000
+                , $0a108
+                , $730000
+                , $0c208
+                , $7b0000
+                , $0e208
+                , $830000
+                , $00010
+                , $8b0000
+                , $02010
+                , $940000
+                , $04010
+                , $9c0000
+                , $06110
+                , $a40000
+                , $08110
+                , $ac0000
+                , $0a110
+                , $b40000
+                , $0c210
+                , $bd0000
+                , $0e210
+                , $c50000
+                , $00018
+                , $cd0000
+                , $02018
+                , $d50000
+                , $04018
+                , $de0000
+                , $06118
+                , $e60000
+                , $08118
+                , $ee0000
+                , $0a118
+                , $f60000
+                , $0c218
+                , $ff0000
+                , $0e218
+                , $00400
+                , $00020
+                , $80400
+                , $02020
+                , $100400
+                , $04020
+                , $180400
+                , $06120
+                , $200400
+                , $08120
+                , $290400
+                , $0a120
+                , $310400
+                , $0c220
+                , $390400
+                , $0e220
+                , $410400
+                , $00029
+                , $4a0400
+                , $02029
+                , $520400
+                , $04029
+                , $5a0400
+                , $06129
+                , $620400
+                , $08129
+                , $6a0400
+                , $0a129
+                , $730400
+                , $0c229
+                , $7b0400
+                , $0e229
+                , $830400
+                , $00031
+                , $8b0400
+                , $02031
+                , $940400
+                , $04031
+                , $9c0400
+                , $06131
+                , $a40400
+                , $08131
+                , $ac0400
+                , $0a131
+                , $b40400
+                , $0c231
+                , $bd0400
+                , $0e231
+                , $c50400
+                , $00039
+                , $cd0400
+                , $02039
+                , $d50400
+                , $04039
+                , $de0400
+                , $06139
+                , $e60400
+                , $08139
+                , $ee0400
+                , $0a139
+                , $f60400
+                , $0c239
+                , $ff0400
+                , $0e239
+                , $00800
+                , $00041
+                , $80800
+                , $02041
+                , $100800
+                , $04041
+                , $180800
+                , $06141
+                , $200800
+                , $08141
+                , $290800
+                , $0a141
+                , $310800
+                , $0c241
+                , $390800
+                , $0e241
+                , $410800
+                , $0004a
+                , $4a0800
+                , $0204a
+                , $520800
+                , $0404a
+                , $5a0800
+                , $0614a
+                , $620800
+                , $0814a
+                , $6a0800
+                , $0a14a
+                , $730800
+                , $0c24a
+                , $7b0800
+                , $0e24a
+                , $830800
+                , $00052
+                , $8b0800
+                , $02052
+                , $940800
+                , $04052
+                , $9c0800
+                , $06152
+                , $a40800
+                , $08152
+                , $ac0800
+                , $0a152
+                , $b40800
+                , $0c252
+                , $bd0800
+                , $0e252
+                , $c50800
+                , $0005a
+                , $cd0800
+                , $0205a
+                , $d50800
+                , $0405a
+                , $de0800
+                , $0615a
+                , $e60800
+                , $0815a
+                , $ee0800
+                , $0a15a
+                , $f60800
+                , $0c25a
+                , $ff0800
+                , $0e25a
+                , $00c00
+                , $00062
+                , $80c00
+                , $02062
+                , $100c00
+                , $04062
+                , $180c00
+                , $06162
+                , $200c00
+                , $08162
+                , $290c00
+                , $0a162
+                , $310c00
+                , $0c262
+                , $390c00
+                , $0e262
+                , $410c00
+                , $0006a
+                , $4a0c00
+                , $0206a
+                , $520c00
+                , $0406a
+                , $5a0c00
+                , $0616a
+                , $620c00
+                , $0816a
+                , $6a0c00
+                , $0a16a
+                , $730c00
+                , $0c26a
+                , $7b0c00
+                , $0e26a
+                , $830c00
+                , $00073
+                , $8b0c00
+                , $02073
+                , $940c00
+                , $04073
+                , $9c0c00
+                , $06173
+                , $a40c00
+                , $08173
+                , $ac0c00
+                , $0a173
+                , $b40c00
+                , $0c273
+                , $bd0c00
+                , $0e273
+                , $c50c00
+                , $0007b
+                , $cd0c00
+                , $0207b
+                , $d50c00
+                , $0407b
+                , $de0c00
+                , $0617b
+                , $e60c00
+                , $0817b
+                , $ee0c00
+                , $0a17b
+                , $f60c00
+                , $0c27b
+                , $ff0c00
+                , $0e27b
+                , $01000
+                , $00083
+                , $81000
+                , $02083
+                , $101000
+                , $04083
+                , $181000
+                , $06183
+                , $201000
+                , $08183
+                , $291000
+                , $0a183
+                , $311000
+                , $0c283
+                , $391000
+                , $0e283
+                , $411000
+                , $0008b
+                , $4a1000
+                , $0208b
+                , $521000
+                , $0408b
+                , $5a1000
+                , $0618b
+                , $621000
+                , $0818b
+                , $6a1000
+                , $0a18b
+                , $731000
+                , $0c28b
+                , $7b1000
+                , $0e28b
+                , $831000
+                , $00094
+                , $8b1000
+                , $02094
+                , $941000
+                , $04094
+                , $9c1000
+                , $06194
+                , $a41000
+                , $08194
+                , $ac1000
+                , $0a194
+                , $b41000
+                , $0c294
+                , $bd1000
+                , $0e294
+                , $c51000
+                , $0009c
+                , $cd1000
+                , $0209c
+                , $d51000
+                , $0409c
+                , $de1000
+                , $0619c
+                , $e61000
+                , $0819c
+                , $ee1000
+                , $0a19c
+                , $f61000
+                , $0c29c
+                , $ff1000
+                , $0e29c
+                , $01400
+                , $000a4
+                , $81400
+                , $020a4
+                , $101400
+                , $040a4
+                , $181400
+                , $061a4
+                , $201400
+                , $081a4
+                , $291400
+                , $0a1a4
+                , $311400
+                , $0c2a4
+                , $391400
+                , $0e2a4
+                , $411400
+                , $000ac
+                , $4a1400
+                , $020ac
+                , $521400
+                , $040ac
+                , $5a1400
+                , $061ac
+                , $621400
+                , $081ac
+                , $6a1400
+                , $0a1ac
+                , $731400
+                , $0c2ac
+                , $7b1400
+                , $0e2ac
+                , $831400
+                , $000b4
+                , $8b1400
+                , $020b4
+                , $941400
+                , $040b4
+                , $9c1400
+                , $061b4
+                , $a41400
+                , $081b4
+                , $ac1400
+                , $0a1b4
+                , $b41400
+                , $0c2b4
+                , $bd1400
+                , $0e2b4
+                , $c51400
+                , $000bd
+                , $cd1400
+                , $020bd
+                , $d51400
+                , $040bd
+                , $de1400
+                , $061bd
+                , $e61400
+                , $081bd
+                , $ee1400
+                , $0a1bd
+                , $f61400
+                , $0c2bd
+                , $ff1400
+                , $0e2bd
+                , $01800
+                , $000c5
+                , $81800
+                , $020c5
+                , $101800
+                , $040c5
+                , $181800
+                , $061c5
+                , $201800
+                , $081c5
+                , $291800
+                , $0a1c5
+                , $311800
+                , $0c2c5
+                , $391800
+                , $0e2c5
+                , $411800
+                , $000cd
+                , $4a1800
+                , $020cd
+                , $521800
+                , $040cd
+                , $5a1800
+                , $061cd
+                , $621800
+                , $081cd
+                , $6a1800
+                , $0a1cd
+                , $731800
+                , $0c2cd
+                , $7b1800
+                , $0e2cd
+                , $831800
+                , $000d5
+                , $8b1800
+                , $020d5
+                , $941800
+                , $040d5
+                , $9c1800
+                , $061d5
+                , $a41800
+                , $081d5
+                , $ac1800
+                , $0a1d5
+                , $b41800
+                , $0c2d5
+                , $bd1800
+                , $0e2d5
+                , $c51800
+                , $000de
+                , $cd1800
+                , $020de
+                , $d51800
+                , $040de
+                , $de1800
+                , $061de
+                , $e61800
+                , $081de
+                , $ee1800
+                , $0a1de
+                , $f61800
+                , $0c2de
+                , $ff1800
+                , $0e2de
+                , $01c00
+                , $000e6
+                , $81c00
+                , $020e6
+                , $101c00
+                , $040e6
+                , $181c00
+                , $061e6
+                , $201c00
+                , $081e6
+                , $291c00
+                , $0a1e6
+                , $311c00
+                , $0c2e6
+                , $391c00
+                , $0e2e6
+                , $411c00
+                , $000ee
+                , $4a1c00
+                , $020ee
+                , $521c00
+                , $040ee
+                , $5a1c00
+                , $061ee
+                , $621c00
+                , $081ee
+                , $6a1c00
+                , $0a1ee
+                , $731c00
+                , $0c2ee
+                , $7b1c00
+                , $0e2ee
+                , $831c00
+                , $000f6
+                , $8b1c00
+                , $020f6
+                , $941c00
+                , $040f6
+                , $9c1c00
+                , $061f6
+                , $a41c00
+                , $081f6
+                , $ac1c00
+                , $0a1f6
+                , $b41c00
+                , $0c2f6
+                , $bd1c00
+                , $0e2f6
+                , $c51c00
+                , $000ff
+                , $cd1c00
+                , $020ff
+                , $d51c00
+                , $040ff
+                , $de1c00
+                , $061ff
+                , $e61c00
+                , $081ff
+                , $ee1c00
+                , $0a1ff
+                , $f61c00
+                , $0c2ff
+                , $ff1c00
+                , $0e2ff);
+
+  ConvertX86p16_32RGBA888_LUT_X86: array [0..511] of DWord = (
+                  $00000
+                , $000ff
+                , $00800
+                , $2000ff
+                , $01000
+                , $4000ff
+                , $01800
+                , $6100ff
+                , $02000
+                , $8100ff
+                , $02900
+                , $a100ff
+                , $03100
+                , $c200ff
+                , $03900
+                , $e200ff
+                , $04100
+                , $80000ff
+                , $04a00
+                , $82000ff
+                , $05200
+                , $84000ff
+                , $05a00
+                , $86100ff
+                , $06200
+                , $88100ff
+                , $06a00
+                , $8a100ff
+                , $07300
+                , $8c200ff
+                , $07b00
+                , $8e200ff
+                , $08300
+                , $100000ff
+                , $08b00
+                , $102000ff
+                , $09400
+                , $104000ff
+                , $09c00
+                , $106100ff
+                , $0a400
+                , $108100ff
+                , $0ac00
+                , $10a100ff
+                , $0b400
+                , $10c200ff
+                , $0bd00
+                , $10e200ff
+                , $0c500
+                , $180000ff
+                , $0cd00
+                , $182000ff
+                , $0d500
+                , $184000ff
+                , $0de00
+                , $186100ff
+                , $0e600
+                , $188100ff
+                , $0ee00
+                , $18a100ff
+                , $0f600
+                , $18c200ff
+                , $0ff00
+                , $18e200ff
+                , $40000
+                , $200000ff
+                , $40800
+                , $202000ff
+                , $41000
+                , $204000ff
+                , $41800
+                , $206100ff
+                , $42000
+                , $208100ff
+                , $42900
+                , $20a100ff
+                , $43100
+                , $20c200ff
+                , $43900
+                , $20e200ff
+                , $44100
+                , $290000ff
+                , $44a00
+                , $292000ff
+                , $45200
+                , $294000ff
+                , $45a00
+                , $296100ff
+                , $46200
+                , $298100ff
+                , $46a00
+                , $29a100ff
+                , $47300
+                , $29c200ff
+                , $47b00
+                , $29e200ff
+                , $48300
+                , $310000ff
+                , $48b00
+                , $312000ff
+                , $49400
+                , $314000ff
+                , $49c00
+                , $316100ff
+                , $4a400
+                , $318100ff
+                , $4ac00
+                , $31a100ff
+                , $4b400
+                , $31c200ff
+                , $4bd00
+                , $31e200ff
+                , $4c500
+                , $390000ff
+                , $4cd00
+                , $392000ff
+                , $4d500
+                , $394000ff
+                , $4de00
+                , $396100ff
+                , $4e600
+                , $398100ff
+                , $4ee00
+                , $39a100ff
+                , $4f600
+                , $39c200ff
+                , $4ff00
+                , $39e200ff
+                , $80000
+                , $410000ff
+                , $80800
+                , $412000ff
+                , $81000
+                , $414000ff
+                , $81800
+                , $416100ff
+                , $82000
+                , $418100ff
+                , $82900
+                , $41a100ff
+                , $83100
+                , $41c200ff
+                , $83900
+                , $41e200ff
+                , $84100
+                , $4a0000ff
+                , $84a00
+                , $4a2000ff
+                , $85200
+                , $4a4000ff
+                , $85a00
+                , $4a6100ff
+                , $86200
+                , $4a8100ff
+                , $86a00
+                , $4aa100ff
+                , $87300
+                , $4ac200ff
+                , $87b00
+                , $4ae200ff
+                , $88300
+                , $520000ff
+                , $88b00
+                , $522000ff
+                , $89400
+                , $524000ff
+                , $89c00
+                , $526100ff
+                , $8a400
+                , $528100ff
+                , $8ac00
+                , $52a100ff
+                , $8b400
+                , $52c200ff
+                , $8bd00
+                , $52e200ff
+                , $8c500
+                , $5a0000ff
+                , $8cd00
+                , $5a2000ff
+                , $8d500
+                , $5a4000ff
+                , $8de00
+                , $5a6100ff
+                , $8e600
+                , $5a8100ff
+                , $8ee00
+                , $5aa100ff
+                , $8f600
+                , $5ac200ff
+                , $8ff00
+                , $5ae200ff
+                , $c0000
+                , $620000ff
+                , $c0800
+                , $622000ff
+                , $c1000
+                , $624000ff
+                , $c1800
+                , $626100ff
+                , $c2000
+                , $628100ff
+                , $c2900
+                , $62a100ff
+                , $c3100
+                , $62c200ff
+                , $c3900
+                , $62e200ff
+                , $c4100
+                , $6a0000ff
+                , $c4a00
+                , $6a2000ff
+                , $c5200
+                , $6a4000ff
+                , $c5a00
+                , $6a6100ff
+                , $c6200
+                , $6a8100ff
+                , $c6a00
+                , $6aa100ff
+                , $c7300
+                , $6ac200ff
+                , $c7b00
+                , $6ae200ff
+                , $c8300
+                , $730000ff
+                , $c8b00
+                , $732000ff
+                , $c9400
+                , $734000ff
+                , $c9c00
+                , $736100ff
+                , $ca400
+                , $738100ff
+                , $cac00
+                , $73a100ff
+                , $cb400
+                , $73c200ff
+                , $cbd00
+                , $73e200ff
+                , $cc500
+                , $7b0000ff
+                , $ccd00
+                , $7b2000ff
+                , $cd500
+                , $7b4000ff
+                , $cde00
+                , $7b6100ff
+                , $ce600
+                , $7b8100ff
+                , $cee00
+                , $7ba100ff
+                , $cf600
+                , $7bc200ff
+                , $cff00
+                , $7be200ff
+                , $100000
+                , $830000ff
+                , $100800
+                , $832000ff
+                , $101000
+                , $834000ff
+                , $101800
+                , $836100ff
+                , $102000
+                , $838100ff
+                , $102900
+                , $83a100ff
+                , $103100
+                , $83c200ff
+                , $103900
+                , $83e200ff
+                , $104100
+                , $8b0000ff
+                , $104a00
+                , $8b2000ff
+                , $105200
+                , $8b4000ff
+                , $105a00
+                , $8b6100ff
+                , $106200
+                , $8b8100ff
+                , $106a00
+                , $8ba100ff
+                , $107300
+                , $8bc200ff
+                , $107b00
+                , $8be200ff
+                , $108300
+                , $940000ff
+                , $108b00
+                , $942000ff
+                , $109400
+                , $944000ff
+                , $109c00
+                , $946100ff
+                , $10a400
+                , $948100ff
+                , $10ac00
+                , $94a100ff
+                , $10b400
+                , $94c200ff
+                , $10bd00
+                , $94e200ff
+                , $10c500
+                , $9c0000ff
+                , $10cd00
+                , $9c2000ff
+                , $10d500
+                , $9c4000ff
+                , $10de00
+                , $9c6100ff
+                , $10e600
+                , $9c8100ff
+                , $10ee00
+                , $9ca100ff
+                , $10f600
+                , $9cc200ff
+                , $10ff00
+                , $9ce200ff
+                , $140000
+                , $a40000ff
+                , $140800
+                , $a42000ff
+                , $141000
+                , $a44000ff
+                , $141800
+                , $a46100ff
+                , $142000
+                , $a48100ff
+                , $142900
+                , $a4a100ff
+                , $143100
+                , $a4c200ff
+                , $143900
+                , $a4e200ff
+                , $144100
+                , $ac0000ff
+                , $144a00
+                , $ac2000ff
+                , $145200
+                , $ac4000ff
+                , $145a00
+                , $ac6100ff
+                , $146200
+                , $ac8100ff
+                , $146a00
+                , $aca100ff
+                , $147300
+                , $acc200ff
+                , $147b00
+                , $ace200ff
+                , $148300
+                , $b40000ff
+                , $148b00
+                , $b42000ff
+                , $149400
+                , $b44000ff
+                , $149c00
+                , $b46100ff
+                , $14a400
+                , $b48100ff
+                , $14ac00
+                , $b4a100ff
+                , $14b400
+                , $b4c200ff
+                , $14bd00
+                , $b4e200ff
+                , $14c500
+                , $bd0000ff
+                , $14cd00
+                , $bd2000ff
+                , $14d500
+                , $bd4000ff
+                , $14de00
+                , $bd6100ff
+                , $14e600
+                , $bd8100ff
+                , $14ee00
+                , $bda100ff
+                , $14f600
+                , $bdc200ff
+                , $14ff00
+                , $bde200ff
+                , $180000
+                , $c50000ff
+                , $180800
+                , $c52000ff
+                , $181000
+                , $c54000ff
+                , $181800
+                , $c56100ff
+                , $182000
+                , $c58100ff
+                , $182900
+                , $c5a100ff
+                , $183100
+                , $c5c200ff
+                , $183900
+                , $c5e200ff
+                , $184100
+                , $cd0000ff
+                , $184a00
+                , $cd2000ff
+                , $185200
+                , $cd4000ff
+                , $185a00
+                , $cd6100ff
+                , $186200
+                , $cd8100ff
+                , $186a00
+                , $cda100ff
+                , $187300
+                , $cdc200ff
+                , $187b00
+                , $cde200ff
+                , $188300
+                , $d50000ff
+                , $188b00
+                , $d52000ff
+                , $189400
+                , $d54000ff
+                , $189c00
+                , $d56100ff
+                , $18a400
+                , $d58100ff
+                , $18ac00
+                , $d5a100ff
+                , $18b400
+                , $d5c200ff
+                , $18bd00
+                , $d5e200ff
+                , $18c500
+                , $de0000ff
+                , $18cd00
+                , $de2000ff
+                , $18d500
+                , $de4000ff
+                , $18de00
+                , $de6100ff
+                , $18e600
+                , $de8100ff
+                , $18ee00
+                , $dea100ff
+                , $18f600
+                , $dec200ff
+                , $18ff00
+                , $dee200ff
+                , $1c0000
+                , $e60000ff
+                , $1c0800
+                , $e62000ff
+                , $1c1000
+                , $e64000ff
+                , $1c1800
+                , $e66100ff
+                , $1c2000
+                , $e68100ff
+                , $1c2900
+                , $e6a100ff
+                , $1c3100
+                , $e6c200ff
+                , $1c3900
+                , $e6e200ff
+                , $1c4100
+                , $ee0000ff
+                , $1c4a00
+                , $ee2000ff
+                , $1c5200
+                , $ee4000ff
+                , $1c5a00
+                , $ee6100ff
+                , $1c6200
+                , $ee8100ff
+                , $1c6a00
+                , $eea100ff
+                , $1c7300
+                , $eec200ff
+                , $1c7b00
+                , $eee200ff
+                , $1c8300
+                , $f60000ff
+                , $1c8b00
+                , $f62000ff
+                , $1c9400
+                , $f64000ff
+                , $1c9c00
+                , $f66100ff
+                , $1ca400
+                , $f68100ff
+                , $1cac00
+                , $f6a100ff
+                , $1cb400
+                , $f6c200ff
+                , $1cbd00
+                , $f6e200ff
+                , $1cc500
+                , $ff0000ff
+                , $1ccd00
+                , $ff2000ff
+                , $1cd500
+                , $ff4000ff
+                , $1cde00
+                , $ff6100ff
+                , $1ce600
+                , $ff8100ff
+                , $1cee00
+                , $ffa100ff
+                , $1cf600
+                , $ffc200ff
+                , $1cff00
+                , $ffe200ff);
+
+  ConvertX86p16_32BGRA888_LUT_X86: array [0..511] of DWord = (
+                  $00000
+                , $000ff
+                , $8000000
+                , $2000ff
+                , $10000000
+                , $4000ff
+                , $18000000
+                , $6100ff
+                , $20000000
+                , $8100ff
+                , $29000000
+                , $a100ff
+                , $31000000
+                , $c200ff
+                , $39000000
+                , $e200ff
+                , $41000000
+                , $008ff
+                , $4a000000
+                , $2008ff
+                , $52000000
+                , $4008ff
+                , $5a000000
+                , $6108ff
+                , $62000000
+                , $8108ff
+                , $6a000000
+                , $a108ff
+                , $73000000
+                , $c208ff
+                , $7b000000
+                , $e208ff
+                , $83000000
+                , $010ff
+                , $8b000000
+                , $2010ff
+                , $94000000
+                , $4010ff
+                , $9c000000
+                , $6110ff
+                , $a4000000
+                , $8110ff
+                , $ac000000
+                , $a110ff
+                , $b4000000
+                , $c210ff
+                , $bd000000
+                , $e210ff
+                , $c5000000
+                , $018ff
+                , $cd000000
+                , $2018ff
+                , $d5000000
+                , $4018ff
+                , $de000000
+                , $6118ff
+                , $e6000000
+                , $8118ff
+                , $ee000000
+                , $a118ff
+                , $f6000000
+                , $c218ff
+                , $ff000000
+                , $e218ff
+                , $40000
+                , $020ff
+                , $8040000
+                , $2020ff
+                , $10040000
+                , $4020ff
+                , $18040000
+                , $6120ff
+                , $20040000
+                , $8120ff
+                , $29040000
+                , $a120ff
+                , $31040000
+                , $c220ff
+                , $39040000
+                , $e220ff
+                , $41040000
+                , $029ff
+                , $4a040000
+                , $2029ff
+                , $52040000
+                , $4029ff
+                , $5a040000
+                , $6129ff
+                , $62040000
+                , $8129ff
+                , $6a040000
+                , $a129ff
+                , $73040000
+                , $c229ff
+                , $7b040000
+                , $e229ff
+                , $83040000
+                , $031ff
+                , $8b040000
+                , $2031ff
+                , $94040000
+                , $4031ff
+                , $9c040000
+                , $6131ff
+                , $a4040000
+                , $8131ff
+                , $ac040000
+                , $a131ff
+                , $b4040000
+                , $c231ff
+                , $bd040000
+                , $e231ff
+                , $c5040000
+                , $039ff
+                , $cd040000
+                , $2039ff
+                , $d5040000
+                , $4039ff
+                , $de040000
+                , $6139ff
+                , $e6040000
+                , $8139ff
+                , $ee040000
+                , $a139ff
+                , $f6040000
+                , $c239ff
+                , $ff040000
+                , $e239ff
+                , $80000
+                , $041ff
+                , $8080000
+                , $2041ff
+                , $10080000
+                , $4041ff
+                , $18080000
+                , $6141ff
+                , $20080000
+                , $8141ff
+                , $29080000
+                , $a141ff
+                , $31080000
+                , $c241ff
+                , $39080000
+                , $e241ff
+                , $41080000
+                , $04aff
+                , $4a080000
+                , $204aff
+                , $52080000
+                , $404aff
+                , $5a080000
+                , $614aff
+                , $62080000
+                , $814aff
+                , $6a080000
+                , $a14aff
+                , $73080000
+                , $c24aff
+                , $7b080000
+                , $e24aff
+                , $83080000
+                , $052ff
+                , $8b080000
+                , $2052ff
+                , $94080000
+                , $4052ff
+                , $9c080000
+                , $6152ff
+                , $a4080000
+                , $8152ff
+                , $ac080000
+                , $a152ff
+                , $b4080000
+                , $c252ff
+                , $bd080000
+                , $e252ff
+                , $c5080000
+                , $05aff
+                , $cd080000
+                , $205aff
+                , $d5080000
+                , $405aff
+                , $de080000
+                , $615aff
+                , $e6080000
+                , $815aff
+                , $ee080000
+                , $a15aff
+                , $f6080000
+                , $c25aff
+                , $ff080000
+                , $e25aff
+                , $c0000
+                , $062ff
+                , $80c0000
+                , $2062ff
+                , $100c0000
+                , $4062ff
+                , $180c0000
+                , $6162ff
+                , $200c0000
+                , $8162ff
+                , $290c0000
+                , $a162ff
+                , $310c0000
+                , $c262ff
+                , $390c0000
+                , $e262ff
+                , $410c0000
+                , $06aff
+                , $4a0c0000
+                , $206aff
+                , $520c0000
+                , $406aff
+                , $5a0c0000
+                , $616aff
+                , $620c0000
+                , $816aff
+                , $6a0c0000
+                , $a16aff
+                , $730c0000
+                , $c26aff
+                , $7b0c0000
+                , $e26aff
+                , $830c0000
+                , $073ff
+                , $8b0c0000
+                , $2073ff
+                , $940c0000
+                , $4073ff
+                , $9c0c0000
+                , $6173ff
+                , $a40c0000
+                , $8173ff
+                , $ac0c0000
+                , $a173ff
+                , $b40c0000
+                , $c273ff
+                , $bd0c0000
+                , $e273ff
+                , $c50c0000
+                , $07bff
+                , $cd0c0000
+                , $207bff
+                , $d50c0000
+                , $407bff
+                , $de0c0000
+                , $617bff
+                , $e60c0000
+                , $817bff
+                , $ee0c0000
+                , $a17bff
+                , $f60c0000
+                , $c27bff
+                , $ff0c0000
+                , $e27bff
+                , $100000
+                , $083ff
+                , $8100000
+                , $2083ff
+                , $10100000
+                , $4083ff
+                , $18100000
+                , $6183ff
+                , $20100000
+                , $8183ff
+                , $29100000
+                , $a183ff
+                , $31100000
+                , $c283ff
+                , $39100000
+                , $e283ff
+                , $41100000
+                , $08bff
+                , $4a100000
+                , $208bff
+                , $52100000
+                , $408bff
+                , $5a100000
+                , $618bff
+                , $62100000
+                , $818bff
+                , $6a100000
+                , $a18bff
+                , $73100000
+                , $c28bff
+                , $7b100000
+                , $e28bff
+                , $83100000
+                , $094ff
+                , $8b100000
+                , $2094ff
+                , $94100000
+                , $4094ff
+                , $9c100000
+                , $6194ff
+                , $a4100000
+                , $8194ff
+                , $ac100000
+                , $a194ff
+                , $b4100000
+                , $c294ff
+                , $bd100000
+                , $e294ff
+                , $c5100000
+                , $09cff
+                , $cd100000
+                , $209cff
+                , $d5100000
+                , $409cff
+                , $de100000
+                , $619cff
+                , $e6100000
+                , $819cff
+                , $ee100000
+                , $a19cff
+                , $f6100000
+                , $c29cff
+                , $ff100000
+                , $e29cff
+                , $140000
+                , $0a4ff
+                , $8140000
+                , $20a4ff
+                , $10140000
+                , $40a4ff
+                , $18140000
+                , $61a4ff
+                , $20140000
+                , $81a4ff
+                , $29140000
+                , $a1a4ff
+                , $31140000
+                , $c2a4ff
+                , $39140000
+                , $e2a4ff
+                , $41140000
+                , $0acff
+                , $4a140000
+                , $20acff
+                , $52140000
+                , $40acff
+                , $5a140000
+                , $61acff
+                , $62140000
+                , $81acff
+                , $6a140000
+                , $a1acff
+                , $73140000
+                , $c2acff
+                , $7b140000
+                , $e2acff
+                , $83140000
+                , $0b4ff
+                , $8b140000
+                , $20b4ff
+                , $94140000
+                , $40b4ff
+                , $9c140000
+                , $61b4ff
+                , $a4140000
+                , $81b4ff
+                , $ac140000
+                , $a1b4ff
+                , $b4140000
+                , $c2b4ff
+                , $bd140000
+                , $e2b4ff
+                , $c5140000
+                , $0bdff
+                , $cd140000
+                , $20bdff
+                , $d5140000
+                , $40bdff
+                , $de140000
+                , $61bdff
+                , $e6140000
+                , $81bdff
+                , $ee140000
+                , $a1bdff
+                , $f6140000
+                , $c2bdff
+                , $ff140000
+                , $e2bdff
+                , $180000
+                , $0c5ff
+                , $8180000
+                , $20c5ff
+                , $10180000
+                , $40c5ff
+                , $18180000
+                , $61c5ff
+                , $20180000
+                , $81c5ff
+                , $29180000
+                , $a1c5ff
+                , $31180000
+                , $c2c5ff
+                , $39180000
+                , $e2c5ff
+                , $41180000
+                , $0cdff
+                , $4a180000
+                , $20cdff
+                , $52180000
+                , $40cdff
+                , $5a180000
+                , $61cdff
+                , $62180000
+                , $81cdff
+                , $6a180000
+                , $a1cdff
+                , $73180000
+                , $c2cdff
+                , $7b180000
+                , $e2cdff
+                , $83180000
+                , $0d5ff
+                , $8b180000
+                , $20d5ff
+                , $94180000
+                , $40d5ff
+                , $9c180000
+                , $61d5ff
+                , $a4180000
+                , $81d5ff
+                , $ac180000
+                , $a1d5ff
+                , $b4180000
+                , $c2d5ff
+                , $bd180000
+                , $e2d5ff
+                , $c5180000
+                , $0deff
+                , $cd180000
+                , $20deff
+                , $d5180000
+                , $40deff
+                , $de180000
+                , $61deff
+                , $e6180000
+                , $81deff
+                , $ee180000
+                , $a1deff
+                , $f6180000
+                , $c2deff
+                , $ff180000
+                , $e2deff
+                , $1c0000
+                , $0e6ff
+                , $81c0000
+                , $20e6ff
+                , $101c0000
+                , $40e6ff
+                , $181c0000
+                , $61e6ff
+                , $201c0000
+                , $81e6ff
+                , $291c0000
+                , $a1e6ff
+                , $311c0000
+                , $c2e6ff
+                , $391c0000
+                , $e2e6ff
+                , $411c0000
+                , $0eeff
+                , $4a1c0000
+                , $20eeff
+                , $521c0000
+                , $40eeff
+                , $5a1c0000
+                , $61eeff
+                , $621c0000
+                , $81eeff
+                , $6a1c0000
+                , $a1eeff
+                , $731c0000
+                , $c2eeff
+                , $7b1c0000
+                , $e2eeff
+                , $831c0000
+                , $0f6ff
+                , $8b1c0000
+                , $20f6ff
+                , $941c0000
+                , $40f6ff
+                , $9c1c0000
+                , $61f6ff
+                , $a41c0000
+                , $81f6ff
+                , $ac1c0000
+                , $a1f6ff
+                , $b41c0000
+                , $c2f6ff
+                , $bd1c0000
+                , $e2f6ff
+                , $c51c0000
+                , $0ffff
+                , $cd1c0000
+                , $20ffff
+                , $d51c0000
+                , $40ffff
+                , $de1c0000
+                , $61ffff
+                , $e61c0000
+                , $81ffff
+                , $ee1c0000
+                , $a1ffff
+                , $f61c0000
+                , $c2ffff
+                , $ff1c0000
+                , $e2ffff);

+ 0 - 297
packages/hermes/src/i386/x86_clr.as

@@ -1,297 +0,0 @@
-#
-# x86 surface clear routines for HERMES
-# Copyright (c) 1998 Christian Nentwich ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-# (04/10/99)    Modified ClearX86_8             <[email protected]>
-
-
-
-
-.globl _ClearX86_32
-.globl _ClearX86_24
-.globl _ClearX86_16
-.globl _ClearX86_8
-
-.text
-
-##
-## --------------------------------------------------------------------------
-## HermesClearInterface (ebp+..)
-##   0: char8 *dest
-##   4: int32 value
-##   8: unsigned int width (already checked to be >0!)
-##  12: unsigned int height (already checked to be >0!)
-##  16: int add
-
-.align 8
-_ClearX86_32:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl (%ebp),%edi        # destination
-        movl 4(%ebp),%eax       # pixel value
-
-        movl 12(%ebp),%edx      # height
-.align 4
-_ClearX86_32.L_y:
-        movl 8(%ebp),%ecx
-        rep
- stosl
-
-        addl 16(%ebp),%edi
-
-        decl %edx
-        jnz _ClearX86_32.L_y
-
-        popl %ebp
-        ret
-
-
-
-_ClearX86_24:
-        ret
-
-
-
-.align 8
-_ClearX86_16:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl (%ebp),%edi        # destination
-        movl 4(%ebp),%eax       # pixel value
-
-        movl 12(%ebp),%edx      # height
-        movl %eax,%ebx
-
-        shll $16,%eax           # Duplicate pixel value
-        andl $0x0ffff,%ebx
-
-        orl %ebx,%eax
-_ClearX86_16.L_y:
-        movl 8(%ebp),%ecx
-
-        testl $3,%edi           # Check if destination is aligned mod 4
-        jz _ClearX86_16.L_aligned
-
-        movw %ax,(%edi)         # otherwise write one pixel
-        addl $2,%edi
-
-        decl %ecx
-        jz _ClearX86_16.L_endline
-
-_ClearX86_16.L_aligned:
-        shrl %ecx
-
-rep
- stosl
-
-        jnc _ClearX86_16.L_endline
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-_ClearX86_16.L_endline:
-        addl 16(%ebp),%edi
-
-        decl %edx
-        jnz _ClearX86_16.L_y
-
-        popl %ebp
-        ret
-
-
-
-.align 8
-_ClearX86_8:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl 4(%ebp),%eax       # pixel value
-        movl 12(%ebp),%edx      # height
-
-        movb %al,%ah
-        movl (%ebp),%edi        # destination
-
-        movl %eax,%ecx
-
-        shll $16,%eax           # Put the byte pixel value in all four bytes
-        andl $0x0ffff,%ecx      # of eax
-
-        movl 8(%ebp),%ebx
-        orl %ecx,%eax
-
-        cmpl $5,%ebx            # removes need for extra checks later
-        jbe _ClearX86_8.L_short_y
-
-.align 4
-_ClearX86_8.L_y:
-        testl $3,%edi
-        jz _ClearX86_8.L_aligned
-
-        movl %edi,%ecx
-        negl %ecx
-        andl $3,%ecx
-
-        subl %ecx,%ebx
-
-        rep
- stosb
-
-_ClearX86_8.L_aligned:
-        movl %ebx,%ecx
-
-        shrl $2,%ecx
-        andl $3,%ebx
-
-        rep
- stosl
-
-        movl %ebx,%ecx
-        rep
- stosb
-
-        addl 16(%ebp),%edi
-
-        decl %edx
-        movl 8(%ebp),%ebx
-        jnz _ClearX86_8.L_y
-
-        popl %ebp
-        ret
-
-## Short loop
-.align 4
-_ClearX86_8.L_short_y:
-        movl %ebx,%ecx
-
-        rep
- stosb
-        addl 16(%ebp),%edi
-
-        decl %edx
-        jnz _ClearX86_8.L_short_y
-
-        popl %ebp
-        ret
-
-## ClearX86_8 version 2,
-## Im not sure wheather this is faster or not...
-## too many jumps could confuse the CPU branch quessing
-
-
-.align 8
-_ClearX86_8_2:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl 4(%ebp),%eax       # pixel value
-        movl 12(%ebp),%edx      # height
-
-        movb %al,%ah
-        movl (%ebp),%edi        # destination
-
-        movl %eax,%ecx
-
-        shll $16,%eax           # Put the byte pixel value in all four bytes
-        andl $0x0ffff,%ecx      # of eax
-
-        movl 8(%ebp),%ebx
-        orl %ecx,%eax
-
-        cmpl $5,%ebx            # removes need for extra checks in main loop
-        jbe _ClearX86_8_2.L_short_y
-
-
-.align 4
-_ClearX86_8_2.L_y:
-        testl $3,%edi
-        jz _ClearX86_8_2.L_aligned
-
-        movl %edi,%ecx
-        negl %ecx
-        andl $3,%ecx
-
-        movb %al,(%edi)
-        subl %ecx,%ebx
-
-        incl %edi
-
-        decl %ecx
-        jz _ClearX86_8_2.L_aligned
-
-        movb %al,(%edi)
-        incl %edi
-        decl %ecx
-        jz _ClearX86_8_2.L_aligned
-
-        movb %al,(%edi)
-        incl %edi
-
-_ClearX86_8_2.L_aligned:
-        movl %ebx,%ecx
-
-        shrl $2,%ecx
-        andl $3,%ebx
-
-        rep
- stosl
-
-        jz _ClearX86_8_2.L_endline
-                # ebx
-
-        movb %al,(%edi)
-                # Write remaining (1,2 or 3) pixels
-        incl %edi
-        decl %ebx
-        jz _ClearX86_8_2.L_endline
-
-        movb %al,(%edi)
-        incl %edi
-        decl %ebx
-        jz _ClearX86_8_2.L_endline
-
-        movb %al,(%edi)
-        incl %edi
-        decl %ebx
-        jz _ClearX86_8_2.L_endline
-
-        movb %al,(%edi)
-        incl %edi
-
-_ClearX86_8_2.L_endline:
-        addl 16(%ebp),%edi
-
-        decl %edx
-        movl 8(%ebp),%ebx
-        jnz _ClearX86_8_2.L_y
-
-        popl %ebp
-        ret
-
-## Short loop
-.align 4
-_ClearX86_8_2.L_short_y:
-        movl %ebx,%ecx
-
-        rep
- stosb
-        addl 16(%ebp),%edi
-
-        decl %edx
-        jnz _ClearX86_8_2.L_short_y
-
-        popl %ebp
-        ret

+ 305 - 0
packages/hermes/src/i386/x86_clr.inc

@@ -0,0 +1,305 @@
+{
+    x86 surface clear routines for HERMES
+    Copyright (c) 1998 Christian Nentwich ([email protected])
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    (04/10/99)    Modified ClearX86_8             <[email protected]>
+}
+
+{$ASMMODE att}
+
+{
+ --------------------------------------------------------------------------
+ HermesClearInterface (ebp+..)
+   0: char8 *dest
+   4: int32 value
+   8: unsigned int width (already checked to be >0!)
+  12: unsigned int height (already checked to be >0!)
+  16: int add
+}
+procedure ClearX86_32(hci: PHermesClearInterface); cdecl; assembler;
+asm
+        pushl %ebp
+
+        movl 8(%ebp),%ebp
+
+        movl (%ebp),%edi        // destination
+        movl 4(%ebp),%eax       // pixel value
+
+        movl 12(%ebp),%edx      // height
+.balign 4
+.L_y:
+        movl 8(%ebp),%ecx
+        rep
+ stosl
+
+        addl 16(%ebp),%edi
+
+        decl %edx
+        jnz .L_y
+
+        popl %ebp
+end;
+
+procedure ClearX86_24(hci: PHermesClearInterface); cdecl; assembler;
+asm
+end;
+
+procedure ClearX86_16(hci: PHermesClearInterface); cdecl; assembler;
+asm
+        pushl %ebp
+
+        movl 8(%ebp),%ebp
+
+        movl (%ebp),%edi        // destination
+        movl 4(%ebp),%eax       // pixel value
+
+        movl 12(%ebp),%edx      // height
+        movl %eax,%ebx
+
+        shll $16,%eax           // Duplicate pixel value
+        andl $0x0ffff,%ebx
+
+        orl %ebx,%eax
+.L_y:
+        movl 8(%ebp),%ecx
+
+        testl $3,%edi           // Check if destination is aligned mod 4
+        jz .L_aligned
+
+        movw %ax,(%edi)         // otherwise write one pixel
+        addl $2,%edi
+
+        decl %ecx
+        jz .L_endline
+
+.L_aligned:
+        shrl $1,%ecx
+
+rep
+ stosl
+
+        jnc .L_endline
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+.L_endline:
+        addl 16(%ebp),%edi
+
+        decl %edx
+        jnz .L_y
+
+        popl %ebp
+end;
+
+procedure ClearX86_8(hci: PHermesClearInterface); cdecl; nostackframe; assembler;
+asm
+        pushl %ebp
+        movl %esp,%ebp
+
+        movl 8(%ebp),%ebp
+
+        movl 4(%ebp),%eax       // pixel value
+        movl 12(%ebp),%edx      // height
+
+        movb %al,%ah
+        movl (%ebp),%edi        // destination
+
+        movl %eax,%ecx
+
+        shll $16,%eax           // Put the byte pixel value in all four bytes
+        andl $0x0ffff,%ecx      // of eax
+
+        movl 8(%ebp),%ebx
+        orl %ecx,%eax
+
+        cmpl $5,%ebx            // removes need for extra checks later
+        jbe .L_short_y
+
+.balign 4
+.L_y:
+        testl $3,%edi
+        jz .L_aligned
+
+        movl %edi,%ecx
+        negl %ecx
+        andl $3,%ecx
+
+        subl %ecx,%ebx
+
+        rep
+ stosb
+
+.L_aligned:
+        movl %ebx,%ecx
+
+        shrl $2,%ecx
+        andl $3,%ebx
+
+        rep
+ stosl
+
+        movl %ebx,%ecx
+        rep
+ stosb
+
+        addl 16(%ebp),%edi
+
+        decl %edx
+        movl 8(%ebp),%ebx
+        jnz .L_y
+
+        popl %ebp
+        ret
+
+// Short loop
+.balign 4
+.L_short_y:
+        movl %ebx,%ecx
+
+        rep
+ stosb
+        addl 16(%ebp),%edi
+
+        decl %edx
+        jnz .L_short_y
+
+        popl %ebp
+end;
+
+{
+ ClearX86_8 version 2,
+ Im not sure wheather this is faster or not...
+ too many jumps could confuse the CPU branch guessing
+}
+procedure ClearX86_8_2(hci: PHermesClearInterface); cdecl; nostackframe; assembler;
+asm
+        pushl %ebp
+        movl %esp,%ebp
+
+        movl 8(%ebp),%ebp
+
+        movl 4(%ebp),%eax       // pixel value
+        movl 12(%ebp),%edx      // height
+
+        movb %al,%ah
+        movl (%ebp),%edi        // destination
+
+        movl %eax,%ecx
+
+        shll $16,%eax           // Put the byte pixel value in all four bytes
+        andl $0x0ffff,%ecx      // of eax
+
+        movl 8(%ebp),%ebx
+        orl %ecx,%eax
+
+        cmpl $5,%ebx            // removes need for extra checks in main loop
+        jbe .L_short_y
+
+
+.balign 4
+.L_y:
+        testl $3,%edi
+        jz .L_aligned
+
+        movl %edi,%ecx
+        negl %ecx
+        andl $3,%ecx
+
+        movb %al,(%edi)
+        subl %ecx,%ebx
+
+        incl %edi
+
+        decl %ecx
+        jz .L_aligned
+
+        movb %al,(%edi)
+        incl %edi
+        decl %ecx
+        jz .L_aligned
+
+        movb %al,(%edi)
+        incl %edi
+
+.L_aligned:
+        movl %ebx,%ecx
+
+        shrl $2,%ecx
+        andl $3,%ebx
+
+        rep
+ stosl
+
+        jz .L_endline
+                // ebx
+
+        movb %al,(%edi)
+                // Write remaining (1,2 or 3) pixels
+        incl %edi
+        decl %ebx
+        jz .L_endline
+
+        movb %al,(%edi)
+        incl %edi
+        decl %ebx
+        jz .L_endline
+
+        movb %al,(%edi)
+        incl %edi
+        decl %ebx
+        jz .L_endline
+
+        movb %al,(%edi)
+        incl %edi
+
+.L_endline:
+        addl 16(%ebp),%edi
+
+        decl %edx
+        movl 8(%ebp),%ebx
+        jnz .L_y
+
+        popl %ebp
+        ret
+
+// Short loop
+.balign 4
+.L_short_y:
+        movl %ebx,%ecx
+
+        rep
+ stosb
+        addl 16(%ebp),%edi
+
+        decl %edx
+        jnz .L_short_y
+
+        popl %ebp
+end;

+ 0 - 182
packages/hermes/src/i386/x86_main.as

@@ -1,182 +0,0 @@
-#
-# x86 format converters for HERMES
-# Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-
-
-
-.globl _ConvertX86
-.globl _ConvertX86Stretch
-.globl _x86return
-.globl _x86return_S
-
-.globl _Hermes_X86_CPU
-
-
-.data
-
-cpu_flags: .long 0
-
-.text
-
-.equ s_pixels, 0
-.equ s_width, 4
-.equ s_height, 8
-.equ s_add, 12
-.equ d_pixels, 16
-.equ d_width, 20
-.equ d_height, 24
-.equ d_add, 28
-.equ conv_func, 32
-.equ lookup, 36
-.equ s_pitch, 40
-.equ d_pitch, 44
-
-## _ConvertX86:
-## [ESP+8] ConverterInfo*
-## --------------------------------------------------------------------------
-##
-## ConvertX86Stretch 'abuses' the following info structure fields:
-##      - d_pitch for the y increment
-##      - s_add for the x increment
-## because they're unused anyway and this is thread safe.. (it's a per
-## converter handle structure)
-_ConvertX86Stretch:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl s_height(%ebp),%eax
-        sall $16,%eax
-        cdq
-        idivl d_height(%ebp)
-        movl %eax,d_pitch(%ebp)
-
-        movl s_width(%ebp),%eax
-        sall $16,%eax
-        cdq
-        idivl d_width(%ebp)
-        movl %eax,s_add(%ebp)
-
-        movl $0,s_height(%ebp)
-
-        movl d_pixels(%ebp),%edi
-        movl s_pixels(%ebp),%esi
-
-        movl s_add(%ebp),%edx
-        movl d_width(%ebp),%ecx
-        jmp *conv_func(%ebp)
-
-.align 8
-_x86return_S:
-
-        decl d_height(%ebp)
-        jz endconvert_S
-
-        movl s_height(%ebp),%eax
-        addl d_add(%ebp),%edi
-
-        addl d_pitch(%ebp),%eax
-
-        movl %eax,%ebx
-
-        shrl $16,%eax
-
-        mull s_pitch(%ebp)
-        andl $0x0ffff,%ebx
-
-        movl %ebx,s_height(%ebp)
-        addl %eax,%esi
-
-        movl s_add(%ebp),%edx
-        movl d_width(%ebp),%ecx
-
-        jmp *conv_func(%ebp)
-
-endconvert_S:
-
-        popl %ebp
-        ret
-
-
-
-_ConvertX86:
-        pushl %ebp
-        movl %esp,%ebp
-
-        movl 8(%ebp),%ebp
-
-        movl s_pixels(%ebp),%esi
-        movl d_width(%ebp),%ecx
-        movl d_pixels(%ebp),%edi
-
-        jmp *32(%ebp)
-
-.align 8
-_x86return:
-        decl s_height(%ebp)
-        jz endconvert
-
-        movl d_width(%ebp),%ecx
-        addl s_add(%ebp),%esi
-        addl d_add(%ebp),%edi
-
-        jmp *32(%ebp)
-
-
-endconvert:
-        popl %ebp
-        ret
-
-
-
-## Hermes_X86_CPU returns the CPUID flags in eax
-
-_Hermes_X86_CPU:
-        pushfl
-        popl %eax
-
-        movl %eax,%ecx
-
-        xorl $0x040000,%eax
-        pushl %eax
-
-        popfl
-        pushfl
-
-        popl %eax
-        xorl %ecx,%eax
-        jz _Hermes_X86_CPU.L1   # Processor is 386
-
-        pushl %ecx
-        popfl
-
-        movl %ecx,%eax
-        xorl $0x200000,%eax
-
-        pushl %eax
-        popfl
-        pushfl
-
-        popl %eax
-        xorl %ecx,%eax
-        je _Hermes_X86_CPU.L1
-
-        pusha
-
-        movl $1,%eax
-        cpuid
-
-        movl %edx,cpu_flags
-
-        popa
-
-        movl cpu_flags,%eax
-
-_Hermes_X86_CPU.L1:
-        ret

+ 182 - 0
packages/hermes/src/i386/x86_main.inc

@@ -0,0 +1,182 @@
+{
+    x86 format converters for HERMES
+    Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+label
+  _x86return, _x86return_S;
+
+var
+  cpu_flags: DWord = 0;
+
+{ _ConvertX86:
+ [ESP+8] ConverterInfo*
+ --------------------------------------------------------------------------
+
+ ConvertX86Stretch 'abuses' the following info structure fields:
+      - d_pitch for the y increment
+      - s_add for the x increment
+ because they're unused anyway and this is thread safe.. (it's a per
+ converter handle structure)
+}
+procedure ConvertX86Stretch(hci: PHermesConverterInterface); cdecl; assembler;
+label
+  endconvert_S;
+asm
+        pushl %ebp
+
+        movl 8(%ebp),%ebp
+
+        movl 8(%ebp),%eax  // s_height
+        sall $16,%eax
+        cltd
+        idivl 24(%ebp)  // d_height
+        movl %eax,44(%ebp)  // d_pitch
+
+        movl 4(%ebp),%eax  // s_width
+        sall $16,%eax
+        cltd
+        idivl 20(%ebp)  // d_width
+        movl %eax,12(%ebp)  // s_add
+
+        movl $0,8(%ebp)  // s_height
+
+        movl 16(%ebp),%edi  // d_pixels
+        movl 0(%ebp),%esi  // s_pixels
+
+        movl 12(%ebp),%edx  // s_add
+        movl 20(%ebp),%ecx  // d_width
+        jmp *32(%ebp)  // conv_func
+
+.balign 8
+_x86return_S:
+
+        decl 24(%ebp)  // d_height
+        jz endconvert_S
+
+        movl 8(%ebp),%eax  // s_height
+        addl 28(%ebp),%edi  // d_add
+
+        addl 44(%ebp),%eax  // d_pitch
+
+        movl %eax,%ebx
+
+        shrl $16,%eax
+
+        mull 40(%ebp)  // s_pitch
+        andl $0x0ffff,%ebx
+
+        movl %ebx,8(%ebp)  // s_height
+        addl %eax,%esi
+
+        movl 12(%ebp),%edx  // s_add
+        movl 20(%ebp),%ecx  // d_width
+
+        jmp *32(%ebp)  // conv_func
+
+endconvert_S:
+
+        popl %ebp
+end;
+
+procedure ConvertX86(hci: PHermesConverterInterface); cdecl; assembler;
+label
+  endconvert;
+asm
+        pushl %ebp
+
+        movl 8(%ebp),%ebp
+
+        movl 0(%ebp),%esi  // s_pixels
+        movl 20(%ebp),%ecx  // d_width
+        movl 16(%ebp),%edi  // d_pixels
+
+        jmp *32(%ebp)
+
+.balign 8
+_x86return:
+        decl 8(%ebp)  // s_height
+        jz endconvert
+
+        movl 20(%ebp),%ecx  // d_width
+        addl 12(%ebp),%esi  // s_add
+        addl 28(%ebp),%edi  // d_add
+
+        jmp *32(%ebp)
+
+
+endconvert:
+        popl %ebp
+end;
+
+// Hermes_X86_CPU returns the CPUID flags in eax
+function Hermes_X86_CPU: Integer; cdecl; assembler;
+asm
+        pushfl
+        popl %eax
+
+        movl %eax,%ecx
+
+        xorl $0x040000,%eax
+        pushl %eax
+
+        popfl
+        pushfl
+
+        popl %eax
+        xorl %ecx,%eax
+        jz .L1   // Processor is 386
+
+        pushl %ecx
+        popfl
+
+        movl %ecx,%eax
+        xorl $0x200000,%eax
+
+        pushl %eax
+        popfl
+        pushfl
+
+        popl %eax
+        xorl %ecx,%eax
+        je .L1
+
+        pusha
+
+        movl $1,%eax
+        cpuid
+
+        movl %edx,cpu_flags
+
+        popa
+
+        movl cpu_flags,%eax
+
+.L1:
+end;

+ 0 - 1154
packages/hermes/src/i386/x86p_16.as

@@ -1,1154 +0,0 @@
-#
-# x86 format converters for HERMES
-# Copyright (c) 1998 Glenn Fielder ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-# Routines adjusted for Hermes by Christian Nentwich ([email protected])
-# Used with permission.
-#
-
-
-#BITS 32
-
-.globl _ConvertX86p16_32RGB888
-.globl _ConvertX86p16_32BGR888
-.globl _ConvertX86p16_32RGBA888
-.globl _ConvertX86p16_32BGRA888
-.globl _ConvertX86p16_24RGB888
-.globl _ConvertX86p16_24BGR888
-.globl _ConvertX86p16_16BGR565
-.globl _ConvertX86p16_16RGB555
-.globl _ConvertX86p16_16BGR555
-.globl _ConvertX86p16_8RGB332
-
-.extern _ConvertX86
-.extern _x86return
-
-.globl _ConvertX86p16_32RGB888_LUT_X86
-.globl _ConvertX86p16_32BGR888_LUT_X86
-.globl _ConvertX86p16_32RGBA888_LUT_X86
-.globl _ConvertX86p16_32BGRA888_LUT_X86
-
-.include "src/i386/x8616lut.as"
-
-.text
-
-
-
-_ConvertX86p16_32RGB888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p16_32RGB888.L3
-
-
-    # short loop
-    xorl %ebx,%ebx
-_ConvertX86p16_32RGB888.L1: movb (%esi),%bl             # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%eax  # eax = ARGB8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                    # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%edx# edx = ARGB8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p16_32RGB888.L1
-_ConvertX86p16_32RGB888.L2:
-    jmp _x86return
-
-
-_ConvertX86p16_32RGB888.L3:  # save ebp
-    pushl %ebp
-
-    # save count
-    pushl %ecx
-
-    # unroll twice
-    movl %ecx,%ebp
-    shrl %ebp
-
-    # point arrays to end
-    leal (%esi,%ebp,4),%esi
-    leal (%edi,%ebp,8),%edi
-
-    # negative counter
-    negl %ebp
-
-    # clear
-    xorl %ebx,%ebx
-    xorl %ecx,%ecx
-
-    # prestep
-    movb (%esi,%ebp,4),%cl
-    movb 1(%esi,%ebp,4),%bl
-
-_ConvertX86p16_32RGB888.L4: movl _ConvertX86p16_32RGB888_LUT_X86(,%ecx,8),%edx
-        movb 2(%esi,%ebp,4),%cl
-
-        movl _ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%eax
-        movb 3(%esi,%ebp,4),%bl
-
-        addl %edx,%eax
-        movl _ConvertX86p16_32RGB888_LUT_X86(,%ecx,8),%edx
-
-        movl %eax,(%edi,%ebp,8)
-        movl _ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%eax
-
-        addl %edx,%eax
-        movb 4(%esi,%ebp,4),%cl
-
-        movl %eax,4(%edi,%ebp,8)
-        movb 5(%esi,%ebp,4),%bl
-
-        incl %ebp
-        jnz _ConvertX86p16_32RGB888.L4
-
-    # tail
-    popl %ecx
-    andl $1,%ecx
-    jz _ConvertX86p16_32RGB888.L6
-    xorl %ebx,%ebx
-    movb (%esi),%bl                                     # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%eax  # eax = ARGB8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                    # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%edx# edx = ARGB8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-
-_ConvertX86p16_32RGB888.L6: popl %ebp
-    jmp _x86return
-
-
-
-
-
-
-_ConvertX86p16_32BGR888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p16_32BGR888.L3
-
-
-    # short loop
-    xorl %ebx,%ebx
-_ConvertX86p16_32BGR888.L1: movb (%esi),%bl             # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax  # eax = ABGR8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                    # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%edx# edx = ABGR8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p16_32BGR888.L1
-_ConvertX86p16_32BGR888.L2:
-    jmp _x86return
-
-_ConvertX86p16_32BGR888.L3:  # save ebp
-    pushl %ebp
-
-    # save count
-    pushl %ecx
-
-    # unroll twice
-    movl %ecx,%ebp
-    shrl %ebp
-
-    # point arrays to end
-    leal (%esi,%ebp,4),%esi
-    leal (%edi,%ebp,8),%edi
-
-    # negative counter
-    negl %ebp
-
-    # clear
-    xorl %ebx,%ebx
-    xorl %ecx,%ecx
-
-    # prestep
-    movb (%esi,%ebp,4),%cl
-    movb 1(%esi,%ebp,4),%bl
-
-_ConvertX86p16_32BGR888.L4: movl _ConvertX86p16_32BGR888_LUT_X86(,%ecx,8),%edx
-        movb 2(%esi,%ebp,4),%cl
-
-        movl _ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%eax
-        movb 3(%esi,%ebp,4),%bl
-
-        addl %edx,%eax
-        movl _ConvertX86p16_32BGR888_LUT_X86(,%ecx,8),%edx
-
-        movl %eax,(%edi,%ebp,8)
-        movl _ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%eax
-
-        addl %edx,%eax
-        movb 4(%esi,%ebp,4),%cl
-
-        movl %eax,4(%edi,%ebp,8)
-        movb 5(%esi,%ebp,4),%bl
-
-        incl %ebp
-        jnz _ConvertX86p16_32BGR888.L4
-
-    # tail
-    popl %ecx
-    andl $1,%ecx
-    jz _ConvertX86p16_32BGR888.L6
-    xorl %ebx,%ebx
-    movb (%esi),%bl                                     # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax  # eax = ABGR8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                    # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%edx# edx = ABGR8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-
-_ConvertX86p16_32BGR888.L6: popl %ebp
-    jmp _x86return
-
-
-
-
-
-
-_ConvertX86p16_32RGBA888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p16_32RGBA888.L3
-
-
-    # short loop
-    xorl %ebx,%ebx
-_ConvertX86p16_32RGBA888.L1: movb (%esi),%bl             # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32RGBA888_LUT_X86(,%ebx,8),%eax  # eax = RGBA8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                     # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%edx# edx = RGBA8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p16_32RGBA888.L1
-_ConvertX86p16_32RGBA888.L2:
-    jmp _x86return
-
-_ConvertX86p16_32RGBA888.L3:  # save ebp
-    pushl %ebp
-
-    # save count
-    pushl %ecx
-
-    # unroll twice
-    movl %ecx,%ebp
-    shrl %ebp
-
-    # point arrays to end
-    leal (%esi,%ebp,4),%esi
-    leal (%edi,%ebp,8),%edi
-
-    # negative counter
-    negl %ebp
-
-    # clear
-    xorl %ebx,%ebx
-    xorl %ecx,%ecx
-
-    # prestep
-    movb (%esi,%ebp,4),%cl
-    movb 1(%esi,%ebp,4),%bl
-
-_ConvertX86p16_32RGBA888.L4: movl _ConvertX86p16_32RGBA888_LUT_X86(,%ecx,8),%edx
-        movb 2(%esi,%ebp,4),%cl
-
-        movl _ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%eax
-        movb 3(%esi,%ebp,4),%bl
-
-        addl %edx,%eax
-        movl _ConvertX86p16_32RGBA888_LUT_X86(,%ecx,8),%edx
-
-        movl %eax,(%edi,%ebp,8)
-        movl _ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%eax
-
-        addl %edx,%eax
-        movb 4(%esi,%ebp,4),%cl
-
-        movl %eax,4(%edi,%ebp,8)
-        movb 5(%esi,%ebp,4),%bl
-
-        incl %ebp
-        jnz _ConvertX86p16_32RGBA888.L4
-
-    # tail
-    popl %ecx
-    andl $1,%ecx
-    jz _ConvertX86p16_32RGBA888.L6
-    xorl %ebx,%ebx
-    movb (%esi),%bl                                      # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32RGBA888_LUT_X86(,%ebx,8),%eax  # eax = RGBA8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                     # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%edx# edx = RGBA8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-
-_ConvertX86p16_32RGBA888.L6: popl %ebp
-    jmp _x86return
-
-
-
-
-
-
-_ConvertX86p16_32BGRA888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p16_32BGRA888.L3
-
-    # short loop
-    xorl %ebx,%ebx
-_ConvertX86p16_32BGRA888.L1: movb (%esi),%bl             # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32BGRA888_LUT_X86(,%ebx,8),%eax  # eax = BGRA8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                     # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%edx# edx = BGRA8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p16_32BGRA888.L1
-_ConvertX86p16_32BGRA888.L2:
-    jmp _x86return
-
-_ConvertX86p16_32BGRA888.L3:  # save ebp
-    pushl %ebp
-
-    # save count
-    pushl %ecx
-
-    # unroll twice
-    movl %ecx,%ebp
-    shrl %ebp
-
-    # point arrays to end
-    leal (%esi,%ebp,4),%esi
-    leal (%edi,%ebp,8),%edi
-
-    # negative counter
-    negl %ebp
-
-    # clear
-    xorl %ebx,%ebx
-    xorl %ecx,%ecx
-
-    # prestep
-    movb (%esi,%ebp,4),%cl
-    movb 1(%esi,%ebp,4),%bl
-
-_ConvertX86p16_32BGRA888.L4: movl _ConvertX86p16_32BGRA888_LUT_X86(,%ecx,8),%edx
-        movb 2(%esi,%ebp,4),%cl
-
-        movl _ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%eax
-        movb 3(%esi,%ebp,4),%bl
-
-        addl %edx,%eax
-        movl _ConvertX86p16_32BGRA888_LUT_X86(,%ecx,8),%edx
-
-        movl %eax,(%edi,%ebp,8)
-        movl _ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%eax
-
-        addl %edx,%eax
-        movb 4(%esi,%ebp,4),%cl
-
-        movl %eax,4(%edi,%ebp,8)
-        movb 5(%esi,%ebp,4),%bl
-
-        incl %ebp
-        jnz _ConvertX86p16_32BGRA888.L4
-
-    # tail
-    popl %ecx
-    andl $1,%ecx
-    jz _ConvertX86p16_32BGRA888.L6
-    xorl %ebx,%ebx
-    movb (%esi),%bl                                      # ebx = lower byte pixel 1
-    movl _ConvertX86p16_32BGRA888_LUT_X86(,%ebx,8),%eax  # eax = BGRA8888 of lower byte pixel 1
-    movb 1(%esi),%bl                                     # ebx = upper byte pixel 1
-    movl _ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%edx# edx = BGRA8888 of upper byte pixel 1
-    addl %edx,%eax
-    movl %eax,(%edi)
-    addl $2,%esi
-    addl $4,%edi
-
-_ConvertX86p16_32BGRA888.L6: popl %ebp
-    jmp _x86return
-
-
-
-
-
-
-_ConvertX86p16_24RGB888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p16_24RGB888.L3
-
-
-    # short loop
-    xorl %edx,%edx
-_ConvertX86p16_24RGB888.L1: movb (%esi),%dl
-    movl _ConvertX86p16_32RGB888_LUT_X86(,%edx,8),%eax    # eax = ARGB8888 of lower byte
-    movb 1(%esi),%dl
-    movl _ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebx  # ebx = ARGB8888 of upper byte
-    addl %ebx,%eax                                        # eax = ARGB8888 pixel
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    shrl $16,%eax
-    movb %al,2(%edi)
-    addl $2,%esi
-    addl $3,%edi
-    decl %ecx
-    jnz _ConvertX86p16_24RGB888.L1
-_ConvertX86p16_24RGB888.L2: jmp _x86return
-
-
-_ConvertX86p16_24RGB888.L3:  # clear edx
-    xorl %edx,%edx
-
-_ConvertX86p16_24RGB888.L4:  # head
-    movl %edi,%eax
-    andl $0b11,%eax
-    jz _ConvertX86p16_24RGB888.L5
-    movb (%esi),%dl
-    movl _ConvertX86p16_32RGB888_LUT_X86(,%edx,8),%eax    # eax = ARGB8888 of lower byte
-    movb 1(%esi),%dl
-    movl _ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebx  # ebx = ARGB8888 of upper byte
-    addl %ebx,%eax                                        # eax = ARGB8888 pixel
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    shrl $16,%eax
-    movb %al,2(%edi)
-    addl $2,%esi
-    addl $3,%edi
-    decl %ecx
-    jmp _ConvertX86p16_24RGB888.L4
-
-_ConvertX86p16_24RGB888.L5:  # unroll 4 times
-    pushl %ebp
-    movl %ecx,%ebp
-    shrl $2,%ebp
-
-    # clear ebx
-    xorl %ebx,%ebx
-
-    # save count
-    pushl %ecx
-
-    # prestep
-    movb (%esi),%bl                                     # ebx = lower byte pixel 1
-    movb 1(%esi),%dl                                    # edx = upper byte pixel 1
-
-_ConvertX86p16_24RGB888.L6: movl _ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%eax # eax = ARGB8888 of lower byte pixel 1
-        movb 2(%esi),%bl                                    # ebx = lower byte pixel 2
-
-        movl _ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ecx    # ecx = ARGB8888 of upper byte pixel 1
-        movb 3(%esi),%dl                                    # edx = upper byte pixel 2
-
-        pushl %ebp                                          # save ebp
-        addl %ecx,%eax                                      # eax = ARGB8888 of pixel 1
-
-        movl _ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%ebp      # ebp = ARGB8888 of lower byte pixel 2
-        movl _ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ecx    # ecx = ARGB8888 of upper byte pixel 2
-
-        movb 4(%esi),%bl                                    # ebx = lower byte pixel 3
-        addl %ebp,%ecx                                      # ecx = ARGB8888 of pixel 2
-
-        shll $24,%ebp                                       # ebp = [b][0][0][0] of pixel 2
-        movb 5(%esi),%dl                                    # edx = upper byte pixel 3
-
-        shrl $8,%ecx                                        # ecx = [0][0][r][g] pixel 2
-        addl %ebp,%eax                                      # eax = [b2][r1][g1][b1] (done)
-
-        movl %eax,(%edi)                                    # store dword 1
-        movl _ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%eax    # eax = ARGB8888 of upper byte pixel 3
-
-        movl _ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%ebp      # ebp = ARGB8888 of lower byte pixel 3
-        movb 6(%esi),%bl                                    # ebx = lower byte pixel 4
-
-        addl %eax,%ebp                                      # ebp = ARGB8888 of pixel 3
-        movb 7(%esi),%dl                                    # edx = upper byte pixel 4
-
-        shll $16,%ebp                                       # ebp = [g][b][0][0] pixel 3
-
-        shrl $16,%eax                                       #  al = red component of pixel 3
-        addl %ecx,%ebp                                      # ebp = [g3][b3][r2][g2] (done)
-
-        movl %ebp,4(%edi)                                   # store dword 2
-        movl _ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%ecx      # ebx = ARGB8888 of lower byte pixel 4
-
-        movl _ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebp    # ebp = ARGB8888 of upper byte pixel 4
-        movb 4*2+0(%esi),%bl                                # ebx = lower byte pixel 1
-
-        addl %ebp,%ecx                                      # ecx = ARGB8888 of pixel 4
-        movb 4*2+1(%esi),%dl                                # edx = upper byte pixel 1
-
-        shll $8,%ecx                                        # ecx = [r][g][b][0]
-        popl %ebp                                           # restore ebp
-
-        movb %al,%cl                                        # ecx = [r4][g4][b4][r3] (done)
-        addl $4*2,%esi
-
-        movl %ecx,8(%edi)                                   # store dword 3
-        addl $3*4,%edi
-
-        decl %ebp
-        jz _ConvertX86p16_24RGB888.L7
-
-        jmp _ConvertX86p16_24RGB888.L6
-
-_ConvertX86p16_24RGB888.L7:  # check tail
-    popl %ecx
-    andl $0b11,%ecx
-    jz _ConvertX86p16_24RGB888.L9
-
-_ConvertX86p16_24RGB888.L8:  # tail
-    movb (%esi),%dl
-    movl _ConvertX86p16_32RGB888_LUT_X86(,%edx,8),%eax    # eax = ARGB8888 of lower byte
-    movb 1(%esi),%dl
-    movl _ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebx  # ebx = ARGB8888 of upper byte
-    addl %ebx,%eax                                    # eax = ARGB8888 pixel
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    shrl $16,%eax
-    movb %al,2(%edi)
-    addl $2,%esi
-    addl $3,%edi
-    decl %ecx
-    jnz _ConvertX86p16_24RGB888.L8
-
-_ConvertX86p16_24RGB888.L9: popl %ebp
-    jmp _x86return
-
-
-
-
-
-_ConvertX86p16_24BGR888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p16_24BGR888.L3
-
-
-    # short loop
-    xorl %edx,%edx
-_ConvertX86p16_24BGR888.L1: movb (%esi),%dl
-    movl _ConvertX86p16_32BGR888_LUT_X86(,%edx,8),%eax    # eax = ABGR8888 of lower byte
-    movb 1(%esi),%dl
-    movl _ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebx  # ebx = ABGR8888 of upper byte
-    addl %ebx,%eax                                    # eax = ABGR8888 pixel
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    shrl $16,%eax
-    movb %al,2(%edi)
-    addl $2,%esi
-    addl $3,%edi
-    decl %ecx
-    jnz _ConvertX86p16_24BGR888.L1
-_ConvertX86p16_24BGR888.L2:
-    jmp _x86return
-
-
-_ConvertX86p16_24BGR888.L3:  # clear edx
-    xorl %edx,%edx
-
-_ConvertX86p16_24BGR888.L4:  # head
-    movl %edi,%eax
-    andl $0b11,%eax
-    jz _ConvertX86p16_24BGR888.L5
-    movb (%esi),%dl
-    movl _ConvertX86p16_32BGR888_LUT_X86(,%edx,8),%eax    # eax = ABGR8888 of lower byte
-    movb 1(%esi),%dl
-    movl _ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebx  # ebx = ABGR8888 of upper byte
-    addl %ebx,%eax                                    # eax = ABGR8888 pixel
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    shrl $16,%eax
-    movb %al,2(%edi)
-    addl $2,%esi
-    addl $3,%edi
-    decl %ecx
-    jmp _ConvertX86p16_24BGR888.L4
-
-_ConvertX86p16_24BGR888.L5:  # unroll 4 times
-    pushl %ebp
-    movl %ecx,%ebp
-    shrl $2,%ebp
-
-    # clear ebx
-    xorl %ebx,%ebx
-
-    # save count
-    pushl %ecx
-
-    # prestep
-    movb (%esi),%bl                                     # ebx = lower byte pixel 1
-    movb 1(%esi),%dl                                    # edx = upper byte pixel 1
-
-_ConvertX86p16_24BGR888.L6: movl _ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax # eax = ABGR8888 of lower byte pixel 1
-        movb 2(%esi),%bl                                    # ebx = lower byte pixel 2
-
-        movl _ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ecx    # ecx = ABGR8888 of upper byte pixel 1
-        movb 3(%esi),%dl                                    # edx = upper byte pixel 2
-
-        pushl %ebp                                          # save ebp
-        addl %ecx,%eax                                      # eax = ABGR8888 of pixel 1
-
-        movl _ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%ecx      # ecx = ABGR8888 of lower byte pixel 2
-        movl _ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebp    # ebp = ABGR8888 of upper byte pixel 2
-
-        movb 4(%esi),%bl                                    # ebx = lower byte pixel 3
-        addl %ebp,%ecx                                      # ecx = ABGR8888 of pixel 2
-
-        shll $24,%ebp                                       # ebp = [r][0][0][0] of pixel 2
-        movb 5(%esi),%dl                                    # edx = upper byte pixel 3
-
-        shrl $8,%ecx                                        # ecx = [0][0][b][g] pixel 2
-        addl %ebp,%eax                                      # eax = [r2][b1][g1][r1] (done)
-
-        movl %eax,(%edi)                                    # store dword 1
-        movl _ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebp    # ebp = ABGR8888 of upper byte pixel 3
-
-        movl _ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax      # eax = ABGR8888 of lower byte pixel 3
-        movb 6(%esi),%bl                                    # ebx = lower byte pixel 4
-
-        addl %eax,%ebp                                      # ebp = ABGR8888 of pixel 3
-        movb 7(%esi),%dl                                    # edx = upper byte pixel 4
-
-        shll $16,%ebp                                       # ebp = [g][r][0][0] pixel 3
-
-        shrl $16,%eax                                       #  al = blue component of pixel 3
-        addl %ecx,%ebp                                      # ebp = [g3][r3][b2][g2] (done)
-
-        movl %ebp,4(%edi)                                   # store dword 2
-        movl _ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%ecx      # ebx = ABGR8888 of lower byte pixel 4
-
-        movl _ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebp    # ebp = ABGR8888 of upper byte pixel 4
-        movb 4*2+0(%esi),%bl                                # ebx = lower byte pixel 1
-
-        addl %ebp,%ecx                                      # ecx = ABGR8888 of pixel 4
-        movb 4*2+1(%esi),%dl                                # edx = upper byte pixel 1
-
-        shll $8,%ecx                                        # ecx = [b][g][r][0]
-        popl %ebp                                           # restore ebp
-
-        movb %al,%cl                                        # ecx = [b4][g4][r4][b3] (done)
-        addl $4*2,%esi
-
-        movl %ecx,8(%edi)                                   # store dword 3
-        addl $3*4,%edi
-
-        decl %ebp
-        jz _ConvertX86p16_24BGR888.L7
-
-        jmp _ConvertX86p16_24BGR888.L6
-
-_ConvertX86p16_24BGR888.L7:  # check tail
-    popl %ecx
-    andl $0b11,%ecx
-    jz _ConvertX86p16_24BGR888.L9
-
-_ConvertX86p16_24BGR888.L8:  # tail
-    movb (%esi),%dl
-    movl _ConvertX86p16_32BGR888_LUT_X86(,%edx,8),%eax    # eax = ABGR8888 of lower byte
-    movb 1(%esi),%dl
-    movl _ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebx  # ebx = ABGR8888 of upper byte
-    addl %ebx,%eax                                    # eax = ABGR8888 pixel
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    shrl $16,%eax
-    movb %al,2(%edi)
-    addl $2,%esi
-    addl $3,%edi
-    decl %ecx
-    jnz _ConvertX86p16_24BGR888.L8
-
-_ConvertX86p16_24BGR888.L9: popl %ebp
-    jmp _x86return
-
-
-
-
-_ConvertX86p16_16BGR565:
-
-    # check short
-    cmpl $16,%ecx
-    ja _ConvertX86p16_16BGR565.L3
-
-
-_ConvertX86p16_16BGR565.L1:  # short loop
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    shrl $11,%eax
-    andl $0b11111,%eax
-    andl $0b11111100000,%ebx
-    shll $11,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-    decl %ecx
-    jnz _ConvertX86p16_16BGR565.L1
-_ConvertX86p16_16BGR565.L2:
-    jmp _x86return
-
-_ConvertX86p16_16BGR565.L3:  # head
-    movl %edi,%eax
-    andl $0b11,%eax
-    jz _ConvertX86p16_16BGR565.L4
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    shrl $11,%eax
-    andl $0b11111,%eax
-    andl $0b11111100000,%ebx
-    shll $11,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-    decl %ecx
-
-_ConvertX86p16_16BGR565.L4:  # save count
-    pushl %ecx
-
-    # unroll twice
-    shrl %ecx
-
-    # point arrays to end
-    leal (%esi,%ecx,4),%esi
-    leal (%edi,%ecx,4),%edi
-
-    # negative counter
-    negl %ecx
-    jmp _ConvertX86p16_16BGR565.L6
-
-_ConvertX86p16_16BGR565.L5: movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p16_16BGR565.L6: movl (%esi,%ecx,4),%eax
-
-        movl (%esi,%ecx,4),%ebx
-        andl $0x07E007E0,%eax
-
-        movl (%esi,%ecx,4),%edx
-        andl $0x0F800F800,%ebx
-
-        shrl $11,%ebx
-        andl $0x001F001F,%edx
-
-        shll $11,%edx
-        addl %ebx,%eax
-
-        addl %edx,%eax
-        incl %ecx
-
-        jnz _ConvertX86p16_16BGR565.L5
-
-    movl %eax,-4(%edi,%ecx,4)
-
-    # tail
-    popl %ecx
-    andl $1,%ecx
-    jz _ConvertX86p16_16BGR565.L7
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    shrl $11,%eax
-    andl $0b11111,%eax
-    andl $0b11111100000,%ebx
-    shll $11,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-
-_ConvertX86p16_16BGR565.L7:
-    jmp _x86return
-
-
-
-
-
-
-_ConvertX86p16_16RGB555:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p16_16RGB555.L3
-
-
-_ConvertX86p16_16RGB555.L1:  # short loop
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    shrl %ebx
-    andl $0b0111111111100000,%ebx
-    andl $0b0000000000011111,%eax
-    addl %ebx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-    decl %ecx
-    jnz _ConvertX86p16_16RGB555.L1
-_ConvertX86p16_16RGB555.L2:
-    jmp _x86return
-
-_ConvertX86p16_16RGB555.L3:  # head
-    movl %edi,%eax
-    andl $0b11,%eax
-    jz _ConvertX86p16_16RGB555.L4
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    shrl %ebx
-    andl $0b0111111111100000,%ebx
-    andl $0b0000000000011111,%eax
-    addl %ebx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-    decl %ecx
-
-_ConvertX86p16_16RGB555.L4:  # save ebp
-    pushl %ebp
-
-    # save count
-    pushl %ecx
-
-    # unroll four times
-    shrl $2,%ecx
-
-    # point arrays to end
-    leal (%esi,%ecx,8),%esi
-    leal (%edi,%ecx,8),%edi
-
-    # negative counter
-    xorl %ebp,%ebp
-    subl %ecx,%ebp
-
-_ConvertX86p16_16RGB555.L5: movl (%esi,%ebp,8),%eax # agi?
-        movl 4(%esi,%ebp,8),%ecx
-
-        movl %eax,%ebx
-        movl %ecx,%edx
-
-        andl $0x0FFC0FFC0,%eax
-        andl $0x0FFC0FFC0,%ecx
-
-        shrl %eax
-        andl $0x001F001F,%ebx
-
-        shrl %ecx
-        andl $0x001F001F,%edx
-
-        addl %ebx,%eax
-        addl %edx,%ecx
-
-        movl %eax,(%edi,%ebp,8)
-        movl %ecx,4(%edi,%ebp,8)
-
-        incl %ebp
-        jnz _ConvertX86p16_16RGB555.L5
-
-    # tail
-    popl %ecx
-_ConvertX86p16_16RGB555.L6: andl $0b11,%ecx
-    jz _ConvertX86p16_16RGB555.L7
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    shrl %ebx
-    andl $0b0111111111100000,%ebx
-    andl $0b0000000000011111,%eax
-    addl %ebx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-    decl %ecx
-    jmp _ConvertX86p16_16RGB555.L6
-
-_ConvertX86p16_16RGB555.L7: popl %ebp
-    jmp _x86return
-
-
-
-
-
-
-_ConvertX86p16_16BGR555:
-
-    # check short
-    cmpl $16,%ecx
-    ja _ConvertX86p16_16BGR555.L3
-
-
-_ConvertX86p16_16BGR555.L1:  # short loop
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    shrl $11,%eax
-    andl $0b11111,%eax
-    shrl %ebx
-    andl $0b1111100000,%ebx
-    shll $10,%edx
-    andl $0b0111110000000000,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-    decl %ecx
-    jnz _ConvertX86p16_16BGR555.L1
-_ConvertX86p16_16BGR555.L2:
-    jmp _x86return
-
-_ConvertX86p16_16BGR555.L3:  # head
-    movl %edi,%eax
-    andl $0b11,%eax
-    jz _ConvertX86p16_16BGR555.L4
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    shrl $11,%eax
-    andl $0b11111,%eax
-    shrl %ebx
-    andl $0b1111100000,%ebx
-    shll $10,%edx
-    andl $0b0111110000000000,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-    decl %ecx
-
-_ConvertX86p16_16BGR555.L4:  # save count
-    pushl %ecx
-
-    # unroll twice
-    shrl %ecx
-
-    # point arrays to end
-    leal (%esi,%ecx,4),%esi
-    leal (%edi,%ecx,4),%edi
-
-    # negative counter
-    negl %ecx
-    jmp _ConvertX86p16_16BGR555.L6
-
-_ConvertX86p16_16BGR555.L5: movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p16_16BGR555.L6: movl (%esi,%ecx,4),%eax
-
-        shrl %eax
-        movl (%esi,%ecx,4),%ebx
-
-        andl $0x03E003E0,%eax
-        movl (%esi,%ecx,4),%edx
-
-        andl $0x0F800F800,%ebx
-
-        shrl $11,%ebx
-        andl $0x001F001F,%edx
-
-        shll $10,%edx
-        addl %ebx,%eax
-
-        addl %edx,%eax
-        incl %ecx
-
-        jnz _ConvertX86p16_16BGR555.L5
-
-    movl %eax,-4(%edi,%ecx,4)
-
-    # tail
-    popl %ecx
-    andl $1,%ecx
-    jz _ConvertX86p16_16BGR555.L7
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    shrl $11,%eax
-    andl $0b11111,%eax
-    shrl %ebx
-    andl $0b1111100000,%ebx
-    shll $10,%edx
-    andl $0b0111110000000000,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    movb %ah,1(%edi)
-    addl $2,%esi
-    addl $2,%edi
-
-_ConvertX86p16_16BGR555.L7:
-    jmp _x86return
-
-
-
-
-
-
-_ConvertX86p16_8RGB332:
-
-    # check short
-    cmpl $16,%ecx
-    ja _ConvertX86p16_8RGB332.L3
-
-
-_ConvertX86p16_8RGB332.L1:  # short loop
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    andl $0b11000,%eax          # blue
-    shrl $3,%eax
-    andl $0b11100000000,%ebx    # green
-    shrl $6,%ebx
-    andl $0b1110000000000000,%edx # red
-    shrl $8,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    addl $2,%esi
-    incl %edi
-    decl %ecx
-    jnz _ConvertX86p16_8RGB332.L1
-_ConvertX86p16_8RGB332.L2:
-    jmp _x86return
-
-_ConvertX86p16_8RGB332.L3: movl %edi,%eax
-    andl $0b11,%eax
-    jz _ConvertX86p16_8RGB332.L4
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    andl $0b11000,%eax          # blue
-    shrl $3,%eax
-    andl $0b11100000000,%ebx    # green
-    shrl $6,%ebx
-    andl $0b1110000000000000,%edx # red
-    shrl $8,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    addl $2,%esi
-    incl %edi
-    decl %ecx
-    jmp _ConvertX86p16_8RGB332.L3
-
-_ConvertX86p16_8RGB332.L4:  # save ebp
-    pushl %ebp
-
-    # save count
-    pushl %ecx
-
-    # unroll 4 times
-    shrl $2,%ecx
-
-    # prestep
-    movb (%esi),%dl
-    movb 1(%esi),%bl
-    movb 2(%esi),%dh
-
-_ConvertX86p16_8RGB332.L5: shll $16,%edx
-        movb 3(%esi),%bh
-
-        shll $16,%ebx
-        movb 4(%esi),%dl
-
-        movb 6(%esi),%dh
-        movb 5(%esi),%bl
-
-        andl $0b00011000000110000001100000011000,%edx
-        movb 7(%esi),%bh
-
-        rorl $16+3,%edx
-        movl %ebx,%eax                                  # setup eax for reds
-
-        andl $0b00000111000001110000011100000111,%ebx
-        andl $0b11100000111000001110000011100000,%eax   # reds
-
-        rorl $16-2,%ebx
-        addl $8,%esi
-
-        rorl $16,%eax
-        addl $4,%edi
-
-        addl %ebx,%eax
-        movb 1(%esi),%bl                                # greens
-
-        addl %edx,%eax
-        movb (%esi),%dl                                 # blues
-
-        movl %eax,-4(%edi)
-        movb 2(%esi),%dh
-
-        decl %ecx
-        jnz _ConvertX86p16_8RGB332.L5
-
-    # check tail
-    popl %ecx
-    andl $0b11,%ecx
-    jz _ConvertX86p16_8RGB332.L7
-
-_ConvertX86p16_8RGB332.L6:  # tail
-    movb (%esi),%al
-    movb 1(%esi),%ah
-    movl %eax,%ebx
-    movl %eax,%edx
-    andl $0b11000,%eax          # blue
-    shrl $3,%eax
-    andl $0b11100000000,%ebx    # green
-    shrl $6,%ebx
-    andl $0b1110000000000000,%edx # red
-    shrl $8,%edx
-    addl %ebx,%eax
-    addl %edx,%eax
-    movb %al,(%edi)
-    addl $2,%esi
-    incl %edi
-    decl %ecx
-    jnz _ConvertX86p16_8RGB332.L6
-
-_ConvertX86p16_8RGB332.L7: popl %ebp
-    jmp _x86return
-

+ 1143 - 0
packages/hermes/src/i386/x86p_16.inc

@@ -0,0 +1,1143 @@
+{
+    x86 format converters for HERMES
+    Copyright (c) 1998 Glenn Fielder ([email protected])
+    Routines adjusted for Hermes by Christian Nentwich ([email protected])
+    Used with permission.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+
+procedure ConvertX86p16_32RGB888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+
+    // short loop
+    xorl %ebx,%ebx
+.L1: movb (%esi),%bl              // ebx = lower byte pixel 1
+    movl ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%eax   // eax = ARGB8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                     // ebx = upper byte pixel 1
+    movl ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%edx // edx = ARGB8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+
+.L3:  // save ebp
+    pushl %ebp
+
+    // save count
+    pushl %ecx
+
+    // unroll twice
+    movl %ecx,%ebp
+    shrl $1,%ebp
+
+    // point arrays to end
+    leal (%esi,%ebp,4),%esi
+    leal (%edi,%ebp,8),%edi
+
+    // negative counter
+    negl %ebp
+
+    // clear
+    xorl %ebx,%ebx
+    xorl %ecx,%ecx
+
+    // prestep
+    movb (%esi,%ebp,4),%cl
+    movb 1(%esi,%ebp,4),%bl
+
+.L4:    movl ConvertX86p16_32RGB888_LUT_X86(,%ecx,8),%edx
+        movb 2(%esi,%ebp,4),%cl
+
+        movl ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%eax
+        movb 3(%esi,%ebp,4),%bl
+
+        addl %edx,%eax
+        movl ConvertX86p16_32RGB888_LUT_X86(,%ecx,8),%edx
+
+        movl %eax,(%edi,%ebp,8)
+        movl ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%eax
+
+        addl %edx,%eax
+        movb 4(%esi,%ebp,4),%cl
+
+        movl %eax,4(%edi,%ebp,8)
+        movb 5(%esi,%ebp,4),%bl
+
+        incl %ebp
+        jnz .L4
+
+    // tail
+    popl %ecx
+    andl $1,%ecx
+    jz .L6
+    xorl %ebx,%ebx
+    movb (%esi),%bl                                      // ebx = lower byte pixel 1
+    movl ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%eax   // eax = ARGB8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                     // ebx = upper byte pixel 1
+    movl ConvertX86p16_32RGB888_LUT_X86+4(,%ebx,8),%edx // edx = ARGB8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+
+.L6: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+
+
+procedure ConvertX86p16_32BGR888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+
+    // short loop
+    xorl %ebx,%ebx
+.L1: movb (%esi),%bl                                     // ebx = lower byte pixel 1
+    movl ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax    // eax = ABGR8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                     // ebx = upper byte pixel 1
+    movl ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%edx  // edx = ABGR8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // save ebp
+    pushl %ebp
+
+    // save count
+    pushl %ecx
+
+    // unroll twice
+    movl %ecx,%ebp
+    shrl $1,%ebp
+
+    // point arrays to end
+    leal (%esi,%ebp,4),%esi
+    leal (%edi,%ebp,8),%edi
+
+    // negative counter
+    negl %ebp
+
+    // clear
+    xorl %ebx,%ebx
+    xorl %ecx,%ecx
+
+    // prestep
+    movb (%esi,%ebp,4),%cl
+    movb 1(%esi,%ebp,4),%bl
+
+.L4:    movl ConvertX86p16_32BGR888_LUT_X86(,%ecx,8),%edx
+        movb 2(%esi,%ebp,4),%cl
+
+        movl ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%eax
+        movb 3(%esi,%ebp,4),%bl
+
+        addl %edx,%eax
+        movl ConvertX86p16_32BGR888_LUT_X86(,%ecx,8),%edx
+
+        movl %eax,(%edi,%ebp,8)
+        movl ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%eax
+
+        addl %edx,%eax
+        movb 4(%esi,%ebp,4),%cl
+
+        movl %eax,4(%edi,%ebp,8)
+        movb 5(%esi,%ebp,4),%bl
+
+        incl %ebp
+        jnz .L4
+
+    // tail
+    popl %ecx
+    andl $1,%ecx
+    jz .L6
+    xorl %ebx,%ebx
+    movb (%esi),%bl                                      // ebx = lower byte pixel 1
+    movl ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax    // eax = ABGR8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                     // ebx = upper byte pixel 1
+    movl ConvertX86p16_32BGR888_LUT_X86+4(,%ebx,8),%edx  // edx = ABGR8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+
+.L6: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+procedure ConvertX86p16_32RGBA888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+
+    // short loop
+    xorl %ebx,%ebx
+.L1: movb (%esi),%bl                                      // ebx = lower byte pixel 1
+    movl ConvertX86p16_32RGBA888_LUT_X86(,%ebx,8),%eax   // eax = RGBA8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                      // ebx = upper byte pixel 1
+    movl ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%edx // edx = RGBA8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // save ebp
+    pushl %ebp
+
+    // save count
+    pushl %ecx
+
+    // unroll twice
+    movl %ecx,%ebp
+    shrl $1,%ebp
+
+    // point arrays to end
+    leal (%esi,%ebp,4),%esi
+    leal (%edi,%ebp,8),%edi
+
+    // negative counter
+    negl %ebp
+
+    // clear
+    xorl %ebx,%ebx
+    xorl %ecx,%ecx
+
+    // prestep
+    movb (%esi,%ebp,4),%cl
+    movb 1(%esi,%ebp,4),%bl
+
+.L4:    movl ConvertX86p16_32RGBA888_LUT_X86(,%ecx,8),%edx
+        movb 2(%esi,%ebp,4),%cl
+
+        movl ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%eax
+        movb 3(%esi,%ebp,4),%bl
+
+        addl %edx,%eax
+        movl ConvertX86p16_32RGBA888_LUT_X86(,%ecx,8),%edx
+
+        movl %eax,(%edi,%ebp,8)
+        movl ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%eax
+
+        addl %edx,%eax
+        movb 4(%esi,%ebp,4),%cl
+
+        movl %eax,4(%edi,%ebp,8)
+        movb 5(%esi,%ebp,4),%bl
+
+        incl %ebp
+        jnz .L4
+
+    // tail
+    popl %ecx
+    andl $1,%ecx
+    jz .L6
+    xorl %ebx,%ebx
+    movb (%esi),%bl                                       // ebx = lower byte pixel 1
+    movl ConvertX86p16_32RGBA888_LUT_X86(,%ebx,8),%eax   // eax = RGBA8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                      // ebx = upper byte pixel 1
+    movl ConvertX86p16_32RGBA888_LUT_X86+4(,%ebx,8),%edx // edx = RGBA8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+
+.L6: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+
+procedure ConvertX86p16_32BGRA888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+    // short loop
+    xorl %ebx,%ebx
+.L1: movb (%esi),%bl                                      // ebx = lower byte pixel 1
+    movl ConvertX86p16_32BGRA888_LUT_X86(,%ebx,8),%eax    // eax = BGRA8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                      // ebx = upper byte pixel 1
+    movl ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%edx  // edx = BGRA8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // save ebp
+    pushl %ebp
+
+    // save count
+    pushl %ecx
+
+    // unroll twice
+    movl %ecx,%ebp
+    shrl $1,%ebp
+
+    // point arrays to end
+    leal (%esi,%ebp,4),%esi
+    leal (%edi,%ebp,8),%edi
+
+    // negative counter
+    negl %ebp
+
+    // clear
+    xorl %ebx,%ebx
+    xorl %ecx,%ecx
+
+    // prestep
+    movb (%esi,%ebp,4),%cl
+    movb 1(%esi,%ebp,4),%bl
+
+.L4:    movl ConvertX86p16_32BGRA888_LUT_X86(,%ecx,8),%edx
+        movb 2(%esi,%ebp,4),%cl
+
+        movl ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%eax
+        movb 3(%esi,%ebp,4),%bl
+
+        addl %edx,%eax
+        movl ConvertX86p16_32BGRA888_LUT_X86(,%ecx,8),%edx
+
+        movl %eax,(%edi,%ebp,8)
+        movl ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%eax
+
+        addl %edx,%eax
+        movb 4(%esi,%ebp,4),%cl
+
+        movl %eax,4(%edi,%ebp,8)
+        movb 5(%esi,%ebp,4),%bl
+
+        incl %ebp
+        jnz .L4
+
+    // tail
+    popl %ecx
+    andl $1,%ecx
+    jz .L6
+    xorl %ebx,%ebx
+    movb (%esi),%bl                                       // ebx = lower byte pixel 1
+    movl ConvertX86p16_32BGRA888_LUT_X86(,%ebx,8),%eax   // eax = BGRA8888 of lower byte pixel 1
+    movb 1(%esi),%bl                                      // ebx = upper byte pixel 1
+    movl ConvertX86p16_32BGRA888_LUT_X86+4(,%ebx,8),%edx // edx = BGRA8888 of upper byte pixel 1
+    addl %edx,%eax
+    movl %eax,(%edi)
+    addl $2,%esi
+    addl $4,%edi
+
+.L6: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+
+procedure ConvertX86p16_24RGB888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+
+    // short loop
+    xorl %edx,%edx
+.L1: movb (%esi),%dl
+    movl ConvertX86p16_32RGB888_LUT_X86(,%edx,8),%eax     // eax = ARGB8888 of lower byte
+    movb 1(%esi),%dl
+    movl ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebx   // ebx = ARGB8888 of upper byte
+    addl %ebx,%eax                                        // eax = ARGB8888 pixel
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    shrl $16,%eax
+    movb %al,2(%edi)
+    addl $2,%esi
+    addl $3,%edi
+    decl %ecx
+    jnz .L1
+.L2: jmp _X86RETURN
+
+
+.L3:  // clear edx
+    xorl %edx,%edx
+
+.L4:  // head
+    movl %edi,%eax
+    andl $0b11,%eax
+    jz .L5
+    movb (%esi),%dl
+    movl ConvertX86p16_32RGB888_LUT_X86(,%edx,8),%eax     // eax = ARGB8888 of lower byte
+    movb 1(%esi),%dl
+    movl ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebx   // ebx = ARGB8888 of upper byte
+    addl %ebx,%eax                                        // eax = ARGB8888 pixel
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    shrl $16,%eax
+    movb %al,2(%edi)
+    addl $2,%esi
+    addl $3,%edi
+    decl %ecx
+    jmp .L4
+
+.L5:  // unroll 4 times
+    pushl %ebp
+    movl %ecx,%ebp
+    shrl $2,%ebp
+
+    // clear ebx
+    xorl %ebx,%ebx
+
+    // save count
+    pushl %ecx
+
+    // prestep
+    movb (%esi),%bl                                     // ebx = lower byte pixel 1
+    movb 1(%esi),%dl                                    // edx = upper byte pixel 1
+
+.L6:    movl ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%eax   // eax = ARGB8888 of lower byte pixel 1
+        movb 2(%esi),%bl                                    // ebx = lower byte pixel 2
+
+        movl ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ecx    // ecx = ARGB8888 of upper byte pixel 1
+        movb 3(%esi),%dl                                    // edx = upper byte pixel 2
+
+        pushl %ebp                                          // save ebp
+        addl %ecx,%eax                                      // eax = ARGB8888 of pixel 1
+
+        movl ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%ebp      // ebp = ARGB8888 of lower byte pixel 2
+        movl ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ecx    // ecx = ARGB8888 of upper byte pixel 2
+
+        movb 4(%esi),%bl                                    // ebx = lower byte pixel 3
+        addl %ebp,%ecx                                      // ecx = ARGB8888 of pixel 2
+
+        shll $24,%ebp                                       // ebp = [b][0][0][0] of pixel 2
+        movb 5(%esi),%dl                                    // edx = upper byte pixel 3
+
+        shrl $8,%ecx                                        // ecx = [0][0][r][g] pixel 2
+        addl %ebp,%eax                                      // eax = [b2][r1][g1][b1] (done)
+
+        movl %eax,(%edi)                                    // store dword 1
+        movl ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%eax    // eax = ARGB8888 of upper byte pixel 3
+
+        movl ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%ebp      // ebp = ARGB8888 of lower byte pixel 3
+        movb 6(%esi),%bl                                    // ebx = lower byte pixel 4
+
+        addl %eax,%ebp                                      // ebp = ARGB8888 of pixel 3
+        movb 7(%esi),%dl                                    // edx = upper byte pixel 4
+
+        shll $16,%ebp                                       // ebp = [g][b][0][0] pixel 3
+
+        shrl $16,%eax                                       //  al = red component of pixel 3
+        addl %ecx,%ebp                                      // ebp = [g3][b3][r2][g2] (done)
+
+        movl %ebp,4(%edi)                                   // store dword 2
+        movl ConvertX86p16_32RGB888_LUT_X86(,%ebx,8),%ecx      // ebx = ARGB8888 of lower byte pixel 4
+
+        movl ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebp    // ebp = ARGB8888 of upper byte pixel 4
+        movb 4*2+0(%esi),%bl                                // ebx = lower byte pixel 1
+
+        addl %ebp,%ecx                                      // ecx = ARGB8888 of pixel 4
+        movb 4*2+1(%esi),%dl                                // edx = upper byte pixel 1
+
+        shll $8,%ecx                                        // ecx = [r][g][b][0]
+        popl %ebp                                           // restore ebp
+
+        movb %al,%cl                                        // ecx = [r4][g4][b4][r3] (done)
+        addl $4*2,%esi
+
+        movl %ecx,8(%edi)                                   // store dword 3
+        addl $3*4,%edi
+
+        decl %ebp
+        jz .L7
+
+        jmp .L6
+
+.L7:  // check tail
+    popl %ecx
+    andl $0b11,%ecx
+    jz .L9
+
+.L8:  // tail
+    movb (%esi),%dl
+    movl ConvertX86p16_32RGB888_LUT_X86(,%edx,8),%eax    // eax = ARGB8888 of lower byte
+    movb 1(%esi),%dl
+    movl ConvertX86p16_32RGB888_LUT_X86+4(,%edx,8),%ebx  // ebx = ARGB8888 of upper byte
+    addl %ebx,%eax                                    // eax = ARGB8888 pixel
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    shrl $16,%eax
+    movb %al,2(%edi)
+    addl $2,%esi
+    addl $3,%edi
+    decl %ecx
+    jnz .L8
+
+.L9: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+
+procedure ConvertX86p16_24BGR888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+
+    // short loop
+    xorl %edx,%edx
+.L1: movb (%esi),%dl
+    movl ConvertX86p16_32BGR888_LUT_X86(,%edx,8),%eax    // eax = ABGR8888 of lower byte
+    movb 1(%esi),%dl
+    movl ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebx  // ebx = ABGR8888 of upper byte
+    addl %ebx,%eax                                    // eax = ABGR8888 pixel
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    shrl $16,%eax
+    movb %al,2(%edi)
+    addl $2,%esi
+    addl $3,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+
+.L3:  // clear edx
+    xorl %edx,%edx
+
+.L4:  // head
+    movl %edi,%eax
+    andl $0b11,%eax
+    jz .L5
+    movb (%esi),%dl
+    movl ConvertX86p16_32BGR888_LUT_X86(,%edx,8),%eax    // eax = ABGR8888 of lower byte
+    movb 1(%esi),%dl
+    movl ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebx  // ebx = ABGR8888 of upper byte
+    addl %ebx,%eax                                    // eax = ABGR8888 pixel
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    shrl $16,%eax
+    movb %al,2(%edi)
+    addl $2,%esi
+    addl $3,%edi
+    decl %ecx
+    jmp .L4
+
+.L5:  // unroll 4 times
+    pushl %ebp
+    movl %ecx,%ebp
+    shrl $2,%ebp
+
+    // clear ebx
+    xorl %ebx,%ebx
+
+    // save count
+    pushl %ecx
+
+    // prestep
+    movb (%esi),%bl                                     // ebx = lower byte pixel 1
+    movb 1(%esi),%dl                                    // edx = upper byte pixel 1
+
+.L6:    movl ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax // eax = ABGR8888 of lower byte pixel 1
+        movb 2(%esi),%bl                                    // ebx = lower byte pixel 2
+
+        movl ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ecx    // ecx = ABGR8888 of upper byte pixel 1
+        movb 3(%esi),%dl                                    // edx = upper byte pixel 2
+
+        pushl %ebp                                          // save ebp
+        addl %ecx,%eax                                      // eax = ABGR8888 of pixel 1
+
+        movl ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%ecx      // ecx = ABGR8888 of lower byte pixel 2
+        movl ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebp    // ebp = ABGR8888 of upper byte pixel 2
+
+        movb 4(%esi),%bl                                    // ebx = lower byte pixel 3
+        addl %ebp,%ecx                                      // ecx = ABGR8888 of pixel 2
+
+        shll $24,%ebp                                       // ebp = [r][0][0][0] of pixel 2
+        movb 5(%esi),%dl                                    // edx = upper byte pixel 3
+
+        shrl $8,%ecx                                        // ecx = [0][0][b][g] pixel 2
+        addl %ebp,%eax                                      // eax = [r2][b1][g1][r1] (done)
+
+        movl %eax,(%edi)                                    // store dword 1
+        movl ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebp    // ebp = ABGR8888 of upper byte pixel 3
+
+        movl ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%eax      // eax = ABGR8888 of lower byte pixel 3
+        movb 6(%esi),%bl                                    // ebx = lower byte pixel 4
+
+        addl %eax,%ebp                                      // ebp = ABGR8888 of pixel 3
+        movb 7(%esi),%dl                                    // edx = upper byte pixel 4
+
+        shll $16,%ebp                                       // ebp = [g][r][0][0] pixel 3
+
+        shrl $16,%eax                                       //  al = blue component of pixel 3
+        addl %ecx,%ebp                                      // ebp = [g3][r3][b2][g2] (done)
+
+        movl %ebp,4(%edi)                                   // store dword 2
+        movl ConvertX86p16_32BGR888_LUT_X86(,%ebx,8),%ecx      // ebx = ABGR8888 of lower byte pixel 4
+
+        movl ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebp    // ebp = ABGR8888 of upper byte pixel 4
+        movb 4*2+0(%esi),%bl                                // ebx = lower byte pixel 1
+
+        addl %ebp,%ecx                                      // ecx = ABGR8888 of pixel 4
+        movb 4*2+1(%esi),%dl                                // edx = upper byte pixel 1
+
+        shll $8,%ecx                                        // ecx = [b][g][r][0]
+        popl %ebp                                           // restore ebp
+
+        movb %al,%cl                                        // ecx = [b4][g4][r4][b3] (done)
+        addl $4*2,%esi
+
+        movl %ecx,8(%edi)                                   // store dword 3
+        addl $3*4,%edi
+
+        decl %ebp
+        jz .L7
+
+        jmp .L6
+
+.L7:  // check tail
+    popl %ecx
+    andl $0b11,%ecx
+    jz .L9
+
+.L8:  // tail
+    movb (%esi),%dl
+    movl ConvertX86p16_32BGR888_LUT_X86(,%edx,8),%eax    // eax = ABGR8888 of lower byte
+    movb 1(%esi),%dl
+    movl ConvertX86p16_32BGR888_LUT_X86+4(,%edx,8),%ebx  // ebx = ABGR8888 of upper byte
+    addl %ebx,%eax                                    // eax = ABGR8888 pixel
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    shrl $16,%eax
+    movb %al,2(%edi)
+    addl $2,%esi
+    addl $3,%edi
+    decl %ecx
+    jnz .L8
+
+.L9: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+procedure ConvertX86p16_16BGR565(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $16,%ecx
+    ja .L3
+
+
+.L1:  // short loop
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    shrl $11,%eax
+    andl $0b11111,%eax
+    andl $0b11111100000,%ebx
+    shll $11,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // head
+    movl %edi,%eax
+    andl $0b11,%eax
+    jz .L4
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    shrl $11,%eax
+    andl $0b11111,%eax
+    andl $0b11111100000,%ebx
+    shll $11,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+    decl %ecx
+
+.L4:  // save count
+    pushl %ecx
+
+    // unroll twice
+    shrl $1,%ecx
+
+    // point arrays to end
+    leal (%esi,%ecx,4),%esi
+    leal (%edi,%ecx,4),%edi
+
+    // negative counter
+    negl %ecx
+    jmp .L6
+
+.L5:    movl %eax,-4(%edi,%ecx,4)
+.L6:    movl (%esi,%ecx,4),%eax
+
+        movl (%esi,%ecx,4),%ebx
+        andl $0x07E007E0,%eax
+
+        movl (%esi,%ecx,4),%edx
+        andl $0x0F800F800,%ebx
+
+        shrl $11,%ebx
+        andl $0x001F001F,%edx
+
+        shll $11,%edx
+        addl %ebx,%eax
+
+        addl %edx,%eax
+        incl %ecx
+
+        jnz .L5
+
+    movl %eax,-4(%edi,%ecx,4)
+
+    // tail
+    popl %ecx
+    andl $1,%ecx
+    jz .L7
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    shrl $11,%eax
+    andl $0b11111,%eax
+    andl $0b11111100000,%ebx
+    shll $11,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+
+.L7:
+    jmp _X86RETURN
+end;
+
+
+
+
+procedure ConvertX86p16_16RGB555(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+
+.L1:  // short loop
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    shrl $1,%ebx
+    andl $0b0111111111100000,%ebx
+    andl $0b0000000000011111,%eax
+    addl %ebx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // head
+    movl %edi,%eax
+    andl $0b11,%eax
+    jz .L4
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    shrl $1,%ebx
+    andl $0b0111111111100000,%ebx
+    andl $0b0000000000011111,%eax
+    addl %ebx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+    decl %ecx
+
+.L4:  // save ebp
+    pushl %ebp
+
+    // save count
+    pushl %ecx
+
+    // unroll four times
+    shrl $2,%ecx
+
+    // point arrays to end
+    leal (%esi,%ecx,8),%esi
+    leal (%edi,%ecx,8),%edi
+
+    // negative counter
+    xorl %ebp,%ebp
+    subl %ecx,%ebp
+
+.L5:    movl (%esi,%ebp,8),%eax // agi?
+        movl 4(%esi,%ebp,8),%ecx
+
+        movl %eax,%ebx
+        movl %ecx,%edx
+
+        andl $0x0FFC0FFC0,%eax
+        andl $0x0FFC0FFC0,%ecx
+
+        shrl $1,%eax
+        andl $0x001F001F,%ebx
+
+        shrl $1,%ecx
+        andl $0x001F001F,%edx
+
+        addl %ebx,%eax
+        addl %edx,%ecx
+
+        movl %eax,(%edi,%ebp,8)
+        movl %ecx,4(%edi,%ebp,8)
+
+        incl %ebp
+        jnz .L5
+
+    // tail
+    popl %ecx
+.L6: andl $0b11,%ecx
+    jz .L7
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    shrl $1,%ebx
+    andl $0b0111111111100000,%ebx
+    andl $0b0000000000011111,%eax
+    addl %ebx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+    decl %ecx
+    jmp .L6
+
+.L7: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+
+
+procedure ConvertX86p16_16BGR555(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $16,%ecx
+    ja .L3
+
+
+.L1:  // short loop
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    shrl $11,%eax
+    andl $0b11111,%eax
+    shrl $1,%ebx
+    andl $0b1111100000,%ebx
+    shll $10,%edx
+    andl $0b0111110000000000,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // head
+    movl %edi,%eax
+    andl $0b11,%eax
+    jz .L4
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    shrl $11,%eax
+    andl $0b11111,%eax
+    shrl $1,%ebx
+    andl $0b1111100000,%ebx
+    shll $10,%edx
+    andl $0b0111110000000000,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+    decl %ecx
+
+.L4:  // save count
+    pushl %ecx
+
+    // unroll twice
+    shrl $1,%ecx
+
+    // point arrays to end
+    leal (%esi,%ecx,4),%esi
+    leal (%edi,%ecx,4),%edi
+
+    // negative counter
+    negl %ecx
+    jmp .L6
+
+.L5:    movl %eax,-4(%edi,%ecx,4)
+.L6:    movl (%esi,%ecx,4),%eax
+
+        shrl $1,%eax
+        movl (%esi,%ecx,4),%ebx
+
+        andl $0x03E003E0,%eax
+        movl (%esi,%ecx,4),%edx
+
+        andl $0x0F800F800,%ebx
+
+        shrl $11,%ebx
+        andl $0x001F001F,%edx
+
+        shll $10,%edx
+        addl %ebx,%eax
+
+        addl %edx,%eax
+        incl %ecx
+
+        jnz .L5
+
+    movl %eax,-4(%edi,%ecx,4)
+
+    // tail
+    popl %ecx
+    andl $1,%ecx
+    jz .L7
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    shrl $11,%eax
+    andl $0b11111,%eax
+    shrl $1,%ebx
+    andl $0b1111100000,%ebx
+    shll $10,%edx
+    andl $0b0111110000000000,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    movb %ah,1(%edi)
+    addl $2,%esi
+    addl $2,%edi
+
+.L7:
+    jmp _X86RETURN
+end;
+
+
+
+
+
+procedure ConvertX86p16_8RGB332(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $16,%ecx
+    ja .L3
+
+
+.L1:  // short loop
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    andl $0b11000,%eax          // blue
+    shrl $3,%eax
+    andl $0b11100000000,%ebx    // green
+    shrl $6,%ebx
+    andl $0b1110000000000000,%edx // red
+    shrl $8,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    addl $2,%esi
+    incl %edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3: movl %edi,%eax
+    andl $0b11,%eax
+    jz .L4
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    andl $0b11000,%eax          // blue
+    shrl $3,%eax
+    andl $0b11100000000,%ebx    // green
+    shrl $6,%ebx
+    andl $0b1110000000000000,%edx // red
+    shrl $8,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    addl $2,%esi
+    incl %edi
+    decl %ecx
+    jmp .L3
+
+.L4:  // save ebp
+    pushl %ebp
+
+    // save count
+    pushl %ecx
+
+    // unroll 4 times
+    shrl $2,%ecx
+
+    // prestep
+    movb (%esi),%dl
+    movb 1(%esi),%bl
+    movb 2(%esi),%dh
+
+.L5: shll $16,%edx
+        movb 3(%esi),%bh
+
+        shll $16,%ebx
+        movb 4(%esi),%dl
+
+        movb 6(%esi),%dh
+        movb 5(%esi),%bl
+
+        andl $0b00011000000110000001100000011000,%edx
+        movb 7(%esi),%bh
+
+        rorl $16+3,%edx
+        movl %ebx,%eax                                  // setup eax for reds
+
+        andl $0b00000111000001110000011100000111,%ebx
+        andl $0b11100000111000001110000011100000,%eax   // reds
+
+        rorl $16-2,%ebx
+        addl $8,%esi
+
+        rorl $16,%eax
+        addl $4,%edi
+
+        addl %ebx,%eax
+        movb 1(%esi),%bl                                // greens
+
+        addl %edx,%eax
+        movb (%esi),%dl                                 // blues
+
+        movl %eax,-4(%edi)
+        movb 2(%esi),%dh
+
+        decl %ecx
+        jnz .L5
+
+    // check tail
+    popl %ecx
+    andl $0b11,%ecx
+    jz .L7
+
+.L6:  // tail
+    movb (%esi),%al
+    movb 1(%esi),%ah
+    movl %eax,%ebx
+    movl %eax,%edx
+    andl $0b11000,%eax          // blue
+    shrl $3,%eax
+    andl $0b11100000000,%ebx    // green
+    shrl $6,%ebx
+    andl $0b1110000000000000,%edx // red
+    shrl $8,%edx
+    addl %ebx,%eax
+    addl %edx,%eax
+    movb %al,(%edi)
+    addl $2,%esi
+    incl %edi
+    decl %ecx
+    jnz .L6
+
+.L7: popl %ebp
+    jmp _X86RETURN
+end;

+ 0 - 1043
packages/hermes/src/i386/x86p_32.as

@@ -1,1043 +0,0 @@
-#
-# x86 format converters for HERMES
-# Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-# Most routines are (c) Glenn Fiedler ([email protected]), used with permission
-#
-
-
-
-.globl _ConvertX86p32_32BGR888
-.globl _ConvertX86p32_32RGBA888
-.globl _ConvertX86p32_32BGRA888
-.globl _ConvertX86p32_24RGB888
-.globl _ConvertX86p32_24BGR888
-.globl _ConvertX86p32_16RGB565
-.globl _ConvertX86p32_16BGR565
-.globl _ConvertX86p32_16RGB555
-.globl _ConvertX86p32_16BGR555
-.globl _ConvertX86p32_8RGB332
-
-.extern _x86return
-
-.text
-
-
-## _Convert_*
-## Paramters:
-##   ESI = source
-##   EDI = dest
-##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
-## Destroys:
-##   EAX, EBX, EDX
-
-
-_ConvertX86p32_32BGR888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p32_32BGR888.L3
-
-_ConvertX86p32_32BGR888.L1:  # short loop
-    movl (%esi),%edx
-    bswapl %edx
-    rorl $8,%edx
-    movl %edx,(%edi)
-    addl $4,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p32_32BGR888.L1
-_ConvertX86p32_32BGR888.L2:
-    jmp _x86return
-
-_ConvertX86p32_32BGR888.L3:  # save ebp
-    pushl %ebp
-
-    # unroll four times
-    movl %ecx,%ebp
-    shrl $2,%ebp
-
-    # save count
-    pushl %ecx
-
-_ConvertX86p32_32BGR888.L4: movl (%esi),%eax
-        movl 4(%esi),%ebx
-
-        bswapl %eax
-
-        bswapl %ebx
-
-        rorl $8,%eax
-        movl 8(%esi),%ecx
-
-        rorl $8,%ebx
-        movl 12(%esi),%edx
-
-        bswapl %ecx
-
-        bswapl %edx
-
-        rorl $8,%ecx
-        movl %eax,(%edi)
-
-        rorl $8,%edx
-        movl %ebx,4(%edi)
-
-        movl %ecx,8(%edi)
-        movl %edx,12(%edi)
-
-        addl $16,%esi
-        addl $16,%edi
-
-        decl %ebp
-        jnz _ConvertX86p32_32BGR888.L4
-
-    # check tail
-    popl %ecx
-    andl $0b11,%ecx
-    jz _ConvertX86p32_32BGR888.L6
-
-_ConvertX86p32_32BGR888.L5:  # tail loop
-    movl (%esi),%edx
-    bswapl %edx
-    rorl $8,%edx
-    movl %edx,(%edi)
-    addl $4,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p32_32BGR888.L5
-
-_ConvertX86p32_32BGR888.L6: popl %ebp
-    jmp _x86return
-
-
-
-
-_ConvertX86p32_32RGBA888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p32_32RGBA888.L3
-
-_ConvertX86p32_32RGBA888.L1:  # short loop
-    movl (%esi),%edx
-    roll $8,%edx
-    movl %edx,(%edi)
-    addl $4,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p32_32RGBA888.L1
-_ConvertX86p32_32RGBA888.L2:
-    jmp _x86return
-
-_ConvertX86p32_32RGBA888.L3:  # save ebp
-    pushl %ebp
-
-    # unroll four times
-    movl %ecx,%ebp
-    shrl $2,%ebp
-
-    # save count
-    pushl %ecx
-
-_ConvertX86p32_32RGBA888.L4: movl (%esi),%eax
-        movl 4(%esi),%ebx
-
-        roll $8,%eax
-        movl 8(%esi),%ecx
-
-        roll $8,%ebx
-        movl 12(%esi),%edx
-
-        roll $8,%ecx
-        movl %eax,(%edi)
-
-        roll $8,%edx
-        movl %ebx,4(%edi)
-
-        movl %ecx,8(%edi)
-        movl %edx,12(%edi)
-
-        addl $16,%esi
-        addl $16,%edi
-
-        decl %ebp
-        jnz _ConvertX86p32_32RGBA888.L4
-
-    # check tail
-    popl %ecx
-    andl $0b11,%ecx
-    jz _ConvertX86p32_32RGBA888.L6
-
-_ConvertX86p32_32RGBA888.L5:  # tail loop
-    movl (%esi),%edx
-    roll $8,%edx
-    movl %edx,(%edi)
-    addl $4,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p32_32RGBA888.L5
-
-_ConvertX86p32_32RGBA888.L6: popl %ebp
-    jmp _x86return
-
-
-
-
-_ConvertX86p32_32BGRA888:
-
-    # check short
-    cmpl $32,%ecx
-    ja _ConvertX86p32_32BGRA888.L3
-
-_ConvertX86p32_32BGRA888.L1:  # short loop
-    movl (%esi),%edx
-    bswapl %edx
-    movl %edx,(%edi)
-    addl $4,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p32_32BGRA888.L1
-_ConvertX86p32_32BGRA888.L2:
-    jmp _x86return
-
-_ConvertX86p32_32BGRA888.L3:  # save ebp
-    pushl %ebp
-
-    # unroll four times
-    movl %ecx,%ebp
-    shrl $2,%ebp
-
-    # save count
-    pushl %ecx
-
-_ConvertX86p32_32BGRA888.L4: movl (%esi),%eax
-        movl 4(%esi),%ebx
-
-        movl 8(%esi),%ecx
-        movl 12(%esi),%edx
-
-        bswapl %eax
-
-        bswapl %ebx
-
-        bswapl %ecx
-
-        bswapl %edx
-
-        movl %eax,(%edi)
-        movl %ebx,4(%edi)
-
-        movl %ecx,8(%edi)
-        movl %edx,12(%edi)
-
-        addl $16,%esi
-        addl $16,%edi
-
-        decl %ebp
-        jnz _ConvertX86p32_32BGRA888.L4
-
-    # check tail
-    popl %ecx
-    andl $0b11,%ecx
-    jz _ConvertX86p32_32BGRA888.L6
-
-_ConvertX86p32_32BGRA888.L5:  # tail loop
-    movl (%esi),%edx
-    bswapl %edx
-    movl %edx,(%edi)
-    addl $4,%esi
-    addl $4,%edi
-    decl %ecx
-    jnz _ConvertX86p32_32BGRA888.L5
-
-_ConvertX86p32_32BGRA888.L6: popl %ebp
-    jmp _x86return
-
-
-
-
-## 32 bit RGB 888 to 24 BIT RGB 888
-
-_ConvertX86p32_24RGB888:
-
-        # check short
-        cmpl $32,%ecx
-        ja _ConvertX86p32_24RGB888.L3
-
-_ConvertX86p32_24RGB888.L1:  # short loop
-        movb (%esi),%al
-        movb 1(%esi),%bl
-        movb 2(%esi),%dl
-        movb %al,(%edi)
-        movb %bl,1(%edi)
-        movb %dl,2(%edi)
-        addl $4,%esi
-        addl $3,%edi
-        decl %ecx
-        jnz _ConvertX86p32_24RGB888.L1
-_ConvertX86p32_24RGB888.L2:
-        jmp _x86return
-
-_ConvertX86p32_24RGB888.L3:  #        head
-        movl %edi,%edx
-        andl $0b11,%edx
-        jz _ConvertX86p32_24RGB888.L4
-        movb (%esi),%al
-        movb 1(%esi),%bl
-        movb 2(%esi),%dl
-        movb %al,(%edi)
-        movb %bl,1(%edi)
-        movb %dl,2(%edi)
-        addl $4,%esi
-        addl $3,%edi
-        decl %ecx
-        jmp _ConvertX86p32_24RGB888.L3
-
-_ConvertX86p32_24RGB888.L4:  # unroll 4 times
-        pushl %ebp
-        movl %ecx,%ebp
-        shrl $2,%ebp
-
-    # save count
-        pushl %ecx
-
-_ConvertX86p32_24RGB888.L5: movl (%esi),%eax # first dword            eax = [A][R][G][B]
-        movl 4(%esi),%ebx               # second dword           ebx = [a][r][g][b]
-
-        shll $8,%eax                    #                        eax = [R][G][B][.]
-        movl 12(%esi),%ecx              # third dword            ecx = [a][r][g][b]
-
-        shll $8,%ebx                    #                        ebx = [r][g][b][.]
-        movb 4(%esi),%al                #                        eax = [R][G][B][b]
-
-        rorl $8,%eax                    #                        eax = [b][R][G][B] (done)
-        movb 8+1(%esi),%bh              #                        ebx = [r][g][G][.]
-
-        movl %eax,(%edi)
-        addl $3*4,%edi
-
-        shll $8,%ecx                    #                        ecx = [r][g][b][.]
-        movb 8+0(%esi),%bl              #                        ebx = [r][g][G][B]
-
-        roll $16,%ebx                   #                        ebx = [G][B][r][g] (done)
-        movb 8+2(%esi),%cl              #                        ecx = [r][g][b][R] (done)
-
-        movl %ebx,4-3*4(%edi)
-        addl $4*4,%esi
-
-        movl %ecx,8-3*4(%edi)
-        decl %ebp
-
-        jnz _ConvertX86p32_24RGB888.L5
-
-    # check tail
-        popl %ecx
-        andl $0b11,%ecx
-        jz _ConvertX86p32_24RGB888.L7
-
-_ConvertX86p32_24RGB888.L6:  # tail loop
-        movb (%esi),%al
-        movb 1(%esi),%bl
-        movb 2(%esi),%dl
-        movb %al,(%edi)
-        movb %bl,1(%edi)
-        movb %dl,2(%edi)
-        addl $4,%esi
-        addl $3,%edi
-        decl %ecx
-        jnz _ConvertX86p32_24RGB888.L6
-
-_ConvertX86p32_24RGB888.L7: popl %ebp
-        jmp _x86return
-
-
-
-
-## 32 bit RGB 888 to 24 bit BGR 888
-
-_ConvertX86p32_24BGR888:
-
-        # check short
-        cmpl $32,%ecx
-        ja _ConvertX86p32_24BGR888.L3
-
-
-_ConvertX86p32_24BGR888.L1:  # short loop
-        movb (%esi),%dl
-        movb 1(%esi),%bl
-        movb 2(%esi),%al
-        movb %al,(%edi)
-        movb %bl,1(%edi)
-        movb %dl,2(%edi)
-        addl $4,%esi
-        addl $3,%edi
-        decl %ecx
-        jnz _ConvertX86p32_24BGR888.L1
-_ConvertX86p32_24BGR888.L2:
-        jmp _x86return
-
-_ConvertX86p32_24BGR888.L3:  # head
-        movl %edi,%edx
-        andl $0b11,%edx
-        jz _ConvertX86p32_24BGR888.L4
-        movb (%esi),%dl
-        movb 1(%esi),%bl
-        movb 2(%esi),%al
-        movb %al,(%edi)
-        movb %bl,1(%edi)
-        movb %dl,2(%edi)
-        addl $4,%esi
-        addl $3,%edi
-        decl %ecx
-        jmp _ConvertX86p32_24BGR888.L3
-
-_ConvertX86p32_24BGR888.L4:  # unroll 4 times
-        pushl %ebp
-        movl %ecx,%ebp
-        shrl $2,%ebp
-
-        # save count
-        pushl %ecx
-
-_ConvertX86p32_24BGR888.L5:
-        movl (%esi),%eax                # first dword            eax = [A][R][G][B]
-        movl 4(%esi),%ebx               # second dword           ebx = [a][r][g][b]
-
-        bswapl %eax                     #                        eax = [B][G][R][A]
-
-        bswapl %ebx                     #                        ebx = [b][g][r][a]
-
-        movb 4+2(%esi),%al              #                        eax = [B][G][R][r]
-        movb 4+4+1(%esi),%bh            #                        ebx = [b][g][G][a]
-
-        rorl $8,%eax                    #                        eax = [r][B][G][R] (done)
-        movb 4+4+2(%esi),%bl            #                        ebx = [b][g][G][R]
-
-        rorl $16,%ebx                   #                        ebx = [G][R][b][g] (done)
-        movl %eax,(%edi)
-
-        movl %ebx,4(%edi)
-        movl 12(%esi),%ecx              # third dword            ecx = [a][r][g][b]
-
-        bswapl %ecx                     #                        ecx = [b][g][r][a]
-
-        movb 8(%esi),%cl                #                        ecx = [b][g][r][B] (done)
-        addl $4*4,%esi
-
-        movl %ecx,8(%edi)
-        addl $3*4,%edi
-
-        decl %ebp
-        jnz _ConvertX86p32_24BGR888.L5
-
-        # check tail
-        popl %ecx
-        andl $0b11,%ecx
-        jz _ConvertX86p32_24BGR888.L7
-
-_ConvertX86p32_24BGR888.L6:  # tail loop
-        movb (%esi),%dl
-        movb 1(%esi),%bl
-        movb 2(%esi),%al
-        movb %al,(%edi)
-        movb %bl,1(%edi)
-        movb %dl,2(%edi)
-        addl $4,%esi
-        addl $3,%edi
-        decl %ecx
-        jnz _ConvertX86p32_24BGR888.L6
-
-_ConvertX86p32_24BGR888.L7:
-        popl %ebp
-        jmp _x86return
-
-
-
-
-## 32 bit RGB 888 to 16 BIT RGB 565
-.align 8
-_ConvertX86p32_16RGB565:
-        # check short
-        cmpl $16,%ecx
-        ja _ConvertX86p32_16RGB565.L3
-
-_ConvertX86p32_16RGB565.L1:  # short loop
-        movb (%esi),%bl   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%ah  # red
-        shrb $3,%ah
-        andb $0b11111100,%al
-        shll $3,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-        jnz _ConvertX86p32_16RGB565.L1
-
-_ConvertX86p32_16RGB565.L2:     # End of short loop
-        jmp _x86return
-
-
-_ConvertX86p32_16RGB565.L3:  # head
-        movl %edi,%ebx
-        andl $0b11,%ebx
-        jz _ConvertX86p32_16RGB565.L4
-
-        movb (%esi),%bl   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%ah  # red
-        shrb $3,%ah
-        andb $0b11111100,%al
-        shll $3,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-
-_ConvertX86p32_16RGB565.L4:
-    # save count
-        pushl %ecx
-
-    # unroll twice
-        shrl %ecx
-
-    # point arrays to end
-        leal (%esi,%ecx,8),%esi
-        leal (%edi,%ecx,4),%edi
-
-    # negative counter
-        negl %ecx
-        jmp _ConvertX86p32_16RGB565.L6
-
-_ConvertX86p32_16RGB565.L5:
-        movl %eax,-4(%edi,%ecx,4)
-.align 8
-_ConvertX86p32_16RGB565.L6:
-        movl (%esi,%ecx,8),%eax
-
-        shrb $2,%ah
-        movl 4(%esi,%ecx,8),%ebx
-
-        shrl $3,%eax
-        movl 4(%esi,%ecx,8),%edx
-
-        shrb $2,%bh
-        movb 2(%esi,%ecx,8),%dl
-
-        shll $13,%ebx
-        andl $0x000007FF,%eax
-
-        shll $8,%edx
-        andl $0x07FF0000,%ebx
-
-        andl $0x0F800F800,%edx
-        addl %ebx,%eax
-
-        addl %edx,%eax
-        incl %ecx
-
-        jnz _ConvertX86p32_16RGB565.L5
-
-        movl %eax,-4(%edi,%ecx,4)
-
-    # tail
-        popl %ecx
-        testb $1,%cl
-        jz _ConvertX86p32_16RGB565.L7
-
-        movb (%esi),%bl   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%ah  # red
-        shrb $3,%ah
-        andb $0b11111100,%al
-        shll $3,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-
-_ConvertX86p32_16RGB565.L7:
-        jmp _x86return
-
-
-
-
-## 32 bit RGB 888 to 16 BIT BGR 565
-
-_ConvertX86p32_16BGR565:
-
-        # check short
-        cmpl $16,%ecx
-        ja _ConvertX86p32_16BGR565.L3
-
-_ConvertX86p32_16BGR565.L1:  # short loop
-        movb (%esi),%ah   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%bl  # red
-        shrb $3,%ah
-        andb $0b11111100,%al
-        shll $3,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-        jnz _ConvertX86p32_16BGR565.L1
-_ConvertX86p32_16BGR565.L2:
-        jmp _x86return
-
-_ConvertX86p32_16BGR565.L3:  # head
-        movl %edi,%ebx
-        andl $0b11,%ebx
-        jz _ConvertX86p32_16BGR565.L4
-        movb (%esi),%ah   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%bl  # red
-        shrb $3,%ah
-        andb $0b11111100,%al
-        shll $3,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-
-_ConvertX86p32_16BGR565.L4:  # save count
-        pushl %ecx
-
-        # unroll twice
-        shrl %ecx
-
-        # point arrays to end
-        leal (%esi,%ecx,8),%esi
-        leal (%edi,%ecx,4),%edi
-
-        # negative count
-        negl %ecx
-        jmp _ConvertX86p32_16BGR565.L6
-
-_ConvertX86p32_16BGR565.L5:
-        movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p32_16BGR565.L6:
-        movl 4(%esi,%ecx,8),%edx
-
-        movb 4(%esi,%ecx,8),%bh
-        movb (%esi,%ecx,8),%ah
-
-        shrb $3,%bh
-        movb 1(%esi,%ecx,8),%al
-
-        shrb $3,%ah
-        movb 5(%esi,%ecx,8),%bl
-
-        shll $3,%eax
-        movb 2(%esi,%ecx,8),%dl
-
-        shll $19,%ebx
-        andl $0x0000FFE0,%eax
-
-        shrl $3,%edx
-        andl $0x0FFE00000,%ebx
-
-        andl $0x001F001F,%edx
-        addl %ebx,%eax
-
-        addl %edx,%eax
-        incl %ecx
-
-        jnz _ConvertX86p32_16BGR565.L5
-
-        movl %eax,-4(%edi,%ecx,4)
-
-        # tail
-        popl %ecx
-        andl $1,%ecx
-        jz _ConvertX86p32_16BGR565.L7
-        movb (%esi),%ah   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%bl  # red
-        shrb $3,%ah
-        andb $0b11111100,%al
-        shll $3,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-
-_ConvertX86p32_16BGR565.L7:
-        jmp _x86return
-
-
-
-
-## 32 BIT RGB TO 16 BIT RGB 555
-
-_ConvertX86p32_16RGB555:
-
-        # check short
-        cmpl $16,%ecx
-        ja _ConvertX86p32_16RGB555.L3
-
-_ConvertX86p32_16RGB555.L1:  # short loop
-        movb (%esi),%bl   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%ah  # red
-        shrb $3,%ah
-        andb $0b11111000,%al
-        shll $2,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-        jnz _ConvertX86p32_16RGB555.L1
-_ConvertX86p32_16RGB555.L2:
-        jmp _x86return
-
-_ConvertX86p32_16RGB555.L3:  # head
-        movl %edi,%ebx
-        andl $0b11,%ebx
-        jz _ConvertX86p32_16RGB555.L4
-        movb (%esi),%bl   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%ah  # red
-        shrb $3,%ah
-        andb $0b11111000,%al
-        shll $2,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-
-_ConvertX86p32_16RGB555.L4:  # save count
-        pushl %ecx
-
-        # unroll twice
-        shrl %ecx
-
-        # point arrays to end
-        leal (%esi,%ecx,8),%esi
-        leal (%edi,%ecx,4),%edi
-
-        # negative counter
-        negl %ecx
-        jmp _ConvertX86p32_16RGB555.L6
-
-_ConvertX86p32_16RGB555.L5:
-        movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p32_16RGB555.L6:
-        movl (%esi,%ecx,8),%eax
-
-        shrb $3,%ah
-        movl 4(%esi,%ecx,8),%ebx
-
-        shrl $3,%eax
-        movl 4(%esi,%ecx,8),%edx
-
-        shrb $3,%bh
-        movb 2(%esi,%ecx,8),%dl
-
-        shll $13,%ebx
-        andl $0x000007FF,%eax
-
-        shll $7,%edx
-        andl $0x07FF0000,%ebx
-
-        andl $0x07C007C00,%edx
-        addl %ebx,%eax
-
-        addl %edx,%eax
-        incl %ecx
-
-        jnz _ConvertX86p32_16RGB555.L5
-
-        movl %eax,-4(%edi,%ecx,4)
-
-        # tail
-        popl %ecx
-        andl $1,%ecx
-        jz _ConvertX86p32_16RGB555.L7
-        movb (%esi),%bl   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%ah  # red
-        shrb $3,%ah
-        andb $0b11111000,%al
-        shll $2,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-
-_ConvertX86p32_16RGB555.L7:
-        jmp _x86return
-
-
-
-
-## 32 BIT RGB TO 16 BIT BGR 555
-
-_ConvertX86p32_16BGR555:
-
-        # check short
-        cmpl $16,%ecx
-        ja _ConvertX86p32_16BGR555.L3
-
-
-_ConvertX86p32_16BGR555.L1:  # short loop
-        movb (%esi),%ah   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%bl  # red
-        shrb $3,%ah
-        andb $0b11111000,%al
-        shll $2,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-        jnz _ConvertX86p32_16BGR555.L1
-_ConvertX86p32_16BGR555.L2:
-        jmp _x86return
-
-_ConvertX86p32_16BGR555.L3:  # head
-        movl %edi,%ebx
-        andl $0b11,%ebx
-        jz _ConvertX86p32_16BGR555.L4
-        movb (%esi),%ah   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%bl  # red
-        shrb $3,%ah
-        andb $0b11111000,%al
-        shll $2,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-        decl %ecx
-
-_ConvertX86p32_16BGR555.L4:  # save count
-        pushl %ecx
-
-        # unroll twice
-        shrl %ecx
-
-        # point arrays to end
-        leal (%esi,%ecx,8),%esi
-        leal (%edi,%ecx,4),%edi
-
-        # negative counter
-        negl %ecx
-        jmp _ConvertX86p32_16BGR555.L6
-
-_ConvertX86p32_16BGR555.L5:
-        movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p32_16BGR555.L6:
-        movl 4(%esi,%ecx,8),%edx
-
-        movb 4(%esi,%ecx,8),%bh
-        movb (%esi,%ecx,8),%ah
-
-        shrb $3,%bh
-        movb 1(%esi,%ecx,8),%al
-
-        shrb $3,%ah
-        movb 5(%esi,%ecx,8),%bl
-
-        shll $2,%eax
-        movb 2(%esi,%ecx,8),%dl
-
-        shll $18,%ebx
-        andl $0x00007FE0,%eax
-
-        shrl $3,%edx
-        andl $0x07FE00000,%ebx
-
-        andl $0x001F001F,%edx
-        addl %ebx,%eax
-
-        addl %edx,%eax
-        incl %ecx
-
-        jnz _ConvertX86p32_16BGR555.L5
-
-        movl %eax,-4(%edi,%ecx,4)
-
-        # tail
-        popl %ecx
-        andl $1,%ecx
-        jz _ConvertX86p32_16BGR555.L7
-        movb (%esi),%ah   # blue
-        movb 1(%esi),%al  # green
-        movb 2(%esi),%bl  # red
-        shrb $3,%ah
-        andb $0b11111000,%al
-        shll $2,%eax
-        shrb $3,%bl
-        addb %bl,%al
-        movb %al,(%edi)
-        movb %ah,1(%edi)
-        addl $4,%esi
-        addl $2,%edi
-
-_ConvertX86p32_16BGR555.L7:
-        jmp _x86return
-
-
-
-
-
-## FROM 32 BIT RGB to 8 BIT RGB (rrrgggbbb)
-## This routine writes FOUR pixels at once (dword) and then, if they exist
-## the trailing three pixels
-_ConvertX86p32_8RGB332:
-
-
-_ConvertX86p32_8RGB332.L_ALIGNED:
-        pushl %ecx
-
-        shrl $2,%ecx            # We will draw 4 pixels at once
-        jnz _ConvertX86p32_8RGB332.L1
-
-        jmp _ConvertX86p32_8RGB332.L2 # short jump out of range :(
-
-_ConvertX86p32_8RGB332.L1:
-        movl (%esi),%eax        # first pair of pixels
-        movl 4(%esi),%edx
-
-        shrb $6,%dl
-        movl %eax,%ebx
-
-        shrb $6,%al
-        andb $0x0e0,%ah
-
-        shrl $16,%ebx
-        andb $0x0e0,%dh
-
-        shrb $3,%ah
-        andb $0x0e0,%bl
-
-        shrb $3,%dh
-
-        orb %bl,%al
-
-        movl %edx,%ebx
-        orb %ah,%al
-
-        shrl $16,%ebx
-        orb %dh,%dl
-
-        andb $0x0e0,%bl
-
-        orb %bl,%dl
-
-        movb %dl,%ah
-
-
-
-        movl 8(%esi),%ebx       # second pair of pixels
-
-        movl %ebx,%edx
-        andb $0x0e0,%bh
-
-        shrb $6,%bl
-        andl $0x0e00000,%edx
-
-        shrl $16,%edx
-
-        shrb $3,%bh
-
-        rorl $16,%eax
-        orb %dl,%bl
-
-        movl 12(%esi),%edx
-        orb %bh,%bl
-
-        movb %bl,%al
-
-        movl %edx,%ebx
-        andb $0x0e0,%dh
-
-        shrb $6,%dl
-        andl $0x0e00000,%ebx
-
-        shrb $3,%dh
-        movb %dl,%ah
-
-        shrl $16,%ebx
-        orb %dh,%ah
-
-        orb %bl,%ah
-
-        roll $16,%eax
-        addl $16,%esi
-
-        movl %eax,(%edi)
-        addl $4,%edi
-
-        decl %ecx
-        jz _ConvertX86p32_8RGB332.L2 # L1 out of range for short jump :(
-
-        jmp _ConvertX86p32_8RGB332.L1
-_ConvertX86p32_8RGB332.L2:
-
-        popl %ecx
-        andl $3,%ecx            # mask out number of pixels to draw
-
-        jz _ConvertX86p32_8RGB332.L4 # Nothing to do anymore
-
-_ConvertX86p32_8RGB332.L3:
-        movl (%esi),%eax        # single pixel conversion for trailing pixels
-
-        movl %eax,%ebx
-
-        shrb $6,%al
-        andb $0x0e0,%ah
-
-        shrl $16,%ebx
-
-        shrb $3,%ah
-        andb $0x0e0,%bl
-
-        orb %ah,%al
-        orb %bl,%al
-
-        movb %al,(%edi)
-
-        incl %edi
-        addl $4,%esi
-
-        decl %ecx
-        jnz _ConvertX86p32_8RGB332.L3
-
-_ConvertX86p32_8RGB332.L4:
-        jmp _x86return

+ 1041 - 0
packages/hermes/src/i386/x86p_32.inc

@@ -0,0 +1,1041 @@
+{
+    x86 format converters for HERMES
+    Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
+    Most routines are (c) Glenn Fiedler ([email protected]), used with permission
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+
+
+{ _Convert_*
+ Paramters:
+   ESI = source
+   EDI = dest
+   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
+ Destroys:
+   EAX, EBX, EDX
+}
+
+procedure ConvertX86p32_32BGR888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+.L1:  // short loop
+    movl (%esi),%edx
+    bswapl %edx
+    rorl $8,%edx
+    movl %edx,(%edi)
+    addl $4,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // save ebp
+    pushl %ebp
+
+    // unroll four times
+    movl %ecx,%ebp
+    shrl $2,%ebp
+
+    // save count
+    pushl %ecx
+
+.L4:    movl (%esi),%eax
+        movl 4(%esi),%ebx
+
+        bswapl %eax
+
+        bswapl %ebx
+
+        rorl $8,%eax
+        movl 8(%esi),%ecx
+
+        rorl $8,%ebx
+        movl 12(%esi),%edx
+
+        bswapl %ecx
+
+        bswapl %edx
+
+        rorl $8,%ecx
+        movl %eax,(%edi)
+
+        rorl $8,%edx
+        movl %ebx,4(%edi)
+
+        movl %ecx,8(%edi)
+        movl %edx,12(%edi)
+
+        addl $16,%esi
+        addl $16,%edi
+
+        decl %ebp
+        jnz .L4
+
+    // check tail
+    popl %ecx
+    andl $0b11,%ecx
+    jz .L6
+
+.L5:  // tail loop
+    movl (%esi),%edx
+    bswapl %edx
+    rorl $8,%edx
+    movl %edx,(%edi)
+    addl $4,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L5
+
+.L6: popl %ebp
+    jmp _X86RETURN
+end;
+
+procedure ConvertX86p32_32RGBA888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+.L1:  // short loop
+    movl (%esi),%edx
+    roll $8,%edx
+    movl %edx,(%edi)
+    addl $4,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // save ebp
+    pushl %ebp
+
+    // unroll four times
+    movl %ecx,%ebp
+    shrl $2,%ebp
+
+    // save count
+    pushl %ecx
+
+.L4:    movl (%esi),%eax
+        movl 4(%esi),%ebx
+
+        roll $8,%eax
+        movl 8(%esi),%ecx
+
+        roll $8,%ebx
+        movl 12(%esi),%edx
+
+        roll $8,%ecx
+        movl %eax,(%edi)
+
+        roll $8,%edx
+        movl %ebx,4(%edi)
+
+        movl %ecx,8(%edi)
+        movl %edx,12(%edi)
+
+        addl $16,%esi
+        addl $16,%edi
+
+        decl %ebp
+        jnz .L4
+
+    // check tail
+    popl %ecx
+    andl $0b11,%ecx
+    jz .L6
+
+.L5:  // tail loop
+    movl (%esi),%edx
+    roll $8,%edx
+    movl %edx,(%edi)
+    addl $4,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L5
+
+.L6: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+procedure ConvertX86p32_32BGRA888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+    // check short
+    cmpl $32,%ecx
+    ja .L3
+
+.L1:  // short loop
+    movl (%esi),%edx
+    bswapl %edx
+    movl %edx,(%edi)
+    addl $4,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L1
+.L2:
+    jmp _X86RETURN
+
+.L3:  // save ebp
+    pushl %ebp
+
+    // unroll four times
+    movl %ecx,%ebp
+    shrl $2,%ebp
+
+    // save count
+    pushl %ecx
+
+.L4:    movl (%esi),%eax
+        movl 4(%esi),%ebx
+
+        movl 8(%esi),%ecx
+        movl 12(%esi),%edx
+
+        bswapl %eax
+
+        bswapl %ebx
+
+        bswapl %ecx
+
+        bswapl %edx
+
+        movl %eax,(%edi)
+        movl %ebx,4(%edi)
+
+        movl %ecx,8(%edi)
+        movl %edx,12(%edi)
+
+        addl $16,%esi
+        addl $16,%edi
+
+        decl %ebp
+        jnz .L4
+
+    // check tail
+    popl %ecx
+    andl $0b11,%ecx
+    jz .L6
+
+.L5:  // tail loop
+    movl (%esi),%edx
+    bswapl %edx
+    movl %edx,(%edi)
+    addl $4,%esi
+    addl $4,%edi
+    decl %ecx
+    jnz .L5
+
+.L6: popl %ebp
+    jmp _X86RETURN
+end;
+
+
+
+// 32 bit RGB 888 to 24 BIT RGB 888
+procedure ConvertX86p32_24RGB888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // check short
+        cmpl $32,%ecx
+        ja .L3
+
+.L1:  // short loop
+        movb (%esi),%al
+        movb 1(%esi),%bl
+        movb 2(%esi),%dl
+        movb %al,(%edi)
+        movb %bl,1(%edi)
+        movb %dl,2(%edi)
+        addl $4,%esi
+        addl $3,%edi
+        decl %ecx
+        jnz .L1
+.L2:
+        jmp _X86RETURN
+
+.L3:  //        head
+        movl %edi,%edx
+        andl $0b11,%edx
+        jz .L4
+        movb (%esi),%al
+        movb 1(%esi),%bl
+        movb 2(%esi),%dl
+        movb %al,(%edi)
+        movb %bl,1(%edi)
+        movb %dl,2(%edi)
+        addl $4,%esi
+        addl $3,%edi
+        decl %ecx
+        jmp .L3
+
+.L4:  // unroll 4 times
+        pushl %ebp
+        movl %ecx,%ebp
+        shrl $2,%ebp
+
+    // save count
+        pushl %ecx
+
+.L5:    movl (%esi),%eax                // first dword            eax = [A][R][G][B]
+        movl 4(%esi),%ebx               // second dword           ebx = [a][r][g][b]
+
+        shll $8,%eax                    //                        eax = [R][G][B][.]
+        movl 12(%esi),%ecx              // third dword            ecx = [a][r][g][b]
+
+        shll $8,%ebx                    //                        ebx = [r][g][b][.]
+        movb 4(%esi),%al                //                        eax = [R][G][B][b]
+
+        rorl $8,%eax                    //                        eax = [b][R][G][B] (done)
+        movb 8+1(%esi),%bh              //                        ebx = [r][g][G][.]
+
+        movl %eax,(%edi)
+        addl $3*4,%edi
+
+        shll $8,%ecx                    //                        ecx = [r][g][b][.]
+        movb 8+0(%esi),%bl              //                        ebx = [r][g][G][B]
+
+        roll $16,%ebx                   //                        ebx = [G][B][r][g] (done)
+        movb 8+2(%esi),%cl              //                        ecx = [r][g][b][R] (done)
+
+        movl %ebx,4-3*4(%edi)
+        addl $4*4,%esi
+
+        movl %ecx,8-3*4(%edi)
+        decl %ebp
+
+        jnz .L5
+
+    // check tail
+        popl %ecx
+        andl $0b11,%ecx
+        jz .L7
+
+.L6:  // tail loop
+        movb (%esi),%al
+        movb 1(%esi),%bl
+        movb 2(%esi),%dl
+        movb %al,(%edi)
+        movb %bl,1(%edi)
+        movb %dl,2(%edi)
+        addl $4,%esi
+        addl $3,%edi
+        decl %ecx
+        jnz .L6
+
+.L7:    popl %ebp
+        jmp _X86RETURN
+end;
+
+
+
+// 32 bit RGB 888 to 24 bit BGR 888
+procedure ConvertX86p32_24BGR888(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // check short
+        cmpl $32,%ecx
+        ja .L3
+
+
+.L1:  // short loop
+        movb (%esi),%dl
+        movb 1(%esi),%bl
+        movb 2(%esi),%al
+        movb %al,(%edi)
+        movb %bl,1(%edi)
+        movb %dl,2(%edi)
+        addl $4,%esi
+        addl $3,%edi
+        decl %ecx
+        jnz .L1
+.L2:
+        jmp _X86RETURN
+
+.L3:  // head
+        movl %edi,%edx
+        andl $0b11,%edx
+        jz .L4
+        movb (%esi),%dl
+        movb 1(%esi),%bl
+        movb 2(%esi),%al
+        movb %al,(%edi)
+        movb %bl,1(%edi)
+        movb %dl,2(%edi)
+        addl $4,%esi
+        addl $3,%edi
+        decl %ecx
+        jmp .L3
+
+.L4:  // unroll 4 times
+        pushl %ebp
+        movl %ecx,%ebp
+        shrl $2,%ebp
+
+        // save count
+        pushl %ecx
+
+.L5:
+        movl (%esi),%eax                // first dword            eax = [A][R][G][B]
+        movl 4(%esi),%ebx               // second dword           ebx = [a][r][g][b]
+
+        bswapl %eax                     //                        eax = [B][G][R][A]
+
+        bswapl %ebx                     //                        ebx = [b][g][r][a]
+
+        movb 4+2(%esi),%al              //                        eax = [B][G][R][r]
+        movb 4+4+1(%esi),%bh            //                        ebx = [b][g][G][a]
+
+        rorl $8,%eax                    //                        eax = [r][B][G][R] (done)
+        movb 4+4+2(%esi),%bl            //                        ebx = [b][g][G][R]
+
+        rorl $16,%ebx                   //                        ebx = [G][R][b][g] (done)
+        movl %eax,(%edi)
+
+        movl %ebx,4(%edi)
+        movl 12(%esi),%ecx              // third dword            ecx = [a][r][g][b]
+
+        bswapl %ecx                     //                        ecx = [b][g][r][a]
+
+        movb 8(%esi),%cl                //                        ecx = [b][g][r][B] (done)
+        addl $4*4,%esi
+
+        movl %ecx,8(%edi)
+        addl $3*4,%edi
+
+        decl %ebp
+        jnz .L5
+
+        // check tail
+        popl %ecx
+        andl $0b11,%ecx
+        jz .L7
+
+.L6:  // tail loop
+        movb (%esi),%dl
+        movb 1(%esi),%bl
+        movb 2(%esi),%al
+        movb %al,(%edi)
+        movb %bl,1(%edi)
+        movb %dl,2(%edi)
+        addl $4,%esi
+        addl $3,%edi
+        decl %ecx
+        jnz .L6
+
+.L7:
+        popl %ebp
+        jmp _X86RETURN
+end;
+
+
+
+// 32 bit RGB 888 to 16 BIT RGB 565
+procedure ConvertX86p32_16RGB565(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // check short
+        cmpl $16,%ecx
+        ja .L3
+
+.L1:  // short loop
+        movb (%esi),%bl   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%ah  // red
+        shrb $3,%ah
+        andb $0b11111100,%al
+        shll $3,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+        jnz .L1
+
+.L2:     // End of short loop
+        jmp _X86RETURN
+
+
+.L3:  // head
+        movl %edi,%ebx
+        andl $0b11,%ebx
+        jz .L4
+
+        movb (%esi),%bl   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%ah  // red
+        shrb $3,%ah
+        andb $0b11111100,%al
+        shll $3,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+
+.L4:
+    // save count
+        pushl %ecx
+
+    // unroll twice
+        shrl $1,%ecx
+
+    // point arrays to end
+        leal (%esi,%ecx,8),%esi
+        leal (%edi,%ecx,4),%edi
+
+    // negative counter
+        negl %ecx
+        jmp .L6
+
+.L5:
+        movl %eax,-4(%edi,%ecx,4)
+.balign 8
+.L6:
+        movl (%esi,%ecx,8),%eax
+
+        shrb $2,%ah
+        movl 4(%esi,%ecx,8),%ebx
+
+        shrl $3,%eax
+        movl 4(%esi,%ecx,8),%edx
+
+        shrb $2,%bh
+        movb 2(%esi,%ecx,8),%dl
+
+        shll $13,%ebx
+        andl $0x000007FF,%eax
+
+        shll $8,%edx
+        andl $0x07FF0000,%ebx
+
+        andl $0x0F800F800,%edx
+        addl %ebx,%eax
+
+        addl %edx,%eax
+        incl %ecx
+
+        jnz .L5
+
+        movl %eax,-4(%edi,%ecx,4)
+
+    // tail
+        popl %ecx
+        testb $1,%cl
+        jz .L7
+
+        movb (%esi),%bl   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%ah  // red
+        shrb $3,%ah
+        andb $0b11111100,%al
+        shll $3,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+
+.L7:
+        jmp _X86RETURN
+end;
+
+
+
+// 32 bit RGB 888 to 16 BIT BGR 565
+
+procedure ConvertX86p32_16BGR565(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // check short
+        cmpl $16,%ecx
+        ja .L3
+
+.L1:  // short loop
+        movb (%esi),%ah   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%bl  // red
+        shrb $3,%ah
+        andb $0b11111100,%al
+        shll $3,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+        jnz .L1
+.L2:
+        jmp _X86RETURN
+
+.L3:  // head
+        movl %edi,%ebx
+        andl $0b11,%ebx
+        jz .L4
+        movb (%esi),%ah   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%bl  // red
+        shrb $3,%ah
+        andb $0b11111100,%al
+        shll $3,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+
+.L4:  // save count
+        pushl %ecx
+
+        // unroll twice
+        shrl $1,%ecx
+
+        // point arrays to end
+        leal (%esi,%ecx,8),%esi
+        leal (%edi,%ecx,4),%edi
+
+        // negative count
+        negl %ecx
+        jmp .L6
+
+.L5:
+        movl %eax,-4(%edi,%ecx,4)
+.L6:
+        movl 4(%esi,%ecx,8),%edx
+
+        movb 4(%esi,%ecx,8),%bh
+        movb (%esi,%ecx,8),%ah
+
+        shrb $3,%bh
+        movb 1(%esi,%ecx,8),%al
+
+        shrb $3,%ah
+        movb 5(%esi,%ecx,8),%bl
+
+        shll $3,%eax
+        movb 2(%esi,%ecx,8),%dl
+
+        shll $19,%ebx
+        andl $0x0000FFE0,%eax
+
+        shrl $3,%edx
+        andl $0x0FFE00000,%ebx
+
+        andl $0x001F001F,%edx
+        addl %ebx,%eax
+
+        addl %edx,%eax
+        incl %ecx
+
+        jnz .L5
+
+        movl %eax,-4(%edi,%ecx,4)
+
+        // tail
+        popl %ecx
+        andl $1,%ecx
+        jz .L7
+        movb (%esi),%ah   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%bl  // red
+        shrb $3,%ah
+        andb $0b11111100,%al
+        shll $3,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+
+.L7:
+        jmp _X86RETURN
+end;
+
+
+
+// 32 BIT RGB TO 16 BIT RGB 555
+procedure ConvertX86p32_16RGB555(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // check short
+        cmpl $16,%ecx
+        ja .L3
+
+.L1:  // short loop
+        movb (%esi),%bl   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%ah  // red
+        shrb $3,%ah
+        andb $0b11111000,%al
+        shll $2,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+        jnz .L1
+.L2:
+        jmp _X86RETURN
+
+.L3:  // head
+        movl %edi,%ebx
+        andl $0b11,%ebx
+        jz .L4
+        movb (%esi),%bl   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%ah  // red
+        shrb $3,%ah
+        andb $0b11111000,%al
+        shll $2,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+
+.L4:  // save count
+        pushl %ecx
+
+        // unroll twice
+        shrl $1,%ecx
+
+        // point arrays to end
+        leal (%esi,%ecx,8),%esi
+        leal (%edi,%ecx,4),%edi
+
+        // negative counter
+        negl %ecx
+        jmp .L6
+
+.L5:
+        movl %eax,-4(%edi,%ecx,4)
+.L6:
+        movl (%esi,%ecx,8),%eax
+
+        shrb $3,%ah
+        movl 4(%esi,%ecx,8),%ebx
+
+        shrl $3,%eax
+        movl 4(%esi,%ecx,8),%edx
+
+        shrb $3,%bh
+        movb 2(%esi,%ecx,8),%dl
+
+        shll $13,%ebx
+        andl $0x000007FF,%eax
+
+        shll $7,%edx
+        andl $0x07FF0000,%ebx
+
+        andl $0x07C007C00,%edx
+        addl %ebx,%eax
+
+        addl %edx,%eax
+        incl %ecx
+
+        jnz .L5
+
+        movl %eax,-4(%edi,%ecx,4)
+
+        // tail
+        popl %ecx
+        andl $1,%ecx
+        jz .L7
+        movb (%esi),%bl   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%ah  // red
+        shrb $3,%ah
+        andb $0b11111000,%al
+        shll $2,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+
+.L7:
+        jmp _X86RETURN
+end;
+
+
+
+// 32 BIT RGB TO 16 BIT BGR 555
+procedure ConvertX86p32_16BGR555(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        // check short
+        cmpl $16,%ecx
+        ja .L3
+
+
+.L1:  // short loop
+        movb (%esi),%ah   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%bl  // red
+        shrb $3,%ah
+        andb $0b11111000,%al
+        shll $2,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+        jnz .L1
+.L2:
+        jmp _X86RETURN
+
+.L3:  // head
+        movl %edi,%ebx
+        andl $0b11,%ebx
+        jz .L4
+        movb (%esi),%ah   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%bl  // red
+        shrb $3,%ah
+        andb $0b11111000,%al
+        shll $2,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+        decl %ecx
+
+.L4:  // save count
+        pushl %ecx
+
+        // unroll twice
+        shrl $1,%ecx
+
+        // point arrays to end
+        leal (%esi,%ecx,8),%esi
+        leal (%edi,%ecx,4),%edi
+
+        // negative counter
+        negl %ecx
+        jmp .L6
+
+.L5:
+        movl %eax,-4(%edi,%ecx,4)
+.L6:
+        movl 4(%esi,%ecx,8),%edx
+
+        movb 4(%esi,%ecx,8),%bh
+        movb (%esi,%ecx,8),%ah
+
+        shrb $3,%bh
+        movb 1(%esi,%ecx,8),%al
+
+        shrb $3,%ah
+        movb 5(%esi,%ecx,8),%bl
+
+        shll $2,%eax
+        movb 2(%esi,%ecx,8),%dl
+
+        shll $18,%ebx
+        andl $0x00007FE0,%eax
+
+        shrl $3,%edx
+        andl $0x07FE00000,%ebx
+
+        andl $0x001F001F,%edx
+        addl %ebx,%eax
+
+        addl %edx,%eax
+        incl %ecx
+
+        jnz .L5
+
+        movl %eax,-4(%edi,%ecx,4)
+
+        // tail
+        popl %ecx
+        andl $1,%ecx
+        jz .L7
+        movb (%esi),%ah   // blue
+        movb 1(%esi),%al  // green
+        movb 2(%esi),%bl  // red
+        shrb $3,%ah
+        andb $0b11111000,%al
+        shll $2,%eax
+        shrb $3,%bl
+        addb %bl,%al
+        movb %al,(%edi)
+        movb %ah,1(%edi)
+        addl $4,%esi
+        addl $2,%edi
+
+.L7:
+        jmp _X86RETURN
+end;
+
+
+
+
+// FROM 32 BIT RGB to 8 BIT RGB (rrrgggbbb)
+// This routine writes FOUR pixels at once (dword) and then, if they exist
+// the trailing three pixels
+procedure ConvertX86p32_8RGB332(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+.L_ALIGNED:
+        pushl %ecx
+
+        shrl $2,%ecx            // We will draw 4 pixels at once
+        jnz .L1
+
+        jmp .L2 // short jump out of range :(
+
+.L1:
+        movl (%esi),%eax        // first pair of pixels
+        movl 4(%esi),%edx
+
+        shrb $6,%dl
+        movl %eax,%ebx
+
+        shrb $6,%al
+        andb $0x0e0,%ah
+
+        shrl $16,%ebx
+        andb $0x0e0,%dh
+
+        shrb $3,%ah
+        andb $0x0e0,%bl
+
+        shrb $3,%dh
+
+        orb %bl,%al
+
+        movl %edx,%ebx
+        orb %ah,%al
+
+        shrl $16,%ebx
+        orb %dh,%dl
+
+        andb $0x0e0,%bl
+
+        orb %bl,%dl
+
+        movb %dl,%ah
+
+
+
+        movl 8(%esi),%ebx       // second pair of pixels
+
+        movl %ebx,%edx
+        andb $0x0e0,%bh
+
+        shrb $6,%bl
+        andl $0x0e00000,%edx
+
+        shrl $16,%edx
+
+        shrb $3,%bh
+
+        rorl $16,%eax
+        orb %dl,%bl
+
+        movl 12(%esi),%edx
+        orb %bh,%bl
+
+        movb %bl,%al
+
+        movl %edx,%ebx
+        andb $0x0e0,%dh
+
+        shrb $6,%dl
+        andl $0x0e00000,%ebx
+
+        shrb $3,%dh
+        movb %dl,%ah
+
+        shrl $16,%ebx
+        orb %dh,%ah
+
+        orb %bl,%ah
+
+        roll $16,%eax
+        addl $16,%esi
+
+        movl %eax,(%edi)
+        addl $4,%edi
+
+        decl %ecx
+        jz .L2 // L1 out of range for short jump :(
+
+        jmp .L1
+.L2:
+
+        popl %ecx
+        andl $3,%ecx            // mask out number of pixels to draw
+
+        jz .L4 // Nothing to do anymore
+
+.L3:
+        movl (%esi),%eax        // single pixel conversion for trailing pixels
+
+        movl %eax,%ebx
+
+        shrb $6,%al
+        andb $0x0e0,%ah
+
+        shrl $16,%ebx
+
+        shrb $3,%ah
+        andb $0x0e0,%bl
+
+        orb %ah,%al
+        orb %bl,%al
+
+        movb %al,(%edi)
+
+        incl %edi
+        addl $4,%esi
+
+        decl %ecx
+        jnz .L3
+
+.L4:
+        jmp _X86RETURN
+end;

+ 0 - 120
packages/hermes/src/i386/x86p_cpy.as

@@ -1,120 +0,0 @@
-
-
-
-
-
-.globl _CopyX86p_4byte
-.globl _CopyX86p_3byte
-.globl _CopyX86p_2byte
-.globl _CopyX86p_1byte
-
-.extern _x86return
-
-
-.text
-
-## _Copy*
-## Paramters:
-##   ESI = source
-##   EDI = dest
-##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
-## Destroys:
-##   EAX, EBX, EDX
-
-_CopyX86p_4byte:
-
-        rep
- movsl
-
-        jmp _x86return
-
-
-_CopyX86p_3byte:
-
-        leal (%ecx,%ecx,2),%ecx
-        jmp _CopyX86p_1byte
-
-
-
-_CopyX86p_2byte:
-
-        testl $3,%edi                   # Check if video memory is aligned
-        jz _CopyX86p_2byte.L_ALIGNED
-
-        movw (%esi),%ax
-        addl $2,%esi
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-        decl %ecx
-        jz _CopyX86p_2byte.L3
-
-_CopyX86p_2byte.L_ALIGNED:
-
-        movl %ecx,%ebx                  # Save ecx for later
-
-        shrl %ecx
-        jz _CopyX86p_2byte.L2
-
-        rep
- movsl
-
-_CopyX86p_2byte.L2:
-        andl $1,%ebx
-        jz _CopyX86p_2byte.L3
-
-        movw (%esi),%ax
-        addl $2,%esi
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-_CopyX86p_2byte.L3:
-        jmp _x86return
-
-
-
-_CopyX86p_1byte:
-
-_CopyX86p_1byte.L_alignloop:
-        testl $3,%edi
-        jz _CopyX86p_1byte.L_aligned
-
-        movb (%esi),%al
-        incl %esi
-
-        movb %al,(%edi)
-        incl %edi
-
-        decl %ecx
-        jz _CopyX86p_1byte.L4
-        jmp _CopyX86p_1byte.L_alignloop
-
-_CopyX86p_1byte.L_aligned:
-        movl %ecx,%edx
-
-        shrl $2,%ecx
-        jz _CopyX86p_1byte.L2
-
-        rep
- movsl
-
-_CopyX86p_1byte.L2:
-        movl %edx,%ecx          # Get the remaining pixels to draw
-
-        andl $3,%ecx
-        jz _CopyX86p_1byte.L4   # width was modulo 4
-
-_CopyX86p_1byte.L3:
-        movb (%esi),%al
-        incl %esi
-
-        movb %al,(%edi)
-        incl %edi
-
-        decl %ecx
-        jnz _CopyX86p_1byte.L3
-
-_CopyX86p_1byte.L4:
-        jmp _x86return

+ 148 - 0
packages/hermes/src/i386/x86p_cpy.inc

@@ -0,0 +1,148 @@
+{
+    x86 format converters for HERMES
+    Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
+    Some routines are (c) Glenn Fiedler ([email protected]), used with permission
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+
+
+
+
+{ _Copy*
+ Paramters:
+   ESI = source
+   EDI = dest
+   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
+ Destroys:
+   EAX, EBX, EDX
+}
+
+procedure CopyX86p_4byte(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+
+        rep
+ movsl
+
+        jmp _X86RETURN
+end;
+
+
+procedure CopyX86p_1byte(CONVERT_PARAMETERS); cdecl; nostackframe; forward;
+
+procedure CopyX86p_3byte; cdecl; nostackframe; assembler;
+asm
+        leal (%ecx,%ecx,2),%ecx
+        jmp CopyX86p_1byte
+end;
+
+
+
+procedure CopyX86p_2byte(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        testl $3,%edi                   // Check if video memory is aligned
+        jz .L_ALIGNED
+
+        movw (%esi),%ax
+        addl $2,%esi
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+        decl %ecx
+        jz .L3
+
+.L_ALIGNED:
+
+        movl %ecx,%ebx                  // Save ecx for later
+
+        shrl $1,%ecx
+        jz .L2
+
+        rep
+ movsl
+
+.L2:
+        andl $1,%ebx
+        jz .L3
+
+        movw (%esi),%ax
+        addl $2,%esi
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+.L3:
+        jmp _X86RETURN
+end;
+
+
+procedure CopyX86p_1byte(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+.L_alignloop:
+        testl $3,%edi
+        jz .L_aligned
+
+        movb (%esi),%al
+        incl %esi
+
+        movb %al,(%edi)
+        incl %edi
+
+        decl %ecx
+        jz .L4
+        jmp .L_alignloop
+
+.L_aligned:
+        movl %ecx,%edx
+
+        shrl $2,%ecx
+        jz .L2
+
+        rep
+ movsl
+
+.L2:
+        movl %edx,%ecx          // Get the remaining pixels to draw
+
+        andl $3,%ecx
+        jz .L4                  // width was modulo 4
+
+.L3:
+        movb (%esi),%al
+        incl %esi
+
+        movb %al,(%edi)
+        incl %edi
+
+        decl %ecx
+        jnz .L3
+
+.L4:
+        jmp _X86RETURN
+end;

+ 0 - 224
packages/hermes/src/i386/x86p_i8.as

@@ -1,224 +0,0 @@
-#
-# x86 format converters for HERMES
-# Copyright (c) 1998 Christian Nentwich ([email protected])
-# This source code is licensed under the GNU LGPL
-#
-# Please refer to the file COPYING.LIB contained in the distribution for
-# licensing conditions
-#
-# Some routines are (c) Glenn Fiedler ([email protected]), used with permission
-#
-
-
-
-.globl _ConvertX86pI8_32
-.globl _ConvertX86pI8_24
-.globl _ConvertX86pI8_16
-
-.extern _ConvertX86
-.extern _x86return
-
-.text
-
-
-## Convert_*
-## Paramters:
-##   ESI = source
-##   EDI = dest
-##   ECX = amount (NOT 0!!! (the ConvertX86 routine checks for that though))
-## Destroys:
-##   EAX, EBX, EDX
-
-_ConvertX86pI8_32:
-
-        xorl %ebx,%ebx
-        movl 36(%ebp),%edx
-_ConvertX86pI8_32.L1:
-        movb (%esi),%bl
-        incl %esi
-
-        movl (%edx,%ebx,4),%eax
-
-        movl %eax,(%edi)
-        addl $4,%edi
-
-        decl %ecx
-        jnz _ConvertX86pI8_32.L1
-
-        jmp _x86return
-
-
-
-_ConvertX86pI8_24:
-        movl 36(%ebp),%ebx
-
-        xorl %edx,%edx
-
-        # check short
-        cmpl $32,%ecx
-        ja _ConvertX86pI8_24.L3
-
-
-_ConvertX86pI8_24.L1:  # short loop
-        movb (%esi),%dl
-        movl (%ebx,%edx,4),%eax
-        movb %al,(%edi) # blue
-        movb %ah,1(%edi)# green
-        shrl $16,%eax
-        movb %al,2(%edi)# red
-        incl %esi
-        addl $3,%edi
-        decl %ecx
-        jnz _ConvertX86pI8_24.L1
-_ConvertX86pI8_24.L2:
-        jmp _x86return
-
-_ConvertX86pI8_24.L3:  # head
-        movl %edi,%eax
-        andl $0b11,%eax
-        jz _ConvertX86pI8_24.L4
-        movb (%esi),%dl
-        movl (%ebx,%edx,4),%eax
-        movb %al,(%edi) # blue
-        movb %ah,1(%edi)# green
-        shrl $16,%eax
-        movb %al,2(%edi)# red
-        incl %esi
-        addl $3,%edi
-        decl %ecx
-        jmp _ConvertX86pI8_24.L3
-
-_ConvertX86pI8_24.L4:  # save ebp
-        pushl %ebp
-        movl %ebx,%ebp
-
-        # save count
-        pushl %ecx
-
-        # unroll 4 times
-        shrl $2,%ecx
-
-_ConvertX86pI8_24.L5: pushl %ecx        # save ecx
-        movb (%esi),%dl                 # index to "A"
-
-        movl (%ebp,%edx,4),%eax         # eax = [xx][A2][A1][A0]
-        shll $8,%eax                    # eax = [A2][A1][A0][xx]
-
-        movb 1(%esi),%dl                # index to "B"
-
-        movb (%ebp,%edx,4),%al          # eax = [A2][A1][A0][B0]
-        rorl $8,%eax                    # eax = [B0][A2][A1][A0] (done)
-        movl %eax,(%edi)
-
-        movl (%ebp,%edx,4),%eax         # eax = [xx][B2][B1][B0]
-        shll $8,%eax                    # eax = [B2][B1][B0][xx]
-
-        movb 3(%esi),%dl                # index to "D"
-
-        movl (%ebp,%edx,4),%ecx         # ecx = [xx][D2][D1][D0]
-        shll $8,%ecx                    # ecx = [D2][D1][D0][xx]
-
-        movb 2(%esi),%dl                # index to "C"
-
-        movb 1(%ebp,%edx,4),%ah         # eax = [B2][B1][C1][xx]
-        movb (%ebp,%edx,4),%al          # eax = [B2][B1][C1][C0]
-        rorl $16,%eax                   # eax = [C1][C0][B2][B1] (done)
-
-        movb 2(%ebp,%edx,4),%cl         # ecx = [D2][D1][D0][C2] (done)
-
-        movl %eax,4(%edi)
-        movl %ecx,8(%edi)
-
-        addl $4,%esi
-        addl $3*4,%edi
-
-        popl %ecx                       # restore ecx
-
-        decl %ecx
-        jnz _ConvertX86pI8_24.L5
-
-        # tail
-        popl %ecx
-        andl $0b11,%ecx
-        jz _ConvertX86pI8_24.L7
-
-_ConvertX86pI8_24.L6:
-        movb (%esi),%dl
-        movl (%ebx,%edx,4),%eax
-        movb %al,(%edi) # blue
-        movb %ah,1(%edi)# green
-        shrl $16,%eax
-        movb %al,2(%edi)# red
-        incl %esi
-        addl $3,%edi
-        decl %ecx
-        jnz _ConvertX86pI8_24.L6
-
-_ConvertX86pI8_24.L7: popl %ebp
-        jmp _x86return
-
-
-.align 8
-_ConvertX86pI8_16:
-        xorl %ebx,%ebx
-        movl 36(%ebp),%edx
-
-        testl $3,%edi
-        jz _ConvertX86pI8_16.Laligned
-
-        movb (%esi),%bl
-
-        movl (%edx,%ebx,4),%eax
-        incl %esi
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-        decl %ecx
-        jz _ConvertX86pI8_16.out
-
-_ConvertX86pI8_16.Laligned:
-        pushl %ecx
-
-        xorl %eax,%eax
-        xorl %ebx,%ebx
-
-        shrl %ecx
-        jz _ConvertX86pI8_16.last_pixel
-.align 8
-_ConvertX86pI8_16.Ly:
-        movb 1(%esi),%bl
-        movb (%esi),%al
-
-        movl (%edx,%ebx,4),%ebx
-        addl $2,%esi
-
-        shll $16,%ebx
-        movl (%edx,%eax,4),%eax
-
-        orl %ebx,%eax
-        xorl %ebx,%ebx
-
-        movl %eax,(%edi)
-        addl $4,%edi
-
-        xorl %eax,%eax
-        decl %ecx
-        jnz _ConvertX86pI8_16.Ly
-
-_ConvertX86pI8_16.last_pixel:
-        popl %ecx
-
-        testb $1,%cl
-        jz _ConvertX86pI8_16.out
-
-        movb (%esi),%bl
-
-        movl (%edx,%ebx,4),%eax
-        incl %esi
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-_ConvertX86pI8_16.out:
-        jmp _x86return

+ 238 - 0
packages/hermes/src/i386/x86p_i8.inc

@@ -0,0 +1,238 @@
+{
+    x86 format converters for HERMES
+    Copyright (c) 1998 Christian Nentwich ([email protected])
+    Some routines are (c) Glenn Fiedler ([email protected]), used with permission
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+
+
+{ Convert_*
+ Paramters:
+   ESI = source
+   EDI = dest
+   ECX = amount (NOT 0!!! (the ConvertX86 routine checks for that though))
+ Destroys:
+   EAX, EBX, EDX
+}
+
+procedure ConvertX86pI8_32(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        xorl %ebx,%ebx
+        movl 36(%ebp),%edx
+.L1:
+        movb (%esi),%bl
+        incl %esi
+
+        movl (%edx,%ebx,4),%eax
+
+        movl %eax,(%edi)
+        addl $4,%edi
+
+        decl %ecx
+        jnz .L1
+
+        jmp _X86RETURN
+end;
+
+
+procedure ConvertX86pI8_24(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        movl 36(%ebp),%ebx
+
+        xorl %edx,%edx
+
+        // check short
+        cmpl $32,%ecx
+        ja .L3
+
+
+.L1:  // short loop
+        movb (%esi),%dl
+        movl (%ebx,%edx,4),%eax
+        movb %al,(%edi)  // blue
+        movb %ah,1(%edi) // green
+        shrl $16,%eax
+        movb %al,2(%edi) // red
+        incl %esi
+        addl $3,%edi
+        decl %ecx
+        jnz .L1
+.L2:
+        jmp _X86RETURN
+
+.L3:  // head
+        movl %edi,%eax
+        andl $0b11,%eax
+        jz .L4
+        movb (%esi),%dl
+        movl (%ebx,%edx,4),%eax
+        movb %al,(%edi)  // blue
+        movb %ah,1(%edi) // green
+        shrl $16,%eax
+        movb %al,2(%edi) // red
+        incl %esi
+        addl $3,%edi
+        decl %ecx
+        jmp .L3
+
+.L4:    // save ebp
+        pushl %ebp
+        movl %ebx,%ebp
+
+        // save count
+        pushl %ecx
+
+        // unroll 4 times
+        shrl $2,%ecx
+
+.L5:    pushl %ecx                      // save ecx
+        movb (%esi),%dl                 // index to "A"
+
+        movl (%ebp,%edx,4),%eax         // eax = [xx][A2][A1][A0]
+        shll $8,%eax                    // eax = [A2][A1][A0][xx]
+
+        movb 1(%esi),%dl                // index to "B"
+
+        movb (%ebp,%edx,4),%al          // eax = [A2][A1][A0][B0]
+        rorl $8,%eax                    // eax = [B0][A2][A1][A0] (done)
+        movl %eax,(%edi)
+
+        movl (%ebp,%edx,4),%eax         // eax = [xx][B2][B1][B0]
+        shll $8,%eax                    // eax = [B2][B1][B0][xx]
+
+        movb 3(%esi),%dl                // index to "D"
+
+        movl (%ebp,%edx,4),%ecx         // ecx = [xx][D2][D1][D0]
+        shll $8,%ecx                    // ecx = [D2][D1][D0][xx]
+
+        movb 2(%esi),%dl                // index to "C"
+
+        movb 1(%ebp,%edx,4),%ah         // eax = [B2][B1][C1][xx]
+        movb (%ebp,%edx,4),%al          // eax = [B2][B1][C1][C0]
+        rorl $16,%eax                   // eax = [C1][C0][B2][B1] (done)
+
+        movb 2(%ebp,%edx,4),%cl         // ecx = [D2][D1][D0][C2] (done)
+
+        movl %eax,4(%edi)
+        movl %ecx,8(%edi)
+
+        addl $4,%esi
+        addl $3*4,%edi
+
+        popl %ecx                       // restore ecx
+
+        decl %ecx
+        jnz .L5
+
+        // tail
+        popl %ecx
+        andl $0b11,%ecx
+        jz .L7
+
+.L6:
+        movb (%esi),%dl
+        movl (%ebx,%edx,4),%eax
+        movb %al,(%edi)  // blue
+        movb %ah,1(%edi) // green
+        shrl $16,%eax
+        movb %al,2(%edi) // red
+        incl %esi
+        addl $3,%edi
+        decl %ecx
+        jnz .L6
+
+.L7:    popl %ebp
+        jmp _X86RETURN
+end;
+
+procedure ConvertX86pI8_16(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        xorl %ebx,%ebx
+        movl 36(%ebp),%edx
+
+        testl $3,%edi
+        jz .Laligned
+
+        movb (%esi),%bl
+
+        movl (%edx,%ebx,4),%eax
+        incl %esi
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+        decl %ecx
+        jz .LOut
+
+.Laligned:
+        pushl %ecx
+
+        xorl %eax,%eax
+        xorl %ebx,%ebx
+
+        shrl $1,%ecx
+        jz .Last_pixel
+.balign 8
+.Ly:
+        movb 1(%esi),%bl
+        movb (%esi),%al
+
+        movl (%edx,%ebx,4),%ebx
+        addl $2,%esi
+
+        shll $16,%ebx
+        movl (%edx,%eax,4),%eax
+
+        orl %ebx,%eax
+        xorl %ebx,%ebx
+
+        movl %eax,(%edi)
+        addl $4,%edi
+
+        xorl %eax,%eax
+        decl %ecx
+        jnz .Ly
+
+.Last_pixel:
+        popl %ecx
+
+        testb $1,%cl
+        jz .LOut
+
+        movb (%esi),%bl
+
+        movl (%edx,%ebx,4),%eax
+        incl %esi
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+.LOut:
+        jmp _X86RETURN
+end;

+ 0 - 114
packages/hermes/src/i386/x86p_s32.as

@@ -1,114 +0,0 @@
-
-
-
-.globl _ConvertX86p32_16RGB565_S
-
-.text
-
-.extern _x86return_S
-
-## _Convert*_S
-## Paramters:
-##   ESI = source
-##   EDI = dest
-##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
-##   EDX = x increment
-## Destroys:
-##   EAX, EBX, ECX, EDX
-
-
-_ConvertX86p32_16RGB565_S:
-
-        pushl %ebp
-        pushl %edx              # increment now at [esp+4]!
-
-        movl $0,%ebp
-
-        pushl %ecx
-        shrl %ecx
-        jnz _ConvertX86p32_16RGB565_S.L_ok
-        jmp _ConvertX86p32_16RGB565_S.L_final
-
-_ConvertX86p32_16RGB565_S.L_ok:
-
-.align 8
-_ConvertX86p32_16RGB565_S.Lx:
-        movl %ebp,%eax
-
-        shrl $14,%eax
-        addl 4(%esp),%ebp
-
-        movl %ebp,%edx
-        andl $0x0fffffffc,%eax
-
-        shrl $14,%edx
-        movl (%esi,%eax,),%ebx  # ebx = pixel one
-
-        andl $0x0fffffffc,%edx
-        andl $0x0f8fcf8,%ebx
-
-        shrb $2,%bh
-        movl (%esi,%edx,),%eax  # eax = pixel two
-
-        andl $0x0f8fcf8,%eax
-        addl 4(%esp),%ebp
-
-        shrb $2,%ah             # eax & ebx= rrrrr000|00gggggg|bbbbb000
-
-        movl %eax,%edx
-
-        shrw $3,%dx
-        andl $0x0f80000,%eax
-
-        shrl $8,%eax
-
-        orl %edx,%eax
-
-        shll $16,%eax
-        movl %ebx,%edx
-
-        shrw $3,%dx
-        andl $0x0f80000,%ebx
-
-        shrl $8,%ebx
-        orb %dh,%ah
-
-        orb %bh,%ah
-        orb %dl,%al
-
-        movl %eax,(%edi)
-        addl $4,%edi
-
-        decl %ecx
-        jnz _ConvertX86p32_16RGB565_S.Lx
-
-_ConvertX86p32_16RGB565_S.L_final:
-        popl %ecx
-        andl $1,%ecx
-        jz _ConvertX86p32_16RGB565_S.L_out
-
-        shrl $14,%ebp           # trailing pixel
-
-        andl $0x0fffffffc,%ebp
-
-        movl (%esi,%ebp,),%eax
-        movl (%esi,%ebp,),%ebx
-
-        shrl $8,%ebx
-        andl $0x0fcf8,%eax
-
-        shrb $2,%ah
-        andl $0x0f800,%ebx
-
-        shrl $3,%eax
-
-        orl %ebx,%eax
-
-        movw %ax,(%edi)
-        addl $2,%edi
-
-_ConvertX86p32_16RGB565_S.L_out:
-
-        popl %edx
-        popl %ebp
-        jmp _x86return_S

+ 140 - 0
packages/hermes/src/i386/x86p_s32.inc

@@ -0,0 +1,140 @@
+{
+    x86 format converters for HERMES
+    Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
+    Some routines are (c) Glenn Fiedler ([email protected]), used with permission
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+
+
+{ _Convert*_S
+ Paramters:
+   ESI = source
+   EDI = dest
+   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
+   EDX = x increment
+ Destroys:
+   EAX, EBX, ECX, EDX
+}
+
+procedure ConvertX86p32_16RGB565_S(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        pushl %ebp
+        pushl %edx              // increment now at [esp+4]!
+
+        movl $0,%ebp
+
+        pushl %ecx
+        shrl $1,%ecx
+        jnz .L_ok
+        jmp .L_final
+
+.L_ok:
+
+.balign 8
+.Lx:
+        movl %ebp,%eax
+
+        shrl $14,%eax
+        addl 4(%esp),%ebp
+
+        movl %ebp,%edx
+        andl $0x0fffffffc,%eax
+
+        shrl $14,%edx
+        movl (%esi,%eax),%ebx  // ebx = pixel one
+
+        andl $0x0fffffffc,%edx
+        andl $0x0f8fcf8,%ebx
+
+        shrb $2,%bh
+        movl (%esi,%edx),%eax  // eax = pixel two
+
+        andl $0x0f8fcf8,%eax
+        addl 4(%esp),%ebp
+
+        shrb $2,%ah             // eax & ebx= rrrrr000|00gggggg|bbbbb000
+
+        movl %eax,%edx
+
+        shrw $3,%dx
+        andl $0x0f80000,%eax
+
+        shrl $8,%eax
+
+        orl %edx,%eax
+
+        shll $16,%eax
+        movl %ebx,%edx
+
+        shrw $3,%dx
+        andl $0x0f80000,%ebx
+
+        shrl $8,%ebx
+        orb %dh,%ah
+
+        orb %bh,%ah
+        orb %dl,%al
+
+        movl %eax,(%edi)
+        addl $4,%edi
+
+        decl %ecx
+        jnz .Lx
+
+.L_final:
+        popl %ecx
+        andl $1,%ecx
+        jz .L_out
+
+        shrl $14,%ebp           // trailing pixel
+
+        andl $0x0fffffffc,%ebp
+
+        movl (%esi,%ebp),%eax
+        movl (%esi,%ebp),%ebx
+
+        shrl $8,%ebx
+        andl $0x0fcf8,%eax
+
+        shrb $2,%ah
+        andl $0x0f800,%ebx
+
+        shrl $3,%eax
+
+        orl %ebx,%eax
+
+        movw %ax,(%edi)
+        addl $2,%edi
+
+.L_out:
+
+        popl %edx
+        popl %ebp
+        jmp _X86RETURN_S
+end;

+ 0 - 40
packages/hermes/src/i386/x86pscpy.as

@@ -1,40 +0,0 @@
-
-
-
-.globl _CopyX86p_4byte_S
-.globl _CopyX86p_3byte_S
-.globl _CopyX86p_2byte_S
-.globl _CopyX86p_1byte_S
-
-.extern _x86return
-
-
-.text
-
-## _Copy*
-## Paramters:
-##   ESI = source
-##   EDI = dest
-##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
-## Destroys:
-##   EAX, EBX, EDX
-
-_CopyX86p_4byte_S:
-
-
-        jmp _x86return_S
-
-
-_CopyX86p_3byte_S:
-
-        jmp _x86return_S
-
-
-
-_CopyX86p_2byte_S:
-
-        jmp _x86return_S
-
-_CopyX86p_1byte_S:
-
-        jmp _x86return_S

+ 60 - 0
packages/hermes/src/i386/x86pscpy.inc

@@ -0,0 +1,60 @@
+{
+    x86 format converters for HERMES
+    Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
+    Some routines are (c) Glenn Fiedler ([email protected]), used with permission
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version
+    with the following modification:
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,and
+    to copy and distribute the resulting executable under terms of your choice,
+    provided that you also meet, for each linked independent module, the terms
+    and conditions of the license of that module. An independent module is a
+    module which is not derived from or based on this library. If you modify
+    this library, you may extend this exception to your version of the library,
+    but you are not obligated to do so. If you do not wish to do so, delete this
+    exception statement from your version.
+
+    This library 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.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+{ _Copy*
+ Paramters:
+   ESI = source
+   EDI = dest
+   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
+ Destroys:
+   EAX, EBX, EDX
+}
+
+procedure CopyX86p_4byte_S(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        jmp _X86RETURN_S
+end;
+
+procedure CopyX86p_3byte_S(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        jmp _X86RETURN_S
+end;
+
+procedure CopyX86p_2byte_S(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        jmp _X86RETURN_S
+end;
+
+procedure CopyX86p_1byte_S(CONVERT_PARAMETERS); cdecl; nostackframe; assembler;
+asm
+        jmp _X86RETURN_S
+end;

+ 63 - 63
packages/libxml/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/01/10]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -267,190 +267,190 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(F
 override PACKAGE_NAME=libxml2
 override PACKAGE_NAME=libxml2
 override PACKAGE_VERSION=2.5.1
 override PACKAGE_VERSION=2.5.1
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-haiku)
 ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-nativent)
 ifeq ($(FULL_TARGET),i386-nativent)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-iphonesim)
 ifeq ($(FULL_TARGET),i386-iphonesim)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 ifeq ($(FULL_TARGET),x86_64-solaris)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-darwin)
 ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
 ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-linux)
 ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),mipsel-linux)
 ifeq ($(FULL_TARGET),mipsel-linux)
-override TARGET_UNITS+=xml2 xmlxsd
+override TARGET_UNITS+=xml2 xmlxsdparser xmlxsd
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_EXAMPLEDIRS+=examples
 override TARGET_EXAMPLEDIRS+=examples

+ 1 - 1
packages/libxml/Makefile.fpc

@@ -7,7 +7,7 @@ name=libxml2
 version=2.5.1
 version=2.5.1
 
 
 [target]
 [target]
-units=xml2 xmlxsd
+units=xml2 xmlxsdparser xmlxsd
 exampledirs=examples
 exampledirs=examples
 
 
 [require]
 [require]

+ 3 - 0
packages/libxml/fpmake.pp

@@ -71,6 +71,9 @@ begin
       AddInclude('schematron.inc');
       AddInclude('schematron.inc');
     end;
     end;
 
 
+  T:=P.Targets.AddUnit('xmlxsdparser.pas');
+  T.ResourceStrings := True;
+
   T:=P.Targets.AddUnit('xmlxsd.pas');
   T:=P.Targets.AddUnit('xmlxsd.pas');
   T.ResourceStrings := True;
   T.ResourceStrings := True;
 
 

File diff suppressed because it is too large
+ 51 - 1772
packages/libxml/src/xmlxsd.pas


+ 1768 - 0
packages/libxml/src/xmlxsdparser.pas

@@ -0,0 +1,1768 @@
+{
+  Parser functions to parser xml xsd types
+  See: http://books.xmlschemata.org/relaxng/relax-CHP-19.html
+
+  Copyright (C) 2011 by Ivo Steinmann
+}
+
+unit xmlxsdparser;
+
+{$mode objfpc}
+{$H+}
+
+interface
+
+uses
+  sysutils,
+  dateutils,
+  math,
+  Classes;
+
+resourcestring
+  SXsdParserError = 'parsing "%s" as "%s" failed';
+
+type
+  TXsdTimezoneType = (
+    tzUnknown,
+    tzUTC,
+    tzUser
+  );
+
+  PXsdTimezone = ^TXsdTimezone;
+  TXsdTimezone = record
+    Kind   : TXsdTimezoneType;
+    Hour   : Longint;  // +/- [00..23]
+    Minute : Longword; // [00..59]
+    Convert: Boolean;  // you have to initialize this field allways!!!
+  end;
+
+const
+  TIMEZONE_UTC: TXsdTimezone = (Kind:tzUTC;Hour:0;Minute:0;Convert:False);
+  TIMEZONE_UNKNOWN: TXsdTimezone = (Kind:tzUnknown;Hour:0;Minute:0;Convert:False);
+  CONVERT_TO_TIMEZONE_UTC: TXsdTimezone = (Kind:tzUTC;Hour:0;Minute:0;Convert:True);
+
+{ Format functions }
+function xsdFormatBase64(Value: TStream): Utf8String;
+function xsdFormatBoolean(Value: Boolean; UseWords: Boolean = False): Utf8String;
+function xsdFormatDate(Year, Month, Day: Longword; BC: Boolean; Timezone: PXsdTimezone = nil): Utf8String;
+function xsdFormatDate(Value: TDateTime; Timezone: PXsdTimezone = nil): Utf8String;
+function xsdFormatTime(Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil): Utf8String;
+function xsdFormatTime(Value: TDateTime; Timezone: PXsdTimezone = nil): Utf8String;
+function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PXsdTimezone = nil): Utf8String;
+function xsdFormatDateTime(Value: TDateTime; Timezone: PXsdTimezone): Utf8String;
+function xsdFormatDecimal(Value: Extended; Precision: Integer = 4; Digits: Integer = 1): Utf8String;
+function xsdFormatDouble(Value: Double): Utf8String;
+function xsdFormatFloat(Value: Single): Utf8String;
+function xsdFormatByte(Value: Shortint): Utf8String;
+function xsdFormatShort(Value: Smallint): Utf8String;
+function xsdFormatInt(Value: Longint): Utf8String;
+function xsdFormatLong(Value: Int64): Utf8String;
+function xsdFormatUnsignedByte(Value: Byte): Utf8String;
+function xsdFormatUnsignedShort(Value: Word): Utf8String;
+function xsdFormatUnsignedInt(Value: Longword): Utf8String;
+function xsdFormatUnsignedLong(Value: QWord): Utf8String;
+function xsdFormatEnum(enum: array of Utf8String; Value: Integer): Utf8String;
+
+{ DateTime functions }
+procedure xsdTimeConvertTo(var Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TXsdTimezone);
+procedure xsdDateConvertTo(var Year, Month, Day: Longword; const Current, Target: TXsdTimezone);
+procedure xsdDateTimeConvertTo(var Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TXsdTimezone);
+
+{ Parse functions }
+function xsdTryParseBase64(Chars: PChar; Len: Integer; const Value: TStream): Boolean;
+function xsdTryParseString(Chars: PChar; Len: Integer; out Value: Utf8String): Boolean;
+function xsdTryParseStringLower(Chars: PChar; Len: Integer; out Value: Utf8String): Boolean;
+function xsdTryParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean): Boolean;
+function xsdTryParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil): Boolean;
+function xsdTryParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
+function xsdTryParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil): Boolean;
+function xsdTryParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
+function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil): Boolean;
+function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
+function xsdTryParseDecimal(Chars: PChar; Len: Integer; out Value: Extended): Boolean;
+function xsdTryParseDouble(Chars: PChar; Len: Integer; out Value: Double): Boolean;
+function xsdTryParseFloat(Chars: PChar; Len: Integer; out Value: Single): Boolean;
+function xsdTryParseInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+function xsdTryParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
+function xsdTryParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+function xsdTryParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+function xsdTryParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
+function xsdTryParseByte(Chars: PChar; Len: Integer; out Value: Shortint): Boolean;
+function xsdTryParseShort(Chars: PChar; Len: Integer; out Value: Smallint): Boolean;
+function xsdTryParseInt(Chars: PChar; Len: Integer; out Value: Longint): Boolean;
+function xsdTryParseLong(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+function xsdTryParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte): Boolean;
+function xsdTryParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word): Boolean;
+function xsdTryParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword): Boolean;
+function xsdTryParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
+function xsdTryParseEnum(Chars: PChar; Len: Integer; enum: array of Utf8String; out Value: Integer): Boolean;
+
+function xsdParseStringDef(Chars: PChar; Len: Integer; Default: Utf8String): Utf8String;
+function xsdParseStringLowerDef(Chars: PChar; Len: Integer; Default: Utf8String): Utf8String;
+function xsdParseBooleanDef(Chars: PChar; Len: Integer; Default: Boolean): Boolean;
+function xsdParseDateDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
+function xsdParseTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
+function xsdParseDateTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
+function xsdParseDecimalDef(Chars: PChar; Len: Integer; Default: Extended): Extended;
+function xsdParseDoubleDef(Chars: PChar; Len: Integer; Default: Double): Double;
+function xsdParseFloatDef(Chars: PChar; Len: Integer; Default: Single): Single;
+function xsdParseIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+function xsdParseNonNegativeIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
+function xsdParseNonPositiveIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+function xsdParseNegativeIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+function xsdParsePositiveIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
+function xsdParseByteDef(Chars: PChar; Len: Integer; Default: Shortint): Shortint;
+function xsdParseShortDef(Chars: PChar; Len: Integer; Default: Smallint): Smallint;
+function xsdParseIntDef(Chars: PChar; Len: Integer; Default: Longint): Longint;
+function xsdParseLongDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+function xsdParseUnsignedByteDef(Chars: PChar; Len: Integer; Default: Byte): Byte;
+function xsdParseUnsignedShortDef(Chars: PChar; Len: Integer; Default: Word): Word;
+function xsdParseUnsignedIntDef(Chars: PChar; Len: Integer; Default: Longword): Longword;
+function xsdParseUnsignedLongDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
+function xsdParseEnumDef(Chars: PChar; Len: Integer; enum: array of Utf8String; Default: Integer): Integer;
+
+procedure xsdParseBase64(Chars: PChar; Len: Integer; const Value: TStream);
+procedure xsdParseString(Chars: PChar; Len: Integer; out Value: Utf8String);
+procedure xsdParseStringLower(Chars: PChar; Len: Integer; out Value: Utf8String);
+procedure xsdParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean);
+procedure xsdParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil);
+procedure xsdParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil);
+procedure xsdParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil);
+procedure xsdParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil);
+procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil);
+procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil);
+procedure xsdParseDecimal(Chars: PChar; Len: Integer; out Value: Extended);
+procedure xsdParseDouble(Chars: PChar; Len: Integer; out Value: Double);
+procedure xsdParseFloat(Chars: PChar; Len: Integer; out Value: Single);
+procedure xsdParseInteger(Chars: PChar; Len: Integer; out Value: Int64);
+procedure xsdParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord);
+procedure xsdParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64);
+procedure xsdParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64);
+procedure xsdParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord);
+procedure xsdParseByte(Chars: PChar; Len: Integer; out Value: Shortint);
+procedure xsdParseShort(Chars: PChar; Len: Integer; out Value: Smallint);
+procedure xsdParseInt(Chars: PChar; Len: Integer; out Value: Longint);
+procedure xsdParseLong(Chars: PChar; Len: Integer; out Value: Int64);
+procedure xsdParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte);
+procedure xsdParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word);
+procedure xsdParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword);
+procedure xsdParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord);
+procedure xsdParseEnum(Chars: PChar; Len: Integer; enum: array of Utf8String; out Value: Integer);
+
+function xsdParseString(Chars: PChar; Len: Integer): Utf8String;
+function xsdParseStringLower(Chars: PChar; Len: Integer): Utf8String;
+function xsdParseBoolean(Chars: PChar; Len: Integer): Boolean;
+function xsdParseDate(Chars: PChar; Len: Integer; Timezone: PXsdTimezone = nil): TDateTime;
+function xsdParseTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone = nil): TDateTime;
+function xsdParseDateTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone = nil): TDateTime;
+function xsdParseDecimal(Chars: PChar; Len: Integer): Extended;
+function xsdParseDouble(Chars: PChar; Len: Integer): Double;
+function xsdParseFloat(Chars: PChar; Len: Integer): Single;
+function xsdParseInteger(Chars: PChar; Len: Integer): Int64;
+function xsdParseNonNegativeInteger(Chars: PChar; Len: Integer): QWord;
+function xsdParseNonPositiveInteger(Chars: PChar; Len: Integer): Int64;
+function xsdParseNegativeInteger(Chars: PChar; Len: Integer): Int64;
+function xsdParsePositiveInteger(Chars: PChar; Len: Integer): QWord;
+function xsdParseByte(Chars: PChar; Len: Integer): Shortint;
+function xsdParseShort(Chars: PChar; Len: Integer): Smallint;
+function xsdParseInt(Chars: PChar; Len: Integer): Longint;
+function xsdParseLong(Chars: PChar; Len: Integer): Int64;
+function xsdParseUnsignedByte(Chars: PChar; Len: Integer): Byte;
+function xsdParseUnsignedShort(Chars: PChar; Len: Integer): Word;
+function xsdParseUnsignedInt(Chars: PChar; Len: Integer): Longword;
+function xsdParseUnsignedLong(Chars: PChar; Len: Integer): QWord;
+function xsdParseEnum(Chars: PChar; Len: Integer; enum: array of Utf8String): Integer;
+
+
+{ INTERNAL HELPERS!!! }
+const
+  XSD_IGNORE_LAST = Pointer(-1); // maybe used as L parameter if the string is zero terminated
+
+function __parseNonNegativeInteger(var P: PChar; const L: PChar; out Value: QWord): Boolean;
+function __parseInteger(var P: PChar; const L: PChar; out Value: Int64): Boolean;
+function __parseFloat(var P: PChar; const L: PChar; out Value: Extended): Boolean;
+function __parseTimezone(var P: PChar; const L: PChar; out T: TXsdTimezone): Boolean;
+function __parseDate(var P: PChar; const L: PChar; out Year, Month, Day: Longword; BC: PBoolean): Boolean;
+function __parseTime(var P: PChar; const L: PChar; const AllowMoreThan24h: Boolean;
+  out Hour, Minute, Second, Milliseconds: Longword): Boolean;
+function __strpas(Chars: PChar; Len: Integer): Utf8String;
+
+implementation
+
+function xsdFormatBase64(Value: TStream): Utf8String;
+const
+  Base64: array[0..63] of char = (
+    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
+    'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
+    'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
+    'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
+  );
+  BufferSize = 3*512; { buffer size must be a multiple of 3 }
+var
+  Buffer: array[0..BufferSize-1] of Byte;
+  Num, Ofs: Integer;
+  b1, b2, b3: Byte;
+begin
+  Result := '';
+  while True do
+  begin
+    Num := Value.Read(Buffer, BufferSize);
+    if Num = 0 then
+      Exit;
+
+    Ofs := 0;
+    while Num >= 3 do
+    begin
+      b1 := Buffer[Ofs];
+      b2 := Buffer[Ofs+1];
+      b3 := Buffer[Ofs+2];
+
+      Result := Result +
+        Base64[b1 shr 2] +
+        Base64[((b1 and $3) shl 4) or (b2 shr 4)] +
+        Base64[((b2 and $F) shl 2) or (b3 shr 6)] +
+        Base64[b3 and $3F];
+
+      Num := Num - 3;
+      Ofs := Ofs + 3;
+    end;
+
+    case Num of
+      1: begin
+        b1 := Buffer[Ofs];
+
+        Result := Result +
+          Base64[b1 shr 2] +
+          Base64[((b1 and $3) shl 4)] +
+          '==';
+
+        Exit;
+      end;
+
+      2: begin
+        b1 := Buffer[Ofs];
+        b2 := Buffer[Ofs+1];
+
+        Result := Result +
+          Base64[b1 shr 2] +
+          Base64[((b1 and $3) shl 4) or (b2 shr 4)] +
+          Base64[((b2 and $F) shl 2)] +
+          '=';
+
+        Exit;
+      end;
+    end;
+  end;
+end;
+
+function xsdFormatBoolean(Value: Boolean; UseWords: Boolean): Utf8String;
+begin
+  if UseWords then
+    if Value then
+      Result := 'true'
+    else
+      Result := 'false'
+  else
+    if Value then
+      Result := '1'
+    else
+      Result := '0';
+end;
+
+function xsdFormatDate(Year, Month, Day: Longword; BC: Boolean; Timezone: PXsdTimezone): Utf8String;
+begin
+  Result := Format('%4.4d-%2.2u-%2.2u', [Year, Month, Day]);
+  if BC then
+    Result := '-' + Result;
+
+  if Assigned(Timezone) then
+    case Timezone^.Kind of
+      tzUTC:
+        Result := Result + 'Z';
+      tzUser:
+        begin
+          if Timezone^.Hour >= 0 then
+            Result := Result + '+'
+          else
+            Result := Result + '-';
+          Result := Result + Format('%2.2d:%2.2u', [Timezone^.Hour, Timezone^.Minute]);
+        end;
+    end;
+end;
+
+function xsdFormatDate(Value: TDateTime; Timezone: PXsdTimezone): Utf8String;
+var
+  Year, Month, Day: Word;
+begin
+  DecodeDate(Value, Year, Month, Day);
+  Result := xsdFormatDate(Year, Month, Day, False, Timezone);
+end;
+
+function xsdFormatTime(Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone): Utf8String;
+begin
+  Result := Format('%2.2u:%2.2u:%2.2u', [Hour, Minute, Second]);
+  if Milliseconds > 0 then
+    Result := Result + '.' + IntToStr(Milliseconds);
+
+  if Assigned(Timezone) then
+    case Timezone^.Kind of
+      tzUTC:
+        Result := Result + 'Z';
+      tzUser:
+        begin
+          if Timezone^.Hour >= 0 then
+            Result := Result + '+'
+          else
+            Result := Result + '-';
+          Result := Result + Format('%2.2d:%2.2u', [Timezone^.Hour, Timezone^.Minute]);
+        end;
+    end;
+end;
+
+function xsdFormatTime(Value: TDateTime; Timezone: PXsdTimezone): Utf8String;
+var
+  Hour, Minute, Second, Milliseconds: Word;
+begin
+  DecodeTime(Value, Hour, Minute, Second, Milliseconds);
+  Result := xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
+end;
+
+function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PXsdTimezone): Utf8String;
+begin
+  Result := xsdFormatDate(Year, Month, Day, BC, nil) + 'T' + xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
+end;
+
+function xsdFormatDateTime(Value: TDateTime; Timezone: PXsdTimezone): Utf8String;
+var
+  Year, Month, Day, Hour, Minute, Second, Milliseconds: Word;
+begin
+  DecodeDateTime(Value, Year, Month, Day, Hour, Minute, Second, Milliseconds);
+  Result := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, False, Timezone);
+end;
+
+function xsdFormatDecimal(Value: Extended; Precision: Integer; Digits: Integer): Utf8String;
+begin
+  Result := FloatToStrF(Value, ffFixed, Precision, Digits);
+end;
+
+function xsdFormatDouble(Value: Double): Utf8String;
+begin
+  Result := FloatToStr(Value);
+end;
+
+function xsdFormatFloat(Value: Single): Utf8String;
+begin
+  Result := FloatToStr(Value);
+end;
+
+function xsdFormatByte(Value: Shortint): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatShort(Value: Smallint): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatInt(Value: Integer): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatLong(Value: Int64): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatUnsignedByte(Value: Byte): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatUnsignedShort(Value: Word): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatUnsignedInt(Value: Longword): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatUnsignedLong(Value: QWord): Utf8String;
+begin
+  Result := IntToStr(Value);
+end;
+
+function xsdFormatEnum(enum: array of Utf8String; Value: Integer): Utf8String;
+begin
+  Result := enum[Value];
+end;
+
+procedure xsdTimeConvertTo(var Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TXsdTimezone);
+begin
+  {$warning xsdTimeConvertTo: not implemented}
+end;
+
+procedure xsdDateConvertTo(var Year, Month, Day: Longword; const Current, Target: TXsdTimezone);
+begin
+  {$warning xsdDateConvertTo: not implemented}
+end;
+
+procedure xsdDateTimeConvertTo(var Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TXsdTimezone);
+begin
+  {$warning xsdDateTimeConvertTo: not implemented}
+end;
+
+function __parseNonNegativeInteger(var P: PChar; const L: PChar; out Value: QWord): Boolean;
+begin
+  { expect integer }
+  Value := 0;
+  while (P < L) and (P^ in ['0'..'9']) do
+  begin
+    Value := 10*Value + Ord(P^) - Ord('0');
+    Inc(P);
+  end;
+
+  Result := True;
+end;
+
+function __parseInteger(var P: PChar; const L: PChar; out Value: Int64): Boolean;
+var
+  N: Boolean;
+begin
+  { allow '-' }
+  N := (P < L) and (P^ = '-');
+  if N then
+    Inc(P);
+
+  { expect integer }
+  Value := 0;
+  while (P < L) and (P^ in ['0'..'9']) do
+  begin
+    Value := 10*Value + Ord(P^) - Ord('0');
+    Inc(P);
+  end;
+  if N then
+    Value := -Value;
+
+  Result := True;
+end;
+
+function __parseFloat(var P: PChar; const L: PChar; out Value: Extended): Boolean;
+var
+  N: Boolean;
+  Exp: Int64;
+  Int: QWord;
+begin
+  { allow 'Nan' }
+  if (P+2 < L) and ((P^ = 'N') or (P^ = 'n')) then
+  begin
+    Inc(P);
+    if (P^ <> 'A') and (P^ <> 'a') then Exit(False);
+    Inc(P);
+    if (P^ <> 'N') and (P^ <> 'n') then Exit(False);
+    Inc(P);
+    Value := Nan;
+    Result := True;
+    Exit;
+  end;
+
+  { allow '-' }
+  N := (P < L) and (P^ = '-');
+  if N then
+    Inc(P);
+
+  { allow 'Inf' }
+  if (P+2 < L) and ((P^ = 'I') or (P^ = 'i')) then
+  begin
+    Inc(P);
+    if (P^ <> 'N') and (P^ <> 'n') then Exit(False);
+    Inc(P);
+    if (P^ <> 'F') and (P^ <> 'f') then Exit(False);
+    Inc(P);
+    if N then
+      Value := NegInfinity
+    else
+      Value := Infinity;
+    Result := True;
+    Exit;
+  end;
+
+  { expect integer }
+  Int := 0;
+  while (P < L) and (P^ in ['0'..'9']) do
+  begin
+    Int := 10*Int + Ord(P^) - Ord('0');
+    Inc(P);
+  end;
+  Value := Int;
+
+  { allow '.' }
+  if (P < L) and (P^ = '.') then
+  begin
+    Inc(P);
+
+    { expect integer }
+    Exp := 1;
+    Int := 0;
+    while (P < L) and (P^ in ['0'..'9']) do
+    begin
+      Int := 10*Int + Ord(P^) - Ord('0');
+      Exp := 10*Exp;
+      Inc(P);
+    end;
+    Value := Value + Int / Exp;
+  end;
+
+  { allow 'E' or 'e' }
+  if (P < L) and ((P^ = 'E') or (P^ = 'e')) then
+  begin
+    Inc(P);
+
+    { expect integer }
+    if not __parseInteger(P, L, Exp) then
+      Exit(False);
+
+    while Exp > 0 do
+    begin
+      Value := Value * 10;
+      Dec(Exp);
+    end;
+
+    while Exp < 0 do
+    begin
+      Value := Value * 0.1;
+      Inc(Exp);
+    end;
+  end;
+
+  if N then
+    Value := -Value;
+
+  Result := True;
+end;
+
+function __parseTimezone(var P: PChar; const L: PChar; out T: TXsdTimezone): Boolean;
+var
+  I: Integer;
+  N: Boolean;
+begin
+  { allow 'Z' }
+  if (P < L) and (P^ = 'Z') then
+  begin
+    T.Kind := tzUTC;
+    T.Hour := 0;
+    T.Minute := 0;
+    Inc(P);
+  end else
+
+    { allow '+' or '-' }
+    if (P < L) and (P^ in ['+','-']) then
+    begin
+      N := P^ = '-';
+      Inc(P);
+
+      { expect 00..13 }
+      T.Hour := 0; I := 2;
+      while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
+      begin
+        T.Hour := 10*T.Hour + Ord(P^) - Ord('0');
+        Dec(I); Inc(P);
+      end;
+      if T.Hour > 13 then
+        Exit(False);
+      if N then
+        T.Hour := -T.Hour;
+
+      { expect ':' }
+      if (P >= L) or (P^ <> ':') then
+        Exit(False);
+      Inc(P);
+
+      { expect 00..59 }
+      T.Minute := 0; I := 2;
+      while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
+      begin
+        T.Minute := 10*T.Minute + Ord(P^) - Ord('0');
+        Dec(I); Inc(P);
+      end;
+      if T.Minute > 59 then
+        Exit(False);
+    end else
+
+      { unknown }
+      begin
+        T.Kind := tzUnknown;
+        T.Hour := 0;
+        T.Minute := 0;
+      end;
+
+  Result := True;
+end;
+
+function __parseDate(var P: PChar; const L: PChar; out Year, Month, Day: Longword; BC: PBoolean): Boolean;
+var
+  I: Integer;
+begin
+  { allow '-' }
+  if (P < L) and (P^ = '-') then
+  begin
+    if Assigned(BC) then
+      BC^ := True
+    else
+      Exit(False);
+    Inc(P);
+  end else
+    if Assigned(BC) then
+      BC^ := False;
+
+  { expect Integer }
+  Year := 0;
+  while (P < L) and (P^ in ['0'..'9']) do
+  begin
+    Year := 10*Year + Ord(P^) - Ord('0');
+    Inc(P);
+  end;
+
+  { expect '-' }
+  if (P >= L) or (P^ <> '-') then
+    Exit(False);
+  Inc(P);
+
+  { expect 01..12 }
+  Month := 0; I := 2;
+  while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
+  begin
+    Month := 10*Month + Ord(P^) - Ord('0');
+    Dec(I); Inc(P);
+  end;
+  if (Month < 1) or (Month > 12) then
+    Exit(False);
+
+  { expect '-' }
+  if (P >= L) or (P^ <> '-') then
+    Exit(False);
+  Inc(P);
+
+  { expect 01..31 }
+  Day := 0; I := 2;
+  while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
+  begin
+    Day := 10*Day + Ord(P^) - Ord('0');
+    Dec(I); Inc(P);
+  end;
+  if (Day < 1) or (Day > 31) then
+    Exit(False);
+
+  Result := True;
+end;
+
+function __parseTime(var P: PChar; const L: PChar; const AllowMoreThan24h: Boolean;
+  out Hour, Minute, Second, Milliseconds: Longword): Boolean;
+var
+  I: Integer;
+  Ms: Longword;
+begin
+  { expect 00..24 (except if AllowMoreThan24h) }
+  Hour := 0;
+  if AllowMoreThan24h then I := 9 { maximal 9 digits for hour } else I := 2;
+  while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
+  begin
+    Hour := 10*Hour + Ord(P^) - Ord('0');
+    Inc(P); Dec(I);
+  end;
+  if not AllowMoreThan24h and (Hour > 24) then
+    Exit(False);
+
+  { expect ':' }
+  if (P >= L) or (P^ <> ':') then
+    Exit(False);
+  Inc(P);
+
+  { expect 00..59 }
+  Minute := 0; I := 2;
+  while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
+  begin
+    Minute := 10*Minute + Ord(P^) - Ord('0');
+    Dec(I); Inc(P);
+  end;
+  if (Minute > 59) or (not AllowMoreThan24h and (Hour = 24) and (Minute > 0)) then
+    Exit(False);
+
+  { expect ':' }
+  if (P >= L) or (P^ <> ':') then
+    Exit(False);
+  Inc(P);
+
+  { expect 00..59 }
+  Second := 0; I := 2;
+  while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
+  begin
+    Second := 10*Second + Ord(P^) - Ord('0');
+    Dec(I); Inc(P);
+  end;
+  if (Second > 59) or (not AllowMoreThan24h and (Hour = 24) and (Second > 0)) then
+    Exit(False);
+
+  { allow '.' }
+  if (P < L) and (P^ = '.') then
+  begin
+    Inc(P);
+
+    { expect integer }
+    Ms := 0; I := 1;
+    while (P < L) and (P^ in ['0'..'9']) do
+    begin
+      Ms := 10*Ms + Ord(P^) - Ord('0');
+      I := 10*I;
+      Inc(P);
+    end;
+    Milliseconds := (1000*Ms) div I;
+    if (Milliseconds >= 999) or (not AllowMoreThan24h and (Hour = 24) and (Milliseconds > 0)) then
+      Exit(False);
+  end else
+    Milliseconds := 0;
+
+  Result := True;
+end;
+
+function xsdTryParseBase64(Chars: PChar; Len: Integer; const Value: TStream): Boolean;
+const
+  BufferSize = 3*512;
+var
+  Buffer: array[0..BufferSize-1] of Byte;
+  Ofs: Integer;
+  P,L: PByte;
+  p1,p2,p3,p4: Shortint;
+begin
+  if Assigned(Chars) then
+  begin
+    Ofs := 0;
+
+    P := PByte(Chars);
+    if Len >= 0 then
+    begin
+      if Len mod 4 <> 0 then
+        Exit(False);
+
+      L := P + Len;
+      while P < L do
+      begin
+        case Chr(P^) of
+          'A'..'Z': p1 := P^ - Ord('A');
+          'a'..'z': p1 := P^ - Ord('a') + 26;
+          '0'..'9': p1 := P^ - Ord('0') + 52;
+          '+' : p1 := 62;
+          '/' : p1 := 63;
+          else Exit(False);
+        end;
+        Inc(P);
+
+        case Chr(P^) of
+          'A'..'Z': p2 := P^ - Ord('A');
+          'a'..'z': p2 := P^ - Ord('a') + 26;
+          '0'..'9': p2 := P^ - Ord('0') + 52;
+          '+' : p2 := 62;
+          '/' : p2 := 63;
+          else Exit(False);
+        end;
+        Inc(P);
+
+        case Chr(P^) of
+          'A'..'Z': p3 := P^ - Ord('A');
+          'a'..'z': p3 := P^ - Ord('a') + 26;
+          '0'..'9': p3 := P^ - Ord('0') + 52;
+          '+' : p3 := 62;
+          '/' : p3 := 63;
+          '=' : p3 := -1;
+          else Exit(False);
+        end;
+        Inc(P);
+
+        if (p3 >= 0) then
+        begin
+          case Chr(P^) of
+            'A'..'Z': p4 := P^ - Ord('A');
+            'a'..'z': p4 := P^ - Ord('a') + 26;
+            '0'..'9': p4 := P^ - Ord('0') + 52;
+            '+' : p4 := 62;
+            '/' : p4 := 63;
+            '=' : p4 := -1;
+            else Exit(False);
+          end;
+        end else begin
+          if P^ <> Ord('=') then
+            Exit(False);
+          p4 := -1;
+        end;
+        Inc(P);
+
+        Buffer[Ofs] := (p1 shl 2) or (p2 shr 4);
+        Ofs := Ofs + 1;
+
+        if p3 >= 0 then
+        begin
+          Buffer[Ofs] := ((p2 and $F) shl 4) or (p3 shr 2);
+          Ofs := Ofs + 1;
+
+          if p4 >= 0 then
+          begin
+            Buffer[Ofs] := ((p3 and $3) shl 6) or p4;
+            Ofs := Ofs + 1;
+          end;
+        end;
+
+        if Ofs >= BufferSize-2 then
+        begin
+          Value.Write(Buffer, Ofs);
+          Ofs := 0;
+        end;
+      end;
+    end else begin
+      while P^ <> 0 do
+      begin
+        case Chr(P^) of
+          'A'..'Z': p1 := P^ - Ord('A');
+          'a'..'z': p1 := P^ - Ord('a') + 26;
+          '0'..'9': p1 := P^ - Ord('0') + 52;
+          '+' : p1 := 62;
+          '/' : p1 := 63;
+          else Exit(False);
+        end;
+        Inc(P);
+
+        case Chr(P^) of
+          'A'..'Z': p2 := P^ - Ord('A');
+          'a'..'z': p2 := P^ - Ord('a') + 26;
+          '0'..'9': p2 := P^ - Ord('0') + 52;
+          '+' : p2 := 62;
+          '/' : p2 := 63;
+          else Exit(False);
+        end;
+        Inc(P);
+
+        case Chr(P^) of
+          'A'..'Z': p3 := P^ - Ord('A');
+          'a'..'z': p3 := P^ - Ord('a') + 26;
+          '0'..'9': p3 := P^ - Ord('0') + 52;
+          '+' : p3 := 62;
+          '/' : p3 := 63;
+          '=' : p3 := -1;
+          else Exit(False);
+        end;
+        Inc(P);
+
+        if (p3 >= 0) then
+        begin
+          case Chr(P^) of
+            'A'..'Z': p4 := P^ - Ord('A');
+            'a'..'z': p4 := P^ - Ord('a') + 26;
+            '0'..'9': p4 := P^ - Ord('0') + 52;
+            '+' : p4 := 62;
+            '/' : p4 := 63;
+            '=' : p4 := -1;
+            else Exit(False);
+          end;
+        end else begin
+          if P^ <> Ord('=') then
+            Exit(False);
+          p4 := -1;
+        end;
+        Inc(P);
+
+        Buffer[Ofs] := (p1 shl 2) or (p2 shr 4);
+        Ofs := Ofs + 1;
+
+        if p3 >= 0 then
+        begin
+          Buffer[Ofs] := ((p2 and $F) shl 4) or (p3 shr 2);
+          Ofs := Ofs + 1;
+
+          if p4 >= 0 then
+          begin
+            Buffer[Ofs] := ((p3 and $3) shl 6) or p4;
+            Ofs := Ofs + 1;
+          end;
+        end;
+
+        if Ofs >= BufferSize-2 then
+        begin
+          Value.Write(Buffer, Ofs);
+          Ofs := 0;
+        end;
+      end;
+    end;
+
+    if Ofs > 0 then // flush
+      Value.Write(Buffer, Ofs);
+
+    Result := True;
+  end else
+    Result := False;
+end;
+
+function xsdTryParseString(Chars: PChar; Len: Integer; out Value: Utf8String): Boolean;
+const
+  AllocChars = 256;
+var
+  P,L,D: PByte;
+begin
+  if Assigned(Chars) then
+  begin
+    P := PByte(Chars);
+    if Len >= 0 then
+    begin
+      L := P + Len;
+      SetLength(Value, Len);
+      D := @Value[1];
+      while P < L do
+      begin
+        D^ := P^;
+        Inc(D);
+        Inc(P);
+      end;
+    end else begin
+      SetLength(Value, AllocChars);
+      D := @Value[1];
+      L := D + AllocChars;
+      while P^ <> 0 do
+      begin
+        if D = L then
+        begin
+          Len := Length(Value);
+          SetLength(Value, Len+AllocChars);
+          D := @Value[Len+1];
+          L := D + AllocChars;
+        end;
+        D^ := P^;
+        Inc(D);
+        Inc(P);
+      end;
+      SetLength(Value, P-PByte(Chars));
+    end;
+    Result := True;
+  end else
+    Result := False;
+end;
+{begin
+  if Assigned(Chars) then
+  begin
+    if Len >= 0 then
+    begin
+      SetLength(Value, Len);
+      Move(Chars^, Value[1], Len);
+    end else
+      Value := PChar(Chars);
+    Result := True;
+  end else
+    Result := False;
+end;}
+
+function xsdTryParseStringLower(Chars: PChar; Len: Integer; out Value: Utf8String): Boolean;
+const
+  AllocChars = 256;
+var
+  P,L,D: PByte;
+  C: Byte;
+begin
+  if Assigned(Chars) then
+  begin
+    P := PByte(Chars);
+    if Len >= 0 then
+    begin
+      L := P + Len;
+      SetLength(Value, Len);
+      D := @Value[1];
+      while P < L do
+      begin
+        C := P^;
+        if (C>=65) and (C<=90) then Inc(C, 32);
+        D^ := C;
+        Inc(D);
+        Inc(P);
+      end;
+    end else begin
+      SetLength(Value, AllocChars);
+      D := @Value[1];
+      L := D + AllocChars;
+      while P^ <> 0 do
+      begin
+        C := P^;
+        if (C>=65) and (C<=90) then Inc(C, 32);
+        if D = L then
+        begin
+          Len := Length(Value);
+          SetLength(Value, Len+AllocChars);
+          D := @Value[Len+1];
+          L := D + AllocChars;
+        end;
+        D^ := C;
+        Inc(D);
+        Inc(P);
+      end;
+      SetLength(Value, P-PByte(Chars));
+    end;
+    Result := True;
+  end else
+    Result := False;
+end;
+
+function __strpas(Chars: PChar; Len: Integer): Utf8String;
+begin
+  if not xsdTryParseString(Chars, Len, Result) then
+    Result := '';
+end;
+
+function xsdTryParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean): Boolean;
+var
+  P: PChar;
+  Num: QWord;
+begin
+  if not Assigned(Chars) then
+    Exit(False);
+
+  if Len < 0 then
+  begin
+    P := PChar(Chars);
+    Len := 0;
+    while (Len < 7) and (P^ <> #0) do
+    begin
+      Inc(Len);
+      Inc(P);
+    end;
+  end;
+
+  case Len of
+    1: Num := PByte(Chars)^;
+    4: Num := PLongword(Chars)^;
+    5: Num := PLongword(Chars)^ or (QWord(Chars[4]) shl 32);
+    else Exit(False);
+  end;
+
+  case Num of
+    $30,
+    $65736C6166,$65736C6146,$65736C4166,$65736C4146,$65734C6166,$65734C6146,$65734C4166,$65734C4146,
+    $65536C6166,$65536C6146,$65536C4166,$65536C4146,$65534C6166,$65534C6146,$65534C4166,$65534C4146,
+    $45736C6166,$45736C6146,$45736C4166,$45736C4146,$45734C6166,$45734C6146,$45734C4166,$45734C4146,
+    $45536C6166,$45536C6146,$45536C4166,$45536C4146,$45534C6166,$45534C6146,$45534C4166,$45534C4146:
+      Value := False;
+    $31,
+    $65757274,$65757254,$65755274,$65755254,$65557274,$65557254,$65555274,$65555254,
+    $45757274,$45757254,$45755274,$45755254,$45557274,$45557254,$45555274,$45555254:
+      Value := True;
+    else Exit(False);
+  end;
+
+  Result := True;
+end;
+
+function xsdTryParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone; BC: PBoolean): Boolean;
+var
+  P: PChar;
+  L: PChar;
+  T: TXsdTimezone;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and
+      __parseDate(P, L, Year, Month, Day, BC) and
+      __parseTimezone(P, L, T) and (P = L)
+  end else
+    Result := Assigned(P) and
+      __parseDate(P, XSD_IGNORE_LAST, Year, Month, Day, BC) and
+      __parseTimezone(P, XSD_IGNORE_LAST, T) and (P^ = #0);
+
+  { assign Timezone if requested }
+  if Result and Assigned(Timezone) then
+  begin
+    if Timezone^.Convert then
+      xsdDateConvertTo(Year, Month, Day, T, Timezone^)
+    else
+      Timezone^ := T;
+  end;
+end;
+
+function xsdTryParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone): Boolean;
+var
+  Year, Month, Day: Longword;
+begin
+  if xsdTryParseDate(Chars, Len, Year, Month, Day, Timezone, nil) then
+    Result := TryEncodeDate(Year, Month, Day, Value)
+  else
+    Result := False;
+end;
+
+function xsdTryParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone): Boolean;
+var
+  P: PChar;
+  L: PChar;
+  T: TXsdTimezone;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and
+      __parseTime(P, L, False, Hour, Minute, Second, Milliseconds) and
+      __parseTimezone(P, L, T) and (P = L)
+  end else
+    Result := Assigned(P) and
+      __parseTime(P, XSD_IGNORE_LAST, False, Hour, Minute, Second, Milliseconds) and
+      __parseTimezone(P, XSD_IGNORE_LAST, T) and (P^ = #0);
+
+  { assign Timezone if requested }
+  if Result and Assigned(Timezone) then
+  begin
+    if Timezone^.Convert then
+      xsdTimeConvertTo(Hour, Minute, Second, Milliseconds, T, Timezone^)
+    else
+      Timezone^ := T;
+  end;
+end;
+
+function xsdTryParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone): Boolean;
+var
+  Hour, Minute, Second, Milliseconds: Longword;
+begin
+  if xsdTryParseTime(Chars, Len, Hour, Minute, Second, Milliseconds, Timezone) then
+    Result := TryEncodeTime(Hour, Minute, Second, Milliseconds, Value)
+  else
+    Result := False;
+end;
+
+function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone; BC: PBoolean): Boolean;
+
+    function __parseT(var P: PChar; const L: PChar): Boolean;
+    begin
+      Result := (P < L) and (P^ = 'T');
+      if Result then Inc(P);
+    end;
+
+var
+  P: PChar;
+  L: PChar;
+  T: TXsdTimezone;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and
+      __parseDate(P, L, Year, Month, Day, BC) and
+      __parseT(P, L) and
+      __parseTime(P, L, False, Hour, Minute, Second, Milliseconds) and
+      __parseTimezone(P, L, T) and (P = L)
+  end else
+    Result := Assigned(P) and
+      __parseDate(P, XSD_IGNORE_LAST, Year, Month, Day, BC) and
+      __parseT(P, XSD_IGNORE_LAST) and
+      __parseTime(P, XSD_IGNORE_LAST, False, Hour, Minute, Second, Milliseconds) and
+      __parseTimezone(P, XSD_IGNORE_LAST, T) and (P^ = #0);
+
+  { assign Timezone if requested }
+  if Result and Assigned(Timezone) then
+  begin
+    if Timezone^.Convert then
+      xsdDateTimeConvertTo(Year, Month, Day, Hour, Minute, Second, Milliseconds, T, Timezone^)
+    else
+      Timezone^ := T;
+  end;
+end;
+
+function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone): Boolean;
+var
+  Year, Month, Day: Longword;
+  Hour, Minute, Second, Milliseconds: Longword;
+begin
+  if xsdTryParseDateTime(Chars, Len, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone) then
+    Result := TryEncodeDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, Value)
+  else
+    Result := False;
+end;
+
+function xsdTryParseDecimal(Chars: PChar; Len: Integer; out Value: Extended): Boolean;
+var
+  P: PChar;
+  L: PChar;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and __parseFloat(P, L, Value) and (P = L)
+  end else
+    Result := Assigned(P) and __parseFloat(P, XSD_IGNORE_LAST, Value) and (P^ = #0);
+end;
+
+function xsdTryParseDouble(Chars: PChar; Len: Integer; out Value: Double): Boolean;
+var
+  P: PChar;
+  L: PChar;
+  Tmp: Extended;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and __parseFloat(P, L, Tmp) and (P = L)
+  end else
+    Result := Assigned(P) and __parseFloat(P, XSD_IGNORE_LAST, Tmp) and (P^ = #0);
+  Value := Tmp;
+end;
+
+function xsdTryParseFloat(Chars: PChar; Len: Integer; out Value: Single): Boolean;
+var
+  P: PChar;
+  L: PChar;
+  Tmp: Extended;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and __parseFloat(P, L, Tmp) and (P = L)
+  end else
+    Result := Assigned(P) and __parseFloat(P, XSD_IGNORE_LAST, Tmp) and (P^ = #0);
+  Value := Tmp;
+end;
+
+function xsdTryParseInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+var
+  P: PChar;
+  L: PChar;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and __parseInteger(P, L, Value) and (P = L)
+  end else
+    Result := Assigned(P) and __parseInteger(P, XSD_IGNORE_LAST, Value) and (P^ = #0);
+end;
+
+function xsdTryParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
+var
+  P: PChar;
+  L: PChar;
+begin
+  P := PChar(Chars);
+  if Len >= 0 then
+  begin
+    L := P + Len;
+    Result := Assigned(P) and __parseNonNegativeInteger(P, L, Value) and (P = L)
+  end else
+    Result := Assigned(P) and __parseNonNegativeInteger(P, XSD_IGNORE_LAST, Value) and (P^ = #0);
+end;
+
+function xsdTryParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+begin
+  Result := xsdTryParseInteger(Chars, Len, Value) and (Value <= 0);
+end;
+
+function xsdTryParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+begin
+  Result := xsdTryParseInteger(Chars, Len, Value) and (Value <= -1);
+end;
+
+function xsdTryParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
+begin
+  Result := xsdTryParseNonNegativeInteger(Chars, Len, Value) and (Value >= 1);
+end;
+
+function xsdTryParseByte(Chars: PChar; Len: Integer; out Value: Shortint): Boolean;
+var
+  Tmp: Int64;
+begin
+  Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 128) and (Tmp >= -127);
+  Value := Tmp;
+end;
+
+function xsdTryParseShort(Chars: PChar; Len: Integer; out Value: Smallint): Boolean;
+var
+  Tmp: Int64;
+begin
+  Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 32767) and (Tmp >= -32768);
+  Value := Tmp;
+end;
+
+function xsdTryParseInt(Chars: PChar; Len: Integer; out Value: Longint): Boolean;
+var
+  Tmp: Int64;
+begin
+  Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 2147483647) and (Tmp >= -2147483648);
+  Value := Tmp;
+end;
+
+function xsdTryParseLong(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
+begin
+  Result := xsdTryParseInteger(Chars, Len, Value);
+end;
+
+function xsdTryParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte): Boolean;
+var
+  Tmp: QWord;
+begin
+  Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 255);
+  Value := Tmp;
+end;
+
+function xsdTryParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word): Boolean;
+var
+  Tmp: QWord;
+begin
+  Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 65535);
+  Value := Tmp;
+end;
+
+function xsdTryParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword): Boolean;
+var
+  Tmp: QWord;
+begin
+  Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 4294967295);
+  Value := Tmp;
+end;
+
+function xsdTryParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
+begin
+  Result := xsdTryParseNonNegativeInteger(Chars, Len, Value)
+end;
+
+function xsdTryParseEnum(Chars: PChar; Len: Integer; enum: array of Utf8String; out Value: Integer): Boolean;
+var
+  Temp: Utf8String;
+  I: Integer;
+begin
+  Temp := '';
+  Result := xsdTryParseString(Chars, Len, Temp);
+  if Result then
+  begin
+    for I := 0 to High(enum) do
+      if Temp = enum[I] then
+      begin
+        Value := I;
+        Exit(True);
+      end;
+    Result := False;
+  end;
+end;
+
+function xsdParseStringDef(Chars: PChar; Len: Integer; Default: Utf8String): Utf8String;
+begin
+  if not xsdTryParseString(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseStringLowerDef(Chars: PChar; Len: Integer; Default: Utf8String): Utf8String;
+begin
+  if not xsdTryParseStringLower(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseBooleanDef(Chars: PChar; Len: Integer; Default: Boolean): Boolean;
+begin
+  if not xsdTryParseBoolean(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseDateDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone): TDateTime;
+begin
+  if not xsdTryParseDate(Chars, Len, Result, Timezone) then
+    Result := Default;
+end;
+
+function xsdParseTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone): TDateTime;
+begin
+  if not xsdTryParseTime(Chars, Len, Result, Timezone) then
+    Result := Default;
+end;
+
+function xsdParseDateTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone): TDateTime;
+begin
+  if not xsdTryParseDateTime(Chars, Len, Result, Timezone) then
+    Result := Default;
+end;
+
+function xsdParseDecimalDef(Chars: PChar; Len: Integer; Default: Extended): Extended;
+begin
+  if not xsdTryParseDecimal(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseDoubleDef(Chars: PChar; Len: Integer; Default: Double): Double;
+begin
+  if not xsdTryParseDouble(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseFloatDef(Chars: PChar; Len: Integer; Default: Single): Single;
+begin
+  if not xsdTryParseFloat(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+begin
+  if not xsdTryParseInteger(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseNonNegativeIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
+begin
+  if not xsdTryParseNonNegativeInteger(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseNonPositiveIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+begin
+  if not xsdTryParseNonPositiveInteger(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseNegativeIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+begin
+  if not xsdTryParseNegativeInteger(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParsePositiveIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
+begin
+  if not xsdTryParsePositiveInteger(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseByteDef(Chars: PChar; Len: Integer; Default: Shortint): Shortint;
+begin
+  if not xsdTryParseByte(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseShortDef(Chars: PChar; Len: Integer; Default: Smallint): Smallint;
+begin
+  if not xsdTryParseShort(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseIntDef(Chars: PChar; Len: Integer; Default: Longint): Longint;
+begin
+  if not xsdTryParseInt(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseLongDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
+begin
+  if not xsdTryParseLong(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseUnsignedByteDef(Chars: PChar; Len: Integer; Default: Byte): Byte;
+begin
+  if not xsdTryParseUnsignedByte(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseUnsignedShortDef(Chars: PChar; Len: Integer; Default: Word): Word;
+begin
+  if not xsdTryParseUnsignedShort(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseUnsignedIntDef(Chars: PChar; Len: Integer; Default: Longword): Longword;
+begin
+  if not xsdTryParseUnsignedInt(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseUnsignedLongDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
+begin
+  if not xsdTryParseUnsignedLong(Chars, Len, Result) then
+    Result := Default;
+end;
+
+function xsdParseEnumDef(Chars: PChar; Len: Integer; enum: array of Utf8String; Default: Integer): Integer;
+begin
+  if not xsdTryParseEnum(Chars, Len, enum, Result) then
+    Result := Default;
+end;
+
+procedure xsdParseBase64(Chars: PChar; Len: Integer; const Value: TStream);
+begin
+  if not xsdTryParseBase64(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:base64Binary']);
+end;
+
+procedure xsdParseString(Chars: PChar; Len: Integer; out Value: Utf8String);
+begin
+  if not xsdTryParseString(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:string']);
+end;
+
+procedure xsdParseStringLower(Chars: PChar; Len: Integer; out Value: Utf8String);
+begin
+  if not xsdTryParseStringLower(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:string']);
+end;
+
+procedure xsdParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean);
+begin
+  if not xsdTryParseBoolean(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:boolean']);
+end;
+
+procedure xsdParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone; BC: PBoolean);
+begin
+  if not xsdTryParseDate(Chars, Len, Year, Month, Day, Timezone, BC) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:date']);
+end;
+
+procedure xsdParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone);
+begin
+  if not xsdTryParseDate(Chars, Len, Value, Timezone) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:date']);
+end;
+
+procedure xsdParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone);
+begin
+  if not xsdTryParseTime(Chars, Len, Hour, Minute, Second, Milliseconds, Timezone) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:time']);
+end;
+
+procedure xsdParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone);
+begin
+  if not xsdTryParseTime(Chars, Len, Value, Timezone) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:time']);
+end;
+
+procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone; BC: PBoolean);
+begin
+  if not xsdTryParseDateTime(Chars, Len, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:dateTime']);
+end;
+
+procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone);
+begin
+  if not xsdTryParseDateTime(Chars, Len, Value, Timezone) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:dateTime']);
+end;
+
+procedure xsdParseDecimal(Chars: PChar; Len: Integer; out Value: Extended);
+begin
+  if not xsdTryParseDecimal(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:decimal']);
+end;
+
+procedure xsdParseDouble(Chars: PChar; Len: Integer; out Value: Double);
+begin
+  if not xsdTryParseDouble(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:double']);
+end;
+
+procedure xsdParseFloat(Chars: PChar; Len: Integer; out Value: Single);
+begin
+  if not xsdTryParseFloat(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:float']);
+end;
+
+procedure xsdParseInteger(Chars: PChar; Len: Integer; out Value: Int64);
+begin
+  if not xsdTryParseInteger(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:integer']);
+end;
+
+procedure xsdParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord);
+begin
+  if not xsdTryParseNonNegativeInteger(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:nonNegativeInteger']);
+end;
+
+procedure xsdParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64);
+begin
+  if not xsdTryParseNonPositiveInteger(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:nonPositiveInteger']);
+end;
+
+procedure xsdParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64);
+begin
+  if not xsdTryParseNegativeInteger(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:negativeInteger']);
+end;
+
+procedure xsdParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord);
+begin
+  if not xsdTryParsePositiveInteger(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:positiveInteger']);
+end;
+
+procedure xsdParseByte(Chars: PChar; Len: Integer; out Value: Shortint);
+begin
+  if not xsdTryParseByte(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:byte']);
+end;
+
+procedure xsdParseShort(Chars: PChar; Len: Integer; out Value: Smallint);
+begin
+  if not xsdTryParseShort(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:short']);
+end;
+
+procedure xsdParseInt(Chars: PChar; Len: Integer; out Value: Longint);
+begin
+  if not xsdTryParseInt(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:int']);
+end;
+
+procedure xsdParseLong(Chars: PChar; Len: Integer; out Value: Int64);
+begin
+  if not xsdTryParseLong(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:long']);
+end;
+
+procedure xsdParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte);
+begin
+  if not xsdTryParseUnsignedByte(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedByte']);
+end;
+
+procedure xsdParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word);
+begin
+  if not xsdTryParseUnsignedShort(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedShort']);
+end;
+
+procedure xsdParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword);
+begin
+  if not xsdTryParseUnsignedInt(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedInt']);
+end;
+
+procedure xsdParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord);
+begin
+  if not xsdTryParseUnsignedLong(Chars, Len, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedLong']);
+end;
+
+procedure xsdParseEnum(Chars: PChar; Len: Integer; enum: array of Utf8String; out Value: Integer);
+begin
+  if not xsdTryParseEnum(Chars, Len, enum, Value) then
+    raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:enum']);
+end;
+
+function xsdParseString(Chars: PChar; Len: Integer): Utf8String;
+begin
+  xsdParseString(Chars, Len, Result);
+end;
+
+function xsdParseStringLower(Chars: PChar; Len: Integer): Utf8String;
+begin
+  xsdParseStringLower(Chars, Len, Result);
+end;
+
+function xsdParseBoolean(Chars: PChar; Len: Integer): Boolean;
+begin
+  xsdParseBoolean(Chars, Len, Result);
+end;
+
+function xsdParseDate(Chars: PChar; Len: Integer; Timezone: PXsdTimezone): TDateTime;
+begin
+  xsdParseDate(Chars, Len, Result, Timezone);
+end;
+
+function xsdParseTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone): TDateTime;
+begin
+  xsdParseTime(Chars, Len, Result, Timezone);
+end;
+
+function xsdParseDateTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone): TDateTime;
+begin
+  xsdParseDateTime(Chars, Len, Result, Timezone);
+end;
+
+function xsdParseDecimal(Chars: PChar; Len: Integer): Extended;
+begin
+  xsdParseDecimal(Chars, Len, Result);
+end;
+
+function xsdParseDouble(Chars: PChar; Len: Integer): Double;
+begin
+  xsdParseDouble(Chars, Len, Result);
+end;
+
+function xsdParseFloat(Chars: PChar; Len: Integer): Single;
+begin
+  xsdParseFloat(Chars, Len, Result);
+end;
+
+function xsdParseInteger(Chars: PChar; Len: Integer): Int64;
+begin
+  xsdParseInteger(Chars, Len, Result);
+end;
+
+function xsdParseNonNegativeInteger(Chars: PChar; Len: Integer): QWord;
+begin
+  xsdParseNonNegativeInteger(Chars, Len, Result);
+end;
+
+function xsdParseNonPositiveInteger(Chars: PChar; Len: Integer): Int64;
+begin
+  xsdParseNonPositiveInteger(Chars, Len, Result);
+end;
+
+function xsdParseNegativeInteger(Chars: PChar; Len: Integer): Int64;
+begin
+  xsdParseNegativeInteger(Chars, Len, Result);
+end;
+
+function xsdParsePositiveInteger(Chars: PChar; Len: Integer): QWord;
+begin
+  xsdParsePositiveInteger(Chars, Len, Result);
+end;
+
+function xsdParseByte(Chars: PChar; Len: Integer): Shortint;
+begin
+  xsdParseByte(Chars, Len, Result);
+end;
+
+function xsdParseShort(Chars: PChar; Len: Integer): Smallint;
+begin
+  xsdParseShort(Chars, Len, Result);
+end;
+
+function xsdParseInt(Chars: PChar; Len: Integer): Longint;
+begin
+  xsdParseInt(Chars, Len, Result);
+end;
+
+function xsdParseLong(Chars: PChar; Len: Integer): Int64;
+begin
+  xsdParseLong(Chars, Len, Result);
+end;
+
+function xsdParseUnsignedByte(Chars: PChar; Len: Integer): Byte;
+begin
+  xsdParseUnsignedByte(Chars, Len, Result);
+end;
+
+function xsdParseUnsignedShort(Chars: PChar; Len: Integer): Word;
+begin
+  xsdParseUnsignedShort(Chars, Len, Result);
+end;
+
+function xsdParseUnsignedInt(Chars: PChar; Len: Integer): Longword;
+begin
+  xsdParseUnsignedInt(Chars, Len, Result);
+end;
+
+function xsdParseUnsignedLong(Chars: PChar; Len: Integer): QWord;
+begin
+  xsdParseUnsignedLong(Chars, Len, Result);
+end;
+
+function xsdParseEnum(Chars: PChar; Len: Integer; enum: array of Utf8String): Integer;
+begin
+  xsdParseEnum(Chars, Len, enum, Result);
+end;
+
+end.

Some files were not shown because too many files changed in this diff