-
Notifications
You must be signed in to change notification settings - Fork 1
/
wungiel.c
194 lines (156 loc) · 5.28 KB
/
wungiel.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#include <ace/managers/viewport/simplebuffer.h>
#include <ace/managers/joy.h>
#include <ace/managers/key.h>
#include <ace/managers/system.h>
#include <ace/managers/game.h>
#include <ace/utils/palette.h>
#include <ace/utils/string.h>
#include <stdio.h>
#include <ace/managers/state.h>
#include <ace/managers/blit.h>
#include <ace/utils/font.h>
#include <ace/managers/ptplayer.h>
#include <ace/managers/rand.h>
#include "enum.h"
static tView *s_pView;
static tVPort *s_pVp;
static tSimpleBufferManager *s_pVpManager;
//extern tState g_sStateIntro;
extern tStateManager *g_pStateMachineGame;
//extern tState g_sStateMenu;
extern tState g_sStateCredits;
void waitFrames();
static tFont *s_pFont;
static tTextBitMap *s_pBmText;
static tPtplayerSfx *s_pAtari;
UBYTE typingRandomizer = 0;
#define LOAD 1
#define RUN 2
char szWungiel[50];
char lineToPass[50];
static const char *lines[5] = {
"",
"if (system.hacked == TRUE){",
"atariMode = ON; }",
"",
"READY",
};
const char load1[] = "LOAD ATARENIUM FALCON";
const char *w2 = "ERROR - INSERT WINCY WUNGLA TO DF0:";
const char dots[] = "...";
const char *w3 = "WUNGIEL DETECTED";
const char *w4 = "DONE";
const char run[] = "RUN";
void blitBlueAtariScreen(void){
blitRect(s_pVpManager->pBack, 0, 0, 320, 128, 21);
blitRect(s_pVpManager->pBack, 0, 128, 320, 128, 21);
}
void printLineOfAtariText(const char *lineToPass, UBYTE textPositionY){
sprintf(szWungiel, lineToPass);
fontFillTextBitMap(s_pFont, s_pBmText, szWungiel);
fontDrawTextBitMap(s_pVpManager->pBack, s_pBmText, 10, textPositionY, 23, FONT_COOKIE);
}
void printThreeDots(UBYTE dotsPositionY){
for (BYTE i = 0; i < 3; ++i) {
sprintf(szWungiel, "%c", dots[i]);
fontFillTextBitMap(s_pFont, s_pBmText, szWungiel);
fontDrawTextBitMap(s_pVpManager->pBack, s_pBmText, (i * 7) + 10, dotsPositionY, 23, FONT_COOKIE);
waitFrames(s_pVp, 50, 200);
}
}
void typingAtariLineWithSound(UBYTE line, UBYTE typingPositionY){
UWORD uwX = 10;
switch (line){
case LOAD:
for (UBYTE i = 0; i < strlen(load1); ++i) {
sprintf(szWungiel, "%c", load1[i]);
fontFillTextBitMap(s_pFont, s_pBmText, szWungiel);
fontDrawTextBitMap(s_pVpManager->pBack, s_pBmText, uwX, typingPositionY, 23, FONT_COOKIE);
uwX += fontGlyphWidth(s_pFont, load1[i]) + 1;
ptplayerSfxPlay(s_pAtari, 3, 64, 100);
typingRandomizer = ulRandMinMax(10, 20);
waitFrames(s_pVp, typingRandomizer, 200);
}
break;
case RUN:
for (BYTE i = 0; i < 3; ++i) {
sprintf(szWungiel, "%c", run[i]);
fontFillTextBitMap(s_pFont, s_pBmText, szWungiel);
fontDrawTextBitMap(s_pVpManager->pBack, s_pBmText, (i * 7) + 10, 120, 23, FONT_COOKIE);
ptplayerSfxPlay(s_pAtari, 3, 64, 100);
typingRandomizer = ulRandMinMax(10, 20);
waitFrames(s_pVp, typingRandomizer, 200);
}
break;
}
}
void stateWungielCreate(void)
{
s_pView = viewCreate(0,
TAG_VIEW_COPLIST_MODE, COPPER_MODE_BLOCK,
TAG_VIEW_GLOBAL_CLUT, 1,
TAG_END);
s_pVp = vPortCreate(0,
TAG_VPORT_VIEW, s_pView,
TAG_VPORT_BPP, 5,
TAG_END);
// Paleta z falkona
paletteLoad("data/falkon.plt", s_pVp->pPalette, 32);
s_pVpManager = simpleBufferCreate(0,
TAG_SIMPLEBUFFER_VPORT, s_pVp,
TAG_SIMPLEBUFFER_BITMAP_FLAGS, BMF_CLEAR | BMF_INTERLEAVED,
TAG_SIMPLEBUFFER_IS_DBLBUF, 0,
TAG_END);
systemUnuse();
joyOpen();
keyCreate();
viewLoad(s_pView);
randInit(476);
ptplayerCreate(1);
s_pAtari = ptplayerSfxCreateFromFile("data/Atari.sfx");
s_pFont = fontCreate("data/topaz.fnt");
s_pBmText = fontCreateTextBitMap(TEXT_BITMAP_WIDTH, s_pFont->uwHeight);
blitBlueAtariScreen();
for(UBYTE i = 1; i < 5; ++i) {
if (!stringIsEmpty(lines[i])){
printLineOfAtariText(lines[i], i * 10);
}
}
waitFrames(s_pVp, 50, 200);
typingAtariLineWithSound(LOAD, 50);
waitFrames(s_pVp, 50, 200);
printLineOfAtariText(w2, 60); // 'insert wincy wungla' ...
waitFrames(s_pVp, 50, 200);
printThreeDots(70);
printLineOfAtariText(w3, 80); // 'wungiel detected'
waitFrames(s_pVp, 50, 200);
typingAtariLineWithSound(LOAD, 90);
printThreeDots(100);
printLineOfAtariText(w4, 110); // 'done'
waitFrames(s_pVp, 50, 200);
typingAtariLineWithSound(RUN, 120);
printThreeDots(130);
}
void stateWungielLoop(void)
{
stateChange(g_pStateMachineGame, &g_sStateCredits);
return;
}
void stateWungielDestroy(void)
{
systemUse();
ptplayerSfxDestroy(s_pAtari);
ptplayerDestroy();
fontDestroy(s_pFont);
fontDestroyTextBitMap(s_pBmText);
joyClose();
keyDestroy();
viewDestroy(s_pView);
}
tState g_sStateWungiel ={
.cbCreate = stateWungielCreate,
.cbLoop = stateWungielLoop,
.cbDestroy = stateWungielDestroy,
.cbSuspend = 0,
.cbResume = 0,
.pPrev = 0 };