-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
executable file
·270 lines (222 loc) · 4.33 KB
/
main.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#include <xboxrt/debug.h>
#include <pbkit/pbkit.h>
#include <hal/xbox.h>
#include "stdio.h"
#define delayAfterBeep 47
void beep(int freq, int duration) // freq in [hz], duration in [ms]
{
register int reg_ax asm ("ax");
reg_ax = freq;
asm("mov %ax,%bx \n"
"mov $0x12,%dx \n"
"mov $0x34dc,%ax \n"
"div %bx \n"
"mov %al,%bl \n"
"mov $0xb6,%al \n"
"out %al,$0x43 \n"
"mov %bl,%al \n"
"out %al,$0x42 \n"
"mov %ah,%al \n"
"out %al,$0x42 \n"
"in $0x61,%al \n"
"or $0x3,%al \n"
"out %al,$0x61 \n"
"xor %ax,%ax \n");
XSleep(duration);
asm("in $0x61,%al \n"
"and $0xfc,%al \n"
"out %al,$0x61 \n");
XSleep(delayAfterBeep);
}
void main(void)
{
switch(pb_init())
{
case 0: break;
default:
XSleep(2000);
XReboot();
return;
}
pb_show_debug_screen();
while(1) {
XSleep(500);
debugPrint("thx JayFoxRox!\n\n");
XSleep(1100);
debugPrint("proudly presented by DaveX ;)\n\n");
XSleep(1100);
debugPrint("if run in Xqemu make sure to use: -soundhw pcspk\n");
debugPrint("e.g. ./qemu-system-xbox -soundhw pcspk -machine xbox, [...]\nor\n");
debugPrint("./qemu-system-i386 -soundhw pcspk -cpu pentium3 [...]\n\n");
XSleep(1100);
debugPrint("get ready!\n");
XSleep(1002);
beep(440,100);
XSleep(700);
beep(222,600);
XSleep(300);
beep(111,2200);
XSleep(700);
beep(440,200);
XSleep(700);
debugPrint("now => \n");
XSleep(700);
beep(659,406);
beep(494,203);
beep(523,203);
beep(587,406);
beep(523,203);
beep(494,203);
beep(440,406);
beep(440,203);
beep(523,203);
beep(659,406);
beep(587,203);
beep(523,203);
beep(494,609);
beep(523,203);
beep(587,406);
beep(659,406);
beep(523,406);
beep(440,406);
beep(440,203);
beep(440,203);
beep(494,203);
beep(523,203);
beep(587,609);
beep(698,203);
beep(880,406);
beep(784,203);
beep(698,203);
beep(659,609);
beep(523,203);
beep(659,406);
beep(587,203);
beep(523,203);
beep(494,406);
beep(494,203);
beep(523,203);
beep(587,406);
beep(659,406);
beep(523,406);
beep(440,406);
beep(440,406);
XSleep(1953);
/* Imp March
stolen from (/thx at) https://gist.github.com/tagliati/1804108
*/
beep(440, 500);
beep(440, 500);
beep(440, 500);
beep(349, 350);
beep(523, 150);
beep(440, 500);
beep(349, 350);
beep(523, 150);
beep(440, 1000);
//first bit
beep(659, 500);
beep(659, 500);
beep(659, 500);
beep(698, 350);
beep(523, 150);
beep(415, 500);
beep(349, 350);
beep(523, 150);
beep(440, 1000);
//second bit...
beep(880, 500);
beep(440, 350);
beep(440, 150);
beep(880, 500);
beep(830, 250);
beep(784, 250);
beep(740, 125);
beep(698, 125);
beep(740, 250);
XSleep(250);
beep(455, 250);
beep(622, 500);
beep(587, 250);
beep(466, 250);
//start of the interesting bit
beep(523, 125);
beep(466, 125);
beep(523, 250);
XSleep(250);
beep(349, 125);
beep(415, 500);
beep(349, 375);
beep(440, 125);
beep(523, 500);
beep(440, 375);
beep(523, 125);
beep(659, 1000);
//more interesting stuff (this doesn't quite get it right somehow)
beep(880, 500);
beep(440, 350);
beep(440, 150);
beep(880, 500);
beep(830, 250);
beep(784, 250);
beep(740, 125);
beep(698, 125);
beep(740, 250);
XSleep(250);
beep(455, 250);
beep(622, 500);
beep(587, 250);
beep(466, 250);
//repeat... repeat
beep(523, 125);
beep(466, 125);
beep(523, 250);
XSleep(250);
beep(349, 250);
beep(415, 500);
beep(349, 375);
beep(523, 125);
beep(440, 500);
beep(349, 375);
beep(261, 125);
beep(440, 1000);
//and we're done \ó/
// end March
XSleep(1776);
debugPrint("thx bb :)\n");
XSleep(7887);
}
pb_kill();
XReboot();
}
/* CREDIZ
from user "Matrix" https://board.flatassembler.net/topic.php?t=1813
// <asm code>
mov ax,440
call sound
xor ax,ax
int 22
call nosound
int 32
nosound:
in al,0x61
and al,0xFC;
out 0x61,al
ret
sound:
mov bx,ax
mov dx,0x12
mov ax,0x34DC
div bx
mov bl,al
mov al,0xB6
out 0x43,al
mov al,bl
out 0x42,al
mov al,ah
out 0x42,al
in al,0x61
or al,3
out 0x61,al
ret
*/