-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControl.asm
2673 lines (1859 loc) · 44.8 KB
/
Control.asm
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
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
include_macros equ 1
include_deb_mac equ 1
include_flags equ 1
include_struc equ 1
include_error_codes equ 1
include include.asm
c2_cancel_pressed equ 100 ;save cancel key pressed
c2_name_2_short equ 101 ;game name too short
c2_game_saved equ 102
c2_shifted equ 103
c2_toggled equ 104
c2_restarted equ 105
c2_game_restored equ 106
c2_restore_failed equ 107
c2_no_disk_space equ 108
c2_speed_changed equ 109
yes_mask equ 0
no_mask equ 1
max_save_games equ 999 ;no of games in total
max_text_len equ 80 ;max no of characters (multiple of 4 please)
pan_line_width equ 184 ;width of save game line (pixels)
pan_char_height equ 12 ;character set height
mpnl_x equ 60
mpnl_y equ 10
spnl_x equ 20
spnl_y equ 20
; save panel dimensions
sp_height equ 149
sp_top_gap equ 12
sp_bot_gap equ 27
game_name_x equ (spnl_x+18) ;x coordinate of game names
game_name_y equ (spnl_y+sp_top_gap) ;start y coord of game names
max_on_screen equ ((sp_height-sp_top_gap-sp_bot_gap)/pan_char_height) ;no of save games on screen
cp_panel equ 60400 ;main panel sprite
c_spr struc ;structure of a button
sp_add dd ? ;pointer to pointer to sprite
no_spr dd ? ;no of sprites in file
c_spr dd ? ;current sprite
x dd ? ;x address
y dd ? ;y address
text dd ? ;text to display
routine dd ? ;routine to call if button pressed
c_spr ends
m_draw_sprite macro number
; draw sprite esi with frame number
mov (c_spr ptr[esi]).c_spr,number
push esi
clear ebp
call c2_draw_control_sprite2
pop esi
endm
start32data
extrn text_buffer:byte ;data for text mouse pointer
ifdef cmd_options
extrn _ignore_saved_game_version:dword
endif
; Main panel variables
c2_palette_data dd ? ;pointer to panel palette
; sprites to load at start
no_init_sprites equ 10
init_sprite_file equ 60500
spp_control_panel dd ? ;pointer to control panel sprite
spp_button dd ? ;pointer to panel button
spp_dn_btn dd ? ;pointer to save panel down button
spp_save_panel dd ? ;pointer to save restore panel sprite
spp_yes_no dd ? ;pointer to yes/no sprite
spp_slide dd ? ;pointer to slider sprite
spp_slode dd ? ;pointer to slider sprite (hd)
spp_slod2 dd ? ;pointer to slider sprite (cd)
spp_slid2 dd ? ;pointer to slider sprite (cd)
spp_music_bdg dd ? ;sprite to put over music symbol on cd version
sp_control_panel c_spr <offset spp_control_panel,1,0,mpnl_x,mpnl_y,0,0> ;the main control panel
sp_exit_btn c_spr <offset spp_button,3,0,mpnl_x+16,mpnl_y+125,7000h+50,offset r_exit> ;the exit button
sp_slide c_spr <offset spp_slide,1,0,mpnl_x+19,mpnl_y+68,7000h+95,offset c2_slide> ;the speed slider
sp_slid2 c_spr <offset spp_slid2,1,0,mpnl_x+19,mpnl_y+50+6,7000h+14,offset c2_slide2> ;the music vol slider
sp_slode c_spr <offset spp_slode,1,0,mpnl_x+9 ,mpnl_y+49,0,0>
sp_rest_pan_btn c_spr <offset spp_button,3,0,mpnl_x+58,mpnl_y+19,7000h+51,offset c2_rest_game_panel> ;the restore button
sp_save_pan_btn c_spr <offset spp_button,3,0,mpnl_x+58,mpnl_y+39,7000h+48,offset c2_save_game_panel> ;the save button
sp_dos_pan_btn c_spr <offset spp_button,3,0,mpnl_x+58,mpnl_y+59,7000h+93,offset c2_quit_to_dos> ;the quit button
sp_restart_pan_btn c_spr <offset spp_button,3,0,mpnl_x+58,mpnl_y+79,7000h+94,offset c2_restart> ;the restart button
sp_fx_pan_btn c_spr <offset spp_button,3,2,mpnl_x+58,mpnl_y+99,7000h+90,offset toggle_fx> ;the fx button
sp_ms_pan_btn c_spr <offset spp_button,3,2,mpnl_x+58,mpnl_y+119,7000h+91,offset toggle_ms> ;the music button
sp_bodge c_spr <offset spp_music_bdg,2,0,mpnl_x+98,mpnl_y+115,0,0> ;the music bodge
sp_yes_no c_spr <offset spp_yes_no,1,0,mpnl_x-2,mpnl_y+40,0,0> ;yes / no panel
sp_ctext c_spr <offset spp_ctext,1,0,mpnl_x+15,mpnl_y+137,0,0> ;Some text
spp_ctext dd 0
; list of sprites to check for mouse over / mouse click, main panel
cp_look_list_no equ 8
cp_look_list dd offset sp_exit_btn
dd offset sp_rest_pan_btn
dd offset sp_save_pan_btn
dd offset sp_dos_pan_btn
dd offset sp_restart_pan_btn
dd offset sp_fx_pan_btn
dd offset sp_ms_pan_btn
dd offset sp_slide
dd offset sp_slid2
; save game variables
sp_save_panel c_spr <offset spp_save_panel,1,0,spnl_x,spnl_y,0,0> ;the save panel sprite
sp_look_list_no equ 6 ;buttons to check
sp_look_list dd offset sp_save_btn ;\ save panel
rp_look_list dd offset sp_dn_btn ;| \ restore panel
dd offset sp_dn_btn2 ;| |
dd offset sp_up_btn ;| |
dd offset sp_up_btn2 ;| |
dd offset sp_quit_btn ;/ :
dd offset sp_rest_btn ; /
sp_save_btn c_spr <offset spp_button,3,0,spnl_x+29,spnl_y+129,7000h+48,c2_save_a_game> ;save a real game
sp_dn_btn c_spr <offset spp_dn_btn,1,0,spnl_x+212,spnl_y+104,0,c2_shift_down_fast> ;shift games down
sp_dn_btn2 c_spr <offset spp_dn_btn,1,0,spnl_x+212,spnl_y+114,0,c2_shift_down_slow> ;shift games down
sp_up_btn c_spr <offset spp_dn_btn,1,0,spnl_x+212,spnl_y+21,0,c2_shift_up_fast> ;shift games up
sp_up_btn2 c_spr <offset spp_dn_btn,1,0,spnl_x+212,spnl_y+10,0,c2_shift_up_slow> ;shift games up
sp_quit_btn c_spr <offset spp_button,3,0,spnl_x+72,spnl_y+129,7000h+49,offset c2_sp_cancel>
sp_rest_btn c_spr <offset spp_button,3,0,spnl_x+29,spnl_y+129,7000h+51,c2_restore_a_game> ;restore a real game
init_text dd 0
restore_fx_flag dd ? ;set this if we want to restart fx when we leave the panel
character_list db " ,().='-& +!?" ;list of valid characters
db '"',0
align 4
; Slider variables
panel_int dd 0 ;set this when panel first run
sl_sp_top_y dd (mpnl_y + 52) ;speed slider top y
sl_sp_bot_y dd (mpnl_y + 92) ;speed slider bottom y
sl_sp_range dd (mpnl_y + 92)-(mpnl_y + 52)
sl_sp_devidor dd 4 ;step size
sl_ms_top_y dd (mpnl_y + 49) ;volume slider top y
sl_ms_bot_y dd (mpnl_y + 81) ;volume slider bottom y
sl_ms_range dd (mpnl_y + 81)-(mpnl_y + 49)
music_volume dd 27 ;31 ;music volume multiplier
end32data
start32save_data
saved_char_set dd ?
save_mouse_type dd 0
save_m_off_x dd 0
save_m_off_y dd 0
end32save_data
start32code
control_panel proc
ifdef s1_demo
ret
endif
test [panel_int],-1 ;only do this once
jne not_sb
; Change some things for the cd/sblaster version
bt [system_flags],sf_sblaster ;sblaster only
jnc not_sb
mov (c_spr ptr[sp_slode]).sp_add,offset spp_slod2
mov (c_spr ptr[sp_slide]).sp_add,offset spp_slid2
mov (c_spr ptr[sp_slide]).y,(mpnl_y + 99)
mov [sl_sp_top_y],(mpnl_y + 95) ;speed slider top y
mov [sl_sp_bot_y],(mpnl_y + 105) ;speed slider bottom y
mov [sl_sp_range],(mpnl_y + 105)-(mpnl_y + 95)
mov [sl_sp_devidor],1
test [_cd_version],-1
je not_cd
mov (c_spr ptr[sp_ms_pan_btn]).c_spr,0
mov (c_spr ptr[sp_ms_pan_btn]).text,35+7000h
mov (c_spr ptr[sp_bodge]).c_spr,1
not_cd: mov [panel_int],1
not_sb: call set_up_control_panel_data
; Now print out the main control panel
new_control_panel: call flush_key_buffer
call remove_mouse
call clear_screen
mov esi,offset sp_control_panel
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_exit_btn
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_save_pan_btn
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_rest_pan_btn
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_dos_pan_btn
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_restart_pan_btn
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_fx_pan_btn
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_ms_pan_btn
mov ebp,no_mask
call c2_draw_control_sprite2
mov esi,offset sp_slode
mov ebp,yes_mask
printf "1"
call c2_draw_control_sprite2
mov esi,offset sp_slide
mov ebp,yes_mask
printf "2"
call c2_draw_control_sprite2
mov esi,offset sp_bodge
mov ebp,yes_mask
printf "3"
call c2_draw_control_sprite2
printf "4"
bt [system_flags],sf_sblaster ;sblaster only
jnc not_cd2
mov esi,offset sp_slid2
mov ebp,yes_mask
call c2_draw_control_sprite2
not_cd2: mov eax,[init_text]
jife eax,no_init_text
call control_text
mov [init_text],0
no_init_text: btr [mouse_flag],mf_no_update
call fn_normal_mouse
; Loop round looking for something to do
control_loop: mov esi,offset cp_look_list
mov ecx,cp_look_list_no
;test [_cd_version],-1 ;xtra slide in cd + sblaster combination
;je look_loop
bt [system_flags],sf_sblaster
jnc look_loop
inc ecx
look_loop: push esi
mov esi,[esi]
call c2_check_for_hit
pop esi
je btn_hit
lea esi,4[esi]
loop look_loop
; No buttons
call c2_restore_button_screen ;restore screen under button text
mov [bmouse_b],0
control_key: call fetch_key
je control_loop
cmp ax,27
je r_exit2
cmp ax,13
je r_exit2
jmp control_loop
btn_hit: ;The mouse is over a button, we must print up some text
mov esi,[esi]
call c2_button_control
test [mouse_b],-1
je control_key
call c2_kill_button
call (c_spr ptr[esi]).routine
; Check return value
cmp eax,c2_cancel_pressed
je new_control_panel
cmp eax,c2_toggled
je control_loop
cmp eax,c2_speed_changed
je control_loop
cmp eax,c2_game_saved
je r_exit2
cmp eax,c2_game_restored
je r_exit2
cmp eax,c2_restarted
je r_exit2
jmp new_control_panel
; End control panel
r_exit:: pop eax ;trash return address
m_draw_sprite 2 ;press button
mov (c_spr ptr[esi]).c_spr,0
r_exit2: call disinstall_control_panel
; Check if we must restart any sound fx
test [restore_fx_flag],-1
je no_rst_fx
call restore_saved_effects_0 ;restore any constant sound fx
no_rst_fx: ret
control_panel endp
toggle_fx_kbd proc
; Called from keyboard so no control data has been set up
mov esi,offset sp_fx_pan_btn
xor (c_spr ptr[esi]).c_spr,2
btc [system_flags],sf_fx_off
jc was_off
clear eax
call fn_suspend_fx
mov eax,1
call fn_suspend_fx
ret
was_off: call restore_saved_effects_0 ;restore any constant sound fx
call restore_saved_effects_1 ;restore any constant sound fx
ret
toggle_fx_kbd endp
toggle_fx proc
push esi
call remove_mouse
pop esi
xor (c_spr ptr[esi]).c_spr,2
mov ebp,no_mask
call c2_draw_control_sprite2
btc [system_flags],sf_fx_off
jc was_off
; Turn fx off
clear eax
call fn_suspend_fx
mov eax,1
call fn_suspend_fx
mov [restore_fx_flag],0 ;don't restart them when we leave
mov eax,7000h+87 ;text for fx off
jmp was_on
was_off: mov [restore_fx_flag],1 ;restart fx when we leave
mov eax,7000h+86 ;text for fx on
was_on: call control_text
call restore_mouse
call wait_mouse_not_pressed
mov eax,c2_toggled
ret
toggle_fx endp
toggle_ms_kbd proc
; Called from keyboard so no control data has been set up
mov esi,offset sp_ms_pan_btn
xor (c_spr ptr[esi]).c_spr,2
btc [system_flags],sf_mus_off
jc was_off
call stop_music
ret
was_off: call restart_current_music
ret
toggle_ms_kbd endp
toggle_ms proc
test [_cd_version],-1
je not_cd
; flip between text, speech and text&speech
; 35 21 52
ifndef american_cd
cmp (c_spr ptr[esi]).text,35+7000h
je was_text_only
endif
cmp (c_spr ptr[esi]).text,21+7000h
je was_speech_only
; text only to text and speech to speech only
bts [system_flags],sf_allow_speech
mov eax,21+7000h
jmp cgot
was_text_only: ;speech only to text only to speech and text
bts [system_flags],sf_allow_text
btr [system_flags],sf_allow_speech
mov eax,52+7000h
jmp cgot
was_speech_only: ;text and speech to speech only to text only
btr [system_flags],sf_allow_text
mov eax,35+7000h
cgot: xchg (c_spr ptr[esi]).text,eax
push esi
call control_text
pop esi
call c2_depress_button_2 ;wait until mouse released
mov eax,c2_toggled
ret
cdun: mov (c_spr ptr[esi]).text,eax
not_cd: push esi
call remove_mouse
btc [system_flags],sf_mus_off
jc was_off
call stop_music
mov eax,7000h+89
jmp was_on
was_off: call restart_current_music
mov eax,7000h+88
was_on: call control_text
pop esi
xor (c_spr ptr[esi]).c_spr,2
mov ebp,no_mask
call c2_draw_control_sprite2
call restore_mouse
call wait_mouse_not_pressed
mov eax,c2_toggled
ret
toggle_ms endp
control_text proc
; Draw up some text on the screen
; Do text eax
push eax
mov eax,[spp_ctext]
jife eax,no_free
call my_free
no_free: pop eax
; Now do the text
call get_text
mov dl,-1
mov ecx,140
clear ebx
mov esi,offset text_buffer
mov ebp,1
call display_text
mov [spp_ctext],eax
push es
mov es,[screen_segment]
mov edi,163*320 + 66
lea esi,SIZE s[eax]
movzx ebx,(s ptr[eax]).s_width
movzx edx,(s ptr[eax]).s_height
add esi,ebx
sub edx,2
ct_ylop: mov ecx,ebx
push edi
ct_xlop: lodsb
jifne al,not0
mov al,34
not0: stosb
floop ecx,ct_xlop
pop edi
lea edi,320[edi]
floop edx,ct_ylop
pop es
ret
control_text endp
set_up_control_panel_data proc
; First save the current mouse status
call fn_pause_fx
mov eax,[mouse_type2]
mov [save_mouse_type],eax
mov eax,[mouse_offset_x]
mov [save_m_off_x],eax
mov eax,[mouse_offset_y]
mov [save_m_off_y],eax
call fn_disk_mouse
mov eax,60510 ;load in the palette
clear edx
call load_file
mov [c2_palette_data],eax
mov eax,[cur_char_set] ;save current character set
mov [saved_char_set],eax
; load in the character set
mov eax,2
call fn_set_font
; Load in the essential sprites
mov eax,init_sprite_file
mov ecx,no_init_sprites
mov edi,offset spp_control_panel
init_load_loop: push eax
push ecx
push edi
clear edx
call load_file
pop edi
stosd
pop ecx
pop eax
inc eax
loop init_load_loop
call remove_mouse
call clear_screen
mov esi,[c2_palette_data]
call set_palette
; Set up some memory locations
mov eax,max_save_games*max_text_len
call my_malloc
mov [c2_save_game_texts],eax
ret
set_up_control_panel_data endp
disinstall_control_panel proc
; free up the memory we used
call remove_mouse
r_exit2: mov eax,[c2_palette_data]
call my_free
ifdef mem_check
mov [c2_palette_data],0
endif
mov esi,offset spp_control_panel ;free panel sprites
mov ecx,no_init_sprites
free_loop1: lodsd
ifdef mem_check
mov dpt[esi-4],0
endif
push esi
push ecx
call my_free
pop ecx
pop esi
loop free_loop1
mov eax,[c2_save_game_texts]
call my_free
ifdef mem_check
mov [c2_save_game_texts],0 ;for checking it was freed]
endif
mov esi,offset c2_text_sprites ;free saved game sprites
mov ecx,max_on_screen
free_loop91: clear eax
xchg eax,[esi]
jife eax,no_91
push esi
push ecx
call my_free
pop ecx
pop esi
lea esi,4[esi]
no_91: loop free_loop91
mov eax,[c2_edit_sprite]
jife eax,no_espr
call my_free
mov [c2_edit_sprite],0
no_espr: call fn_force_refresh
mov [bmouse_b],0
mov eax,[saved_char_set]
call fn_set_font
call wait_mouse_not_pressed
call clear_screen
mov eax,[current_palette]
call fn_set_palette
call restore_mouse
; restore mouse data
mov eax,[save_mouse_type]
mov ebx,[save_m_off_x]
mov [mouse_offset_x],ebx
mov ecx,[save_m_off_y]
mov [mouse_offset_y],ecx
; If mouse type == 0 we have an object fing
jife eax,obj_mouse
call sprite_mouse
jmp mouse_done
obj_mouse: call fn_close_hand
mouse_done:
call flush_key_buffer
call fn_un_pause_fx
ret
disinstall_control_panel endp
restore_a_game_from_disk proc
; edx points to name of file to load
push edx
call _open_for_read__Npc
or eax,eax
js no_restore
; mov ax,3d00h ;open the file
; clear ecx
; dos_int
; jc no_restore
; cause an error if versions changed
push eax
clear eax
call fn_stop_fx
mov eax,1
call fn_stop_fx
call fn_flush_buffers
pop ebx
mov edx,offset start_of_save_data ;read the data length
mov ecx,4
mov ah,3fh
int 21h
jc restore_error
mov edx,offset start_of_save_data + 4 ;read the data
mov ecx,[start_of_save_data]
mov eax,offset end_of_save_data ;check sizes are the same
sub eax,offset start_of_save_data
cmp eax,ecx
je gamok
program_error em_invalid_save
gamok: sub ecx,4
mov ah,3fh
int 21h
jc restore_error
; Now read the saved games replay data
ifdef with_replay
bt [system_flags],sf_replay_rst
jc no_rep_lod
mov edx,offset start_of_save_data ;read the data length
mov ecx,4
mov ah,3fh
int 21h
jc restore_error
mov eax,[start_of_save_data]
mov [replay_data_len],eax
mov [replay_data_ptr],eax
push ebx
add eax,40 ;play safe
call my_malloc
pop ebx
mov [replay_data],eax
mov edx,eax
mov ecx,[start_of_save_data]
mov ah,3fh
int 21h
no_rep_lod:
endif
mov ah,3eh ;and close the file
int 21h
ifdef with_replay
bt [system_flags],sf_replay_rst
jc no_rep_lod2
call rewrite_replay_file ;new replay file
no_rep_lod2:
endif
call load_grids ;reload fresh grids
call restore_file_lists
call fn_text_kill2
ifndef s1_demo
mov eax,[current_section]
call fn_leave_section
endif
mov eax,[save_current_section]
call fn_enter_section
mov eax,[saved_current_music]
call fn_start_music
call restore_saved_effects_0 ;restore any constant sound fx
call restore_saved_effects_1 ;restore any constant sound fx
mov eax,c2_game_restored
bts [system_flags],sf_game_restored
ret
no_restore: mov eax,c2_restore_failed
ret
restore_error: program_error em_disk_rd_error
restore_a_game_from_disk endp
force_restart proc
bts [system_flags],sf_replay_rst
call fn_fade_down
mov edx,[restart_name_p]
call restore_a_game_from_disk
call fn_force_refresh
call re_create
call sprite_engine
call flip
clear eax ;ensure module 0 and 1 in
call check_module_loaded
mov eax,1
call check_module_loaded
mov eax,[current_palette]
call fn_fade_up
bts [system_flags],sf_game_restored
btr [system_flags],sf_replay_rst
ret
force_restart endp
fn_restore_game proc
ifdef s1_demo
ret
endif
call set_up_control_panel_data
call fn_normal_mouse
clear esi ;no button to push
call c2_rest_game_panel
call disinstall_control_panel
clear eax
ret
fn_restore_game endp
fn_restart_game proc
call force_restart
clear eax
ret
fn_restart_game endp
end32code
;--------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------
start32data
c2_save_game_texts dd ? ;Pointer to game numbers and text stored here
c2_text_sprites dd max_on_screen dup (0) ;pointers to the text sprites
c2_text_c_spr c_spr <0,1,0,game_name_x,0> ;c_spr for displaying texts
c2_desc_file dd ? ;file handle of description files
c2_desc_temp dd ? ;temporary store for loading description file
c2_desc_size dd ? ;size of desc file
c2_cur_button dd ? ;mouse is over this button
c2_cur_but_textn dd 0 ;text for current button
c2_cur_but_text_sp dd 0 ;pointer to button text sprite
c2_button_screen c_spr <offset c2_cur_but_text_sp,1,0,0,0>
c2_button_save_dat dd ?
c2_button_save_adr dd ?
c2_button_save_wid dd ?
c2_button_save_hig dd ?
c2_game_on_top dd 0 ;game number on top of list
c2_edit_game dd 0 ;no of game selected
c2_edit_text db max_text_len dup (?) ;text being edited
c2_edit_cursor dd ? ;location of cursor
c2_edit_sprite dd 0 ;pointer to text being edited
c2_edit_width dd ? ;width of line in editor buffer (pixels)
c2_allow_edit dd ? ;set if we can edit text
end32data
start32code
c2_load_save_descriptions proc
; Set up blank numbers for the save game texts
mov ecx,max_save_games
mov ebx,312020h ;convoluted game counter
mov eax,[c2_save_game_texts]
aloc_loop: mov [eax],ebx ;put game number in, followed by