Repository navigation
Expand file tree
/
Copy pathplatform.c
More file actions
691 lines (676 loc) · 27.9 KB
/
Copy pathplatform.c
File metadata and controls
691 lines (676 loc) · 27.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
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
#include "platform.h"
#include "directx_factory.h"
#include "file.h"
#include "paddle.h"
#include "bonuses.h"
#include "round.h"
#include "trig.h"
#include "intro.h"
#include "gameover.h"
#include "editor.h"
#include "midi.h"
#include "sound.h"
#include "startup.h"
#include <stdlib.h>
#include <string.h>
DxBallInt (DXBALL_DDCALL *dxball_window_get_cursor_pos)(DxBallPoint *);
DxBallInt (DXBALL_DDCALL *dxball_window_peek_message)(DxBallMessage *, DxBallHandle, DxBallUInt, DxBallUInt, DxBallUInt);
DxBallInt (DXBALL_DDCALL *dxball_window_wait_message)(void);
DxBallInt (DXBALL_DDCALL *dxball_window_get_message)(DxBallMessage *, DxBallHandle, DxBallUInt, DxBallUInt);
DxBallInt (DXBALL_DDCALL *dxball_window_translate_message)(const DxBallMessage *);
DxBallWindowResult (DXBALL_DDCALL *dxball_window_dispatch_message)(const DxBallMessage *);
DxBallWindowResult (DXBALL_DDCALL *dxball_window_default_window_proc)(DxBallHandle, DxBallUInt, DxBallHandle, DxBallWindowResult);
DxBallInt (DXBALL_DDCALL *dxball_window_post_message)(DxBallHandle, DxBallUInt, DxBallHandle, DxBallWindowResult);
void (DXBALL_DDCALL *dxball_window_post_quit_message)(DxBallInt);
DxBallHandle (DXBALL_DDCALL *dxball_window_set_cursor)(DxBallHandle);
DxBallHandle (DXBALL_DDCALL *dxball_window_set_capture)(DxBallHandle);
DxBallInt (DXBALL_DDCALL *dxball_window_release_capture)(void);
DxBallInt (DXBALL_DDCALL *dxball_window_get_version_ex)(DxBallVersionInfo *);
DxBallHandle (DXBALL_DDCALL *dxball_window_load_icon)(DxBallHandle, DxBallHandle);
DxBallHandle (DXBALL_DDCALL *dxball_window_load_cursor)(DxBallHandle, DxBallHandle);
DxBallHandle (DXBALL_DDCALL *dxball_window_stock_object)(DxBallInt);
DxBallUInt (DXBALL_DDCALL *dxball_window_register_class)(const DxBallWindowClass *);
DxBallHandle (DXBALL_DDCALL *dxball_window_create_window_ex)(DxBallUInt, const char *, const char *,
DxBallUInt, DxBallInt, DxBallInt, DxBallInt, DxBallInt,
DxBallHandle, DxBallHandle, DxBallHandle, void *);
DxBallInt (DXBALL_DDCALL *dxball_window_show_window)(DxBallHandle, DxBallInt);
DxBallInt (DXBALL_DDCALL *dxball_window_update_window)(DxBallHandle);
DxBallHandle (DXBALL_DDCALL *dxball_window_set_focus)(DxBallHandle);
DxBallInt (DXBALL_DDCALL *dxball_window_destroy_window)(DxBallHandle);
DxBallInt (DXBALL_DDCALL *dxball_window_message_box)(DxBallHandle, const char *, const char *, DxBallUInt);
DxBallHandle (DXBALL_DDCALL *dxball_window_open_semaphore)(DxBallUInt,
DxBallInt, const char *);
DxBallHandle (DXBALL_DDCALL *dxball_window_create_semaphore)(
const DxBallSecurityAttributes *, DxBallInt, DxBallInt, const char *);
const char dxball_semaphore_open_name[] = "DX-Ball";
const char dxball_semaphore_create_name[] = "DX-Ball";
static void load_platform_music(const char *path, DxBallInt play)
{ (void)dxball_load_music(path, play); }
DxBallPlatformOps dxball_platform_ops = {
dxball_prepare_sound, dxball_initialize_sound, dxball_pause_sound,
dxball_resume_music, dxball_pause_music, dxball_close_music,
dxball_release_audio, load_platform_music, exit
};
DxBallKeyModeOps dxball_key_mode_ops = { {dxball_intro_key, dxball_game_key, dxball_editor_key, dxball_game_over_key}, dxball_splash_key };
DxBallHandle dxball_main_window, dxball_instance_semaphore;
DxBallInt dxball_application_active, dxball_shift_pressed, dxball_control_pressed;
DxBallInt dxball_sound_suspended, dxball_low_video_memory;
DxBallInt dxball_software_only = 1;
DxBallPoint dxball_cursor_point;
DxBallDDClipper *dxball_direct_clipper;
const char dxball_fullscreen_name[] = "DX-Ball";
const char dxball_fullscreen_factory_title[] = "DX-Ball";
const char dxball_fullscreen_factory_message[] = "Direct X could not initialize. (DX Object failed)";
const char dxball_fullscreen_cooperative_title[] = "DX-Ball";
const char dxball_fullscreen_cooperative_message[] = "Direct X could not initialize. (Exclusive/Fullscreen failed)";
const char dxball_fullscreen_display_title[] = "DX-Ball";
const char dxball_fullscreen_display_message[] = "Direct X could not initialize. (640x480 failed)";
const char dxball_fullscreen_primary_title[] = "DX-Ball";
const char dxball_fullscreen_primary_message[] = "Direct X could not initialize. (Primary Failed)";
const char dxball_compatible_name[] = "DX-Ball";
const char dxball_compatible_factory_title[] = "DX-Ball";
const char dxball_compatible_factory_message[] = "Direct X could not initialize. (DX Object failed)";
const char dxball_compatible_cooperative_title[] = "DX-Ball";
const char dxball_compatible_cooperative_message[] = "Direct X could not initialize.(Coop Normal failed)";
const char dxball_compatible_primary_title[] = "DX-Ball";
const char dxball_compatible_primary_message[] = "Direct X could not initialize. (Primary failed)";
const char dxball_compatible_board_title[] = "DX-Ball";
const char dxball_compatible_board_message[] = "Direct X could not initialize. (Offscreen failed)";
const char dxball_compatible_clipper_title[] = "DX-Ball";
const char dxball_compatible_clipper_message[] = "Direct X could not initialize.(Clipper failed)";
const char dxball_compatible_clip_window_title[] = "DX-Ball";
const char dxball_compatible_clip_window_message[] = "Direct X could not initialize. (Clipper SetHWnd failed)";
const char dxball_compatible_primary_clipper_title[] = "DX-Ball";
const char dxball_compatible_primary_clipper_message[] = "Direct X could not initialize. (Clipper->Primary failed)";
/* FUNCTION: DXBALL 0x0040CF70 */
DxBallInt dxball_initialize_fullscreen(DxBallHandle instance, DxBallInt show)
{
DxBallUInt attached;
{
DxBallInt result;
{
DxBallSurfaceDesc surface;
{
DxBallDrawCaps caps;
{
DxBallWindowClass window_class;
window_class.style = 3;
window_class.procedure = dxball_window_proc;
window_class.class_extra = 0;
window_class.window_extra = 0;
window_class.instance = instance;
window_class.icon = dxball_window_load_icon(instance, 0x7f00);
window_class.cursor = dxball_window_load_cursor(0, 0x7f00);
window_class.background = dxball_window_stock_object(4);
window_class.menu = dxball_fullscreen_name;
window_class.name = dxball_fullscreen_name;
dxball_window_register_class(&window_class);
}
dxball_main_window = dxball_window_create_window_ex(0, dxball_fullscreen_name, dxball_fullscreen_name,
0x80000000UL, 0, 0, 640, 480, 0, 0, instance, NULL);
if (dxball_main_window == 0) return 0;
dxball_window_show_window(dxball_main_window, show);
dxball_window_update_window(dxball_main_window);
dxball_window_set_focus(dxball_main_window);
dxball_window_show_window(dxball_main_window, 0);
dxball_prepare_sound(dxball_main_window);
dxball_window_show_window(dxball_main_window, 5);
result = DirectDrawCreate(NULL, &dxball_direct_draw, NULL);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_fullscreen_factory_message,
dxball_fullscreen_factory_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
result = ((DxBallSetCooperativeLevel)dxball_direct_draw->vtable->slots_7_to_21[13])(
dxball_direct_draw, dxball_main_window, 0x11);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_fullscreen_cooperative_message,
dxball_fullscreen_cooperative_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
result = ((DxBallSetDisplayMode)dxball_direct_draw->vtable->slots_7_to_21[14])(
dxball_direct_draw, 640, 480, 8);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_fullscreen_display_message,
dxball_fullscreen_display_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
dxball_draw_to_primary = 0;
caps.size = 316;
result = ((DxBallGetCaps)dxball_direct_draw->vtable->slots_7_to_21[4])(
dxball_direct_draw, &caps, NULL);
if ((caps.caps & 0x02000000UL) != 0) {
dxball_software_only = 1;
dxball_reduced_particles = 1;
} else {
dxball_software_only = 0;
dxball_reduced_particles = 0;
}
if (dxball_software_only == 0 && caps.free_video_memory < 310000UL) {
dxball_reduced_particles = 1;
dxball_low_video_memory = 1;
}
}
if (dxball_display_buffer_count == 0) {
surface.size = 108;
surface.flags = 1;
surface.caps = 0x200;
} else {
surface.size = 108;
surface.flags = 0x21;
surface.caps = 0x218;
surface.ancillary[0] = (DxBallUInt)dxball_display_buffer_count;
}
result = dxball_direct_draw->vtable->create_surface(
dxball_direct_draw, &surface, &dxball_primary_surface, NULL);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_fullscreen_primary_message,
dxball_fullscreen_primary_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
if (dxball_display_buffer_count != 0) {
attached = 4;
result = ((DxBallGetAttachedSurface)dxball_primary_surface->vtable->slot_12)(
dxball_primary_surface, &attached, &dxball_secondary_surface);
if (result != 0) {
dxball_window_destroy_window(dxball_main_window);
return 0;
}
}
surface.flags = 7;
surface.caps = 0x40;
surface.height = 480;
surface.width = 640;
result = dxball_direct_draw->vtable->create_surface(
dxball_direct_draw, &surface, &dxball_board_surface, NULL);
if (result != 0) {
dxball_window_destroy_window(dxball_main_window);
return 0;
}
if (dxball_clip_regions == 1) {
result = ((DxBallCreateClipper)dxball_direct_draw->vtable->slots_0_to_4[4])(
dxball_direct_draw, 0, &dxball_direct_clipper, NULL);
if (result != 0) {
dxball_window_destroy_window(dxball_main_window);
return 0;
}
result = dxball_direct_clipper->vtable->set_window(
dxball_direct_clipper, 0, dxball_main_window);
if (result != 0) {
dxball_window_destroy_window(dxball_main_window);
return 0;
}
result = ((DxBallSetClipper)dxball_primary_surface->vtable->set_clipper)(
dxball_primary_surface, dxball_direct_clipper);
if (result != 0) {
dxball_window_destroy_window(dxball_main_window);
return 0;
}
if (dxball_secondary_surface != NULL) {
result = ((DxBallSetClipper)dxball_secondary_surface->vtable->set_clipper)(
dxball_secondary_surface, dxball_direct_clipper);
if (result != 0) {
dxball_window_destroy_window(dxball_main_window);
return 0;
}
}
}
dxball_initialize_sprite_banks();
dxball_select_surface((DxBallSurface)dxball_primary_surface);
return 1;
}
}
}
/* FUNCTION: DXBALL 0x0040D4B0 */
DxBallInt dxball_initialize_compatible(DxBallHandle instance, DxBallInt show)
{
DxBallInt result;
{
DxBallSurfaceDesc surface;
{
DxBallDrawCaps caps;
{
DxBallWindowClass window_class;
window_class.style = 3;
window_class.procedure = dxball_window_proc;
window_class.class_extra = 0;
window_class.window_extra = 0;
window_class.instance = instance;
window_class.icon = dxball_window_load_icon(instance, 0x7f00);
window_class.cursor = dxball_window_load_cursor(0, 0x7f00);
window_class.background = dxball_window_stock_object(4);
window_class.menu = dxball_compatible_name;
window_class.name = dxball_compatible_name;
dxball_window_register_class(&window_class);
}
dxball_main_window = dxball_window_create_window_ex(0, dxball_compatible_name, dxball_compatible_name,
0x80000000UL, 0, 0, 640, 480, 0, 0, instance, NULL);
if (dxball_main_window == 0) return 0;
dxball_window_show_window(dxball_main_window, show);
dxball_window_update_window(dxball_main_window);
dxball_window_set_focus(dxball_main_window);
dxball_window_show_window(dxball_main_window, 0);
dxball_prepare_sound(dxball_main_window);
dxball_window_show_window(dxball_main_window, 5);
result = DirectDrawCreate(NULL, &dxball_direct_draw, NULL);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_compatible_factory_message,
dxball_compatible_factory_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
result = ((DxBallSetCooperativeLevel)dxball_direct_draw->vtable->slots_7_to_21[13])(
dxball_direct_draw, dxball_main_window, 8);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_compatible_cooperative_message,
dxball_compatible_cooperative_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
dxball_draw_to_primary = 1;
dxball_display_buffer_count = 0;
caps.size = 316;
result = ((DxBallGetCaps)dxball_direct_draw->vtable->slots_7_to_21[4])(
dxball_direct_draw, &caps, NULL);
if ((caps.caps & 0x02000000UL) != 0) {
dxball_software_only = 1;
} else {
dxball_software_only = 0;
}
}
surface.size = 108;
surface.flags = 1;
surface.caps = 0x200;
result = dxball_direct_draw->vtable->create_surface(
dxball_direct_draw, &surface, &dxball_primary_surface, NULL);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_compatible_primary_message,
dxball_compatible_primary_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
surface.flags = 7;
surface.caps = 0x40;
surface.height = 480;
surface.width = 640;
result = dxball_direct_draw->vtable->create_surface(
dxball_direct_draw, &surface, &dxball_board_surface, NULL);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_compatible_board_message,
dxball_compatible_board_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
if (dxball_clip_regions == 1) {
result = ((DxBallCreateClipper)dxball_direct_draw->vtable->slots_0_to_4[4])(
dxball_direct_draw, 0, &dxball_direct_clipper, NULL);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_compatible_clipper_message,
dxball_compatible_clipper_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
result = dxball_direct_clipper->vtable->set_window(
dxball_direct_clipper, 0, dxball_main_window);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_compatible_clip_window_message,
dxball_compatible_clip_window_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
result = ((DxBallSetClipper)dxball_primary_surface->vtable->set_clipper)(
dxball_primary_surface, dxball_direct_clipper);
if (result != 0) {
dxball_window_show_window(dxball_main_window, 0);
dxball_window_message_box(dxball_main_window, dxball_compatible_primary_clipper_message,
dxball_compatible_primary_clipper_title, 0);
dxball_window_destroy_window(dxball_main_window);
return 0;
}
}
dxball_initialize_sprite_banks();
dxball_select_surface((DxBallSurface)dxball_primary_surface);
return 1;
}
}
/* FUNCTION: DXBALL 0x0040DF10 */
DxBallHandle dxball_claim_instance(void)
{
DxBallSecurityAttributes attributes;
DxBallHandle opened;
attributes.length = 12; attributes.descriptor = NULL; attributes.inherit = 1;
opened = dxball_window_open_semaphore(2, 0, dxball_semaphore_open_name);
if (opened == 0) {
dxball_instance_semaphore = dxball_window_create_semaphore(
&attributes, 0, 1, dxball_semaphore_create_name);
return dxball_instance_semaphore;
} else {
return 0;
}
}
/* FUNCTION: DXBALL 0x0040DF80 */
void dxball_close_instance(void)
{
if (dxball_instance_semaphore != 0) {
dxball_file_close(dxball_instance_semaphore);
dxball_instance_semaphore = 0;
}
return;
}
/* FUNCTION: DXBALL 0x00403550 */
void dxball_detect_clock(void)
{
DxBallVersionInfo version;
version.size = sizeof(version);
dxball_window_get_version_ex(&version);
if (version.platform == 1)
dxball_high_resolution_clock = 0;
else
dxball_high_resolution_clock = 1;
return;
}
const char dxball_instance_running_title[] = "DX-Ball";
const char dxball_instance_running_message[] = "DX-Ball is already running.";
/* FUNCTION: DXBALL 0x0040D930 */
DxBallHandle DXBALL_DDCALL dxball_win_main(DxBallHandle instance,
DxBallHandle previous, DxBallHandle command_line, DxBallInt show)
{
DxBallMessage message;
DxBallInt initialized;
(void)previous;
(void)command_line;
if (dxball_claim_instance() == 0) {
dxball_window_message_box(0, dxball_instance_running_message,
dxball_instance_running_title, 0);
dxball_process_exit(0);
}
if (dxball_cursor_warp_disabled != 0) {
initialized = dxball_initialize_compatible(instance, show);
} else {
initialized = dxball_initialize_fullscreen(instance, show);
}
if (initialized == 0) return 0;
dxball_detect_clock();
dxball_initialize_trig();
dxball_control_pressed = 0;
dxball_shift_pressed = 0;
dxball_window_get_cursor_pos(&dxball_cursor_point);
dxball_mouse_x = dxball_cursor_point.x;
dxball_mouse_y = dxball_cursor_point.y;
dxball_mouse_action = 0;
for (;;) {
if (dxball_window_peek_message(&message, 0, 0, 0, 0) != 0) {
if (dxball_window_get_message(&message, 0, 0, 0) == 0)
return message.wparam;
dxball_window_translate_message(&message);
dxball_window_dispatch_message(&message);
} else {
if (dxball_application_active != 0)
dxball_dispatch_frame();
else
dxball_window_wait_message();
}
}
}
void dxball_initialize_sprite_banks(void)
{
DxBallInt bank, slot;
for (bank = 0; bank < 3; ++bank) {
dxball_sprite_banks[bank].count = 0;
slot = 0;
while (slot <= 254) {
dxball_sprite_banks[bank].sprites[slot] = NULL;
++slot;
}
}
return;
}
void dxball_dispose_working_surface(DxBallInt fade)
{
if (dxball_device_reset_requested != 0)
dxball_cleanup_mode(fade);
if (dxball_background_surface != NULL) {
dxball_background_surface->vtable->release(dxball_background_surface);
dxball_background_surface = NULL;
}
return;
}
/* FUNCTION: DXBALL 0x00403820 */
void dxball_dispatch_key(char key)
{
switch (dxball_display_mode) {
case 0:
dxball_intro_key(key);
break;
case 1:
dxball_game_key(key);
break;
case 2:
dxball_editor_key(key);
break;
case 3:
dxball_game_over_key(key);
break;
case 4:
dxball_splash_key(key);
break;
}
return;
}
/* FUNCTION: DXBALL 0x00410290 */
void dxball_game_key(char key)
{
DxBallInt choice;
if (dxball_paused == 1) {
dxball_paused = 0;
if (dxball_restart_requested == 0)
dxball_palette_transition(1, 10, 0, 255, 0);
dxball_redraw_mode();
dxball_palette_transition(1, 10, 0, 255, 1);
return;
}
switch (key) {
case 'P':
if (dxball_paused == 0) {
dxball_paused = 1;
if (dxball_restart_requested == 0)
dxball_palette_transition(1, 10, 0, 255, 0);
dxball_redraw_mode();
dxball_palette_transition(1, 10, 0, 255, 1);
}
/* Fall through to the shared space-key exit. */
case ' ':
break;
case 0x70:
if (dxball_control_pressed != 0) {
dxball_bonus_9_active = 0;
dxball_bonus_8_active = 0;
dxball_paddle_width =
dxball_sprite_banks[dxball_sprite_bank].sprites[68]->width;
}
break;
case 0x71:
if (dxball_control_pressed != 0)
dxball_bonus_9_active = 1;
break;
case 0x72:
if (dxball_control_pressed != 0)
dxball_bonus_8_active = 1;
break;
case 0x73:
if (dxball_control_pressed != 0)
dxball_paddle_width =
dxball_sprite_banks[dxball_sprite_bank].sprites[68]->width * 2;
break;
case 0x74:
choice = dxball_random_range(6);
dxball_close_music();
switch (choice) {
case 0:
dxball_load_music("12flight.mds", 1);
break;
case 1:
dxball_load_music("acker-gs.mds", 1);
break;
case 2:
dxball_load_music("brain.mds", 1);
break;
case 3:
dxball_load_music("ethno_pa.mds", 1);
break;
case 4:
dxball_load_music("freebee.mds", 1);
break;
case 5:
dxball_load_music("gmfigaro.mds", 1);
break;
}
break;
case 0x75:
dxball_close_music();
break;
case 0x76:
break;
case 0x77:
break;
case 0x78:
break;
case 0x79:
break;
case 0x7a:
break;
case 0x7b:
dxball_pan_scale = dxball_pan_scale * -1.0;
break;
}
return;
}
/* FUNCTION: DXBALL 0x0040DA70 */
DxBallWindowResult DXBALL_DDCALL dxball_window_proc(DxBallHandle window,
DxBallUInt message, DxBallHandle wparam, DxBallWindowResult lparam)
{
switch (message) {
case 0x1c:
dxball_application_active = (DxBallInt)wparam;
dxball_control_pressed = 0;
dxball_shift_pressed = 0;
break;
case 0x20:
dxball_window_set_cursor(0);
return 1;
/* Retain the original per-case switch exit after the direct return. */
break;
case 0x100:
if (wparam == 0x1b) {
if (dxball_display_mode == 0) {
dxball_cleanup_mode(1);
dxball_window_post_message(window, 0x10, 0, 0);
} else {
dxball_end_requested = 1;
dxball_return_to_menu = 0;
}
} else {
dxball_dispatch_key((char)wparam);
}
if (wparam == 0x11) dxball_control_pressed = 1;
if (wparam == 0x10) dxball_shift_pressed = 1;
break;
case 0x101:
if (wparam == 0x11) dxball_control_pressed = 0;
if (wparam == 0x10) dxball_shift_pressed = 0;
break;
case 2:
dxball_dispose_working_surface(0);
dxball_release_audio();
dxball_close_music();
if (dxball_direct_draw != NULL) {
dxball_release_sprite_banks();
if (dxball_board_surface != NULL) {
dxball_board_surface->vtable->release(dxball_board_surface);
dxball_board_surface = NULL;
}
if (dxball_primary_surface != NULL) {
dxball_primary_surface->vtable->release(dxball_primary_surface);
dxball_primary_surface = NULL;
dxball_secondary_surface = NULL;
}
if (dxball_direct_palette != NULL) {
((DxBallReleasePalette)dxball_direct_palette->vtable->slots_0_to_5[2])(
dxball_direct_palette);
dxball_direct_palette = NULL;
}
dxball_direct_draw = NULL;
}
dxball_close_instance();
dxball_window_post_quit_message((DxBallInt)wparam);
break;
case 0x48:
if (wparam == 1) dxball_sound_suspended = 1;
if (wparam == 3 || wparam == 2) dxball_sound_suspended = 0;
break;
case 0x218:
if (wparam == 0 || wparam == 4) dxball_sound_suspended = 1;
if (wparam == 2 || wparam == 6 || wparam == 7)
dxball_sound_suspended = 0;
break;
case 7:
dxball_sound_suspended = 0;
if (dxball_direct_draw != NULL)
dxball_initialize_sound(window);
dxball_resume_music();
break;
case 8:
if (dxball_sound_suspended == 0) dxball_pause_sound();
dxball_pause_music();
dxball_surface_restore_requested = 1;
break;
case 0x201:
dxball_window_set_capture(window);
dxball_mouse_action = 1;
break;
case 0x204:
dxball_window_set_capture(window);
dxball_mouse_action = 2;
break;
case 0x202:
dxball_window_release_capture();
dxball_mouse_action = 0;
break;
case 0x205:
dxball_window_release_capture();
dxball_mouse_action = 0;
break;
case 1:
case 0x14:
break;
case 0x311:
if (dxball_direct_draw != NULL && dxball_primary_surface != NULL &&
dxball_device_reset_requested == 0) {
dxball_direct_palette->vtable->set_entries(dxball_direct_palette,
0, 0, 256, dxball_live_palette);
}
break;
case 0x200:
dxball_window_get_cursor_pos(&dxball_cursor_point);
dxball_mouse_x = dxball_cursor_point.x;
dxball_mouse_y = dxball_cursor_point.y;
/* fall through */
default:
return dxball_window_default_window_proc(window, message, wparam, lparam);
}
return 0;
}