-
Notifications
You must be signed in to change notification settings - Fork 0
/
STBreader.h
115 lines (93 loc) · 2.71 KB
/
STBreader.h
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
// Smart Toybox Theme file reader
// TI PLATFORM implementation
//
// Copyright(C) 2016. Nebojsa Sumrak and Jelena (Petra) Markovic
//
// This program is free software; you can redistribute it and / or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA.
#pragma once
// set to remove unneeded functions on embedded systems
#define EMBEDDED 1
/***********************************************
STB file format:
-- Header (12b)
LONG id = 0xBABADEDA
CHAR numsounds
3 CHAR soundsize
CHAR nummusic
3 CHAR musicsize
-- SOUNDS INDEX for each numsounds
CHAR id
3 CHAR wvsize
-- MUSIC INDEX for each nummusic
CHAR type
CHAR plsize
-- SOUND DATA (soundsize) for each numsounds
CHAR wv[wvsize]
-- MUSIC DATA (musicsize) for each nummusic
CHAR playlist[plsize]
-- NAMES for each numsounds+nummusic
CHAR size
CHAR name[size]
************************************************/
#ifdef __cplusplus
extern "C" {
#endif
enum {
GAME_START = 0,
GAME_WIN,
GAME_LOSE,
GAME_MUSIC,
GAME_GIMME,
GAME_CHEW,
GAME_CHEW_GRAND,
GAME_GULP,
GAME_GULP_GRAND,
GAME_COMPLAIN,
GAME_GUARDIAN,
GAME_GUARDIAN_OFF,
GAME_GOOD_PROGRESS,
GAME_BAD_PROGRESS,
GUARDIAN,
GUARDIAN_OFF,
};
int stb_open(const char *filename);
void stb_close();
int stb_get_sound(unsigned char c, int *pos, int *size);
int stb_read(void *buf, int pos, int size);
int stb_get_music_num(unsigned char type);
int stb_get_music(char *buf, unsigned char type, int num);
#ifndef EMBEDDED
#include "platform.h"
#include <stdio.h>
void stb_get_sound_name(char *buf, int namenum);
void stb_get_music_name(char *buf, int namenum);
int stb_get_num_sounds();
int stb_get_num_musics();
void stb_get_sound_bynum(int num, unsigned char *id, int *pos, int *size);
void stb_get_music_bynum(int num, unsigned char *type, char *buf);
#define INVALID_FILE_HANDLE (0)
typedef FILE *filehandle;
inline filehandle open_file(const char *fn) { return fopen(fn, "rb"); }
#else
#include "platform.h"
typedef _i32 filehandle;
inline filehandle open_file(const char *fn) {
return fs_open(fn, FS_OPEN_MODE_READ);
}
#define INVALID_FILE_HANDLE (-1)
#endif
#ifdef __cplusplus
};
#endif