chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Steel / c / resspr
1 /*
2  * resspr.c
3  *
4  * Loading sprites
5  *
6  * © 1994-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Steel library.
12  *
13  * Steel is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * Steel is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with Steel.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #include <stdlib.h>
29
30 #include "os.h"
31 #include "resspr.h"
32 #include "mem.h"
33 #include "msgs.h"
34 #include "werr.h"
35 #include "res.h"
36
37 static sprite_area *resspr__area=(sprite_area *)1;
38
39 /*
40  * void resspr_init(void)
41  *
42  * Use
43  *  Loads the applications `Sprites' file into memory.
44  */
45
46 void resspr_init(void)
47 {
48   os_filestr f;
49   int size;
50
51   /* --- Find the file and it's length --- */
52
53   f.name=res_name("Sprites");
54   f.action=17;
55   if (os_file(&f) || f.action!=1)
56     return;
57
58   /* --- Create a buffer the right size --- *
59    *
60    * The sprite file size may not be word aligned -- cope with this.
61    */
62
63   size=(f.start+7) & ~3;
64   resspr__area=mem_alloc(size);
65   if (!resspr__area)
66   {
67     werr(FALSE,msgs_lookup("ressprNEM:Not enough memory to load sprites."));
68     exit(0);
69   }
70
71   /* --- Load the sprites into memory --- */
72
73   resspr__area->size=size;
74   f.action=16;
75   f.loadaddr=((int)resspr__area)+4;
76   f.execaddr=0;
77   os_file(&f);
78 }
79
80 /*
81  * sprite_area *resspr_area(void)
82  *
83  * Use
84  *  Returns the address of the application's sprite area.
85  */
86
87 sprite_area *resspr_area(void)
88 {
89   return (resspr__area);
90 }