~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to packages/extra/hermes/p_cpy.inc

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
    Free Pascal port of the Hermes C library.
 
3
    Copyright (C) 2001-2003  Nikolay Nikolov (nickysn@users.sourceforge.net)
 
4
    Original C version by Christian Nentwich (c.nentwich@cs.ucl.ac.uk)
 
5
 
 
6
    This library is free software; you can redistribute it and/or
 
7
    modify it under the terms of the GNU Lesser General Public
 
8
    License as published by the Free Software Foundation; either
 
9
    version 2.1 of the License, or (at your option) any later version.
 
10
 
 
11
    This library is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
    Lesser General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU Lesser General Public
 
17
    License along with this library; if not, write to the Free Software
 
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
}
 
20
 
 
21
{
 
22
   C straight copy routines for the HERMES library
 
23
   Copyright (c) 1998 Christian Nentwich (c.nentwich@cs.ucl.ac.uk)
 
24
   This source code is licensed under the GNU LGPL
 
25
 
 
26
   Please refer to the file COPYING.LIB contained in the distribution for
 
27
   licensing conditions
 
28
}
 
29
 
 
30
Procedure CopyP_4byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
31
 
 
32
Begin
 
33
  Move(source^, dest^, count Shl 2);
 
34
End;
 
35
 
 
36
Procedure CopyP_3byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
37
 
 
38
Begin
 
39
  Move(source^, dest^, count * 3);
 
40
End;
 
41
 
 
42
Procedure CopyP_2byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
43
 
 
44
Begin
 
45
  Move(source^, dest^, count Shl 1);
 
46
End;
 
47
 
 
48
Procedure CopyP_1byte(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
49
 
 
50
Begin
 
51
  Move(source^, dest^, count);
 
52
End;
 
53
 
 
54
Procedure CopyP_4byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
55
 
 
56
Var
 
57
  x : DWord;
 
58
 
 
59
Begin
 
60
  x := 0;
 
61
  Repeat
 
62
    Pint32(dest)^ := (Pint32(source)+(x Shr 16))^;
 
63
 
 
64
    Inc(x, inc_source);
 
65
    Inc(dest, 4);
 
66
    Dec(count);
 
67
  Until count = 0;
 
68
End;
 
69
 
 
70
{ TODO: Optimise }
 
71
Procedure CopyP_3byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
72
 
 
73
Var
 
74
  x : DWord;
 
75
 
 
76
Begin
 
77
  x := 0;
 
78
  Repeat
 
79
    dest[R_24] := source[R_24];
 
80
    dest[G_24] := source[G_24];
 
81
    dest[B_24] := source[B_24];
 
82
 
 
83
    Inc(x, inc_source);
 
84
    Inc(source, 3*(x Shr 16));
 
85
    x := x And $FFFF;
 
86
    Inc(dest, 3);
 
87
    Dec(count);
 
88
  Until count = 0;
 
89
End;
 
90
 
 
91
Procedure CopyP_2byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
92
 
 
93
Var
 
94
  x, c : DWord;
 
95
  p : int32;
 
96
 
 
97
Begin
 
98
  x := 0;
 
99
  { Alignment mod 4 }
 
100
  If (PtrUInt(dest) And 3) <> 0 Then
 
101
  Begin
 
102
    Pshort16(dest)^ := (Pshort16(source) + (x Shr 16))^;
 
103
    Inc(x, inc_source);
 
104
    Inc(dest, 2);
 
105
    Dec(count);
 
106
  End;
 
107
 
 
108
  c := count Shr 1;
 
109
 
 
110
  While c <> 0 Do
 
111
  Begin
 
112
    Dec(c);
 
113
    { TODO: make fast :) }
 
114
    p := (Pshort16(source) + (x Shr 16))^; Inc(x, inc_source);
 
115
    p := p Or ((Pshort16(source) + (x Shr 16))^ Shl 16);
 
116
    Inc(x, inc_source);
 
117
 
 
118
    Pint32(dest)^ := p;
 
119
    Inc(dest, 4);
 
120
  End;
 
121
 
 
122
  If (count And 1) <> 0 Then
 
123
    Pshort16(dest)^ := (Pshort16(source) + (x Shr 16))^;
 
124
End;
 
125
 
 
126
Procedure CopyP_1byte_S(source, dest : Pchar8; count, inc_source : DWord); CDecl;
 
127
 
 
128
Var
 
129
  x, c : DWord;
 
130
  p : int32;
 
131
 
 
132
Begin
 
133
  x := 0;
 
134
  { Alignment mod 4 }
 
135
  While (PtrUInt(dest) And 3) <> 0 Do
 
136
  Begin
 
137
    dest^ := (source + (x Shr 16))^;
 
138
    Inc(x, inc_source);
 
139
    Inc(dest); Dec(count);
 
140
    If count = 0 Then
 
141
      Exit;
 
142
  End;
 
143
 
 
144
  { Write blocks of four pixels }
 
145
  c := count Shr 2;
 
146
  While c <> 0 Do
 
147
  Begin
 
148
    Dec(c);
 
149
    p := (source + (x Shr 16))^; Inc(x, inc_source);
 
150
    p := p Or ((source + (x Shr 16))^ Shl 8); Inc(x, inc_source);
 
151
    p := p Or ((source + (x Shr 16))^ Shl 16); Inc(x, inc_source);
 
152
    p := p Or ((source + (x Shr 16))^ Shl 24); Inc(x, inc_source);
 
153
 
 
154
    Pint32(dest)^ := p;
 
155
    Inc(dest, 4);
 
156
  End;
 
157
 
 
158
  { Write up to three trailing pixels }
 
159
  c := count And $3;
 
160
  While c <> 0 Do
 
161
  Begin
 
162
    Dec(c);
 
163
    dest^ := (source + (x Shr 16))^;
 
164
    Inc(x, inc_source);
 
165
    Inc(dest);
 
166
  End;
 
167
End;