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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#include "Support.h"
#include "Files.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "SDL.h"
void Microseconds(UnsignedWide *microTickCount)
{
/* NOTE: hi isn't used in BS, so it's not implemented here */
/* TODO: does game need microsecond precision? */
microTickCount->hi = 0;
microTickCount->lo = SDL_GetTicks() * 1000;
}
void GetMouse(Point *p)
{
STUB_FUNCTION;
}
void GetKeys(unsigned long *keys)
{
STUB_FUNCTION;
}
int Button(void)
{
STUB_FUNCTION;
return 0;
}
void InitMouse()
{
STUB_FUNCTION;
}
void MoveMouse(int xcoord, int ycoord, Point *mouseloc)
{
STUB_FUNCTION;
}
void DisposeMouse()
{
STUB_FUNCTION;
}
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef MAX_PATH
#define MAX_PATH 256
#endif
static void fix_filename(const char *original, char *fixed)
{
const char *start;
int i;
int len;
start = original;
if (original[0] == ':') {
start = &original[1];
}
/*
here would be stuff to check where the file is,
including the game root and the user local dir
*/
fixed[MAX_PATH-1] = 0;
strncpy(fixed, start, MAX_PATH);
/* check to see if strncpy overwrote the terminator */
if (fixed[MAX_PATH-1] != 0) {
fixed[MAX_PATH-1] = 0;
fprintf(stderr, "ERROR: file truncation error: %s -> %s\n",
original, fixed);
}
len = strlen(fixed);
for (i = 0; i < len; i++) {
if (fixed[i] == ':') {
fixed[i] = '/';
}
}
}
/*
Convenient Filename Hacks
*/
FILE *cfh_fopen(const char *filename, const char *mode)
{
char filename1[MAX_PATH];
fix_filename(filename, filename1);
return fopen(filename1, mode);
}
int Files::OpenFile(Str255 Name)
{
char filename1[MAX_PATH];
fix_filename((char *)Name, filename1);
sFile = open(filename1, O_RDONLY | O_BINARY);
return sFile;
}
void Files::EndLoad()
{
if (sFile != -1) {
FSClose( sFile );
}
sFile = -1;
}
void alutLoadWAVFile(char *filename, ALenum *format, void **wave,
unsigned int *size, ALsizei *freq)
{
char filename1[256];
ALsizei format1, size1, bits1, freq1;
int i, len;
fix_filename(filename, filename1);
alutLoadWAV(filename1, wave, &format1, &size1, &bits1, &freq1);
*format = format1;
*size = size1;
*freq = freq1;
}
void alutUnloadWAV(ALenum format, void *wave, unsigned int size,
ALsizei freq)
{
free(wave);
}
|