forked from kilobyte/lastbeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
support.c
97 lines (77 loc) · 1.92 KB
/
support.c
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
/* Allegro port Copyright (C) 2014 Gavin Smith. */
// module 'SUPPORT.C'
// [c] copyright by ALPHA-HELIX 1993
#include <allegro.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "xmode.h"
#include "baller.h"
#include "sound.h"
/*------------------------------------------------------
Function: setspeed
Description: Sets the speed of the timer.
------------------------------------------------------*/
void setspeed(unsigned speed)
{
install_int_ex (settick, BPS_TO_TIMER(speed * RESOLUTION));
LOCK_VARIABLE (tick);
LOCK_VARIABLE (_subtick);
LOCK_VARIABLE (mstthsbevalidp);
LOCK_VARIABLE (updates_due);
LOCK_FUNCTION (settick);
}
void waitforkey(void)
{
while (keypressed()) clear_keybuf();
while (!keypressed());
}
int waitdelayedkey(int count)
{
while (keypressed()) clear_keybuf();
while (!keypressed() && --count) waitfortick();
return (count) ? 1 : 0;
}
void writetext(int x, int y, const char *s, struct sprstrc *font)
{
int i;
int xs;
xs = font->xs;
i = 0;
while (s[i] != 0) {
putspritedirect(font, x, y, s[i++] - ' ');
x += xs;
}
}
void writenumber(int x, int y, long number, struct sprstrc *font)
{
int j, xs, i = 0;
int zahl;
xs = font->xs;
for(j = 0; j < 2; j++){
zahl = number % 10;
number /= 10;
putspritedirect(font, x, y, 16 + zahl);
x -= xs;
}
putspritedirect(font, x, y, '.'-' ');
for(; j < 10; j++){
x -= xs;
zahl = number % 10;
number /= 10;
if(zahl != 0 || j == 2){
putspritedirect(font, x, y, 16 + zahl);
if(i!=0) for(; i > 0; i--) putspritedirect(font, x+i*xs, y, 16);
i = 0;
}else{
i ++;
}
}
}
void killallbuddies(void)
{
int i;
for (i = 0; i < MAXARMS; i++) _arm[i].object = -1;
for (i = 0; i < MAXFOES; i++) _foe[i].object = -1;
for (i = 0; i < MAXSHOTS; i++) _shot[i].object = -1;
for (i = 0; i < MAXEXPLS; i++) _expl[i].object = -1;
}