1 |
REM > JLibraries:Sprite.2 |
2 |
|
3 |
REM JB 19 Nov 1997 created |
4 |
|
5 |
|
6 |
DEF PROCSprite_LoadFile(Path$, Fixd%, Name$) |
7 |
LOCAL Buff%, Type%, Siz1%, Siz2%, Siz3%, Sqsh%, Work% |
8 |
|
9 |
SYS"OS_File", 17, Path$ TO File%,, Type%,, Siz1% |
10 |
IF File% = 0 THEN ERROR 1, FNMess_Global1("NoFile", Path$) |
11 |
IF File% <> 1 THEN ERROR 1, FNMess_Global1("IsntFil", Path$) |
12 |
Type% = (Type% AND &FFF00) / &100 |
13 |
|
14 |
CASE Type% OF |
15 |
WHEN &FF9 |
16 |
Siz2% = Siz1% |
17 |
WHEN &FCA |
18 |
Sqsh% = FNHeap_Safe(Siz1%, 0, "_Sqsh") |
19 |
SYS"OS_File", 16, Path$, Sqsh% |
20 |
Siz2% = Sqsh%!04 |
21 |
OTHERWISE |
22 |
ERROR 1, "'" + Path$ + "' is not a sprite file or squashed sprite file" |
23 |
ENDCASE |
24 |
|
25 |
IF Fixd% THEN |
26 |
DIM Buff% Siz2% + 8 |
27 |
!Buff% = Buff% + 4 |
28 |
ELSE |
29 |
Buff% = FNHeap_Alloc(Siz2% + 4) |
30 |
IF Buff% = 0 THEN ERROR Erro_Memo%, "" |
31 |
ENDIF |
32 |
BuffB% = !Buff% |
33 |
!BuffB% = Siz2% + 4 |
34 |
|
35 |
CASE Type% OF |
36 |
WHEN &FF9 |
37 |
SYS"OS_SpriteOp", 265, BuffB% |
38 |
SYS"OS_SpriteOp", 266, BuffB%, Path$ |
39 |
WHEN &FCA |
40 |
SYS"Squash_Decompress", %1000, -1 TO Siz3% |
41 |
Work% = FNHeap_Safe(Siz3%, 0, "_Work") |
42 |
SYS"Squash_Decompress", %100, Work%, Sqsh% + 20, Siz1% - 20, BuffB% + 4, Siz2% |
43 |
PROCHeap_Lose(0, "_Sqsh") |
44 |
PROCHeap_Lose(0, "_Work") |
45 |
ENDCASE |
46 |
|
47 |
PROCObject_Add(6, Buff%, 0, Name$) |
48 |
SYS"WimpExt_Heap", 6 |
49 |
ENDPROC |