-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
71 lines (58 loc) · 2.01 KB
/
main.c
File metadata and controls
71 lines (58 loc) · 2.01 KB
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
#include <exec/types.h>
#include <dos/dos.h>
#include <stdlib.h>
#include "starlight/starlight.h"
#include "twoplanes.h"
#include "ballblob.h"
#include "doublebuffer.h"
#include "main.h"
WORD fsmCurrentState = FSM_START;
WORD fsmNextState = -1;
int main(void)
{
while(fsmCurrentState!=FSM_QUIT){
switch(fsmCurrentState){
case FSM_START:
initStarlight();
fsmNextState = FSM_TWOPLANES_INIT;
break;
case FSM_TWOPLANES_INIT:
initTwoPlanes();
fsmNextState = FSM_TWOPLANES_RUN;
break;
case FSM_TWOPLANES_RUN:
fsmNextState = executeTwoPlanes() ? FSM_TWOPLANES_RUN : FSM_BALLBLOB_INIT;
break;
case FSM_BALLBLOB_INIT:
initBallBlob();
exitTwoPlanes();
fsmNextState = FSM_BALLBLOB_RUN;
break;
case FSM_BALLBLOB_RUN:
fsmNextState = executeBallBlob() ? FSM_BALLBLOB_RUN : FSM_DOUBLEBUFFER_INIT;
break;
case FSM_DOUBLEBUFFER_INIT:
initDoubleBuffer();
exitBallBlob();
fsmNextState = FSM_DOUBLEBUFFER_RUN;
break;
case FSM_DOUBLEBUFFER_RUN:
fsmNextState = executeDoubleBuffer() ? FSM_DOUBLEBUFFER_RUN : FSM_STOP;
break;
case FSM_STOP:
// first switch to null view, then free double buffer bitplanes
exitStarlight();
exitDoubleBuffer();
fsmNextState = FSM_QUIT;
break;
//something unexcpected happened, we better leave
default:
fsmNextState = FSM_QUIT;
writeLogFS("Error: Main, unknown fsm status %d\n",
fsmCurrentState);
break;
}
fsmCurrentState = fsmNextState;
}
exit(RETURN_OK);
}