ソースを参照

* updated hermes to latest version from trunk

git-svn-id: trunk@16017 -
nickysn 15 年 前
コミット
fc8d088308
55 ファイル変更8556 行追加8873 行削除
  1. 9 10
      .gitattributes
  2. 105 153
      packages/hermes/Makefile
  3. 35 17
      packages/hermes/Makefile.fpc
  4. 0 223
      packages/hermes/src/clear.inc
  5. 89 81
      packages/hermes/src/d_32.inc
  6. 0 62
      packages/hermes/src/debug.inc
  7. 0 82
      packages/hermes/src/dither.inc
  8. 134 123
      packages/hermes/src/factconv.inc
  9. 0 398
      packages/hermes/src/factory.inc
  10. 0 138
      packages/hermes/src/format.inc
  11. 18 6
      packages/hermes/src/headp.inc
  12. 41 16
      packages/hermes/src/hermconf.inc
  13. 22 24
      packages/hermes/src/hermdef.inc
  14. 232 213
      packages/hermes/src/hermes.pp
  15. 156 0
      packages/hermes/src/hermes_clearer.inc
  16. 350 427
      packages/hermes/src/hermes_converter.inc
  17. 68 0
      packages/hermes/src/hermes_debug.inc
  18. 92 0
      packages/hermes/src/hermes_dither.inc
  19. 377 0
      packages/hermes/src/hermes_factory.inc
  20. 117 0
      packages/hermes/src/hermes_format.inc
  21. 182 0
      packages/hermes/src/hermes_list.inc
  22. 232 0
      packages/hermes/src/hermes_palette.inc
  23. 119 0
      packages/hermes/src/hermes_utility.inc
  24. 81 43
      packages/hermes/src/i386/headi386.inc
  25. 41 11
      packages/hermes/src/i386/headmmx.inc
  26. 23 25
      packages/hermes/src/i386/mmx_clr.as
  27. 9 12
      packages/hermes/src/i386/mmx_main.as
  28. 27 30
      packages/hermes/src/i386/mmxp2_32.as
  29. 14 14
      packages/hermes/src/i386/mmxp_32.as
  30. 2048 2048
      packages/hermes/src/i386/x8616lut.as
  31. 24 24
      packages/hermes/src/i386/x86_clr.as
  32. 11 11
      packages/hermes/src/i386/x86_main.as
  33. 33 33
      packages/hermes/src/i386/x86p_16.as
  34. 49 49
      packages/hermes/src/i386/x86p_32.as
  35. 13 13
      packages/hermes/src/i386/x86p_cpy.as
  36. 16 22
      packages/hermes/src/i386/x86p_i8.as
  37. 6 8
      packages/hermes/src/i386/x86p_s32.as
  38. 5 7
      packages/hermes/src/i386/x86pscpy.as
  39. 0 212
      packages/hermes/src/list.inc
  40. 0 31
      packages/hermes/src/malloc.inc
  41. 499 511
      packages/hermes/src/p_16.inc
  42. 499 523
      packages/hermes/src/p_24.inc
  43. 625 610
      packages/hermes/src/p_32.inc
  44. 92 89
      packages/hermes/src/p_clr.inc
  45. 30 21
      packages/hermes/src/p_cnv.inc
  46. 93 93
      packages/hermes/src/p_cpy.inc
  47. 570 614
      packages/hermes/src/p_g.inc
  48. 348 364
      packages/hermes/src/p_ga.inc
  49. 57 59
      packages/hermes/src/p_gac.inc
  50. 57 59
      packages/hermes/src/p_gca.inc
  51. 57 59
      packages/hermes/src/p_gcc.inc
  52. 240 219
      packages/hermes/src/p_i8.inc
  53. 611 627
      packages/hermes/src/p_muhmu.inc
  54. 0 348
      packages/hermes/src/palette.inc
  55. 0 111
      packages/hermes/src/utility.inc

+ 9 - 10
.gitattributes

@@ -3281,18 +3281,21 @@ packages/hash/src/uuid.pas svneol=native#text/plain
 packages/hermes/Makefile svneol=native#text/plain
 packages/hermes/Makefile.fpc svneol=native#text/plain
 packages/hermes/fpmake_disabled.pp svneol=native#text/plain
-packages/hermes/src/clear.inc svneol=native#text/plain
-packages/hermes/src/convert.inc svneol=native#text/plain
 packages/hermes/src/d_32.inc svneol=native#text/plain
-packages/hermes/src/debug.inc svneol=native#text/plain
-packages/hermes/src/dither.inc svneol=native#text/plain
 packages/hermes/src/factconv.inc svneol=native#text/plain
-packages/hermes/src/factory.inc svneol=native#text/plain
-packages/hermes/src/format.inc svneol=native#text/plain
 packages/hermes/src/headp.inc svneol=native#text/plain
 packages/hermes/src/hermconf.inc svneol=native#text/plain
 packages/hermes/src/hermdef.inc svneol=native#text/plain
 packages/hermes/src/hermes.pp svneol=native#text/plain
+packages/hermes/src/hermes_clearer.inc svneol=native#text/plain
+packages/hermes/src/hermes_converter.inc svneol=native#text/plain
+packages/hermes/src/hermes_debug.inc svneol=native#text/plain
+packages/hermes/src/hermes_dither.inc svneol=native#text/plain
+packages/hermes/src/hermes_factory.inc svneol=native#text/plain
+packages/hermes/src/hermes_format.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_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
@@ -3308,8 +3311,6 @@ 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/list.inc svneol=native#text/plain
-packages/hermes/src/malloc.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_32.inc svneol=native#text/plain
@@ -3323,8 +3324,6 @@ packages/hermes/src/p_gca.inc svneol=native#text/plain
 packages/hermes/src/p_gcc.inc svneol=native#text/plain
 packages/hermes/src/p_i8.inc svneol=native#text/plain
 packages/hermes/src/p_muhmu.inc svneol=native#text/plain
-packages/hermes/src/palette.inc svneol=native#text/plain
-packages/hermes/src/utility.inc svneol=native#text/plain
 packages/httpd13/Makefile svneol=native#text/plain
 packages/httpd13/Makefile.fpc svneol=native#text/plain
 packages/httpd13/fpmake.pp svneol=native#text/plain

+ 105 - 153
packages/hermes/Makefile

@@ -1,10 +1,10 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/08/02]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/19]
 #
 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 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-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
+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 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
 BSDs = freebsd netbsd openbsd darwin
-UNIXs = linux $(BSDs) solaris qnx
+UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
 OSNeedsComspecToRunBatch = go32v2 watcom
 FORCE:
@@ -266,15 +266,6 @@ endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 override PACKAGE_NAME=hermes
 override PACKAGE_VERSION=2.5.1
-I386_LOADERSSRC=src/i386/x86_main.as src/i386/x86p_cpy.as \
-	src/i386/x86pscpy.as src/i386/x86p_16.as \
-	src/i386/x86p_i8.as src/i386/x86_clr.as \
-	src/i386/x86p_32.as src/i386/x86p_s32.as
-ifeq ($(CPU_TARGET),i386)
-CPU_LOADERS=mmx_clr mmxp_32 mmx_main mmxp2_32 hm_i386
-else
-CPU_LOADERS=
-endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_UNITS+=hermes
 endif
@@ -335,6 +326,9 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 override TARGET_UNITS+=hermes
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override TARGET_UNITS+=hermes
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 override TARGET_UNITS+=hermes
 endif
@@ -398,6 +392,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_UNITS+=hermes
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_UNITS+=hermes
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_UNITS+=hermes
 endif
@@ -449,180 +446,73 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override TARGET_UNITS+=hermes
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override TARGET_UNITS+=hermes
+endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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+=$(CPU_LOADERS)
+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+=$(CPU_LOADERS)
+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-os2)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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+=$(CPU_LOADERS)
+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+=$(CPU_LOADERS)
+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+=$(CPU_LOADERS)
+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-netbsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-solaris)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-qnx)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-netware)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-openbsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-wdosx)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-darwin)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-emx)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-watcom)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-netwlibc)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-wince)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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-symbian)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+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),arm-palmos)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_LOADERS+=$(CPU_LOADERS)
-endif
-ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_LOADERS+=$(CPU_LOADERS)
+ifeq ($(FULL_TARGET),i386-nativent)
+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
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_INCLUDEDIR+=src
 endif
@@ -683,6 +573,9 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 override COMPILER_INCLUDEDIR+=src
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_INCLUDEDIR+=src
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_INCLUDEDIR+=src
 endif
@@ -746,6 +639,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_INCLUDEDIR+=src
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_INCLUDEDIR+=src
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_INCLUDEDIR+=src
 endif
@@ -797,6 +693,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_INCLUDEDIR+=src
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_SOURCEDIR+=src tests
 endif
@@ -857,6 +756,9 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 override COMPILER_SOURCEDIR+=src tests
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_SOURCEDIR+=src tests
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_SOURCEDIR+=src tests
 endif
@@ -920,6 +822,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_SOURCEDIR+=src tests
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_SOURCEDIR+=src tests
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_SOURCEDIR+=src tests
 endif
@@ -971,6 +876,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_SOURCEDIR+=src tests
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_TARGETDIR+=.
 endif
@@ -1031,6 +939,9 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 override COMPILER_TARGETDIR+=.
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_TARGETDIR+=.
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_TARGETDIR+=.
 endif
@@ -1094,6 +1005,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_TARGETDIR+=.
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_TARGETDIR+=.
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_TARGETDIR+=.
 endif
@@ -1145,6 +1059,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_TARGETDIR+=.
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_TARGETDIR+=.
+endif
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 endif
@@ -1487,6 +1404,10 @@ ifeq ($(OS_TARGET),symbian)
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=symbian
 endif
+ifeq ($(OS_TARGET),NativeNT)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=nativent
+endif
 else
 ifeq ($(OS_TARGET),go32v1)
 PPUEXT=.pp1
@@ -1972,6 +1893,9 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
 endif
@@ -2035,6 +1959,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 REQUIRE_PACKAGES_RTL=1
 endif
@@ -2086,6 +2013,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_RTL),)
@@ -2095,9 +2025,9 @@ else
 UNITDIR_RTL=$(PACKAGEDIR_RTL)
 endif
 ifdef CHECKDEPEND
-$(PACKAGEDIR_RTL)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE)
-override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
+$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE)
 endif
 else
 PACKAGEDIR_RTL=
@@ -2494,7 +2424,7 @@ ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
 ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
 ifdef USETAR
 ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
-ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+ZIPCMD_ZIP:=$(TARPROG) c$(TAROPT)f $(ZIPDESTFILE) *
 else
 ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
 ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
@@ -2539,6 +2469,9 @@ fpc_zipdistinstall:
 ifdef EXEFILES
 override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
 endif
+ifdef CLEAN_PROGRAMS
+override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
+endif
 ifdef CLEAN_UNITS
 override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
 endif
@@ -2585,6 +2518,9 @@ endif
 ifdef CLEANRSTFILES
 	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
 endif
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
 endif
 	-$(DELTREE) units
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
@@ -2735,11 +2671,27 @@ endif
 .NOTPARALLEL:
 mmx_clr$(OEXT):src/$(CPU_TARGET)/mmx_clr.as
 	$(AS) --32 -o $(UNITTARGETDIRPREFIX)mmx_clr$(OEXT) src/$(CPU_TARGET)/mmx_clr.as
-mmxp_32$(OEXT):src/$(CPU_TARGET)/mmxp_32.as
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)mmxp_32$(OEXT) src/$(CPU_TARGET)/mmxp_32.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
-hm_i386$(OEXT): $(I386_LOADERSSRC)
-	$(AS) --32 -o $(UNITTARGETDIRPREFIX)hm_i386$(OEXT) $(I386_LOADERSSRC)
+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

+ 35 - 17
packages/hermes/Makefile.fpc

@@ -8,7 +8,9 @@ version=2.5.1
 
 [target]
 units=hermes
-loaders=$(CPU_LOADERS)
+loaders_i386=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]
 unitdir=
@@ -16,6 +18,9 @@ targetdir=.
 includedir=src
 sourcedir=src tests
 
+[install]
+fpcpackage=y
+
 [default]
 fpcdir=../..
 
@@ -24,25 +29,38 @@ fpcdir=../..
 mmx_clr$(OEXT):src/$(CPU_TARGET)/mmx_clr.as
         $(AS) --32 -o $(UNITTARGETDIRPREFIX)mmx_clr$(OEXT) src/$(CPU_TARGET)/mmx_clr.as
 
-mmxp_32$(OEXT):src/$(CPU_TARGET)/mmxp_32.as
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)mmxp_32$(OEXT) src/$(CPU_TARGET)/mmxp_32.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
 
-hm_i386$(OEXT): $(I386_LOADERSSRC)
-        $(AS) --32 -o $(UNITTARGETDIRPREFIX)hm_i386$(OEXT) $(I386_LOADERSSRC)
-
-[prerules]
-I386_LOADERSSRC=src/i386/x86_main.as src/i386/x86p_cpy.as \
-        src/i386/x86pscpy.as src/i386/x86p_16.as \
-        src/i386/x86p_i8.as src/i386/x86_clr.as \
-        src/i386/x86p_32.as src/i386/x86p_s32.as
-ifeq ($(CPU_TARGET),i386)
-CPU_LOADERS=mmx_clr mmxp_32 mmx_main mmxp2_32 hm_i386
-else
-CPU_LOADERS=
-endif
+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 - 223
packages/hermes/src/clear.inc

@@ -1,223 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-{Function Hermes_ClearerInstance : THermesHandle;
-Procedure Hermes_ClearerReturn(handle : THermesHandle);
-Function Hermes_ClearerRequest(handle : THermesHandle; format : PHermesFormat) : Boolean;
-Function Hermes_ClearerClear(handle : THermesHandle; pixels : Pointer;
-                             x1, y1, width, height, pitch : Integer;
-                             r, g, b : int32; index : char8) : Boolean;}
-
-Type
-  PClearerInstance = ^TClearerInstance;
-  TClearerInstance = Record
-    format : PHermesFormat;
-    func : THermesClearPtr;
-  End;
-
-Const
-{ClearerList is a list of TClearerInstance}
-  ClearerList : PHermesList = Nil;
-  CLEARrefcount : Integer = 0;
-  ClearCurrenthandle : THermesHandle = 0;
-
-Function Hermes_ClearerInstance : THermesHandle;
-
-Var
-  element : PHermesListElement;
-  newinstance : PClearerInstance;
-
-Begin
-  If CLEARrefcount = 0 Then
-  Begin
-    ClearerList := Hermes_ListNew;
-    If ClearerList = Nil Then
-    Begin
-      Hermes_ClearerInstance := 0;
-      Exit;
-    End;
-  End;
-  element := Hermes_ListElementNew(ClearCurrenthandle + 1);
-  If element = Nil Then
-  Begin
-    Hermes_ClearerInstance := 0;
-    Exit;
-  End;
-  newinstance := malloc(SizeOf(TClearerInstance));
-  If newinstance = Nil Then
-  Begin
-    Hermes_ClearerInstance := 0;
-    Exit;
-  End;
-  newinstance^.func := Nil;
-  newinstance^.format := Hermes_FormatNewEmpty;
-  If newinstance^.format = Nil Then
-  Begin
-    Hermes_ClearerInstance := 0;
-    Exit;
-  End;
-  element^.data := newinstance;
-  Hermes_ListAdd(ClearerList, element);
-  Inc(CLEARrefcount);
-  Inc(ClearCurrenthandle);
-  Hermes_ClearerInstance := ClearCurrenthandle;
-End;
-
-Procedure Hermes_ClearerFreeHandleCallback(q : Pointer);
-
-Begin
-  free(PClearerInstance(q)^.format);
-End;
-
-Procedure Hermes_ClearerReturn(handle : THermesHandle);
-
-Var
-  element : PHermesListElement;
-  instance : PClearerInstance;
-
-Begin
-  Dec(CLEARrefcount);
-  If Hermes_ListDeleteElement(ClearerList, handle, @Hermes_ClearerFreeHandleCallback) = False Then
-    Exit;
-  If CLEARrefcount = 0 Then
-  Begin
-    { Dirty fix: Free the format pointers in all the clearer instances }
-    { The list functions need updating to allow member deletion! }
-    element := ClearerList^.first;
-    While element <> Nil Do
-    Begin
-      instance := element^.data;
-      free(instance^.format);
-      element := element^.next;
-    End;
-    Hermes_ListDestroy(ClearerList);
-  End;
-End;
-
-Function Hermes_ClearerRequest(handle : THermesHandle; format : PHermesFormat) : Boolean;
-
-Var
-  element : PHermesListElement;
-  clr : PClearerInstance;
-  i : Integer;
-
-Begin
-  { Look up this clearer in the list }
-  element := Hermes_ListLookup(ClearerList, handle);
-  If element = Nil Then
-  Begin
-    Hermes_ClearerRequest := False;
-    Exit;
-  End;
-  clr := element^.data;
-
-  { If the clearer is the same, return 1 }
-  If Hermes_FormatEquals(clr^.format, format) Then
-  Begin
-    Hermes_ClearerRequest := True;
-    Exit;
-  End;
-
-  { Otherwise look for a new clearer }
-  clr^.func := Nil;
-  For i := 0 To numClearers - 1 Do
-  Begin
-    If Clearers[i]^.bits = format^.bits Then
-    Begin
-      clr^.func := Clearers[i]^.func;
-      Hermes_FormatCopy(format, clr^.format);
-      Hermes_ClearerRequest := True;
-      Exit;
-    End;
-  End;
-  Hermes_ClearerRequest := False;
-End;
-
-Function Hermes_ClearerClear(handle : THermesHandle; pixels : Pointer;
-                             x1, y1, width, height, pitch : Integer;
-                             r, g, b : int32; index : char8) : Boolean;
-
-Var
-  element : PHermesListElement;
-  info : THermesGenericInfo;
-  clr : PClearerInstance;
-  pixelval, d_r, d_g, d_b, d_a : int32;
-  iface : THermesClearInterface;
-
-Begin
-  If (height <= 0) Or (width <= 0) Then
-  Begin
-    Hermes_ClearerClear := True;
-    Exit;
-  End;
-
-  { Look up this clearer in the list }
-  element := Hermes_ListLookup(ClearerList, handle);
-  If (element = Nil) Or (element^.data = Nil) Then
-  Begin
-    Hermes_ClearerClear := False;
-    Exit;
-  End;
-
-  { Get clearer instance from list element data }
-  clr := element^.data;
-
-  { No conversion function assigned }
-  If clr^.func = Nil Then
-  Begin
-    Hermes_ClearerClear := False;
-    Exit;
-  End;
-
-  If clr^.format^.indexed Then
-    pixelval := index
-  Else
-  Begin
-    Hermes_Calculate_Generic_Info(24, 16, 8, 32,
-                                  Hermes_Topbit(clr^.format^.r),
-                                  Hermes_Topbit(clr^.format^.g),
-                                  Hermes_Topbit(clr^.format^.b),
-                                  Hermes_Topbit(clr^.format^.a), @info);
-    pixelval := (index Shl 24) Or (r Shl 16) Or (g Shl 8) Or b;
-    d_r := ((pixelval Shr info.r_right) Shl info.r_left) And clr^.format^.r;
-    d_g := ((pixelval Shr info.g_right) Shl info.g_left) And clr^.format^.g;
-    d_b := ((pixelval Shr info.b_right) Shl info.b_left) And clr^.format^.b;
-    d_a := ((pixelval Shr info.a_right) Shl info.a_left) And clr^.format^.a;
-    pixelval := d_r Or d_g Or d_b Or d_a;
-  End;
-  iface.dest := pixels;
-  Inc(iface.dest, y1*pitch + x1*(clr^.format^.bits Shr 3));
-
-  iface.width := width;
-  iface.height := height;
-  iface.add := pitch - width * (clr^.format^.bits Shr 3);
-
-  iface.value := pixelval;
-
-  { Optimization }
-  If iface.add = 0 Then
-  Begin
-    iface.width := iface.width * iface.height;
-    iface.height := 1;
-  End;
-
-  clr^.func(@iface);
-  Hermes_ClearerClear := True;
-End;

+ 89 - 81
packages/hermes/src/d_32.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -22,97 +34,93 @@
    32 bit to * dithered converters for the HERMES library
    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
 }
 
-Procedure ConvertP_32rgb888_16rgb565_dither(iface : PHermesConverterInterface); CDecl;
-
-Var
-  source, dest : Pchar8;
-  d_pixel : int32;
-  y, count : LongInt;
-
-Begin
+procedure ConvertP_32rgb888_16rgb565_dither(iface: PHermesConverterInterface); cdecl;
+var
+  source, dest: PUint8;
+  d_pixel: Uint32;
+  y, count: LongInt;
+begin
   y := 0;
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  While y < iface^.d_height Do
-  Begin
+  while y < iface^.d_height do
+  begin
     { Get counter for this scanline }
     count := iface^.d_width;
 
     { Check first pixel alignment, correct if necessary }
-    If (PtrUInt(iface^.d_pixels) And 3) <> 0 Then
-    Begin
-      Pshort16(dest)^ := 
-        DitherTab_r565_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g565_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b565_44[count And 3, y And 3, Pint32(source)^ And $ff];
+    if (PtrUInt(iface^.d_pixels) and 3) <> 0 then
+    begin
+      PUint16(dest)^ :=
+        DitherTab_r565_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g565_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b565_44[count and 3, y and 3, PUint32(source)^ and $ff];
 
       Inc(source, 4);
       Inc(dest, 2);
       Dec(count);
-    End;
+    end;
 
     { Two pixels at a time loop }
-    While count > 1 Do
-    Begin
-      d_pixel :=
-        DitherTab_r565_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g565_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b565_44[count And 3, y And 3, Pint32(source)^ And $ff];
+    while count > 1 do
+    begin
+      d_pixel := (
+        DitherTab_r565_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g565_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b565_44[count and 3, y and 3, PUint32(source)^ and $ff]) shl DWORD_SMALLINT0_SHL;
 
       Inc(source, 4);
       Dec(count);
 
-      d_pixel := d_pixel Or ((
-        DitherTab_r565_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g565_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b565_44[count And 3, y And 3, Pint32(source)^ And $ff]) Shl 16);
+      d_pixel := d_pixel or ((
+        DitherTab_r565_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g565_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b565_44[count and 3, y and 3, PUint32(source)^ and $ff]) shl DWORD_SMALLINT1_SHL);
 
       Dec(count);
       Inc(source, 4);
 
-      Pint32(dest)^ := d_pixel;
+      PUint32(dest)^ := d_pixel;
 
       Inc(dest, 4);
-    End;
+    end;
 
     { Convert the odd trailing pixel }
-    If (iface^.d_width And 1) <> 0 Then
-    Begin
-      Pshort16(dest)^ :=
-        DitherTab_r565_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g565_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b565_44[count And 3, y And 3, Pint32(source)^ And $ff];
+    if (iface^.d_width and 1) <> 0 then
+    begin
+      PUint16(dest)^ :=
+        DitherTab_r565_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g565_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b565_44[count and 3, y and 3, PUint32(source)^ and $ff];
 
       Inc(source, 4);
       Inc(dest, 2);
-    End;
+    end;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
 
     Inc(y);
-  End;
-End;
-
-Procedure ConvertP_32rgb888_8rgb332_dither(iface : PHermesConverterInterface); CDecl;
-
-Var
-  source, dest : Pchar8;
-  d_pixel : int32;
-  y, count : LongInt;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_32rgb888_8rgb332_dither(iface: PHermesConverterInterface); cdecl;
+var
+  source, dest: PUint8;
+  d_pixel: Uint32;
+  y, count: LongInt;
+begin
   y := 0;
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
- 
-  While y < iface^.d_height Do
-  Begin
+
+  while y < iface^.d_height do
+  begin
     { Get counter for this scanline }
     count := iface^.d_width;
 
@@ -121,56 +129,56 @@ Begin
 
 
     { Convert 4 pixels at a time }
-    While count > 3 Do
-    Begin
-      d_pixel :=
-        DitherTab_r332_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g332_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b332_44[count And 3, y And 3, Pint32(source)^ And $ff];
+    while count > 3 do
+    begin
+      d_pixel := (
+        DitherTab_r332_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g332_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b332_44[count and 3, y and 3, PUint32(source)^ and $ff]) shl DWORD_BYTE0_SHL;
       Dec(count);
       Inc(source, 4);
 
-      d_pixel := d_pixel Or ((
-        DitherTab_r332_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g332_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b332_44[count And 3, y And 3, Pint32(source)^ And $ff]) Shl 8);
+      d_pixel := d_pixel or ((
+        DitherTab_r332_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g332_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b332_44[count and 3, y and 3, PUint32(source)^ and $ff]) shl DWORD_BYTE1_SHL);
       Dec(count);
       Inc(source, 4);
 
-      d_pixel := d_pixel Or ((
-        DitherTab_r332_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g332_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b332_44[count And 3, y And 3, Pint32(source)^ And $ff]) Shl 16);
+      d_pixel := d_pixel or ((
+        DitherTab_r332_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g332_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b332_44[count and 3, y and 3, PUint32(source)^ and $ff]) shl DWORD_BYTE2_SHL);
       Dec(count);
       Inc(source, 4);
 
-      d_pixel := d_pixel Or ((
-        DitherTab_r332_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g332_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b332_44[count And 3, y And 3, Pint32(source)^ And $ff]) Shl 24);
+      d_pixel := d_pixel or ((
+        DitherTab_r332_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g332_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b332_44[count and 3, y and 3, PUint32(source)^ and $ff]) shl DWORD_BYTE3_SHL);
       Dec(count);
       Inc(source, 4);
 
-      Pint32(dest)^ := d_pixel;
+      PUint32(dest)^ := d_pixel;
       Inc(dest, 4);
-    End;
+    end;
 
     { Write trailing pixels }
-    While count <> 0 Do
-    Begin
+    while count <> 0 do
+    begin
       Dec(count);
-      dest^ := 
-        DitherTab_r332_44[count And 3, y And 3, (Pint32(source)^ Shr 16) And $ff] Or
-	DitherTab_g332_44[count And 3, y And 3, (Pint32(source)^ Shr 8) And $ff] Or
-	DitherTab_b332_44[count And 3, y And 3, Pint32(source)^ And $ff];
+      dest^ :=
+        DitherTab_r332_44[count and 3, y and 3, (PUint32(source)^ shr 16) and $ff] or
+        DitherTab_g332_44[count and 3, y and 3, (PUint32(source)^ shr 8) and $ff] or
+        DitherTab_b332_44[count and 3, y and 3, PUint32(source)^ and $ff];
 
       Inc(source, 4);
       Inc(dest);
-    End;
+    end;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
 
     Inc(y);
-  End;
-End;
+  end;
+end;

+ 0 - 62
packages/hermes/src/debug.inc

@@ -1,62 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-Function C2Str(Q : Integer) : String;
-
-Var
-  S : String;
-
-Begin
-  Str(Q, S);
-  C2Str := S;
-End;
-
-Procedure DebugInit;
-
-{Var
-  F : Text;}
-
-Begin
-{  ASSign(F, 'debug.txt');
-  Rewrite(F);
-  Close(F);}
-End;
-
-Procedure DebugMSG(S : String);
-
-Var
-  F : Text;
-
-Begin
-  ASSign(F, 'debug.txt');
-  {$I-}
-  Append(F);
-  {$I+}
-  If IOResult <> 0 Then
-  Begin
-    {$I-}
-    Rewrite(F);
-    {$I+}
-    If IOResult <> 0 Then
-      Exit;
-  End;
-  Writeln(F, S);
-  Close(F);
-End;

+ 0 - 82
packages/hermes/src/dither.inc

@@ -1,82 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-{ Everything in here (C)1998 The Rasterman }
-
-{ Rasterman's dither matrix }
-
-Const
-  DitherMatrix_44 : Array[0..3, 0..3] Of char8 = (
-    (0, 4, 1, 5),
-    (6, 2, 7, 3),
-    (1, 5, 0, 4),
-    (7, 3, 6, 2));
-
-Var
-  DitherTab_r565_44 : Array[0..3, 0..3, 0..255] Of short16;
-  DitherTab_g565_44 : Array[0..3, 0..3, 0..255] Of short16;
-  DitherTab_b565_44 : Array[0..3, 0..3, 0..255] Of short16;
-
-  DitherTab_r332_44 : Array[0..3, 0..3, 0..255] Of char8;
-  DitherTab_g332_44 : Array[0..3, 0..3, 0..255] Of char8;
-  DitherTab_b332_44 : Array[0..3, 0..3, 0..255] Of char8;
-
-Procedure Dither_SetupMatrices;
-
-Var
-  i, x, y : LongInt;
-
-Begin  
-  For y := 0 To 3 Do
-    For x := 0 To 3 Do
-      For i := 0 To 255 Do
-      Begin
-        If (DitherMatrix_44[x, y] < (i And $7)) And (i < (256 - 8)) Then
-	Begin
-	  DitherTab_r565_44[x, y, i] := ((i + 8) And $f8) Shl 8;
-	  DitherTab_r332_44[x, y, i] := ((i + 8) And $e0);
-	End
-	Else
-	Begin
-	  DitherTab_r565_44[x, y, i] := (i And $f8) Shl 8;
-	  DitherTab_r332_44[x, y, i] := i And $e0;
-	End;
-        If (DitherMatrix_44[x, y] < ((i And $3) Shl 1)) And (i < (256 - 4)) Then
-	Begin
-	  DitherTab_g565_44[x, y, i] := (((i + 4) And $fc) Shl 8) Shr 5;
-	  DitherTab_g332_44[x, y, i] := ((i + 4) And $e0) Shr 3;
-	End
-	Else
-	Begin
-	  DitherTab_g565_44[x, y, i] := ((i And $fc) Shl 8) Shr 5;
-	  DitherTab_g332_44[x, y, i] := (i And $e0) Shr 3;
-	End;
-        If (DitherMatrix_44[x, y] < (i And $7)) And (i < (256 - 8)) Then
-	Begin
-	  DitherTab_b565_44[x, y, i] := (((i + 8) And $f8) Shl 16) Shr 19;
-	  DitherTab_b332_44[x, y, i] := ((i + 8) Shr 6) And $3;
-	End
-	Else
-	Begin
-	  DitherTab_b565_44[x, y, i] := ((i And $f8) Shl 16) Shr 19;
-	  DitherTab_b332_44[x, y, i] := (i Shr 6) And $3;
-	End;
-      End;
-End;

+ 134 - 123
packages/hermes/src/factconv.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -24,15 +36,14 @@
    which use the generic loop.
    There needs to be a function assigned to the scanline loop however,
    otherwise the converter will fail a test in Convert.c. This is the easiest
-   way. Do NOT use NotApplicable as NotYetImplemented ! }
-Procedure NotApplicable(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Begin
-  If source <> Nil Then;
-  If dest <> Nil Then;
-  If count <> 0 Then;
-  If inc_source <> 0 Then;
-End;
+   way. do NOT use NotApplicable as NotYetImplemented ! }
+procedure NotApplicable(source, dest: PUint8; count, inc_source: DWord); cdecl;
+begin
+  if source <> nil Then;
+  if dest <> nil Then;
+  if count <> 0 Then;
+  if inc_source <> 0 Then;
+end;
 
 {  Factory converter array, holds ALL converters available from HERMES. Note
    that converters have to be assigned IN ORDER of priority for processors
@@ -43,154 +54,154 @@ End;
       - X86 converters
       - Pascal converters
 
-   If someone wrote a P2 or P3 converter, if would be added even further up. }
+   if someone wrote a P2 or P3 converter, if would be added even further up. }
 
-Const
+const
   Factory_NumConverters = 45
   {$IFDEF I386_ASSEMBLER}+27{$ENDIF I386_ASSEMBLER};
 
-  Factory_Converters : Array[0..Factory_NumConverters - 1] Of THermesFactoryStruct =
+  Factory_Converters: array [0..Factory_NumConverters - 1] of THermesFactoryStruct =
 (
 {$IFDEF I386_ASSEMBLER}
   { ------ From 32 RGB 888 - MMX PENTIUM II ---- }
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
-   loopnormal:@ConvertMMX;loopstretch:Nil;normal:@ConvertMMXpII32_24RGB888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_MMX_PENTIUM),
+   loopnormal:@ConvertMMX;loopstretch:nil;normal:@ConvertMMXpII32_24RGB888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_MMX_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$f800;d_g:$7e0;d_b:$1f;d_a:0;
-   loopnormal:@ConvertMMX;loopstretch:Nil;normal:@ConvertMMXpII32_16RGB565;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_MMX_PENTIUM),
+   loopnormal:@ConvertMMX;loopstretch:nil;normal:@ConvertMMXpII32_16RGB565;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_MMX_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$7e0;d_b:$f800;d_a:0;
-   loopnormal:@ConvertMMX;loopstretch:Nil;normal:@ConvertMMXpII32_16BGR565;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_MMX_PENTIUM),
+   loopnormal:@ConvertMMX;loopstretch:nil;normal:@ConvertMMXpII32_16BGR565;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_MMX_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
-   loopnormal:@ConvertMMX;loopstretch:Nil;normal:@ConvertMMXpII32_16RGB555;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_MMX_PENTIUM),
+   loopnormal:@ConvertMMX;loopstretch:nil;normal:@ConvertMMXpII32_16RGB555;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_MMX_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$3e0;d_b:$7c00;d_a:0;
-   loopnormal:@ConvertMMX;loopstretch:Nil;normal:@ConvertMMXpII32_16BGR555;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_MMX_PENTIUM),
+   loopnormal:@ConvertMMX;loopstretch:nil;normal:@ConvertMMXpII32_16BGR555;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_MMX_PENTIUM),
 
   { ------ From 32 RGB 888 - MMX PENTIUM ------- }
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
-   loopnormal:@ConvertMMX;loopstretch:Nil;normal:@ConvertMMXpII32_16RGB555;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_MMX_PENTIUM),
+   loopnormal:@ConvertMMX;loopstretch:nil;normal:@ConvertMMXpII32_16RGB555;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_MMX_PENTIUM),
 
   { ------ From 32 RGB 888 - X86 PENTIUM ------- }
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_32BGR888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_32BGR888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff000000;d_g:$ff0000;d_b:$ff00;d_a:$ff;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_32RGBA888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_32RGBA888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff00;d_g:$ff0000;d_b:$ff000000;d_a:$ff;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_32BGRA888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_32BGRA888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_24RGB888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_24RGB888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_24BGR888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_24BGR888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$f800;d_g:$7e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertX86;loopstretch:@ConvertX86Stretch;
    normal:@ConvertX86p32_16RGB565;stretch:@ConvertX86p32_16RGB565_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$7e0;d_b:$f800;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_16BGR565;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_16BGR565;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_16RGB555;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_16RGB555;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$3e0;d_b:$7c00;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_16BGR555;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_16BGR555;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:8;d_idx:False;d_r:$e0;d_g:$1c;d_b:$3;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p32_8RGB332;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p32_8RGB332;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   { ------ From 16 RGB 565 - X86 PENTIUM ------- }
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_32RGB888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_32RGB888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_32BGR888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_32BGR888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff000000;d_g:$ff0000;d_b:$ff00;d_a:$ff;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_32RGBA888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_32RGBA888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff00;d_g:$ff0000;d_b:$ff000000;d_a:$ff;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_32BGRA888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_32BGRA888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_24RGB888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_24RGB888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_24BGR888;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_24BGR888;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$7e0;d_b:$f800;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_16BGR565;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_16BGR565;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_16RGB555;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_16RGB555;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$3e0;d_b:$7c00;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_16BGR555;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_16BGR555;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:8;d_idx:False;d_r:$e0;d_g:$1c;d_b:$3;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86p16_8RGB332;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86p16_8RGB332;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 
   (s_bits:8;s_idx:True;s_r:0;s_g:0;s_b:0;s_a:0;
    d_bits:16;d_idx:False;d_r:0;d_g:0;d_b:0;d_a:0;
-   loopnormal:@ConvertX86;loopstretch:Nil;normal:@ConvertX86pI8_16;
-   stretch:Nil;dither:Nil;ditherstretch:Nil;processor:PROC_X86_PENTIUM),
+   loopnormal:@ConvertX86;loopstretch:nil;normal:@ConvertX86pI8_16;
+   stretch:nil;dither:nil;ditherstretch:nil;processor:PROC_X86_PENTIUM),
 {$ENDIF I386_ASSEMBLER}
 
   { ------ From 32 RGBA 8888 ---- }
@@ -199,7 +210,7 @@ Const
    d_bits:32;d_idx:False;d_r:$ff000000;d_g:$ff0000;d_b:$ff00;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_32bgr888;stretch:@ConvertP_32rgb888_32bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
   }
 
   { ------ From 32 RGB 888 ------- }
@@ -208,275 +219,275 @@ Const
    d_bits:32;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_32bgr888;stretch:@ConvertP_32rgb888_32bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff000000;d_g:$ff0000;d_b:$ff00;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_32rgba888;stretch:@ConvertP_32rgb888_32rgba888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff00;d_g:$ff0000;d_b:$ff000000;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_32bgra888;stretch:@ConvertP_32rgb888_32bgra888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_24rgb888;stretch:@ConvertP_32rgb888_24rgb888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_24bgr888;stretch:@ConvertP_32rgb888_24bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$f800;d_g:$7e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_16rgb565;stretch:@ConvertP_32rgb888_16rgb565_S;
-   dither:@ConvertP_32rgb888_16rgb565_dither;ditherstretch:Nil;
+   dither:@ConvertP_32rgb888_16rgb565_dither;ditherstretch:nil;
    processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$7e0;d_b:$f800;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_16bgr565;stretch:@ConvertP_32rgb888_16bgr565_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_16rgb555;stretch:@ConvertP_32rgb888_16rgb555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$3e0;d_b:$7c00;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_16bgr555;stretch:@ConvertP_32rgb888_16bgr555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:32;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:8;d_idx:False;d_r:$e0;d_g:$1c;d_b:$3;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_32rgb888_8rgb332;stretch:@ConvertP_32rgb888_8rgb332_S;
    dither:@ConvertP_32rgb888_8rgb332_dither;
-   ditherstretch:Nil;processor:PROC_GENERIC),
+   ditherstretch:nil;processor:PROC_GENERIC),
 
  { ------ From 32 RGB MUHMU ------- }
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_32rgb888;stretch:@ConvertP_muhmu32_32rgb888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_32bgr888;stretch:@ConvertP_muhmu32_32bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff000000;d_g:$ff0000;d_b:$ff00;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_32rgba888;stretch:@ConvertP_muhmu32_32rgba888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff00;d_g:$ff0000;d_b:$ff000000;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_32bgra888;stretch:@ConvertP_muhmu32_32bgra888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_24rgb888;stretch:@ConvertP_muhmu32_24rgb888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_24bgr888;stretch:@ConvertP_muhmu32_24bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$f800;d_g:$7e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_16rgb565;stretch:@ConvertP_muhmu32_16rgb565_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$7e0;d_b:$f800;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_16bgr565;stretch:@ConvertP_muhmu32_16bgr565_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_16rgb555;stretch:@ConvertP_muhmu32_16rgb555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$3e0;d_b:$7c00;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_16bgr555;stretch:@ConvertP_muhmu32_16bgr555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
-  (s_bits:32;s_idx:False;s_r:$ff Shl 20;s_g:$ff Shl 10;s_b:$ff;s_a:0;
+  (s_bits:32;s_idx:False;s_r:$ff shl 20;s_g:$ff shl 10;s_b:$ff;s_a:0;
    d_bits:8;d_idx:False;d_r:$e0;d_g:$1c;d_b:$3;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_muhmu32_8rgb332;stretch:@ConvertP_muhmu32_8rgb332_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   { ------ From 24 RGB 888 ------- }
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_32rgb888;stretch:@ConvertP_24rgb888_32rgb888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_32bgr888;stretch:@ConvertP_24rgb888_32bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff000000;d_g:$ff0000;d_b:$ff00;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_32rgba888;stretch:@ConvertP_24rgb888_32rgba888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff00;d_g:$ff0000;d_b:$ff000000;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_32bgra888;stretch:@ConvertP_24rgb888_32bgra888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_24bgr888;stretch:@ConvertP_24rgb888_24bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$f800;d_g:$7e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_16rgb565;stretch:@ConvertP_24rgb888_16rgb565_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$7e0;d_b:$f800;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_16bgr565;stretch:@ConvertP_24rgb888_16bgr565_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_16rgb555;stretch:@ConvertP_24rgb888_16rgb555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$3e0;d_b:$7c00;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_16bgr555;stretch:@ConvertP_24rgb888_16bgr555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:24;s_idx:False;s_r:$ff0000;s_g:$ff00;s_b:$ff;s_a:0;
    d_bits:8;d_idx:False;d_r:$e0;d_g:$1c;d_b:$3;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_24rgb888_8rgb332;stretch:@ConvertP_24rgb888_8rgb332_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   { ------ From 16 RGB 565 ------- }
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_32rgb888;stretch:@ConvertP_16rgb565_32rgb888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_32bgr888;stretch:@ConvertP_16rgb565_32bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff000000;d_g:$ff0000;d_b:$ff00;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_32rgba888;stretch:@ConvertP_16rgb565_32rgba888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:32;d_idx:False;d_r:$ff00;d_g:$ff0000;d_b:$ff000000;d_a:$ff;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_32bgra888;stretch:@ConvertP_16rgb565_32bgra888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff0000;d_g:$ff00;d_b:$ff;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_24rgb888;stretch:@ConvertP_16rgb565_24rgb888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:24;d_idx:False;d_r:$ff;d_g:$ff00;d_b:$ff0000;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_24bgr888;stretch:@ConvertP_16rgb565_24bgr888_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$7e0;d_b:$f800;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_16bgr565;stretch:@ConvertP_16rgb565_16bgr565_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:16;d_idx:False;d_r:$7c00;d_g:$3e0;d_b:$1f;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_16rgb555;stretch:@ConvertP_16rgb565_16rgb555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:16;d_idx:False;d_r:$1f;d_g:$3e0;d_b:$7c00;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_16bgr555;stretch:@ConvertP_16rgb565_16bgr555_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:16;s_idx:False;s_r:$f800;s_g:$7e0;s_b:$1f;s_a:0;
    d_bits:8;d_idx:False;d_r:$e0;d_g:$1c;d_b:$3;d_a:0;
    loopnormal:@ConvertP;loopstretch:@ConvertPStretch;
    normal:@ConvertP_16rgb565_8rgb332;stretch:@ConvertP_16rgb565_8rgb332_S;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   { ------ From 8 bit INDEXED ------- }
   (s_bits:8;s_idx:True;s_r:0;s_g:0;s_b:0;s_a:0;
    d_bits:32;d_idx:False;d_r:0;d_g:0;d_b:0;d_a:0;
    loopnormal:@ConvertP_index8_32;loopstretch:@ConvertP_index8_32_S;
    normal:@NotApplicable;stretch:@NotApplicable;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:8;s_idx:True;s_r:0;s_g:0;s_b:0;s_a:0;
    d_bits:24;d_idx:False;d_r:0;d_g:0;d_b:0;d_a:0;
    loopnormal:@ConvertP_index8_24;loopstretch:@ConvertP_index8_24_S;
    normal:@NotApplicable;stretch:@NotApplicable;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:8;s_idx:True;s_r:0;s_g:0;s_b:0;s_a:0;
    d_bits:16;d_idx:False;d_r:0;d_g:0;d_b:0;d_a:0;
    loopnormal:@ConvertP_index8_16;loopstretch:@ConvertP_index8_16_S;
    normal:@NotApplicable;stretch:@NotApplicable;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC),
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC),
 
   (s_bits:8;s_idx:True;s_r:0;s_g:0;s_b:0;s_a:0;
    d_bits:8;d_idx:False;d_r:0;d_g:0;d_b:0;d_a:0;
    loopnormal:@ConvertP_index8_8;loopstretch:@ConvertP_index8_8_S;
    normal:@NotApplicable;stretch:@NotApplicable;
-   dither:Nil;ditherstretch:Nil;processor:PROC_GENERIC)
+   dither:nil;ditherstretch:nil;processor:PROC_GENERIC)
 );

+ 0 - 398
packages/hermes/src/factory.inc

@@ -1,398 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-Var
-  Processor : Integer;
-
-Procedure Hermes_Factory_Init;
-
-Var
-  res : Integer;
-
-Begin
-  res := 0;
-  Processor := PROC_GENERIC;
-
-  {$IFDEF I386_ASSEMBLER}
-    Processor := Processor Or PROC_X86_PENTIUM;{There are no others at the moment}
-    res := Hermes_X86_CPU;
-    If (res And $800000) <> 0 Then
-    Begin
-//      Writeln('mmx disabled for debugging');
-      Processor := Processor Or PROC_MMX_PENTIUM;
-{      Writeln('mmx!');}
-    End;
-  {$ENDIF I386_ASSEMBLER}
-End;
-
-Function Hermes_Factory_getClearer(bits : int32) : PHermesClearer;
-
-Var
-  tmp : PHermesClearer;
-
-Begin
-  { Try different processors in order of priority..
-    Note that for this to work, an MMX processor has to have both MMX and
-    X86 flags }
-  tmp := malloc(SizeOf(THermesClearer));
-  If tmp = Nil Then
-  Begin
-    Hermes_Factory_getClearer := Nil;
-    Exit;
-  End;
-
-  tmp^.bits := bits;
-  Hermes_Factory_getClearer := tmp;
-
-  {$IFDEF I386_ASSEMBLER}
-    If (Processor And PROC_MMX_PENTIUM) <> 0 Then
-      Case bits Of
-        32 : Begin
-          tmp^.func := @ClearMMX_32;
-          Exit;
-        End;
-        24 : ;
-        16 : Begin
-          tmp^.func := @ClearMMX_16;
-          Exit;
-        End;
-        8 : Begin
-          tmp^.func := @ClearMMX_8;
-          Exit;
-        End;
-      End;
-
-    If (Processor And PROC_X86_PENTIUM) <> 0 Then
-      Case bits Of
-        32 : Begin
-          tmp^.func := @ClearX86_32;
-          Exit;
-        End;
-        24 : ;
-        16 : Begin
-          tmp^.func := @ClearX86_16;
-          Exit;
-        End;
-        8 : Begin
-          tmp^.func := @ClearX86_8;
-          Exit;
-        End;
-      End;
-  {$ENDIF I386_ASSEMBLER}
-
-  Case bits Of
-    32 : Begin
-      tmp^.func := @ClearP_32;
-      Exit;
-    End;
-    24 : Begin
-      tmp^.func := @ClearP_24;
-      Exit;
-    End;
-    16 : Begin
-      tmp^.func := @ClearP_16;
-      Exit;
-    End;
-    8 : Begin
-      tmp^.func := @ClearP_8;
-      Exit;
-    End;
-    Else
-    Begin
-      free(tmp);
-      Hermes_Factory_getClearer := Nil;
-    End;
-  End;
-End;
-
-Function Hermes_Factory_getConverter(source, dest : PHermesFormat) : PHermesConverter;
-
-Var
-  tmp : PHermesConverter;
-  i : Integer;
-  found : Boolean;
-
-Begin
-  found := False;
-
-  tmp := malloc(SizeOf(THermesConverter));
-  If tmp = Nil Then
-  Begin
-    Hermes_Factory_getConverter := Nil;
-    Exit;
-  End;
-
-  { Set all conversion routines to nil }
-  tmp^.loopnormal := Nil;
-  tmp^.loopstretch := Nil;
-  tmp^.normal := Nil;
-  tmp^.stretch := Nil;
-  tmp^.dither := Nil;
-  tmp^.ditherstretch := Nil;
-  tmp^.flags := 0;
-
-  If source^.indexed Then
-    { For 8 bit indexed, just look at the destination bit depth and check
-      if the converter's processor is a subset of our processor }
-    For i := 0 To Factory_NumConverters - 1 Do
-      If (Factory_Converters[i].d_bits = dest^.bits) And
-        (Factory_Converters[i].s_idx And
-        ((processor And Factory_Converters[i].processor) <> 0)) Then
-      Begin
-        { If any routines are unassigned, assign them now }
-
-        If tmp^.loopnormal = Nil Then
-        Begin
-          tmp^.loopnormal := Factory_Converters[i].loopnormal;
-          found := True;
-        End;
-
-        If tmp^.normal = Nil Then
-        Begin
-          tmp^.normal := Factory_Converters[i].normal;
-          found := True;
-        End;
-
-        If tmp^.loopstretch = Nil Then
-        Begin
-          tmp^.loopstretch := Factory_Converters[i].loopstretch;
-          found := True;
-        End;
-
-        If tmp^.stretch = Nil Then
-        Begin
-          tmp^.stretch := Factory_Converters[i].stretch;
-          found := True;
-        End;
-      End Else
-  Else
-    { Otherwise we need to compare everything, including bitmasks }
-    For i := 0 To Factory_NumConverters - 1 Do
-      If (Factory_Converters[i].d_bits = dest^.bits) And
-         (Factory_Converters[i].d_r = dest^.r) And
-         (Factory_Converters[i].d_g = dest^.g) And
-         (Factory_Converters[i].d_b = dest^.b) And
-         (Factory_Converters[i].d_a = dest^.a) And
-         (Factory_Converters[i].d_idx = dest^.indexed) And
-         (Factory_Converters[i].s_bits = source^.bits) And
-         (Factory_Converters[i].s_r = source^.r) And
-         (Factory_Converters[i].s_g = source^.g) And
-         (Factory_Converters[i].s_b = source^.b) And
-         (Factory_Converters[i].s_a = source^.a) And
-         (Factory_Converters[i].s_idx = source^.indexed) And
-         ((processor And Factory_Converters[i].processor) <> 0) Then
-      Begin
-        { If any routines are unassigned, assign them now }
-
-        If (tmp^.loopnormal = Nil) And
-           (Factory_Converters[i].loopnormal <> Nil) Then
-        Begin
-          tmp^.loopnormal := Factory_Converters[i].loopnormal;
-          found := True;
-        End;
-
-        If (tmp^.normal = Nil) And
-           (Factory_Converters[i].normal <> Nil) Then
-        Begin
-          tmp^.normal := Factory_Converters[i].normal;
-          found := True;
-        End;
-
-        If (tmp^.loopstretch = Nil) And
-           (Factory_Converters[i].loopstretch <> Nil) Then
-        Begin
-          tmp^.loopstretch := Factory_Converters[i].loopstretch;
-          found := True;
-        End;
-
-        If (tmp^.stretch = Nil) And
-           (Factory_Converters[i].stretch <> Nil) Then
-        Begin
-          tmp^.stretch := Factory_Converters[i].stretch;
-          found := True;
-        End;
-
-        If (tmp^.dither = Nil) And
-           (Factory_Converters[i].dither <> Nil) Then
-        Begin
-          tmp^.dither := Factory_Converters[i].dither;
-          found := True;
-        End;
-
-        If (tmp^.ditherstretch = Nil) And
-           (Factory_Converters[i].ditherstretch <> Nil) Then
-        Begin
-          tmp^.ditherstretch := Factory_Converters[i].ditherstretch;
-          found := True;
-        End;
-
-        { In the rare event of having everything assigned, pull the emergency
-          break. Otherwise we need to continue looking (might be stretching
-          routines somewhere :)
-          Do I sound like a stewardess? }
-        If (tmp^.loopnormal <> Nil) And (tmp^.normal <> Nil) And
-           (tmp^.loopstretch <> Nil) And (tmp^.stretch <> Nil) And
-           (tmp^.dither <> Nil) And (tmp^.ditherstretch <> Nil) Then
-          Break;
-      End;
-
-  If found Then
-  Begin
-    Hermes_FormatCopy(source, @tmp^.source);
-    Hermes_FormatCopy(dest, @tmp^.dest);
-
-    Hermes_Factory_getConverter := tmp;
-  End
-  Else
-  Begin
-    free(tmp);
-    Hermes_Factory_getConverter := Nil;
-  End;
-End;
-
-Function Hermes_Factory_getEqualConverter(bits : Integer) : PHermesConverter;
-
-Var
-  found : Boolean;
-  tmp : PHermesConverter;
-  asm_found : Integer;
-  c_found : Integer;
-
-Begin
-  found := False;
-  tmp := malloc(SizeOf(THermesConverter));
-  If tmp = Nil Then
-  Begin
-    Hermes_Factory_getEqualConverter := Nil;
-    Exit;
-  End;
-
-  { Set all conversion routines to null }
-  tmp^.loopnormal := Nil;
-  tmp^.loopstretch := Nil;
-  tmp^.normal := Nil;
-  tmp^.stretch := Nil;
-  tmp^.dither := Nil;
-  tmp^.ditherstretch := Nil;
-
-{$IFDEF I386_ASSEMBLER}
-
-  { Try MMX routines }
-  If (tmp^.loopnormal = Nil) Or (tmp^.normal = Nil) Or
-     (tmp^.loopstretch = Nil) Or (tmp^.stretch = Nil) Then
-    If (processor And PROC_MMX_PENTIUM) <> 0 Then
-{      Case bits Of
-      End};
-
-  { Try X86 routines }
-  If (tmp^.loopnormal = Nil) Or (tmp^.normal = Nil) Or
-     (tmp^.loopstretch = Nil) Or (tmp^.stretch = Nil) Then
-    If (processor And PROC_X86_PENTIUM) <> 0 Then
-    Begin
-      asm_found := 0;
-      Case bits Of
-        32 : Begin
-          tmp^.normal := @CopyX86p_4byte; asm_found := 1;
-        End;
-        24 : ;
-        16 : Begin
-          tmp^.normal := @CopyX86p_2byte; asm_found := 1;
-        End;
-         8 : Begin
-          tmp^.normal := @CopyX86p_1byte; asm_found := 1;
-        End;
-      End;
-
-      If (asm_found And 1) <> 0 Then
-      Begin
-        tmp^.loopnormal := @ConvertX86;
-        found := True;
-      End;
-    End;
-
-{$ENDIF I386_ASSEMBLER}
-
-
-  If (tmp^.loopnormal = Nil) Or (tmp^.normal = Nil) Or
-     (tmp^.loopstretch = Nil) Or (tmp^.stretch = Nil) Then
-  Begin
-    c_found := 0;
-
-    Case bits Of
-      32 : Begin
-        If tmp^.normal = Nil Then
-        Begin
-          tmp^.normal := @CopyP_4byte; c_found := c_found Or 1;
-        End;
-        If tmp^.stretch = Nil Then
-        Begin
-          tmp^.stretch := @CopyP_4byte_S; c_found := c_found Or 2;
-        End;
-      End;
-      24 : Begin
-        If tmp^.normal = Nil Then
-        Begin
-          tmp^.normal := @CopyP_3byte; c_found := c_found Or 1;
-        End;
-        If tmp^.stretch = Nil Then
-        Begin
-          tmp^.stretch := @CopyP_3byte_S; c_found := c_found Or 2;
-        End;
-      End;
-      16 : Begin
-        If tmp^.normal = Nil Then
-        Begin
-          tmp^.normal := @CopyP_2byte; c_found := c_found Or 1;
-        End;
-        If tmp^.stretch = Nil Then
-        Begin
-          tmp^.stretch := @CopyP_2byte_S; c_found := c_found Or 2;
-        End;
-      End;
-       8 : Begin
-        If tmp^.normal = Nil Then
-        Begin
-          tmp^.normal := @CopyP_1byte; c_found := c_found Or 1;
-        End;
-        If tmp^.stretch = Nil Then
-        Begin
-          tmp^.stretch := @CopyP_1byte_S; c_found := c_found Or 2;
-        End;
-      End;
-    End;
-
-    If (c_found And 1) <> 0 Then
-    Begin
-      tmp^.loopnormal := @ConvertP; found := True;
-    End;
-    If (c_found And 2) <> 0 Then
-    Begin
-      tmp^.loopstretch := @ConvertPStretch; found := True;
-    End;
-  End;
-
-  If found Then
-    Hermes_Factory_getEqualConverter := tmp
-  Else
-  Begin
-    free(tmp);
-    Hermes_Factory_getEqualConverter := Nil;
-  End;
-End;

+ 0 - 138
packages/hermes/src/format.inc

@@ -1,138 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-{Function Hermes_FormatNewEmpty : PHermesFormat;
-Function Hermes_FormatNew(bits : Integer; r, g, b, a : int32;
-                          indexed : Boolean) : PHermesFormat;
-Procedure Hermes_FormatFree(fmt : PHermesFormat);
-Function Hermes_FormatNewEx(bits : Integer; r, g, b, a : int32;
-                            indexed, has_colorkey : Boolean;
-                            colorkey : int32) : PHermesFormat;
-Function Hermes_FormatEquals(op1, op2 : PHermesFormat) : Boolean;
-Procedure Hermes_FormatCopy(source, dest : PHermesFormat);}
-
-Function Hermes_FormatNewEmpty : PHermesFormat;
-
-Var
-  tmp : PHermesFormat;
-
-Begin
-  tmp := malloc(SizeOf(THermesFormat));
-  If tmp = Nil Then
-  Begin
-    Hermes_FormatNewEmpty := Nil;
-    Exit;
-  End;
-  tmp^.bits := 0;
-  tmp^.indexed := False;
-  tmp^.r := 0;
-  tmp^.g := 0;
-  tmp^.b := 0;
-  tmp^.a := 0;
-  tmp^.has_colorkey := False;
-  tmp^.colorkey := 0;
-  Hermes_FormatNewEmpty := tmp;
-End;
-
-Function Hermes_FormatNew(bits : Integer; r, g, b, a : int32;
-                          indexed : Boolean) : PHermesFormat;
-
-Var
-  tmp : PHermesFormat;
-
-Begin
-  If indexed And (bits <> 8) Then
-  Begin
-    Hermes_FormatNew := Nil;
-    Exit;
-  End;
-  tmp := malloc(SizeOf(THermesFormat));
-  If tmp = Nil Then
-  Begin
-    Hermes_FormatNew := Nil;
-    Exit;
-  End;
-  tmp^.bits := bits;
-  tmp^.r := r;
-  tmp^.g := g;
-  tmp^.b := b;
-  tmp^.a := a;
-  tmp^.indexed := indexed;
-  tmp^.has_colorkey := False;
-  tmp^.colorkey := 0;
-  Hermes_FormatNew := tmp;
-End;
-
-Procedure Hermes_FormatFree(fmt : PHermesFormat);
-
-Begin
-  If fmt <> Nil Then
-    free(fmt);
-End;
-
-Function Hermes_FormatNewEx(bits : Integer; r, g, b, a : int32;
-                            indexed, has_colorkey : Boolean;
-                            colorkey : int32) : PHermesFormat;
-
-Var
-  tmp : PHermesFormat;
-
-Begin
-  If indexed And (bits <> 8) Then
-  Begin
-    Hermes_FormatNewEx := Nil;
-    Exit;
-  End;
-  tmp := malloc(SizeOf(THermesFormat));
-  If tmp = Nil Then
-  Begin
-    Hermes_FormatNewEx := Nil;
-    Exit;
-  End;
-  tmp^.bits := bits;
-  tmp^.r := r;
-  tmp^.g := g;
-  tmp^.b := b;
-  tmp^.a := a;
-  tmp^.indexed := indexed;
-  tmp^.has_colorkey := has_colorkey;
-  tmp^.colorkey := colorkey;
-  Hermes_FormatNewEx := tmp;
-End;
-
-Function Hermes_FormatEquals(op1, op2 : PHermesFormat) : Boolean;
-
-Begin
-  Hermes_FormatEquals := ((op1^.indexed = op2^.indexed) And
-                          (op1^.bits = op2^.bits) And
-                          (op1^.r = op2^.r) And
-                          (op1^.g = op2^.g) And
-                          (op1^.b = op2^.b) And
-                          (op1^.a = op2^.a) And
-                          (op1^.has_colorkey = op2^.has_colorkey) And
-                          ((op1^.has_colorkey = False) Or
-                           (op1^.colorkey = op2^.colorkey)));
-End;
-
-Procedure Hermes_FormatCopy(source, dest : PHermesFormat);
-
-Begin
-  Move(source^, dest^, SizeOf(THermesFormat));
-End;

+ 18 - 6
packages/hermes/src/headp.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -20,23 +32,23 @@
 
 { This little definition makes everything much nicer below here }
 {$MACRO ON}
-{$define CONVERT_PARAMETERS:=source, dest : Pchar8; count, inc_source : DWord}
+{$define CONVERT_PARAMETERS:=source, dest: PUint8; count, inc_source: DWord}
 
 {$I p_16.inc}
 {$I p_24.inc}
 {$I p_32.inc}
-{ $I p32aoblt.pp}
+{ $I p32aoblt.inc}
 {$I p_clr.inc}
 {$I p_cnv.inc}
 {$I p_cpy.inc}
 {$I p_g.inc}
 {$I p_ga.inc}
 {$I p_gac.inc}
-{ $I p_gaoblt.pp}
+{ $I p_gaoblt.inc}
 {$I p_gca.inc}
 {$I p_gcc.inc}
-{ $I p_gccblt.pp}
-{ $I p_gcoblt.pp}
+{ $I p_gccblt.inc}
+{ $I p_gcoblt.inc}
 {$I p_i8.inc}
 {$I p_muhmu.inc}
 {$I d_32.inc}

+ 41 - 16
packages/hermes/src/hermconf.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -19,22 +31,35 @@
 }
 
 
-Const
-  HERMES_INITIAL = 8; { Initial size and growth of dynamic }
-  HERMES_GROWTH = 4; { array structures }
-
-  A_32 = 3;		      { oh yes, hardcode it... tsk tsk tsk }
-  R_32 = 2;                   { Position of R,G,B in a 32 bit dword }
+const
+  {$IFDEF FPC_LITTLE_ENDIAN}
+  A_32 = 3;                   { oh yes, hardcode it... tsk tsk tsk }
+  R_32 = 2;                   { Position of R,G,B in a 32 bit dword (in ARGB8888 format) }
   G_32 = 1;
   B_32 = 0;
-  R_24 = 2;                   { Position of R,G,B in a 24 bit pixel }
+  R_24 = 2;                   { Position of R,G,B in a 24 bit pixel (in RGB888 format) }
   G_24 = 1;
   B_24 = 0;
-{  #define DWORD_BYTE0(s) s         /* Shift values to get to bytes in dwords */
-  #define DWORD_BYTE1(s) ((s)<<8)  /* Check out the bracket paranoia to */   
-  #define DWORD_BYTE2(s) ((s)<<16) /* prevent bugs :)) */     
-  #define DWORD_BYTE3(s) ((s)<<24)       
-  #define DWORD_SHORT0(s) s
-  #define DWORD_SHORT1(s) ((s)<<16)
-  #define DWORD_SHORT0(s) s
-  #define DWORD_SHORT1(s) ((s)<<16)}
+
+  DWORD_BYTE0_SHL = 0;
+  DWORD_BYTE1_SHL = 8;
+  DWORD_BYTE2_SHL = 16;
+  DWORD_BYTE3_SHL = 24;
+  DWORD_SMALLINT0_SHL = 0;
+  DWORD_SMALLINT1_SHL = 16;
+  {$ELSE FPC_LITTLE_ENDIAN}
+  A_32 = 0;
+  R_32 = 1;
+  G_32 = 2;
+  B_32 = 3;
+  R_24 = 0;
+  G_24 = 1;
+  B_24 = 2;
+
+  DWORD_BYTE0_SHL = 24;
+  DWORD_BYTE1_SHL = 16;
+  DWORD_BYTE2_SHL = 8;
+  DWORD_BYTE3_SHL = 0;
+  DWORD_SMALLINT0_SHL = 16;
+  DWORD_SMALLINT1_SHL = 0;
+  {$ENDIF FPC_LITTLE_ENDIAN}

+ 22 - 24
packages/hermes/src/hermdef.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -22,26 +34,19 @@
 {$IFDEF CPU86}
   {$DEFINE I386_ASSEMBLER}
   {$IFNDEF win32}
-    Const
-      ExternalAsmPrefix='_';
+    {$IFNDEF go32v2}
+    const
+      ExternalAsmPrefix='_'; // targets other than go32v2 and win32
+    {$ELSE go32v2}
+    const
+      ExternalAsmPrefix=''; // go32v2
+    {$ENDIF go32v2}
   {$ELSE win32}
-    Const
-      ExternalAsmPrefix='';
+    const
+      ExternalAsmPrefix=''; // win32
   {$ENDIF win32}
 {$ENDIF CPU86}
 
-{$IFDEF VER1_0}
-  {$IFDEF ENDIAN_LITTLE}
-    {$DEFINE FPC_LITTLE_ENDIAN}
-  {$ENDIF ENDIAN_LITTLE}
-  {$IFDEF ENDIAN_BIG}
-    {$DEFINE FPC_BIG_ENDIAN}
-  {$ENDIF ENDIAN_BIG}
-  Type
-    PtrInt = LongInt;
-    PtrUInt = Cardinal;
-{$ENDIF VER1_0}
-
 {$IFDEF FPC_LITTLE_ENDIAN}
   {$IFDEF FPC_BIG_ENDIAN}
     {$FATAL Both FPC_LITTLE_ENDIAN and FPC_BIG_ENDIAN defined?!}
@@ -51,10 +56,3 @@
     {$FATAL Neither FPC_LITTLE_ENDIAN, nor FPC_BIG_ENDIAN defined?!}
   {$ENDIF FPC_BIG_ENDIAN}
 {$ENDIF FPC_LITTLE_ENDIAN}
-
-{$IFDEF FPC_LITTLE_ENDIAN}
-  {$INFO FPC_LITTLE_ENDIAN}
-{$ENDIF FPC_LITTLE_ENDIAN}
-{$IFDEF FPC_BIG_ENDIAN}
-  {$INFO FPC_BIG_ENDIAN}
-{$ENDIF FPC_BIG_ENDIAN}

+ 232 - 213
packages/hermes/src/hermes.pp

@@ -6,7 +6,19 @@
     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.
+    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
@@ -18,65 +30,77 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 }
 
-Unit Hermes;
+unit Hermes;
 
 {$MODE objfpc}
 
-Interface
+interface
 
-Const
+const
   HERMES_CONVERT_NORMAL = 0;
   HERMES_CONVERT_DITHER = 1;
 
-Type
-  THermesHandle = Integer;
-  Pint32 = ^int32;
-  int32 = DWord;
-  Pshort16 = ^short16;
-  short16 = Word;
-  Pchar8 = ^char8;
-  char8 = Byte;
+type
+  THermesConverterHandle = Pointer;
+  THermesPaletteHandle = Pointer;
+  THermesClearerHandle = Pointer;
+  PUint8  = ^Uint8;
+  PUint16 = ^Uint16;
+  PUint32 = ^Uint32;
+  PUint64 = ^Uint64;
+  PSint8  = ^Sint8;
+  PSint16 = ^Sint16;
+  PSint32 = ^Sint32;
+  PSint64 = ^Sint64;
+  Uint8  = Byte;
+  Uint16 = Word;
+  Uint32 = DWord;
+  Uint64 = QWord;
+  Sint8  = ShortInt;
+  Sint16 = SmallInt;
+  Sint32 = LongInt;
+  Sint64 = Int64;
   PHermesFormat = ^THermesFormat;
-  THermesFormat = Record
-    r,g,b,a : int32;
-    bits : Integer;
-    indexed : Boolean;
-    has_colorkey : Boolean;
-    colorkey : int32;
-  End;
+  THermesFormat = record
+    r,g,b,a: Uint32;
+    bits: Integer;
+    indexed: Boolean;
+    has_colorkey: Boolean;
+    colorkey: Uint32;
+  end;
 
-Function Hermes_FormatNewEmpty : PHermesFormat;
+function Hermes_FormatNewEmpty: PHermesFormat;
 
-{ Create a new format structure, returns 0 if failed. }
-Function Hermes_FormatNew(bits : Integer; r, g, b, a : int32;
-                          indexed : Boolean) : PHermesFormat;
+{ Create a new format structure, returns nil if failed. }
+function Hermes_FormatNew(bits: Integer; r, g, b, a: Uint32;
+                          indexed: Boolean): PHermesFormat;
 
 { Free a format structure }
-Procedure Hermes_FormatFree(fmt : PHermesFormat);
+procedure Hermes_FormatFree(fmt: PHermesFormat);
 
-{ Create a new format structure with colorkey info, returns 0 if failed. }
-Function Hermes_FormatNewEx(bits : Integer; r, g, b, a : int32;
-                            indexed, has_colorkey : Boolean;
-                            colorkey : int32) : PHermesFormat;
+{ Create a new format structure with colorkey info, returns nil if failed. }
+function Hermes_FormatNewEx(bits: Integer; r, g, b, a: Uint32;
+                            indexed, has_colorkey: Boolean;
+                            colorkey: Uint32): PHermesFormat;
 
 { Compare two formats. Return true if they are equal, false otherwise }
-Function Hermes_FormatEquals(op1, op2 : PHermesFormat) : Boolean;
+function Hermes_FormatEquals(op1, op2: PHermesFormat): Boolean;
 
 { Copy the contents of format 'source' to format 'destination' }
-Procedure Hermes_FormatCopy(source, dest : PHermesFormat);
+procedure Hermes_FormatCopy(source, dest: PHermesFormat);
 
 
 {
    Get a converter to work with, specifying a combination of the flags
-   above. Returns 0 if unsuccessful.
+   above. Returns nil if unsuccessful.
 }
-Function Hermes_ConverterInstance(flags : DWord) : THermesHandle;
+function Hermes_ConverterInstance(flags: DWord): THermesConverterHandle;
 
 {
    Return a converter if it is not needed anymore, thus releasing some
    memory.
 }
-Procedure Hermes_ConverterReturn(handle : THermesHandle);
+procedure Hermes_ConverterReturn(handle: THermesConverterHandle);
 
 {
    Request a format conversion between two formats. This function returns false
@@ -84,27 +108,27 @@ Procedure Hermes_ConverterReturn(handle : THermesHandle);
    Repeated calls to this function will be cached an terminate almost
    immediately, so don't be ashamed of calling it often.
 }
-Function Hermes_ConverterRequest(handle : THermesHandle;
-                                 source, dest : PHermesFormat) : Boolean;
+function Hermes_ConverterRequest(handle: THermesConverterHandle;
+                                 source, dest: PHermesFormat): Boolean;
 
 {
    Set the palette of the source surface / destination surface for a
    subsequent conversion. At the moment, only sourcepal is used.
    Returns false if unsuccessful (invalid handle!).
 }
-Function Hermes_ConverterPalette(handle, sourcepal, destpal : THermesHandle) : Boolean;
+function Hermes_ConverterPalette(handle: THermesConverterHandle; sourcepal, destpal: THermesPaletteHandle): Boolean;
 
 {
-   Do a format conversion after calling the setup routines above. This will
+   do a format conversion after calling the setup routines above. This will
    convert (or copy) the pixel data from s_pixels to the data in d_pixels.
    Both source and destination areas/origins can be specified as well as
    the scanline width in bytes of the source/destination.
    Returns false if unsuccessful (invalid handle or request not called before).
 }
-Function Hermes_ConverterCopy(handle : THermesHandle; s_pixels : Pointer;
-                              s_x, s_y, s_width, s_height, s_pitch : Integer;
-                              d_pixels : Pointer; d_x, d_y, d_width,
-                              d_height, d_pitch : Integer) : Boolean;
+function Hermes_ConverterCopy(handle: THermesConverterHandle; s_pixels: Pointer;
+                              s_x, s_y, s_width, s_height, s_pitch: Integer;
+                              d_pixels: Pointer; d_x, d_y, d_width,
+                              d_height, d_pitch: Integer): Boolean;
 
 (*
 {-----------------H_BLIT---------------}
@@ -113,13 +137,13 @@ Function Hermes_ConverterCopy(handle : THermesHandle; s_pixels : Pointer;
    Get a blitter to work with, specifying a combination of the flags
    in H_Conv. Returns 0 if unsuccessful.
 }
-Function Hermes_BlitterInstance(flags : DWord) : THermesHandle;
+function Hermes_BlitterInstance(flags: DWord): THermesHandle;
 
 {
    Return a blitter if it is not needed anymore, thus releasing some
    memory.
 }
-Procedure Hermes_BlitterReturn(handle : THermesHandle);
+procedure Hermes_BlitterReturn(handle: THermesHandle);
 
 {
    Request a format blitting between two formats. This function returns false
@@ -127,101 +151,101 @@ Procedure Hermes_BlitterReturn(handle : THermesHandle);
    Repeated calls to this function will be cached an terminate almost
    immediately, so don't be ashamed of calling it often.
 }
-Function Hermes_BlitterRequest(handle : THermesHandle;
-                               source, dest : PHermesFormat) : Boolean;
+function Hermes_BlitterRequest(handle: THermesHandle;
+                               source, dest: PHermesFormat): Boolean;
 
 {
    Set the palette of the source surface / destination surface for a
    subsequent blitting. At the moment, only sourcepal is used.
    Returns false if unsuccessful (invalid handle!).
 }
-Function Hermes_BlitterPalette(handle, sourcepal, destpal : THermesHandle) : Boolean;
+function Hermes_BlitterPalette(handle, sourcepal, destpal: THermesHandle): Boolean;
 
 {
-   Do a format blitting after calling the setup routines above. This will
+   do a format blitting after calling the setup routines above. This will
    blit the pixel data from s_pixels to the data in d_pixels.  Both source
    and destination areas/origins can be specified as well as the scanline
    width in bytes of the source/destination.  Returns false if unsuccessful
    (invalid handle or request not called before).
 }
-Function Hermes_BlitterBlit(handle : THermesHandle; s_pixels : Pointer;
-                            s_x, s_y, s_width, s_height, s_pitch : Integer;
-                            d_pixels : Pointer; d_x, d_y, d_width, d_height,
-                            d_pitch : Integer) : Boolean;
+function Hermes_BlitterBlit(handle: THermesHandle; s_pixels: Pointer;
+                            s_x, s_y, s_width, s_height, s_pitch: Integer;
+                            d_pixels: Pointer; d_x, d_y, d_width, d_height,
+                            d_pitch: Integer): Boolean;
 *)
 {-----------------H_PAL---------------}
 
 { Get a handle for a palette to work with. This allocates memory for an
-   internal palette. Returns 0 if failed.
+   internal palette. Returns nil if failed.
 }
-Function Hermes_PaletteInstance : THermesHandle;
+function Hermes_PaletteInstance: THermesPaletteHandle;
 
 {
    Return a handle for a palette if the palette isn't used anymore. The
    internal palette will be deallocated.
 }
-Procedure Hermes_PaletteReturn(handle : THermesHandle);
+procedure Hermes_PaletteReturn(handle: THermesPaletteHandle);
 
 {
    Copy the contents of the palette parameter provided into the internal
    palette. The user palette has to be 256*4 bytes long.
 }
-Procedure Hermes_PaletteSet(handle : THermesHandle; palette : Pointer);
+procedure Hermes_PaletteSet(handle: THermesPaletteHandle; palette: Pointer);
 
 {
    Return the pointer to the internal palette. The palette is 256*4 bytes
    long.
 }
-Function Hermes_PaletteGet(handle : THermesHandle) : Pointer;
+function Hermes_PaletteGet(handle: THermesPaletteHandle): Pointer;
 
 {
    Force invalidation of the palette cache. This will force lookup tables to
    be regenerated and has to be done manually after PaletteGet has been used
    and the data has been modified without the knowledge of Hermes.
 }
-Procedure Hermes_PaletteInvalidateCache(handle : THermesHandle);
+procedure Hermes_PaletteInvalidateCache(handle: THermesPaletteHandle);
 
 
 {-----------------H_CLEAR---------------}
 
 {
-   Get a handle for a new clearer instance to work with. Returns 0 if failed.
+   Get a handle for a new clearer instance to work with. Returns nil if failed.
 }
-Function Hermes_ClearerInstance : THermesHandle;
+function Hermes_ClearerInstance: THermesClearerHandle;
 
 {
    Return the clearer instance if it is no longer needed.
 }
-Procedure Hermes_ClearerReturn(handle : THermesHandle);
+procedure Hermes_ClearerReturn(handle: THermesClearerHandle);
 
 {
    Request the clearing routines to be set up for clearing to a specific
    format later. Repeated calls to the routine will be cached and terminate
    after a short check.
 }
-Function Hermes_ClearerRequest(handle : THermesHandle; format : PHermesFormat) : Boolean;
+function Hermes_ClearerRequest(handle: THermesClearerHandle; format: PHermesFormat): Boolean;
 
 {
    Clear a surface. pixels points to the pixel data, x1, y1, width, height
    specify the area to clear, pitch is the width of a scanline in bytes,
    the rest are the colour components.
 }
-Function Hermes_ClearerClear(handle : THermesHandle; pixels : Pointer;
-                             x1, y1, width, height, pitch : Integer;
-                             r, g, b : int32; index : char8) : Boolean;
+function Hermes_ClearerClear(handle: THermesClearerHandle; pixels: Pointer;
+                             x1, y1, width, height, pitch: Integer;
+                             r, g, b: Uint32; index: Uint8): Boolean;
 
 
 { Initialise Hermes, returns false if failed }
-Function Hermes_Init : Boolean;
+function Hermes_Init: Boolean;
 
 { Deinitialise Hermes, returns false if failed }
-Function Hermes_Done : Boolean;
+function Hermes_Done: Boolean;
 
-Implementation
+implementation
 
 {$I hermdef.inc}
 
-Const
+const
   PROC_GENERIC = 1;
   PROC_X86_PENTIUM = 2;
   PROC_MMX_PENTIUM = 4;
@@ -229,102 +253,103 @@ Const
 
 {$I hermconf.inc}
 
-Type
+type
+  THermesHandle = Integer;
   PHermesClearInterface = ^THermesClearInterface;
-  THermesClearInterface = Record
-    dest : ^char8;
-    value : int32;
-    width, height : Integer;
-    add : Integer;
-  End;
-  THermesClearPtr = Procedure(hci : PHermesClearInterface); CDecl;
+  THermesClearInterface = record
+    dest: ^Uint8;
+    value: Uint32;
+    width, height: Integer;
+    add: Integer;
+  end;
+  THermesClearPtr = procedure(hci: PHermesClearInterface); cdecl;
   PHermesClearer = ^THermesClearer;
-  THermesClearer = Record
-    bits : Integer;
-    func : THermesClearPtr;
-  End;
+  THermesClearer = record
+    bits: Integer;
+    func: THermesClearPtr;
+  end;
 
 
 { Structure to hold shift amounts for the generic routines }
   PHermesGenericInfo = ^THermesGenericInfo;
-  THermesGenericInfo = Record
-    r_right, g_right, b_right, a_right : Integer; {Shift amount to the right}
-    r_left, g_left, b_left, a_left : Integer; {Shift amount to the right}
-  End;
+  THermesGenericInfo = record
+    r_right, g_right, b_right, a_right: Integer; {Shift amount to the right}
+    r_left, g_left, b_left, a_left: Integer; {Shift amount to the right}
+  end;
 
 
 { Pointer to specialised (one-scanline-only) conversion procedure }
-  THermesConverterPtr = Procedure(source, dest : Pchar8;
-                                  count, inc_source : DWord); CDecl;
+  THermesConverterPtr = procedure(source, dest: PUint8;
+                                  count, inc_source: DWord); cdecl;
 
 { Structure for conversion loop routines, don't be scared, size does NOT
    matter in this case :) }
   PHermesConverterInterface = ^THermesConverterInterface;
-  THermesConverterInterface = Record
-    s_pixels : Pchar8;
-    s_width,s_height : Integer;
-    s_add : Integer;          { Offset to next line from end of line }
+  THermesConverterInterface = record
+    s_pixels: PUint8;
+    s_width,s_height: Integer;
+    s_add: Integer;          { Offset to next line from end of line }
 
-    d_pixels : Pchar8;
-    d_width,d_height : Integer;
-    d_add : Integer;
+    d_pixels: PUint8;
+    d_width,d_height: Integer;
+    d_add: Integer;
 
-    func : THermesConverterPtr;
+    func: THermesConverterPtr;
 
-    lookup : Pint32;          { Palette lookup table ptr, for 8 bit }
+    lookup: PUint32;          { Palette lookup table ptr, for 8 bit }
 
-    s_pitch : Integer;        { Source and destination pitch, }
-    d_pitch : Integer;        { only used by C routines }
+    s_pitch: Integer;        { Source and destination pitch, }
+    d_pitch: Integer;        { only used by C routines }
 
-    info : THermesGenericInfo; { Only used by generic converters }
-    mask_r, mask_g, mask_b, mask_a : int32; { Only used by generic converters }
-    s_mask_a : int32;
+    info: THermesGenericInfo; { Only used by generic converters }
+    mask_r, mask_g, mask_b, mask_a: Uint32; { Only used by generic converters }
+    s_mask_a: Uint32;
 
-    s_has_colorkey : Boolean;
-    s_colorkey : int32;
+    s_has_colorkey: Boolean;
+    s_colorkey: Uint32;
 
-    d_has_colorkey : Boolean;
-    d_colorkey : int32;
-  End;
+    d_has_colorkey: Boolean;
+    d_colorkey: Uint32;
+  end;
 
 { Pointer to loop function (C, assembler main loop, generic routines) }
-  THermesConverterLoopPtr = Procedure(hci : PHermesConverterInterface); CDecl;
+  THermesConverterLoopPtr = procedure(hci: PHermesConverterInterface); cdecl;
 
   PHermesConverter = ^THermesConverter;
-  THermesConverter = Record
-    source,dest : THermesFormat;           { Source and destination format }
-    lookup : Pint32;                       { Pointer to lookup table (8bit) }
+  THermesConverter = record
+    source,dest: THermesFormat;           { Source and destination format }
+    lookup: PUint32;                       { Pointer to lookup table (8bit) }
 
-    flags : DWord;                         { Defined in H_Conv.h, DITHER,etc}
+    flags: DWord;                         { Defined in H_Conv.h, DITHER,etc}
 
-    loopnormal : THermesConverterLoopPtr;  { Loop routine for normal conv. }
-    loopstretch : THermesConverterLoopPtr;
-    normal : THermesConverterPtr;          { One-scanline routine }
-    stretch : THermesConverterPtr;
+    loopnormal: THermesConverterLoopPtr;  { Loop routine for normal conv. }
+    loopstretch: THermesConverterLoopPtr;
+    normal: THermesConverterPtr;          { One-scanline routine }
+    stretch: THermesConverterPtr;
 
-    dither : THermesConverterLoopPtr;        { Dithering routines always }
-    ditherstretch : THermesConverterLoopPtr; { convert the whole buffer }
-  End;
+    dither: THermesConverterLoopPtr;        { Dithering routines always }
+    ditherstretch: THermesConverterLoopPtr; { convert the whole buffer }
+  end;
 
   PHermesFactoryStruct = ^THermesFactoryStruct;
-  THermesFactoryStruct = Record
-    s_bits : Integer;
-    s_idx : Boolean;
-    s_r, s_g, s_b, s_a : int32;
-    d_bits : Integer;
-    d_idx : Boolean;
-    d_r, d_g, d_b, d_a : int32;
+  THermesFactoryStruct = record
+    s_bits: Integer;
+    s_idx: Boolean;
+    s_r, s_g, s_b, s_a: Uint32;
+    d_bits: Integer;
+    d_idx: Boolean;
+    d_r, d_g, d_b, d_a: Uint32;
 
-    loopnormal, loopstretch : THermesConverterLoopPtr;
-    normal, stretch : THermesConverterPtr;
-    dither, ditherstretch : THermesConverterLoopPtr;
+    loopnormal, loopstretch: THermesConverterLoopPtr;
+    normal, stretch: THermesConverterPtr;
+    dither, ditherstretch: THermesConverterLoopPtr;
 
-    processor : Integer;
-  End;
+    processor: Integer;
+  end;
 
 {dither types ?}
 
-Const
+const
 { p_converters holds a list of formats, for conversion from 32 bit, 24 bit,
   16 bit, muhmu and 8 bit.
   The destination formats are listed in the order of frequency they might
@@ -336,7 +361,7 @@ Const
 }
 { I wish I could touch this, but it's used in too many other placed in the code,
   ( at least indirectly), and many of the indicies are hardcoded }
-  p_converters : Array[0..4, 0..11, 0..11] Of DWord =
+  p_converters: array [0..4, 0..11, 0..11] of DWord =
   (
   ( {From 32 bit RGB 888}
   (32,0,$ff0000,$ff00,$ff,0,16,0,$f800,$7e0,$1f,0),          {16RGB565 }
@@ -404,47 +429,43 @@ Const
   (0,0,0,0,0,0,0,0,0,0,0,0),(0,0,0,0,0,0,0,0,0,0,0,0)
   )
   );
-  numConverters : Array[0..4] Of Integer = (10,10,10,11,4);
-  refcount : Integer = 0;
-
-Var
-  Clearers : Array[0..3] Of PHermesClearer;
-  numClearers : Integer;
-  standardConverters : Array[0..4] Of ^PHermesConverter;
-  equalConverters : Array[0..3] Of PHermesConverter;
+  numConverters: array [0..4] of Integer = (10,10,10,11,4);
+  refcount: Integer = 0;
 
-{$I malloc.inc}
+var
+  Clearers: array [0..3] of PHermesClearer;
+  numClearers: Integer;
+  standardConverters: array [0..4] of ^PHermesConverter;
+  equalConverters: array [0..3] of PHermesConverter;
 
-{$I debug.inc}
+{$I hermes_debug.inc}
 
-{$I dither.inc}
+{$I hermes_dither.inc}
 {$I headp.inc}
 {$IFDEF I386_ASSEMBLER}
   {$I i386/headi386.inc}
   {$I i386/headmmx.inc}
 {$ENDIF I386_ASSEMBLER}
 {$I factconv.inc}
-{$I list.inc}
-{$I utility.inc}
-{$I format.inc}
-{$I palette.inc}
-{$I convert.inc}
-{$I clear.inc}
-{$I factory.inc}
-
-Function Hermes_Init : Boolean;
-
-Var
-  i, j : Integer;
-  source, dest : THermesFormat;
-
-Begin
-  If refcount > 0 Then
-  Begin
+{$I hermes_list.inc}
+{$I hermes_utility.inc}
+{$I hermes_format.inc}
+{$I hermes_palette.inc}
+{$I hermes_converter.inc}
+{$I hermes_clearer.inc}
+{$I hermes_factory.inc}
+
+function Hermes_Init: Boolean;
+var
+  i, j: Integer;
+  source, dest: THermesFormat;
+begin
+  if refcount > 0 then
+  begin
     Inc(refcount);
-    Hermes_Init := True;
-    Exit;
-  End;
+    Result := True;
+    exit;
+  end;
   { Initialise hermes factory }
   Hermes_Factory_Init;
 
@@ -456,11 +477,11 @@ Begin
   numClearers := 4;
 
   { Use factory to obtain specialised converters }
-  For j := 0 To 4 Do
-  Begin
-    standardConverters[j] := malloc(SizeOf(PHermesConverter)*numConverters[j]);
-    For i := 0 To numConverters[j] - 1 Do
-    Begin
+  for j := 0 to 4 do
+  begin
+    standardConverters[j] := GetMem(SizeOf(PHermesConverter)*numConverters[j]);
+    for i := 0 to numConverters[j] - 1 do
+    begin
       // xxx jm color keys not taken into consideration here
       FillChar(source, SizeOf(source), 0);
       FillChar(dest, SizeOf(dest), 0);
@@ -472,8 +493,8 @@ Begin
       source.a := p_converters[j, i, 5];       dest.a := p_converters[j, i, 11];
 
       standardConverters[j][i] := Hermes_Factory_getConverter(@source, @dest);
-    End;
-  End;
+    end;
+  end;
 
 
   { Set up converters for equal colour formats }
@@ -486,51 +507,49 @@ Begin
   Dither_SetupMatrices;
 
   Inc(refcount);
-  Hermes_Init := True;
-End;
-
-Function Hermes_Done : Boolean;
-
-Var
-  i, j : Integer;
+  Result := True;
+end;
 
-Begin
+function Hermes_Done: Boolean;
+var
+  i, j: Integer;
+begin
   Dec(refcount);
-  If refcount < 0 Then
-  Begin
+  if refcount < 0 then
+  begin
     refcount := 0;
-    Hermes_Done := False;
-    Exit;
-  End;
-  If refcount = 0 Then
-  Begin
-    For i := 0 To 3 Do
-    Begin
-      If Clearers[i] <> Nil Then
-      Begin
-        free(Clearers[i]);
-        Clearers[i] := Nil;
-      End;
-      If equalConverters[i] <> Nil Then
-      Begin
-        free(equalConverters[i]);
-        equalConverters[i] := Nil;
-      End;
-    End;
-    For i := 0 To 4 Do
-    Begin
-      If standardConverters[i] <> Nil Then
-      Begin
-        For j := 0 To numConverters[i] - 1 Do
-          free(standardConverters[i][j]);
-        free(standardConverters[i]);
-      End;
-      standardConverters[i] := Nil;
-    End;
-  End;
-  Hermes_Done := True;
-End;
-
-Begin
+    Result := False;
+    exit;
+  end;
+  if refcount = 0 then
+  begin
+    for i := 0 to 3 do
+    begin
+      if Clearers[i] <> nil then
+      begin
+        Dispose(Clearers[i]);
+        Clearers[i] := nil;
+      end;
+      if equalConverters[i] <> nil then
+      begin
+        Dispose(equalConverters[i]);
+        equalConverters[i] := nil;
+      end;
+    end;
+    for i := 0 to 4 do
+    begin
+      if standardConverters[i] <> nil then
+      begin
+        for j := 0 to numConverters[i] - 1 do
+          Dispose(standardConverters[i][j]);
+        FreeMem(standardConverters[i]);
+        standardConverters[i] := nil;
+      end;
+    end;
+  end;
+  Result := True;
+end;
+
+begin
   DebugInit;
-End.
+end.

+ 156 - 0
packages/hermes/src/hermes_clearer.inc

@@ -0,0 +1,156 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+type
+  PClearerInstance = ^TClearerInstance;
+  TClearerInstance = record
+    format: PHermesFormat;
+    func: THermesClearPtr;
+  end;
+
+function Hermes_ClearerInstance: THermesClearerHandle;
+var
+  newinstance: PClearerInstance;
+begin
+  New(newinstance);
+  newinstance^.func := nil;
+  newinstance^.format := Hermes_FormatNewEmpty;
+  Result := THermesClearerHandle(newinstance);
+end;
+
+procedure Hermes_ClearerReturn(handle: THermesClearerHandle);
+begin
+  if handle <> nil then
+  begin
+    Hermes_FormatFree(PClearerInstance(handle)^.format);
+    Dispose(PClearerInstance(handle));
+  end;
+end;
+
+function Hermes_ClearerRequest(handle: THermesClearerHandle; format: PHermesFormat): Boolean;
+var
+  clr: PClearerInstance;
+  i: Integer;
+begin
+  if handle = nil then
+  begin
+    Result := False;
+    exit;
+  end;
+  clr := PClearerInstance(handle);
+
+  { if the clearer is the same, return 1 }
+  if Hermes_FormatEquals(clr^.format, format) then
+  begin
+    Result := True;
+    exit;
+  end;
+
+  { Otherwise look for a new clearer }
+  clr^.func := nil;
+  for i := 0 to numClearers - 1 do
+  begin
+    if Clearers[i]^.bits = format^.bits then
+    begin
+      clr^.func := Clearers[i]^.func;
+      Hermes_FormatCopy(format, clr^.format);
+      Result := True;
+      exit;
+    end;
+  end;
+  Result := False;
+end;
+
+function Hermes_ClearerClear(handle: THermesClearerHandle; pixels: Pointer;
+                             x1, y1, width, height, pitch: Integer;
+                             r, g, b: Uint32; index: Uint8): Boolean;
+var
+  info: THermesGenericInfo;
+  clr: PClearerInstance;
+  pixelval, d_r, d_g, d_b, d_a: Uint32;
+  iface: THermesClearInterface;
+begin
+  if (height <= 0) or (width <= 0) then
+  begin
+    Result := True;
+    exit;
+  end;
+
+  if handle = nil then
+  begin
+    Result := False;
+    exit;
+  end;
+  clr := PClearerInstance(handle);
+
+  { No conversion function assigned }
+  if clr^.func = nil then
+  begin
+    Result := False;
+    exit;
+  end;
+
+  if clr^.format^.indexed then
+    pixelval := index
+  else
+  begin
+    Hermes_Calculate_Generic_Info(24, 16, 8, 32,
+                                  Hermes_Topbit(clr^.format^.r),
+                                  Hermes_Topbit(clr^.format^.g),
+                                  Hermes_Topbit(clr^.format^.b),
+                                  Hermes_Topbit(clr^.format^.a), @info);
+    pixelval := (index shl 24) or (r shl 16) or (g shl 8) or b;
+    d_r := ((pixelval shr info.r_right) shl info.r_left) and clr^.format^.r;
+    d_g := ((pixelval shr info.g_right) shl info.g_left) and clr^.format^.g;
+    d_b := ((pixelval shr info.b_right) shl info.b_left) and clr^.format^.b;
+    d_a := ((pixelval shr info.a_right) shl info.a_left) and clr^.format^.a;
+    pixelval := d_r or d_g or d_b or d_a;
+  end;
+  iface.dest := pixels;
+  Inc(iface.dest, y1*pitch + x1*(clr^.format^.bits shr 3));
+
+  iface.width := width;
+  iface.height := height;
+  iface.add := pitch - width * (clr^.format^.bits shr 3);
+
+  iface.value := pixelval;
+
+  { Optimization }
+  if iface.add = 0 then
+  begin
+    iface.width := iface.width * iface.height;
+    iface.height := 1;
+  end;
+
+  clr^.func(@iface);
+  Result := True;
+end;

+ 350 - 427
packages/hermes/src/convert.inc → packages/hermes/src/hermes_converter.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -18,202 +30,115 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 }
 
-
-{Function Hermes_ConverterInstance(flags : DWord) : THermesHandle;
-Procedure Hermes_ConverterReturn(handle : THermesHandle);}
-
-Var
-{ ConverterList is a list of HermesConverter* }
-  ConverterList : ^PHermesConverter;
-  ConvertCurrenthandle : THermesHandle;
-
-Const
-  lastConverter : Integer = 0;                { Array size, one beyond end }
-  CONVERTrefcount : Integer = 0;
-
-Function Hermes_ConverterInstance(flags : DWord) : THermesHandle;
-
-Var
-  i : Integer;
-  newinstance : PHermesConverter;
-  newlist : ^PHermesConverter;
-
-Begin
-  { Initialising, allocate initial size array of converters }
-  If CONVERTrefcount = 0 Then
-  Begin
-    ConverterList := malloc(SizeOf(PHermesConverter) * HERMES_INITIAL);
-    If ConverterList = Nil Then
-    Begin
-      Hermes_ConverterInstance := 0;
-      Exit;
-    End;
-    lastConverter := HERMES_INITIAL;
-    ConvertCurrenthandle := 1;
-    For i := 0 To lastConverter - 1 Do
-      ConverterList[i] := Nil;
-{    DEBUG_PRINT("Creating dynamic array(convert.c:57), size %d\n",HERMES_INITIAL)}
-  End;
-
-  { Uh oh, arrary too small, time for growth }
-  If ConvertCurrenthandle = lastConverter Then
-  Begin
-    { I'm told realloc isn't completely portable !? Let's do it by hand }
-    newlist := malloc(SizeOf(PHermesConverter)*(lastConverter+HERMES_GROWTH));
-    If newlist = Nil Then
-    Begin
-      Hermes_ConverterInstance := 0;
-      Exit;
-    End;
-    { Copy converter pointers }
-    For i := 0 To lastConverter - 1 Do
-      newlist[i] := ConverterList[i];
-    free(ConverterList);
-    { Assign new list to old one }
-    ConverterList := newlist;
-    Inc(lastConverter, HERMES_GROWTH);
-{    DEBUG_PRINT("Growing dynamic array, new size %d\n",lastConverter)}
-  End;
-
+function Hermes_ConverterInstance(flags: DWord): THermesConverterHandle;
+var
+  newinstance: PHermesConverter;
+begin
   { Create a HermesConverter }
-  newinstance := malloc(sizeof(THermesConverter));
-  If newinstance = Nil Then
-  Begin
-    Hermes_ConverterInstance := 0;
-    Exit;
-  End;
+  New(newinstance);
 
   { Zero it out }
-  newinstance^.loopnormal := Nil;
-  newinstance^.loopstretch := Nil;
-  newinstance^.normal := Nil;
-  newinstance^.stretch := Nil;
-  newinstance^.dither := Nil;
-  newinstance^.ditherstretch := Nil;
+  newinstance^.loopnormal := nil;
+  newinstance^.loopstretch := nil;
+  newinstance^.normal := nil;
+  newinstance^.stretch := nil;
+  newinstance^.dither := nil;
+  newinstance^.ditherstretch := nil;
   newinstance^.flags := flags;
   FillChar(newinstance^.source, 0, SizeOf(THermesFormat));
   FillChar(newinstance^.dest, 0, SizeOf(THermesFormat));
 
-  ConverterList[ConvertCurrenthandle] := newinstance;
-
-  Inc(CONVERTrefcount);
-  Inc(ConvertCurrenthandle);
-
-  Hermes_ConverterInstance := ConvertCurrenthandle - 1;
-End;
-
-Procedure Hermes_ConverterReturn(handle : THermesHandle);
-
-Begin
-  If (handle < 0) Or (handle >= lastConverter) Then
-    Exit;
-
-  { Adjust reference count }
-  Dec(CONVERTrefcount);
-
-  If ConverterList[handle] <> Nil Then
-  Begin
-    free(ConverterList[handle]);
-    ConverterList[handle] := Nil;
-  End;
-
-  { No more references, deinitialise }
-  If CONVERTrefcount = 0 Then
-  Begin
-    If ConverterList <> Nil Then
-    Begin
-      free(ConverterList);
-      ConverterList := Nil;
-    End;
-    ConvertCurrenthandle := 0;
-    lastConverter := 0;
-  End;
-End;
-
-Function Hermes_ConverterRequest(handle : THermesHandle;
-                                 source, dest : PHermesFormat) : Boolean;
-
-Var
-  searchlist : Integer;
-  i : Integer;
-  found : Boolean;
-  cnv : PHermesConverter;
-
-Begin
+  Result := THermesConverterHandle(newinstance);
+end;
+
+procedure Hermes_ConverterReturn(handle: THermesConverterHandle);
+begin
+  if handle = nil then
+    exit;
+
+  Dispose(PHermesConverter(handle));
+end;
+
+function Hermes_ConverterRequest(handle: THermesConverterHandle;
+                                 source, dest: PHermesFormat): Boolean;
+var
+  searchlist: Integer;
+  i: Integer;
+  found: Boolean;
+  cnv: PHermesConverter;
+begin
 {  DebugMSG('Hermes_ConverterRequest(' + C2Str(source^.bits)
    + ',' + C2Str(source^.r) + ',' + C2Str(source^.g) + ',' +
    C2Str(source^.b) + ';' + C2Str(dest^.bits)
    + ',' + C2Str(dest^.r) + ',' + C2Str(dest^.g) + ',' +
    C2Str(dest^.b) + ')');}
 
-  Hermes_ConverterRequest := False;
+  Result := False;
   searchlist := 0;
   i := 0;
   found := False;
   { Check array ranges }
-  If (handle < 0) Or (handle >= lastConverter) Then
-    Exit;
-  If ConverterList[handle] = Nil Then
-    Exit;
-  cnv := ConverterList[handle];
+  if handle = nil then
+    exit;
+  cnv := PHermesConverter(handle);
 
   { Cache repeated requests of the same conversion }
-  If Hermes_FormatEquals(source, @ConverterList[handle]^.source) And
-     Hermes_FormatEquals(dest, @ConverterList[handle]^.dest) Then
-  Begin
-    Hermes_ConverterRequest := True;
-    Exit;
-  End;
+  if Hermes_FormatEquals(source, @cnv^.source) and
+     Hermes_FormatEquals(dest, @cnv^.dest) then
+  begin
+    Result := True;
+    exit;
+  end;
 
   { Clear the generic converter flag }
-  cnv^.flags := cnv^.flags And (Not HERMES_CONVERT_GENERIC);
+  cnv^.flags := cnv^.flags and (not HERMES_CONVERT_GENERIC);
 
-  { If the source and destination are equal, use copy routines }
-  If Hermes_FormatEquals(source, dest) Then
-  Begin
+  { if the source and destination are equal, use copy routines }
+  if Hermes_FormatEquals(source, dest) then
+  begin
 {    DebugMSG('format equals!');}
-    If ((source^.bits And 7) <> 0) Or (source^.bits > 32) Or
-       (source^.bits = 0) Then
-      Exit;
-    i := (source^.bits Shr 3) - 1;
-    If equalConverters[i] = Nil Then
-      Exit;
+    if ((source^.bits and 7) <> 0) or (source^.bits > 32) or
+       (source^.bits = 0) then
+      exit;
+    i := (source^.bits shr 3) - 1;
+    if equalConverters[i] = nil then
+      exit;
     Hermes_FormatCopy(source, @cnv^.source);
     Hermes_FormatCopy(dest, @cnv^.dest);
     cnv^.loopnormal := equalConverters[i]^.loopnormal;
     cnv^.loopstretch := equalConverters[i]^.loopstretch;
     cnv^.normal := equalConverters[i]^.normal;
     cnv^.stretch := equalConverters[i]^.stretch;
-    Hermes_ConverterRequest := True;
-    Exit;
-  End;
+    Result := True;
+    exit;
+  end;
 
   { Start looking for specialised converters }
   searchlist := $ff;
-  Case source^.bits Of
-    32 : If (source^.r = $ff0000) And (source^.g = $ff00) And (source^.b = $ff) Then
+  case source^.bits of
+    32: if (source^.r = $ff0000) and (source^.g = $ff00) and (source^.b = $ff) then
            searchlist := 0
-         Else
-           If (source^.r = ($ff Shl 20)) And
-              (source^.g = ($ff Shl 10)) And
-              (source^.b = $ff) Then
+         else
+           if (source^.r = ($ff shl 20)) and
+              (source^.g = ($ff shl 10)) and
+              (source^.b = $ff) then
              searchlist := 3;
-    24 : If (source^.r = $ff0000) And (source^.g = $ff00) And (source^.b = $ff) Then
+    24: if (source^.r = $ff0000) and (source^.g = $ff00) and (source^.b = $ff) then
            searchlist := 1;
-    16 : If (source^.r = $f800) And (source^.g = $7e0) And (source^.b = $1f) Then
+    16: if (source^.r = $f800) and (source^.g = $7e0) and (source^.b = $1f) then
            searchlist := 2;
-     8 : If source^.indexed Then
+     8: if source^.indexed then
            searchlist := 4;
-  End;
+  end;
 
   { We can use a quicker loop for 8 bit }
-  If searchlist <> $ff Then
-    If source^.bits = 8 Then
-    Begin
-      For i := 0 To numConverters[searchlist] - 1 Do
-        If standardConverters[searchlist][i] <> Nil Then
-          If dest^.bits = standardConverters[searchlist][i]^.dest.bits Then
-          Begin
+  if searchlist <> $ff then
+    if source^.bits = 8 then
+    begin
+      for i := 0 to numConverters[searchlist] - 1 do
+        if standardConverters[searchlist][i] <> nil then
+          if dest^.bits = standardConverters[searchlist][i]^.dest.bits then
+          begin
             Hermes_FormatCopy(source, @cnv^.source);
             Hermes_FormatCopy(dest, @cnv^.dest);
 
@@ -226,17 +151,16 @@ Begin
             cnv^.dither := standardConverters[searchlist][i]^.dither;
             cnv^.ditherstretch := standardConverters[searchlist][i]^.ditherstretch;
 
-            Hermes_ConverterRequest := True;
-            Exit;
-          End
-;
-    End
-    Else
-      For i := 0 To numConverters[searchlist] - 1 Do
-        If standardConverters[searchlist][i] <> Nil Then
-          If Hermes_FormatEquals(@standardConverters[searchlist][i]^.source, source) And
-             Hermes_FormatEquals(@standardConverters[searchlist][i]^.dest, dest) Then
-          Begin
+            Result := True;
+            exit;
+          end;
+    end
+    else
+      for i := 0 to numConverters[searchlist] - 1 do
+        if standardConverters[searchlist][i] <> nil then
+          if Hermes_FormatEquals(@standardConverters[searchlist][i]^.source, source) and
+             Hermes_FormatEquals(@standardConverters[searchlist][i]^.dest, dest) then
+          begin
             Hermes_FormatCopy(source, @cnv^.source);
             Hermes_FormatCopy(dest, @cnv^.dest);
 
@@ -249,20 +173,20 @@ Begin
             cnv^.dither := standardConverters[searchlist][i]^.dither;
             cnv^.ditherstretch := standardConverters[searchlist][i]^.ditherstretch;
 
-            Hermes_ConverterRequest := True;
-            Exit;
-          End;
+            Result := True;
+            exit;
+          end;
 
 
   { Otherwise find a generic converter }
 {  DebugMSG('looking for a generic converter!');}
 
 
-  cnv^.loopnormal := Nil;
-  cnv^.loopstretch := Nil;
-  cnv^.dither := Nil;
-  cnv^.ditherstretch := Nil;
-  cnv^.flags := cnv^.flags Or HERMES_CONVERT_GENERIC;
+  cnv^.loopnormal := nil;
+  cnv^.loopstretch := nil;
+  cnv^.dither := nil;
+  cnv^.ditherstretch := nil;
+  cnv^.flags := cnv^.flags or HERMES_CONVERT_GENERIC;
 
 
   { Generic routines implement whole converters not scanline converters,
@@ -285,394 +209,393 @@ Begin
         O -> O , A, C are the same
 }
 
-  If source^.has_colorkey And dest^.has_colorkey Then { Ck -> Ck }
-    Case source^.bits Of
-      32 : Case dest^.bits Of
-        32 : Begin
+  if source^.has_colorkey and dest^.has_colorkey then { Ck -> Ck }
+    case source^.bits of
+      32: case dest^.bits of
+        32: begin
           cnv^.loopnormal := @ConvertP_Generic32_C_Generic32_C;
           cnv^.loopstretch := @ConvertP_Generic32_C_Generic32_C_S;
           found := True;
-        End;
-        24 : Begin
+        end;
+        24: begin
           cnv^.loopnormal := @ConvertP_Generic32_C_Generic24_C;
           found := True;
-        End;
-        16 : Begin
+        end;
+        16: begin
           cnv^.loopnormal := @ConvertP_Generic32_C_Generic16_C;
           cnv^.loopstretch := @ConvertP_Generic32_C_Generic16_C_S;
           found := True;
-        End;
-        8 : Begin
+        end;
+        8: begin
           cnv^.loopnormal := @ConvertP_Generic32_C_Generic8_C;
           found := True;
-        End;
-      End;
-      24 : Case dest^.bits Of
-        32 : Begin
+        end;
+      end;
+      24: case dest^.bits of
+        32: begin
           cnv^.loopnormal := @ConvertP_Generic24_C_Generic32_C;
           found := True;
-        End;
-        24 : Begin
+        end;
+        24: begin
           cnv^.loopnormal := @ConvertP_Generic24_C_Generic24_C;
           found := True;
-        End;
-        16 : Begin
+        end;
+        16: begin
           cnv^.loopnormal := @ConvertP_Generic24_C_Generic16_C;
           found := True;
-        End;
-        8 : Begin
+        end;
+        8: begin
           cnv^.loopnormal := @ConvertP_Generic24_C_Generic8_C;
           found := True;
-        End;
-      End;
-      16 : Case dest^.bits Of
-        32 : Begin
+        end;
+      end;
+      16: case dest^.bits of
+        32: begin
           cnv^.loopnormal := @ConvertP_Generic16_C_Generic32_C;
           found := True;
-        End;
-        24 : Begin
+        end;
+        24: begin
           cnv^.loopnormal := @ConvertP_Generic16_C_Generic24_C;
           found := True;
-        End;
-        16 : Begin
+        end;
+        16: begin
           cnv^.loopnormal := @ConvertP_Generic16_C_Generic16_C;
           found := True;
-        End;
-        8 : Begin
+        end;
+        8: begin
           cnv^.loopnormal := @ConvertP_Generic16_C_Generic8_C;
           found := True;
-        End;
-      End;
-    End
-  Else
-    If source^.has_colorkey And (dest^.a <> 0) Then { Ck -> A }
-      Case source^.bits Of
-        32 : Case dest^.bits Of
-          32 : Begin
+        end;
+      end;
+    end
+  else
+    if source^.has_colorkey and (dest^.a <> 0) then { Ck -> A }
+      case source^.bits of
+        32: case dest^.bits of
+          32: begin
             cnv^.loopnormal := @ConvertP_Generic32_C_Generic32_A;
             cnv^.loopstretch := @ConvertP_Generic32_C_Generic32_A_S;
             found := True;
-          End;
-          24 : Begin
+          end;
+          24: begin
             cnv^.loopnormal := @ConvertP_Generic32_C_Generic24_A;
             found := True;
-          End;
-          16 : Begin
+          end;
+          16: begin
             cnv^.loopnormal := @ConvertP_Generic32_C_Generic16_A;
             cnv^.loopstretch := @ConvertP_Generic32_C_Generic16_A_S;
             found := True;
-          End;
-          8 : Begin
+          end;
+          8: begin
             cnv^.loopnormal := @ConvertP_Generic32_C_Generic8_A;
             found := True;
-          End;
-        End;
-        24 : Case dest^.bits Of
-          32 : Begin
+          end;
+        end;
+        24: case dest^.bits of
+          32: begin
             cnv^.loopnormal := @ConvertP_Generic24_C_Generic32_A;
             found := True;
-          End;
-          24 : Begin
+          end;
+          24: begin
             cnv^.loopnormal := @ConvertP_Generic24_C_Generic24_A;
             found := True;
-          End;
-          16 : Begin
+          end;
+          16: begin
             cnv^.loopnormal := @ConvertP_Generic24_C_Generic16_A;
             found := True;
-          End;
-          8 : Begin
+          end;
+          8: begin
             cnv^.loopnormal := @ConvertP_Generic24_C_Generic8_A;
             found := True;
-          End;
-        End;
-        16 : Case dest^.bits Of
-          32 : Begin
+          end;
+        end;
+        16: case dest^.bits of
+          32: begin
             cnv^.loopnormal := @ConvertP_Generic16_C_Generic32_A;
             found := True;
-          End;
-          24 : Begin
+          end;
+          24: begin
             cnv^.loopnormal := @ConvertP_Generic16_C_Generic24_A;
             found := True;
-          End;
-          16 : Begin
+          end;
+          16: begin
             cnv^.loopnormal := @ConvertP_Generic16_C_Generic16_A;
             found := True;
-          End;
-          8 : Begin
+          end;
+          8: begin
             cnv^.loopnormal := @ConvertP_Generic16_C_Generic8_A;
             found := True;
-          End;
-        End;
-      End
-    Else
-      If (source^.a <> 0) And dest^.has_colorkey Then { A -> Ck }
-        Case source^.bits Of
-          32 : Case dest^.bits Of
-            32 : Begin
+          end;
+        end;
+      end
+    else
+      if (source^.a <> 0) and dest^.has_colorkey then { A -> Ck }
+        case source^.bits of
+          32: case dest^.bits of
+            32: begin
               cnv^.loopnormal := @ConvertP_Generic32_A_Generic32_C;
               cnv^.loopstretch := @ConvertP_Generic32_A_Generic32_C_S;
               found := True;
-            End;
-            24 : Begin
+            end;
+            24: begin
               cnv^.loopnormal := @ConvertP_Generic32_A_Generic24_C;
               found := True;
-            End;
-            16 : Begin
+            end;
+            16: begin
               cnv^.loopnormal := @ConvertP_Generic32_A_Generic16_C;
               cnv^.loopnormal := @ConvertP_Generic32_A_Generic16_C_S;
               found := True;
-            End;
-            8 : Begin
+            end;
+            8: begin
               cnv^.loopnormal := @ConvertP_Generic32_A_Generic8_C;
               found := True;
-            End;
-          End;
-          24 : Case dest^.bits Of
-            32 : Begin
+            end;
+          end;
+          24: case dest^.bits of
+            32: begin
               cnv^.loopnormal := @ConvertP_Generic24_A_Generic32_C;
               found := True;
-            End;
-            24 : Begin
+            end;
+            24: begin
               cnv^.loopnormal := @ConvertP_Generic24_A_Generic24_C;
               found := True;
-            End;
-            16 : Begin
+            end;
+            16: begin
               cnv^.loopnormal := @ConvertP_Generic24_A_Generic16_C;
               found := True;
-            End;
-            8 : Begin
+            end;
+            8: begin
               cnv^.loopnormal := @ConvertP_Generic24_A_Generic8_C;
               found := True;
-            End;
-          End;
-          16 : Case dest^.bits Of
-            32 : Begin
+            end;
+          end;
+          16: case dest^.bits of
+            32: begin
               cnv^.loopnormal := @ConvertP_Generic16_A_Generic32_C;
               found := True;
-            End;
-            24 : Begin
+            end;
+            24: begin
               cnv^.loopnormal := @ConvertP_Generic16_A_Generic24_C;
               found := True;
-            End;
-            16 : Begin
+            end;
+            16: begin
               cnv^.loopnormal := @ConvertP_Generic16_A_Generic16_C;
               found := True;
-            End;
-            8 : Begin
+            end;
+            8: begin
               cnv^.loopnormal := @ConvertP_Generic16_A_Generic8_C;
               found := True;
-            End;
-          End;
-        End
-      Else
-        If (source^.a <> 0) And (dest^.a <> 0) Then { A -> A }
-          Case source^.bits Of
-            32 : Case dest^.bits Of
-              32 : Begin
+            end;
+          end;
+        end
+      else
+        if (source^.a <> 0) and (dest^.a <> 0) then { A -> A }
+          case source^.bits of
+            32: case dest^.bits of
+              32: begin
                 cnv^.loopnormal := @ConvertP_Generic32_A_Generic32_A;
                 cnv^.loopstretch := @ConvertP_Generic32_A_Generic32_A_S;
                 found := True;
-              End;
-              24 : Begin
+              end;
+              24: begin
                 cnv^.loopnormal := @ConvertP_Generic32_A_Generic24_A;
                 found := True;
-              End;
-              16 : Begin
+              end;
+              16: begin
                 cnv^.loopnormal := @ConvertP_Generic32_A_Generic16_A;
                 cnv^.loopstretch := @ConvertP_Generic32_A_Generic16_A_S;
                 found := True;
-              End;
-              8 : Begin
+              end;
+              8: begin
                 cnv^.loopnormal := @ConvertP_Generic32_A_Generic8_A;
                 found := True;
-              End;
-            End;
-            24 : Case dest^.bits Of
-              32 : Begin
+              end;
+            end;
+            24: case dest^.bits of
+              32: begin
                 cnv^.loopnormal := @ConvertP_Generic24_A_Generic32_A;
                 found := True;
-              End;
-              24 : Begin
+              end;
+              24: begin
                 cnv^.loopnormal := @ConvertP_Generic24_A_Generic24_A;
                 found := True;
-              End;
-              16 : Begin
+              end;
+              16: begin
                 cnv^.loopnormal := @ConvertP_Generic24_A_Generic16_A;
                 found := True;
-              End;
-              8 : Begin
+              end;
+              8: begin
                 cnv^.loopnormal := @ConvertP_Generic24_A_Generic8_A;
                 found := True;
-              End;
-            End;
-            16 : Case dest^.bits Of
-              32 : Begin
+              end;
+            end;
+            16: case dest^.bits of
+              32: begin
                 cnv^.loopnormal := @ConvertP_Generic16_A_Generic32_A;
                 found := True;
-              End;
-              24 : Begin
+              end;
+              24: begin
                 cnv^.loopnormal := @ConvertP_Generic16_A_Generic24_A;
                 found := True;
-              End;
-              16 : Begin
+              end;
+              16: begin
                 cnv^.loopnormal := @ConvertP_Generic16_A_Generic16_A;
                 found := True;
-              End;
-              8 : Begin
+              end;
+              8: begin
                 cnv^.loopnormal := @ConvertP_Generic16_A_Generic8_A;
                 found := True;
-              End;
-            End;
-          End
-        Else { O->O, O->A, A->O, Ck->O, O->Ck }
-          Case source^.bits Of
-            32 : Case dest^.bits Of
-              32 : Begin
+              end;
+            end;
+          end
+        else { O->O, O->A, A->O, Ck->O, O->Ck }
+          case source^.bits of
+            32: case dest^.bits of
+              32: begin
                 cnv^.loopnormal := @ConvertP_Generic32_Generic32;
                 cnv^.loopstretch := @ConvertP_Generic32_Generic32_S;
                 found := True;
-              End;
-              24 : Begin
+              end;
+              24: begin
                 cnv^.loopnormal := @ConvertP_Generic32_Generic24;
                 cnv^.loopstretch := @ConvertP_Generic32_Generic24_S;
                 found := True;
-              End;
-              16 : Begin
+              end;
+              16: begin
                 cnv^.loopnormal := @ConvertP_Generic32_Generic16;
                 cnv^.loopstretch := @ConvertP_Generic32_Generic16_S;
                 found := True;
-              End;
-              8 : Begin
+              end;
+              8: begin
                 cnv^.loopnormal := @ConvertP_Generic32_Generic8;
                 cnv^.loopstretch := @ConvertP_Generic32_Generic8_S;
                 found := True;
-              End;
-            End;
-            24 : Case dest^.bits Of
-              32 : Begin
+              end;
+            end;
+            24: case dest^.bits of
+              32: begin
                 cnv^.loopnormal := @ConvertP_Generic24_Generic32;
                 cnv^.loopstretch := @ConvertP_Generic24_Generic32_S;
                 found := True;
-              End;
-              24 : Begin
+              end;
+              24: begin
                 cnv^.loopnormal := @ConvertP_Generic24_Generic24;
                 cnv^.loopstretch := @ConvertP_Generic24_Generic24_S;
                 found := True;
-              End;
-              16 : Begin
+              end;
+              16: begin
                 cnv^.loopnormal := @ConvertP_Generic24_Generic16;
                 cnv^.loopstretch := @ConvertP_Generic24_Generic16_S;
                 found := True;
-              End;
-              8 : Begin
+              end;
+              8: begin
                 cnv^.loopnormal := @ConvertP_Generic24_Generic8;
                 cnv^.loopstretch := @ConvertP_Generic24_Generic8_S;
                 found := True;
-              End;
-            End;
-            16 : Case dest^.bits Of
-              32 : Begin
+              end;
+            end;
+            16: case dest^.bits of
+              32: begin
                 cnv^.loopnormal := @ConvertP_Generic16_Generic32;
                 cnv^.loopstretch := @ConvertP_Generic16_Generic32_S;
                 found := True;
-              End;
-              24 : Begin
+              end;
+              24: begin
                 cnv^.loopnormal := @ConvertP_Generic16_Generic24;
                 cnv^.loopstretch := @ConvertP_Generic16_Generic24_S;
                 found := True;
-              End;
-              16 : Begin
+              end;
+              16: begin
                 cnv^.loopnormal := @ConvertP_Generic16_Generic16;
                 cnv^.loopstretch := @ConvertP_Generic16_Generic16_S;
                 found := True;
-              End;
-              8 : Begin
+              end;
+              8: begin
                 cnv^.loopnormal := @ConvertP_Generic16_Generic8;
                 cnv^.loopstretch := @ConvertP_Generic16_Generic8_S;
                 found := True;
-              End;
-            End;
-          End;
+              end;
+            end;
+          end;
 
-  If found Then
-  Begin
+  if found then
+  begin
     Hermes_FormatCopy(source, @cnv^.source);
     Hermes_FormatCopy(dest, @cnv^.dest);
 
-    Hermes_ConverterRequest := True;
-    Exit;
-  End;
+    Result := True;
+    exit;
+  end;
 
   DebugMSG('no converter found!!!');
   { No converter found, fail }
-  Hermes_ConverterRequest := False;
-End;
-
-Function Hermes_ConverterPalette(handle, sourcepal, destpal : THermesHandle) : Boolean;
+  Result := False;
+end;
 
-Begin
+function Hermes_ConverterPalette(handle: THermesConverterHandle; sourcepal, destpal: THermesPaletteHandle): Boolean;
+var
+  cnv: PHermesConverter;
+begin
 {  DebugMSG('Hermes_ConverterPalette('+C2Str(sourcepal)+','+C2Str(destpal)+')');}
-  Hermes_ConverterPalette := False;
-  If (handle < 0) Or (handle >= lastConverter) Then
-    Exit;
-  If ConverterList[handle] = Nil Then
-    Exit;
+  Result := False;
+  if handle = nil then
+    exit;
+
+  cnv := PHermesConverter(handle);
 
   { Fail silently if not indexed colour format }
-  If Not ConverterList[handle]^.source.indexed Then
-  Begin
-    ConverterList[handle]^.lookup := Nil;
-    Hermes_ConverterPalette := True;
-    Exit;
-  End;
-
-  ConverterList[handle]^.lookup :=
-    Hermes_PaletteGetTable(sourcepal, @ConverterList[handle]^.dest);
-
-  If ConverterList[handle]^.lookup = Nil Then
-    Exit;
-
-  Hermes_ConverterPalette := True;
-End;
-
-Function Hermes_ConverterCopy(handle : THermesHandle; s_pixels : Pointer;
-                              s_x, s_y, s_width, s_height, s_pitch : Integer;
-                              d_pixels : Pointer; d_x, d_y, d_width,
-                              d_height, d_pitch : Integer) : Boolean;
-
-Var
-  cnv : PHermesConverter;
-  iface : THermesConverterInterface;
-
-Begin
-  Hermes_ConverterCopy := False;
-  If (handle < 0) Or (handle >= lastConverter) Then
-    Exit;
-  cnv := ConverterList[handle];
-  If cnv = Nil Then
-    Exit;
+  if not cnv^.source.indexed then
+  begin
+    cnv^.lookup := nil;
+    Result := True;
+    exit;
+  end;
+
+  cnv^.lookup := Hermes_PaletteGetTable(sourcepal, @cnv^.dest);
+
+  if cnv^.lookup = nil then
+    exit;
+
+  Result := True;
+end;
+
+function Hermes_ConverterCopy(handle: THermesConverterHandle; s_pixels: Pointer;
+                              s_x, s_y, s_width, s_height, s_pitch: Integer;
+                              d_pixels: Pointer; d_x, d_y, d_width,
+                              d_height, d_pitch: Integer): Boolean;
+var
+  cnv: PHermesConverter;
+  iface: THermesConverterInterface;
+begin
+  Result := False;
+  if handle = nil then
+    exit;
+//  cnv := ConverterList[handle];
+  cnv := PHermesConverter(handle);
+//  if cnv = nil then
+//    exit;
 
   { Returns success if height or width is zero. This is debatable.. ! }
-  If (s_width <= 0) Or (s_height <= 0) Or (d_width <= 0) Or (d_height <= 0) Then
-  Begin
-    Hermes_ConverterCopy := True;
-    Exit;
-  End;
+  if (s_width <= 0) or (s_height <= 0) or (d_width <= 0) or (d_height <= 0) then
+  begin
+    Result := True;
+    exit;
+  end;
 
   iface.s_pixels := s_pixels;
   iface.s_width := s_width;
   iface.s_height := s_height;
-  iface.s_add := s_pitch - s_width * (cnv^.source.bits Shr 3);
+  iface.s_add := s_pitch - s_width * (cnv^.source.bits shr 3);
   iface.s_pitch := s_pitch;
 
   iface.d_pixels := d_pixels;
   iface.d_width := d_width;
   iface.d_height := d_height;
-  iface.d_add := d_pitch - d_width*(cnv^.dest.bits Shr 3);
+  iface.d_add := d_pitch - d_width*(cnv^.dest.bits shr 3);
   iface.d_pitch := d_pitch;
 
-  Inc(iface.s_pixels, s_y * s_pitch + s_x * (cnv^.source.bits Shr 3));
-  Inc(iface.d_pixels, d_y * d_pitch + d_x * (cnv^.dest.bits Shr 3));
+  Inc(iface.s_pixels, s_y * s_pitch + s_x * (cnv^.source.bits shr 3));
+  Inc(iface.d_pixels, d_y * d_pitch + d_x * (cnv^.dest.bits shr 3));
 
   iface.s_has_colorkey := cnv^.source.has_colorkey;
   iface.d_has_colorkey := cnv^.dest.has_colorkey;
@@ -682,10 +605,10 @@ Begin
   iface.lookup := cnv^.lookup;
 
 
-  { For generic converters, do some extra setup (find shifts, etc.)
+  { for generic converters, do some extra setup (find shifts, etc.)
     TODO: Move that out of here and in the request routine ! }
-  If (cnv^.flags And HERMES_CONVERT_GENERIC) <> 0 Then
-  Begin
+  if (cnv^.flags and HERMES_CONVERT_GENERIC) <> 0 then
+  begin
     Hermes_Calculate_Generic_Info(Hermes_Topbit(cnv^.source.r),
                                   Hermes_Topbit(cnv^.source.g),
                                   Hermes_Topbit(cnv^.source.b),
@@ -699,41 +622,41 @@ Begin
     iface.mask_g := cnv^.dest.g;
     iface.mask_b := cnv^.dest.b;
     iface.mask_a := cnv^.dest.a;
-  End;
+  end;
 
   { Check for dithering. This should not be in here but in request as well }
-  If (cnv^.flags And HERMES_CONVERT_DITHER) <> 0 Then
-  Begin
-    { If there is a ditherer, use it else fall back to normal }
-    If cnv^.dither <> Nil Then
+  if (cnv^.flags and HERMES_CONVERT_DITHER) <> 0 then
+  begin
+    { if there is a ditherer, use it else fall back to normal }
+    if cnv^.dither <> nil then
       cnv^.loopnormal := cnv^.dither;
-  End;
+  end;
 
   { Normal conversion }
-  If (s_width = d_width) And (s_height = d_height) Then
-  Begin
-    If (cnv^.normal = Nil) Or (cnv^.loopnormal = Nil) Then
-      Exit;
+  if (s_width = d_width) and (s_height = d_height) then
+  begin
+    if (cnv^.normal = nil) or (cnv^.loopnormal = nil) then
+      exit;
     { Optimization
-    If (iface.s_add = 0) And (iface.d_add = 0) Then
-    Begin
+    if (iface.s_add = 0) and (iface.d_add = 0) then
+    begin
       iface.s_width := iface.s_width * s_height;
       iface.d_width := iface.d_width * d_height;
       iface.s_height := 1;
       iface.d_height := 1;
-    End;}
+    end;}
     iface.func := cnv^.normal;
     cnv^.loopnormal(@iface);
-    Hermes_ConverterCopy := True;
-    Exit;
-  End
+    Result := True;
+    exit;
+  end
   { Stretch conversion }
-  Else
-  Begin
-    If (cnv^.stretch = Nil) Or (cnv^.loopstretch = Nil) Then
-      Exit;
+  else
+  begin
+    if (cnv^.stretch = nil) or (cnv^.loopstretch = nil) then
+      exit;
     iface.func := cnv^.stretch;
     cnv^.loopstretch(@iface);
-  End;
-  Hermes_ConverterCopy := True;
-End;
+  end;
+  Result := True;
+end;

+ 68 - 0
packages/hermes/src/hermes_debug.inc

@@ -0,0 +1,68 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+function C2Str(Q: Integer): string;
+var
+  S: string;
+begin
+  Str(Q, S);
+  Result := S;
+end;
+
+procedure DebugInit;
+{var
+  F: TextFile;}
+begin
+{  AssignFile(F, 'debug.txt');
+  Rewrite(F);
+  CloseFile(F);}
+end;
+
+procedure DebugMSG(S: string);
+var
+  F: TextFile;
+begin
+  AssignFile(F, 'debug.txt');
+  {$I-}
+  Append(F);
+  {$I+}
+  if IOResult <> 0 then
+  begin
+    {$I-}
+    Rewrite(F);
+    {$I+}
+    if IOResult <> 0 then
+      exit;
+  end;
+  Writeln(F, S);
+  CloseFile(F);
+end;

+ 92 - 0
packages/hermes/src/hermes_dither.inc

@@ -0,0 +1,92 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+{ Everything in here (C)1998 The Rasterman }
+
+{ Rasterman's dither matrix }
+
+const
+  DitherMatrix_44: array [0..3, 0..3] of Uint8 = (
+    (0, 4, 1, 5),
+    (6, 2, 7, 3),
+    (1, 5, 0, 4),
+    (7, 3, 6, 2));
+
+var
+  DitherTab_r565_44: array [0..3, 0..3, 0..255] of Uint16;
+  DitherTab_g565_44: array [0..3, 0..3, 0..255] of Uint16;
+  DitherTab_b565_44: array [0..3, 0..3, 0..255] of Uint16;
+
+  DitherTab_r332_44: array [0..3, 0..3, 0..255] of Uint8;
+  DitherTab_g332_44: array [0..3, 0..3, 0..255] of Uint8;
+  DitherTab_b332_44: array [0..3, 0..3, 0..255] of Uint8;
+
+procedure Dither_SetupMatrices;
+var
+  i, x, y: LongInt;
+begin
+  for y := 0 to 3 do
+    for x := 0 to 3 do
+      for i := 0 to 255 do
+      begin
+        if (DitherMatrix_44[x, y] < (i and $7)) and (i < (256 - 8)) then
+        begin
+          DitherTab_r565_44[x, y, i] := ((i + 8) and $f8) shl 8;
+          DitherTab_r332_44[x, y, i] := ((i + 8) and $e0);
+        end
+        else
+        begin
+          DitherTab_r565_44[x, y, i] := (i and $f8) shl 8;
+          DitherTab_r332_44[x, y, i] := i and $e0;
+        end;
+        if (DitherMatrix_44[x, y] < ((i and $3) shl 1)) and (i < (256 - 4)) then
+        begin
+          DitherTab_g565_44[x, y, i] := (((i + 4) and $fc) shl 8) shr 5;
+          DitherTab_g332_44[x, y, i] := ((i + 4) and $e0) shr 3;
+        end
+        else
+        begin
+          DitherTab_g565_44[x, y, i] := ((i and $fc) shl 8) shr 5;
+          DitherTab_g332_44[x, y, i] := (i and $e0) shr 3;
+        end;
+        if (DitherMatrix_44[x, y] < (i and $7)) and (i < (256 - 8)) then
+        begin
+          DitherTab_b565_44[x, y, i] := (((i + 8) and $f8) shl 16) shr 19;
+          DitherTab_b332_44[x, y, i] := ((i + 8) shr 6) and $3;
+        end
+        else
+        begin
+          DitherTab_b565_44[x, y, i] := ((i and $f8) shl 16) shr 19;
+          DitherTab_b332_44[x, y, i] := (i shr 6) and $3;
+        end;
+      end;
+end;

+ 377 - 0
packages/hermes/src/hermes_factory.inc

@@ -0,0 +1,377 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+var
+  Processor: Integer;
+
+procedure Hermes_Factory_Init;
+var
+  res: Integer;
+begin
+  res := 0;
+  Processor := PROC_GENERIC;
+
+  {$IFDEF I386_ASSEMBLER}
+    Processor := Processor or PROC_X86_PENTIUM;{There are no others at the moment}
+    res := Hermes_X86_CPU;
+    if (res and $800000) <> 0 then
+    begin
+//      Writeln('mmx disabled for debugging');
+      Processor := Processor or PROC_MMX_PENTIUM;
+{      Writeln('mmx!');}
+    end;
+  {$ENDIF I386_ASSEMBLER}
+end;
+
+function Hermes_Factory_getClearer(bits: Uint32): PHermesClearer;
+begin
+  { Try different processors in order of priority..
+    Note that for this to work, an MMX processor has to have both MMX and
+    X86 flags }
+  New(Result);
+  Result^.bits := bits;
+
+  {$IFDEF I386_ASSEMBLER}
+    if (Processor and PROC_MMX_PENTIUM) <> 0 then
+      case bits of
+        32: begin
+          Result^.func := @ClearMMX_32;
+          exit;
+        end;
+        24: ;
+        16: begin
+          Result^.func := @ClearMMX_16;
+          exit;
+        end;
+        8: begin
+          Result^.func := @ClearMMX_8;
+          exit;
+        end;
+      end;
+
+    if (Processor and PROC_X86_PENTIUM) <> 0 then
+      case bits of
+        32: begin
+          Result^.func := @ClearX86_32;
+          exit;
+        end;
+        24: ;
+        16: begin
+          Result^.func := @ClearX86_16;
+          exit;
+        end;
+        8: begin
+          Result^.func := @ClearX86_8;
+          exit;
+        end;
+      end;
+  {$ENDIF I386_ASSEMBLER}
+
+  case bits of
+    32: begin
+      Result^.func := @ClearP_32;
+      exit;
+    end;
+    24: begin
+      Result^.func := @ClearP_24;
+      exit;
+    end;
+    16: begin
+      Result^.func := @ClearP_16;
+      exit;
+    end;
+    8: begin
+      Result^.func := @ClearP_8;
+      exit;
+    end;
+    else
+    begin
+      Dispose(Result);
+      Result := nil;
+    end;
+  end;
+end;
+
+function Hermes_Factory_getConverter(source, dest: PHermesFormat): PHermesConverter;
+var
+  i: Integer;
+  found: Boolean;
+begin
+  found := False;
+
+  New(Result);
+
+  { Set all conversion routines to nil }
+  Result^.loopnormal := nil;
+  Result^.loopstretch := nil;
+  Result^.normal := nil;
+  Result^.stretch := nil;
+  Result^.dither := nil;
+  Result^.ditherstretch := nil;
+  Result^.flags := 0;
+
+  if source^.indexed then
+    { for 8 bit indexed, just look at the destination bit depth and check
+      if the converter's processor is a subset of our processor }
+    for i := 0 to Factory_NumConverters - 1 do
+      if (Factory_Converters[i].d_bits = dest^.bits) and
+        (Factory_Converters[i].s_idx and
+        ((processor and Factory_Converters[i].processor) <> 0)) then
+      begin
+        { if any routines are unassigned, assign them now }
+
+        if Result^.loopnormal = nil then
+        begin
+          Result^.loopnormal := Factory_Converters[i].loopnormal;
+          found := True;
+        end;
+
+        if Result^.normal = nil then
+        begin
+          Result^.normal := Factory_Converters[i].normal;
+          found := True;
+        end;
+
+        if Result^.loopstretch = nil then
+        begin
+          Result^.loopstretch := Factory_Converters[i].loopstretch;
+          found := True;
+        end;
+
+        if Result^.stretch = nil then
+        begin
+          Result^.stretch := Factory_Converters[i].stretch;
+          found := True;
+        end;
+      end else
+  else
+    { Otherwise we need to compare everything, including bitmasks }
+    for i := 0 to Factory_NumConverters - 1 do
+      if (Factory_Converters[i].d_bits = dest^.bits) and
+         (Factory_Converters[i].d_r = dest^.r) and
+         (Factory_Converters[i].d_g = dest^.g) and
+         (Factory_Converters[i].d_b = dest^.b) and
+         (Factory_Converters[i].d_a = dest^.a) and
+         (Factory_Converters[i].d_idx = dest^.indexed) and
+         (Factory_Converters[i].s_bits = source^.bits) and
+         (Factory_Converters[i].s_r = source^.r) and
+         (Factory_Converters[i].s_g = source^.g) and
+         (Factory_Converters[i].s_b = source^.b) and
+         (Factory_Converters[i].s_a = source^.a) and
+         (Factory_Converters[i].s_idx = source^.indexed) and
+         ((processor and Factory_Converters[i].processor) <> 0) then
+      begin
+        { if any routines are unassigned, assign them now }
+
+        if (Result^.loopnormal = nil) and
+           (Factory_Converters[i].loopnormal <> nil) then
+        begin
+          Result^.loopnormal := Factory_Converters[i].loopnormal;
+          found := True;
+        end;
+
+        if (Result^.normal = nil) and
+           (Factory_Converters[i].normal <> nil) then
+        begin
+          Result^.normal := Factory_Converters[i].normal;
+          found := True;
+        end;
+
+        if (Result^.loopstretch = nil) and
+           (Factory_Converters[i].loopstretch <> nil) then
+        begin
+          Result^.loopstretch := Factory_Converters[i].loopstretch;
+          found := True;
+        end;
+
+        if (Result^.stretch = nil) and
+           (Factory_Converters[i].stretch <> nil) then
+        begin
+          Result^.stretch := Factory_Converters[i].stretch;
+          found := True;
+        end;
+
+        if (Result^.dither = nil) and
+           (Factory_Converters[i].dither <> nil) then
+        begin
+          Result^.dither := Factory_Converters[i].dither;
+          found := True;
+        end;
+
+        if (Result^.ditherstretch = nil) and
+           (Factory_Converters[i].ditherstretch <> nil) then
+        begin
+          Result^.ditherstretch := Factory_Converters[i].ditherstretch;
+          found := True;
+        end;
+
+        { In the rare event of having everything assigned, pull the emergency
+          break. Otherwise we need to continue looking (might be stretching
+          routines somewhere :)
+          do I sound like a stewardess? }
+        if (Result^.loopnormal <> nil) and (Result^.normal <> nil) and
+           (Result^.loopstretch <> nil) and (Result^.stretch <> nil) and
+           (Result^.dither <> nil) and (Result^.ditherstretch <> nil) then
+          break;
+      end;
+
+  if found then
+  begin
+    Hermes_FormatCopy(source, @Result^.source);
+    Hermes_FormatCopy(dest, @Result^.dest);
+  end
+  else
+  begin
+    Dispose(Result);
+    Result := nil;
+  end;
+end;
+
+function Hermes_Factory_getEqualConverter(bits: Integer): PHermesConverter;
+var
+  found: Boolean;
+  asm_found: Integer;
+  c_found: Integer;
+begin
+  found := False;
+  New(Result);
+
+  { Set all conversion routines to null }
+  Result^.loopnormal := nil;
+  Result^.loopstretch := nil;
+  Result^.normal := nil;
+  Result^.stretch := nil;
+  Result^.dither := nil;
+  Result^.ditherstretch := nil;
+
+{$IFDEF I386_ASSEMBLER}
+
+  { Try MMX routines }
+  if (Result^.loopnormal = nil) or (Result^.normal = nil) or
+     (Result^.loopstretch = nil) or (Result^.stretch = nil) then
+    if (processor and PROC_MMX_PENTIUM) <> 0 then
+{      case bits of
+      end};
+
+  { Try X86 routines }
+  if (Result^.loopnormal = nil) or (Result^.normal = nil) or
+     (Result^.loopstretch = nil) or (Result^.stretch = nil) then
+    if (processor and PROC_X86_PENTIUM) <> 0 then
+    begin
+      asm_found := 0;
+      case bits of
+        32: begin
+          Result^.normal := @CopyX86p_4byte; asm_found := 1;
+        end;
+        24: ;
+        16: begin
+          Result^.normal := @CopyX86p_2byte; asm_found := 1;
+        end;
+         8: begin
+          Result^.normal := @CopyX86p_1byte; asm_found := 1;
+        end;
+      end;
+
+      if (asm_found and 1) <> 0 then
+      begin
+        Result^.loopnormal := @ConvertX86;
+        found := True;
+      end;
+    end;
+
+{$ENDIF I386_ASSEMBLER}
+
+
+  if (Result^.loopnormal = nil) or (Result^.normal = nil) or
+     (Result^.loopstretch = nil) or (Result^.stretch = nil) then
+  begin
+    c_found := 0;
+
+    case bits of
+      32: begin
+        if Result^.normal = nil then
+        begin
+          Result^.normal := @CopyP_4byte; c_found := c_found or 1;
+        end;
+        if Result^.stretch = nil then
+        begin
+          Result^.stretch := @CopyP_4byte_S; c_found := c_found or 2;
+        end;
+      end;
+      24: begin
+        if Result^.normal = nil then
+        begin
+          Result^.normal := @CopyP_3byte; c_found := c_found or 1;
+        end;
+        if Result^.stretch = nil then
+        begin
+          Result^.stretch := @CopyP_3byte_S; c_found := c_found or 2;
+        end;
+      end;
+      16: begin
+        if Result^.normal = nil then
+        begin
+          Result^.normal := @CopyP_2byte; c_found := c_found or 1;
+        end;
+        if Result^.stretch = nil then
+        begin
+          Result^.stretch := @CopyP_2byte_S; c_found := c_found or 2;
+        end;
+      end;
+       8: begin
+        if Result^.normal = nil then
+        begin
+          Result^.normal := @CopyP_1byte; c_found := c_found or 1;
+        end;
+        if Result^.stretch = nil then
+        begin
+          Result^.stretch := @CopyP_1byte_S; c_found := c_found or 2;
+        end;
+      end;
+    end;
+
+    if (c_found and 1) <> 0 then
+    begin
+      Result^.loopnormal := @ConvertP; found := True;
+    end;
+    if (c_found and 2) <> 0 then
+    begin
+      Result^.loopstretch := @ConvertPStretch; found := True;
+    end;
+  end;
+
+  if not found then
+  begin
+    Dispose(Result);
+    Result := nil;
+  end;
+end;

+ 117 - 0
packages/hermes/src/hermes_format.inc

@@ -0,0 +1,117 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+{function Hermes_FormatNewEmpty: PHermesFormat;
+function Hermes_FormatNew(bits: Integer; r, g, b, a: Uint32;
+                          indexed: Boolean): PHermesFormat;
+procedure Hermes_FormatFree(fmt: PHermesFormat);
+function Hermes_FormatNewEx(bits: Integer; r, g, b, a: Uint32;
+                            indexed, has_colorkey: Boolean;
+                            colorkey: Uint32): PHermesFormat;
+function Hermes_FormatEquals(op1, op2: PHermesFormat): Boolean;
+procedure Hermes_FormatCopy(source, dest: PHermesFormat);}
+
+function Hermes_FormatNewEmpty: PHermesFormat;
+begin
+  New(Result);
+  Result^.bits := 0;
+  Result^.indexed := False;
+  Result^.r := 0;
+  Result^.g := 0;
+  Result^.b := 0;
+  Result^.a := 0;
+  Result^.has_colorkey := False;
+  Result^.colorkey := 0;
+end;
+
+function Hermes_FormatNew(bits: Integer; r, g, b, a: Uint32;
+                          indexed: Boolean): PHermesFormat;
+begin
+  if indexed and (bits <> 8) then
+  begin
+    Result := nil;
+    exit;
+  end;
+  New(Result);
+  Result^.bits := bits;
+  Result^.r := r;
+  Result^.g := g;
+  Result^.b := b;
+  Result^.a := a;
+  Result^.indexed := indexed;
+  Result^.has_colorkey := False;
+  Result^.colorkey := 0;
+end;
+
+procedure Hermes_FormatFree(fmt: PHermesFormat);
+begin
+  if fmt <> nil then
+    Dispose(fmt);
+end;
+
+function Hermes_FormatNewEx(bits: Integer; r, g, b, a: Uint32;
+                            indexed, has_colorkey: Boolean;
+                            colorkey: Uint32): PHermesFormat;
+begin
+  if indexed and (bits <> 8) then
+  begin
+    Result := nil;
+    exit;
+  end;
+  New(Result);
+  Result^.bits := bits;
+  Result^.r := r;
+  Result^.g := g;
+  Result^.b := b;
+  Result^.a := a;
+  Result^.indexed := indexed;
+  Result^.has_colorkey := has_colorkey;
+  Result^.colorkey := colorkey;
+end;
+
+function Hermes_FormatEquals(op1, op2: PHermesFormat): Boolean;
+begin
+  Result := ((op1^.indexed = op2^.indexed) and
+             (op1^.bits = op2^.bits) and
+             (op1^.r = op2^.r) and
+             (op1^.g = op2^.g) and
+             (op1^.b = op2^.b) and
+             (op1^.a = op2^.a) and
+             (op1^.has_colorkey = op2^.has_colorkey) and
+            ((op1^.has_colorkey = False) or
+             (op1^.colorkey = op2^.colorkey)));
+end;
+
+procedure Hermes_FormatCopy(source, dest: PHermesFormat);
+begin
+  Move(source^, dest^, SizeOf(THermesFormat));
+end;

+ 182 - 0
packages/hermes/src/hermes_list.inc

@@ -0,0 +1,182 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+type
+  TListFreeCallback = procedure(p: Pointer);
+  PHermesListElementStruct = ^THermesListElementStruct;
+  THermesListElementStruct = record
+    handle: THermesHandle;
+    data: Pointer;
+    next: PHermesListElementStruct;
+  end;
+  PHermesListElement = ^THermesListElement;
+  THermesListElement = THermesListElementStruct;
+  PHermesList = ^THermesList;
+  THermesList = record
+    first, last: PHermesListElement;
+  end;
+
+{function Hermes_ListNew: PHermesList;
+procedure Hermes_ListDestroy(list: PHermesList);
+function Hermes_ListElementNew(handle: THermesHandle): PHermesListElement;
+procedure Hermes_ListAdd(list: PHermesList; element: PHermesListElement);
+procedure Hermes_ListAddFront(list: PHermesList; element: PHermesListElement);
+function Hermes_ListDeleteElement(list: PHermesList; handle: THermesHandle): Boolean;
+function Hermes_ListLookup(list: PHermesList;
+                           handle: THermesHandle): PHermesListElement;}
+
+function Hermes_ListNew: PHermesList;
+begin
+  New(Result);
+  Result^.first := nil;
+  Result^.last := nil;
+end;
+
+procedure Hermes_ListDestroy(list: PHermesList; user_free: TListFreeCallback);
+var
+  tmp, run: PHermesListElement;
+begin
+  if list = nil then
+    exit;
+  run := list^.first;
+  while run <> nil do
+  begin
+    tmp := run;
+    run := run^.next;
+    if (tmp^.data <> nil) and (user_free <> nil) then
+      user_free(tmp^.data);
+    Dispose(tmp);
+  end;
+  Dispose(list);
+end;
+
+function Hermes_ListElementNew(handle: THermesHandle): PHermesListElement;
+begin
+  New(Result);
+  Result^.handle := handle;
+  Result^.next := nil;
+  Result^.data := nil;
+end;
+
+procedure Hermes_ListAdd(list: PHermesList; element: PHermesListElement);
+begin
+  if (list = nil) or (element = nil) then
+    exit;
+  if list^.first = nil then
+  begin
+    list^.first := element;
+    list^.last := element;
+    element^.next := nil;
+    exit;
+  end;
+  list^.last^.next := element;
+  list^.last := element;
+  element^.next := nil;
+end;
+
+procedure Hermes_ListAddFront(list: PHermesList; element: PHermesListElement);
+begin
+  if (list = nil) or (element = nil) then
+    exit;
+  if list^.first = nil then
+  begin
+    list^.first := element;
+    list^.last := element;
+    element^.next := nil;
+    exit;
+  end;
+  element^.next := list^.first;
+  list^.first := element;
+end;
+
+function Hermes_ListDeleteElement(list: PHermesList; handle: THermesHandle; user_free: TListFreeCallback): Boolean;
+var
+  run, previous: PHermesListElement;
+begin
+  if list = nil then
+  begin
+    Result := False;
+    exit;
+  end;
+  previous := nil;
+  run := list^.first;
+  while run <> nil do
+  begin
+    if run^.handle = handle then
+    begin
+      if run = list^.first then
+        list^.first := run^.next
+      else
+        previous^.next := run^.next;
+
+      if run = list^.last then
+      begin
+        list^.last := previous;
+        if list^.last <> nil then
+          list^.last^.next := nil;
+      end;
+
+      if (run^.data <> nil) and (user_free <> nil) then
+        user_free(run^.data);
+
+      Dispose(run);
+      Result := True;
+      exit;
+    end;
+    previous := run;
+    run := run^.next;
+  end;
+  Result := False;
+end;
+
+function Hermes_ListLookup(list: PHermesList;
+                           handle: THermesHandle): PHermesListElement;
+var
+  run: PHermesListElement;
+begin
+  if list = nil then
+  begin
+    Result := nil;
+    exit;
+  end;
+  run := list^.first;
+  while run <> nil do
+  begin
+    if run^.handle = handle then
+    begin
+      Result := run;
+      exit;
+    end;
+    run := run^.next;
+  end;
+  Result := nil;
+end;

+ 232 - 0
packages/hermes/src/hermes_palette.inc

@@ -0,0 +1,232 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+type
+  PHermesLookupTable = ^THermesLookupTable;
+  THermesLookupTable = record
+    data: ^Uint32;             { Actual lookup table }
+    valid: Boolean;           { Is this table up to date? }
+    format: THermesFormat;    { Format of lookup table }
+  end;
+  PHermesPalette = ^THermesPalette;
+  THermesPalette = record
+    data: ^Uint32;             { Palette data }
+    tables: PHermesList;      { Linked list of HermesLookupTables }
+  end;
+
+function Hermes_PaletteInstance: THermesPaletteHandle;
+var
+  newinstance: PHermesPalette;
+begin
+  { Create a new palette structure }
+  New(newinstance);
+  { Create palette data }
+  newinstance^.data := GetMem(256*SizeOf(Uint32));
+  { Create lookup table list }
+  newinstance^.tables := Hermes_ListNew;
+
+  Result := THermesPaletteHandle(newinstance);
+end;
+
+procedure HermesLookupTable_FreeCallback(q: Pointer);
+begin
+  FreeMem(PHermesLookupTable(q)^.data);
+  Dispose(PHermesLookupTable(q));
+end;
+
+procedure Hermes_PaletteReturn(handle: THermesPaletteHandle);
+begin
+  if handle <> nil then
+  begin
+    { Free palette data and lookup tables }
+    FreeMem(PHermesPalette(handle)^.data);
+    Hermes_ListDestroy(PHermesPalette(handle)^.tables, @HermesLookupTable_FreeCallback);
+    Dispose(PHermesPalette(handle));
+  end;
+end;
+
+procedure Hermes_PaletteSet(handle: THermesPaletteHandle; palette: Pointer);
+var
+  element: PHermesListElement;
+  pal: PHermesPalette;
+begin
+{  DebugMSG('Hermes_PaletteSet('+C2Str(handle)+','+C2Str(DWord(palette))+')');}
+  if handle = nil then
+    exit;
+
+  pal := PHermesPalette(handle);
+  element := pal^.tables^.first;
+
+  { Invalidate all lookup tables }
+  while element <> nil do
+  begin
+    (PHermesLookupTable(element^.data))^.valid := False;
+    element := element^.next;
+  end;
+
+{  FillChar(palette^, 256*4, $7f);}
+  Move(palette^, pal^.data^, 256*4);
+end;
+
+function Hermes_PaletteGet(handle: THermesPaletteHandle): Pointer;
+begin
+  if handle = nil then
+  begin
+    Result := nil;
+    exit;
+  end;
+
+  Result := PHermesPalette(handle)^.data;
+end;
+
+procedure Hermes_PaletteMakeLookup(lookup, palette: PUint32;
+                                   format: PHermesFormat);
+var
+  info: THermesGenericInfo;
+  I: Integer;
+  r, g, b: Uint32;
+begin
+{  DebugMSG('Yo! Hermes_PaletteMakeLookup');}
+  r := 0;
+  g := 0;
+  b := 0;
+  if format^.indexed then
+    exit;
+
+  Hermes_Calculate_Generic_Info(24,16,8,32,
+                                Hermes_Topbit(format^.r),
+                                Hermes_Topbit(format^.g),
+                                Hermes_Topbit(format^.b),
+                                Hermes_Topbit(format^.a),
+                                @info);
+
+  { Optimised loop if there are no left shifts }
+  if (info.r_left = 0) and (info.g_left = 0) and (info.b_left = 0) then
+    for I := 0 to 255 do
+    begin
+      r := (palette[i] shr info.r_right) and format^.r;
+      g := (palette[i] shr info.g_right) and format^.g;
+      b := (palette[i] shr info.b_right) and format^.b;
+      lookup[i] := r or g or b;
+    end
+  else
+    for I := 0 to 255 do
+    begin
+      r := ((palette[i] shr info.r_right) shl info.r_left) and format^.r;
+      g := ((palette[i] shr info.g_right) shl info.g_left) and format^.g;
+      b := ((palette[i] shr info.b_right) shl info.b_left) and format^.b;
+      lookup[i] := r or g or b;
+    end;
+end;
+
+function Hermes_PaletteGetTable(palette: THermesPaletteHandle; format: PHermesFormat): Pointer;
+var
+  element: PHermesListElement;
+  pal: PHermesPalette;
+  table: PHermesLookupTable;
+begin
+  if palette = nil then
+  begin
+    Result := nil;
+    exit;
+  end;
+
+  pal := PHermesPalette(palette);
+
+  { Go to the first table in the list }
+  element := pal^.tables^.first;
+
+  { Search for correct table using format }
+  while element <> nil do
+  begin
+    table := element^.data;
+
+    if Hermes_FormatEquals(@table^.format, format) then
+    begin
+      if table^.valid then
+      begin
+        Result := table^.data;
+        exit;
+      end;
+
+      { Have to recreate the lookup table }
+      Hermes_PaletteMakeLookup(table^.data, pal^.data, format);
+      table^.valid := True;
+
+      Result := table^.data;
+      exit;
+    end;
+
+    element := element^.next;
+  end;
+
+  { Format not found, have to create a new table (need no handle) }
+  New(table);
+  table^.data := GetMem(1024);
+
+  { Create lookup table }
+  Hermes_PaletteMakeLookup(table^.data, pal^.data, format);
+  Hermes_FormatCopy(format, @table^.format);
+
+  table^.valid := True;
+
+  { Create a new list element }
+  element := Hermes_ListElementNew(0);
+  element^.data := table;
+
+  { Add to the front of the list }
+  Hermes_ListAddFront(pal^.tables, element);
+
+  { Return lookup data }
+  Result := table^.data;
+end;
+
+procedure Hermes_PaletteInvalidateCache(handle: THermesPaletteHandle);
+var
+  element: PHermesListElement;
+  pal: PHermesPalette;
+begin
+  if handle = nil then
+    exit;
+
+  pal := PHermesPalette(handle);
+
+  element := pal^.tables^.first;
+
+  { Invalidate all lookup tables }
+
+  while element <> nil do
+  begin
+    (PHermesLookupTable(element^.data))^.valid := False;
+    element := element^.next;
+  end;
+end;

+ 119 - 0
packages/hermes/src/hermes_utility.inc

@@ -0,0 +1,119 @@
+{
+    Free Pascal port of the Hermes C library.
+    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
+    Original C version by 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
+}
+
+{procedure Hermes_Calculate_Generic_Info(s_r, s_g, s_b, s_a,
+                                        d_r, d_g, d_b, d_a: Uint32;
+                                        info: PHermesGenericInfo);
+function Hermes_Topbit(mask: Uint32): Integer;}
+
+procedure Hermes_Calculate_Generic_Info(s_r, s_g, s_b, s_a,
+                                        d_r, d_g, d_b, d_a: Integer;
+                                        info: PHermesGenericInfo);
+var
+  r_right, g_right, b_right, a_right: Integer;
+begin
+  {Calculate right shift amount for red. if it's <0, then set it to 0
+   and calculate left shift amount}
+  r_right := s_r - d_r;
+  if r_right < 0 then
+  begin
+    info^.r_left := -r_right;
+    info^.r_right := 0;
+  end
+  else
+  begin
+    info^.r_left := 0;
+    info^.r_right := r_right;
+  end;
+
+  {Same for green}
+  g_right := s_g - d_g;
+  if g_right < 0 then
+  begin
+    info^.g_left := -g_right;
+    info^.g_right := 0;
+  end
+  else
+  begin
+    info^.g_left := 0;
+    info^.g_right := g_right;
+  end;
+
+  {Same for blue}
+  b_right := s_b - d_b;
+  if b_right < 0 then
+  begin
+    info^.b_left := -b_right;
+    info^.b_right := 0;
+  end
+  else
+  begin
+    info^.b_left := 0;
+    info^.b_right := b_right;
+  end;
+
+  {Alpha}
+  a_right := s_a - d_a;
+  if a_right < 0 then
+  begin
+    info^.a_left := -a_right;
+    info^.a_right := 0;
+  end
+  else
+  begin
+    info^.a_left := 0;
+    info^.a_right := a_right;
+  end;
+end;
+
+function Hermes_Topbit(mask: Uint32): Integer;
+var
+  i: Integer;
+begin
+  if mask = 0 then
+  begin
+    Result := 0;
+    exit;
+  end;
+  i := 0;
+  while (mask and 1) = 0 do
+  begin
+    mask := mask shr 1;
+    Inc(i);
+  end;
+  while (mask and 1) = 1 do
+  begin
+    mask := mask shr 1;
+    Inc(i);
+  end;
+  Result := i;
+end;

+ 81 - 43
packages/hermes/src/i386/headi386.inc

@@ -1,44 +1,82 @@
+{
+    This file is part of the PTCPas framebuffer library
+    Copyright (C) 2001-2010 Nikolay Nikolov ([email protected])
 
-{$L hm_i386}
-
-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';
+    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
+}
+
+{$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';

+ 41 - 11
packages/hermes/src/i386/headmmx.inc

@@ -1,20 +1,50 @@
+{
+    This file is part of the PTCPas framebuffer library
+    Copyright (C) 2001-2010 Nikolay Nikolov ([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
+}
 
 {$L mmx_clr}
 {$L mmx_main}
 {$L mmxp2_32}
 {$L mmxp_32}
 
-Procedure ConvertMMX(hci : PHermesConverterInterface); CDecl; External name ExternalAsmPrefix+'ConvertMMX';
+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 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 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';
+procedure ConvertMMXp32_16RGB555(CONVERT_PARAMETERS); cdecl; external name ExternalAsmPrefix+'ConvertMMXp32_16RGB555';

+ 23 - 25
packages/hermes/src/i386/mmx_clr.as

@@ -2,7 +2,7 @@
 # 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
 #
@@ -25,13 +25,13 @@
 ##  16: int add
 
 
-_ClearMMX_32: 
+_ClearMMX_32:
         pushl %ebp
         movl %esp,%ebp
 
         movl 8(%ebp),%ebp
 
-        movl 4(%ebp),%eax       # pixel value   
+        movl 4(%ebp),%eax       # pixel value
         movd 4(%ebp),%mm0
 
         movl 12(%ebp),%edx      # height
@@ -41,7 +41,7 @@ _ClearMMX_32:
         movl (%ebp),%edi        # destination
 
         por %mm1,%mm0
-_ClearMMX_32.L_y: 
+_ClearMMX_32.L_y:
         movl 8(%ebp),%ecx
 
         movl %ecx,%ebx
@@ -49,7 +49,7 @@ _ClearMMX_32.L_y:
         shrl %ecx
         jz _ClearMMX_32.L_last
 
-_ClearMMX_32.L_x: 
+_ClearMMX_32.L_x:
         movq %mm0,(%edi)
         addl $8,%edi
 
@@ -57,14 +57,14 @@ _ClearMMX_32.L_x:
         jnz _ClearMMX_32.L_x
 
 
-_ClearMMX_32.L_last: 
+_ClearMMX_32.L_last:
         testl $1,%ebx
         jz _ClearMMX_32.L_endline
 
         movl %eax,(%edi)
         addl $4,%edi
 
-_ClearMMX_32.L_endline: 
+_ClearMMX_32.L_endline:
 
         addl 16(%ebp),%edi
 
@@ -78,18 +78,18 @@ _ClearMMX_32.L_endline:
 
 
 
-_ClearMMX_24: 
+_ClearMMX_24:
         ret
 
 
 
-_ClearMMX_16: 
+_ClearMMX_16:
         pushl %ebp
         movl %esp,%ebp
 
         movl 8(%ebp),%ebp
 
-        movl 4(%ebp),%eax       # pixel value   
+        movl 4(%ebp),%eax       # pixel value
         movl 4(%ebp),%ebx
 
         movl 12(%ebp),%edx      # height
@@ -106,7 +106,7 @@ _ClearMMX_16:
         psllq $32,%mm0
 
         por %mm1,%mm0
-_ClearMMX_16.L_y: 
+_ClearMMX_16.L_y:
         movl 8(%ebp),%ecx
 
         testl $3,%edi           # Check if destination is aligned mod 4
@@ -118,20 +118,20 @@ _ClearMMX_16.L_y:
         decl %ecx
         jz _ClearMMX_16.L_endline
 
-_ClearMMX_16.L_aligned: 
+_ClearMMX_16.L_aligned:
         movl %ecx,%ebx
         shrl $2,%ecx
 
         jz _ClearMMX_16.L_last
 
-_ClearMMX_16.L_x: 
+_ClearMMX_16.L_x:
         movq %mm0,(%edi)
         addl $8,%edi
 
         decl %ecx
         jnz _ClearMMX_16.L_x
 
-_ClearMMX_16.L_last: 
+_ClearMMX_16.L_last:
         andl $3,%ebx
         jz _ClearMMX_16.L_endline
 
@@ -150,7 +150,7 @@ _ClearMMX_16.L_last:
         decl %ebx
         jnz _ClearMMX_16.L_endline
 
-_ClearMMX_16.L_endline: 
+_ClearMMX_16.L_endline:
         addl 16(%ebp),%edi
 
         decl %edx
@@ -165,13 +165,13 @@ _ClearMMX_16.L_endline:
 
 ## Clear8_x86 isnt optimised fully yet as it seems to be a tiny bit slower
 ## than the C routine
-_ClearMMX_8: 
+_ClearMMX_8:
         pushl %ebp
         movl %esp,%ebp
 
         movl 8(%ebp),%ebp
 
-        movl 4(%ebp),%eax       # pixel value           
+        movl 4(%ebp),%eax       # pixel value
         movl 4(%ebp),%ebx
 
         movl 12(%ebp),%edx      # height
@@ -195,7 +195,7 @@ _ClearMMX_8:
 
         por %mm1,%mm0
 
-_ClearMMX_8.L_y: 
+_ClearMMX_8.L_y:
         movl 8(%ebp),%ecx
 
         testl $3,%edi           # Align mod 4
@@ -226,20 +226,20 @@ _ClearMMX_8.L_y:
         decl %ebx
         jz _ClearMMX_8.L_aligned
 
-_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: 
+_ClearMMX_8.L_x:
         movq %mm0,(%edi)
         addl $8,%edi
 
         decl %ecx
         jnz _ClearMMX_8.L_x
 
-_ClearMMX_8.L_last: 
+_ClearMMX_8.L_last:
         movl %ebx,%ecx          # Clean up trailing pixels
 
         andl $7,%ecx            # Could be up to 7 left
@@ -253,11 +253,11 @@ _ClearMMX_8.L_last:
 
         subl $4,%ecx
 
-_ClearMMX_8.L_lessthanfour: 
+_ClearMMX_8.L_lessthanfour:
         rep
  stosb              # Clean up the very rest
 
-_ClearMMX_8.L_endline: 
+_ClearMMX_8.L_endline:
         addl 16(%ebp),%edi
 
         decl %edx
@@ -267,5 +267,3 @@ _ClearMMX_8.L_endline:
 
         popl %ebp
         ret
-
-

+ 9 - 12
packages/hermes/src/i386/mmx_main.as

@@ -2,12 +2,12 @@
 # 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          
+# licensing conditions
 #
 # Most routines are (c) Glenn Fiedler ([email protected]), used with permission
-# 
+#
 
 #BITS 32
 
@@ -17,7 +17,7 @@
 
 .text
 
-## _ConvertMMX:  
+## _ConvertMMX:
 ## [ESP+8] ConverterInfo*
 ## --------------------------------------------------------------------------
 ## ConverterInfo (ebp+..)
@@ -29,10 +29,10 @@
 ##  20: int d_width
 ##  24: int d_height
 ##  28: int d_add
-##  32: void (*converter_function)() 
+##  32: void (*converter_function)()
 ##  36: int32 *lookup
 
-_ConvertMMX: 
+_ConvertMMX:
         pushl %ebp
         movl %esp,%ebp
 
@@ -46,12 +46,12 @@ _ConvertMMX:
         movl (%ebp),%esi
         movl 16(%ebp),%edi
 
-y_loop: 
+y_loop:
         movl 4(%ebp),%ecx
 
         jmp *32(%ebp)
 
-_mmxreturn: 
+_mmxreturn:
         addl 12(%ebp),%esi
         addl 28(%ebp),%edi
 
@@ -61,10 +61,7 @@ _mmxreturn:
 
         popl %ebp
 
-endconvert: 
+endconvert:
         emms
 
         ret
-
-
-

+ 27 - 30
packages/hermes/src/i386/mmxp2_32.as

@@ -3,12 +3,12 @@
 # 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          
+# 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).
@@ -50,7 +50,7 @@ mmx32_bgr555_mul: .long 0x00082000,0x00082000
 
 .text
 
-_ConvertMMXpII32_24RGB888: 
+_ConvertMMXpII32_24RGB888:
 
         # set up mm6 as the mask, mm7 as zero
         movq mmx32_rgb888_mask,%mm6
@@ -61,7 +61,7 @@ _ConvertMMXpII32_24RGB888:
         jnz _ConvertMMXpII32_24RGB888.L1
         jmp _ConvertMMXpII32_24RGB888.L2
 
-_ConvertMMXpII32_24RGB888.L1: 
+_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
@@ -92,11 +92,11 @@ _ConvertMMXpII32_24RGB888.L1:
         subl $4,%ecx
         jnz _ConvertMMXpII32_24RGB888.L1
 
-_ConvertMMXpII32_24RGB888.L2: 
+_ConvertMMXpII32_24RGB888.L2:
         movl %edx,%ecx
         andl $3,%ecx
         jz _ConvertMMXpII32_24RGB888.L4
-_ConvertMMXpII32_24RGB888.L3: 
+_ConvertMMXpII32_24RGB888.L3:
         movb (%esi),%al
         movb 1(%esi),%bl
         movb 2(%esi),%dl
@@ -107,12 +107,12 @@ _ConvertMMXpII32_24RGB888.L3:
         addl $3,%edi
         decl %ecx
         jnz _ConvertMMXpII32_24RGB888.L3
-_ConvertMMXpII32_24RGB888.L4: 
+_ConvertMMXpII32_24RGB888.L4:
         jmp _mmxreturn
 
 
 
-_ConvertMMXpII32_16RGB565: 
+_ConvertMMXpII32_16RGB565:
 
         # set up masks
         movq mmx32_rgb565_b,%mm5
@@ -124,7 +124,7 @@ _ConvertMMXpII32_16RGB565:
         jnz _ConvertMMXpII32_16RGB565.L1
         jmp _ConvertMMXpII32_16RGB565.L2 # not necessary at the moment, but doesnt hurt (much)
 
-_ConvertMMXpII32_16RGB565.L1: 
+_ConvertMMXpII32_16RGB565.L1:
         movq (%esi),%mm0        # argb
         movq %mm0,%mm1          # argb
         pand %mm6,%mm0          # 00g0
@@ -155,11 +155,11 @@ _ConvertMMXpII32_16RGB565.L1:
         decl %ecx
         jnz _ConvertMMXpII32_16RGB565.L1
 
-_ConvertMMXpII32_16RGB565.L2: 
+_ConvertMMXpII32_16RGB565.L2:
         movl %edx,%ecx
         andl $3,%ecx
         jz _ConvertMMXpII32_16RGB565.L4
-_ConvertMMXpII32_16RGB565.L3: 
+_ConvertMMXpII32_16RGB565.L3:
         movb (%esi),%al
         movb 1(%esi),%bh
         movb 2(%esi),%ah
@@ -175,11 +175,11 @@ _ConvertMMXpII32_16RGB565.L3:
         decl %ecx
         jnz _ConvertMMXpII32_16RGB565.L3
 
-_ConvertMMXpII32_16RGB565.L4: 
+_ConvertMMXpII32_16RGB565.L4:
         jmp _mmxreturn
 
 
-_ConvertMMXpII32_16BGR565: 
+_ConvertMMXpII32_16BGR565:
 
         movq mmx32_rgb565_r,%mm5
         movq mmx32_rgb565_g,%mm6
@@ -190,7 +190,7 @@ _ConvertMMXpII32_16BGR565:
         jnz _ConvertMMXpII32_16BGR565.L1
         jmp _ConvertMMXpII32_16BGR565.L2
 
-_ConvertMMXpII32_16BGR565.L1: 
+_ConvertMMXpII32_16BGR565.L1:
         movq (%esi),%mm0                # a r g b
         movq %mm0,%mm1                  # a r g b
         pand %mm6,%mm0                  # 0 0 g 0
@@ -225,10 +225,10 @@ _ConvertMMXpII32_16BGR565.L1:
         decl %ecx
         jnz _ConvertMMXpII32_16BGR565.L1
 
-_ConvertMMXpII32_16BGR565.L2: 
+_ConvertMMXpII32_16BGR565.L2:
         andl $3,%edx
         jz _ConvertMMXpII32_16BGR565.L4
-_ConvertMMXpII32_16BGR565.L3: 
+_ConvertMMXpII32_16BGR565.L3:
         movb 2(%esi),%al
         movb 1(%esi),%bh
         movb (%esi),%ah
@@ -244,10 +244,10 @@ _ConvertMMXpII32_16BGR565.L3:
         decl %edx
         jnz _ConvertMMXpII32_16BGR565.L3
 
-_ConvertMMXpII32_16BGR565.L4: 
+_ConvertMMXpII32_16BGR565.L4:
         jmp _mmxreturn
 
-_ConvertMMXpII32_16BGR555: 
+_ConvertMMXpII32_16BGR555:
 
         # the 16BGR555 converter is identical to the RGB555 one,
         # except it uses a different multiplier for the pmaddwd
@@ -261,19 +261,19 @@ _ConvertMMXpII32_16BGR555:
 # 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: 
+_ConvertMMXpII32_16RGB555:
 
         movq mmx32_rgb555_mul,%mm7
-_convert_bgr555_cheat: 
+_convert_bgr555_cheat:
         movq mmx32_rgb555_g,%mm6
 
-        movl %ecx,%edx                     # Save ecx 
+        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: 
+_convert_bgr555_cheat.L_OK:
 
         movq 8(%esi),%mm2
 
@@ -289,7 +289,7 @@ _convert_bgr555_cheat.L_OK:
         pmaddwd %mm7,%mm1
         pand %mm6,%mm2
 
-_convert_bgr555_cheat.L1: 
+_convert_bgr555_cheat.L1:
         movq 24(%esi),%mm4
         pand %mm6,%mm0
 
@@ -346,13 +346,13 @@ _convert_bgr555_cheat.L1:
         jmp _convert_bgr555_cheat.L1
 
 
-_convert_bgr555_cheat.L2: 
+_convert_bgr555_cheat.L2:
         movl %edx,%ecx
 
         andl $7,%ecx
         jz _convert_bgr555_cheat.L4
 
-_convert_bgr555_cheat.L3: 
+_convert_bgr555_cheat.L3:
         movl (%esi),%ebx
         addl $4,%esi
 
@@ -379,8 +379,5 @@ _convert_bgr555_cheat.L3:
         decl %ecx
         jnz _convert_bgr555_cheat.L3
 
-_convert_bgr555_cheat.L4: 
+_convert_bgr555_cheat.L4:
         jmp _mmxreturn
-
-
-

+ 14 - 14
packages/hermes/src/i386/mmxp_32.as

@@ -2,16 +2,16 @@
 # 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          
+# 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
 
@@ -24,7 +24,7 @@
 
 .align 8
 
-mmx32_rgb555_rb: .long 0x00f800f8,0x00f800f8 # Constants for conversion routines 
+mmx32_rgb555_rb: .long 0x00f800f8,0x00f800f8 # Constants for conversion routines
 mmx32_rgb555_add: .long 0x20000008,0x20000008
 mmx32_rgb555_g: .long 0x0000f800,0x0000f800
 
@@ -34,26 +34,26 @@ mmx32_rgb555_g: .long 0x0000f800,0x0000f800
 
 
 
-## Gone for now, it didnt draw correctly AND was slower than the x86 routine 
-_ConvertMMXp32_16RGB565: 
+## Gone for now, it didnt draw correctly AND was slower than the x86 routine
+_ConvertMMXp32_16RGB565:
 
         jmp _mmxreturn
 
 
 
 
-_ConvertMMXp32_16RGB555: 
+_ConvertMMXp32_16RGB555:
 
         movq mmx32_rgb555_add,%mm7
         movq mmx32_rgb555_g,%mm6
 
-        movl %ecx,%edx                     # Save ecx 
+        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: 
+_ConvertMMXp32_16RGB555.L_OK:
 
         movq 8(%esi),%mm2
 
@@ -69,7 +69,7 @@ _ConvertMMXp32_16RGB555.L_OK:
         pmaddwd %mm7,%mm1
         pand %mm6,%mm2
 
-_ConvertMMXp32_16RGB555.L1: 
+_ConvertMMXp32_16RGB555.L1:
         movq 24(%esi),%mm4
         pand %mm6,%mm0
 
@@ -126,13 +126,13 @@ _ConvertMMXp32_16RGB555.L1:
         jmp _ConvertMMXp32_16RGB555.L1
 
 
-_ConvertMMXp32_16RGB555.L2: 
+_ConvertMMXp32_16RGB555.L2:
         movl %edx,%ecx
 
         andl $7,%ecx
         jz _ConvertMMXp32_16RGB555.L4
 
-_ConvertMMXp32_16RGB555.L3: 
+_ConvertMMXp32_16RGB555.L3:
         movl (%esi),%ebx
         addl $4,%esi
 
@@ -159,5 +159,5 @@ _ConvertMMXp32_16RGB555.L3:
         decl %ecx
         jnz _ConvertMMXp32_16RGB555.L3
 
-_ConvertMMXp32_16RGB555.L4: 
+_ConvertMMXp32_16RGB555.L4:
         jmp _mmxreturn

+ 2048 - 2048
packages/hermes/src/i386/x8616lut.as

@@ -2,2058 +2,2058 @@
 .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
+                .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
+                .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
+                .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
+                .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
 

+ 24 - 24
packages/hermes/src/i386/x86_clr.as

@@ -2,7 +2,7 @@
 # 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
 #
@@ -18,7 +18,7 @@
 
 .text
 
-##   
+##
 ## --------------------------------------------------------------------------
 ## HermesClearInterface (ebp+..)
 ##   0: char8 *dest
@@ -28,18 +28,18 @@
 ##  16: int add
 
 .align 8
-_ClearX86_32: 
+_ClearX86_32:
         pushl %ebp
         movl %esp,%ebp
 
         movl 8(%ebp),%ebp
 
         movl (%ebp),%edi        # destination
-        movl 4(%ebp),%eax       # pixel value   
+        movl 4(%ebp),%eax       # pixel value
 
         movl 12(%ebp),%edx      # height
 .align 4
-_ClearX86_32.L_y: 
+_ClearX86_32.L_y:
         movl 8(%ebp),%ecx
         rep
  stosl
@@ -54,20 +54,20 @@ _ClearX86_32.L_y:
 
 
 
-_ClearX86_24: 
+_ClearX86_24:
         ret
 
 
 
 .align 8
-_ClearX86_16: 
+_ClearX86_16:
         pushl %ebp
         movl %esp,%ebp
 
         movl 8(%ebp),%ebp
 
         movl (%ebp),%edi        # destination
-        movl 4(%ebp),%eax       # pixel value   
+        movl 4(%ebp),%eax       # pixel value
 
         movl 12(%ebp),%edx      # height
         movl %eax,%ebx
@@ -76,7 +76,7 @@ _ClearX86_16:
         andl $0x0ffff,%ebx
 
         orl %ebx,%eax
-_ClearX86_16.L_y: 
+_ClearX86_16.L_y:
         movl 8(%ebp),%ecx
 
         testl $3,%edi           # Check if destination is aligned mod 4
@@ -88,7 +88,7 @@ _ClearX86_16.L_y:
         decl %ecx
         jz _ClearX86_16.L_endline
 
-_ClearX86_16.L_aligned: 
+_ClearX86_16.L_aligned:
         shrl %ecx
 
 rep
@@ -99,7 +99,7 @@ rep
         movw %ax,(%edi)
         addl $2,%edi
 
-_ClearX86_16.L_endline: 
+_ClearX86_16.L_endline:
         addl 16(%ebp),%edi
 
         decl %edx
@@ -111,13 +111,13 @@ _ClearX86_16.L_endline:
 
 
 .align 8
-_ClearX86_8: 
+_ClearX86_8:
         pushl %ebp
         movl %esp,%ebp
 
         movl 8(%ebp),%ebp
 
-        movl 4(%ebp),%eax       # pixel value           
+        movl 4(%ebp),%eax       # pixel value
         movl 12(%ebp),%edx      # height
 
         movb %al,%ah
@@ -135,7 +135,7 @@ _ClearX86_8:
         jbe _ClearX86_8.L_short_y
 
 .align 4
-_ClearX86_8.L_y: 
+_ClearX86_8.L_y:
         testl $3,%edi
         jz _ClearX86_8.L_aligned
 
@@ -148,7 +148,7 @@ _ClearX86_8.L_y:
         rep
  stosb
 
-_ClearX86_8.L_aligned: 
+_ClearX86_8.L_aligned:
         movl %ebx,%ecx
 
         shrl $2,%ecx
@@ -172,7 +172,7 @@ _ClearX86_8.L_aligned:
 
 ## Short loop
 .align 4
-_ClearX86_8.L_short_y: 
+_ClearX86_8.L_short_y:
         movl %ebx,%ecx
 
         rep
@@ -185,19 +185,19 @@ _ClearX86_8.L_short_y:
         popl %ebp
         ret
 
-## ClearX86_8 version 2,  
-## Im not sure wheather this is faster or not... 
+## 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: 
+_ClearX86_8_2:
         pushl %ebp
         movl %esp,%ebp
 
         movl 8(%ebp),%ebp
 
-        movl 4(%ebp),%eax       # pixel value           
+        movl 4(%ebp),%eax       # pixel value
         movl 12(%ebp),%edx      # height
 
         movb %al,%ah
@@ -216,7 +216,7 @@ _ClearX86_8_2:
 
 
 .align 4
-_ClearX86_8_2.L_y: 
+_ClearX86_8_2.L_y:
         testl $3,%edi
         jz _ClearX86_8_2.L_aligned
 
@@ -240,7 +240,7 @@ _ClearX86_8_2.L_y:
         movb %al,(%edi)
         incl %edi
 
-_ClearX86_8_2.L_aligned: 
+_ClearX86_8_2.L_aligned:
         movl %ebx,%ecx
 
         shrl $2,%ecx
@@ -271,7 +271,7 @@ _ClearX86_8_2.L_aligned:
         movb %al,(%edi)
         incl %edi
 
-_ClearX86_8_2.L_endline: 
+_ClearX86_8_2.L_endline:
         addl 16(%ebp),%edi
 
         decl %edx
@@ -283,7 +283,7 @@ _ClearX86_8_2.L_endline:
 
 ## Short loop
 .align 4
-_ClearX86_8_2.L_short_y: 
+_ClearX86_8_2.L_short_y:
         movl %ebx,%ecx
 
         rep

+ 11 - 11
packages/hermes/src/i386/x86_main.as

@@ -2,9 +2,9 @@
 # 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          
+# licensing conditions
 #
 
 
@@ -36,7 +36,7 @@ cpu_flags: .long 0
 .equ s_pitch, 40
 .equ d_pitch, 44
 
-## _ConvertX86:  
+## _ConvertX86:
 ## [ESP+8] ConverterInfo*
 ## --------------------------------------------------------------------------
 ##
@@ -45,7 +45,7 @@ cpu_flags: .long 0
 ##      - s_add for the x increment
 ## because they're unused anyway and this is thread safe.. (it's a per
 ## converter handle structure)
-_ConvertX86Stretch: 
+_ConvertX86Stretch:
         pushl %ebp
         movl %esp,%ebp
 
@@ -73,7 +73,7 @@ _ConvertX86Stretch:
         jmp *conv_func(%ebp)
 
 .align 8
-_x86return_S: 
+_x86return_S:
 
         decl d_height(%ebp)
         jz endconvert_S
@@ -98,14 +98,14 @@ _x86return_S:
 
         jmp *conv_func(%ebp)
 
-endconvert_S: 
+endconvert_S:
 
         popl %ebp
         ret
 
 
 
-_ConvertX86: 
+_ConvertX86:
         pushl %ebp
         movl %esp,%ebp
 
@@ -118,7 +118,7 @@ _ConvertX86:
         jmp *32(%ebp)
 
 .align 8
-_x86return: 
+_x86return:
         decl s_height(%ebp)
         jz endconvert
 
@@ -129,7 +129,7 @@ _x86return:
         jmp *32(%ebp)
 
 
-endconvert: 
+endconvert:
         popl %ebp
         ret
 
@@ -137,7 +137,7 @@ endconvert:
 
 ## Hermes_X86_CPU returns the CPUID flags in eax
 
-_Hermes_X86_CPU: 
+_Hermes_X86_CPU:
         pushfl
         popl %eax
 
@@ -178,5 +178,5 @@ _Hermes_X86_CPU:
 
         movl cpu_flags,%eax
 
-_Hermes_X86_CPU.L1: 
+_Hermes_X86_CPU.L1:
         ret

+ 33 - 33
packages/hermes/src/i386/x86p_16.as

@@ -2,13 +2,13 @@
 # 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          
-# 
+# licensing conditions
+#
 # Routines adjusted for Hermes by Christian Nentwich ([email protected])
 # Used with permission.
-# 
+#
 
 
 #BITS 32
@@ -32,13 +32,13 @@
 .globl _ConvertX86p16_32RGBA888_LUT_X86
 .globl _ConvertX86p16_32BGRA888_LUT_X86
 
-.include "src/i386/x8616lut.as"
+.include "hermes/i386/x8616lut.as"
 
 .text
 
 
 
-_ConvertX86p16_32RGB888: 
+_ConvertX86p16_32RGB888:
 
     # check short
     cmpl $32,%ecx
@@ -57,7 +57,7 @@ _ConvertX86p16_32RGB888.L1: movb (%esi),%bl             # ebx = lower byte pixel
     addl $4,%edi
     decl %ecx
     jnz _ConvertX86p16_32RGB888.L1
-_ConvertX86p16_32RGB888.L2: 
+_ConvertX86p16_32RGB888.L2:
     jmp _x86return
 
 
@@ -75,7 +75,7 @@ _ConvertX86p16_32RGB888.L3:  # save ebp
     leal (%esi,%ebp,4),%esi
     leal (%edi,%ebp,8),%edi
 
-    # negative counter 
+    # negative counter
     negl %ebp
 
     # clear
@@ -129,7 +129,7 @@ _ConvertX86p16_32RGB888.L6: popl %ebp
 
 
 
-_ConvertX86p16_32BGR888: 
+_ConvertX86p16_32BGR888:
 
     # check short
     cmpl $32,%ecx
@@ -148,7 +148,7 @@ _ConvertX86p16_32BGR888.L1: movb (%esi),%bl             # ebx = lower byte pixel
     addl $4,%edi
     decl %ecx
     jnz _ConvertX86p16_32BGR888.L1
-_ConvertX86p16_32BGR888.L2: 
+_ConvertX86p16_32BGR888.L2:
     jmp _x86return
 
 _ConvertX86p16_32BGR888.L3:  # save ebp
@@ -165,7 +165,7 @@ _ConvertX86p16_32BGR888.L3:  # save ebp
     leal (%esi,%ebp,4),%esi
     leal (%edi,%ebp,8),%edi
 
-    # negative counter 
+    # negative counter
     negl %ebp
 
     # clear
@@ -219,7 +219,7 @@ _ConvertX86p16_32BGR888.L6: popl %ebp
 
 
 
-_ConvertX86p16_32RGBA888: 
+_ConvertX86p16_32RGBA888:
 
     # check short
     cmpl $32,%ecx
@@ -238,7 +238,7 @@ _ConvertX86p16_32RGBA888.L1: movb (%esi),%bl             # ebx = lower byte pixe
     addl $4,%edi
     decl %ecx
     jnz _ConvertX86p16_32RGBA888.L1
-_ConvertX86p16_32RGBA888.L2: 
+_ConvertX86p16_32RGBA888.L2:
     jmp _x86return
 
 _ConvertX86p16_32RGBA888.L3:  # save ebp
@@ -255,7 +255,7 @@ _ConvertX86p16_32RGBA888.L3:  # save ebp
     leal (%esi,%ebp,4),%esi
     leal (%edi,%ebp,8),%edi
 
-    # negative counter 
+    # negative counter
     negl %ebp
 
     # clear
@@ -309,7 +309,7 @@ _ConvertX86p16_32RGBA888.L6: popl %ebp
 
 
 
-_ConvertX86p16_32BGRA888: 
+_ConvertX86p16_32BGRA888:
 
     # check short
     cmpl $32,%ecx
@@ -327,7 +327,7 @@ _ConvertX86p16_32BGRA888.L1: movb (%esi),%bl             # ebx = lower byte pixe
     addl $4,%edi
     decl %ecx
     jnz _ConvertX86p16_32BGRA888.L1
-_ConvertX86p16_32BGRA888.L2: 
+_ConvertX86p16_32BGRA888.L2:
     jmp _x86return
 
 _ConvertX86p16_32BGRA888.L3:  # save ebp
@@ -344,7 +344,7 @@ _ConvertX86p16_32BGRA888.L3:  # save ebp
     leal (%esi,%ebp,4),%esi
     leal (%edi,%ebp,8),%edi
 
-    # negative counter 
+    # negative counter
     negl %ebp
 
     # clear
@@ -398,7 +398,7 @@ _ConvertX86p16_32BGRA888.L6: popl %ebp
 
 
 
-_ConvertX86p16_24RGB888: 
+_ConvertX86p16_24RGB888:
 
     # check short
     cmpl $32,%ecx
@@ -544,7 +544,7 @@ _ConvertX86p16_24RGB888.L9: popl %ebp
 
 
 
-_ConvertX86p16_24BGR888: 
+_ConvertX86p16_24BGR888:
 
     # check short
     cmpl $32,%ecx
@@ -566,7 +566,7 @@ _ConvertX86p16_24BGR888.L1: movb (%esi),%dl
     addl $3,%edi
     decl %ecx
     jnz _ConvertX86p16_24BGR888.L1
-_ConvertX86p16_24BGR888.L2: 
+_ConvertX86p16_24BGR888.L2:
     jmp _x86return
 
 
@@ -690,7 +690,7 @@ _ConvertX86p16_24BGR888.L9: popl %ebp
 
 
 
-_ConvertX86p16_16BGR565: 
+_ConvertX86p16_16BGR565:
 
     # check short
     cmpl $16,%ecx
@@ -714,7 +714,7 @@ _ConvertX86p16_16BGR565.L1:  # short loop
     addl $2,%edi
     decl %ecx
     jnz _ConvertX86p16_16BGR565.L1
-_ConvertX86p16_16BGR565.L2: 
+_ConvertX86p16_16BGR565.L2:
     jmp _x86return
 
 _ConvertX86p16_16BGR565.L3:  # head
@@ -747,7 +747,7 @@ _ConvertX86p16_16BGR565.L4:  # save count
     leal (%esi,%ecx,4),%esi
     leal (%edi,%ecx,4),%edi
 
-    # negative counter 
+    # negative counter
     negl %ecx
     jmp _ConvertX86p16_16BGR565.L6
 
@@ -792,7 +792,7 @@ _ConvertX86p16_16BGR565.L6: movl (%esi,%ecx,4),%eax
     addl $2,%esi
     addl $2,%edi
 
-_ConvertX86p16_16BGR565.L7: 
+_ConvertX86p16_16BGR565.L7:
     jmp _x86return
 
 
@@ -800,7 +800,7 @@ _ConvertX86p16_16BGR565.L7:
 
 
 
-_ConvertX86p16_16RGB555: 
+_ConvertX86p16_16RGB555:
 
     # check short
     cmpl $32,%ecx
@@ -821,7 +821,7 @@ _ConvertX86p16_16RGB555.L1:  # short loop
     addl $2,%edi
     decl %ecx
     jnz _ConvertX86p16_16RGB555.L1
-_ConvertX86p16_16RGB555.L2: 
+_ConvertX86p16_16RGB555.L2:
     jmp _x86return
 
 _ConvertX86p16_16RGB555.L3:  # head
@@ -854,7 +854,7 @@ _ConvertX86p16_16RGB555.L4:  # save ebp
     leal (%esi,%ecx,8),%esi
     leal (%edi,%ecx,8),%edi
 
-    # negative counter 
+    # negative counter
     xorl %ebp,%ebp
     subl %ecx,%ebp
 
@@ -908,7 +908,7 @@ _ConvertX86p16_16RGB555.L7: popl %ebp
 
 
 
-_ConvertX86p16_16BGR555: 
+_ConvertX86p16_16BGR555:
 
     # check short
     cmpl $16,%ecx
@@ -934,7 +934,7 @@ _ConvertX86p16_16BGR555.L1:  # short loop
     addl $2,%edi
     decl %ecx
     jnz _ConvertX86p16_16BGR555.L1
-_ConvertX86p16_16BGR555.L2: 
+_ConvertX86p16_16BGR555.L2:
     jmp _x86return
 
 _ConvertX86p16_16BGR555.L3:  # head
@@ -969,7 +969,7 @@ _ConvertX86p16_16BGR555.L4:  # save count
     leal (%esi,%ecx,4),%esi
     leal (%edi,%ecx,4),%edi
 
-    # negative counter 
+    # negative counter
     negl %ecx
     jmp _ConvertX86p16_16BGR555.L6
 
@@ -1018,7 +1018,7 @@ _ConvertX86p16_16BGR555.L6: movl (%esi,%ecx,4),%eax
     addl $2,%esi
     addl $2,%edi
 
-_ConvertX86p16_16BGR555.L7: 
+_ConvertX86p16_16BGR555.L7:
     jmp _x86return
 
 
@@ -1026,7 +1026,7 @@ _ConvertX86p16_16BGR555.L7:
 
 
 
-_ConvertX86p16_8RGB332: 
+_ConvertX86p16_8RGB332:
 
     # check short
     cmpl $16,%ecx
@@ -1051,7 +1051,7 @@ _ConvertX86p16_8RGB332.L1:  # short loop
     incl %edi
     decl %ecx
     jnz _ConvertX86p16_8RGB332.L1
-_ConvertX86p16_8RGB332.L2: 
+_ConvertX86p16_8RGB332.L2:
     jmp _x86return
 
 _ConvertX86p16_8RGB332.L3: movl %edi,%eax

+ 49 - 49
packages/hermes/src/i386/x86p_32.as

@@ -2,12 +2,12 @@
 # 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          
+# licensing conditions
 #
 # Most routines are (c) Glenn Fiedler ([email protected]), used with permission
-# 
+#
 
 
 
@@ -28,15 +28,15 @@
 
 
 ## _Convert_*
-## Paramters:   
-##   ESI = source 
+## Paramters:
+##   ESI = source
 ##   EDI = dest
 ##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
 ## Destroys:
 ##   EAX, EBX, EDX
 
 
-_ConvertX86p32_32BGR888: 
+_ConvertX86p32_32BGR888:
 
     # check short
     cmpl $32,%ecx
@@ -51,7 +51,7 @@ _ConvertX86p32_32BGR888.L1:  # short loop
     addl $4,%edi
     decl %ecx
     jnz _ConvertX86p32_32BGR888.L1
-_ConvertX86p32_32BGR888.L2: 
+_ConvertX86p32_32BGR888.L2:
     jmp _x86return
 
 _ConvertX86p32_32BGR888.L3:  # save ebp
@@ -117,7 +117,7 @@ _ConvertX86p32_32BGR888.L6: popl %ebp
 
 
 
-_ConvertX86p32_32RGBA888: 
+_ConvertX86p32_32RGBA888:
 
     # check short
     cmpl $32,%ecx
@@ -131,7 +131,7 @@ _ConvertX86p32_32RGBA888.L1:  # short loop
     addl $4,%edi
     decl %ecx
     jnz _ConvertX86p32_32RGBA888.L1
-_ConvertX86p32_32RGBA888.L2: 
+_ConvertX86p32_32RGBA888.L2:
     jmp _x86return
 
 _ConvertX86p32_32RGBA888.L3:  # save ebp
@@ -188,7 +188,7 @@ _ConvertX86p32_32RGBA888.L6: popl %ebp
 
 
 
-_ConvertX86p32_32BGRA888: 
+_ConvertX86p32_32BGRA888:
 
     # check short
     cmpl $32,%ecx
@@ -202,7 +202,7 @@ _ConvertX86p32_32BGRA888.L1:  # short loop
     addl $4,%edi
     decl %ecx
     jnz _ConvertX86p32_32BGRA888.L1
-_ConvertX86p32_32BGRA888.L2: 
+_ConvertX86p32_32BGRA888.L2:
     jmp _x86return
 
 _ConvertX86p32_32BGRA888.L3:  # save ebp
@@ -263,7 +263,7 @@ _ConvertX86p32_32BGRA888.L6: popl %ebp
 
 ## 32 bit RGB 888 to 24 BIT RGB 888
 
-_ConvertX86p32_24RGB888: 
+_ConvertX86p32_24RGB888:
 
         # check short
         cmpl $32,%ecx
@@ -280,7 +280,7 @@ _ConvertX86p32_24RGB888.L1:  # short loop
         addl $3,%edi
         decl %ecx
         jnz _ConvertX86p32_24RGB888.L1
-_ConvertX86p32_24RGB888.L2: 
+_ConvertX86p32_24RGB888.L2:
         jmp _x86return
 
 _ConvertX86p32_24RGB888.L3:  #        head
@@ -360,7 +360,7 @@ _ConvertX86p32_24RGB888.L7: popl %ebp
 
 ## 32 bit RGB 888 to 24 bit BGR 888
 
-_ConvertX86p32_24BGR888: 
+_ConvertX86p32_24BGR888:
 
         # check short
         cmpl $32,%ecx
@@ -378,7 +378,7 @@ _ConvertX86p32_24BGR888.L1:  # short loop
         addl $3,%edi
         decl %ecx
         jnz _ConvertX86p32_24BGR888.L1
-_ConvertX86p32_24BGR888.L2: 
+_ConvertX86p32_24BGR888.L2:
         jmp _x86return
 
 _ConvertX86p32_24BGR888.L3:  # head
@@ -404,7 +404,7 @@ _ConvertX86p32_24BGR888.L4:  # unroll 4 times
         # save count
         pushl %ecx
 
-_ConvertX86p32_24BGR888.L5: 
+_ConvertX86p32_24BGR888.L5:
         movl (%esi),%eax                # first dword            eax = [A][R][G][B]
         movl 4(%esi),%ebx               # second dword           ebx = [a][r][g][b]
 
@@ -412,7 +412,7 @@ _ConvertX86p32_24BGR888.L5:
 
         bswapl %ebx                     #                        ebx = [b][g][r][a]
 
-        movb 4+2(%esi),%al              #                        eax = [B][G][R][r] 
+        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)
@@ -452,16 +452,16 @@ _ConvertX86p32_24BGR888.L6:  # tail loop
         decl %ecx
         jnz _ConvertX86p32_24BGR888.L6
 
-_ConvertX86p32_24BGR888.L7: 
+_ConvertX86p32_24BGR888.L7:
         popl %ebp
         jmp _x86return
 
 
 
 
-## 32 bit RGB 888 to 16 BIT RGB 565 
+## 32 bit RGB 888 to 16 BIT RGB 565
 .align 8
-_ConvertX86p32_16RGB565: 
+_ConvertX86p32_16RGB565:
         # check short
         cmpl $16,%ecx
         ja _ConvertX86p32_16RGB565.L3
@@ -505,7 +505,7 @@ _ConvertX86p32_16RGB565.L3:  # head
         addl $2,%edi
         decl %ecx
 
-_ConvertX86p32_16RGB565.L4: 
+_ConvertX86p32_16RGB565.L4:
     # save count
         pushl %ecx
 
@@ -516,14 +516,14 @@ _ConvertX86p32_16RGB565.L4:
         leal (%esi,%ecx,8),%esi
         leal (%edi,%ecx,4),%edi
 
-    # negative counter 
+    # negative counter
         negl %ecx
         jmp _ConvertX86p32_16RGB565.L6
 
-_ConvertX86p32_16RGB565.L5: 
+_ConvertX86p32_16RGB565.L5:
         movl %eax,-4(%edi,%ecx,4)
 .align 8
-_ConvertX86p32_16RGB565.L6: 
+_ConvertX86p32_16RGB565.L6:
         movl (%esi,%ecx,8),%eax
 
         shrb $2,%ah
@@ -569,15 +569,15 @@ _ConvertX86p32_16RGB565.L6:
         addl $4,%esi
         addl $2,%edi
 
-_ConvertX86p32_16RGB565.L7: 
+_ConvertX86p32_16RGB565.L7:
         jmp _x86return
 
 
 
 
-## 32 bit RGB 888 to 16 BIT BGR 565 
+## 32 bit RGB 888 to 16 BIT BGR 565
 
-_ConvertX86p32_16BGR565: 
+_ConvertX86p32_16BGR565:
 
         # check short
         cmpl $16,%ecx
@@ -598,7 +598,7 @@ _ConvertX86p32_16BGR565.L1:  # short loop
         addl $2,%edi
         decl %ecx
         jnz _ConvertX86p32_16BGR565.L1
-_ConvertX86p32_16BGR565.L2: 
+_ConvertX86p32_16BGR565.L2:
         jmp _x86return
 
 _ConvertX86p32_16BGR565.L3:  # head
@@ -633,9 +633,9 @@ _ConvertX86p32_16BGR565.L4:  # save count
         negl %ecx
         jmp _ConvertX86p32_16BGR565.L6
 
-_ConvertX86p32_16BGR565.L5: 
+_ConvertX86p32_16BGR565.L5:
         movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p32_16BGR565.L6: 
+_ConvertX86p32_16BGR565.L6:
         movl 4(%esi,%ecx,8),%edx
 
         movb 4(%esi,%ecx,8),%bh
@@ -683,7 +683,7 @@ _ConvertX86p32_16BGR565.L6:
         addl $4,%esi
         addl $2,%edi
 
-_ConvertX86p32_16BGR565.L7: 
+_ConvertX86p32_16BGR565.L7:
         jmp _x86return
 
 
@@ -691,7 +691,7 @@ _ConvertX86p32_16BGR565.L7:
 
 ## 32 BIT RGB TO 16 BIT RGB 555
 
-_ConvertX86p32_16RGB555: 
+_ConvertX86p32_16RGB555:
 
         # check short
         cmpl $16,%ecx
@@ -712,7 +712,7 @@ _ConvertX86p32_16RGB555.L1:  # short loop
         addl $2,%edi
         decl %ecx
         jnz _ConvertX86p32_16RGB555.L1
-_ConvertX86p32_16RGB555.L2: 
+_ConvertX86p32_16RGB555.L2:
         jmp _x86return
 
 _ConvertX86p32_16RGB555.L3:  # head
@@ -743,13 +743,13 @@ _ConvertX86p32_16RGB555.L4:  # save count
         leal (%esi,%ecx,8),%esi
         leal (%edi,%ecx,4),%edi
 
-        # negative counter 
+        # negative counter
         negl %ecx
         jmp _ConvertX86p32_16RGB555.L6
 
-_ConvertX86p32_16RGB555.L5: 
+_ConvertX86p32_16RGB555.L5:
         movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p32_16RGB555.L6: 
+_ConvertX86p32_16RGB555.L6:
         movl (%esi,%ecx,8),%eax
 
         shrb $3,%ah
@@ -794,7 +794,7 @@ _ConvertX86p32_16RGB555.L6:
         addl $4,%esi
         addl $2,%edi
 
-_ConvertX86p32_16RGB555.L7: 
+_ConvertX86p32_16RGB555.L7:
         jmp _x86return
 
 
@@ -802,7 +802,7 @@ _ConvertX86p32_16RGB555.L7:
 
 ## 32 BIT RGB TO 16 BIT BGR 555
 
-_ConvertX86p32_16BGR555: 
+_ConvertX86p32_16BGR555:
 
         # check short
         cmpl $16,%ecx
@@ -824,7 +824,7 @@ _ConvertX86p32_16BGR555.L1:  # short loop
         addl $2,%edi
         decl %ecx
         jnz _ConvertX86p32_16BGR555.L1
-_ConvertX86p32_16BGR555.L2: 
+_ConvertX86p32_16BGR555.L2:
         jmp _x86return
 
 _ConvertX86p32_16BGR555.L3:  # head
@@ -855,13 +855,13 @@ _ConvertX86p32_16BGR555.L4:  # save count
         leal (%esi,%ecx,8),%esi
         leal (%edi,%ecx,4),%edi
 
-        # negative counter 
+        # negative counter
         negl %ecx
         jmp _ConvertX86p32_16BGR555.L6
 
-_ConvertX86p32_16BGR555.L5: 
+_ConvertX86p32_16BGR555.L5:
         movl %eax,-4(%edi,%ecx,4)
-_ConvertX86p32_16BGR555.L6: 
+_ConvertX86p32_16BGR555.L6:
         movl 4(%esi,%ecx,8),%edx
 
         movb 4(%esi,%ecx,8),%bh
@@ -909,7 +909,7 @@ _ConvertX86p32_16BGR555.L6:
         addl $4,%esi
         addl $2,%edi
 
-_ConvertX86p32_16BGR555.L7: 
+_ConvertX86p32_16BGR555.L7:
         jmp _x86return
 
 
@@ -919,10 +919,10 @@ _ConvertX86p32_16BGR555.L7:
 ## 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:
 
 
-_ConvertX86p32_8RGB332.L_ALIGNED: 
+_ConvertX86p32_8RGB332.L_ALIGNED:
         pushl %ecx
 
         shrl $2,%ecx            # We will draw 4 pixels at once
@@ -930,7 +930,7 @@ _ConvertX86p32_8RGB332.L_ALIGNED:
 
         jmp _ConvertX86p32_8RGB332.L2 # short jump out of range :(
 
-_ConvertX86p32_8RGB332.L1: 
+_ConvertX86p32_8RGB332.L1:
         movl (%esi),%eax        # first pair of pixels
         movl 4(%esi),%edx
 
@@ -1008,14 +1008,14 @@ _ConvertX86p32_8RGB332.L1:
         jz _ConvertX86p32_8RGB332.L2 # L1 out of range for short jump :(
 
         jmp _ConvertX86p32_8RGB332.L1
-_ConvertX86p32_8RGB332.L2: 
+_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: 
+_ConvertX86p32_8RGB332.L3:
         movl (%esi),%eax        # single pixel conversion for trailing pixels
 
         movl %eax,%ebx
@@ -1039,5 +1039,5 @@ _ConvertX86p32_8RGB332.L3:
         decl %ecx
         jnz _ConvertX86p32_8RGB332.L3
 
-_ConvertX86p32_8RGB332.L4: 
+_ConvertX86p32_8RGB332.L4:
         jmp _x86return

+ 13 - 13
packages/hermes/src/i386/x86p_cpy.as

@@ -15,13 +15,13 @@
 
 ## _Copy*
 ## Paramters:
-##   ESI = source 
+##   ESI = source
 ##   EDI = dest
 ##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
 ## Destroys:
 ##   EAX, EBX, EDX
 
-_CopyX86p_4byte: 
+_CopyX86p_4byte:
 
         rep
  movsl
@@ -29,14 +29,14 @@ _CopyX86p_4byte:
         jmp _x86return
 
 
-_CopyX86p_3byte: 
+_CopyX86p_3byte:
 
         leal (%ecx,%ecx,2),%ecx
         jmp _CopyX86p_1byte
 
 
 
-_CopyX86p_2byte: 
+_CopyX86p_2byte:
 
         testl $3,%edi                   # Check if video memory is aligned
         jz _CopyX86p_2byte.L_ALIGNED
@@ -50,7 +50,7 @@ _CopyX86p_2byte:
         decl %ecx
         jz _CopyX86p_2byte.L3
 
-_CopyX86p_2byte.L_ALIGNED: 
+_CopyX86p_2byte.L_ALIGNED:
 
         movl %ecx,%ebx                  # Save ecx for later
 
@@ -60,7 +60,7 @@ _CopyX86p_2byte.L_ALIGNED:
         rep
  movsl
 
-_CopyX86p_2byte.L2: 
+_CopyX86p_2byte.L2:
         andl $1,%ebx
         jz _CopyX86p_2byte.L3
 
@@ -70,14 +70,14 @@ _CopyX86p_2byte.L2:
         movw %ax,(%edi)
         addl $2,%edi
 
-_CopyX86p_2byte.L3: 
+_CopyX86p_2byte.L3:
         jmp _x86return
 
 
 
-_CopyX86p_1byte: 
+_CopyX86p_1byte:
 
-_CopyX86p_1byte.L_alignloop: 
+_CopyX86p_1byte.L_alignloop:
         testl $3,%edi
         jz _CopyX86p_1byte.L_aligned
 
@@ -91,7 +91,7 @@ _CopyX86p_1byte.L_alignloop:
         jz _CopyX86p_1byte.L4
         jmp _CopyX86p_1byte.L_alignloop
 
-_CopyX86p_1byte.L_aligned: 
+_CopyX86p_1byte.L_aligned:
         movl %ecx,%edx
 
         shrl $2,%ecx
@@ -100,13 +100,13 @@ _CopyX86p_1byte.L_aligned:
         rep
  movsl
 
-_CopyX86p_1byte.L2: 
+_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: 
+_CopyX86p_1byte.L3:
         movb (%esi),%al
         incl %esi
 
@@ -116,5 +116,5 @@ _CopyX86p_1byte.L3:
         decl %ecx
         jnz _CopyX86p_1byte.L3
 
-_CopyX86p_1byte.L4: 
+_CopyX86p_1byte.L4:
         jmp _x86return

+ 16 - 22
packages/hermes/src/i386/x86p_i8.as

@@ -2,10 +2,10 @@
 # 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          
-# 
+# licensing conditions
+#
 # Some routines are (c) Glenn Fiedler ([email protected]), used with permission
 #
 
@@ -22,18 +22,18 @@
 
 
 ## Convert_*
-## Paramters:   
-##   ESI = source 
+## Paramters:
+##   ESI = source
 ##   EDI = dest
 ##   ECX = amount (NOT 0!!! (the ConvertX86 routine checks for that though))
 ## Destroys:
 ##   EAX, EBX, EDX
 
-_ConvertX86pI8_32: 
+_ConvertX86pI8_32:
 
         xorl %ebx,%ebx
         movl 36(%ebp),%edx
-_ConvertX86pI8_32.L1: 
+_ConvertX86pI8_32.L1:
         movb (%esi),%bl
         incl %esi
 
@@ -49,7 +49,7 @@ _ConvertX86pI8_32.L1:
 
 
 
-_ConvertX86pI8_24: 
+_ConvertX86pI8_24:
         movl 36(%ebp),%ebx
 
         xorl %edx,%edx
@@ -70,7 +70,7 @@ _ConvertX86pI8_24.L1:  # short loop
         addl $3,%edi
         decl %ecx
         jnz _ConvertX86pI8_24.L1
-_ConvertX86pI8_24.L2: 
+_ConvertX86pI8_24.L2:
         jmp _x86return
 
 _ConvertX86pI8_24.L3:  # head
@@ -99,7 +99,7 @@ _ConvertX86pI8_24.L4:  # save ebp
         shrl $2,%ecx
 
 _ConvertX86pI8_24.L5: pushl %ecx        # save ecx
-        movb (%esi),%dl                 # index to "A"           
+        movb (%esi),%dl                 # index to "A"
 
         movl (%ebp,%edx,4),%eax         # eax = [xx][A2][A1][A0]
         shll $8,%eax                    # eax = [A2][A1][A0][xx]
@@ -142,7 +142,7 @@ _ConvertX86pI8_24.L5: pushl %ecx        # save ecx
         andl $0b11,%ecx
         jz _ConvertX86pI8_24.L7
 
-_ConvertX86pI8_24.L6: 
+_ConvertX86pI8_24.L6:
         movb (%esi),%dl
         movl (%ebx,%edx,4),%eax
         movb %al,(%edi) # blue
@@ -159,7 +159,7 @@ _ConvertX86pI8_24.L7: popl %ebp
 
 
 .align 8
-_ConvertX86pI8_16: 
+_ConvertX86pI8_16:
         xorl %ebx,%ebx
         movl 36(%ebp),%edx
 
@@ -177,7 +177,7 @@ _ConvertX86pI8_16:
         decl %ecx
         jz _ConvertX86pI8_16.out
 
-_ConvertX86pI8_16.Laligned: 
+_ConvertX86pI8_16.Laligned:
         pushl %ecx
 
         xorl %eax,%eax
@@ -186,7 +186,7 @@ _ConvertX86pI8_16.Laligned:
         shrl %ecx
         jz _ConvertX86pI8_16.last_pixel
 .align 8
-_ConvertX86pI8_16.Ly: 
+_ConvertX86pI8_16.Ly:
         movb 1(%esi),%bl
         movb (%esi),%al
 
@@ -206,7 +206,7 @@ _ConvertX86pI8_16.Ly:
         decl %ecx
         jnz _ConvertX86pI8_16.Ly
 
-_ConvertX86pI8_16.last_pixel: 
+_ConvertX86pI8_16.last_pixel:
         popl %ecx
 
         testb $1,%cl
@@ -220,11 +220,5 @@ _ConvertX86pI8_16.last_pixel:
         movw %ax,(%edi)
         addl $2,%edi
 
-_ConvertX86pI8_16.out: 
+_ConvertX86pI8_16.out:
         jmp _x86return
-
-
-
-
-
-

+ 6 - 8
packages/hermes/src/i386/x86p_s32.as

@@ -8,7 +8,7 @@
 .extern _x86return_S
 
 ## _Convert*_S
-## Paramters:   
+## Paramters:
 ##   ESI = source
 ##   EDI = dest
 ##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
@@ -17,7 +17,7 @@
 ##   EAX, EBX, ECX, EDX
 
 
-_ConvertX86p32_16RGB565_S: 
+_ConvertX86p32_16RGB565_S:
 
         pushl %ebp
         pushl %edx              # increment now at [esp+4]!
@@ -29,10 +29,10 @@ _ConvertX86p32_16RGB565_S:
         jnz _ConvertX86p32_16RGB565_S.L_ok
         jmp _ConvertX86p32_16RGB565_S.L_final
 
-_ConvertX86p32_16RGB565_S.L_ok: 
+_ConvertX86p32_16RGB565_S.L_ok:
 
 .align 8
-_ConvertX86p32_16RGB565_S.Lx: 
+_ConvertX86p32_16RGB565_S.Lx:
         movl %ebp,%eax
 
         shrl $14,%eax
@@ -82,7 +82,7 @@ _ConvertX86p32_16RGB565_S.Lx:
         decl %ecx
         jnz _ConvertX86p32_16RGB565_S.Lx
 
-_ConvertX86p32_16RGB565_S.L_final: 
+_ConvertX86p32_16RGB565_S.L_final:
         popl %ecx
         andl $1,%ecx
         jz _ConvertX86p32_16RGB565_S.L_out
@@ -107,10 +107,8 @@ _ConvertX86p32_16RGB565_S.L_final:
         movw %ax,(%edi)
         addl $2,%edi
 
-_ConvertX86p32_16RGB565_S.L_out: 
+_ConvertX86p32_16RGB565_S.L_out:
 
         popl %edx
         popl %ebp
         jmp _x86return_S
-
-

+ 5 - 7
packages/hermes/src/i386/x86pscpy.as

@@ -13,30 +13,28 @@
 
 ## _Copy*
 ## Paramters:
-##   ESI = source 
+##   ESI = source
 ##   EDI = dest
 ##   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
 ## Destroys:
 ##   EAX, EBX, EDX
 
-_CopyX86p_4byte_S: 
+_CopyX86p_4byte_S:
 
 
         jmp _x86return_S
 
 
-_CopyX86p_3byte_S: 
+_CopyX86p_3byte_S:
 
         jmp _x86return_S
 
 
 
-_CopyX86p_2byte_S: 
+_CopyX86p_2byte_S:
 
         jmp _x86return_S
 
-_CopyX86p_1byte_S: 
+_CopyX86p_1byte_S:
 
         jmp _x86return_S
-
-

+ 0 - 212
packages/hermes/src/list.inc

@@ -1,212 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-Type
-  TListFreeCallback = Procedure(p : Pointer);
-  PHermesListElementStruct = ^THermesListElementStruct;
-  THermesListElementStruct = Record
-    handle : THermesHandle;
-    data : Pointer;
-    next : PHermesListElementStruct;
-  End;
-  PHermesListElement = ^THermesListElement;
-  THermesListElement = THermesListElementStruct;
-  PHermesList = ^THermesList;
-  THermesList = Record
-    first, last : PHermesListElement;
-  End;
-
-{Function Hermes_ListNew : PHermesList;
-Procedure Hermes_ListDestroy(list : PHermesList);
-Function Hermes_ListElementNew(handle : THermesHandle) : PHermesListElement;
-Procedure Hermes_ListAdd(list : PHermesList; element : PHermesListElement);
-Procedure Hermes_ListAddFront(list : PHermesList; element : PHermesListElement);
-Function Hermes_ListDeleteElement(list : PHermesList; handle : THermesHandle) : Boolean;
-Function Hermes_ListLookup(list : PHermesList;
-                           handle : THermesHandle) : PHermesListElement;}
-
-Function Hermes_ListNew : PHermesList;
-
-Var
-  tmp : PHermesList;
-
-Begin
-{  New(tmp);}
-  tmp := malloc(SizeOf(THermesList));
-  If tmp = Nil Then
-  Begin
-    Hermes_ListNew := Nil;
-    Exit;
-  End;
-  tmp^.first := Nil;
-  tmp^.last := Nil;
-  Hermes_ListNew := tmp;
-End;
-
-Procedure Hermes_ListDestroy(list : PHermesList);
-
-Var
-  tmp, run : PHermesListElement;
-
-Begin
-  If list = Nil Then
-    Exit;
-  run := list^.first;
-  While run <> Nil Do
-  Begin
-    tmp := run;
-    run := run^.next;
-    If tmp^.data <> Nil Then
-    Begin
-      {to do: free(tmp->data)}
-      free(tmp^.data);
-    End;
-    free(tmp);
-  End;
-  free(list);
-  list := Nil;
-End;
-
-Function Hermes_ListElementNew(handle : THermesHandle) : PHermesListElement;
-
-Var
-  tmp : PHermesListElement;
-
-Begin
-  tmp := malloc(SizeOf(THermesListElement));
-  If tmp = Nil Then
-  Begin
-    Hermes_ListElementNew := Nil;
-    Exit;
-  End;
-  tmp^.handle := handle;
-  tmp^.next := Nil;
-  tmp^.data := Nil;
-  Hermes_ListElementNew := tmp;
-End;
-
-Procedure Hermes_ListAdd(list : PHermesList; element : PHermesListElement);
-
-Begin
-  If (list = Nil) Or (element = Nil) Then
-    Exit;
-  If list^.first = Nil Then
-  Begin
-    list^.first := element;
-    list^.last := element;
-    element^.next := Nil;
-    Exit;
-  End;
-  list^.last^.next := element;
-  list^.last := element;
-  element^.next := Nil;
-End;
-
-Procedure Hermes_ListAddFront(list : PHermesList; element : PHermesListElement);
-
-Begin
-  If (list = Nil) Or (element = Nil) Then
-    Exit;
-  If list^.first = Nil Then
-  Begin
-    list^.first := element;
-    list^.last := element;
-    element^.next := Nil;
-    Exit;
-  End;
-  element^.next := list^.first;
-  list^.first := element;
-End;
-
-Function Hermes_ListDeleteElement(list : PHermesList; handle : THermesHandle; user_free : TListFreeCallback) : Boolean;
-
-Var
-  run, previous : PHermesListElement;
-
-Begin
-  If list = Nil Then
-  Begin
-    Hermes_ListDeleteElement := False;
-    Exit;
-  End;
-  previous := Nil;
-  run := list^.first;
-  While run <> Nil Do
-  Begin
-    If run^.handle = handle Then
-    Begin
-      If run = list^.first Then
-        list^.first := run^.next
-      Else
-        previous^.next := run^.next;
-      If run = list^.last Then
-      Begin
-        list^.last := previous;
-        If list^.last <> Nil Then
-          list^.last^.next := Nil;
-      End;
-      If run^.data <> Nil Then
-      Begin
-        If user_free <> Nil Then
-        Begin
-          user_free(run^.data);
-        End;
-        free(run^.data);
-      End;
-      free(run);
-      Hermes_ListDeleteElement := True;
-      Exit;
-    End;
-    previous := run;
-    run := run^.next;
-  End;
-  Hermes_ListDeleteElement := False;
-End;
-
-Function Hermes_ListDeleteElement(list : PHermesList; handle : THermesHandle) : Boolean;
-
-Begin
-  Hermes_ListDeleteElement := Hermes_ListDeleteElement(list, handle, Nil);
-End;
-
-Function Hermes_ListLookup(list : PHermesList;
-                           handle : THermesHandle) : PHermesListElement;
-
-Var
-  run : PHermesListElement;
-
-Begin
-  If list = Nil Then
-  Begin
-    Hermes_ListLookup := Nil;
-    Exit;
-  End;
-  run := list^.first;
-  While run <> Nil Do
-  Begin
-    If run^.handle = handle Then
-    Begin
-      Hermes_ListLookup := run;
-      Exit;
-    End;
-    run := run^.next;
-  End;
-  Hermes_ListLookup := Nil;
-End;

+ 0 - 31
packages/hermes/src/malloc.inc

@@ -1,31 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-Function malloc(size : DWord) : Pointer;
-
-Begin
-  malloc := GetMem(size);
-End;
-
-Procedure free(ptr : Pointer);
-
-Begin
-  FreeMem(ptr);
-End;

+ 499 - 511
packages/hermes/src/p_16.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -28,357 +40,337 @@
 }
 
 { TO 32 BIT RGB }
-Procedure ConvertP_16rgb565_32rgb888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+procedure ConvertP_16rgb565_32rgb888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+begin
+  repeat
+    d_pixel := PUint16(source)^;
 
-Var
-  d_pixel : int32;
+    d_pixel := ((d_pixel and $f800) shl 8) or ((d_pixel and $7e0) shl 5) or
+               ((d_pixel and $1f) shl 3) or $030103;
 
-Begin
-  Repeat
-    d_pixel := Pshort16(source)^;
-
-    d_pixel := ((d_pixel And $f800) Shl 8) Or ((d_pixel And $7e0) Shl 5) Or
-               ((d_pixel And $1f) Shl 3) Or $030103;
-
-    Pint32(dest)^ := d_pixel;
+    PUint32(dest)^ := d_pixel;
 
     Inc(source, 2);
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 32 BIT BGR }
-Procedure ConvertP_16rgb565_32bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_pixel : int32;
-
-Begin
-  Repeat
-    d_pixel := Pshort16(source)^;
+procedure ConvertP_16rgb565_32bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+begin
+  repeat
+    d_pixel := PUint16(source)^;
 
-    d_pixel := ((d_pixel And $f800) Shr 8) Or ((d_pixel And $7e0) Shl 5) Or
-               ((d_pixel And $1f) Shl 19) Or $030103;
+    d_pixel := ((d_pixel and $f800) shr 8) or ((d_pixel and $7e0) shl 5) or
+               ((d_pixel and $1f) shl 19) or $030103;
 
-    Pint32(dest)^ := d_pixel;
+    PUint32(dest)^ := d_pixel;
 
     Inc(source, 2);
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 32 BIT RGBA }
-Procedure ConvertP_16rgb565_32rgba888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+procedure ConvertP_16rgb565_32rgba888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+begin
+  repeat
+    d_pixel := PUint16(source)^;
 
-Var
-  d_pixel : int32;
+    d_pixel := ((d_pixel and $f800) shl 8) or ((d_pixel and $7e0) shl 5) or
+               ((d_pixel and $1f) shl 3) or $030103;
 
-Begin
-  Repeat
-    d_pixel := Pshort16(source)^;
-
-    d_pixel := ((d_pixel And $f800) Shl 8) Or ((d_pixel And $7e0) Shl 5) Or
-               ((d_pixel And $1f) Shl 3) Or $030103;
-
-    Pint32(dest)^ := (d_pixel Shl 8) Or $ff;
+    PUint32(dest)^ := (d_pixel shl 8) or $ff;
 
     Inc(source, 2);
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 32 BIT BGRA }
-Procedure ConvertP_16rgb565_32bgra888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_pixel : int32;
-
-Begin
-  Repeat
-    d_pixel := Pshort16(source)^;
+procedure ConvertP_16rgb565_32bgra888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+begin
+  repeat
+    d_pixel := PUint16(source)^;
 
-    d_pixel := ((d_pixel And $f800) Shr 8) Or ((d_pixel And $7e0) Shl 5) Or
-               ((d_pixel And $1f) Shl 19) Or $030103;
+    d_pixel := ((d_pixel and $f800) shr 8) or ((d_pixel and $7e0) shl 5) or
+               ((d_pixel and $1f) shl 19) or $030103;
 
-    Pint32(dest)^ := (d_pixel Shl 8) Or $ff;
+    PUint32(dest)^ := (d_pixel shl 8) or $ff;
 
     Inc(source, 2);
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 24 BIT RGB }
-Procedure ConvertP_16rgb565_24rgb888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_pixel : int32;
-  d_ptr : Pchar8;
-
-Begin
-  d_ptr := @d_pixel;
-  Repeat
-    d_pixel := Pshort16(source)^;
-
-    d_pixel := ((d_pixel And $f800) Shl 8) Or ((d_pixel And $7e0) Shl 5) Or
-               ((d_pixel And $1f) Shl 3) Or $030103;
-
-    (dest + R_24)^ := (d_ptr + R_32)^;
-    (dest + G_24)^ := (d_ptr + G_32)^;
-    (dest + B_24)^ := (d_ptr + B_32)^;
+procedure ConvertP_16rgb565_24rgb888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+  d_ptr: PUint8;
+begin
+  d_ptr := PUint8(@d_pixel) + (R_32 - R_24);
+  repeat
+    d_pixel := PUint16(source)^;
+
+    d_pixel := ((d_pixel and $f800) shl 8) or ((d_pixel and $7e0) shl 5) or
+               ((d_pixel and $1f) shl 3) or $030103;
+
+    (dest + 0)^ := (d_ptr + 0)^;
+    (dest + 1)^ := (d_ptr + 1)^;
+    (dest + 2)^ := (d_ptr + 2)^;
 
     Inc(source, 2);
     Inc(dest, 3);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 24 BIT BGR }
-Procedure ConvertP_16rgb565_24bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_pixel : int32;
-  d_ptr : Pchar8;
-
-Begin
-  d_ptr := @d_pixel;
-  Repeat
-    d_pixel := Pshort16(source)^;
-
-    d_pixel := ((d_pixel And $f800) Shl 8) Or ((d_pixel And $7e0) Shl 5) Or
-               ((d_pixel And $1f) Shl 3) Or $030103;
+procedure ConvertP_16rgb565_24bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+  d_ptr: PUint8;
+begin
+  d_ptr := PUint8(@d_pixel) + (R_32 - R_24);
+  repeat
+    d_pixel := PUint16(source)^;
+
+    d_pixel := ((d_pixel and $f800) shl 8) or ((d_pixel and $7e0) shl 5) or
+               ((d_pixel and $1f) shl 3) or $030103;
 
     { Red and blue are swapped here }
-    (dest + R_24)^ := (d_ptr + B_32)^;
-    (dest + G_24)^ := (d_ptr + G_32)^;
-    (dest + B_24)^ := (d_ptr + R_32)^;
+    (dest + 0)^ := (d_ptr + 2)^;
+    (dest + 1)^ := (d_ptr + 1)^;
+    (dest + 2)^ := (d_ptr + 0)^;
 
     Inc(source, 2);
     Inc(dest, 3);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 16 BIT BGR 565 }
-Procedure ConvertP_16rgb565_16bgr565(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  s_pixel : int32;
-
-Begin
-  { If we are not aligned to a dword, try and convert a single pixel }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pshort16(source)^;
+procedure ConvertP_16rgb565_16bgr565(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  s_pixel: Uint32;
+begin
+  { if we are not aligned to a dword, try and convert a single pixel }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint16(source)^;
 
     { Swap around R and B, leave G unchanged }
-    s_pixel := (s_pixel Shr 11) Or (s_pixel And $7e0) Or
-               ((s_pixel Shl 11) And $f800);
+    s_pixel := (s_pixel shr 11) or (s_pixel and $7e0) or
+               ((s_pixel shl 11) and $f800);
 
-    Pshort16(dest)^ := s_pixel;
+    PUint16(dest)^ := s_pixel;
 
     Dec(count);
     Inc(dest, 2); Inc(source, 2);
-  End;
+  end;
 
   { Now copy blocks of dwords }
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
     { Leave G unchanged, shift R to the right and B to the left }
-    s_pixel := (s_pixel And $07e007e0) Or ((s_pixel And $f800f800) Shr 11) Or
-               ((s_pixel And $001f001f) Shl 11);
+    s_pixel := (s_pixel and $07e007e0) or ((s_pixel and $f800f800) shr 11) or
+               ((s_pixel and $001f001f) shl 11);
 
-    Pint32(dest)^ := s_pixel;
+    PUint32(dest)^ := s_pixel;
     Inc(source, 4); Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pshort16(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint16(source)^;
 
     { Swap around R and B, leave G unchanged }
-    s_pixel := (s_pixel Shr 11) Or (s_pixel And $7e0) Or
-               ((s_pixel Shl 11) And $f800);
+    s_pixel := (s_pixel shr 11) or (s_pixel and $7e0) or
+               ((s_pixel shl 11) and $f800);
 
-    Pshort16(dest)^ := s_pixel;
-  End;
-End;
+    PUint16(dest)^ := s_pixel;
+  end;
+end;
 
 { TO 16 BIT RGB 555 }
-Procedure ConvertP_16rgb565_16rgb555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  s_pixel : int32;
-
-Begin
-  { If we are not aligned to a dword, try and convert a single pixel }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pshort16(source)^;
+procedure ConvertP_16rgb565_16rgb555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  s_pixel: Uint32;
+begin
+  { if we are not aligned to a dword, try and convert a single pixel }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint16(source)^;
 
     { Leave blue untouched, mask red and shift by one, mask green and shift
       by one }
-    s_pixel := (s_pixel And $1f) Or ((s_pixel And $f800) Shr 1) Or
-               ((s_pixel And $7c0) Shr 1);
+    s_pixel := (s_pixel and $1f) or ((s_pixel and $f800) shr 1) or
+               ((s_pixel and $7c0) shr 1);
 
-    Pshort16(dest)^ := s_pixel;
+    PUint16(dest)^ := s_pixel;
 
     Dec(count);
     Inc(dest, 2); Inc(source, 2);
-  End;
+  end;
 
   { Now copy blocks of dwords }
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
     { Leave blue untouched, mask red and shift by one, mask green and shift
       by one }
-    s_pixel := (s_pixel And $001f001f) Or ((s_pixel And $f800f800) Shr 1) Or
-               ((s_pixel And $07c007c0) Shr 1);
+    s_pixel := (s_pixel and $001f001f) or ((s_pixel and $f800f800) shr 1) or
+               ((s_pixel and $07c007c0) shr 1);
 
-    Pint32(dest)^ := s_pixel;
+    PUint32(dest)^ := s_pixel;
     Inc(source, 4); Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pshort16(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint16(source)^;
 
     { Leave blue untouched, mask red and shift by one, mask green and shift
       by one }
-    s_pixel := (s_pixel And $1f) Or ((s_pixel And $f800) Shr 1) Or
-               ((s_pixel And $7c0) Shr 1);
+    s_pixel := (s_pixel and $1f) or ((s_pixel and $f800) shr 1) or
+               ((s_pixel and $7c0) shr 1);
 
-    Pshort16(dest)^ := s_pixel;
-  End;
-End;
+    PUint16(dest)^ := s_pixel;
+  end;
+end;
 
 { TO 16 BIT BGR 555 }
-Procedure ConvertP_16rgb565_16bgr555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  s_pixel : int32;
-
-Begin
-  { If we are not aligned to a dword, try and convert a single pixel }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pshort16(source)^;
+procedure ConvertP_16rgb565_16bgr555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  s_pixel: Uint32;
+begin
+  { if we are not aligned to a dword, try and convert a single pixel }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint16(source)^;
 
     { Shift red right by 11, mask green and shift right one, shift blue
       left ten }
-    s_pixel := ((s_pixel And $f800) Shr 11) Or ((s_pixel And $7c0) Shr 1) Or
-               ((s_pixel And $1f) Shl 10);
+    s_pixel := ((s_pixel and $f800) shr 11) or ((s_pixel and $7c0) shr 1) or
+               ((s_pixel and $1f) shl 10);
 
-    Pshort16(dest)^ := s_pixel;
+    PUint16(dest)^ := s_pixel;
 
     Dec(count);
     Inc(dest, 2); Inc(source, 2);
-  End;
+  end;
 
   { Now copy blocks of dwords }
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
     { Shift red right by 11, mask green and shift right one, shift blue
       left ten }
-    s_pixel := ((s_pixel And $f800f800) Shr 11) Or
-               ((s_pixel And $07c007c0) Shr 1) Or
-               ((s_pixel And $001f001f) Shl 10);
+    s_pixel := ((s_pixel and $f800f800) shr 11) or
+               ((s_pixel and $07c007c0) shr 1) or
+               ((s_pixel and $001f001f) shl 10);
 
-    Pint32(dest)^ := s_pixel;
+    PUint32(dest)^ := s_pixel;
     Inc(source, 4); Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pshort16(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint16(source)^;
 
     { Shift red right by 11, mask green and shift right one, shift blue
       left ten }
-    s_pixel := ((s_pixel And $f800) Shr 11) Or ((s_pixel And $7c0) Shr 1) Or
-               ((s_pixel And $1f) Shl 10);
+    s_pixel := ((s_pixel and $f800) shr 11) or ((s_pixel and $7c0) shr 1) or
+               ((s_pixel and $1f) shl 10);
 
-    Pshort16(dest)^ := s_pixel;
-  End;
-End;
+    PUint16(dest)^ := s_pixel;
+  end;
+end;
 
 { TO 8 BIT RGB 332 }
-Procedure ConvertP_16rgb565_8rgb332(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_block, d_block : int32;
-  i : DWord;
-
-Begin
+procedure ConvertP_16rgb565_8rgb332(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_block, d_block: Uint32;
+  i: DWord;
+begin
   { Align to dword first }
-  While (PtrUInt(dest) And $3) <> 0 Do
-  Begin
-    s_block := Pshort16(source)^;
+  while (PtrUInt(dest) and $3) <> 0 do
+  begin
+    s_block := PUint16(source)^;
 
-    s_block := ((s_block And $e000) Shr 8) Or ((s_block And $0700) Shr 6) Or
-               ((s_block And $18) Shr 3);
+    s_block := ((s_block and $e000) shr 8) or ((s_block and $0700) shr 6) or
+               ((s_block and $18) shr 3);
 
     dest^ := s_block;
 
     Dec(count);
-    If count = 0 Then
-      Exit;
+    if count = 0 then
+      exit;
 
     Inc(source, 2);
     Inc(dest);
-  End;
+  end;
 
   { Write blocks of four pixels }
-  For i := 1 To count Shr 2 Do
-  Begin
+  for i := 1 to count shr 2 do
+  begin
     { Read and process first two pixels }
-    s_block := Pint32(source)^;
+    s_block := PUint32(source)^;
 
-    d_block := ((s_block And $e000e000) Shr 8) Or
-               ((s_block And $07000700) Shr 6) Or
-               ((s_block And $00180018) Shr 3);
-    d_block := (d_block And $ff) Or ((d_block And $ff0000) Shr 8);
+    d_block := ((s_block and $e000e000) shr 8) or
+               ((s_block and $07000700) shr 6) or
+               ((s_block and $00180018) shr 3);
+    d_block := (d_block and $ff) or ((d_block and $ff0000) shr 8);
 
-    { And the second two }
-    s_block := (Pint32(source)+1)^;
+    { and the second two }
+    s_block := (PUint32(source)+1)^;
 
-    s_block := ((s_block And $e000e000) Shr 8) Or
-               ((s_block And $07000700) Shr 6) Or
-               ((s_block And $00180018) Shr 3);
-    s_block := (s_block And $ff) Or ((s_block And $ff0000) Shr 8);
+    s_block := ((s_block and $e000e000) shr 8) or
+               ((s_block and $07000700) shr 6) or
+               ((s_block and $00180018) shr 3);
+    s_block := (s_block and $ff) or ((s_block and $ff0000) shr 8);
 
     { Put it all in one dword and write it }
-    d_block := d_block Or (s_block Shl 16);
+    d_block := (d_block shl DWORD_SMALLINT0_SHL) or (s_block shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_block;
+    PUint32(dest)^ := d_block;
     Inc(source, 8);
     Inc(dest, 4);
-  End;
+  end;
 
   { Clean up remaining pixels }
-  count := count And 3;
-  While count > 0 Do
-  Begin
+  count := count and 3;
+  while count > 0 do
+  begin
     Dec(count);
-    s_block := Pshort16(source)^;
+    s_block := PUint16(source)^;
 
-    dest^ := ((s_block And $e000) Shr 8) Or ((s_block And $0700) Shr 6) Or
-             ((s_block And $18) Shr 3);
+    dest^ := ((s_block and $e000) shr 8) or ((s_block and $0700) shr 6) or
+             ((s_block and $18) shr 3);
     Inc(dest);
     Inc(source, 2);
-  End;
-End;
+  end;
+end;
 
 { -------------------------------------------------------------------------
 
@@ -387,409 +379,405 @@ End;
   ------------------------------------------------------------------------- }
 
 
-Procedure ConvertP_16rgb565_32rgb888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  p : int32;
-
-Begin
+procedure ConvertP_16rgb565_32rgb888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  p: Uint32;
+begin
   x := 0;
-  Repeat
-    p := (((Pshort16(source) + (x Shr 16))^ And $f800) Shl 8) Or
-         (((Pshort16(source) + (x Shr 16))^ And $7e0) Shl 5) Or
-         (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 3) Or $30103;
+  repeat
+    p := (((PUint16(source) + (x shr 16))^ and $f800) shl 8) or
+         (((PUint16(source) + (x shr 16))^ and $7e0) shl 5) or
+         (((PUint16(source) + (x shr 16))^ and $1f) shl 3) or $30103;
 
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_16rgb565_32bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_pixel : int32;
-  x : DWord;
-
-Begin
+  until count = 0;
+end;
+
+procedure ConvertP_16rgb565_32bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+  x: DWord;
+begin
   x := 0;
 
-  Repeat
-    d_pixel := (Pshort16(source) + (x Shr 16))^;
+  repeat
+    d_pixel := (PUint16(source) + (x shr 16))^;
 
-    d_pixel := ((d_pixel And $f800) Shr 8) Or ((d_pixel And $7e0) Shl 5) Or
-               ((d_pixel And $1f) Shl 19) Or $30103;
+    d_pixel := ((d_pixel and $f800) shr 8) or ((d_pixel and $7e0) shl 5) or
+               ((d_pixel and $1f) shl 19) or $30103;
 
-    Pint32(dest)^ := d_pixel;
+    PUint32(dest)^ := d_pixel;
 
     Inc(dest, 4);
     Inc(x, inc_source);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_16rgb565_32rgba888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  p : int32;
-
-Begin
+  until count = 0;
+end;
+
+procedure ConvertP_16rgb565_32rgba888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  p: Uint32;
+begin
   x := 0;
-  Repeat
-    p := (((Pshort16(source) + (x Shr 16))^ And $f800) Shl (8+8)) Or
-         (((Pshort16(source) + (x Shr 16))^ And $7e0) Shl (5+8)) Or
-         (((Pshort16(source) + (x Shr 16))^ And $1f) Shl (3+8)) Or $30103ff;
+  repeat
+    p := (((PUint16(source) + (x shr 16))^ and $f800) shl (8+8)) or
+         (((PUint16(source) + (x shr 16))^ and $7e0) shl (5+8)) or
+         (((PUint16(source) + (x shr 16))^ and $1f) shl (3+8)) or $30103ff;
 
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_16rgb565_32bgra888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_pixel : int32;
-  x : DWord;
-
-Begin
+  until count = 0;
+end;
+
+procedure ConvertP_16rgb565_32bgra888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pixel: Uint32;
+  x: DWord;
+begin
   x := 0;
 
-  Repeat
-    d_pixel := (Pshort16(source) + (x Shr 16))^;
+  repeat
+    d_pixel := (PUint16(source) + (x shr 16))^;
 
-    d_pixel := ((d_pixel And $f800) {Shr 8}) Or ((d_pixel And $7e0) Shl (5+8)) Or
-               ((d_pixel And $1f) Shl (19+8)) Or $30103ff;
+    d_pixel := ((d_pixel and $f800) {Shr 8}) or ((d_pixel and $7e0) shl (5+8)) or
+               ((d_pixel and $1f) shl (19+8)) or $30103ff;
 
-    Pint32(dest)^ := d_pixel;
+    PUint32(dest)^ := d_pixel;
 
     Inc(dest, 4);
     Inc(x, inc_source);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_16rgb565_24rgb888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  p1, p2, p3, p4 : DWord;
-  c : DWord;
-
-Begin
+  until count = 0;
+end;
+
+procedure ConvertP_16rgb565_24rgb888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  p1, p2, p3, p4: DWord;
+  c: DWord;
+begin
   x := 0;
-  While (PtrUInt(dest) And 3) <> 0 Do
-  Begin
-    p1 := (((Pshort16(source) + (x Shr 16))^ And $f800) Shl 8) Or
-          (((Pshort16(source) + (x Shr 16))^ And $7e0) Shl 5) Or
-          (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 3) Or $30103;
-    Pshort16(dest)^ := p1 And $FFFF;
-    (dest + 2)^ := p1 Shr 16;
-    
+  while (PtrUInt(dest) and 3) <> 0 do
+  begin
+    p1 := (((PUint16(source) + (x shr 16))^ and $f800) shl 8) or
+          (((PUint16(source) + (x shr 16))^ and $7e0) shl 5) or
+          (((PUint16(source) + (x shr 16))^ and $1f) shl 3) or $30103;
+    (dest + B_24)^ := p1 and $FF;
+    (dest + G_24)^ := (p1 shr 8) and $FF;
+    (dest + R_24)^ := p1 shr 16;
+
     Inc(dest, 3);
     Inc(x, inc_source);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
-  
-  c := count Shr 2;
-  While c > 0 Do
-  Begin
-    p1 := (Pshort16(source) + (x Shr 16))^;
-    p2 := (Pshort16(source) + ((x + inc_source) Shr 16))^;
-    p3 := (Pshort16(source) + ((x + 2*inc_source) Shr 16))^;
-    p4 := (Pshort16(source) + ((x + 3*inc_source) Shr 16))^;
-
-    Pint32(dest + 0)^ := ((p2 And $001F) Shl 27) Or ((p1 And $F800) Shl 8) Or ((p1 And $07E0) Shl 5) Or ((p1 And $001F) Shl 3) Or $03030103;
-    Pint32(dest + 4)^ := ((p3 And $07E0) Shl 21) Or ((p3 And $001F) Shl 19) Or (p2 And $F800) Or ((p2 And $07E0) Shr 3) Or $01030301;
-    Pint32(dest + 8)^ := ((p4 And $F800) Shl 16) Or ((p4 And $07E0) Shl 13) Or ((p4 And $001F) Shl 11) Or ((p3 And $F800) Shr 8) Or $03010303;
-    
+    if count = 0 then
+      exit;
+  end;
+
+  c := count shr 2;
+  while c > 0 do
+  begin
+    p1 := (PUint16(source) + (x shr 16))^;
+    p2 := (PUint16(source) + ((x + inc_source) shr 16))^;
+    p3 := (PUint16(source) + ((x + 2*inc_source) shr 16))^;
+    p4 := (PUint16(source) + ((x + 3*inc_source) shr 16))^;
+
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p2 and $001F) shl 27) or ((p1 and $F800) shl 8) or ((p1 and $07E0) shl 5) or ((p1 and $001F) shl 3) or $03030103;
+    PUint32(dest + 4)^ := ((p3 and $07E0) shl 21) or ((p3 and $001F) shl 19) or (p2 and $F800) or ((p2 and $07E0) shr 3) or $01030301;
+    PUint32(dest + 8)^ := ((p4 and $F800) shl 16) or ((p4 and $07E0) shl 13) or ((p4 and $001F) shl 11) or ((p3 and $F800) shr 8) or $03010303;
+    {$ELSE FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p1 and $F800) shl 16) or ((p1 and $07E0) shl 13) or ((p1 and $001F) shl 11) or ((p2 and $F800) shr 8) or $03010303;
+    PUint32(dest + 4)^ := ((p2 and $07E0) shl 21) or ((p2 and $001F) shl 19) or (p3 and $F800) or ((p3 and $07E0) shr 3) or $01030301;
+    PUint32(dest + 8)^ := ((p3 and $001F) shl 27) or ((p4 and $F800) shl 8) or ((p4 and $07E0) shl 5) or ((p4 and $001F) shl 3) or $03030103;
+    {$ENDIF FPC_LITTLE_ENDIAN}
+
     Inc(x, 4*inc_source);
     Inc(dest, 12);
     Dec(c);
-  End;
-  
-  count := count And 3;
-  While count > 0 Do
-  Begin
-    p1 := (((Pshort16(source) + (x Shr 16))^ And $f800) Shl 8) Or
-          (((Pshort16(source) + (x Shr 16))^ And $7e0) Shl 5) Or
-          (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 3) Or $30103;
-    Pshort16(dest)^ := p1 And $FFFF;
-    (dest + 2)^ := p1 Shr 16;
-    
+  end;
+
+  count := count and 3;
+  while count > 0 do
+  begin
+    p1 := (((PUint16(source) + (x shr 16))^ and $f800) shl 8) or
+          (((PUint16(source) + (x shr 16))^ and $7e0) shl 5) or
+          (((PUint16(source) + (x shr 16))^ and $1f) shl 3) or $30103;
+    (dest + B_24)^ := p1 and $FF;
+    (dest + G_24)^ := (p1 shr 8) and $FF;
+    (dest + R_24)^ := p1 shr 16;
+
     Inc(dest, 3);
     Inc(x, inc_source);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_16rgb565_24bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  p1, p2, p3, p4 : DWord;
-  c : DWord;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_16rgb565_24bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  p1, p2, p3, p4: DWord;
+  c: DWord;
+begin
   x := 0;
-  While (PtrUInt(dest) And 3) <> 0 Do
-  Begin
-    p1 := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 8) Or
-          (((Pshort16(source) + (x Shr 16))^ And $7e0) Shl 5) Or
-          (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 19) Or $30103;
-    Pshort16(dest)^ := p1 And $FFFF;
-    (dest + 2)^ := p1 Shr 16;
-    
+  while (PtrUInt(dest) and 3) <> 0 do
+  begin
+    p1 := (((PUint16(source) + (x shr 16))^ and $f800) shr 8) or
+          (((PUint16(source) + (x shr 16))^ and $7e0) shl 5) or
+          (((PUint16(source) + (x shr 16))^ and $1f) shl 19) or $30103;
+    (dest + B_24)^ := p1 and $FF;
+    (dest + G_24)^ := (p1 shr 8) and $FF;
+    (dest + R_24)^ := p1 shr 16;
+
     Inc(dest, 3);
     Inc(x, inc_source);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
-  
-  c := count Shr 2;
-  While c > 0 Do
-  Begin
-    p1 := (Pshort16(source) + (x Shr 16))^;
-    p2 := (Pshort16(source) + ((x + inc_source) Shr 16))^;
-    p3 := (Pshort16(source) + ((x + 2*inc_source) Shr 16))^;
-    p4 := (Pshort16(source) + ((x + 3*inc_source) Shr 16))^;
-
-    Pint32(dest + 0)^ := ((p2 And $F800) Shl 16) Or ((p1 And $001F) Shl 19) Or ((p1 And $07E0) Shl 5) Or ((p1 And $F800) Shr 8) Or $03030103;
-    Pint32(dest + 4)^ := ((p3 And $07E0) Shl 21) Or ((p3 And $F800) Shl 8) Or ((p2 And $001F) Shl 11) Or ((p2 And $07E0) Shr 3) Or $01030301;
-    Pint32(dest + 8)^ := ((p4 And $001F) Shl 27) Or ((p4 And $07E0) Shl 13) Or (p4 And $F800) Or ((p3 And $001F) Shl 3) Or $03010303;
-    
+    if count = 0 then
+      exit;
+  end;
+
+  c := count shr 2;
+  while c > 0 do
+  begin
+    p1 := (PUint16(source) + (x shr 16))^;
+    p2 := (PUint16(source) + ((x + inc_source) shr 16))^;
+    p3 := (PUint16(source) + ((x + 2*inc_source) shr 16))^;
+    p4 := (PUint16(source) + ((x + 3*inc_source) shr 16))^;
+
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p2 and $F800) shl 16) or ((p1 and $001F) shl 19) or ((p1 and $07E0) shl 5) or ((p1 and $F800) shr 8) or $03030103;
+    PUint32(dest + 4)^ := ((p3 and $07E0) shl 21) or ((p3 and $F800) shl 8) or ((p2 and $001F) shl 11) or ((p2 and $07E0) shr 3) or $01030301;
+    PUint32(dest + 8)^ := ((p4 and $001F) shl 27) or ((p4 and $07E0) shl 13) or (p4 and $F800) or ((p3 and $001F) shl 3) or $03010303;
+    {$ELSE FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p1 and $001F) shl 27) or ((p1 and $07E0) shl 13) or (p1 and $F800) or ((p2 and $001F) shl 3) or $03010303;
+    PUint32(dest + 4)^ := ((p2 and $07E0) shl 21) or ((p2 and $F800) shl 8) or ((p3 and $001F) shl 11) or ((p3 and $07E0) shr 3) or $01030301;
+    PUint32(dest + 8)^ := ((p3 and $F800) shl 16) or ((p4 and $001F) shl 19) or ((p4 and $07E0) shl 5) or ((p4 and $F800) shr 8) or $03030103;
+    {$ENDIF FPC_LITTLE_ENDIAN}
+
     Inc(x, 4*inc_source);
     Inc(dest, 12);
     Dec(c);
-  End;
-  
-  count := count And 3;
-  While count > 0 Do
-  Begin
-    p1 := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 8) Or
-          (((Pshort16(source) + (x Shr 16))^ And $7e0) Shl 5) Or
-          (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 19) Or $30103;
-    Pshort16(dest)^ := p1 And $FFFF;
-    (dest + 2)^ := p1 Shr 16;
-    
+  end;
+
+  count := count and 3;
+  while count > 0 do
+  begin
+    p1 := (((PUint16(source) + (x shr 16))^ and $f800) shr 8) or
+          (((PUint16(source) + (x shr 16))^ and $7e0) shl 5) or
+          (((PUint16(source) + (x shr 16))^ and $1f) shl 19) or $30103;
+    (dest + B_24)^ := p1 and $FF;
+    (dest + G_24)^ := (p1 shr 8) and $FF;
+    (dest + R_24)^ := p1 shr 16;
+
     Inc(dest, 3);
     Inc(x, inc_source);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_16rgb565_16bgr565_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_16rgb565_16bgr565_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
-  { If we are not aligned to a dword, try and convert a single pixel }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
+  { if we are not aligned to a dword, try and convert a single pixel }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
     { Swap r and b, leave g untouched }
-    Pshort16(dest)^ := ((Pshort16(source) + (x Shr 16))^ Shr 11) Or
-                       ((Pshort16(source) + (x Shr 16))^ And $7e0) Or
-                       (((Pshort16(source) + (x Shr 16))^ Shl 11) And $f800);
+    PUint16(dest)^ := ((PUint16(source) + (x shr 16))^ shr 11) or
+                       ((PUint16(source) + (x shr 16))^ and $7e0) or
+                       (((PUint16(source) + (x shr 16))^ shl 11) and $f800);
     Inc(x, inc_source);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
-  c := count Shr 1;
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
 
     { Swap r and b, leave g untouched }
-    p := ((Pshort16(source) + (x Shr 16))^ Shr 11) Or
-         ((Pshort16(source) + (x Shr 16))^ And $7e0) Or
-         (((Pshort16(source) + (x Shr 16))^ Shl 11) And $f800);
+    p := (((PUint16(source) + (x shr 16))^ shr 11) or
+          ((PUint16(source) + (x shr 16))^ and $7e0) or
+          (((PUint16(source) + (x shr 16))^ shl 11) and $f800)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or ((((Pshort16(source) + (x Shr 16))^ Shr 11) Or
-                ((Pshort16(source) + (x Shr 16))^ And $7e0) Or
-                (((Pshort16(source) + (x Shr 16))^ Shl 11) And $f800)) Shl 16);
+    p := p or ((((PUint16(source) + (x shr 16))^ shr 11) or
+                ((PUint16(source) + (x shr 16))^ and $7e0) or
+                (((PUint16(source) + (x shr 16))^ shl 11) and $f800)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
     Inc(dest, 4);
-  End;
-
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := ((Pshort16(source) + (x Shr 16))^ Shr 11) Or
-                       ((Pshort16(source) + (x Shr 16))^ And $7e0) Or
-                       (((Pshort16(source) + (x Shr 16))^ Shl 11) And $f800);
-End;
-
-Procedure ConvertP_16rgb565_16rgb555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  end;
+
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := ((PUint16(source) + (x shr 16))^ shr 11) or
+                       ((PUint16(source) + (x shr 16))^ and $7e0) or
+                       (((PUint16(source) + (x shr 16))^ shl 11) and $f800);
+end;
+
+procedure ConvertP_16rgb565_16rgb555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
-  { If we are not aligned to a dword, try and convert a single pixel }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    Pshort16(dest)^ := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 1) Or
-                       (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-                       ((Pshort16(source) + (x Shr 16))^ And $1f);
+  { if we are not aligned to a dword, try and convert a single pixel }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    PUint16(dest)^ := (((PUint16(source) + (x shr 16))^ and $f800) shr 1) or
+                       (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+                       ((PUint16(source) + (x shr 16))^ and $1f);
     Inc(dest, 2);
     Inc(x, inc_source);
     Dec(count);
-  End;
+  end;
 
-  c := count Shr 1;
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
 
     { Leave blue untouched, mask red and shift by one, mask green and shift
       by one }
-    p := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 1) Or
-         (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-         ((Pshort16(source) + (x Shr 16))^ And $1f);
+    p := ((((PUint16(source) + (x shr 16))^ and $f800) shr 1) or
+          (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+          ((PUint16(source) + (x shr 16))^ and $1f)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or (((((Pshort16(source) + (x Shr 16))^ And $f800) Shr 1) Or
-                (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-                ((Pshort16(source) + (x Shr 16))^ And $1f)) Shl 16);
+    p := p or (((((PUint16(source) + (x shr 16))^ and $f800) shr 1) or
+                (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+                ((PUint16(source) + (x shr 16))^ and $1f)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
     Inc(dest, 4);
-  End;
-
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 1) Or
-                       (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-                       ((Pshort16(source) + (x Shr 16))^ And $1f);
-End;
-
-Procedure ConvertP_16rgb565_16bgr555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  end;
+
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint16(source) + (x shr 16))^ and $f800) shr 1) or
+                       (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+                       ((PUint16(source) + (x shr 16))^ and $1f);
+end;
+
+procedure ConvertP_16rgb565_16bgr555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
-  { If we are not aligned to a dword, try and convert a single pixel }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    Pshort16(dest)^ := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 11) Or
-                       (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-                       (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 10);
+  { if we are not aligned to a dword, try and convert a single pixel }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    PUint16(dest)^ := (((PUint16(source) + (x shr 16))^ and $f800) shr 11) or
+                       (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+                       (((PUint16(source) + (x shr 16))^ and $1f) shl 10);
     Inc(dest, 2);
     Inc(x, inc_source);
     Dec(count);
-  End;
+  end;
 
-  c := count Shr 1;
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
 
-    p := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 11) Or
-         (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-         (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 10);
+    p := ((((PUint16(source) + (x shr 16))^ and $f800) shr 11) or
+          (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+          (((PUint16(source) + (x shr 16))^ and $1f) shl 10)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or (((((Pshort16(source) + (x Shr 16))^ And $f800) Shr 11) Or
-                (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-                (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 10)) Shl 16);
+    p := p or (((((PUint16(source) + (x shr 16))^ and $f800) shr 11) or
+                (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+                (((PUint16(source) + (x shr 16))^ and $1f) shl 10)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
     Inc(dest, 4);
-  End;
-
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pshort16(source) + (x Shr 16))^ And $f800) Shr 11) Or
-                       (((Pshort16(source) + (x Shr 16))^ And $7c0) Shr 1) Or
-                       (((Pshort16(source) + (x Shr 16))^ And $1f) Shl 10);
-End;
-
-Procedure ConvertP_16rgb565_8rgb332_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  end;
+
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint16(source) + (x shr 16))^ and $f800) shr 11) or
+                       (((PUint16(source) + (x shr 16))^ and $7c0) shr 1) or
+                       (((PUint16(source) + (x shr 16))^ and $1f) shl 10);
+end;
+
+procedure ConvertP_16rgb565_8rgb332_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
 
   { Write single pixels until the destination address is aligned mod 4 }
-  While (PtrUInt(dest) And $3) <> 0 Do
-  Begin
-    dest^ := (((Pshort16(source) + (x Shr 16))^ Shr 8) And $e0) Or
-             (((Pshort16(source) + (x Shr 16))^ Shr 6) And $1c) Or
-             (((Pshort16(source) + (x Shr 16))^ Shr 3) And $3);
+  while (PtrUInt(dest) and $3) <> 0 do
+  begin
+    dest^ := (((PUint16(source) + (x shr 16))^ shr 8) and $e0) or
+             (((PUint16(source) + (x shr 16))^ shr 6) and $1c) or
+             (((PUint16(source) + (x shr 16))^ shr 3) and $3);
     Inc(x, inc_source);
     Inc(dest);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
+    if count = 0 then
+      exit;
+  end;
 
 
   {* Write blocks of four pixels now }
-  c := count Shr 2;
-  While c <> 0 Do
-  Begin
+  c := count shr 2;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pshort16(source) + (x Shr 16))^ Shr 8) And $e0) Or
-         (((Pshort16(source) + (x Shr 16))^ Shr 6) And $1c) Or
-         (((Pshort16(source) + (x Shr 16))^ Shr 3) And $3);
+    p := ((((PUint16(source) + (x shr 16))^ shr 8) and $e0) or
+          (((PUint16(source) + (x shr 16))^ shr 6) and $1c) or
+          (((PUint16(source) + (x shr 16))^ shr 3) and $3)) shl DWORD_BYTE0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-      (((((Pshort16(source) + (x Shr 16))^ Shr 8) And $e0) Or
-        (((Pshort16(source) + (x Shr 16))^ Shr 6) And $1c) Or
-        (((Pshort16(source) + (x Shr 16))^ Shr 3) And $3)) Shl 8);
+    p := p or
+      (((((PUint16(source) + (x shr 16))^ shr 8) and $e0) or
+        (((PUint16(source) + (x shr 16))^ shr 6) and $1c) or
+        (((PUint16(source) + (x shr 16))^ shr 3) and $3)) shl DWORD_BYTE1_SHL);
     Inc(x, inc_source);
 
-    p := p Or
-      (((((Pshort16(source) + (x Shr 16))^ Shr 8) And $e0) Or
-        (((Pshort16(source) + (x Shr 16))^ Shr 6) And $1c) Or
-        (((Pshort16(source) + (x Shr 16))^ Shr 3) And $3)) Shl 16);
+    p := p or
+      (((((PUint16(source) + (x shr 16))^ shr 8) and $e0) or
+        (((PUint16(source) + (x shr 16))^ shr 6) and $1c) or
+        (((PUint16(source) + (x shr 16))^ shr 3) and $3)) shl DWORD_BYTE2_SHL);
     Inc(x, inc_source);
 
-    p := p Or
-      (((((Pshort16(source) + (x Shr 16))^ Shr 8) And $e0) Or
-        (((Pshort16(source) + (x Shr 16))^ Shr 6) And $1c) Or
-        (((Pshort16(source) + (x Shr 16))^ Shr 3) And $3)) Shl 24);
+    p := p or
+      (((((PUint16(source) + (x shr 16))^ shr 8) and $e0) or
+        (((PUint16(source) + (x shr 16))^ shr 6) and $1c) or
+        (((PUint16(source) + (x shr 16))^ shr 3) and $3)) shl DWORD_BYTE3_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write up to three trailing pixels }
-  c := count And $3;
-  While c <> 0 Do
-  Begin
+  c := count and $3;
+  while c <> 0 do
+  begin
     Dec(c);
-    dest^ := (((Pshort16(source) + (x Shr 16))^ Shr 8) And $e0) Or
-             (((Pshort16(source) + (x Shr 16))^ Shr 6) And $1c) Or
-             (((Pshort16(source) + (x Shr 16))^ Shr 3) And $3);
+    dest^ := (((PUint16(source) + (x shr 16))^ shr 8) and $e0) or
+             (((PUint16(source) + (x shr 16))^ shr 6) and $1c) or
+             (((PUint16(source) + (x shr 16))^ shr 3) and $3);
     Inc(x, inc_source);
     Inc(dest);
-  End;
-End;
+  end;
+end;

+ 499 - 523
packages/hermes/src/p_24.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -33,103 +45,93 @@
 
   ------------------------------------------------------------------------- }
 { FROM 24 BIT ROUTINES }
-Procedure ConvertP_24rgb888_32rgb888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-
-Begin
-  Repeat
-    d_block := ((source + R_24)^ Shl 16) Or
-               ((source + G_24)^ Shl 8) Or
+procedure ConvertP_24rgb888_32rgb888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+begin
+  repeat
+    d_block := ((source + R_24)^ shl 16) or
+               ((source + G_24)^ shl 8) or
                (source + B_24)^;
-    Pint32(dest)^ := d_block;
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Inc(source, 3);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_32bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-
-Begin
-  Repeat
-    d_block := (source + R_24)^ Or
-               ((source + G_24)^ Shl 8) Or
-               ((source + B_24)^ Shl 16);
-    Pint32(dest)^ := d_block;
+  until count = 0;
+end;
+
+procedure ConvertP_24rgb888_32bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+begin
+  repeat
+    d_block := (source + R_24)^ or
+               ((source + G_24)^ shl 8) or
+               ((source + B_24)^ shl 16);
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Inc(source, 3);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_32rgba888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-
-Begin
-  Repeat
-    d_block := ((source + R_24)^ Shl 24) Or
-               ((source + G_24)^ Shl 16) Or
-               ((source + B_24)^ Shl 8) Or $ff;
-    Pint32(dest)^ := d_block;
+  until count = 0;
+end;
+
+procedure ConvertP_24rgb888_32rgba888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+begin
+  repeat
+    d_block := ((source + R_24)^ shl 24) or
+               ((source + G_24)^ shl 16) or
+               ((source + B_24)^ shl 8) or $ff;
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Inc(source, 3);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_32bgra888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-
-Begin
-  Repeat
-    d_block := ((source + R_24)^ Shl 8) Or
-               ((source + G_24)^ Shl 16) Or
-               ((source + B_24)^ Shl 24) Or $ff;
-    Pint32(dest)^ := d_block;
+  until count = 0;
+end;
+
+procedure ConvertP_24rgb888_32bgra888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+begin
+  repeat
+    d_block := ((source + R_24)^ shl 8) or
+               ((source + G_24)^ shl 16) or
+               ((source + B_24)^ shl 24) or $ff;
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Inc(source, 3);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_24bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_pix1, d_pix2, d_pix3 : int32;
-  c_pix1, c_pix2, c_pix3 : Pchar8;
-  c : DWord;
-  tmp : char8;
-
-Begin
-  While ((PtrUInt(dest) And 3) <> 0) And (count > 0) Do
-  Begin
+  until count = 0;
+end;
+
+procedure ConvertP_24rgb888_24bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_pix1, d_pix2, d_pix3: Uint32;
+  c_pix1, c_pix2, c_pix3: PUint8;
+  c: DWord;
+  tmp: Uint8;
+begin
+  while ((PtrUInt(dest) and 3) <> 0) and (count > 0) do
+  begin
     (dest + 0)^ := (source + 2)^;
     (dest + 1)^ := (source + 1)^;
     (dest + 2)^ := (source + 0)^;
     Dec(count);
     Inc(dest, 3);
     Inc(source, 3);
-  End;
-  
+  end;
+
   c_pix1 := @d_pix1;
   c_pix2 := @d_pix2;
   c_pix3 := @d_pix3;
 
-  c := count Shr 2;
-  While c > 0 Do
-  Begin
-    d_pix1 := Pint32(source)^;
-    d_pix2 := Pint32(source + 4)^;
-    d_pix3 := Pint32(source + 8)^;
+  c := count shr 2;
+  while c > 0 do
+  begin
+    d_pix1 := PUint32(source)^;
+    d_pix2 := PUint32(source + 4)^;
+    d_pix3 := PUint32(source + 8)^;
 
     { Swap R and B in all three pixels }
     tmp := (c_pix1 + 0)^; (c_pix1 + 0)^ := (c_pix1 + 2)^; (c_pix1 + 2)^ := tmp;
@@ -137,555 +139,529 @@ Begin
     tmp := (c_pix2 + 2)^; (c_pix2 + 2)^ := (c_pix3 + 0)^; (c_pix3 + 0)^ := tmp;
     tmp := (c_pix3 + 1)^; (c_pix3 + 1)^ := (c_pix3 + 3)^; (c_pix3 + 3)^ := tmp;
 
-    Pint32(dest)^ := d_pix1;
-    Pint32(dest + 4)^ := d_pix2;
-    Pint32(dest + 8)^ := d_pix3;
+    PUint32(dest)^ := d_pix1;
+    PUint32(dest + 4)^ := d_pix2;
+    PUint32(dest + 8)^ := d_pix3;
     Inc(dest, 12);
     Inc(source, 12);
     Dec(c);
-  End;
+  end;
 
-  count := count And $3;
-  While count > 0 Do
-  Begin
+  count := count and $3;
+  while count > 0 do
+  begin
     (dest + 0)^ := (source + 2)^;
     (dest + 1)^ := (source + 1)^;
     (dest + 2)^ := (source + 0)^;
     Dec(count);
     Inc(dest, 3);
     Inc(source, 3);
-  End;
-End;
-
-Procedure ConvertP_24rgb888_16rgb565(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  i : DWord;
-
-Begin
-  For i := 0 To (count Shr 1) - 1 Do
-  Begin
-    d_block := (((source + R_24)^ Shl 8) And $f800) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
-
-    d_block := d_block Or
-             (((((source + R_24 + 3)^ Shl 8) And $f800) Or
-               (((source + G_24 + 3)^ Shl 3) And $7e0) Or
-               (((source + B_24 + 3)^ Shr 3) And $1f)) Shl 16);
-
-    Pint32(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_16rgb565(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  i: DWord;
+begin
+  for i := 0 to (count shr 1) - 1 do
+  begin
+    d_block := ((((source + R_24)^ shl 8) and $f800) or
+                (((source + G_24)^ shl 3) and $7e0) or
+                (((source + B_24)^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
+
+    d_block := d_block or
+             (((((source + R_24 + 3)^ shl 8) and $f800) or
+               (((source + G_24 + 3)^ shl 3) and $7e0) or
+               (((source + B_24 + 3)^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
+
+    PUint32(dest)^ := d_block;
     Inc(source, 6);
     Inc(dest, 4);
-  End;
-
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shl 8) And $f800) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
-
-    Pshort16(dest)^ := d_block;
-  End;
-End;
-
-Procedure ConvertP_24rgb888_16bgr565(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  i : DWord;
-
-Begin
-  For i := 0 To (count Shr 1) - 1 Do
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shl 8) And $f800);
-
-    d_block := d_block Or
-             (((((source + R_24 + 3)^ Shr 3) And $1f) Or
-               (((source + G_24 + 3)^ Shl 3) And $7e0) Or
-               (((source + B_24 + 3)^ Shl 8) And $f800)) Shl 16);
-
-    Pint32(dest)^ := d_block;
+  end;
+
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shl 8) and $f800) or
+               (((source + G_24)^ shl 3) and $7e0) or
+               (((source + B_24)^ shr 3) and $1f);
+
+    PUint16(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_16bgr565(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  i: DWord;
+begin
+  for i := 0 to (count shr 1) - 1 do
+  begin
+    d_block := ((((source + R_24)^ shr 3) and $1f) or
+                (((source + G_24)^ shl 3) and $7e0) or
+                (((source + B_24)^ shl 8) and $f800)) shl DWORD_SMALLINT0_SHL;
+
+    d_block := d_block or
+             (((((source + R_24 + 3)^ shr 3) and $1f) or
+               (((source + G_24 + 3)^ shl 3) and $7e0) or
+               (((source + B_24 + 3)^ shl 8) and $f800)) shl DWORD_SMALLINT1_SHL);
+
+    PUint32(dest)^ := d_block;
     Inc(source, 6);
     Inc(dest, 4);
-  End;
-
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shl 8) And $f800);
-
-    Pshort16(dest)^ := d_block;
-  End;
-End;
-
-Procedure ConvertP_24rgb888_16rgb555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  i : DWord;
-
-Begin
-  For i := 0 To (count Shr 1) - 1 Do
-  Begin
-    d_block := (((source + R_24)^ Shl 7) And $7c00) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
-
-    d_block := d_block Or
-             (((((source + R_24 + 3)^ Shl 7) And $7c00) Or
-               (((source + G_24 + 3)^ Shl 2) And $3e0) Or
-               (((source + B_24 + 3)^ Shr 3) And $1f)) Shl 16);
-
-    Pint32(dest)^ := d_block;
+  end;
+
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shr 3) and $1f) or
+               (((source + G_24)^ shl 3) and $7e0) or
+               (((source + B_24)^ shl 8) and $f800);
+
+    PUint16(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_16rgb555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  i: DWord;
+begin
+  for i := 0 to (count shr 1) - 1 do
+  begin
+    d_block := ((((source + R_24)^ shl 7) and $7c00) or
+                (((source + G_24)^ shl 2) and $3e0) or
+                (((source + B_24)^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
+
+    d_block := d_block or
+             (((((source + R_24 + 3)^ shl 7) and $7c00) or
+               (((source + G_24 + 3)^ shl 2) and $3e0) or
+               (((source + B_24 + 3)^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
+
+    PUint32(dest)^ := d_block;
     Inc(source, 6);
     Inc(dest, 4);
-  End;
-
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shl 7) And $7c00) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
-
-    Pshort16(dest)^ := d_block;
-  End;
-End;
-
-Procedure ConvertP_24rgb888_16bgr555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  i : DWord;
-
-Begin
-  For i := 0 To (count Shr 1) - 1 Do
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shl 7) And $7c00);
-
-    d_block := d_block Or
-             (((((source + R_24 + 3)^ Shr 3) And $1f) Or
-               (((source + G_24 + 3)^ Shl 2) And $3e0) Or
-               (((source + B_24 + 3)^ Shl 7) And $7c00)) Shl 16);
-
-    Pint32(dest)^ := d_block;
+  end;
+
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shl 7) and $7c00) or
+               (((source + G_24)^ shl 2) and $3e0) or
+               (((source + B_24)^ shr 3) and $1f);
+
+    PUint16(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_16bgr555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  i: DWord;
+begin
+  for i := 0 to (count shr 1) - 1 do
+  begin
+    d_block := ((((source + R_24)^ shr 3) and $1f) or
+                (((source + G_24)^ shl 2) and $3e0) or
+                (((source + B_24)^ shl 7) and $7c00)) shl DWORD_SMALLINT0_SHL;
+
+    d_block := d_block or
+             (((((source + R_24 + 3)^ shr 3) and $1f) or
+               (((source + G_24 + 3)^ shl 2) and $3e0) or
+               (((source + B_24 + 3)^ shl 7) and $7c00)) shl DWORD_SMALLINT1_SHL);
+
+    PUint32(dest)^ := d_block;
     Inc(source, 6);
     Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shl 7) And $7c00);
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shr 3) and $1f) or
+               (((source + G_24)^ shl 2) and $3e0) or
+               (((source + B_24)^ shl 7) and $7c00);
 
-    Pshort16(dest)^ := d_block;
-  End;
-End;
+    PUint16(dest)^ := d_block;
+  end;
+end;
 
 { optimise me !! }
 
-Procedure ConvertP_24rgb888_8rgb332(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  r, g, b : int32;
-  i : DWord;
-
-Begin
-  For i := 0 To count - 1 Do
-  Begin
-    r := (source + R_24)^ And $e0;
-    g := ((source + G_24)^ Shr 3) And $1c;
-    b := ((source + B_24)^ Shr 6) And $3;
-
-    dest^ := r Or g Or b;
+procedure ConvertP_24rgb888_8rgb332(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  r, g, b: Uint32;
+  i: DWord;
+begin
+  for i := 0 to count - 1 do
+  begin
+    r := (source + R_24)^ and $e0;
+    g := ((source + G_24)^ shr 3) and $1c;
+    b := ((source + B_24)^ shr 6) and $3;
+
+    dest^ := r or g or b;
     Inc(source, 3);
     Inc(dest);
-  End;
-End;
+  end;
+end;
 
 { -------------------------------------------------------------------------
 
                              STRETCH CONVERTERS
 
   ------------------------------------------------------------------------- }
-Procedure ConvertP_24rgb888_32rgb888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-
-Begin
+procedure ConvertP_24rgb888_32rgb888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+begin
   x := 0;
-  Repeat
-    Pint32(dest)^ := ((source + R_24)^ Shl 16) Or
-                     ((source + G_24)^ Shl 8) Or
+  repeat
+    PUint32(dest)^ := ((source + R_24)^ shl 16) or
+                     ((source + G_24)^ shl 8) or
                       (source + B_24)^;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
-Procedure ConvertP_24rgb888_32bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-
-Begin
+procedure ConvertP_24rgb888_32bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+begin
   x := 0;
-  Repeat
-    Pint32(dest)^ :=  (source + R_24)^ Or
-                     ((source + G_24)^ Shl 8) Or
-                     ((source + B_24)^ Shl 16);
+  repeat
+    PUint32(dest)^ :=  (source + R_24)^ or
+                     ((source + G_24)^ shl 8) or
+                     ((source + B_24)^ shl 16);
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_32rgba888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+  until count = 0;
+end;
 
-Var
-  x : DWord;
-
-Begin
+procedure ConvertP_24rgb888_32rgba888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+begin
   x := 0;
-  Repeat
-    Pint32(dest)^ := ((((source + R_24)^ Shl 16) Or
-                       ((source + G_24)^ Shl 8) Or
-                        (source + B_24)^) Shl 8) Or $FF;
+  repeat
+    PUint32(dest)^ := ((((source + R_24)^ shl 16) or
+                       ((source + G_24)^ shl 8) or
+                        (source + B_24)^) shl 8) or $FF;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_32bgra888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+  until count = 0;
+end;
 
-Var
-  x : DWord;
-
-Begin
+procedure ConvertP_24rgb888_32bgra888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+begin
   x := 0;
-  Repeat
-    Pint32(dest)^ :=  (((source + R_24)^ Or
-                       ((source + G_24)^ Shl 8) Or
-                       ((source + B_24)^ Shl 16)) Shl 8) Or $FF;
+  repeat
+    PUint32(dest)^ :=  (((source + R_24)^ or
+                       ((source + G_24)^ shl 8) or
+                       ((source + B_24)^ shl 16)) shl 8) or $FF;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_24bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : int32;
+  until count = 0;
+end;
 
-Begin
+procedure ConvertP_24rgb888_24bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: Uint32;
+begin
   x := 0;
-  Repeat
+  repeat
     (dest + 0)^ := (source + 2)^;
     (dest + 1)^ := (source + 1)^;
     (dest + 2)^ := (source + 0)^;
 
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
     Inc(dest, 3);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_24rgb888_16rgb565_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  x : DWord;
-  c : DWord;
-
-Begin
+  until count = 0;
+end;
+
+procedure ConvertP_24rgb888_16rgb565_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  x: DWord;
+  c: DWord;
+begin
   x := 0;
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shl 8) And $f800) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shl 8) and $f800) or
+               (((source + G_24)^ shl 3) and $7e0) or
+               (((source + B_24)^ shr 3) and $1f);
 
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pshort16(dest)^ := d_block;
+    PUint16(dest)^ := d_block;
     Inc(dest, 2);
-  End;
-  c := count Shr 1;
-  While c > 0 Do
-  Begin
-    d_block := (((source + R_24)^ Shl 8) And $f800) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
+    Dec(count);
+  end;
+  c := count shr 1;
+  while c > 0 do
+  begin
+    d_block := ((((source + R_24)^ shl 8) and $f800) or
+                (((source + G_24)^ shl 3) and $7e0) or
+                (((source + B_24)^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
-
-    d_block := d_block Or
-             (((((source + R_24)^ Shl 8) And $f800) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shr 3) And $1f)) Shl 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
+
+    d_block := d_block or
+             (((((source + R_24)^ shl 8) and $f800) or
+               (((source + G_24)^ shl 3) and $7e0) or
+               (((source + B_24)^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pint32(dest)^ := d_block;
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Dec(c);
-  End;
-
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shl 8) And $f800) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
-
-    Pshort16(dest)^ := d_block;
-  End;
-End;
-
-Procedure ConvertP_24rgb888_16bgr565_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  x : DWord;
-  c : DWord;
-
-Begin
+  end;
+
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shl 8) and $f800) or
+               (((source + G_24)^ shl 3) and $7e0) or
+               (((source + B_24)^ shr 3) and $1f);
+
+    PUint16(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_16bgr565_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  x: DWord;
+  c: DWord;
+begin
   x := 0;
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shl 8) And $f800);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shr 3) and $1f) or
+               (((source + G_24)^ shl 3) and $7e0) or
+               (((source + B_24)^ shl 8) and $f800);
 
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pshort16(dest)^ := d_block;
+    PUint16(dest)^ := d_block;
     Inc(dest, 2);
-  End;
-  c := count Shr 1;
-  While c > 0 Do
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shl 8) And $f800);
+    Dec(count);
+  end;
+  c := count shr 1;
+  while c > 0 do
+  begin
+    d_block := ((((source + R_24)^ shr 3) and $1f) or
+                (((source + G_24)^ shl 3) and $7e0) or
+                (((source + B_24)^ shl 8) and $f800)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
-
-    d_block := d_block Or
-              (((((source + R_24)^ Shr 3) And $1f) Or
-                (((source + G_24)^ Shl 3) And $7e0) Or
-                (((source + B_24)^ Shl 8) And $f800)) Shl 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
+
+    d_block := d_block or
+              (((((source + R_24)^ shr 3) and $1f) or
+                (((source + G_24)^ shl 3) and $7e0) or
+                (((source + B_24)^ shl 8) and $f800)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pint32(dest)^ := d_block;
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Dec(c);
-  End;
-
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 3) And $7e0) Or
-               (((source + B_24)^ Shl 8) And $f800);
-
-    Pshort16(dest)^ := d_block;
-  End;
-End;
-
-Procedure ConvertP_24rgb888_16rgb555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  x : DWord;
-  c : DWord;
-
-Begin
+  end;
+
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shr 3) and $1f) or
+               (((source + G_24)^ shl 3) and $7e0) or
+               (((source + B_24)^ shl 8) and $f800);
+
+    PUint16(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_16rgb555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  x: DWord;
+  c: DWord;
+begin
   x := 0;
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shl 7) And $7c00) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shl 7) and $7c00) or
+               (((source + G_24)^ shl 2) and $3e0) or
+               (((source + B_24)^ shr 3) and $1f);
 
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pshort16(dest)^ := d_block;
+    PUint16(dest)^ := d_block;
     Inc(dest, 2);
-  End;
-  c := count Shr 1;
-  While c > 0 Do
-  Begin
-    d_block := (((source + R_24)^ Shl 7) And $7c00) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
+    Dec(count);
+  end;
+  c := count shr 1;
+  while c > 0 do
+  begin
+    d_block := ((((source + R_24)^ shl 7) and $7c00) or
+                (((source + G_24)^ shl 2) and $3e0) or
+                (((source + B_24)^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
-
-    d_block := d_block Or
-               (((((source + R_24)^ Shl 7) And $7c00) Or
-                (((source + G_24)^ Shl 2) And $3e0) Or
-                (((source + B_24)^ Shr 3) And $1f)) Shl 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
+
+    d_block := d_block or
+               (((((source + R_24)^ shl 7) and $7c00) or
+                (((source + G_24)^ shl 2) and $3e0) or
+                (((source + B_24)^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pint32(dest)^ := d_block;
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Dec(c);
-  End;
-
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shl 7) And $7c00) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shr 3) And $1f);
-
-    Pshort16(dest)^ := d_block;
-  End;
-End;
-
-Procedure ConvertP_24rgb888_16bgr555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  d_block : int32;
-  x : DWord;
-  c : DWord;
-
-Begin
+  end;
+
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shl 7) and $7c00) or
+               (((source + G_24)^ shl 2) and $3e0) or
+               (((source + B_24)^ shr 3) and $1f);
+
+    PUint16(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_16bgr555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  d_block: Uint32;
+  x: DWord;
+  c: DWord;
+begin
   x := 0;
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shl 7) And $7c00);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shr 3) and $1f) or
+               (((source + G_24)^ shl 2) and $3e0) or
+               (((source + B_24)^ shl 7) and $7c00);
 
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pshort16(dest)^ := d_block;
+    PUint16(dest)^ := d_block;
     Inc(dest, 2);
-  End;
-  c := count Shr 1;
-  While c > 0 Do
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shl 7) And $7c00);
+    Dec(count);
+  end;
+  c := count shr 1;
+  while c > 0 do
+  begin
+    d_block := ((((source + R_24)^ shr 3) and $1f) or
+                (((source + G_24)^ shl 2) and $3e0) or
+                (((source + B_24)^ shl 7) and $7c00)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
-
-    d_block := d_block Or
-             (((((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shl 7) And $7c00)) Shl 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
+
+    d_block := d_block or
+             (((((source + R_24)^ shr 3) and $1f) or
+               (((source + G_24)^ shl 2) and $3e0) or
+               (((source + B_24)^ shl 7) and $7c00)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
 
-    Pint32(dest)^ := d_block;
+    PUint32(dest)^ := d_block;
     Inc(dest, 4);
     Dec(c);
-  End;
-
-  If (count And 1) <> 0 Then
-  Begin
-    d_block := (((source + R_24)^ Shr 3) And $1f) Or
-               (((source + G_24)^ Shl 2) And $3e0) Or
-               (((source + B_24)^ Shl 7) And $7c00);
-
-    Pshort16(dest)^ := d_block;
-  End;
-End;
-
-Procedure ConvertP_24rgb888_8rgb332_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  r, g, b : int32;
-  i : DWord;
-  x : DWord;
-
-Begin
+  end;
+
+  if (count and 1) <> 0 then
+  begin
+    d_block := (((source + R_24)^ shr 3) and $1f) or
+               (((source + G_24)^ shl 2) and $3e0) or
+               (((source + B_24)^ shl 7) and $7c00);
+
+    PUint16(dest)^ := d_block;
+  end;
+end;
+
+procedure ConvertP_24rgb888_8rgb332_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  r, g, b: Uint32;
+  i: DWord;
+  x: DWord;
+begin
   x := 0;
-  For i := 0 To count - 1 Do
-  Begin
-    r := (source + R_24)^ And $e0;
-    g := ((source + G_24)^ Shr 3) And $1c;
-    b := ((source + B_24)^ Shr 6) And $3;
+  for i := 0 to count - 1 do
+  begin
+    r := (source + R_24)^ and $e0;
+    g := ((source + G_24)^ shr 3) and $1c;
+    b := ((source + B_24)^ shr 6) and $3;
 
-    dest^ := r Or g Or b;
+    dest^ := r or g or b;
     Inc(x, inc_source);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    Inc(source, x Shr 16);
-    x := x And $FFFF;
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    Inc(source, x shr 16);
+    x := x and $FFFF;
     Inc(dest);
-  End;
-End;
+  end;
+end;

+ 625 - 610
packages/hermes/src/p_32.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -35,470 +47,472 @@
 
 
 { TO 32 BGR }
-Procedure ConvertP_32rgb888_32bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
-  s_ptr : Pchar8;
-  tmp : char8;
-
-Begin
+procedure ConvertP_32rgb888_32bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+  s_ptr: PUint8;
+  tmp: Uint8;
+begin
   s_ptr := @s_pixel;
-  Repeat
-    s_pixel := Pint32(source)^;
+  repeat
+    s_pixel := PUint32(source)^;
 
     tmp := (s_ptr + R_32)^;
     (s_ptr + R_32)^ := (s_ptr + B_32)^;
     (s_ptr + B_32)^ := tmp;
 
-    Pint32(dest)^ := s_pixel;
+    PUint32(dest)^ := s_pixel;
 
     Inc(dest, 4);
     Inc(source, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { 32 RGBA }
-Procedure ConvertP_32rgb888_32rgba888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Begin
-  Repeat
-    Pint32(dest)^ := (Pint32(source)^ Shl 8) Or $ff;
+procedure ConvertP_32rgb888_32rgba888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+begin
+  repeat
+    PUint32(dest)^ := (PUint32(source)^ shl 8) or $ff;
 
     Inc(dest, 4);
     Inc(source, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { 32 BGRA }
-Procedure ConvertP_32rgb888_32bgra888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
-  s_ptr : Pchar8;
-  tmp : char8;
-
-Begin
+procedure ConvertP_32rgb888_32bgra888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+  s_ptr: PUint8;
+  tmp: Uint8;
+begin
   s_ptr := @s_pixel;
-  Repeat
-    s_pixel := Pint32(source)^;
+  repeat
+    s_pixel := PUint32(source)^;
 
     tmp := (s_ptr + R_32)^;
     (s_ptr + R_32)^ := (s_ptr + B_32)^;
     (s_ptr + B_32)^ := tmp;
 
-    Pint32(dest)^ := (s_pixel Shl 8) Or $ff;
+    PUint32(dest)^ := (s_pixel shl 8) or $ff;
 
     Inc(dest, 4);
     Inc(source, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 24 RGB }
-Procedure ConvertP_32rgb888_24rgb888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel, s_pixel2 : int32;
-  s_point : Pchar8;
-  c : DWord;
-
-Begin
-  s_point := @s_pixel;
+procedure ConvertP_32rgb888_24rgb888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel, s_pixel2: Uint32;
+  s_point: PUint8;
+  c: DWord;
+begin
+  s_point := PUint8(@s_pixel) + (R_32 - R_24);
 
   { Align mod 4 (quite important in this case.. ) }
 
-  While (PtrUInt(dest) And $3) <> 0 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  while (PtrUInt(dest) and $3) <> 0 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    (dest + R_24)^ := (s_point + R_32)^;
-    (dest + G_24)^ := (s_point + G_32)^;
-    (dest + B_24)^ := (s_point + B_32)^;
+    (dest + 0)^ := (s_point + 0)^;
+    (dest + 1)^ := (s_point + 1)^;
+    (dest + 2)^ := (s_point + 2)^;
 
     Inc(source, 4);
     Inc(dest, 3);
 
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
+    if count = 0 then
+      exit;
+  end;
 
-  { Main loop. TODO: Big endian check! }
+  { Main loop. }
 
-  c := count Shr 2;
-  While c <> 0 Do
-  Begin
+  c := count shr 2;
+  while c <> 0 do
+  begin
     Dec(c);
-    s_pixel := Pint32(source)^;
-    s_pixel2 := (Pint32(source) + 1)^;
-
-    s_pixel := (s_pixel And $ffffff) Or (s_pixel2 Shl 24);
-    Pint32(dest)^ := s_pixel;
-
-    s_pixel := (Pint32(source) + 2)^;
-    s_pixel2 := ((s_pixel2 Shr 8) And $ffff) Or (s_pixel Shl 16);
-    (Pint32(dest) + 1)^ := s_pixel2;
-
-    s_pixel2 := (Pint32(source) + 3)^;
-    s_pixel := ((s_pixel Shr 16) And $ff) Or (s_pixel2 Shl 8);
-    (Pint32(dest) + 2)^ := s_pixel;
+    s_pixel := PUint32(source)^;
+    s_pixel2 := (PUint32(source) + 1)^;
+
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    s_pixel := (s_pixel and $ffffff) or (s_pixel2 shl 24);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    s_pixel := (s_pixel shl 8) or ((s_pixel2 shr 16) and $FF);
+    {$ENDIF FPC_LITTLE_ENDIAN}
+    PUint32(dest)^ := s_pixel;
+
+    s_pixel := (PUint32(source) + 2)^;
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    s_pixel2 := ((s_pixel2 shr 8) and $ffff) or (s_pixel shl 16);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    s_pixel2 := (s_pixel2 shl 16) or ((s_pixel shr 8) and $FFFF);
+    {$ENDIF FPC_LITTLE_ENDIAN}
+    (PUint32(dest) + 1)^ := s_pixel2;
+
+    s_pixel2 := (PUint32(source) + 3)^;
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    s_pixel := ((s_pixel shr 16) and $ff) or (s_pixel2 shl 8);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    s_pixel := (s_pixel shl 24) or (s_pixel2 and $FFFFFF);
+    {$ENDIF FPC_LITTLE_ENDIAN}
+    (PUint32(dest) + 2)^ := s_pixel;
 
     Inc(source, 16);
     Inc(dest, 12);
-  End;
+  end;
 
   { Convert trailing pixels }
 
-  count := count And $3;
-  While count <> 0 Do
-  Begin
+  count := count and $3;
+  while count <> 0 do
+  begin
     Dec(count);
-    s_pixel := Pint32(source)^;
+    s_pixel := PUint32(source)^;
 
-    (dest + R_24)^ := (s_point + R_32)^;
-    (dest + G_24)^ := (s_point + G_32)^;
-    (dest + B_24)^ := (s_point + B_32)^;
+    (dest + 0)^ := (s_point + 0)^;
+    (dest + 1)^ := (s_point + 1)^;
+    (dest + 2)^ := (s_point + 2)^;
 
     Inc(source, 4);
     Inc(dest, 3);
-  End;
-End;
+  end;
+end;
 
 { TO 24 BGR }
-Procedure ConvertP_32rgb888_24bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
-  s_point : Pchar8;
-
-Begin
-  s_point := @s_pixel;
-  Repeat
-    s_pixel := Pint32(source)^;
+procedure ConvertP_32rgb888_24bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+  s_point: PUint8;
+begin
+  s_point := PUint8(@s_pixel) + (R_32 - R_24);
+  repeat
+    s_pixel := PUint32(source)^;
 
     { Note that R and B are swapped }
-    (dest + B_24)^ := (s_point + R_32)^;
-    (dest + G_24)^ := (s_point + G_32)^;
-    (dest + R_24)^ := (s_point + B_32)^;
+    (dest + 0)^ := (s_point + 2)^;
+    (dest + 1)^ := (s_point + 1)^;
+    (dest + 2)^ := (s_point + 0)^;
 
     Inc(source, 4);
     Inc(dest, 3);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 16 RGB 565 }
-Procedure ConvertP_32rgb888_16rgb565(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  s_pixel : int32;
-  source_32, dest_32 : Pint32;
-
-Begin
-  dest_32 := Pint32(dest);
-  source_32 := Pint32(source);
-
-  { If the current pixel isn't dword aligned, try write one pixel first }
-  If (PtrUInt(dest_32) And $3) <> 0 Then
-  Begin
-    s_pixel := ((source_32^ Shr 8) And $f800) Or
-               ((source_32^ Shr 5) And $7e0) Or
-               ((source_32^ Shr 3) And $1f);
-
-    Pshort16(dest_32)^ := s_pixel;
-
-    dest_32 := Pint32(dest + 2);
+procedure ConvertP_32rgb888_16rgb565(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  s_pixel: Uint32;
+  source_32, dest_32: PUint32;
+begin
+  dest_32 := PUint32(dest);
+  source_32 := PUint32(source);
+
+  { if the current pixel isn't dword aligned, try write one pixel first }
+  if (PtrUInt(dest_32) and $3) <> 0 then
+  begin
+    s_pixel := ((source_32^ shr 8) and $f800) or
+               ((source_32^ shr 5) and $7e0) or
+               ((source_32^ shr 3) and $1f);
+
+    PUint16(dest_32)^ := s_pixel;
+
+    dest_32 := PUint32(dest + 2);
     Inc(source_32);
 
     Dec(count);
-  End;
+  end;
 
   { Write blocks of two pixels }
 
-  For i := 1 To count Shr 1 Do
-  Begin
+  for i := 1 to count shr 1 do
+  begin
     {This horrible construct is actually faster than loading into a variable}
-    dest_32^ := ((source_32^ Shr 8) And $f800) Or
-                ((source_32^ Shr 5) And $7e0) Or
-                ((source_32^ Shr 3) And $1f) Or
-                (((source_32 + 1)^ Shl 8) And $f8000000) Or
-                (((source_32 + 1)^ Shl 11) And $7e00000) Or
-                (((source_32 + 1)^ Shl 13) And $1f0000);
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    dest_32^ := ((source_32^ shr 8) and $f800) or
+                ((source_32^ shr 5) and $7e0) or
+                ((source_32^ shr 3) and $1f) or
+                (((source_32 + 1)^ shl 8) and $f8000000) or
+                (((source_32 + 1)^ shl 11) and $7e00000) or
+                (((source_32 + 1)^ shl 13) and $1f0000);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    dest_32^ := ((source_32^ shl 8) and $f8000000) or
+                ((source_32^ shl 11) and $7e00000) or
+                ((source_32^ shl 13) and $1f0000) or
+                (((source_32 + 1)^ shr 8) and $f800) or
+                (((source_32 + 1)^ shr 5) and $7e0) or
+                (((source_32 + 1)^ shr 3) and $1f);
+    {$ENDIF FPC_LITTLE_ENDIAN}
 
     Inc(dest_32);
     Inc(source_32, 2);
-  End;
+  end;
 
   { Eventually, write a single odd pixel that might be left }
-  If (count And 1) <> 0 Then
-  Begin
+  if (count and 1) <> 0 then
+  begin
     s_pixel := source_32^;
-    Pshort16(dest_32)^ := ((s_pixel Shr 8) And $f800) Or
-                          ((s_pixel Shr 5) And $7e0) Or
-                          ((s_pixel Shr 3) And $1f);
-  End;
-End;
+    PUint16(dest_32)^ := ((s_pixel shr 8) and $f800) or
+                          ((s_pixel shr 5) and $7e0) or
+                          ((s_pixel shr 3) and $1f);
+  end;
+end;
 
 { TO 16 BGR 565 }
-Procedure ConvertP_32rgb888_16bgr565(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  r, g, b : int32;
-  s_pixel, d_pixelblock : int32;
-  d_pixel : short16;
-
-Begin
-  { If the current pixel isn't dword aligned, try write one pixel first }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
-
-    r := (s_pixel Shr 19) And $1f;
-    g := (s_pixel Shr 5) And $7e0;
-    b := (s_pixel Shl 8) And $f800;
-
-    d_pixel := r Or g Or b;
-
-    Pshort16(dest)^ := d_pixel;
+procedure ConvertP_32rgb888_16bgr565(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  r, g, b: Uint32;
+  s_pixel, d_pixelblock: Uint32;
+  d_pixel: Uint16;
+begin
+  { if the current pixel isn't dword aligned, try write one pixel first }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
+
+    r := (s_pixel shr 19) and $1f;
+    g := (s_pixel shr 5) and $7e0;
+    b := (s_pixel shl 8) and $f800;
+
+    d_pixel := r or g or b;
+
+    PUint16(dest)^ := d_pixel;
 
     Inc(source, 4);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
   { Write blocks of two pixels }
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixelblock := ((s_pixel Shr 19) And $1f) Or
-                    ((s_pixel Shr 5) And $7e0) Or
-                    ((s_pixel Shl 8) And $f800);
+    d_pixelblock := (((s_pixel shr 19) and $1f) or
+                     ((s_pixel shr 5) and $7e0) or
+                     ((s_pixel shl 8) and $f800)) shl DWORD_SMALLINT0_SHL;
 
-    s_pixel := (Pint32(source) + 1)^;
+    s_pixel := (PUint32(source) + 1)^;
 
-    d_pixelblock := d_pixelblock Or
-                  ((((s_pixel Shr 19) And $1f) Or
-                    ((s_pixel Shr 5) And $7e0) Or
-                    ((s_pixel Shl 8) And $f800)) Shl 16);
+    d_pixelblock := d_pixelblock or
+                  ((((s_pixel shr 19) and $1f) or
+                    ((s_pixel shr 5) and $7e0) or
+                    ((s_pixel shl 8) and $f800)) shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_pixelblock;
+    PUint32(dest)^ := d_pixelblock;
     Inc(source, 8);
     Inc(dest, 4);
-  End;
+  end;
 
   { Eventually, write a single odd pixel that might be left }
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-    r := (s_pixel Shr 19) And $1f;
-    g := (s_pixel Shr 5) And $7e0;
-    b := (s_pixel Shl 8) And $f800;
+    r := (s_pixel shr 19) and $1f;
+    g := (s_pixel shr 5) and $7e0;
+    b := (s_pixel shl 8) and $f800;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
-  End;
-End;
+    PUint16(dest)^ := d_pixel;
+  end;
+end;
 
 { TO 16 RGB 555 }
-Procedure ConvertP_32rgb888_16rgb555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  r, g, b : int32;
-  s_pixel, d_pixelblock : int32;
-  d_pixel : short16;
-  i : DWord;
+procedure ConvertP_32rgb888_16rgb555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  r, g, b: Uint32;
+  s_pixel, d_pixelblock: Uint32;
+  d_pixel: Uint16;
+  i: DWord;
+begin
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-Begin
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+    r := (s_pixel shr 9) and $7c00;
+    g := (s_pixel shr 6) and $3e0;
+    b := (s_pixel shr 3) and $1f;
 
-    r := (s_pixel Shr 9) And $7c00;
-    g := (s_pixel Shr 6) And $3e0;
-    b := (s_pixel Shr 3) And $1f;
+    d_pixel := r or g or b;
 
-    d_pixel := r Or g Or b;
-
-    Pshort16(dest)^ := d_pixel;
+    PUint16(dest)^ := d_pixel;
 
     Inc(source, 4);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixelblock := ((s_pixel Shr 9) And $7c00) Or
-                    ((s_pixel Shr 6) And $3e0) Or
-                    ((s_pixel Shr 3) And $1f);
+    d_pixelblock := (((s_pixel shr 9) and $7c00) or
+                     ((s_pixel shr 6) and $3e0) or
+                     ((s_pixel shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
 
-    s_pixel := (Pint32(source) + 1)^;
+    s_pixel := (PUint32(source) + 1)^;
 
-    d_pixelblock := d_pixelblock Or
-                  ((((s_pixel Shr 9) And $7c00) Or
-                    ((s_pixel Shr 6) And $3e0) Or
-                    ((s_pixel Shr 3) And $1f)) Shl 16);
+    d_pixelblock := d_pixelblock or
+                  ((((s_pixel shr 9) and $7c00) or
+                    ((s_pixel shr 6) and $3e0) or
+                    ((s_pixel shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_pixelblock;
+    PUint32(dest)^ := d_pixelblock;
     Inc(source, 8);
     Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-    r := (s_pixel Shr 9) And $7c00;
-    g := (s_pixel Shr 6) And $3e0;
-    b := (s_pixel Shr 3) And $1f;
+    r := (s_pixel shr 9) and $7c00;
+    g := (s_pixel shr 6) and $3e0;
+    b := (s_pixel shr 3) and $1f;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
-  End;
-End;
+    PUint16(dest)^ := d_pixel;
+  end;
+end;
 
 { TO 16 BGR 555 }
-Procedure ConvertP_32rgb888_16bgr555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  r, g, b : int32;
-  s_pixel, d_pixelblock : int32;
-  d_pixel : short16;
-  i : DWord;
+procedure ConvertP_32rgb888_16bgr555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  r, g, b: Uint32;
+  s_pixel, d_pixelblock: Uint32;
+  d_pixel: Uint16;
+  i: DWord;
+begin
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-Begin
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+    r := (s_pixel shr 19) and $1f;
+    g := (s_pixel shr 6) and $3e0;
+    b := (s_pixel shl 7) and $7c00;
 
-    r := (s_pixel Shr 19) And $1f;
-    g := (s_pixel Shr 6) And $3e0;
-    b := (s_pixel Shl 7) And $7c00;
+    d_pixel := r or g or b;
 
-    d_pixel := r Or g Or b;
-
-    Pshort16(dest)^ := d_pixel;
+    PUint16(dest)^ := d_pixel;
 
     Inc(source, 4);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixelblock := ((s_pixel Shr 19) And $1f) Or
-                    ((s_pixel Shr 6) And $3e0) Or
-                    ((s_pixel Shl 7) And $7c00);
+    d_pixelblock := (((s_pixel shr 19) and $1f) or
+                     ((s_pixel shr 6) and $3e0) or
+                     ((s_pixel shl 7) and $7c00)) shl DWORD_SMALLINT0_SHL;
 
-    s_pixel := (Pint32(source) + 1)^;
+    s_pixel := (PUint32(source) + 1)^;
 
-    d_pixelblock := d_pixelblock Or
-                  ((((s_pixel Shr 19) And $1f) Or
-                    ((s_pixel Shr 6) And $3e0) Or
-                    ((s_pixel Shl 7) And $7c00)) Shl 16);
+    d_pixelblock := d_pixelblock or
+                  ((((s_pixel shr 19) and $1f) or
+                    ((s_pixel shr 6) and $3e0) or
+                    ((s_pixel shl 7) and $7c00)) shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_pixelblock;
+    PUint32(dest)^ := d_pixelblock;
     Inc(source, 8);
     Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-    r := (s_pixel Shr 19) And $1f;
-    g := (s_pixel Shr 6) And $3e0;
-    b := (s_pixel Shl 7) And $7c00;
+    r := (s_pixel shr 19) and $1f;
+    g := (s_pixel shr 6) and $3e0;
+    b := (s_pixel shl 7) and $7c00;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
-  End;
-End;
+    PUint16(dest)^ := d_pixel;
+  end;
+end;
 
 { TO 8 RGB 332 }
-Procedure ConvertP_32rgb888_8rgb332(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  s_pixel, d_block : int32;
-  d_pixel : char8;
-
-Begin
+procedure ConvertP_32rgb888_8rgb332(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  s_pixel, d_block: Uint32;
+  d_pixel: Uint8;
+begin
   { Process single pixels until we are dword aligned }
-  While (PtrUInt(dest) And $3) <> 0 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  while (PtrUInt(dest) and $3) <> 0 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixel := ((s_pixel Shr 16) And $e0) Or
-               ((s_pixel Shr 11) And $1c) Or
-               ((s_pixel Shr 6) And $3);
+    d_pixel := ((s_pixel shr 16) and $e0) or
+               ((s_pixel shr 11) and $1c) or
+               ((s_pixel shr 6) and $3);
 
     dest^ := d_pixel;
 
     Dec(count);
-    If count = 0 Then
-      Exit;
+    if count = 0 then
+      exit;
     Inc(dest);
     Inc(source, 4);
-  End;
+  end;
 
   { Now process blocks of four pixels }
-  For i := 1 To count Shr 2 Do
-  Begin
-    s_pixel := Pint32(source)^;
-    d_block := ((s_pixel Shr 16) And $e0) Or
-               ((s_pixel Shr 11) And $1c) Or
-               ((s_pixel Shr 6) And $3);
-
-    s_pixel := (Pint32(source) + 1)^;
-    d_block := ((((s_pixel Shr 16) And $e0) Or
-                 ((s_pixel Shr 11) And $1c) Or
-                 ((s_pixel Shr 6) And $3)) Shl 8) Or d_block;
-
-    s_pixel := (Pint32(source) + 2)^;
-    d_block := ((((s_pixel Shr 16) And $e0) Or
-                 ((s_pixel Shr 11) And $1c) Or
-                 ((s_pixel Shr 6) And $3)) Shl 16) Or d_block;
-
-    s_pixel := (Pint32(source) + 3)^;
-    d_block := ((((s_pixel Shr 16) And $e0) Or
-                 ((s_pixel Shr 11) And $1c) Or
-                 ((s_pixel Shr 6) And $3)) Shl 24) Or d_block;
-
-    Pint32(dest)^ := d_block;
+  for i := 1 to count shr 2 do
+  begin
+    s_pixel := PUint32(source)^;
+    d_block := (((s_pixel shr 16) and $e0) or
+                ((s_pixel shr 11) and $1c) or
+                ((s_pixel shr 6) and $3)) shl DWORD_BYTE0_SHL;
+
+    s_pixel := (PUint32(source) + 1)^;
+    d_block := ((((s_pixel shr 16) and $e0) or
+                 ((s_pixel shr 11) and $1c) or
+                 ((s_pixel shr 6) and $3)) shl DWORD_BYTE1_SHL) or d_block;
+
+    s_pixel := (PUint32(source) + 2)^;
+    d_block := ((((s_pixel shr 16) and $e0) or
+                 ((s_pixel shr 11) and $1c) or
+                 ((s_pixel shr 6) and $3)) shl DWORD_BYTE2_SHL) or d_block;
+
+    s_pixel := (PUint32(source) + 3)^;
+    d_block := ((((s_pixel shr 16) and $e0) or
+                 ((s_pixel shr 11) and $1c) or
+                 ((s_pixel shr 6) and $3)) shl DWORD_BYTE3_SHL) or d_block;
+
+    PUint32(dest)^ := d_block;
     Inc(source, 16);
     Inc(dest, 4);
-  End;
+  end;
 
   { Write all possibly remaining pixel }
-  count := count And $3;
-  While count <> 0 Do
-  Begin
+  count := count and $3;
+  while count <> 0 do
+  begin
     Dec(count);
-    s_pixel := Pint32(source)^;
+    s_pixel := PUint32(source)^;
 
-    dest^ := ((s_pixel Shr 16) And $e0) Or
-             ((s_pixel Shr 11) And $1c) Or
-             ((s_pixel Shr 6) And $3);
+    dest^ := ((s_pixel shr 16) and $e0) or
+             ((s_pixel shr 11) and $1c) or
+             ((s_pixel shr 6) and $3);
 
     Inc(dest);
     Inc(source, 4);
-  End;
-End;
+  end;
+end;
 
 { -------------------------------------------------------------------------
 
@@ -506,438 +520,439 @@ End;
 
   ------------------------------------------------------------------------- }
 
-Procedure ConvertP_32rgb888_32bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  s_pixel : int32;
-  s_ptr : Pchar8;
-  tmp : char8;
-
-Begin
+procedure ConvertP_32rgb888_32bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  s_pixel: Uint32;
+  s_ptr: PUint8;
+  tmp: Uint8;
+begin
   x := 0;
   s_ptr := @s_pixel;
-  Repeat
-    s_pixel := (Pint32(source)+(x Shr 16))^;
+  repeat
+    s_pixel := (PUint32(source)+(x shr 16))^;
 
     tmp := (s_ptr + R_32)^;
     (s_ptr + R_32)^ := (s_ptr + B_32)^;
     (s_ptr + B_32)^ := tmp;
 
-    Pint32(dest)^ := s_pixel;
+    PUint32(dest)^ := s_pixel;
 
     Inc(dest, 4);
     Inc(x, inc_source);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_32rgb888_32rgba888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+  until count = 0;
+end;
 
-Var
-  x : DWord;
-
-Begin
+procedure ConvertP_32rgb888_32rgba888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+begin
   x := 0;
-  Repeat
-    Pint32(dest)^ := ((Pint32(source) + (x Shr 16))^ Shl 8) Or $ff;
+  repeat
+    PUint32(dest)^ := ((PUint32(source) + (x shr 16))^ shl 8) or $ff;
 
     Inc(dest, 4);
     Inc(x, inc_source);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_32rgb888_32bgra888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  s_pixel : int32;
-  s_ptr : Pchar8;
-  tmp : char8;
-
-Begin
+  until count = 0;
+end;
+
+procedure ConvertP_32rgb888_32bgra888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  s_pixel: Uint32;
+  s_ptr: PUint8;
+  tmp: Uint8;
+begin
   x := 0;
   s_ptr := @s_pixel;
-  Repeat
-    s_pixel := (Pint32(source)+(x Shr 16))^;
+  repeat
+    s_pixel := (PUint32(source)+(x shr 16))^;
 
     tmp := (s_ptr + R_32)^;
     (s_ptr + R_32)^ := (s_ptr + B_32)^;
     (s_ptr + B_32)^ := tmp;
 
-    Pint32(dest)^ := (s_pixel Shl 8) Or $ff;
+    PUint32(dest)^ := (s_pixel shl 8) or $ff;
 
     Inc(dest, 4);
     Inc(x, inc_source);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure ConvertP_32rgb888_24rgb888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  s1, s2 : DWord;
-
-Begin
+  until count = 0;
+end;
+
+procedure ConvertP_32rgb888_24rgb888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+const
+  endian_fixup = R_32 - R_24;
+var
+  x, c: DWord;
+  s1, s2: DWord;
+begin
   x := 0;
-  While (PtrUInt(dest) And 3) <> 0 Do
-  Begin
-    Pshort16(dest)^ := Pshort16(source)^;
-    (dest + 2)^ := (source + 2)^;
-    
+  while (PtrUInt(dest) and 3) <> 0 do
+  begin
+    (dest + 0)^ := (source + 0 + endian_fixup)^;
+    (dest + 1)^ := (source + 1 + endian_fixup)^;
+    (dest + 2)^ := (source + 2 + endian_fixup)^;
+
     Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
-    
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
+
     Inc(dest, 3);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
-  
-  c := count Shr 2;
-  While c > 0 Do
-  Begin
-    s1 := (Pint32(source) + ((x + inc_source) Shr 16))^ And $FFFFFF;
-    Pint32(dest)^ := ((Pint32(source) + (x Shr 16))^ And $FFFFFF) Or (s1 Shl 24);
-    s2 := (Pint32(source) + ((x + 2*inc_source) Shr 16))^ And $FFFFFF;
-    Pint32(dest + 4)^ := (s1 Shr 8) Or (s2 Shl 16);
-    Pint32(dest + 8)^ := (s2 Shr 16) Or ((Pint32(source) + ((x + 3*inc_source) Shr 16))^ Shl 8);
+    if count = 0 then
+      exit;
+  end;
+
+  c := count shr 2;
+  while c > 0 do
+  begin
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    s1 := (PUint32(source) + ((x + inc_source) shr 16))^ and $FFFFFF;
+    PUint32(dest)^ := ((PUint32(source) + (x shr 16))^ and $FFFFFF) or (s1 shl 24);
+    s2 := (PUint32(source) + ((x + 2*inc_source) shr 16))^ and $FFFFFF;
+    PUint32(dest + 4)^ := (s1 shr 8) or (s2 shl 16);
+    PUint32(dest + 8)^ := (s2 shr 16) or ((PUint32(source) + ((x + 3*inc_source) shr 16))^ shl 8);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    s1 := (PUint32(source) + ((x + inc_source) shr 16))^ and $FFFFFF;
+    PUint32(dest)^ := ((PUint32(source) + (x shr 16))^ shl 8) or (s1 shr 16);
+    s2 := (PUint32(source) + ((x + 2*inc_source) shr 16))^ and $FFFFFF;
+    PUint32(dest + 4)^ := (s1 shl 16) or (s2 shr 8);
+    PUint32(dest + 8)^ := (s2 shl 24) or ((PUint32(source) + ((x + 3*inc_source) shr 16))^ and $FFFFFF);
+    {$ENDIF FPC_LITTLE_ENDIAN}
+
     Inc(x, 4*inc_source);
-    
+
     Inc(dest, 12);
     Dec(c);
-  End;
-  Inc(source, (x Shr 16) * 4);
-  x := x And $FFFF;
-  
-  count := count And $3;
-  While count > 0 Do
-  Begin
-    Pshort16(dest)^ := Pshort16(source)^;
-    (dest + 2)^ := (source + 2)^;
-    
-    Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
-    
-    Inc(dest, 3);
-    Dec(count);
-  End;
-End;
+  end;
+  Inc(source, (x shr 16) * 4);
+  x := x and $FFFF;
 
-Procedure ConvertP_32rgb888_24bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+  count := count and $3;
+  while count > 0 do
+  begin
+    (dest + 0)^ := (source + 0 + endian_fixup)^;
+    (dest + 1)^ := (source + 1 + endian_fixup)^;
+    (dest + 2)^ := (source + 2 + endian_fixup)^;
 
-Var
-  x, c : DWord;
-  s1, s2, s3, s4 : DWord;
+    Inc(x, inc_source);
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
 
-Begin
+    Inc(dest, 3);
+    Dec(count);
+  end;
+end;
+
+procedure ConvertP_32rgb888_24bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+const
+  endian_fixup = R_32 - R_24;
+var
+  x, c: DWord;
+  s1, s2, s3, s4: DWord;
+begin
   x := 0;
-  While (PtrUInt(dest) And 3) <> 0 Do
-  Begin
-    (dest)^ := (source + 2)^;
-    (dest + 1)^ := (source + 1)^;
-    (dest + 2)^ := (source)^;
-    
+  while (PtrUInt(dest) and 3) <> 0 do
+  begin
+    (dest + 0)^ := (source + 2 + endian_fixup)^;
+    (dest + 1)^ := (source + 1 + endian_fixup)^;
+    (dest + 2)^ := (source + 0 + endian_fixup)^;
+
     Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
-    
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
+
     Inc(dest, 3);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
-  
-  c := count Shr 2;
-  While c > 0 Do
-  Begin
-    s1 := (Pint32(source) + (x Shr 16))^;
-    s2 := (Pint32(source) + ((x + inc_source) Shr 16))^;
-    s3 := (Pint32(source) + ((x + 2*inc_source) Shr 16))^;
-    s4 := (Pint32(source) + ((x + 3*inc_source) Shr 16))^;
-    
-    Pint32(dest + 0)^ := ((s2 And $FF0000) Shl 8) Or ((s1 And $FF) Shl 16) Or (s1 And $FF00) Or ((s1 Shr 16) And $FF);
-    Pint32(dest + 4)^ := ((s3 And $FF00) Shl 16) Or (s3 And $FF0000) Or ((s2 And $FF) Shl 8) Or ((s2 Shr 8) And $FF);
-    Pint32(dest + 8)^ := ((s4 And $FF) Shl 24) Or ((s4 And $FF00) Shl 8) Or ((s4 Shr 8) And $FF00) Or (s3 And $FF);
-    
+    if count = 0 then
+      exit;
+  end;
+
+  c := count shr 2;
+  while c > 0 do
+  begin
+    s1 := (PUint32(source) + (x shr 16))^;
+    s2 := (PUint32(source) + ((x + inc_source) shr 16))^;
+    s3 := (PUint32(source) + ((x + 2*inc_source) shr 16))^;
+    s4 := (PUint32(source) + ((x + 3*inc_source) shr 16))^;
+
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((s2 and $FF0000) shl 8) or ((s1 and $FF) shl 16) or (s1 and $FF00) or ((s1 shr 16) and $FF);
+    PUint32(dest + 4)^ := ((s3 and $FF00) shl 16) or (s3 and $FF0000) or ((s2 and $FF) shl 8) or ((s2 shr 8) and $FF);
+    PUint32(dest + 8)^ := ((s4 and $FF) shl 24) or ((s4 and $FF00) shl 8) or ((s4 shr 8) and $FF00) or (s3 and $FF);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((s1 and $FF) shl 24) or ((s1 and $FF00) shl 8) or ((s1 and $FF0000) shr 8) or (s2 and $FF);
+    PUint32(dest + 4)^ := ((s2 and $FF00) shl 16) or (s2 and $FF0000) or ((s3 and $FF) shl 8) or ((s3 and $FF00) shr 8);
+    PUint32(dest + 8)^ := ((s3 and $FF0000) shl 8) or ((s4 and $FF) shl 16) or (s4 and $FF00) or ((s4 and $FF0000) shr 16);
+    {$ENDIF FPC_LITTLE_ENDIAN}
+
     Inc(x, 4*inc_source);
-    
+
     Inc(dest, 12);
     Dec(c);
-  End;
-  Inc(source, (x Shr 16) * 4);
-  x := x And $FFFF;
-  
-  count := count And $3;
-  While count > 0 Do
-  Begin
-    (dest)^ := (source + 2)^;
-    (dest + 1)^ := (source + 1)^;
-    (dest + 2)^ := (source)^;
-    
-    Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
-    
-    Inc(dest, 3);
-    Dec(count);
-  End;
-End;
+  end;
+  Inc(source, (x shr 16) * 4);
+  x := x and $FFFF;
 
-Procedure ConvertP_32rgb888_16rgb565_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+  count := count and $3;
+  while count > 0 do
+  begin
+    (dest + 0)^ := (source + 2 + endian_fixup)^;
+    (dest + 1)^ := (source + 1 + endian_fixup)^;
+    (dest + 2)^ := (source + 0 + endian_fixup)^;
 
-Var
-  x, c : DWord;
-  p : int32;
+    Inc(x, inc_source);
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
 
-Begin
+    Inc(dest, 3);
+    Dec(count);
+  end;
+end;
+
+procedure ConvertP_32rgb888_16rgb565_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Align mod 4 }
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 8) And $f800) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 8) and $f800) or
+                       (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+                       (((PUint32(source) + (x shr 16))^ shr 3) and $1f);
     Inc(x, inc_source);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
   { Try to write 2 pixel blocks }
-  c := count Shr 1;
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 8) And $f800) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
+    p := ((((PUint32(source) + (x shr 16))^ shr 8) and $f800) or
+          (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+          (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 8) And $f800) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 8) and $f800) or
+         (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+         (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 8) And $f800) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
-End;
-
-Procedure ConvertP_32rgb888_16bgr565_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 8) and $f800) or
+                       (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+                       (((PUint32(source) + (x shr 16))^ shr 3) and $1f);
+end;
+
+procedure ConvertP_32rgb888_16bgr565_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Align mod 4 }
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shl 8) And $f800);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+                       (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+                       (((PUint32(source) + (x shr 16))^ shl 8) and $f800);
     Inc(x, inc_source);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
   { Try to write 2 pixel blocks }
-  c := count Shr 1;
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shl 8) And $f800);
+    p := ((((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+          (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+          (((PUint32(source) + (x shr 16))^ shl 8) and $f800)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shl 8) And $f800)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+         (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+         (((PUint32(source) + (x shr 16))^ shl 8) and $f800)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 5) And $7e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shl 8) And $f800);
-End;
-
-Procedure ConvertP_32rgb888_16rgb555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+                       (((PUint32(source) + (x shr 16))^ shr 5) and $7e0) or
+                       (((PUint32(source) + (x shr 16))^ shl 8) and $f800);
+end;
+
+procedure ConvertP_32rgb888_16rgb555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Align mod 4 }
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 9) And $7c00) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 9) and $7c00) or
+                       (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+                       (((PUint32(source) + (x shr 16))^ shr 3) and $1f);
     Inc(x, inc_source);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
   { Try to write 2 pixel blocks }
-  c := count Shr 1;
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 9) And $7c00) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
+    p := ((((PUint32(source) + (x shr 16))^ shr 9) and $7c00) or
+          (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+          (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 9) And $7c00) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 9) and $7c00) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+         (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 9) And $7c00) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
-End;
-
-Procedure ConvertP_32rgb888_16bgr555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 9) and $7c00) or
+                       (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+                       (((PUint32(source) + (x shr 16))^ shr 3) and $1f);
+end;
+
+procedure ConvertP_32rgb888_16bgr555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Align mod 4 }
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shl 7) And $7c00);
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+                       (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+                       (((PUint32(source) + (x shr 16))^ shl 7) and $7c00);
     Inc(x, inc_source);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
   { Try to write 2 pixel blocks }
-  c := count Shr 1;
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shl 7) And $7c00);
+    p := ((((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+          (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+          (((PUint32(source) + (x shr 16))^ shl 7) and $7c00)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shl 7) And $7c00)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+         (((PUint32(source) + (x shr 16))^ shl 7) and $7c00)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 19) And $1f) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 6) And $3e0) Or
-                       (((Pint32(source) + (x Shr 16))^ Shl 7) And $7c00);
-End;
-
-Procedure ConvertP_32rgb888_8rgb332_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 19) and $1f) or
+                       (((PUint32(source) + (x shr 16))^ shr 6) and $3e0) or
+                       (((PUint32(source) + (x shr 16))^ shl 7) and $7c00);
+end;
+
+procedure ConvertP_32rgb888_8rgb332_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Write single pixels until the destination address is aligned mod 4 }
-  While (PtrUInt(dest) And $3) <> 0 Do
-  Begin
-    dest^ := (((Pint32(source) + (x Shr 16))^ Shr 16) And $e0) Or
-             (((Pint32(source) + (x Shr 16))^ Shr 11) And $1c) Or
-             (((Pint32(source) + (x Shr 16))^ Shr 6) And $3);
+  while (PtrUInt(dest) and $3) <> 0 do
+  begin
+    dest^ := (((PUint32(source) + (x shr 16))^ shr 16) and $e0) or
+             (((PUint32(source) + (x shr 16))^ shr 11) and $1c) or
+             (((PUint32(source) + (x shr 16))^ shr 6) and $3);
     Inc(x, inc_source);
     Inc(dest);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
+    if count = 0 then
+      exit;
+  end;
 
   { Write blocks of four pixels now }
-  c := count Shr 2;
-  While c <> 0 Do
-  Begin
+  c := count shr 2;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 16) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 11) And $1c) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3);
+    p := ((((PUint32(source) + (x shr 16))^ shr 16) and $e0) or
+          (((PUint32(source) + (x shr 16))^ shr 11) and $1c) or
+          (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 16) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 11) And $1c) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3)) Shl 8);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 16) and $e0) or
+         (((PUint32(source) + (x shr 16))^ shr 11) and $1c) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE1_SHL);
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 16) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 11) And $1c) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 16) and $e0) or
+         (((PUint32(source) + (x shr 16))^ shr 11) and $1c) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE2_SHL);
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 16) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 11) And $1c) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 6) And $3)) Shl 24);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 16) and $e0) or
+         (((PUint32(source) + (x shr 16))^ shr 11) and $1c) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE3_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
     Inc(dest, 4);
-  End;
+  end;
 
   { Write up to three trailing pixels }
-  c := count And $3;
-  While c <> 0 Do
-  Begin
+  c := count and $3;
+  while c <> 0 do
+  begin
     Dec(c);
-    dest^ := (((Pint32(source) + (x Shr 16))^ Shr 16) And $e0) Or
-             (((Pint32(source) + (x Shr 16))^ Shr 11) And $1c) Or
-             (((Pint32(source) + (x Shr 16))^ Shr 6) And $3);
+    dest^ := (((PUint32(source) + (x shr 16))^ shr 16) and $e0) or
+             (((PUint32(source) + (x shr 16))^ shr 11) and $1c) or
+             (((PUint32(source) + (x shr 16))^ shr 6) and $3);
     Inc(x, inc_source);
     Inc(dest);
-  End;
-End;
+  end;
+end;

+ 92 - 89
packages/hermes/src/p_clr.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -27,145 +39,136 @@
    licensing conditions
 }
 
-Procedure ClearP_32(iface : PHermesClearInterface); CDecl;
-
-Var
-  count : DWord;
-  value : int32;
-  dest : Pchar8;
-
-Begin
+procedure ClearP_32(iface: PHermesClearInterface); cdecl;
+var
+  count: DWord;
+  value: Uint32;
+  dest: PUint8;
+begin
   value := iface^.value;
   dest := iface^.dest;
-  Repeat
+  repeat
     count := iface^.width;
-    Repeat
-      Pint32(dest)^ := value;
+    repeat
+      PUint32(dest)^ := value;
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
     Inc(dest, iface^.add);
     Dec(iface^.height);
-  Until iface^.height = 0;
-End;
-
-Procedure ClearP_24(iface : PHermesClearInterface); CDecl;
-
-Var
-  p_value : Pchar8;
-  count : DWord;
-  dest : Pchar8;
-
-Begin
-  p_value := @iface^.value;
+  until iface^.height = 0;
+end;
+
+procedure ClearP_24(iface: PHermesClearInterface); cdecl;
+var
+  p_value: PUint8;
+  count: DWord;
+  dest: PUint8;
+begin
+  p_value := PUint8(@iface^.value) + (R_32 - R_24);
   dest := iface^.dest;
-  Repeat
+  repeat
     count := iface^.width;
-    Repeat
-      (dest + R_24)^ := (p_value + B_32)^;
-      (dest + G_24)^ := (p_value + G_32)^;
-      (dest + B_24)^ := (p_value + B_32)^;
+    repeat
+      (dest + 0)^ := (p_value + 0)^;
+      (dest + 1)^ := (p_value + 1)^;
+      (dest + 2)^ := (p_value + 2)^;
 
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.add);
     Dec(iface^.height);
-  Until iface^.height = 0;
-End;
-
-Procedure ClearP_16(iface : PHermesClearInterface); CDecl;
-
-Var
-  value32 : DWord;
-  countshifted, count : DWord;
-  dest : Pchar8;
-
-Begin
-  value32 := (iface^.value Shl 16) Or (iface^.value And $ffff);
+  until iface^.height = 0;
+end;
+
+procedure ClearP_16(iface: PHermesClearInterface); cdecl;
+var
+  value32: DWord;
+  countshifted, count: DWord;
+  dest: PUint8;
+begin
+  value32 := (iface^.value shl 16) or (iface^.value and $ffff);
   dest := iface^.dest;
-  Repeat
+  repeat
     count := iface^.width;
 
     { Align destination }
-    If (PtrUInt(dest) And $3) <> 0 Then
-    Begin
-      Pshort16(dest)^ := iface^.value;
+    if (PtrUInt(dest) and $3) <> 0 then
+    begin
+      PUint16(dest)^ := iface^.value;
       Inc(dest, 2);
       Dec(count);
-    End;
+    end;
 
-    countshifted := count Shr 1;
+    countshifted := count shr 1;
 
-    While countshifted <> 0 Do
-    Begin
+    while countshifted <> 0 do
+    begin
       Dec(countshifted);
-      Pint32(dest)^ := value32;
+      PUint32(dest)^ := value32;
       Inc(dest, 4);
-    End;
+    end;
 
-    If (count And 1) <> 0 Then
-    Begin
-      Pshort16(dest)^ := iface^.value;
+    if (count and 1) <> 0 then
+    begin
+      PUint16(dest)^ := iface^.value;
       Inc(dest, 2);
-    End;
+    end;
 
     Inc(dest, iface^.add);
     Dec(iface^.height);
-  Until iface^.height = 0;
-End;
+  until iface^.height = 0;
+end;
 
 {$GOTO ON}
 
-Procedure ClearP_8(iface : PHermesClearInterface); CDecl;
-
-Label
+procedure ClearP_8(iface: PHermesClearInterface); cdecl;
+label
   yloop;
-
-Var
-  count, shiftcount : DWord;
-  value32 : int32;
-  value : char8;
-  dest : Pchar8;
-
-Begin
+var
+  count, shiftcount: DWord;
+  value32: Uint32;
+  value: Uint8;
+  dest: PUint8;
+begin
   dest := iface^.dest;
 
-  value := iface^.value And $ff;
-  value32 := (value Shl 24) Or (value Shl 16) Or (value Shl 8) Or value;
+  value := iface^.value and $ff;
+  value32 := (value shl 24) or (value shl 16) or (value shl 8) or value;
 
-  Repeat
+  repeat
     count := iface^.width;
 
-    While (PtrUInt(dest) And $3) <> 0 Do    { Align to dword boundary }
-    Begin
+    while (PtrUInt(dest) and $3) <> 0 do    { Align to dword boundary }
+    begin
       dest^ := value;
       Inc(dest);
       Dec(count);
-      If count = 0 Then
-        Goto yloop;                { GOTO's are nice ;) }
-    End;
+      if count = 0 then
+        goto yloop;                { GOTO's are nice ;) }
+    end;
 
-    shiftcount := count Shr 2;
+    shiftcount := count shr 2;
 
-    While shiftcount <> 0 Do
-    Begin
+    while shiftcount <> 0 do
+    begin
       Dec(shiftcount);
-      Pint32(dest)^ := value32;
+      PUint32(dest)^ := value32;
       Inc(dest, 4);
-    End;
+    end;
 
-    count := count And $3;
-    While count <> 0 Do
-    Begin
+    count := count and $3;
+    while count <> 0 do
+    begin
       Dec(count);
       dest^ := value;
       Inc(dest);
-    End;
+    end;
 
 yloop:
     Inc(dest, iface^.add);
     Dec(iface^.height);
-  Until iface^.height = 0;
-End;
+  until iface^.height = 0;
+end;

+ 30 - 21
packages/hermes/src/p_cnv.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -27,32 +39,29 @@
    licensing conditions
 }
 
-Procedure ConvertP(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP(iface: PHermesConverterInterface); cdecl;
+begin
   { Simply loop through all scanlines }
-  Repeat
+  repeat
     iface^.func(iface^.s_pixels, iface^.d_pixels, iface^.d_width, 1);
 
     Inc(iface^.s_pixels, iface^.s_pitch);
     Inc(iface^.d_pixels, iface^.d_pitch);
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertPStretch(iface : PHermesConverterInterface); CDecl;
-
-Var
-  dx, dy : DWord;
-  y : DWord;
+  until iface^.d_height = 0;
+end;
 
-Begin
+procedure ConvertPStretch(iface: PHermesConverterInterface); cdecl;
+var
+  dx, dy: DWord;
+  y: DWord;
+begin
   y := 0;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
 
   { We have the increment of y and x on the source surface now let's start }
-  Repeat
+  repeat
     iface^.func(iface^.s_pixels, iface^.d_pixels, iface^.d_width, dx);
 
     Inc(iface^.d_pixels, iface^.d_pitch);
@@ -60,8 +69,8 @@ Begin
     Inc(y, dy);
 
     { Check how many lines we need to step forward }
-    Inc(iface^.s_pixels, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(iface^.s_pixels, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
+  until iface^.d_height = 0;
+end;

+ 93 - 93
packages/hermes/src/p_cpy.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -27,141 +39,129 @@
    licensing conditions
 }
 
-Procedure CopyP_4byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+procedure CopyP_4byte(source, dest: PUint8; count, inc_source: DWord); cdecl;
+begin
+  Move(source^, dest^, count shl 2);
+end;
 
-Begin
-  Move(source^, dest^, count Shl 2);
-End;
-
-Procedure CopyP_3byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Begin
+procedure CopyP_3byte(source, dest: PUint8; count, inc_source: DWord); cdecl;
+begin
   Move(source^, dest^, count * 3);
-End;
-
-Procedure CopyP_2byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Begin
-  Move(source^, dest^, count Shl 1);
-End;
+end;
 
-Procedure CopyP_1byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+procedure CopyP_2byte(source, dest: PUint8; count, inc_source: DWord); cdecl;
+begin
+  Move(source^, dest^, count shl 1);
+end;
 
-Begin
+procedure CopyP_1byte(source, dest: PUint8; count, inc_source: DWord); cdecl;
+begin
   Move(source^, dest^, count);
-End;
+end;
 
-Procedure CopyP_4byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-
-Begin
+procedure CopyP_4byte_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+begin
   x := 0;
-  Repeat
-    Pint32(dest)^ := (Pint32(source)+(x Shr 16))^;
+  repeat
+    PUint32(dest)^ := (PUint32(source)+(x shr 16))^;
 
     Inc(x, inc_source);
     Inc(dest, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TODO: Optimise }
-Procedure CopyP_3byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-
-Begin
+procedure CopyP_3byte_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+begin
   x := 0;
-  Repeat
-    dest[R_24] := source[R_24];
-    dest[G_24] := source[G_24];
-    dest[B_24] := source[B_24];
+  repeat
+    dest[0] := source[0];
+    dest[1] := source[1];
+    dest[2] := source[2];
 
     Inc(x, inc_source);
-    Inc(source, 3*(x Shr 16));
-    x := x And $FFFF;
+    Inc(source, 3*(x shr 16));
+    x := x and $FFFF;
     Inc(dest, 3);
     Dec(count);
-  Until count = 0;
-End;
-
-Procedure CopyP_2byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  until count = 0;
+end;
+
+procedure CopyP_2byte_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Alignment mod 4 }
-  If (PtrUInt(dest) And 3) <> 0 Then
-  Begin
-    Pshort16(dest)^ := (Pshort16(source) + (x Shr 16))^;
+  if (PtrUInt(dest) and 3) <> 0 then
+  begin
+    PUint16(dest)^ := (PUint16(source) + (x shr 16))^;
     Inc(x, inc_source);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
-  c := count Shr 1;
+  c := count shr 1;
 
-  While c <> 0 Do
-  Begin
+  while c <> 0 do
+  begin
     Dec(c);
     { TODO: make fast :) }
-    p := (Pshort16(source) + (x Shr 16))^; Inc(x, inc_source);
-    p := p Or ((Pshort16(source) + (x Shr 16))^ Shl 16);
+    p := (PUint16(source) + (x shr 16))^ shl DWORD_SMALLINT0_SHL; Inc(x, inc_source);
+    p := p or ((PUint16(source) + (x shr 16))^ shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
     Inc(dest, 4);
-  End;
-
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (Pshort16(source) + (x Shr 16))^;
-End;
-
-Procedure CopyP_1byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+  end;
 
-Var
-  x, c : DWord;
-  p : int32;
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (PUint16(source) + (x shr 16))^;
+end;
 
-Begin
+procedure CopyP_1byte_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Alignment mod 4 }
-  While (PtrUInt(dest) And 3) <> 0 Do
-  Begin
-    dest^ := (source + (x Shr 16))^;
+  while (PtrUInt(dest) and 3) <> 0 do
+  begin
+    dest^ := (source + (x shr 16))^;
     Inc(x, inc_source);
     Inc(dest); Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
+    if count = 0 then
+      exit;
+  end;
 
   { Write blocks of four pixels }
-  c := count Shr 2;
-  While c <> 0 Do
-  Begin
+  c := count shr 2;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (source + (x Shr 16))^; Inc(x, inc_source);
-    p := p Or ((source + (x Shr 16))^ Shl 8); Inc(x, inc_source);
-    p := p Or ((source + (x Shr 16))^ Shl 16); Inc(x, inc_source);
-    p := p Or ((source + (x Shr 16))^ Shl 24); Inc(x, inc_source);
+    p := (source + (x shr 16))^ shl DWORD_BYTE0_SHL; Inc(x, inc_source);
+    p := p or ((source + (x shr 16))^ shl DWORD_BYTE1_SHL); Inc(x, inc_source);
+    p := p or ((source + (x shr 16))^ shl DWORD_BYTE2_SHL); Inc(x, inc_source);
+    p := p or ((source + (x shr 16))^ shl DWORD_BYTE3_SHL); Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
     Inc(dest, 4);
-  End;
+  end;
 
   { Write up to three trailing pixels }
-  c := count And $3;
-  While c <> 0 Do
-  Begin
+  c := count and $3;
+  while c <> 0 do
+  begin
     Dec(c);
-    dest^ := (source + (x Shr 16))^;
+    dest^ := (source + (x shr 16))^;
     Inc(x, inc_source);
     Inc(dest);
-  End;
-End;
+  end;
+end;

+ 570 - 614
packages/hermes/src/p_g.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -27,491 +39,463 @@
    licensing conditions
 }
 
-Procedure ConvertP_Generic32_Generic32(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+procedure ConvertP_Generic32_Generic32(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pint32(source)^;
+    repeat
+      s_pixel := PUint32(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pint32(dest)^ := r Or g Or b;
+      PUint32(dest)^ := r or g or b;
 
       Inc(source, 4);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic32_Generic24(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic32_Generic24(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pint32(source)^;
+    repeat
+      s_pixel := PUint32(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      s_pixel := r Or g Or b;
+      s_pixel := r or g or b;
 
-      (dest+R_24)^ := (d_ptr+R_32)^;
-      (dest+G_24)^ := (d_ptr+G_32)^;
-      (dest+B_24)^ := (d_ptr+B_32)^;
+      (dest+0)^ := (d_ptr+0)^;
+      (dest+1)^ := (d_ptr+1)^;
+      (dest+2)^ := (d_ptr+2)^;
 
       Inc(source, 4);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic32_Generic16(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic32_Generic16(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
-    count := iface^.s_width Shr 1;
+  repeat
+    count := iface^.s_width shr 1;
 
-    If count <> 0 Then
-      Repeat
-        r := (((Pint32(source)^) Shr iface^.info.r_right) Shl iface^.info.r_left) And
+    if count <> 0 then
+      repeat
+        r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
               iface^.mask_r;
-        g := (((Pint32(source)^) Shr iface^.info.g_right) Shl iface^.info.g_left) And
+        g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
               iface^.mask_g;
-        b := (((Pint32(source)^) Shr iface^.info.b_right) Shl iface^.info.b_left) And
+        b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
               iface^.mask_b;
 
-        s_pixel := (r Or g Or b) And $FFFF;
+        s_pixel := (r or g or b) shl DWORD_SMALLINT0_SHL;
 
-        r := ((((Pint32(source)+1)^) Shr iface^.info.r_right) Shl iface^.info.r_left) And
+        r := ((((PUint32(source)+1)^) shr iface^.info.r_right) shl iface^.info.r_left) and
               iface^.mask_r;
-        g := ((((Pint32(source)+1)^) Shr iface^.info.g_right) Shl iface^.info.g_left) And
+        g := ((((PUint32(source)+1)^) shr iface^.info.g_right) shl iface^.info.g_left) and
               iface^.mask_g;
-        b := ((((Pint32(source)+1)^) Shr iface^.info.b_right) Shl iface^.info.b_left) And
+        b := ((((PUint32(source)+1)^) shr iface^.info.b_right) shl iface^.info.b_left) and
               iface^.mask_b;
 
-        s_pixel := s_pixel Or ((r Or g Or b) Shl 16);
+        s_pixel := s_pixel or ((r or g or b) shl DWORD_SMALLINT1_SHL);
 
-        Pint32(dest)^ := s_pixel;
+        PUint32(dest)^ := s_pixel;
 
         Inc(source, 8);
         Inc(dest, 4);
         Dec(count);
-      Until count = 0;
+      until count = 0;
 
 
     { Trailing pixel }
 
-    If (iface^.s_width And 1) <> 0 Then
-    Begin
-      r := (((Pint32(source)^) Shr iface^.info.r_right) Shl iface^.info.r_left) And
+    if (iface^.s_width and 1) <> 0 then
+    begin
+      r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
             iface^.mask_r;
-      g := (((Pint32(source)^) Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
             iface^.mask_g;
-      b := (((Pint32(source)^) Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
             iface^.mask_b;
 
-      Pshort16(dest)^ := r Or g Or b;
+      PUint16(dest)^ := r or g or b;
       Inc(dest, 2);
       Inc(source, 4);
-    End;
+    end;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic32_Generic8(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic32_Generic8(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pint32(source)^;
+    repeat
+      s_pixel := PUint32(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      dest^ := r Or g Or b;
+      dest^ := r or g or b;
 
       Inc(source, 4);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic32(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic32(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := (((source+R_24)^) Shl 16) Or
-                 (((source+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((source+R_24)^) shl 16) or
+                 (((source+G_24)^) shl 8) or
                  ((source+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pint32(dest)^ := r Or g Or b;
+      PUint32(dest)^ := r or g or b;
 
       Inc(source, 3);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic24(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : PChar8;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic24(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := (((source+R_24)^) Shl 16) Or
-                 (((source+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((source+R_24)^) shl 16) or
+                 (((source+G_24)^) shl 8) or
                  ((source+B_24)^);
 
-      r := ((s_pixel Shl iface^.info.r_left) Shr iface^.info.r_right) And
+      r := ((s_pixel shl iface^.info.r_left) shr iface^.info.r_right) and
         iface^.mask_r;
-      g := ((s_pixel Shl iface^.info.g_left) Shr iface^.info.g_right) And
+      g := ((s_pixel shl iface^.info.g_left) shr iface^.info.g_right) and
         iface^.mask_g;
-      b := ((s_pixel Shl iface^.info.b_left) Shr iface^.info.b_right) And
+      b := ((s_pixel shl iface^.info.b_left) shr iface^.info.b_right) and
         iface^.mask_b;
 
-      s_pixel := r Or g Or b;
+      s_pixel := r or g or b;
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
       Inc(source, 3);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic16(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic16(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := (((source+R_24)^) Shl 16) Or
-                 (((source+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((source+R_24)^) shl 16) or
+                 (((source+G_24)^) shl 8) or
                  ((source+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pshort16(dest)^ := r Or g Or b;
+      PUint16(dest)^ := r or g or b;
 
       Inc(source, 3);
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic8(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic8(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := (((source+R_24)^) Shl 16) Or
-                 (((source+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((source+R_24)^) shl 16) or
+                 (((source+G_24)^) shl 8) or
                  ((source+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      dest^ := r Or g Or b;
+      dest^ := r or g or b;
 
       Inc(source, 3);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic32(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic32(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pint32(dest)^ := r Or g Or b;
+      PUint32(dest)^ := r or g or b;
 
       Inc(source, 2);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic24(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic24(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      s_pixel := r Or g Or b;
+      s_pixel := r or g or b;
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
       Inc(source, 2);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic16(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic16(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pshort16(dest)^ := r Or g Or b;
+      PUint16(dest)^ := r or g or b;
 
       Inc(source, 2);
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic8(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic8(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      dest^ := r Or g Or b;
+      dest^ := r or g or b;
 
       Inc(source, 2);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
+  until iface^.s_height = 0;
+end;
 
-Procedure ConvertP_Generic8_Generic32(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic8_Generic32(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
-
-Procedure ConvertP_Generic8_Generic24(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic8_Generic24(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
+end;
 
-Procedure ConvertP_Generic8_Generic16(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic8_Generic16(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
-
-Procedure ConvertP_Generic8_Generic8(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic8_Generic8(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
+end;
 
 { -------------------------------------------------------------------------
 
@@ -519,600 +503,572 @@ End;
 
   ------------------------------------------------------------------------- }
 
-Procedure ConvertP_Generic32_Generic32_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+procedure ConvertP_Generic32_Generic32_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pint32(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint32(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pint32(dest)^ := r Or g Or b;
+      PUint32(dest)^ := r or g or b;
 
       Inc(x, dx);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic32_Generic24_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic32_Generic24_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pint32(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint32(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      s_pixel := r Or g Or b;
+      s_pixel := r or g or b;
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
       Inc(x, dx);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic32_Generic16_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic32_Generic16_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pint32(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint32(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pshort16(dest)^ := r Or g Or b;
+      PUint16(dest)^ := r or g or b;
 
       Inc(x, dx);
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic32_Generic8_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic32_Generic8_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pint32(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint32(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      dest^ := r Or g Or b;
+      dest^ := r or g or b;
 
       Inc(x, dx);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic32_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, src, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic32_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, src, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
     src := source;
-    Repeat
-      s_pixel := (((src+R_24)^) Shl 16) Or
-                 (((src+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((src+R_24)^) shl 16) or
+                 (((src+G_24)^) shl 8) or
                  ((src+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pint32(dest)^ := r Or g Or b;
+      PUint32(dest)^ := r or g or b;
 
       Inc(x, dx);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      x := x And $FFFF;
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      x := x and $FFFF;
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic24_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, src, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic24_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, src, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
     src := source;
-    Repeat
-      s_pixel := (((src+R_24)^) Shl 16) Or
-                 (((src+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((src+R_24)^) shl 16) or
+                 (((src+G_24)^) shl 8) or
                  ((src+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      s_pixel := r Or g Or b;
+      s_pixel := r or g or b;
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
       Inc(x, dx);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      x := x And $FFFF;
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      x := x and $FFFF;
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic16_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, src, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic16_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, src, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
     src := source;
-    Repeat
-      s_pixel := (((src+R_24)^) Shl 16) Or
-                 (((src+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((src+R_24)^) shl 16) or
+                 (((src+G_24)^) shl 8) or
                  ((src+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pshort16(dest)^ := r Or g Or b;
+      PUint16(dest)^ := r or g or b;
 
       Inc(x, dx);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      x := x And $FFFF;
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      x := x and $FFFF;
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic24_Generic8_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, src, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic24_Generic8_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, src, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
     src := source;
-    Repeat
-      s_pixel := (((src+R_24)^) Shl 16) Or
-                 (((src+G_24)^) Shl 8) Or
+    repeat
+      s_pixel := (((src+R_24)^) shl 16) or
+                 (((src+G_24)^) shl 8) or
                  ((src+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      dest^ := r Or g Or b;
+      dest^ := r or g or b;
 
       Inc(x, dx);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      Inc(src, x Shr 16);
-      x := x And $FFFF;
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      Inc(src, x shr 16);
+      x := x and $FFFF;
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic32_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic32_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pshort16(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint16(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pint32(dest)^ := r Or g Or b;
+      PUint32(dest)^ := r or g or b;
 
       Inc(x, dx);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic24_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic24_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pshort16(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint16(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      s_pixel := r Or g Or b;
+      s_pixel := r or g or b;
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
       Inc(x, dx);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic16_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic16_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pshort16(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint16(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      Pshort16(dest)^ := r Or g Or b;
+      PUint16(dest)^ := r or g or b;
 
       Inc(x, dx);
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic16_Generic8_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic16_Generic8_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pshort16(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint16(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
 
-      dest^ := r Or g Or b;
+      dest^ := r or g or b;
 
       Inc(x, dx);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(dest, iface^.d_add);
 
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
+  until iface^.d_height = 0;
+end;
 
-Procedure ConvertP_Generic8_Generic32_S(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic8_Generic32_S(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
-
-Procedure ConvertP_Generic8_Generic24_S(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic8_Generic24_S(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
+end;
 
-Procedure ConvertP_Generic8_Generic16_S(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic8_Generic16_S(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
-
-Procedure ConvertP_Generic8_Generic8_S(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic8_Generic8_S(iface: PHermesConverterInterface); cdecl;
+begin
   {todo}
-End;
+end;

+ 348 - 364
packages/hermes/src/p_ga.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -22,596 +34,568 @@
    Generic format conversion routines for the HERMES library
    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
 }
 
-Procedure ConvertP_Generic32_A_Generic32_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+procedure ConvertP_Generic32_A_Generic32_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pint32(source)^;
+    repeat
+      s_pixel := PUint32(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      Pint32(dest)^ := r Or g Or b Or a;
+      PUint32(dest)^ := r or g or b or a;
 
       Inc(source, 4);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic32_A_Generic24_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic32_A_Generic24_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pint32(source)^;
+    repeat
+      s_pixel := PUint32(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      s_pixel := r Or g Or b Or a;
+      s_pixel := r or g or b or a;
 
-      (dest+R_24)^ := (d_ptr+R_32)^;
-      (dest+G_24)^ := (d_ptr+G_32)^;
-      (dest+B_24)^ := (d_ptr+B_32)^;
+      (dest+0)^ := (d_ptr+0)^;
+      (dest+1)^ := (d_ptr+1)^;
+      (dest+2)^ := (d_ptr+2)^;
 
       Inc(source, 4);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic32_A_Generic16_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic32_A_Generic16_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
-    count := iface^.s_width Shr 1;
-
-    If count <> 0 Then
-      Repeat
-        r := (((Pint32(source)^) Shr iface^.info.r_right) Shl iface^.info.r_left) And
-	      iface^.mask_r;
-        g := (((Pint32(source)^) Shr iface^.info.g_right) Shl iface^.info.g_left) And
-	      iface^.mask_g;
-        b := (((Pint32(source)^) Shr iface^.info.b_right) Shl iface^.info.b_left) And
-	      iface^.mask_b;
-        a := (((Pint32(source)^) Shr iface^.info.a_right) Shl iface^.info.a_left) And
-	      iface^.mask_a;
-
-        s_pixel := (r Or g Or b Or a) And $FFFF;
-      
-        r := ((((Pint32(source)+1)^) Shr iface^.info.r_right) Shl iface^.info.r_left) And
-	      iface^.mask_r;
-        g := ((((Pint32(source)+1)^) Shr iface^.info.g_right) Shl iface^.info.g_left) And
-	      iface^.mask_g;
-        b := ((((Pint32(source)+1)^) Shr iface^.info.b_right) Shl iface^.info.b_left) And
-	      iface^.mask_b;
-        a := ((((Pint32(source)+1)^) Shr iface^.info.a_right) Shl iface^.info.a_left) And
-	      iface^.mask_a;
-
-        s_pixel := s_pixel Or ((r Or g Or b Or a) Shl 16);
-
-        Pint32(dest)^ := s_pixel;
+  repeat
+    count := iface^.s_width shr 1;
+
+    if count <> 0 then
+      repeat
+        r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
+              iface^.mask_r;
+        g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
+              iface^.mask_g;
+        b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
+              iface^.mask_b;
+        a := (((PUint32(source)^) shr iface^.info.a_right) shl iface^.info.a_left) and
+              iface^.mask_a;
+
+        s_pixel := (r or g or b or a) shl DWORD_SMALLINT0_SHL;
+
+        r := ((((PUint32(source)+1)^) shr iface^.info.r_right) shl iface^.info.r_left) and
+              iface^.mask_r;
+        g := ((((PUint32(source)+1)^) shr iface^.info.g_right) shl iface^.info.g_left) and
+              iface^.mask_g;
+        b := ((((PUint32(source)+1)^) shr iface^.info.b_right) shl iface^.info.b_left) and
+              iface^.mask_b;
+        a := ((((PUint32(source)+1)^) shr iface^.info.a_right) shl iface^.info.a_left) and
+              iface^.mask_a;
+
+        s_pixel := s_pixel or ((r or g or b or a) shl DWORD_SMALLINT1_SHL);
+
+        PUint32(dest)^ := s_pixel;
 
         Inc(source, 8);
         Inc(dest, 4);
         Dec(count);
-      Until count = 0;
+      until count = 0;
 
 
     { Trailing pixel }
-    
-    If (iface^.s_width And 1) <> 0 Then
-    Begin
-      r := (((Pint32(source)^) Shr iface^.info.r_right) Shl iface^.info.r_left) And
-	    iface^.mask_r;
-      g := (((Pint32(source)^) Shr iface^.info.g_right) Shl iface^.info.g_left) And
-	    iface^.mask_g;
-      b := (((Pint32(source)^) Shr iface^.info.b_right) Shl iface^.info.b_left) And
-	    iface^.mask_b;
-      a := (((Pint32(source)^) Shr iface^.info.a_right) Shl iface^.info.a_left) And
-	    iface^.mask_a;
-
-      Pshort16(dest)^ := r Or g Or b Or a;
+
+    if (iface^.s_width and 1) <> 0 then
+    begin
+      r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
+            iface^.mask_r;
+      g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
+            iface^.mask_g;
+      b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
+            iface^.mask_b;
+      a := (((PUint32(source)^) shr iface^.info.a_right) shl iface^.info.a_left) and
+            iface^.mask_a;
+
+      PUint16(dest)^ := r or g or b or a;
       Inc(dest, 2);
       Inc(source, 4);
-    End;
+    end;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic32_A_Generic8_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic32_A_Generic8_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pint32(source)^;
+    repeat
+      s_pixel := PUint32(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      dest^ := r Or g Or b Or a;
+      dest^ := r or g or b or a;
 
       Inc(source, 4);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_A_Generic32_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_A_Generic32_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := ((Pint32(source+R_24)^) Shl 16) Or
-                 ((Pint32(source+G_24)^) Shl 8) Or
-                 (PInt32(source+B_24)^);
+    repeat
+      s_pixel := ((PUint32(source+R_24)^) shl 16) or
+                 ((PUint32(source+G_24)^) shl 8) or
+                 (PUint32(source+B_24)^);
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      Pint32(dest)^ := r Or g Or b Or a;
+      PUint32(dest)^ := r or g or b or a;
 
       Inc(source, 3);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_A_Generic24_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : PChar8;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_A_Generic24_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := ((Pint32(source+R_24)^) Shl 16) Or
-                 ((Pint32(source+G_24)^) Shl 8) Or
-                 (PInt32(source+B_24)^);
-    
-      r := ((s_pixel Shl iface^.info.r_left) Shr iface^.info.r_right) And
+    repeat
+      s_pixel := ((PUint32(source+R_24)^) shl 16) or
+                 ((PUint32(source+G_24)^) shl 8) or
+                 (PUint32(source+B_24)^);
+
+      r := ((s_pixel shl iface^.info.r_left) shr iface^.info.r_right) and
         iface^.mask_r;
-      g := ((s_pixel Shl iface^.info.g_left) Shr iface^.info.g_right) And
+      g := ((s_pixel shl iface^.info.g_left) shr iface^.info.g_right) and
         iface^.mask_g;
-      b := ((s_pixel Shl iface^.info.b_left) Shr iface^.info.b_right) And
+      b := ((s_pixel shl iface^.info.b_left) shr iface^.info.b_right) and
         iface^.mask_b;
-      a := ((s_pixel Shl iface^.info.a_left) Shr iface^.info.a_right) And
+      a := ((s_pixel shl iface^.info.a_left) shr iface^.info.a_right) and
         iface^.mask_a;
 
-      s_pixel := r Or g Or b Or a;
+      s_pixel := r or g or b or a;
+
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
-    
       Inc(source, 3);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_A_Generic16_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_A_Generic16_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := ((Pint32(source+R_24)^) Shl 16) Or
-                 ((Pint32(source+G_24)^) Shl 8) Or
-                 (PInt32(source+B_24)^);
-    
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+    repeat
+      s_pixel := ((PUint32(source+R_24)^) shl 16) or
+                 ((PUint32(source+G_24)^) shl 8) or
+                 (PUint32(source+B_24)^);
+
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      Pshort16(dest)^ := r Or g Or b Or a;
+      PUint16(dest)^ := r or g or b or a;
 
       Inc(source, 3);
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic24_A_Generic8_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic24_A_Generic8_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := ((Pint32(source+R_24)^) Shl 16) Or
-                 ((Pint32(source+G_24)^) Shl 8) Or
-                 (PInt32(source+B_24)^);
-    
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+    repeat
+      s_pixel := ((PUint32(source+R_24)^) shl 16) or
+                 ((PUint32(source+G_24)^) shl 8) or
+                 (PUint32(source+B_24)^);
+
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
-    
-      dest^ := r Or g Or b Or a;
-    
+
+      dest^ := r or g or b or a;
+
       Inc(source, 3);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_A_Generic32_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_A_Generic32_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      Pint32(dest)^ := r Or g Or b Or a;
+      PUint32(dest)^ := r or g or b or a;
 
       Inc(source, 2);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_A_Generic24_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  d_ptr : Pchar8;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
-  d_ptr := @s_pixel;
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_A_Generic24_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  d_ptr: PUint8;
+  count: DWord;
+  source, dest: PUint8;
+begin
+  d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
-    
-      s_pixel := r Or g Or b Or a;
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
-    
+      s_pixel := r or g or b or a;
+
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
+
       Inc(source, 2);
       Inc(dest, 3);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_A_Generic16_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_A_Generic16_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      Pshort16(dest)^ := r Or g Or b Or a;
+      PUint16(dest)^ := r or g or b or a;
 
       Inc(source, 2);
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_Generic16_A_Generic8_A(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_Generic16_A_Generic8_A(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels; dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    Repeat
-      s_pixel := Pshort16(source)^;
+    repeat
+      s_pixel := PUint16(source)^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
 
-      dest^ := r Or g Or b Or a;
+      dest^ := r or g or b or a;
 
       Inc(source, 2);
       Inc(dest);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
+  until iface^.s_height = 0;
+end;
 
 { -------------------------------------------------------------------------
 
                              STRETCH CONVERTERS
-   
-  ------------------------------------------------------------------------- }
-
 
-Procedure ConvertP_Generic32_A_Generic32_A_S(iface : PHermesConverterInterface); CDecl;
+  ------------------------------------------------------------------------- }
 
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
 
-Begin
+procedure ConvertP_Generic32_A_Generic32_A_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pint32(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint32(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
-    
-      Pint32(dest)^ := r Or g Or b Or a;
-    
+
+      PUint32(dest)^ := r or g or b or a;
+
       Inc(x, dx);
       Inc(dest, 4);
       Dec(count);
-    Until count = 0;
-    
+    until count = 0;
+
     Inc(dest, iface^.d_add);
-    
+
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_Generic32_A_Generic16_A_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  s_pixel, r, g, b, a : int32;
-  count : DWord;
-  source, dest : Pchar8;
-  dx, dy, x, y : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_Generic32_A_Generic16_A_S(iface: PHermesConverterInterface); cdecl;
+var
+  s_pixel, r, g, b, a: Uint32;
+  count: DWord;
+  source, dest: PUint8;
+  dx, dy, x, y: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   y := 0;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
-    Repeat
-      s_pixel := (Pint32(source)+(x Shr 16))^;
+    repeat
+      s_pixel := (PUint32(source)+(x shr 16))^;
 
-      r := ((s_pixel Shr iface^.info.r_right) Shl iface^.info.r_left) And
+      r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
         iface^.mask_r;
-      g := ((s_pixel Shr iface^.info.g_right) Shl iface^.info.g_left) And
+      g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
         iface^.mask_g;
-      b := ((s_pixel Shr iface^.info.b_right) Shl iface^.info.b_left) And
+      b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
         iface^.mask_b;
-      a := ((s_pixel Shr iface^.info.a_right) Shl iface^.info.a_left) And
+      a := ((s_pixel shr iface^.info.a_right) shl iface^.info.a_left) and
         iface^.mask_a;
-    
-      Pshort16(dest)^ := r Or g Or b Or a;
-    
+
+      PUint16(dest)^ := r or g or b or a;
+
       Inc(x, dx);
       Inc(dest, 2);
       Dec(count);
-    Until count = 0;
-    
+    until count = 0;
+
     Inc(dest, iface^.d_add);
-    
+
     Inc(y, dy);
-    Inc(source, (y Shr 16)*DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16)*DWord(iface^.s_pitch));
+    y := y and $ffff;
 
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
+  until iface^.d_height = 0;
+end;

+ 57 - 59
packages/hermes/src/p_gac.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -22,98 +34,84 @@
    Generic format conversion routines for the HERMES library
    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
 }
 
-Procedure ConvertP_Generic32_A_Generic32_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_A_Generic32_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic32_A_Generic24_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_A_Generic24_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic32_A_Generic16_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic32_A_Generic16_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic32_A_Generic8_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_A_Generic8_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic24_A_Generic32_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic24_A_Generic32_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic24_A_Generic24_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic24_A_Generic24_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic24_A_Generic16_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic24_A_Generic16_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic24_A_Generic8_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic24_A_Generic8_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic16_A_Generic32_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic16_A_Generic32_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic16_A_Generic24_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic16_A_Generic24_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic16_A_Generic16_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic16_A_Generic16_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic16_A_Generic8_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic16_A_Generic8_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
 { -------------------------------------------------------------------------
 
                              STRETCH CONVERTERS
-   
-  ------------------------------------------------------------------------- }
 
+  ------------------------------------------------------------------------- }
 
-Procedure ConvertP_Generic32_A_Generic32_C_S(iface : PHermesConverterInterface); CDecl;
 
-Begin
+procedure ConvertP_Generic32_A_Generic32_C_S(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic32_A_Generic16_C_S(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic32_A_Generic16_C_S(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;

+ 57 - 59
packages/hermes/src/p_gca.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -22,97 +34,83 @@
    Generic format conversion routines for the HERMES library
    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
 }
 
-Procedure ConvertP_Generic32_C_Generic32_A(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_C_Generic32_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic32_C_Generic24_A(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_C_Generic24_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic32_C_Generic16_A(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic32_C_Generic16_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic32_C_Generic8_A(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_C_Generic8_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic24_C_Generic32_A(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic24_C_Generic32_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic24_C_Generic24_A(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic24_C_Generic24_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic24_C_Generic16_A(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic24_C_Generic16_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic24_C_Generic8_A(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic24_C_Generic8_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic16_C_Generic32_A(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic16_C_Generic32_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic16_C_Generic24_A(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic16_C_Generic24_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic16_C_Generic16_A(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic16_C_Generic16_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic16_C_Generic8_A(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic16_C_Generic8_A(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
 { -------------------------------------------------------------------------
 
                              STRETCH CONVERTERS
-   
-  ------------------------------------------------------------------------- }
 
-Procedure ConvertP_Generic32_C_Generic32_A_S(iface : PHermesConverterInterface); CDecl;
+  ------------------------------------------------------------------------- }
 
-Begin
+procedure ConvertP_Generic32_C_Generic32_A_S(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic32_C_Generic16_A_S(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic32_C_Generic16_A_S(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;

+ 57 - 59
packages/hermes/src/p_gcc.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -22,98 +34,84 @@
    Generic format conversion routines for the HERMES library
    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
 }
 
-Procedure ConvertP_Generic32_C_Generic32_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_C_Generic32_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic32_C_Generic24_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_C_Generic24_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic32_C_Generic16_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic32_C_Generic16_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic32_C_Generic8_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic32_C_Generic8_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic24_C_Generic32_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic24_C_Generic32_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic24_C_Generic24_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic24_C_Generic24_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic24_C_Generic16_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic24_C_Generic16_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic24_C_Generic8_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic24_C_Generic8_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic16_C_Generic32_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic16_C_Generic32_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic16_C_Generic24_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic16_C_Generic24_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic16_C_Generic16_C(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic16_C_Generic16_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
-Procedure ConvertP_Generic16_C_Generic8_C(iface : PHermesConverterInterface); CDecl;
-
-Begin
+procedure ConvertP_Generic16_C_Generic8_C(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;
 
 { -------------------------------------------------------------------------
 
                              STRETCH CONVERTERS
-   
-  ------------------------------------------------------------------------- }
 
+  ------------------------------------------------------------------------- }
 
-Procedure ConvertP_Generic32_C_Generic32_C_S(iface : PHermesConverterInterface); CDecl;
 
-Begin
+procedure ConvertP_Generic32_C_Generic32_C_S(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
-
-Procedure ConvertP_Generic32_C_Generic16_C_S(iface : PHermesConverterInterface); CDecl;
+end;
 
-Begin
+procedure ConvertP_Generic32_C_Generic16_C_S(iface: PHermesConverterInterface); cdecl;
+begin
   {NOT YET IMPLEMENTED!}
-End;
+end;

+ 240 - 219
packages/hermes/src/p_i8.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -34,162 +46,166 @@
 
   ------------------------------------------------------------------------- }
 
-Procedure ConvertP_index8_32(iface : PHermesConverterInterface); CDecl;
-
-Var
-  i : Integer;
-  s_pixel : char8;
-  d_pixel : int32;
-  source, dest : Pchar8;
-
-Begin
+procedure ConvertP_index8_32(iface: PHermesConverterInterface); cdecl;
+var
+  i: Integer;
+  s_pixel: Uint8;
+  d_pixel: Uint32;
+  source, dest: PUint8;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  Repeat
-    For i := 0 To iface^.s_width - 1 Do
-    Begin
+  repeat
+    for i := 0 to iface^.s_width - 1 do
+    begin
       s_pixel := source^;
       d_pixel := iface^.lookup[s_pixel];
-      Pint32(dest)^ := d_pixel;
+      PUint32(dest)^ := d_pixel;
       Inc(source);
       Inc(dest, 4);
-    End;
+    end;
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_index8_24(iface : PHermesConverterInterface); CDecl;
-
-Var
-  count : Integer;
-  s_pixel, s_pixel2, d_pixel : int32;
-  d_ptr, source, dest : Pchar8;
-
-Begin
-  d_ptr := @d_pixel;
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_index8_24(iface: PHermesConverterInterface); cdecl;
+var
+  count: Integer;
+  s_pixel, s_pixel2, d_pixel: Uint32;
+  d_ptr, source, dest: PUint8;
+begin
+  d_ptr := PUint8(@d_pixel) + (R_32 - R_24);
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  Repeat
-    count := iface^.d_width Shr 2;
-    While count <> 0 Do
-    Begin
+  repeat
+    count := iface^.d_width shr 2;
+    while count <> 0 do
+    begin
       Dec(count);
 
       s_pixel := iface^.lookup[source^]; Inc(source);
       s_pixel2 := iface^.lookup[source^]; Inc(source);
 
-      s_pixel := (s_pixel And $ffffff) Or (s_pixel2 Shl 24);
-      Pint32(dest)^ := s_pixel;
+      {$IFDEF FPC_LITTLE_ENDIAN}
+      s_pixel := s_pixel or (s_pixel2 shl 24);
+      {$ELSE FPC_LITTLE_ENDIAN}
+      s_pixel := (s_pixel shl 8) or (s_pixel2 shr 16);
+      {$ENDIF FPC_LITTLE_ENDIAN}
+      PUint32(dest)^ := s_pixel;
 
       s_pixel := iface^.lookup[source^]; Inc(source);
-      s_pixel2 := ((s_pixel2 Shr 8) And $ffff) Or (s_pixel Shl 16);
-      Pint32(dest + 4)^ := s_pixel2;
+      {$IFDEF FPC_LITTLE_ENDIAN}
+      s_pixel2 := (s_pixel2 shr 8) or (s_pixel shl 16);
+      {$ELSE FPC_LITTLE_ENDIAN}
+      s_pixel2 := (s_pixel2 shl 16) or (s_pixel shr 8);
+      {$ENDIF FPC_LITTLE_ENDIAN}
+      PUint32(dest + 4)^ := s_pixel2;
 
       s_pixel2 := iface^.lookup[source^]; Inc(source);
-      s_pixel := ((s_pixel Shr 16) And $ff) Or (s_pixel2 Shl 8);
-      Pint32(dest + 8)^ := s_pixel;
+      {$IFDEF FPC_LITTLE_ENDIAN}
+      s_pixel := (s_pixel shr 16) or (s_pixel2 shl 8);
+      {$ELSE FPC_LITTLE_ENDIAN}
+      s_pixel := (s_pixel shl 24) or s_pixel2;
+      {$ENDIF FPC_LITTLE_ENDIAN}
+      PUint32(dest + 8)^ := s_pixel;
 
       Inc(dest, 12);
-    End;
+    end;
 
-    count := iface^.d_width And $3;
-    While count <> 0 Do
-    Begin
+    count := iface^.d_width and $3;
+    while count <> 0 do
+    begin
       Dec(count);
       d_pixel := iface^.lookup[source^]; Inc(source);
 
-      (dest + R_24)^ := (d_ptr + R_32)^;
-      (dest + G_24)^ := (d_ptr + G_32)^;
-      (dest + B_24)^ := (d_ptr + B_32)^;
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
       Inc(dest, 3);
-    End;
+    end;
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_index8_16(iface : PHermesConverterInterface); CDecl;
-
-Var
-  source, dest : Pchar8;
-  count, c : DWord;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_index8_16(iface: PHermesConverterInterface); cdecl;
+var
+  source, dest: PUint8;
+  count, c: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    If (PtrUInt(dest) And $3) <> 0 Then
-    Begin
-      Pshort16(dest)^ := iface^.lookup[source^]; Inc(source);
+    if (PtrUInt(dest) and $3) <> 0 then
+    begin
+      PUint16(dest)^ := iface^.lookup[source^]; Inc(source);
       Inc(dest, 2);
       Dec(count);
-    End;
-    c := count Shr 1;
-    If c <> 0 Then
-      Repeat
-        Pint32(dest)^ := iface^.lookup[source^] Or
-                        (iface^.lookup[(source + 1)^] Shl 16);
+    end;
+    c := count shr 1;
+    if c <> 0 then
+      repeat
+        PUint32(dest)^ := (iface^.lookup[source^] shl DWORD_SMALLINT0_SHL) or
+                        (iface^.lookup[(source + 1)^] shl DWORD_SMALLINT1_SHL);
         Inc(dest, 4);
         Inc(source, 2);
         Dec(c);
-      Until c = 0;
-    If (count And 1) <> 0 Then
-    Begin
-      Pshort16(dest)^ := iface^.lookup[source^];
+      until c = 0;
+    if (count and 1) <> 0 then
+    begin
+      PUint16(dest)^ := iface^.lookup[source^];
       Inc(source);
       Inc(dest, 2);
-    End;
+    end;
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
-
-Procedure ConvertP_index8_8(iface : PHermesConverterInterface); CDecl;
-
-Var
-  source, dest : Pchar8;
-  count, c : DWord;
-
-Begin
+  until iface^.s_height = 0;
+end;
+
+procedure ConvertP_index8_8(iface: PHermesConverterInterface); cdecl;
+var
+  source, dest: PUint8;
+  count, c: DWord;
+begin
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  Repeat
+  repeat
     count := iface^.s_width;
-    If (PtrUInt(dest) And $3) <> 0 Then
-    Begin
+    if (PtrUInt(dest) and $3) <> 0 then
+    begin
       dest^ := iface^.lookup[source^]; Inc(source);
       Inc(dest);
       Dec(count);
-    End;
-    c := count Shr 2;
-    If c <> 0 Then
-      Repeat
-        Pint32(dest)^ := iface^.lookup[source^] Or
-                        (iface^.lookup[(source + 1)^] Shl 8) Or
-                        (iface^.lookup[(source + 2)^] Shl 16) Or
-                        (iface^.lookup[(source + 3)^] Shl 24);
+    end;
+    c := count shr 2;
+    if c <> 0 then
+      repeat
+        PUint32(dest)^ := (iface^.lookup[source^] shl DWORD_BYTE0_SHL) or
+                        (iface^.lookup[(source + 1)^] shl DWORD_BYTE1_SHL) or
+                        (iface^.lookup[(source + 2)^] shl DWORD_BYTE2_SHL) or
+                        (iface^.lookup[(source + 3)^] shl DWORD_BYTE3_SHL);
         Inc(dest, 4);
         Inc(source, 4);
         Dec(c);
-      Until c = 0;
-    count := count And $03;
-    While count > 0 Do
-    Begin
+      until c = 0;
+    count := count and $03;
+    while count > 0 do
+    begin
       dest^ := iface^.lookup[source^]; Inc(source);
       Inc(dest);
       Dec(count);
-    End;
+    end;
     Inc(source, iface^.s_add);
     Inc(dest, iface^.d_add);
     Dec(iface^.s_height);
-  Until iface^.s_height = 0;
-End;
+  until iface^.s_height = 0;
+end;
 
 { -------------------------------------------------------------------------
 
@@ -197,28 +213,26 @@ End;
 
   ------------------------------------------------------------------------- }
 
-Procedure ConvertP_index8_32_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  x, y, count : DWord;
-  dx, dy : DWord;
-  source : Pchar8;
-
-Begin
+procedure ConvertP_index8_32_S(iface: PHermesConverterInterface); cdecl;
+var
+  x, y, count: DWord;
+  dx, dy: DWord;
+  source: PUint8;
+begin
   y := 0;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   source := iface^.s_pixels;
-  Repeat
+  repeat
     count := iface^.d_width;
     x := 0;
 
-    Repeat
-      Pint32(iface^.d_pixels)^ := iface^.lookup[(source + (x Shr 16))^];
+    repeat
+      PUint32(iface^.d_pixels)^ := iface^.lookup[(source + (x shr 16))^];
       Inc(x, dx);
       Inc(iface^.d_pixels, 4);
       Dec(count);
-    Until count = 0;
+    until count = 0;
 
     { Go to next destination row }
     Inc(iface^.d_pixels, iface^.d_add);
@@ -226,62 +240,73 @@ Begin
     { Calculate amount of rows to move in source surface }
     Inc(y, dy);
 
-    Inc(source, (y Shr 16) * DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16) * DWord(iface^.s_pitch));
+    y := y and $ffff;
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-{by me!}
-Procedure ConvertP_index8_24_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  x, y, count : DWord;
-  dx, dy : DWord;
-  source, dest : Pchar8;
-  s_pixel, s_pixel2, d_pixel : int32;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_index8_24_S(iface: PHermesConverterInterface); cdecl;
+var
+  x, y, count: DWord;
+  dx, dy: DWord;
+  d_ptr, source, dest: PUint8;
+  s_pixel, s_pixel2, d_pixel: Uint32;
+begin
+  d_ptr := PUint8(@d_pixel) + (R_32 - R_24);
   y := 0;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  Repeat
+  repeat
     x := 0;
-    count := iface^.d_width Shr 2;
-    While count <> 0 Do
-    Begin
+    count := iface^.d_width shr 2;
+    while count <> 0 do
+    begin
       Dec(count);
 
-      s_pixel := iface^.lookup[(source + (x Shr 16))^]; Inc(x, dx);
-      s_pixel2 := iface^.lookup[(source + (x Shr 16))^]; Inc(x, dx);
-
-      s_pixel := (s_pixel And $ffffff) Or (s_pixel2 Shl 24);
-      Pint32(dest)^ := s_pixel;
-
-      s_pixel := iface^.lookup[(source + (x Shr 16))^]; Inc(x, dx);
-      s_pixel2 := ((s_pixel2 Shr 8) And $ffff) Or (s_pixel Shl 16);
-      Pint32(dest + 4)^ := s_pixel2;
-
-      s_pixel2 := iface^.lookup[(source + (x Shr 16))^]; Inc(x, dx);
-      s_pixel := ((s_pixel Shr 16) And $ff) Or (s_pixel2 Shl 8);
-      Pint32(dest + 8)^ := s_pixel;
+      s_pixel := iface^.lookup[(source + (x shr 16))^]; Inc(x, dx);
+      s_pixel2 := iface^.lookup[(source + (x shr 16))^]; Inc(x, dx);
+
+      {$IFDEF FPC_LITTLE_ENDIAN}
+      s_pixel := s_pixel or (s_pixel2 shl 24);
+      {$ELSE FPC_LITTLE_ENDIAN}
+      s_pixel := (s_pixel shl 8) or (s_pixel2 shr 16);
+      {$ENDIF FPC_LITTLE_ENDIAN}
+      PUint32(dest)^ := s_pixel;
+
+      s_pixel := iface^.lookup[(source + (x shr 16))^]; Inc(x, dx);
+      {$IFDEF FPC_LITTLE_ENDIAN}
+      s_pixel2 := (s_pixel2 shr 8) or (s_pixel shl 16);
+      {$ELSE FPC_LITTLE_ENDIAN}
+      s_pixel2 := (s_pixel2 shl 16) or (s_pixel shr 8);
+      {$ENDIF FPC_LITTLE_ENDIAN}
+      PUint32(dest + 4)^ := s_pixel2;
+
+      s_pixel2 := iface^.lookup[(source + (x shr 16))^]; Inc(x, dx);
+      {$IFDEF FPC_LITTLE_ENDIAN}
+      s_pixel := (s_pixel shr 16) or (s_pixel2 shl 8);
+      {$ELSE FPC_LITTLE_ENDIAN}
+      s_pixel := (s_pixel shl 24) or s_pixel2;
+      {$ENDIF FPC_LITTLE_ENDIAN}
+      PUint32(dest + 8)^ := s_pixel;
 
       Inc(dest, 12);
-    End;
+    end;
 
-    count := iface^.d_width And $3;
-    While count <> 0 Do
-    Begin
+    count := iface^.d_width and $3;
+    while count <> 0 do
+    begin
       Dec(count);
-      d_pixel := iface^.lookup[(source + (x Shr 16))^]; Inc(x, dx);
+      d_pixel := iface^.lookup[(source + (x shr 16))^]; Inc(x, dx);
 
-      Pshort16(dest)^ := d_pixel;
-      Pchar8(dest + 2)^ := d_pixel Shr 16;
+      (dest + 0)^ := (d_ptr + 0)^;
+      (dest + 1)^ := (d_ptr + 1)^;
+      (dest + 2)^ := (d_ptr + 2)^;
 
       Inc(dest, 3);
-    End;
+    end;
 
     { Go to next destination row }
 {    Inc(iface^.d_pixels, iface^.d_add);}
@@ -290,47 +315,45 @@ Begin
     { Calculate amount of rows to move in source surface }
     Inc(y, dy);
 
-    Inc(source, (y Shr 16) * DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16) * DWord(iface^.s_pitch));
+    y := y and $ffff;
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
+  until iface^.d_height = 0;
+end;
 
 { Quick hack of a index 8 to 16 stretch converter }
-Procedure ConvertP_index8_16_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  x, y, count : DWord;
-  dx, dy : DWord;
-  source, dest : Pchar8;
-
-Begin
+procedure ConvertP_index8_16_S(iface: PHermesConverterInterface); cdecl;
+var
+  x, y, count: DWord;
+  dx, dy: DWord;
+  source, dest: PUint8;
+begin
   y := 0;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  Repeat
-    { Do a two pixel at a time loop }
+  repeat
+    { do a two pixel at a time loop }
 
-    count := iface^.d_width Shr 1;
+    count := iface^.d_width shr 1;
     x := 0;
 
-    While count <> 0 Do
-    Begin
+    while count <> 0 do
+    begin
       Dec(count);
-      Pint32(dest)^ := iface^.lookup[(source + (x Shr 16))^] Or
-                      (iface^.lookup[(source + ((x + dx) Shr 16))^] Shl 16);
+      PUint32(dest)^ := (iface^.lookup[(source + (x shr 16))^] shl DWORD_SMALLINT0_SHL) or
+                      (iface^.lookup[(source + ((x + dx) shr 16))^] shl DWORD_SMALLINT1_SHL);
       Inc(x, dx); Inc(x, dx);
       Inc(dest, 4);
-    End;
+    end;
 
     { Clean up remaining pixel if odd width }
-    If (iface^.d_width And 1) <> 0 Then
-    Begin
-      Pshort16(dest)^ := iface^.lookup[(source + (x Shr 16))^];
+    if (iface^.d_width and 1) <> 0 then
+    begin
+      PUint16(dest)^ := iface^.lookup[(source + (x shr 16))^];
       Inc(dest, 2);
-    End;
+    end;
 
     { Go to next destination row }
     Inc(dest, iface^.d_add);
@@ -338,59 +361,57 @@ Begin
     { Calculate amount of rows to move in source surface }
     Inc(y, dy);
 
-    Inc(source, (y Shr 16) * DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16) * DWord(iface^.s_pitch));
+    y := y and $ffff;
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
-
-Procedure ConvertP_index8_8_S(iface : PHermesConverterInterface); CDecl;
-
-Var
-  x, y, count, c : DWord;
-  dx, dy : DWord;
-  source, dest : Pchar8;
-
-Begin
+  until iface^.d_height = 0;
+end;
+
+procedure ConvertP_index8_8_S(iface: PHermesConverterInterface); cdecl;
+var
+  x, y, count, c: DWord;
+  dx, dy: DWord;
+  source, dest: PUint8;
+begin
   y := 0;
-  dy := (iface^.s_height Shl 16) Div iface^.d_height;
-  dx := (iface^.s_width Shl 16) Div iface^.d_width;
+  dy := (iface^.s_height shl 16) div iface^.d_height;
+  dx := (iface^.s_width shl 16) div iface^.d_width;
   source := iface^.s_pixels;
   dest := iface^.d_pixels;
-  Repeat
-    { Do a four pixel at a time loop }
+  repeat
+    { do a four pixel at a time loop }
 
     count := iface^.d_width;
     x := 0;
 
-    While ((PtrUInt(dest) And 3) <> 0) And (count > 0) Do
-    Begin
+    while ((PtrUInt(dest) and 3) <> 0) and (count > 0) do
+    begin
       Dec(count);
-      dest^ := iface^.lookup[(source + (x Shr 16))^];
+      dest^ := iface^.lookup[(source + (x shr 16))^];
       Inc(x, dx);
       Inc(dest);
-    End;
+    end;
 
-    c := count Shr 2;
-    count := count And 3;
+    c := count shr 2;
+    count := count and 3;
 
-    While c <> 0 Do
-    Begin
+    while c <> 0 do
+    begin
       Dec(c);
-      Pint32(dest)^ := iface^.lookup[(source + (x Shr 16))^] Or
-                      (iface^.lookup[(source + ((x + dx) Shr 16))^] Shl 8) Or
-                      (iface^.lookup[(source + ((x + (dx Shl 1)) Shr 16))^] Shl 16) Or
-                      (iface^.lookup[(source + ((x + dx + (dx Shl 1)) Shr 16))^] Shl 24);
-      Inc(x, dx Shl 2);
+      PUint32(dest)^ := (iface^.lookup[(source + (x shr 16))^] shl DWORD_BYTE0_SHL) or
+                      (iface^.lookup[(source + ((x + dx) shr 16))^] shl DWORD_BYTE1_SHL) or
+                      (iface^.lookup[(source + ((x + (dx shl 1)) shr 16))^] shl DWORD_BYTE2_SHL) or
+                      (iface^.lookup[(source + ((x + dx + (dx shl 1)) shr 16))^] shl DWORD_BYTE3_SHL);
+      Inc(x, dx shl 2);
       Inc(dest, 4);
-    End;
+    end;
 
-    While count > 0 Do
-    Begin
+    while count > 0 do
+    begin
       Dec(count);
-      dest^ := iface^.lookup[(source + (x Shr 16))^];
+      dest^ := iface^.lookup[(source + (x shr 16))^];
       Inc(dest);
-    End;
+    end;
 
     { Go to next destination row }
     Inc(dest, iface^.d_add);
@@ -398,8 +419,8 @@ Begin
     { Calculate amount of rows to move in source surface }
     Inc(y, dy);
 
-    Inc(source, (y Shr 16) * DWord(iface^.s_pitch));
-    y := y And $ffff;
+    Inc(source, (y shr 16) * DWord(iface^.s_pitch));
+    y := y and $ffff;
     Dec(iface^.d_height);
-  Until iface^.d_height = 0;
-End;
+  until iface^.d_height = 0;
+end;

+ 611 - 627
packages/hermes/src/p_muhmu.inc

@@ -6,7 +6,19 @@
     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.
+    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
@@ -22,878 +34,850 @@
    muhmuh converters for the HERMES library
    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
 }
 
 { TO 32 RGB }
-Procedure ConvertP_muhmu32_32rgb888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
+procedure ConvertP_muhmu32_32rgb888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+begin
+  repeat
+    s_pixel := PUint32(source)^;
 
-Begin
-  Repeat
-    s_pixel := Pint32(source)^;
+    PUint32(dest)^ := (s_pixel and $ff) or
+                    ((s_pixel and ($ff shl 10)) shr 2) or
+                    ((s_pixel and ($ff shl 20)) shr 4);
 
-    Pint32(dest)^ := (s_pixel And $ff) Or
-                    ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	            ((s_pixel And ($ff Shl 20)) Shr 4);
-    
     Inc(dest, 4);
     Inc(source, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 32 BGR }
-Procedure ConvertP_muhmu32_32bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
-
-Begin
-  Repeat
-    s_pixel := Pint32(source)^;
+procedure ConvertP_muhmu32_32bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+begin
+  repeat
+    s_pixel := PUint32(source)^;
 
-    Pint32(dest)^ := ((s_pixel And $ff) Shl 16) Or
-                     ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	             ((s_pixel Shr 20) And $FF);
+    PUint32(dest)^ := ((s_pixel and $ff) shl 16) or
+                     ((s_pixel and ($ff shl 10)) shr 2) or
+                     ((s_pixel shr 20) and $FF);
 
     Inc(dest, 4);
     Inc(source, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 32 RGBA }
-Procedure ConvertP_muhmu32_32rgba888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+procedure ConvertP_muhmu32_32rgba888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+begin
+  repeat
+    s_pixel := PUint32(source)^;
 
-Var
-  s_pixel : int32;
+    PUint32(dest)^ := (((s_pixel and $ff) or
+                      ((s_pixel and ($ff shl 10)) shr 2) or
+                      ((s_pixel and ($ff shl 20)) shr 4)) shl 8) or $FF;
 
-Begin
-  Repeat
-    s_pixel := Pint32(source)^;
-
-    Pint32(dest)^ := (((s_pixel And $ff) Or
-                      ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	              ((s_pixel And ($ff Shl 20)) Shr 4)) Shl 8) Or $FF;
-    
     Inc(dest, 4);
     Inc(source, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 32 BGRA }
-Procedure ConvertP_muhmu32_32bgra888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
+procedure ConvertP_muhmu32_32bgra888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+begin
+  repeat
+    s_pixel := PUint32(source)^;
 
-Begin
-  Repeat
-    s_pixel := Pint32(source)^;
-
-    Pint32(dest)^ := (((s_pixel And $ff) Shl 24) Or
-                      ((s_pixel And ($ff Shl 10)) Shl 6) Or
-	              ((s_pixel Shr 12) And $FF00)) Or $FF;
+    PUint32(dest)^ := (((s_pixel and $ff) shl 24) or
+                      ((s_pixel and ($ff shl 10)) shl 6) or
+                      ((s_pixel shr 12) and $FF00)) or $FF;
 
     Inc(dest, 4);
     Inc(source, 4);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 24 RGB }
-Procedure ConvertP_muhmu32_24rgb888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
-  s_point : Pchar8;
-
-Begin
-  s_point := @s_pixel;
-  Repeat
-    s_pixel := Pint32(source)^;
-    s_pixel := (s_pixel And $ff) Or
-               ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	       ((s_pixel And ($ff Shl 20)) Shr 4);
-
-    (dest+R_24)^ := (s_point+R_32)^;
-    (dest+G_24)^ := (s_point+G_32)^;
-    (dest+B_24)^ := (s_point+B_32)^;
+procedure ConvertP_muhmu32_24rgb888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+  s_point: PUint8;
+begin
+  s_point := PUint8(@s_pixel) + (R_32 - R_24);
+  repeat
+    s_pixel := PUint32(source)^;
+    s_pixel := (s_pixel and $ff) or
+               ((s_pixel and ($ff shl 10)) shr 2) or
+               ((s_pixel and ($ff shl 20)) shr 4);
+
+    (dest+0)^ := (s_point+0)^;
+    (dest+1)^ := (s_point+1)^;
+    (dest+2)^ := (s_point+2)^;
 
     Inc(source, 4);
     Inc(dest, 3);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 24 BGR }
-Procedure ConvertP_muhmu32_24bgr888(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  s_pixel : int32;
-  s_point : Pchar8;
-
-Begin
-  s_point := @s_pixel;
-  Repeat
-    s_pixel := Pint32(source)^;
-    s_pixel := (s_pixel And $ff) Or
-               ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	       ((s_pixel And ($ff Shl 20)) Shr 4);
+procedure ConvertP_muhmu32_24bgr888(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  s_pixel: Uint32;
+  s_point: PUint8;
+begin
+  s_point := PUint8(@s_pixel) + (R_32 - R_24);
+  repeat
+    s_pixel := PUint32(source)^;
+    s_pixel := (s_pixel and $ff) or
+               ((s_pixel and ($ff shl 10)) shr 2) or
+               ((s_pixel and ($ff shl 20)) shr 4);
 
     { Note that R and B are swapped }
-    (dest+B_24)^ := (s_point+R_32)^;
-    (dest+G_24)^ := (s_point+G_32)^;
-    (dest+R_24)^ := (s_point+B_32)^;
+    (dest+0)^ := (s_point+2)^;
+    (dest+1)^ := (s_point+1)^;
+    (dest+2)^ := (s_point+0)^;
 
     Inc(source, 4);
     Inc(dest, 3);
     Dec(count);
-  Until count = 0;
-End;
+  until count = 0;
+end;
 
 { TO 16 RGB 565 }
-Procedure ConvertP_muhmu32_16rgb565(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  r, g, b : int32;
-  s_pixel, d_pixelblock : int32;
-  d_pixel : short16;
-
-Begin
-  { If the current pixel isn't dword aligned, try write one pixel first }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
-  
-    r := (s_pixel Shr 12) And $f800;
-    g := (s_pixel Shr 7) And $7e0;
-    b := (s_pixel Shr 3) And $1f;
-
-    d_pixel := r Or g Or b;
-
-    Pshort16(dest)^ := d_pixel;
+procedure ConvertP_muhmu32_16rgb565(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  r, g, b: Uint32;
+  s_pixel, d_pixelblock: Uint32;
+  d_pixel: Uint16;
+begin
+  { if the current pixel isn't dword aligned, try write one pixel first }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
+
+    r := (s_pixel shr 12) and $f800;
+    g := (s_pixel shr 7) and $7e0;
+    b := (s_pixel shr 3) and $1f;
+
+    d_pixel := r or g or b;
+
+    PUint16(dest)^ := d_pixel;
 
     Inc(source, 4);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
   { Write blocks of two pixels }
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixelblock := ((s_pixel Shr 12) And $f800) Or
-                    ((s_pixel Shr 7) And $7e0) Or
-		    ((s_pixel Shr 3) And $1f);
+    d_pixelblock := (((s_pixel shr 12) and $f800) or
+                     ((s_pixel shr 7) and $7e0) or
+                     ((s_pixel shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
 
-    s_pixel := (Pint32(source) + 1)^;
+    s_pixel := (PUint32(source) + 1)^;
 
-    d_pixelblock := d_pixelblock Or
-      ((((s_pixel Shr 12) And $f800) Or
-        ((s_pixel Shr 7) And $7e0) Or
-	((s_pixel Shr 3) And $1f)) Shl 16);
+    d_pixelblock := d_pixelblock or
+      ((((s_pixel shr 12) and $f800) or
+        ((s_pixel shr 7) and $7e0) or
+        ((s_pixel shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_pixelblock;
+    PUint32(dest)^ := d_pixelblock;
     Inc(source, 8); Inc(dest, 4);
-  End;
+  end;
 
   { Eventually, write a single odd pixel that might be left }
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-    r := (s_pixel Shr 12) And $f800;
-    g := (s_pixel Shr 7) And $7e0;
-    b := (s_pixel Shr 3) And $1f;
+    r := (s_pixel shr 12) and $f800;
+    g := (s_pixel shr 7) and $7e0;
+    b := (s_pixel shr 3) and $1f;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
-  End;
-End;
+    PUint16(dest)^ := d_pixel;
+  end;
+end;
 
 { TO 16 BGR 565 }
-Procedure ConvertP_muhmu32_16bgr565(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  r, g, b : int32;
-  s_pixel, d_pixelblock : int32;
-  d_pixel : short16;
-
-Begin
-  { If the current pixel isn't dword aligned, try write one pixel first }
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
-  
-    r := (s_pixel Shr 23) And $1f;
-    g := (s_pixel Shr 7) And $7e0;
-    b := (s_pixel Shl 8) And $f800;
-
-    d_pixel := r Or g Or b;
-
-    Pshort16(dest)^ := d_pixel;
+procedure ConvertP_muhmu32_16bgr565(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  r, g, b: Uint32;
+  s_pixel, d_pixelblock: Uint32;
+  d_pixel: Uint16;
+begin
+  { if the current pixel isn't dword aligned, try write one pixel first }
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
+
+    r := (s_pixel shr 23) and $1f;
+    g := (s_pixel shr 7) and $7e0;
+    b := (s_pixel shl 8) and $f800;
+
+    d_pixel := r or g or b;
+
+    PUint16(dest)^ := d_pixel;
 
     Inc(source, 4);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
   { Write blocks of two pixels }
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixelblock := ((s_pixel Shr 23) And $1f) Or
-                    ((s_pixel Shr 7) And $7e0) Or
-		    ((s_pixel Shl 8) And $f800);
+    d_pixelblock := (((s_pixel shr 23) and $1f) or
+                     ((s_pixel shr 7) and $7e0) or
+                     ((s_pixel shl 8) and $f800)) shl DWORD_SMALLINT0_SHL;
 
-    s_pixel := (Pint32(source) + 1)^;
+    s_pixel := (PUint32(source) + 1)^;
 
-    d_pixelblock := d_pixelblock Or
-      ((((s_pixel Shr 23) And $1f) Or
-        ((s_pixel Shr 7) And $7e0) Or
-	((s_pixel Shl 8) And $f800)) Shl 16);
+    d_pixelblock := d_pixelblock or
+      ((((s_pixel shr 23) and $1f) or
+        ((s_pixel shr 7) and $7e0) or
+        ((s_pixel shl 8) and $f800)) shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_pixelblock;
+    PUint32(dest)^ := d_pixelblock;
     Inc(source, 8); Inc(dest, 4);
-  End;
+  end;
 
   { Eventually, write a single odd pixel that might be left }
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-    r := (s_pixel Shr 23) And $1f;
-    g := (s_pixel Shr 7) And $7e0;
-    b := (s_pixel Shl 8) And $f800;
+    r := (s_pixel shr 23) and $1f;
+    g := (s_pixel shr 7) and $7e0;
+    b := (s_pixel shl 8) and $f800;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
-  End;
-End;
+    PUint16(dest)^ := d_pixel;
+  end;
+end;
 
 { TO 16 RGB 555 }
-Procedure ConvertP_muhmu32_16rgb555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
+procedure ConvertP_muhmu32_16rgb555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  r, g, b: Uint32;
+  s_pixel, d_pixelblock: Uint32;
+  d_pixel: Uint16;
+begin
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-Var
-  i : DWord;
-  r, g, b : int32;
-  s_pixel, d_pixelblock : int32;
-  d_pixel : short16;
+    r := (s_pixel shr 13) and $7c00;
+    g := (s_pixel shr 8) and $3e0;
+    b := (s_pixel shr 3) and $1f;
 
-Begin
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
-  
-    r := (s_pixel Shr 13) And $7c00;
-    g := (s_pixel Shr 8) And $3e0;
-    b := (s_pixel Shr 3) And $1f;
+    d_pixel := r or g or b;
 
-    d_pixel := r Or g Or b;
-
-    Pshort16(dest)^ := d_pixel;
+    PUint16(dest)^ := d_pixel;
 
     Inc(source, 4);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixelblock := ((s_pixel Shr 13) And $7c00) Or
-                    ((s_pixel Shr 8) And $3e0) Or
-		    ((s_pixel Shr 3) And $1f);
+    d_pixelblock := (((s_pixel shr 13) and $7c00) or
+                     ((s_pixel shr 8) and $3e0) or
+                     ((s_pixel shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
 
-    s_pixel := (Pint32(source) + 1)^;
+    s_pixel := (PUint32(source) + 1)^;
 
-    d_pixelblock := d_pixelblock Or
-      ((((s_pixel Shr 13) And $7c00) Or
-        ((s_pixel Shr 8) And $3e0) Or
-	((s_pixel Shr 3) And $1f)) Shl 16);
+    d_pixelblock := d_pixelblock or
+      ((((s_pixel shr 13) and $7c00) or
+        ((s_pixel shr 8) and $3e0) or
+        ((s_pixel shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_pixelblock;
+    PUint32(dest)^ := d_pixelblock;
     Inc(source, 8); Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-    r := (s_pixel Shr 13) And $7c00;
-    g := (s_pixel Shr 8) And $3e0;
-    b := (s_pixel Shr 3) And $1f;
+    r := (s_pixel shr 13) and $7c00;
+    g := (s_pixel shr 8) and $3e0;
+    b := (s_pixel shr 3) and $1f;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
-  End;
-End;
+    PUint16(dest)^ := d_pixel;
+  end;
+end;
 
 { TO 16 BGR 555 }
-Procedure ConvertP_muhmu32_16bgr555(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  r, g, b : int32;
-  s_pixel, d_pixelblock : int32;
-  d_pixel : short16;
+procedure ConvertP_muhmu32_16bgr555(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  r, g, b: Uint32;
+  s_pixel, d_pixelblock: Uint32;
+  d_pixel: Uint16;
+begin
+  if (PtrUInt(dest) and $3) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-Begin
-  If (PtrUInt(dest) And $3) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
-  
-    r := (s_pixel Shr 23) And $1f;
-    g := (s_pixel Shr 8) And $3e0;
-    b := (s_pixel Shl 7) And $7c00;
+    r := (s_pixel shr 23) and $1f;
+    g := (s_pixel shr 8) and $3e0;
+    b := (s_pixel shl 7) and $7c00;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
+    PUint16(dest)^ := d_pixel;
 
     Inc(source, 4);
     Inc(dest, 2);
     Dec(count);
-  End;
+  end;
 
-  For i := 1 To count Shr 1 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  for i := 1 to count shr 1 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixelblock := ((s_pixel Shr 23) And $1f) Or
-                    ((s_pixel Shr 8) And $3e0) Or
-		    ((s_pixel Shl 7) And $7c00);
+    d_pixelblock := (((s_pixel shr 23) and $1f) or
+                     ((s_pixel shr 8) and $3e0) or
+                     ((s_pixel shl 7) and $7c00)) shl DWORD_SMALLINT0_SHL;
 
-    s_pixel := (Pint32(source) + 1)^;
+    s_pixel := (PUint32(source) + 1)^;
 
-    d_pixelblock := d_pixelblock Or
-      ((((s_pixel Shr 23) And $1f) Or
-        ((s_pixel Shr 8) And $3e0) Or
-	((s_pixel Shl 7) And $7c00)) Shl 16);
+    d_pixelblock := d_pixelblock or
+      ((((s_pixel shr 23) and $1f) or
+        ((s_pixel shr 8) and $3e0) or
+        ((s_pixel shl 7) and $7c00)) shl DWORD_SMALLINT1_SHL);
 
-    Pint32(dest)^ := d_pixelblock;
+    PUint32(dest)^ := d_pixelblock;
     Inc(source, 8); Inc(dest, 4);
-  End;
+  end;
 
-  If (count And 1) <> 0 Then
-  Begin
-    s_pixel := Pint32(source)^;
+  if (count and 1) <> 0 then
+  begin
+    s_pixel := PUint32(source)^;
 
-    r := (s_pixel Shr 23) And $1f;
-    g := (s_pixel Shr 8) And $3e0;
-    b := (s_pixel Shl 7) And $7c00;
+    r := (s_pixel shr 23) and $1f;
+    g := (s_pixel shr 8) and $3e0;
+    b := (s_pixel shl 7) and $7c00;
 
-    d_pixel := r Or g Or b;
+    d_pixel := r or g or b;
 
-    Pshort16(dest)^ := d_pixel;
-  End;
-End;
+    PUint16(dest)^ := d_pixel;
+  end;
+end;
 
 { TO 8 RGB 332 }
-Procedure ConvertP_muhmu32_8rgb332(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  i : DWord;
-  s_pixel, d_block : int32;
-  d_pixel : char8;
-
-Begin
+procedure ConvertP_muhmu32_8rgb332(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  i: DWord;
+  s_pixel, d_block: Uint32;
+  d_pixel: Uint8;
+begin
   { Process single pixels until we are dword aligned }
-  While (PtrUInt(dest) And $3) <> 0 Do
-  Begin
-    s_pixel := Pint32(source)^;
+  while (PtrUInt(dest) and $3) <> 0 do
+  begin
+    s_pixel := PUint32(source)^;
 
-    d_pixel := ((s_pixel Shr 20) And $e0) Or
-               ((s_pixel Shr 13) And $1c) Or
-	       ((s_pixel Shr 6) And $3);
+    d_pixel := ((s_pixel shr 20) and $e0) or
+               ((s_pixel shr 13) and $1c) or
+               ((s_pixel shr 6) and $3);
 
     dest^ := d_pixel;
 
     Dec(count);
-    If count = 0 Then
-      Exit;
+    if count = 0 then
+      exit;
     Inc(dest);
     Inc(source, 4);
-  End;
+  end;
 
   { Now process blocks of four pixels }
-  For i := 1 To count Shr 2 Do
-  Begin
-    s_pixel := Pint32(source)^;
-    d_block := ((s_pixel Shr 20) And $e0) Or
-               ((s_pixel Shr 13) And $1c) Or
-	       ((s_pixel Shr 6) And $3);
-
-    s_pixel := (Pint32(source) + 1)^;
-    d_block := d_block Or
-               ((((s_pixel Shr 20) And $e0) Or
-                 ((s_pixel Shr 13) And $1c) Or
-	         ((s_pixel Shr 6) And $3)) Shl 8);
-
-    s_pixel := (Pint32(source) + 2)^;
-    d_block := d_block Or
-               ((((s_pixel Shr 20) And $e0) Or
-                 ((s_pixel Shr 13) And $1c) Or
-	         ((s_pixel Shr 6) And $3)) Shl 16);
-
-    s_pixel := (Pint32(source) + 3)^;
-    d_block := d_block Or
-               ((((s_pixel Shr 20) And $e0) Or
-                 ((s_pixel Shr 13) And $1c) Or
-	         ((s_pixel Shr 6) And $3)) Shl 24);
-
-    Pint32(dest)^ := d_block;
+  for i := 1 to count shr 2 do
+  begin
+    s_pixel := PUint32(source)^;
+    d_block := (((s_pixel shr 20) and $e0) or
+                ((s_pixel shr 13) and $1c) or
+                ((s_pixel shr 6) and $3)) shl DWORD_BYTE0_SHL;
+
+    s_pixel := (PUint32(source) + 1)^;
+    d_block := d_block or
+               ((((s_pixel shr 20) and $e0) or
+                 ((s_pixel shr 13) and $1c) or
+                 ((s_pixel shr 6) and $3)) shl DWORD_BYTE1_SHL);
+
+    s_pixel := (PUint32(source) + 2)^;
+    d_block := d_block or
+               ((((s_pixel shr 20) and $e0) or
+                 ((s_pixel shr 13) and $1c) or
+                 ((s_pixel shr 6) and $3)) shl DWORD_BYTE2_SHL);
+
+    s_pixel := (PUint32(source) + 3)^;
+    d_block := d_block or
+               ((((s_pixel shr 20) and $e0) or
+                 ((s_pixel shr 13) and $1c) or
+                 ((s_pixel shr 6) and $3)) shl DWORD_BYTE3_SHL);
+
+    PUint32(dest)^ := d_block;
     Inc(source, 16);
     Inc(dest, 4);
-  End;
+  end;
 
   { Write all possibly remaining pixel }
-  count := count And 3;
-  While count <> 0 Do
-  Begin
+  count := count and 3;
+  while count <> 0 do
+  begin
     Dec(count);
-    dest^ := ((s_pixel Shr 20) And $e0) Or
-             ((s_pixel Shr 13) And $1c) Or
-	     ((s_pixel Shr 6) And $3);
+    dest^ := ((s_pixel shr 20) and $e0) or
+             ((s_pixel shr 13) and $1c) or
+             ((s_pixel shr 6) and $3);
 
     Inc(dest);
     Inc(source, 4);
-  End;
-End;
+  end;
+end;
 
 { -------------------------------------------------------------------------
 
                              STRETCH CONVERTERS
-   
-  ------------------------------------------------------------------------- }
-
-Procedure ConvertP_muhmu32_32rgb888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
-Var
-  x : DWord;
-  s_pixel : DWord;
+  ------------------------------------------------------------------------- }
 
-Begin
+procedure ConvertP_muhmu32_32rgb888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  s_pixel: DWord;
+begin
   x := 0;
-  While count > 0 Do
-  Begin
-    s_pixel := Pint32(source)^;
-    Pint32(dest)^ := (s_pixel And $ff) Or
-                    ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	            ((s_pixel And ($ff Shl 20)) Shr 4);
+  while count > 0 do
+  begin
+    s_pixel := PUint32(source)^;
+    PUint32(dest)^ := (s_pixel and $ff) or
+                    ((s_pixel and ($ff shl 10)) shr 2) or
+                    ((s_pixel and ($ff shl 20)) shr 4);
     Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_muhmu32_32bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  s_pixel : DWord;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_muhmu32_32bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  s_pixel: DWord;
+begin
   x := 0;
-  While count > 0 Do
-  Begin
-    s_pixel := Pint32(source)^;
-    Pint32(dest)^ := ((s_pixel And $ff) Shl 16) Or
-                     ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	             ((s_pixel Shr 20) And $FF);
+  while count > 0 do
+  begin
+    s_pixel := PUint32(source)^;
+    PUint32(dest)^ := ((s_pixel and $ff) shl 16) or
+                     ((s_pixel and ($ff shl 10)) shr 2) or
+                     ((s_pixel shr 20) and $FF);
     Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_muhmu32_32rgba888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  s_pixel : DWord;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_muhmu32_32rgba888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  s_pixel: DWord;
+begin
   x := 0;
-  While count > 0 Do
-  Begin
-    s_pixel := Pint32(source)^;
-    Pint32(dest)^ := (((s_pixel And $ff) Or
-                      ((s_pixel And ($ff Shl 10)) Shr 2) Or
-	              ((s_pixel And ($ff Shl 20)) Shr 4)) Shl 8) Or $FF;
+  while count > 0 do
+  begin
+    s_pixel := PUint32(source)^;
+    PUint32(dest)^ := (((s_pixel and $ff) or
+                      ((s_pixel and ($ff shl 10)) shr 2) or
+                      ((s_pixel and ($ff shl 20)) shr 4)) shl 8) or $FF;
     Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_muhmu32_32bgra888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  s_pixel : DWord;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_muhmu32_32bgra888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  s_pixel: DWord;
+begin
   x := 0;
-  While count > 0 Do
-  Begin
-    s_pixel := Pint32(source)^;
-    Pint32(dest)^ := (((s_pixel And $ff) Shl 24) Or
-                      ((s_pixel And ($ff Shl 10)) Shl 6) Or
-	              ((s_pixel Shr 12) And $FF00)) Or $FF;
+  while count > 0 do
+  begin
+    s_pixel := PUint32(source)^;
+    PUint32(dest)^ := (((s_pixel and $ff) shl 24) or
+                      ((s_pixel and ($ff shl 10)) shl 6) or
+                      ((s_pixel shr 12) and $FF00)) or $FF;
     Inc(x, inc_source);
-    Inc(source, (x Shr 16)*4);
-    x := x And $FFFF;
+    Inc(source, (x shr 16)*4);
+    x := x and $FFFF;
     Inc(dest, 4);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_muhmu32_24rgb888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  p1, p2, p3, p4 : DWord;
-  c : DWord;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_muhmu32_24rgb888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  p1, p2, p3, p4: DWord;
+  c: DWord;
+begin
   x := 0;
-  While (PtrUInt(dest) And 3) <> 0 Do
-  Begin
-    p1 := (Pint32(source) + (x Shr 16))^;
-    p1 := (p1 And $ff) Or
-         ((p1 And ($ff Shl 10)) Shr 2) Or
-         ((p1 And ($ff Shl 20)) Shr 4);
-    Pshort16(dest)^ := p1 And $FFFF;
-    Pchar8(dest + 2)^ := p1 Shr 16;
-    
+  while (PtrUInt(dest) and 3) <> 0 do
+  begin
+    p1 := (PUint32(source) + (x shr 16))^;
+    p1 := (p1 and $ff) or
+         ((p1 and ($ff shl 10)) shr 2) or
+         ((p1 and ($ff shl 20)) shr 4);
+    PUint8(dest + B_24)^ := p1 and $FF;
+    PUint8(dest + G_24)^ := (p1 shr 8) and $FF;
+    PUint8(dest + R_24)^ := p1 shr 16;
+
     Inc(x, inc_source);
     Inc(dest, 3);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
-  
-  c := count Shr 2;
-  While c > 0 Do
-  Begin
-    p1 := (Pint32(source) + (x Shr 16))^;
-    p2 := (Pint32(source) + ((x + inc_source) Shr 16))^;
-    p3 := (Pint32(source) + ((x + 2*inc_source) Shr 16))^;
-    p4 := (Pint32(source) + ((x + 3*inc_source) Shr 16))^;
-    
-    Pint32(dest + 0)^ := ((p2 And $FF) Shl 24) Or ((p1 And $FF00000) Shr 4) Or ((p1 And $3FC00) Shr 2) Or (p1 And $FF);
-    Pint32(dest + 4)^ := ((p3 And $3FC00) Shl 14) Or ((p3 And $FF) Shl 16) Or ((p2 And $FF00000) Shr 12) Or ((p2 And $3FC00) Shr 10);
-    Pint32(dest + 8)^ := ((p4 And $FF00000) Shl 4) Or ((p4 And $3FC00) Shl 6) Or ((p4 And $FF) Shl 8) Or ((p3 And $FF00000) Shr 20);
-    
+    if count = 0 then
+      exit;
+  end;
+
+  c := count shr 2;
+  while c > 0 do
+  begin
+    p1 := (PUint32(source) + (x shr 16))^;
+    p2 := (PUint32(source) + ((x + inc_source) shr 16))^;
+    p3 := (PUint32(source) + ((x + 2*inc_source) shr 16))^;
+    p4 := (PUint32(source) + ((x + 3*inc_source) shr 16))^;
+
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p2 and $FF) shl 24) or ((p1 and $FF00000) shr 4) or ((p1 and $3FC00) shr 2) or (p1 and $FF);
+    PUint32(dest + 4)^ := ((p3 and $3FC00) shl 14) or ((p3 and $FF) shl 16) or ((p2 and $FF00000) shr 12) or ((p2 and $3FC00) shr 10);
+    PUint32(dest + 8)^ := ((p4 and $FF00000) shl 4) or ((p4 and $3FC00) shl 6) or ((p4 and $FF) shl 8) or ((p3 and $FF00000) shr 20);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p1 and $FF00000) shl 4) or ((p1 and $3FC00) shl 6) or ((p1 and $FF) shl 8) or ((p2 and $FF00000) shr 20);
+    PUint32(dest + 4)^ := ((p2 and $3FC00) shl 14) or ((p2 and $FF) shl 16) or ((p3 and $FF00000) shr 12) or ((p3 and $3FC00) shr 10);
+    PUint32(dest + 8)^ := ((p3 and $FF) shl 24) or ((p4 and $FF00000) shr 4) or ((p4 and $3FC00) shr 2) or (p4 and $FF);
+    {$ENDIF FPC_LITTLE_ENDIAN}
+
     Dec(c);
     Inc(x, inc_source*4);
     Inc(dest, 12);
-  End;
-  
-  count := count And 3;
-  While count > 0 Do
-  Begin
-    p1 := (Pint32(source) + (x Shr 16))^;
-    p1 := (p1 And $ff) Or
-         ((p1 And ($ff Shl 10)) Shr 2) Or
-         ((p1 And ($ff Shl 20)) Shr 4);
-    Pshort16(dest)^ := p1 And $FFFF;
-    Pchar8(dest + 2)^ := p1 Shr 16;
-    
+  end;
+
+  count := count and 3;
+  while count > 0 do
+  begin
+    p1 := (PUint32(source) + (x shr 16))^;
+    p1 := (p1 and $ff) or
+         ((p1 and ($ff shl 10)) shr 2) or
+         ((p1 and ($ff shl 20)) shr 4);
+    PUint8(dest + B_24)^ := p1 and $FF;
+    PUint8(dest + G_24)^ := (p1 shr 8) and $FF;
+    PUint8(dest + R_24)^ := p1 shr 16;
+
     Inc(x, inc_source);
     Inc(dest, 3);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_muhmu32_24bgr888_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x : DWord;
-  p1, p2, p3, p4 : DWord;
-  c : DWord;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_muhmu32_24bgr888_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x: DWord;
+  p1, p2, p3, p4: DWord;
+  c: DWord;
+begin
   x := 0;
-  While (PtrUInt(dest) And 3) <> 0 Do
-  Begin
-    p1 := (Pint32(source) + (x Shr 16))^;
-    p1 := ((p1 And $ff) Shl 16) Or
-          ((p1 And ($ff Shl 10)) Shr 2) Or
-          ((p1 And ($ff Shl 20)) Shr 20);
-    Pshort16(dest)^ := p1 And $FFFF;
-    Pchar8(dest + 2)^ := p1 Shr 16;
-    
+  while (PtrUInt(dest) and 3) <> 0 do
+  begin
+    p1 := (PUint32(source) + (x shr 16))^;
+    p1 := ((p1 and $ff) shl 16) or
+          ((p1 and ($ff shl 10)) shr 2) or
+          ((p1 and ($ff shl 20)) shr 20);
+    PUint8(dest + B_24)^ := p1 and $FF;
+    PUint8(dest + G_24)^ := (p1 shr 8) and $FF;
+    PUint8(dest + R_24)^ := p1 shr 16;
+
     Inc(x, inc_source);
     Inc(dest, 3);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
-  
-  c := count Shr 2;
-  While c > 0 Do
-  Begin
-    p1 := (Pint32(source) + (x Shr 16))^;
-    p2 := (Pint32(source) + ((x + inc_source) Shr 16))^;
-    p3 := (Pint32(source) + ((x + 2*inc_source) Shr 16))^;
-    p4 := (Pint32(source) + ((x + 3*inc_source) Shr 16))^;
-    
-    Pint32(dest + 0)^ := ((p2 And $FF00000) Shl 4) Or ((p1 And $FF) Shl 16) Or ((p1 And $3FC00) Shr 2) Or ((p1 And $FF00000) Shr 20);
-    Pint32(dest + 4)^ := ((p3 And $3FC00) Shl 14) Or ((p3 And $FF00000) Shr 4) Or ((p2 And $FF) Shl 8) Or ((p2 And $3FC00) Shr 10);
-    Pint32(dest + 8)^ := ((p4 And $FF) Shl 24) Or ((p4 And $3FC00) Shl 6) Or ((p4 And $FF00000) Shr 12) Or (p3 And $FF);
-    
+    if count = 0 then
+      exit;
+  end;
+
+  c := count shr 2;
+  while c > 0 do
+  begin
+    p1 := (PUint32(source) + (x shr 16))^;
+    p2 := (PUint32(source) + ((x + inc_source) shr 16))^;
+    p3 := (PUint32(source) + ((x + 2*inc_source) shr 16))^;
+    p4 := (PUint32(source) + ((x + 3*inc_source) shr 16))^;
+
+    {$IFDEF FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p2 and $FF00000) shl 4) or ((p1 and $FF) shl 16) or ((p1 and $3FC00) shr 2) or ((p1 and $FF00000) shr 20);
+    PUint32(dest + 4)^ := ((p3 and $3FC00) shl 14) or ((p3 and $FF00000) shr 4) or ((p2 and $FF) shl 8) or ((p2 and $3FC00) shr 10);
+    PUint32(dest + 8)^ := ((p4 and $FF) shl 24) or ((p4 and $3FC00) shl 6) or ((p4 and $FF00000) shr 12) or (p3 and $FF);
+    {$ELSE FPC_LITTLE_ENDIAN}
+    PUint32(dest + 0)^ := ((p1 and $FF) shl 24) or ((p1 and $3FC00) shl 6) or ((p1 and $FF00000) shr 12) or (p2 and $FF);
+    PUint32(dest + 4)^ := ((p2 and $3FC00) shl 14) or ((p2 and $FF00000) shr 4) or ((p3 and $FF) shl 8) or ((p3 and $3FC00) shr 10);
+    PUint32(dest + 8)^ := ((p3 and $FF00000) shl 4) or ((p4 and $FF) shl 16) or ((p4 and $3FC00) shr 2) or ((p4 and $FF00000) shr 20);
+    {$ENDIF FPC_LITTLE_ENDIAN}
+
     Dec(c);
     Inc(x, inc_source*4);
     Inc(dest, 12);
-  End;
-  
-  count := count And 3;
-  While count > 0 Do
-  Begin
-    p1 := (Pint32(source) + (x Shr 16))^;
-    p1 := ((p1 And $ff) Shl 16) Or
-          ((p1 And ($ff Shl 10)) Shr 2) Or
-          ((p1 And ($ff Shl 20)) Shr 20);
-    Pshort16(dest)^ := p1 And $FFFF;
-    Pchar8(dest + 2)^ := p1 Shr 16;
-    
+  end;
+
+  count := count and 3;
+  while count > 0 do
+  begin
+    p1 := (PUint32(source) + (x shr 16))^;
+    p1 := ((p1 and $ff) shl 16) or
+          ((p1 and ($ff shl 10)) shr 2) or
+          ((p1 and ($ff shl 20)) shr 20);
+    PUint8(dest + B_24)^ := p1 and $FF;
+    PUint8(dest + G_24)^ := (p1 shr 8) and $FF;
+    PUint8(dest + R_24)^ := p1 shr 16;
+
     Inc(x, inc_source);
     Inc(dest, 3);
     Dec(count);
-  End;
-End;
-
-Procedure ConvertP_muhmu32_16rgb565_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  end;
+end;
+
+procedure ConvertP_muhmu32_16rgb565_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Try to write 2 pixel blocks }
-  c := count Shr 1; 
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 12) And $f800) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 7) And $7e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
+    p := ((((PUint32(source) + (x shr 16))^ shr 12) and $f800) or
+          (((PUint32(source) + (x shr 16))^ shr 7) and $7e0) or
+          (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 12) And $f800) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 7) And $7e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 12) and $f800) or
+         (((PUint32(source) + (x shr 16))^ shr 7) and $7e0) or
+         (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 12) And $f800) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 7) And $7e0) Or
-	               (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
-End;
-
-Procedure ConvertP_muhmu32_16bgr565_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 12) and $f800) or
+                       (((PUint32(source) + (x shr 16))^ shr 7) and $7e0) or
+                       (((PUint32(source) + (x shr 16))^ shr 3) and $1f);
+end;
+
+procedure ConvertP_muhmu32_16bgr565_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Try to write 2 pixel blocks }
-  c := count Shr 1; 
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 23) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 7) And $7e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shl 8) And $f800);
+    p := ((((PUint32(source) + (x shr 16))^ shr 23) and $1f) or
+          (((PUint32(source) + (x shr 16))^ shr 7) and $7e0) or
+          (((PUint32(source) + (x shr 16))^ shl 8) and $f800)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 23) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 7) And $7e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shl 8) And $f800)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 23) and $1f) or
+         (((PUint32(source) + (x shr 16))^ shr 7) and $7e0) or
+         (((PUint32(source) + (x shr 16))^ shl 8) and $f800)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 23) And $1f) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 7) And $7e0) Or
-	               (((Pint32(source) + (x Shr 16))^ Shl 8) And $f800);
-End;
-
-Procedure ConvertP_muhmu32_16rgb555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 23) and $1f) or
+                       (((PUint32(source) + (x shr 16))^ shr 7) and $7e0) or
+                       (((PUint32(source) + (x shr 16))^ shl 8) and $f800);
+end;
+
+procedure ConvertP_muhmu32_16rgb555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Try to write 2 pixel blocks }
-  c := count Shr 1; 
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 13) And $7c00) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 8) And $3e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
+    p := ((((PUint32(source) + (x shr 16))^ shr 13) and $7c00) or
+          (((PUint32(source) + (x shr 16))^ shr 8) and $3e0) or
+          (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 13) And $7c00) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 8) And $3e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 13) and $7c00) or
+         (((PUint32(source) + (x shr 16))^ shr 8) and $3e0) or
+         (((PUint32(source) + (x shr 16))^ shr 3) and $1f)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 13) And $7c00) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 8) And $3e0) Or
-	               (((Pint32(source) + (x Shr 16))^ Shr 3) And $1f);
-End;
-
-Procedure ConvertP_muhmu32_16bgr555_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 13) and $7c00) or
+                       (((PUint32(source) + (x shr 16))^ shr 8) and $3e0) or
+                       (((PUint32(source) + (x shr 16))^ shr 3) and $1f);
+end;
+
+procedure ConvertP_muhmu32_16bgr555_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
   { Try to write 2 pixel blocks }
-  c := count Shr 1; 
-  While c <> 0 Do
-  Begin
+  c := count shr 1;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 23) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 8) And $3e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shl 7) And $7c00);
+    p := ((((PUint32(source) + (x shr 16))^ shr 23) and $1f) or
+          (((PUint32(source) + (x shr 16))^ shr 8) and $3e0) or
+          (((PUint32(source) + (x shr 16))^ shl 7) and $7c00)) shl DWORD_SMALLINT0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 23) And $1f) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 8) And $3e0) Or
-	 (((Pint32(source) + (x Shr 16))^ Shl 7) And $7c00)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 23) and $1f) or
+         (((PUint32(source) + (x shr 16))^ shr 8) and $3e0) or
+         (((PUint32(source) + (x shr 16))^ shl 7) and $7c00)) shl DWORD_SMALLINT1_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write trailing pixel }
-  If (count And 1) <> 0 Then
-    Pshort16(dest)^ := (((Pint32(source) + (x Shr 16))^ Shr 23) And $1f) Or
-                       (((Pint32(source) + (x Shr 16))^ Shr 8) And $3e0) Or
-	               (((Pint32(source) + (x Shr 16))^ Shl 7) And $7c00);
-End;
-
-Procedure ConvertP_muhmu32_8rgb332_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
-
-Var
-  x, c : DWord;
-  p : int32;
-
-Begin
+  if (count and 1) <> 0 then
+    PUint16(dest)^ := (((PUint32(source) + (x shr 16))^ shr 23) and $1f) or
+                       (((PUint32(source) + (x shr 16))^ shr 8) and $3e0) or
+                       (((PUint32(source) + (x shr 16))^ shl 7) and $7c00);
+end;
+
+procedure ConvertP_muhmu32_8rgb332_S(source, dest: PUint8; count, inc_source: DWord); cdecl;
+var
+  x, c: DWord;
+  p: Uint32;
+begin
   x := 0;
 
   { Write single pixels until the destination address is aligned mod 4 }
-  While (PtrUInt(dest) And $3) <> 0 Do
-  Begin
-    dest^ := (((Pint32(source) + (x Shr 16))^ Shr 20) And $e0) Or
-             (((Pint32(source) + (x Shr 16))^ Shr 13) And $1c) Or
-	     (((Pint32(source) + (x Shr 16))^ Shr 6) And $3);
+  while (PtrUInt(dest) and $3) <> 0 do
+  begin
+    dest^ := (((PUint32(source) + (x shr 16))^ shr 20) and $e0) or
+             (((PUint32(source) + (x shr 16))^ shr 13) and $1c) or
+             (((PUint32(source) + (x shr 16))^ shr 6) and $3);
     Inc(x, inc_source);
     Inc(dest);
     Dec(count);
-    If count = 0 Then
-      Exit;
-  End;
+    if count = 0 then
+      exit;
+  end;
 
   { Write blocks of four pixels now }
-  c := count Shr 2;
-  While c <> 0 Do
-  Begin
+  c := count shr 2;
+  while c <> 0 do
+  begin
     Dec(c);
-    p := (((Pint32(source) + (x Shr 16))^ Shr 20) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 13) And $1c) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 6) And $3);
+    p := ((((PUint32(source) + (x shr 16))^ shr 20) and $e0) or
+          (((PUint32(source) + (x shr 16))^ shr 13) and $1c) or
+          (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE0_SHL;
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 20) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 13) And $1c) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 6) And $3)) Shl 8);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 20) and $e0) or
+         (((PUint32(source) + (x shr 16))^ shr 13) and $1c) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE1_SHL);
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 20) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 13) And $1c) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 6) And $3)) Shl 16);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 20) and $e0) or
+         (((PUint32(source) + (x shr 16))^ shr 13) and $1c) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE2_SHL);
     Inc(x, inc_source);
 
-    p := p Or
-       (((((Pint32(source) + (x Shr 16))^ Shr 20) And $e0) Or
-         (((Pint32(source) + (x Shr 16))^ Shr 13) And $1c) Or
-	 (((Pint32(source) + (x Shr 16))^ Shr 6) And $3)) Shl 24);
+    p := p or
+       (((((PUint32(source) + (x shr 16))^ shr 20) and $e0) or
+         (((PUint32(source) + (x shr 16))^ shr 13) and $1c) or
+         (((PUint32(source) + (x shr 16))^ shr 6) and $3)) shl DWORD_BYTE3_SHL);
     Inc(x, inc_source);
 
-    Pint32(dest)^ := p;
+    PUint32(dest)^ := p;
 
     Inc(dest, 4);
-  End;
+  end;
 
   { Write up to three trailing pixels }
-  c := count And $3;
-  While c <> 0 Do
-  Begin
+  c := count and $3;
+  while c <> 0 do
+  begin
     Dec(c);
-    dest^ := (((Pint32(source) + (x Shr 16))^ Shr 20) And $e0) Or
-             (((Pint32(source) + (x Shr 16))^ Shr 13) And $1c) Or
-	     (((Pint32(source) + (x Shr 16))^ Shr 6) And $3);
+    dest^ := (((PUint32(source) + (x shr 16))^ shr 20) and $e0) or
+             (((PUint32(source) + (x shr 16))^ shr 13) and $1c) or
+             (((PUint32(source) + (x shr 16))^ shr 6) and $3);
     Inc(x, inc_source);
     Inc(dest);
-  End;
-End;
+  end;
+end;

+ 0 - 348
packages/hermes/src/palette.inc

@@ -1,348 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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
-}
-
-Type
-  PHermesLookupTable = ^THermesLookupTable;
-  THermesLookupTable = Record
-    data : ^int32;             { Actual lookup table }
-    valid : Boolean;           { Is this table up to date? }
-    format : THermesFormat;    { Format of lookup table }
-  End;
-  PHermesPalette = ^THermesPalette;
-  THermesPalette = Record
-    data : ^int32;             { Palette data }
-    tables : PHermesList;      { Linked list of HermesLookupTables }
-  End;
-
-Const
-  PaletteList : PHermesList = Nil;
-  PALETTErefcount : Integer = 0;
-  currenthandle : THermesHandle = 0;
-
-{Function Hermes_PaletteGetTable(palette : THermesHandle; format : PHermesFormat) : Pointer;
-Procedure Hermes_PaletteMakeLookup(lookup, palette : Pint32;
-                                   format : PHermesFormat);
-
-Function Hermes_PaletteInstance : THermesHandle;
-Procedure Hermes_PaletteReturn(handle : THermesHandle);
-Procedure Hermes_PaletteSet(handle : THermesHandle; palette : Pointer);
-Function Hermes_PaletteGet(handle : THermesHandle) : Pointer;
-Procedure Hermes_PaletteInvalidateCache(handle : THermesHandle);}
-
-Function Hermes_PaletteInstance : THermesHandle;
-
-Var
-  newinstance : PHermesPalette;
-  newelement : PHermesListElement;
-
-Begin
-  If PaletteList = Nil Then
-  Begin
-    PaletteList := Hermes_ListNew;
-    { Could not create a new list }
-    If PaletteList = Nil Then
-    Begin
-      Hermes_PaletteInstance := 0;
-      Exit;
-    End;
-  End;
-  { Create a new palette structure }
-  newinstance := malloc(SizeOf(THermesPalette));
-  If newinstance = Nil Then
-  Begin
-    Hermes_PaletteInstance := 0;
-    Exit;
-  End;
-  { Create palette data }
-  newinstance^.data := malloc(256*SizeOf(int32));
-  If newinstance^.data = Nil Then
-  Begin
-    free(newinstance);
-    Hermes_PaletteInstance := 0;
-    Exit;
-  End;
-  { Create lookup table list }
-  newinstance^.tables := Hermes_ListNew;
-  If newinstance^.tables = Nil Then
-  Begin
-    free(newinstance^.data);
-    free(newinstance);
-    Hermes_PaletteInstance := 0;
-    Exit;
-  End;
-  { Everything fine so far, create a new list element }
-  newelement := Hermes_ListElementNew(currenthandle+1);
-  If newelement = Nil Then
-  Begin
-    Hermes_ListDestroy(newinstance^.tables);
-    free(newinstance^.data);
-    free(newinstance);
-    Hermes_PaletteInstance := 0;
-    Exit;
-  End;
-
-  { No errors, put current palette structure into the list element and add
-    that to the list }
-  newelement^.data := newinstance;
-
-  Hermes_ListAdd(PaletteList, newelement);
-
-  Inc(PALETTErefcount);
-  Inc(currenthandle);
-  Hermes_PaletteInstance := currenthandle;
-End;
-
-Procedure Hermes_PaletteReturn(handle : THermesHandle);
-
-Var
-  element : PHermesListElement;
-  pal : PHermesPalette;
-  table : PHermesLookupTable;
-
-Begin
-  element := Hermes_ListLookup(PaletteList, handle);
-  If element = Nil Then
-    Exit;
-
-  pal := element^.data;
-
-
-  { Free palette data and lookup tables }
-  free(pal^.data);
-
-  element := pal^.tables^.first;
-  While element <> Nil Do
-  Begin
-    table := element^.data;
-    If (table <> Nil) And (table^.data <> Nil) Then
-    Begin
-      free(table^.data);
-      table^.data := Nil;
-    End;
-    element := element^.next;
-  End;
-  Hermes_ListDestroy(pal^.tables);
-
-
-  { Delete list element that holds this palette }
-  Hermes_ListDeleteElement(PaletteList, handle);
-
-
-  { Decrease reference count. If down to zero, delete palette list }
-  Dec(PALETTErefcount);
-  If PALETTErefcount = 0 Then
-  Begin
-    Hermes_ListDestroy(PaletteList);
-    PaletteList := Nil;
-  End;
-End;
-
-Procedure Hermes_PaletteSet(handle : THermesHandle; palette : Pointer);
-
-Var
-  element : PHermesListElement;
-  pal : PHermesPalette;
-
-Begin
-{  DebugMSG('Hermes_PaletteSet('+C2Str(handle)+','+C2Str(DWord(palette))+')');}
-  element := Hermes_ListLookup(PaletteList, handle);
-  If element = Nil Then
-    Exit;
-
-  pal := element^.data;
-  element := pal^.tables^.first;
-
-  { Invalidate all lookup tables }
-
-  While element <> Nil Do
-  Begin
-    (PHermesLookupTable(element^.data))^.valid := False;
-    element := element^.next;
-  End;
-
-{  FillChar(palette^, 256*4, $7f);}
-  Move(palette^, pal^.data^, 256*4);
-End;
-
-Function Hermes_PaletteGet(handle : THermesHandle) : Pointer;
-
-Var
-  element : PHermesListElement;
-  pal : PHermesPalette;
-
-Begin
-  element := Hermes_ListLookup(PaletteList, handle);
-  If element = Nil Then
-  Begin
-    Hermes_PaletteGet := Nil;
-    Exit;
-  End;
-
-  pal := element^.data;
-  Hermes_PaletteGet := pal^.data;
-End;
-
-Procedure Hermes_PaletteMakeLookup(lookup, palette : Pint32;
-                                   format : PHermesFormat);
-
-Var
-  info : THermesGenericInfo;
-  I : Integer;
-  r, g, b : int32;
-
-Begin
-{  DebugMSG('Yo! Hermes_PaletteMakeLookup');}
-  r := 0;
-  g := 0;
-  b := 0;
-  If format^.indexed Then
-    Exit;
-
-  Hermes_Calculate_Generic_Info(24,16,8,32,
-                                Hermes_Topbit(format^.r),
-                                Hermes_Topbit(format^.g),
-                                Hermes_Topbit(format^.b),
-                                Hermes_Topbit(format^.a),
-                                @info);
-
-  { Optimised loop if there are no left shifts }
-  If (info.r_left = 0) And (info.g_left = 0) And (info.b_left = 0) Then
-    For I := 0 To 255 Do
-    Begin
-      r := (palette[i] Shr info.r_right) And format^.r;
-      g := (palette[i] Shr info.g_right) And format^.g;
-      b := (palette[i] Shr info.b_right) And format^.b;
-      lookup[i] := r Or g Or b;
-    End
-  Else
-    For I := 0 To 255 Do
-    Begin
-      r := ((palette[i] Shr info.r_right) Shl info.r_left) And format^.r;
-      g := ((palette[i] Shr info.g_right) Shl info.g_left) And format^.g;
-      b := ((palette[i] Shr info.b_right) Shl info.b_left) And format^.b;
-      lookup[i] := r Or g Or b;
-    End;
-End;
-
-Function Hermes_PaletteGetTable(palette : THermesHandle; format : PHermesFormat) : Pointer;
-
-Var
-  element : PHermesListElement;
-  pal : PHermesPalette;
-  table : PHermesLookupTable;
-
-Begin
-  element := Hermes_ListLookup(PaletteList, palette);
-  If element = Nil Then
-  Begin
-    Hermes_PaletteGetTable := Nil;
-    Exit;
-  End;
-
-  pal := element^.data;
-
-  { Go to the first table in the list }
-  element := pal^.tables^.first;
-
-  { Search for correct table using format }
-  While element <> Nil Do
-  Begin
-    table := element^.data;
-
-    If Hermes_FormatEquals(@table^.format, format) Then
-    Begin
-      If table^.valid Then
-      Begin
-        Hermes_PaletteGetTable := table^.data;
-        Exit;
-      End;
-
-      { Have to recreate the lookup table }
-      Hermes_PaletteMakeLookup(table^.data, pal^.data, format);
-      table^.valid := True;
-
-      Hermes_PaletteGetTable := table^.data;
-      Exit;
-    End;
-
-    element := element^.next;
-  End;
-
-  { Format not found, have to create a new table (need no handle) }
-  table := malloc(SizeOf(THermesLookupTable));
-  If table = Nil Then
-  Begin
-    Hermes_PaletteGetTable := Nil;
-    Exit;
-  End;
-
-  table^.data := malloc(1024);
-  If table^.data = Nil Then
-  Begin
-    Hermes_PaletteGetTable := Nil;
-    Exit;
-  End;
-
-  { Create lookup table }
-  Hermes_PaletteMakeLookup(table^.data, pal^.data, format);
-  Hermes_FormatCopy(format, @table^.format);
-
-  table^.valid := True;
-
-  { Create a new list element }
-  element := Hermes_ListElementNew(0);
-  If element = Nil Then
-  Begin
-    Hermes_PaletteGetTable := Nil;
-    Exit;
-  End;
-  element^.data := table;
-
-  { Add to the front of the list }
-  Hermes_ListAddFront(pal^.tables, element);
-
-  { Return lookup data }
-  Hermes_PaletteGetTable := table^.data;
-
-End;
-
-Procedure Hermes_PaletteInvalidateCache(handle : THermesHandle);
-
-Var
-  element : PHermesListElement;
-  pal : PHermesPalette;
-
-Begin
-  element := Hermes_ListLookup(PaletteList, handle);
-  If element = Nil Then
-    Exit;
-
-  pal := element^.data;
-
-  element := pal^.tables^.first;
-
-  { Invalidate all lookup tables }
-
-  While element <> Nil Do
-  Begin
-    (PHermesLookupTable(element^.data))^.valid := False;
-    element := element^.next;
-  End;
-End;

+ 0 - 111
packages/hermes/src/utility.inc

@@ -1,111 +0,0 @@
-{
-    Free Pascal port of the Hermes C library.
-    Copyright (C) 2001-2003  Nikolay Nikolov ([email protected])
-    Original C version by 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.
-
-    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 Hermes_Calculate_Generic_Info(s_r, s_g, s_b, s_a, 
-                                        d_r, d_g, d_b, d_a : int32;
-					info : PHermesGenericInfo);
-Function Hermes_Topbit(mask : int32) : Integer;}
-
-Procedure Hermes_Calculate_Generic_Info(s_r, s_g, s_b, s_a, 
-                                        d_r, d_g, d_b, d_a : Integer;
-					info : PHermesGenericInfo);
-
-Var
-  r_right, g_right, b_right, a_right : Integer;
-
-Begin
-  {Calculate right shift amount for red. If it's <0, then set it to 0
-   and calculate left shift amount}
-  r_right := s_r - d_r;
-  If r_right < 0 Then
-  Begin
-    info^.r_left := -r_right;
-    info^.r_right := 0;
-  End
-  Else
-  Begin
-    info^.r_left := 0;
-    info^.r_right := r_right;
-  End;
-  
-  {Same for green}
-  g_right := s_g - d_g;
-  If g_right < 0 Then
-  Begin
-    info^.g_left := -g_right;
-    info^.g_right := 0;
-  End
-  Else
-  Begin
-    info^.g_left := 0;
-    info^.g_right := g_right;
-  End;
-  
-  {Same for blue}
-  b_right := s_b - d_b;
-  If b_right < 0 Then
-  Begin
-    info^.b_left := -b_right;
-    info^.b_right := 0;
-  End
-  Else
-  Begin
-    info^.b_left := 0;
-    info^.b_right := b_right;
-  End;
-  
-  {Alpha}
-  a_right := s_a - d_a;
-  If a_right < 0 Then
-  Begin
-    info^.a_left := -a_right;
-    info^.a_right := 0;
-  End
-  Else
-  Begin
-    info^.a_left := 0;
-    info^.a_right := a_right;
-  End;
-End;
-
-Function Hermes_Topbit(mask : int32) : Integer;
-
-Var
-  i : Integer;
-
-Begin
-  If mask = 0 Then
-  Begin
-    Hermes_Topbit := 0;
-    Exit;
-  End;
-  i := 0;
-  While (mask And 1) = 0 Do
-  Begin
-    mask := mask Shr 1;
-    Inc(i);
-  End;
-  While (mask And 1) = 1 Do
-  Begin
-    mask := mask Shr 1;
-    Inc(i);
-  End;
-  Hermes_Topbit := i;
-End;