-
Notifications
You must be signed in to change notification settings - Fork 4
/
rwspriteanim.pas
204 lines (171 loc) · 5.45 KB
/
rwspriteanim.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
unit rwspriteanim;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils,LazFileUtils,rmcodegen,animbase,gwbasic;
procedure ExportAnimation(filename : string;Lan : Integer);
procedure WriteAnimationCodeToBuffer(var F : Text;AnimIndex : integer);
procedure WriteAllAnimationCodeToBuffer(var F : Text);
implementation
procedure ExportPascalAnimHeader(var mc : CodeGenRec; AnimIndex : integer);
var
FrameCount : integer;
ImageName : string;
begin
FrameCount:=AnimateBase.GetFrameCount(AnimIndex);
ImageName:=AnimateBase.GetExportName(AnimIndex);
MWSetLan(mc,PascalLan);
MWSetValueFormat(mc,ValueFormatDecimal);
MWSetValuesTotal(mc,FrameCount);
Writeln(mc.FTextPtr^,'(* Pascal Sprite Animation Code Created By Raster Master *)');
Writeln(mc.FTextPtr^,' ',Imagename,'_FrameCount = ',FrameCount,';');
Writeln(mc.FTextPtr^,' ',ImageName,' : array[0..',FrameCount-1,'] of integer = (');
end;
procedure ExportBasicAnimHeader(var mc : CodeGenRec; AnimIndex : integer);
var
FrameCount : integer;
ImageName : string;
begin
FrameCount:=AnimateBase.GetFrameCount(AnimIndex);
ImageName:=AnimateBase.GetExportName(AnimIndex);
MWSetLan(mc,BasicLan);
MWSetValueFormat(mc,ValueFormatDecimal);
MWSetValuesTotal(mc,FrameCount);
Writeln(mc.FTextPtr^,ImageName+'Label:');
Writeln(mc.FTextPtr^,#39,' Basic Sprite Animation Code Created By Raster Master');
Writeln(mc.FTextPtr^,#39,' ',Imagename,' Frame Count =',FrameCount);
end;
procedure ExportBasicLNAnimHeader(var mc : CodeGenRec; AnimIndex : integer);
var
FrameCount : integer;
ImageName : string;
begin
FrameCount:=AnimateBase.GetFrameCount(AnimIndex);
ImageName:=AnimateBase.GetExportName(AnimIndex);
MWSetValuesTotal(mc,FrameCount);
MWSetLan(mc,BasicLNLan);
MWSetValueFormat(mc,ValueFormatDecimal);
Writeln(mc.FTextPtr^,GetGWNextLineNumber,' ',#39,' Basic Sprite Animcation Code Created By Raster Master');
Writeln(mc.FTextPtr^,GetGWNextLineNumber,' ',#39,' ',Imagename,' Frame Count=',FrameCount);
end;
procedure ExportCAnimHeader(var mc : CodeGenRec; AnimIndex : integer);
var
FrameCount : integer;
ImageName : string;
begin
FrameCount:=AnimateBase.GetFrameCount(AnimIndex);
ImageName:=AnimateBase.GetExportName(AnimIndex);
MWSetValuesTotal(mc,FrameCount);
MWSetLan(mc,CLan);
MWSetValueFormat(mc,ValueFormatDecimal);
Writeln(mc.FTextPtr^,'/* C Sprite Animation Code Created By Raster Master */');
Writeln(mc.FTextPtr^,'#define ',Imagename,'_FrameCount ', FrameCount);
Writeln(mc.FTextPtr^,' ','int ',Imagename, '[',FrameCount,'] = {');
end;
procedure WriteAnimationCodeToBuffer(var F : Text;AnimIndex : integer);
var
AnimProps : AnimExportFormatRec;
FrameCount : integer;
ImageName : string;
mc : CodeGenRec;
Lan : integer;
j : integer;
begin
FrameCount:=AnimateBase.GetFrameCount(AnimIndex);
AnimateBase.GetAnimExportProps(AnimIndex,AnimProps);
if (AnimProps.Lan > 0) and (AnimProps.AnimateFormat > 0) then
begin
MWInit(mc,F);
MWSetValuesTotal(mc,FrameCount);
Lan:=AnimProps.Lan;
Imagename:=AnimProps.Name;
//write header
Case Lan of BasicLan,BAMBasicLan,FBBasicLan,QB64BasicLan,AQBBasicLan:ExportBasicAnimHeader(mc,AnimIndex);
BasicLnLan:ExportBasicLNAnimHeader(mc,AnimIndex);
CLan:ExportCAnimHeader(mc,AnimIndex);
PascalLan:ExportPascalAnimHeader(mc,AnimIndex);
End;
//write frame values
For j:=0 to FrameCount-1 do
begin
MWWriteInteger(mc,AnimateBase.GetImageIndex(AnimIndex,j));
end;
Case Lan of BasicLan,FBBasicLan,QB64BasicLan,AQBBasicLan,BasicLNLan:Writeln(F);
CLan:Writeln(F,'};');
PascalLan:Writeln(F,');');
End;
end;
end;
procedure WriteAllAnimationCodeToBuffer(var F : Text);
var
i : integer;
begin
for i:=0 to AnimateBase.GetAnimationCount-1 do
begin
WriteAnimationCodeToBuffer(F,i);
end;
end;
procedure ExportAnimMain(var mc : CodeGenRec; AnimIndex : integer);
var
FrameCount : integer;
i : integer;
begin
FrameCount:=AnimateBase.GetFrameCount(AnimIndex);
//write frame values
For i:=0 to FrameCount-1 do
begin
MWWriteInteger(mc,AnimateBase.GetImageIndex(AnimIndex,i));
end;
end;
procedure ExportAnimation(filename : string;Lan : Integer);
var
mc : CodeGenRec;
AnimIndex : integer;
ImageName : String;
F : Text;
begin
SetGWStartLineNumber(1000);
MWInit(mc,F);
Imagename:=ExtractFileName(ExtractFileNameWithoutExt(filename));
{$I-}
Assign(F,Filename);
Rewrite(F);
{$I+}
if IORESULT<>0 then exit;
AnimIndex:=AnimateBase.GetCurrentAnimation;
Case Lan of BasicLan,BAMBasicLan,FBBasicLan,QB64BasicLan,AQBBasicLan:ExportBasicAnimHeader(mc,AnimIndex);
BasicLnLan:ExportBasicLNAnimHeader(mc,AnimIndex);
CLan:ExportCAnimHeader(mc,AnimIndex);
PascalLan:ExportPascalAnimHeader(mc,AnimIndex);
End;
ExportAnimMain(mc,AnimIndex);
Case Lan of BasicLan,BasicLNLan:Writeln(F);
CLan:Writeln(F,'};');
PascalLan:Writeln(F,');');
End;
{$I-}
close(F);
{$I+}
end;
procedure ExportAllAnimation(filename : string);
var
mc : CodeGenRec;
AnimIndex : integer;
F : Text;
begin
SetGWStartLineNumber(1000);
MWInit(mc,F);
{$I-}
Assign(F,Filename);
Rewrite(F);
{$I+}
if IORESULT<>0 then exit;
for AnimIndex:=0 to AnimateBase.GetAnimationCount-1 do
begin
WriteAnimationCodeToBuffer(F,AnimIndex);
end;
{$I-}
close(F);
{$I+}
end;
end.