-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSwoosh.cpp
More file actions
624 lines (536 loc) · 31.9 KB
/
Swoosh.cpp
File metadata and controls
624 lines (536 loc) · 31.9 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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
#include "stdafx.h"
#include "UI.h"
#include "Objects.h"
#include "Dispatch.h"
#include "CSB.h"
#include <string.h>
//#include <TextUtils.h>
#if 0
using UBYTE=uint8_t;
#define A0B(x) ( (unsigned char*)A0)[x]
#define A0W(x) ((unsigned short*)(((unsigned char*)A0)+x))[0]
#define A0L(x) ((unsigned long*)(((unsigned char*)A0)+x))[0]
#define A1B(x) ( (unsigned char*)A1)[x]
#define A1W(x) ((unsigned short*)(((unsigned char*)A1)+x))[0]
#define A1L(x) ((unsigned long*)(((unsigned char*)A1)+x))[0]
#define A5B(x) ( (unsigned char*)A5)[x]
#define A5W(x) ((unsigned short*)(((unsigned char*)A5)+x))[0]
#define A5L(x) ((unsigned long*)(((unsigned char*)A5)+x))[0]
#define A6B(x) ( (unsigned char*)A6)[x]
#define A6W(x) ((unsigned short*)(((unsigned char*)A6)+x))[0]
#define A6L(x) ((unsigned long*)(((unsigned char*)A6)+x))[0]
static uint8_t sectors3_3 [1536] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x55,0x50,0x45,
0x52,0x47,0x41,0x55,0x30,0x30,0x30,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x41,0x55,0x54,0x4F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF4,0x01,
0x00,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0xE5,0x55,0x4E,0x47,0x45,0x4F,0x4E,0x20,0x50,0x52,0x47,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x57,0x00,0x74,0x0B,0x09,0x00,0xAC,0x29,0x02,0x00,0x44,0x55,0x4E,0x47,0x45,0x4F,0x4E,0x20,0x43,0x46,0x50,0x20,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x39,0x01,0x47,0x90,0x40,0x00,0xC6,0x4A,0x00,0x00,0x44,0x55,0x4E,0x47,0x45,0x4F,
0x4E,0x20,0x44,0x41,0x54,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x01,0x47,0x90,0x53,0x00,0xA2,0x82,0x00,0x00,
0x44,0x55,0x4E,0x47,0x45,0x4F,0x4E,0x20,0x45,0x58,0x45,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x01,0x47,0x90,
0x74,0x00,0xAC,0x29,0x02,0x00,0x47,0x52,0x41,0x50,0x48,0x49,0x43,0x53,0x44,0x41,0x54,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x51,0x01,0x47,0x90,0xFF,0x00,0x2D,0x26,0x04,0x00,0x53,0x45,0x43,0x54,0x4F,0x52,0x53,0x20,0x20,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6F,0x01,0x47,0x90,0x09,0x02,0x00,0x10,0x00,0x00,0x53,0x57,0x4F,0x4F,0x53,0x48,0x20,0x20,
0x49,0x4D,0x47,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x71,0x01,0x47,0x90,0x0D,0x02,0xC8,0x0B,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};
static uint8_t bootsector[512] = {0x60,0x38,0x4C,0x6F,0x61,0x64,0x65,0x72,0x00,0x00,0x00,0x00,0x02,0x02,0x01,0x00,0x02,0x10,0x00,0x24,0x03,0xF8,0x02,0x00,0x0A,0x00,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x57,0x4F,0x4F,0x53,0x48,
0x20,0x20,0x49,0x4D,0x47,0x00,0x70,0x07,0x32,0x3C,0x07,0x77,0x48,0xE7,0xC0,0x00,0x3F,0x3C,0x00,0x25,0x4E,0x4E,0x54,0x8F,0x4C,0xDF,
0x00,0x03,0x20,0x7C,0xFF,0xFF,0x82,0x40,0x30,0x81,0x04,0x41,0x01,0x11,0x51,0xC8,0xFF,0xE2,0x20,0x7C,0xFF,0xFF,0x82,0x40,0x70,0x0F,
0x42,0x58,0x51,0xC8,0xFF,0xFC,0x33,0xFA,0xFF,0xAE,0x00,0x00,0x04,0x82,0x3F,0x39,0x00,0x00,0x04,0x46,0x3F,0x3C,0x00,0x07,0x4E,0x4D,
0x58,0x4F,0x4A,0x80,0x67,0x00,0x00,0xF6,0x2A,0x40,0x41,0xFA,0xFF,0x9C,0x4A,0x90,0x66,0x06,0x20,0xB9,0x00,0x00,0x04,0x32,0x30,0x2D,
0x00,0x08,0xE1,0x48,0xD0,0x80,0x38,0x40,0xD9,0xFA,0xFF,0x84,0x30,0x3A,0xFF,0x76,0x67,0x10,0x3C,0x3A,0xFF,0x72,0x38,0x3A,0xFF,0x70,
0x26,0x7A,0xFF,0x6E,0x60,0x00,0x00,0xB4,0x3C,0x2D,0x00,0x0A,0x38,0x2D,0x00,0x08,0xD8,0x6D,0x00,0x06,0x26,0x7A,0xFF,0x5E,0x61,0x00,
0x00,0xB0,0x66,0x00,0x00,0xAA,0x20,0x4C,0x30,0x2D,0x00,0x06,0xE1,0x48,0xE3,0x48,0x41,0xF0,0x00,0x00,0x43,0xFA,0xFF,0x48,0x90,0xFC,
0x00,0x20,0xB1,0xCC,0x6D,0x00,0x00,0x8E,0x70,0x0A,0x12,0x30,0x00,0x00,0xB2,0x31,0x00,0x00,0x66,0xEA,0x51,0xC8,0xFF,0xF4,0x7E,0x00,
0x1E,0x28,0x00,0x1B,0xE1,0x4F,0x1E,0x28,0x00,0x1A,0x2C,0x7A,0xFF,0x1A,0x26,0x7A,0xFF,0x12,0x42,0x84,0x0C,0x47,0x0F,0xF0,0x6C,0x52,
0x36,0x07,0x55,0x43,0xC6,0xED,0x00,0x02,0xD6,0x6D,0x00,0x0C,0x0C,0x44,0x00,0x40,0x6C,0x08,0x4A,0x44,0x67,0x0E,0xB6,0x45,0x67,0x10,
0x61,0x46,0x66,0x42,0xE1,0x8C,0xE3,0x8C,0xD7,0xC4,0x3C,0x03,0x3A,0x03,0x42,0x84,0xD8,0x6D,0x00,0x02,0xDA,0x6D,0x00,0x02,0x34,0x07,
0xE2,0x4A,0xD4,0x47,0x12,0x36,0x20,0x01,0xE1,0x49,0x12,0x36,0x20,0x00,0x08,0x07,0x00,0x00,0x67,0x02,0xE8,0x49,0x02,0x41,0x0F,0xFF,
0x3E,0x01,0x60,0xA8,0x4A,0x44,0x67,0x04,0x61,0x0A,0x66,0x06,0x2F,0x3A,0xFE,0xAC,0x4E,0x75,0x60,0xFE,0x3F,0x39,0x00,0x00,0x04,0x46,
0x3F,0x06,0x3F,0x04,0x2F,0x0B,0x42,0x67,0x3F,0x3C,0x00,0x04,0x4E,0x4D,0xDE,0xFC,0x00,0x0E,0x4A,0x40,0x4E,0x75,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x7D};
struct bpb
{
WORD recsiz; // sector size in bytes //
WORD clsiz; // cluster size in sectors //
WORD clsizb; // cluster size in bytes //
WORD rdlen; // g_root directory length in records //
WORD fsiz; // fat size in records //
WORD fatrec; // first fat record (of last fat) //
WORD datrec; // first data record //
WORD numcl; // number of data clusters available //
WORD b_flags;
};
static struct flop_info {
WORD cur_track;
WORD rate;
WORD spt; // number of sectors per track //
WORD sides; // number of sides, or -1 if geometry not inited //
BYTE serial[3]; // the serial number taken from the bootsector //
BYTE wp; // != 0 means write protected //
} finfo[2];
static struct bpb flop_bpb[2];
struct bs {
/* 0 */ UBYTE bra[2];
/* 2 */ UBYTE loader[6];
/* 8 */ UBYTE serial[3];
/* b */ UBYTE bps[2]; // bytes per sector */
/* d */ UBYTE spc; // sectors per cluster */
/* e */ UBYTE res[2]; // number of reserved sectors */
/* 10 */ UBYTE fat; // number of FATs */
/* 11 */ UBYTE dir[2]; // number of DIR g_root entries */
/* 13 */ UBYTE sec[2]; // total number of sectors */
/* 15 */ UBYTE media; // media descriptor */
/* 16 */ UBYTE spf[2]; // sectors per FAT */
/* 18 */ UBYTE spt[2]; // sectors per track */
/* 1a */ UBYTE sides[2]; // number of sides */
/* 1c */ UBYTE hid[2]; // number of hidden sectors */
/* 1e */ UBYTE data[0x1e0];
/* 1fe */ UBYTE cksum[2];
};
typedef struct bpb BPB;
static char memory[8192]={'m','e','m','o','r','y',0,};
static unsigned char _bsdata[] = { /*0xA10*/0x00,0x00,
/*0xA12*/0x00,0x00,0x00,0x00,
/*0xA16*/0x00,0x04,0x00,0x00,
/*0xA1A*/0x00,0x00,0x00,0x00,
/*0xA1E*/'S','W','O','O','S','H',' ',' ','I','M','G',0x00};
static unsigned short* A10=(unsigned short*)&_bsdata[0];
static unsigned short* A12=(unsigned short*)&_bsdata[2];
static unsigned short* A14=(unsigned short*)&_bsdata[4];
static unsigned long* A16=(unsigned long*)&_bsdata[6];
static unsigned long* A1A=(unsigned long*)&_bsdata[10];
static unsigned char* A1E=&_bsdata[14];
static long _432 = (long)memory;
i32 _0DD78B70(i16,i16,i32);
void A16LDCode();
/*
0- 1 bra
2- 7 loader
8- a serial number
b- c bytes per sector
d sectors per cluster
e- f number of reserved sectors
10 number of fatek
11-12 number of g_root dir entries
13-14 total number of sectors
15 media descriptor
16-17 sectors per fat
18-19 sectors per track
1a-1b number of sides
1c-1d number of hidden sectors
1e-1fd data
1fe-1ff checksum
*/
static UWORD getiword(UBYTE *addr)
{
UWORD value;
value = (((UWORD)addr[1])<<8) + addr[0];
return value;
}
static LONG flop_getbpb(WORD dev)
{
struct bs *b;
LONG tmp;
WORD err;
if(dev < 0 || dev > 1) return 0;
/* read bootsector */
b = (struct bs *)bootsector;
flop_bpb[dev].recsiz = getiword(b->bps);
flop_bpb[dev].clsiz = b->spc;
flop_bpb[dev].clsizb = flop_bpb[dev].clsiz * flop_bpb[dev].recsiz;
tmp = getiword(b->dir);
flop_bpb[dev].rdlen = (tmp * 32) / flop_bpb[dev].recsiz;
flop_bpb[dev].fsiz = getiword(b->spf);
/* the structure of the floppy is assumed to be:
* - bootsector
* - fats
* - dir
* - data clusters
* TODO: understand what to do with reserved or hidden sectors.
*/
flop_bpb[dev].fatrec = 1 + flop_bpb[dev].fsiz;
flop_bpb[dev].datrec = flop_bpb[dev].fatrec + flop_bpb[dev].fsiz
+ flop_bpb[dev].rdlen;
flop_bpb[dev].numcl = (getiword(b->sec) - flop_bpb[dev].datrec) / b->spc;
flop_bpb[dev].b_flags = 0; // assume floppies are always in FAT12 //
// additional geometry info //
finfo[dev].sides = getiword(b->sides);
finfo[dev].spt = getiword(b->spt);
finfo[dev].serial[0] = b->serial[0];
finfo[dev].serial[1] = b->serial[1];
finfo[dev].serial[2] = b->serial[2];
return (LONG) &flop_bpb[dev];
}
/* 0DD78B70 MOVE.W $00000446,-(A7) | 3F39 0000 0446
0DD78B76 MOVE.W D6,-(A7) | 3F06
0DD78B78 MOVE.W D4,-(A7) | 3F04
0DD78B7A MOVE.L A3,-(A7) | 2F0B
0DD78B7C CLR.W -(A7) | 4267
0DD78B7E MOVE.W #$0004,-(A7) | 3F3C 0004
*/
static short RWABS(short dev, short sector, short count, long addr, short flag, short sel)
{
dev = dev;
sector = sector;
count = count;
addr = addr;
flag = flag;
if(sector == 3 && count == 3)
{
memmove((void*)addr,sectors3_3,1536);
}
return 0;
}
static i8 SWOOSHScreen[320*200/2];
static i16 FFFF8240[16] = { 0x777, 0x700, 0x070, 0x770, 0x007, 0x707, 0x077, 0x555,
0x333, 0x733, 0x373, 0x773, 0x337, 0x737, 0x377, 0x000};
void swoosh_bootsector();
extern void UpdateScreenArea(
i8 *STScreen,
int x0,
int y0,
int width,
int height,
i16 *palette,
bool paletteChanged,
i32 *pOldChecksum);
void VSYNC()
{
i32 ignore;
UpdateScreenArea(SWOOSHScreen,0,0,320,200,FFFF8240,TRUE,&ignore);
}
void swoosh()
{
i32 ignore;
UpdateScreenArea(SWOOSHScreen,0,0,320,200,FFFF8240,TRUE,&ignore);
swoosh_bootsector();
}
void swoosh_bootsector()
{
dReg D0,D1,D2,D3,D4,D5,D6,D7;
unsigned long A0,A1,A2,A3,A4,A5,A6,A7;
/* 0DD789F0 BRA.S *+$003A ; 0DD78A2A | 6038
*/ goto _0DD78A2A;
/* 0DD789F2 TDIVU.L $6572(A7),D4:D6 | 4C6F 6164 6572
0DD789F8 ORI.B #$00,D0 | 0000 0000
0DD789FC ANDI.B #$0100,D2 | 0202 0100
0DD78A00 ANDI.B #$24,(A0) ; '$' | 0210 0024
0DD78A04 BSET D1,SPAlarm | 03F8 0200
0DD78A08 EORI.B #$0100,D0 | 0A00 0100
0DD78A0C ORI.B #$00,D0 | 0000 0000
0DD78A10 ORI.B #$00,D0 | 0000 0000
0DD78A14 ORI.B #$04,D0 | 0000 0004
0DD78A18 ORI.B #$00,D0 | 0000 0000
0DD78A1C ORI.B #$5357,D0 ; 'W' | 0000 5357
0DD78A20 DC.W $4F4F ; ???? | 4F4F
0DD78A22 SUBQ.W #$1,A0 | 5348
0DD78A24 MOVE.L -(A0),D0 | 2020
0DD78A26 DC.W $494D ; ???? | 494D
0DD78A28 CHK.L D0,D3 | 4700
*/
_0DD78A2A:
// 0DD78A2A MOVEQ #$07,D0 | 7007
// 0DD78A2C MOVE.W #$0777,D1 | 323C 0777
D0L = 7;
D1W = 0x777;
// 0DD78A30 MOVEM.L D0/D1,-(A7) | 48E7 C000
// 0DD78A34 MOVE.W #$0025,-(A7) | 3F3C 0025
// 0DD78A38 TRAP #$E | 4E4E
// 0DD78A3A ADDQ.L #$2,A7 | 548F
_0DD78A30:
VSYNC();
// 0DD78A3C MOVEM.L (A7)+,D0/D1 | 4CDF 0003
// 0DD78A40 MOVEA.L #$FFFF8240,A0 | 207C FFFF 8240
A0 = (long)FFFF8240;
// 0DD78A46 MOVE.W D1,(A0) | 3081
// 0DD78A48 SUBI.W #$0111,D1 | 0441 0111
// 0DD78A4C DBF D0,*-$001C ; 0DD78A30 | 51C8 FFE2
A0W(0) = D1W;
D1W -= 0x111;
if(D0W-->=0) goto _0DD78A30;
// 0DD78A50 MOVEA.L #$FFFF8240,A0 | 207C FFFF 8240
// 0DD78A56 MOVEQ #$0F,D0 | 700F
// 0DD78A58 CLR.W (A0)+ | 4258
// 0DD78A5A DBF D0,*-$0002 ; 0DD78A58 | 51C8 FFFC
A0 = (long)FFFF8240;
D0L = 0xF;
_0DD78A58:
A0W(0) = 0; A0+=2;
if(D0W-->=0) goto _0DD78A58;
// 0DD78A5E MOVE.W *-$0050,$00000482 ; 0DD78A0E | 33FA FFAE 0000
// 0DD78A66 MOVE.W $00000446,-(A7) | 3F39 0000 0446
// 0DD78A6C MOVE.W #$0007,-(A7) | 3F3C 0007
// 0DD78A70 TRAP #$D | 4E4D
// 0DD78A72 ADDQ.W #$4,A7 | 584F
// 0DD78A74 TST.L D0 | 4A80
// 0DD78A76 BEQ *+$00F8 ; 0DD78B6E | 6700 00F6
//
// reading bios parameter block. we already have it in memory :-)
D0L = flop_getbpb(0);
if(!D0L) goto _0DD78B6E;
// 0DD78A7A MOVEA.L D0,A5 | 2A40
// 0DD78A7C LEA *-$0062,A0 ; 0DD78A1A | 41FA FF9C
// 0DD78A80 TST.L (A0) | 4A90
// 0DD78A82 BNE.S *+$0008 ; 0DD78A8A | 6606
// 0DD78A84 MOVE.L $00000432,(A0) | 20B9 0000 0432
A5 = D0L;
A0 = (long)A1A;
if(A0L(0)!=0) goto _0DD78A8A;
A0L(0) = _432;
_0DD78A8A:
// 0DD78A8A MOVE.W $0008(A5),D0 | 302D 0008
// 0DD78A8E LSL.W #$8,D0 | E148
// 0DD78A90 ADD.L D0,D0 | D080
// 0DD78A92 MOVEA.W D0,A4 | 3840
D0L = A5W(8);
D0W = D0W << 8;
D0L = D0L + D0L;
A4 = D0W;
// 0DD78A94 ADDA.L *-$007A,A4 ; 0DD78A1A | D9FA FF84
// 0DD78A98 MOVE.W *-$0088,D0 ; 0DD78A10 | 303A FF76
// 0DD78A9C BEQ.S *+$0012 ; 0DD78AAE | 6710
A4 += A1A[0];
D0L = A10[0];
if(!D0W) goto _0DD78AAE;
// 0DD78A9E MOVE.W *-$008C,D6 ; 0DD78A12 | 3C3A FF72
// 0DD78AA2 MOVE.W *-$008E,D4 ; 0DD78A14 | 383A FF70
// 0DD78AA6 MOVEA.L *-$0090,A3 ; 0DD78A16 | 267A FF6E
// 0DD78AAA BRA *+$00B6 ; 0DD78B60 | 6000 00B4
D6L = A12[0];
D4L = A14[0];
A3 = (long)A16[0];
goto _0DD78B60;
_0DD78AAE:
// 0DD78AAE MOVE.W $000A(A5),D6 | 3C2D 000A
// 0DD78AB2 MOVE.W $0008(A5),D4 | 382D 0008
// 0DD78AB6 ADD.W $0006(A5),D4 | D86D 0006
// 0DD78ABA MOVEA.L *-$00A0,A3 ; 0DD78A1A | 267A FF5E
// 0DD78ABE BSR *+$00B2 ; 0DD78B70 | 6100 00B0
// 0DD78AC2 BNE *+$00AC ; 0DD78B6E | 6600 00AA
D6L = A5W(0xA);
D4L = A5W(0x8);
D4W += A5W(0x6);
A3 = (long)A1A[0];
D0L = _0DD78B70(D6W,D4W,A3);
if(D0L) goto _0DD78B6E;
// 0DD78AC6 MOVEA.L A4,A0 | 204C
// 0DD78AC8 MOVE.W $0006(A5),D0 | 302D 0006
// 0DD78ACC LSL.W #$8,D0 | E148
// 0DD78ACE LSL.W #$1,D0 | E348
// 0DD78AD0 LEA $00(A0,D0.W),A0 | 41F0 0000
// 0DD78AD4 LEA *-$00B6,A1 ; 0DD78A1E | 43FA FF48
A0 = A4;
D0L = A5W(6);
D0W <<= 9;
A0 = A0 + D0W;
A1 = (long)A1E;
_0DD78AD8:
// 0DD78AD8 SUBA.W #$0020,A0 | 90FC 0020
// 0DD78ADC CMPA.L A4,A0 | B1CC
// 0DD78ADE BLT *+$0090 ; 0DD78B6E | 6D00 008E
A0 -= 0x20;
if(A0 < A4) goto _0DD78B6E;
// 0DD78AE2 MOVEQ #$0A,D0 | 700A
D0L = 0xA;
_0DD78AE4:
// 0DD78AE4 MOVE.B $00(A0,D0.W),D1 | 1230 0000
// 0DD78AE8 CMP.B $00(A1,D0.W),D1 | B231 0000
// 0DD78AEC BNE.S *-$0014 ; 0DD78AD8 | 66EA
// 0DD78AEE DBF D0,*-$000A ; 0DD78AE4 | 51C8 FFF4
D1B = A0B(D0W);
if(A1B(D0W) != D1B) goto _0DD78AD8;
if(D0W-->=0) goto _0DD78AE4;
// 0DD78AF2 MOVEQ #$00,D7 | 7E00
// 0DD78AF4 MOVE.B $001B(A0),D7 | 1E28 001B
// 0DD78AF8 LSL.W #$8,D7 | E14F
// 0DD78AFA MOVE.B $001A(A0),D7 | 1E28 001A
// 0DD78AFE MOVEA.L *-$00E4,A6 ; 0DD78A1A | 2C7A FF1A
// 0DD78B02 MOVEA.L *-$00EC,A3 ; 0DD78A16 | 267A FF12
// 0DD78B06 CLR.L D4 | 4284
D7L = 0;
D7B = A0B(0x1B);
D7W <<= 8;
D7B = A0B(0x1A);
A6 = (long)A1A[0];
A3 = (long)A16[0];
D4L = 0;
_0DD78B08:
// 0DD78B08 CMPI.W #$0FF0,D7 | 0C47 0FF0
// 0DD78B0C BGE.S *+$0054 ; 0DD78B60 | 6C52
// 0DD78B0E MOVE.W D7,D3 | 3607
// 0DD78B10 SUBQ.W #$2,D3 | 5543
// 0DD78B12 MULU.W $0002(A5),D3 | C6ED 0002
// 0DD78B16 ADD.W $000C(A5),D3 | D66D 000C
// 0DD78B1A CMPI.W #$0040,D4 | 0C44 0040
// 0DD78B1E BGE.S *+$000A ; 0DD78B28 | 6C08
// 0DD78B20 TST.W D4 | 4A44
// 0DD78B22 BEQ.S *+$0010 ; 0DD78B32 | 670E
// 0DD78B24 CMP.W D5,D3 | B645
// 0DD78B26 BEQ.S *+$0012 ; 0DD78B38 | 6710
if(D7W >= 0xFF0) goto _0DD78B60;
D3L = D7W;
D3W-=2;
D3W*=A5W(2);
D3W+=A5W(0xC);
if(D4W >= 0x40) goto _0DD78B28;
if(D4W == 0) goto _0DD78B32;
if(D5W == D3W) goto _0DD78B38;
_0DD78B28:
// 0DD78B28 BSR.S *+$0048 ; 0DD78B70 | 6146
// 0DD78B2A BNE.S *+$0044 ; 0DD78B6E | 6642
// 0DD78B2C LSL.L #$8,D4 | E18C
// 0DD78B2E LSL.L #$1,D4 | E38C
// 0DD78B30 ADDA.L D4,A3 | D7C4
D0L = _0DD78B70(D6W,D4W,A3);
if(D0W) goto _0DD78B6E;
D4L <<= 9;
A3 += D4L;
_0DD78B32:
// 0DD78B32 MOVE.W D3,D6 | 3C03
// 0DD78B34 MOVE.W D3,D5 | 3A03
// 0DD78B36 CLR.L D4 | 4284
D6W = D3W;
D5W = D3W;
D4L = 0;
_0DD78B38:
// 0DD78B38 ADD.W $0002(A5),D4 | D86D 0002
// 0DD78B3C ADD.W $0002(A5),D5 | DA6D 0002
// 0DD78B40 MOVE.W D7,D2 | 3407
// 0DD78B42 LSR.W #$1,D2 | E24A
// 0DD78B44 ADD.W D7,D2 | D447
// 0DD78B46 MOVE.B $01(A6,D2.W),D1 | 1236 2001
// 0DD78B4A LSL.W #$8,D1 | E149
// 0DD78B4C MOVE.B $00(A6,D2.W),D1 | 1236 2000
// 0DD78B50 BTST #$00,D7 | 0807 0000
// 0DD78B54 BEQ.S *+$0004 ; 0DD78B58 | 6702
// 0DD78B56 LSR.W #$4,D1 | E849
D4W += A5W(2);
D5W += A5W(2);
D2W = D7W;
D2W >>= 1;
D2W += D7W;
D1L = A6B(1+D2W);
D1W <<= 8;
D1L = A6B(D2W);
if(!(D7W&1)) goto _0DD78B58;
D1W >>= 4;
_0DD78B58:
// 0DD78B58 ANDI.W #$0FFF,D1 | 0241 0FFF
// 0DD78B5C MOVE.W D1,D7 | 3E01
// 0DD78B5E BRA.S *-$0056 ; 0DD78B08 | 60A8
D1W &= 0xFFF;
D7W = D1W;
goto _0DD78B08;
_0DD78B60:
// 0DD78B60 TST.W D4 | 4A44
// 0DD78B62 BEQ.S *+$0006 ; 0DD78B68 | 6704
// 0DD78B64 BSR.S *+$000C ; 0DD78B70 | 610A
// 0DD78B66 BNE.S *+$0008 ; 0DD78B6E | 6606
if(!D4W) goto _0DD78B68;
D0L = _0DD78B70(D6W,D4W,A3);
if(D0L) goto _0DD78B6E;
_0DD78B68:
// 0DD78B68 MOVE.L *-$0152,-(A7) ; 0DD78A16 | 2F3A FEAC
// 0DD78B6C RTS | 4E75
A16LDCode();
_0DD78B6E: //DebugStr("\pST Code hanged here!");
/*0DD78B6E BRA.S *+$0000 ; 0DD78B6E | 60FE
code here converted to subroutine _0DD78B70
0DD78B8C ORI.B #$00,D0 | 0000 0000
0DD78B90 ORI.B #$00,D0 | 0000 0000
0DD78B94 ORI.B #$00,D0 | 0000 0000
0DD78B98 ORI.B #$00,D0 | 0000 0000
0DD78B9C ORI.B #$00,D0 | 0000 0000
0DD78BA0 ORI.B #$00,D0 | 0000 0000
0DD78BA4 ORI.B #$00,D0 | 0000 0000
0DD78BA8 ORI.B #$00,D0 | 0000 0000
0DD78BAC ORI.B #$00,D0 | 0000 0000
0DD78BB0 ORI.B #$00,D0 | 0000 0000
0DD78BB4 ORI.B #$00,D0 | 0000 0000
0DD78BB8 ORI.B #$00,D0 | 0000 0000
0DD78BBC ORI.B #$00,D0 | 0000 0000
0DD78BC0 ORI.B #$00,D0 | 0000 0000
0DD78BC4 ORI.B #$00,D0 | 0000 0000
0DD78BC8 ORI.B #$00,D0 | 0000 0000
0DD78BCC ORI.B #$00,D0 | 0000 0000
0DD78BD0 ORI.B #$00,D0 | 0000 0000
0DD78BD4 ORI.B #$00,D0 | 0000 0000
0DD78BD8 ORI.B #$00,D0 | 0000 0000
0DD78BDC ORI.B #$00,D0 | 0000 0000
0DD78BE0 ORI.B #$00,D0 | 0000 0000
0DD78BE4 ORI.B #$00,D0 | 0000 0000
0DD78BE8 ORI.B #$00,D0 | 0000 0000
0DD78BEC ORI.B #$247D,D0 ; '}' | 0000 247D
*/
{}
}
i32 _0DD78B70(i16 d6, i16 d4, i32 a3)
{
// 0DD78B70 MOVE.W $00000446,-(A7) | 3F39 0000 0446
// 0DD78B76 MOVE.W D6,-(A7) | 3F06
// 0DD78B78 MOVE.W D4,-(A7) | 3F04
// 0DD78B7A MOVE.L A3,-(A7) | 2F0B
// 0DD78B7C CLR.W -(A7) | 4267
// 0DD78B7E MOVE.W #$0004,-(A7) | 3F3C 0004
// 0DD78B82 TRAP #$D | 4E4D
// 0DD78B84 ADDA.W #$000E,A7 | DEFC 000E
// 0DD78B88 TST.W D0 | 4A40
// 0DD78B8A RTS | 4E75
return RWABS(0,d6,d4,a3,0,4);
}
void A16LDCode()
{
//Debugger();
}
#endif