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
|
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
#include "stdafx.h"
#include "scummsys.h"
#include "system.h"
#include "../sound/mixer.h"
#include "simon.h"
#include <stdarg.h>
#ifdef WIN32
#include <conio.h>
#endif
//uint16 swap16(uint16 a) {
// return (a>>8)|(a<<8);
//}
//uint32 swap32(uint32 a) {
// return (a>>24)|(a>>8)&0xFF00|(a<<8)&0xFF0000|(a<<24);
//}
uint fileReadByte(FILE *in) {
byte b;
fread(&b, sizeof(b), 1, in);
return b;
}
uint fileReadBE16(FILE *in) {
byte b[2];
fread(b, sizeof(b), 1, in);
return (b[0]<<8) | b[1];
}
uint fileReadLE16(FILE *in) {
byte b[2];
fread(b, sizeof(b), 1, in);
return (b[1]<<8) | b[0];
}
uint32 fileReadBE32(FILE *in) {
byte b[4];
fread(b, sizeof(b), 1, in);
return (b[0]<<24)|(b[1]<<16)|(b[2]<<8)|b[3];
}
uint32 fileReadLE32(FILE *in) {
byte b[4];
fread(b, sizeof(b), 1, in);
return (b[3]<<24)|(b[2]<<16)|(b[1]<<8)|b[0];
}
void fileWriteBE32(FILE *in, uint32 value) {
value = TO_BE_32(value);
fwrite(&value, sizeof(value), 1, in);
}
void fileWriteBE16(FILE *in, uint16 value) {
value = TO_BE_16(value);
fwrite(&value, sizeof(value), 1, in);
}
#if 0
void NORETURN CDECL error(const char *s, ...) {
char buf[1024];
va_list va;
va_start(va, s);
vsprintf(buf, s, va);
va_end(va);
#ifdef WIN32
fprintf(stderr, "Error: %s!\nPress a key to quit.\n", buf);
_getch();
#else
fprintf(stderr, "Error: %s!\n", buf);
#endif
exit(1);
}
void CDECL warning(const char *s, ...) {
char buf[1024];
va_list va;
va_start(va, s);
vsprintf(buf, s, va);
va_end(va);
fprintf(stdout, "Warning: %s!\n", buf);
}
#endif
#ifndef WIN32
/* GetAsyncKeyState for unix */
int GetAsyncKeyState(int key) {
return 0;
}
#endif
|