| 1 | #pragma once |
| 2 | #include <stdint.h> |
| 3 | #include <string.h> |
| 4 | |
| 5 | // Sounds are unsigned 8-bit mono PCM |
| 6 | |
| 7 | #pragma pack(push, 1) |
| 8 | typedef struct |
| 9 | { |
| 10 | uint16_t chunkCount; |
| 11 | uint16_t firstSprite; |
| 12 | uint16_t firstSound; |
| 13 | } CWVSwapHead; |
| 14 | #pragma pack(pop) |
| 15 | |
| 16 | typedef struct |
| 17 | { |
| 18 | uint32_t off; |
| 19 | uint16_t len; |
| 20 | } CWVSwapSound; |
| 21 | |
| 22 | typedef struct |
| 23 | { |
| 24 | CWVSwapHead head; |
| 25 | uint32_t *chunkOffset; |
| 26 | uint16_t *chunkLength; |
| 27 | char *data; |
| 28 | size_t dataLen; |
| 29 | CWVSwapSound *sounds; |
| 30 | int nSounds; |
| 31 | } CWVSwap; |
| 32 | |
| 33 | int CWVSwapLoad(CWVSwap *vswap, const char *path); |
| 34 | void CWVSwapFree(CWVSwap *vswap); |
| 35 | |
| 36 | int CWVSwapGetSound( |
| 37 | const CWVSwap *vswap, const int i, const char **data, size_t *len); |