v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
abi/asset.h
1 /* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-
2  *
3  * Sifteo SDK
4  *
5  * Copyright <c> 2012 Sifteo, Inc.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  */
25 
26 #ifndef _SIFTEO_ABI_ASSET_H
27 #define _SIFTEO_ABI_ASSET_H
28 
29 #include <sifteo/abi/types.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 
36 #define _SYS_ASSETLOAD_BUF_SIZE 48 // Makes _SYSAssetLoaderCube come to 64 bytes
37 #define _SYS_MAX_ASSET_SLOTS 4 // Number of AssetSlots maximum per-program
38 #define _SYS_TILES_PER_ASSETSLOT 4096 // Number of tiles per AssetSlot
39 #define _SYS_ASSET_GROUPS_PER_SLOT 24 // Number of AssetGroups we can track per-slot
40 #define _SYS_ASSET_SLOTS_PER_BANK 4 // Number of AssetSlots maximum per-program
41 #define _SYS_ASSET_GROUP_SIZE_UNIT 16 // Basic unit of AssetGroup allocation, in tiles
42 #define _SYS_ASSET_GROUP_CRC_SIZE 16 // Number of bytes of AssetGroup CRC
43 
44 
45 struct _SYSAssetGroupHeader {
46  uint8_t reserved;
47  uint8_t ordinal;
48  uint16_t numTiles;
49  uint32_t dataSize;
50  uint8_t crc[_SYS_ASSET_GROUP_CRC_SIZE];
51  // Followed by compressed data
52 };
53 
54 struct _SYSAssetGroupCube {
55  uint16_t baseAddr;
56 };
57 
58 struct _SYSAssetGroup {
59  uint32_t pHdr;
60  // Followed by a _SYSAssetGroupCube array
61 };
62 
63 struct _SYSAssetLoaderCube {
64  uint32_t progress;
65  uint32_t total;
66  uint16_t reserved;
67  uint8_t head;
68  uint8_t tail;
69  uint8_t buf[_SYS_ASSETLOAD_BUF_SIZE];
70 };
71 
72 struct _SYSAssetLoader {
73  _SYSCubeIDVector busyCubes;
74  // Followed by a _SYSAssetLoaderCube array
75 };
76 
77 struct _SYSAssetConfiguration {
78  uint32_t pGroup;
79  _SYSVolumeHandle volume;
80  uint32_t dataSize;
81  uint16_t numTiles;
82  uint8_t ordinal;
83  _SYSAssetSlot slot;
84 };
85 
86 enum _SYSAssetImageFormat {
87  _SYS_AIF_PINNED = 0,
88  _SYS_AIF_FLAT,
89  _SYS_AIF_DUB_I8,
90  _SYS_AIF_DUB_I16,
91 };
92 
93 struct _SYSAssetImage {
94  uint32_t pAssetGroup;
95  uint16_t width;
96  uint16_t height;
97  uint16_t frames;
98  uint8_t format;
99  uint8_t reserved;
100  uint32_t pData;
101 };
102 
103 
104 #ifdef __cplusplus
105 } // extern "C"
106 #endif
107 
108 #endif