-
Notifications
You must be signed in to change notification settings - Fork 2
/
menu.c
5332 lines (4546 loc) · 123 KB
/
menu.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
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
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "quakedef.h"
/* speud - begin */
#include <kos.h>
#include "vmu_config.h"
#include "vmu_state.h"
#include "vmu_misc.h"
#include "purupuru.h"
void load_defaultConfig(void);
/* speud - end */
#undef _WIN32
//#ifdef _WIN32
//#include "winquake.h"
//#endif
// Manoel Kasimier - begin
cvar_t help_pages = {"help_pages","6", false};
cvar_t sv_aim_h;
cvar_t sv_aim;
cvar_t scr_ofsy;
cvar_t crosshair;
cvar_t crosshair_color;
cvar_t r_drawviewmodel;
cvar_t cl_nobob;
cvar_t sv_idealpitchscale;
cvar_t r_drawentities;
cvar_t r_fullbright;
cvar_t r_waterwarp;
cvar_t d_mipscale;
cvar_t gl_polyblend;
cvar_t axis_x_function;
cvar_t axis_y_function;
cvar_t axis_l_function;
cvar_t axis_r_function;
cvar_t axis_x_scale;
cvar_t axis_y_scale;
cvar_t axis_l_scale;
cvar_t axis_r_scale;
cvar_t axis_pitch_dz;
cvar_t axis_yaw_dz;
cvar_t axis_walk_dz;
cvar_t axis_strafe_dz;
cvar_t sbar_show_scores;
cvar_t sbar_show_ammolist;
cvar_t sbar_show_weaponlist;
cvar_t sbar_show_keys;
cvar_t sbar_show_runes;
cvar_t sbar_show_powerups;
cvar_t sbar_show_armor;
cvar_t sbar_show_health;
cvar_t sbar_show_ammo;
cvar_t sbar_x;
cvar_t sbar_y;
cvar_t sbar;
void Crosshair_Start (int x, int y);
// Manoel Kasimier - end
/* speud - new cvars begin */
cvar_t purupuru_port;
cvar_t purupuru_unit;
cvar_t purupuru_enabled;
cvar_t purupuru_freq;
cvar_t purupuru_pow;
cvar_t vmu_port;
cvar_t vmu_unit;
cvar_t vmu_autosave;
cvar_t vmu_disp;
cvar_t vid_screen_x;
cvar_t vid_screen_y;
cvar_t vid_screen_width;
cvar_t vid_screen_height;
cvar_t vid_disp_mode;
/* speud - new cvars end */
void (*vid_menudrawfn)(void);
void (*vid_menukeyfn)(int key);
//enum {m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, m_net, m_options, m_controller, m_mouse, m_gameplay, m_audio, m_video, m_developer, m_keys, m_help, m_quit, m_serialconfig, m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist} m_state; // Edited by Manoel Kasimier
enum {m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, m_net, m_options, m_controller, m_mouse, m_gameplay, m_audio, m_video, m_vmu, m_purupuru, m_developer, m_keys, m_help, m_quit, m_serialconfig, m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist} m_state;
void M_Off (void); // Manoel Kasimier
void M_Main_f (void);
void M_SinglePlayer_f (void);
void M_Load_f (void);
void M_Save_f (void);
void M_MultiPlayer_f (void);
void M_Setup_f (void);
void M_Net_f (void);
void M_Options_f (void);
void M_Keys_f (void);
void M_Controller_f (void);
void M_Mouse_f (void);
void M_Gameplay_f (void);
void M_Audio_f (void);
void M_Video_f (void);
void M_Vmu_f (void);
void M_Purupuru_f (void);
void M_Developer_f (void);
void M_Help_f (void);
void M_Quit_f (void);
void M_SerialConfig_f (void);
void M_ModemConfig_f (void);
void M_LanConfig_f (void);
void M_GameOptions_f (void);
void M_Menu_MapList_f (void);
void M_MapList_Draw (void);
void M_MapList_Key (int key);
void M_Search_f (void);
void M_ServerList_f (void);
void M_Main_Draw (void);
void M_SinglePlayer_Draw (void);
void M_Load_Draw (void);
void M_Save_Draw (void);
void M_MultiPlayer_Draw (void);
void M_Setup_Draw (void);
void M_Net_Draw (void);
void M_Options_Draw (void);
void M_Keys_Draw (void);
void M_Controller_Draw (void);
void M_Mouse_Draw (void);
void M_Gameplay_Draw (void);
void M_Audio_Draw (void);
void M_Video_Draw (void);
void M_Vmu_Draw (void);
void M_Purupuru_Draw (void);
void M_Developer_Draw (void);
void M_Help_Draw (void);
void M_Quit_Draw (void);
void M_SerialConfig_Draw (void);
void M_ModemConfig_Draw (void);
void M_LanConfig_Draw (void);
void M_GameOptions_Draw (void);
void M_Search_Draw (void);
void M_ServerList_Draw (void);
void M_Main_Key (int key);
void M_SinglePlayer_Key (int key);
void M_Load_Key (int key);
void M_Save_Key (int key);
void M_MultiPlayer_Key (int key);
void M_Setup_Key (int key);
void M_Net_Key (int key);
void M_Options_Key (int key);
void M_Keys_Key (int key);
void M_Controller_Key (int key);
void M_Mouse_Key (int key);
void M_Gameplay_Key (int key);
void M_Audio_Key (int key);
void M_Video_Key (int key);
void M_Vmu_Key (int key);
void M_Purupuru_Key (int key);
void M_Developer_Key (int key);
void M_Help_Key (int key);
void M_Quit_Key (int key);
void M_SerialConfig_Key (int key);
void M_ModemConfig_Key (int key);
void M_LanConfig_Key (int key);
void M_GameOptions_Key (int key);
void M_Search_Key (int key);
void M_ServerList_Key (int key);
qboolean m_entersound; // play after drawing a frame, so caching
// won't disrupt the sound
qboolean m_recursiveDraw;
int m_return_state;
qboolean m_return_onerror;
char m_return_reason [32];
#define StartingGame (m_multiplayer_cursor == 1)
#define JoiningGame (m_multiplayer_cursor == 0)
#define SerialConfig (m_net_cursor == 0)
#define DirectConfig (m_net_cursor == 1)
#define IPXConfig (m_net_cursor == 2)
#define TCPIPConfig (m_net_cursor == 3)
void M_ConfigureNetSubsystem(void);
// BlackAura (28-12-2002) - Alternate menu background fading
void Draw_FadeScreen2 (int level);
static int fade_level = 0;
/*
================
M_DrawCharacter
Draws one solid graphics character
================
*/
void M_DrawCharacter (int cx, int line, int num)
{
Draw_Character ( cx + ((vid.width - 320)>>1), line, num);
}
void M_Print (int cx, int cy, char *str)
{
while (*str)
{
M_DrawCharacter (cx, cy, (*str)+128);
str++;
cx += 8;
}
}
void M_PrintWhite (int cx, int cy, char *str)
{
while (*str)
{
M_DrawCharacter (cx, cy, *str);
str++;
cx += 8;
}
}
void M_DrawTransPic (int x, int y, qpic_t *pic)
{
Draw_TransPic (x + ((vid.width - 320)>>1), y, pic);
}
void M_DrawPic (int x, int y, qpic_t *pic)
{
Draw_Pic (x + ((vid.width - 320)>>1), y, pic);
}
byte identityTable[256];
byte translationTable[256];
void M_BuildTranslationTable(int top, int bottom)
{
int j;
byte *dest, *source;
for (j = 0; j < 256; j++)
identityTable[j] = j;
dest = translationTable;
source = identityTable;
memcpy (dest, source, 256);
if (top < 128) // the artists made some backwards ranges. sigh.
memcpy (dest + TOP_RANGE, source + top, 16);
else
for (j=0 ; j<16 ; j++)
dest[TOP_RANGE+j] = source[top+15-j];
if (bottom < 128)
memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
else
for (j=0 ; j<16 ; j++)
dest[BOTTOM_RANGE+j] = source[bottom+15-j];
}
void M_DrawTransPicTranslate (int x, int y, qpic_t *pic)
{
Draw_TransPicTranslate (x + ((vid.width - 320)>>1), y, pic, translationTable);
}
int textbox_hack = 0; // Manoel Kasimier - crosshair
void M_DrawTextBox (int x, int y, int width, int lines)
{
qpic_t *p;
int cx, cy;
int n;
// draw left side
cx = x;
cy = y;
p = Draw_CachePic ("gfx/box_tl.lmp");
M_DrawTransPic (cx, cy, p);
p = Draw_CachePic ("gfx/box_ml.lmp");
for (n = 0; n < lines; n++)
{
cy += 8;
M_DrawTransPic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bl.lmp");
M_DrawTransPic (cx, cy+8-textbox_hack, p); // Manoel Kasimier - crosshair - edited
// draw middle
cx += 8;
while (width > 0)
{
cy = y;
p = Draw_CachePic ("gfx/box_tm.lmp");
M_DrawTransPic (cx, cy, p);
p = Draw_CachePic ("gfx/box_mm.lmp");
for (n = 0; n < lines; n++)
{
cy += 8;
if (n == 1)
p = Draw_CachePic ("gfx/box_mm2.lmp");
M_DrawTransPic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bm.lmp");
M_DrawTransPic (cx, cy+8-textbox_hack, p); // Manoel Kasimier - crosshair - edited
width -= 2;
cx += 16;
}
// draw right side
cy = y;
p = Draw_CachePic ("gfx/box_tr.lmp");
M_DrawTransPic (cx-textbox_hack, cy, p); // Manoel Kasimier - crosshair - edited
p = Draw_CachePic ("gfx/box_mr.lmp");
for (n = 0; n < lines; n++)
{
cy += 8;
M_DrawTransPic (cx-textbox_hack, cy, p); // Manoel Kasimier - crosshair - edited
}
p = Draw_CachePic ("gfx/box_br.lmp");
M_DrawTransPic (cx-textbox_hack, cy+8-textbox_hack, p); // Manoel Kasimier - crosshair - edited
}
#define SLIDER_RANGE 10
void M_DrawSlider (int x, int y, float range)
{
int i;
if (range < 0)
range = 0;
if (range > 1)
range = 1;
M_DrawCharacter (x-8, y, 128);
for (i=0 ; i<SLIDER_RANGE ; i++)
M_DrawCharacter (x + i*8, y, 129);
M_DrawCharacter (x+i*8, y, 130);
M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
}
void M_DrawCheckbox (int x, int y, int on)
{
#if 0
if (on)
M_DrawCharacter (x, y, 131);
else
M_DrawCharacter (x, y, 129);
#endif
if (on)
M_Print (x, y, "on");
else
M_Print (x, y, "off");
}
// Manoel Kasimier - begin
void M_DrawPlaque (char *c, qboolean b)
{
qpic_t *p;
if (b)
M_DrawTransPic (16, 12, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic (c);
M_DrawTransPic ( (320-p->width)/2, 12, p);
}
// Manoel Kasimier - end
//=============================================================================
//=============================================================================
// Manoel Kasimier - begin
//=============================================================================
/* ON-SCREEN KEYBOARD */
#define NUM_KEYCODES 52
int keyboard_active;
int keyboard_cursor;
int keyboard_shift;
int keycodes[] =
{
'0','1','2','3','4','5','6','7','8','9','-','+','/','|', 92,'_',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
'q','r','s','t','u','v','w','x','y','z','"',';','.','!','?', K_SPACE,
'<','>','(',')','[',']','{','}','@','#','$','%','^','&','*','=',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z', 39,':',',','`','~', K_SPACE,
K_BACKSPACE, K_SHIFT, K_TAB, K_ENTER
};
void M_OnScreenKeyboard_Reset (void)
{
keyboard_active = keyboard_cursor = keyboard_shift = 0;
}
void M_OnScreenKeyboard_Draw (int y)
{
int i;
if (!keyboard_active)
return;
M_DrawTextBox (16, y, 33, 5);
for (i=0; i<47; i++)
M_PrintWhite (36 + i*16 - (256*(i/16)), y+12+(8*(i/16)), Key_KeynumToString (keycodes[i+keyboard_shift]));
i=96;
M_Print (36 , y+36, Key_KeynumToString (keycodes[i++]));
M_Print (36+11*8 , y+36, Key_KeynumToString (keycodes[i++]));
M_Print (36+18*8 , y+36, Key_KeynumToString (keycodes[i++]));
M_Print (36+23*8 , y+36, Key_KeynumToString (keycodes[i++]));
if (keyboard_cursor < 48)
{
M_DrawCharacter (27+ keyboard_cursor*16 - (256*(keyboard_cursor/16)), y+12+(8*(keyboard_cursor/16)), 16);
M_DrawCharacter (44+ keyboard_cursor*16 - (256*(keyboard_cursor/16)), y+12+(8*(keyboard_cursor/16)), 17);
}
else if (keyboard_cursor == 48)
M_DrawCharacter (28 , y+36, 12+((int)(realtime*4)&1));
else if (keyboard_cursor == 49)
M_DrawCharacter (28+11*8 , y+36, 12+((int)(realtime*4)&1));
else if (keyboard_cursor == 50)
M_DrawCharacter (28+18*8 , y+36, 12+((int)(realtime*4)&1));
else if (keyboard_cursor == 51)
M_DrawCharacter (28+23*8 , y+36, 12+((int)(realtime*4)&1));
}
int M_OnScreenKeyboard_Key (int key)
{
if (!keyboard_active)
{
if (key == K_DC_A)
{
M_OnScreenKeyboard_Reset();
keyboard_active = 1;
}
else
return key;
}
else switch (key)
{
case K_DC_B:
M_OnScreenKeyboard_Reset();
break;
case K_DPAD1_LEFT:
if (--keyboard_cursor < 0)
keyboard_cursor = NUM_KEYCODES-1;
break;
case K_DPAD1_RIGHT:
if (++keyboard_cursor >= NUM_KEYCODES)
keyboard_cursor = 0;
break;
case K_DPAD1_UP:
if (keyboard_cursor >= 48)
keyboard_cursor = 48;
keyboard_cursor-=16;
if (keyboard_cursor < 0)
keyboard_cursor = NUM_KEYCODES-4;
break;
case K_DPAD1_DOWN:
if (keyboard_cursor < 32)
keyboard_cursor+=16;
else if (keyboard_cursor < 48)
keyboard_cursor = NUM_KEYCODES-4;
else
keyboard_cursor = 0;
break;
case K_DC_LTRIG:
return K_BACKSPACE;
case K_DC_RTRIG:
return K_SPACE;
case K_DC_A:
if (keyboard_cursor < 48)
return keycodes[keyboard_cursor+keyboard_shift];
else if (keyboard_cursor == 49)
keyboard_shift = (!keyboard_shift)*48;
else
return keycodes[keyboard_cursor+48];
case K_DC_X:
return K_TAB;
case K_DC_Y:
return K_ENTER;
default:
return key;
}
return 0;
}
//=============================================================================
// Manoel Kasimier - end
//=============================================================================
int m_save_demonum;
// Manoel Kasimier additions - begin
void M_Off (void) // turns the menu off
{
/* speud - save config begin */
if (vmu_autosave.value)
Host_WriteConfiguration();
/* speud - save config end */
key_dest = key_game;
m_state = m_none;
cls.demonum = m_save_demonum;
if (cls.demonum != -1 && !cls.demoplayback && cls.state != ca_connected)
CL_NextDemo ();
}
// Manoel Kasimier additions - end
/*
================
M_ToggleMenu_f
================
*/
void M_ToggleMenu_f (void)
{
m_entersound = true;
if (key_dest == key_menu)
{
if (m_state != m_main)
{
M_Main_f ();
return;
}
key_dest = key_game;
m_state = m_none;
return;
}
if (key_dest == key_console)
{
Con_ToggleConsole_f ();
}
else
{
M_Main_f ();
}
}
#if 0
void _ (){}
#endif
//=============================================================================
/* MAIN MENU */
int m_main_cursor;
#define MAIN_ITEMS 5
void M_Main_f (void)
{
if (key_dest != key_menu)
{
m_save_demonum = cls.demonum;
cls.demonum = -1;
}
key_dest = key_menu;
m_state = m_main;
m_entersound = true;
}
void M_Main_Draw (void)
{
M_DrawPlaque ("gfx/ttl_main.lmp", true); // Manoel Kasimier
M_DrawTransPic (72, 40, Draw_CachePic ("gfx/mainmenu.lmp") );
M_DrawTransPic (54, 40 + m_main_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", 1+((int)(realtime * 10)%6) ) ) ); // edited by Manoel Kasimier
}
void M_Main_Key (int key)
{
switch (key)
{
case K_ESCAPE:
case K_DC_START:
M_Off ();
break;
case K_DOWNARROW:
case K_DPAD1_DOWN:
S_LocalSound ("misc/menu1.wav");
if (++m_main_cursor >= MAIN_ITEMS)
m_main_cursor = 0;
break;
case K_UPARROW:
case K_DPAD1_UP:
S_LocalSound ("misc/menu1.wav");
if (--m_main_cursor < 0)
m_main_cursor = MAIN_ITEMS - 1;
break;
case K_ENTER:
case K_DC_A:
m_entersound = true;
switch (m_main_cursor)
{
case 0:
M_SinglePlayer_f ();
break;
case 1:
M_GameOptions_f (); // Manoel Kasimier
//M_MultiPlayer_f (); // Commented out by Manoel Kasimier
break;
case 2:
M_Options_f ();
break;
case 3:
M_Help_f ();
break;
case 4:
M_Quit_f ();
break;
}
}
}
//=============================================================================
/* SINGLE PLAYER MENU */
int m_singleplayer_cursor;
#define SINGLEPLAYER_ITEMS 3
void M_SinglePlayer_f (void)
{
key_dest = key_menu;
m_state = m_singleplayer;
m_entersound = true;
}
void M_SinglePlayer_Draw (void)
{
M_DrawPlaque ("gfx/ttl_sgl.lmp", true); // Manoel Kasimier
M_DrawTransPic (72, 40, Draw_CachePic ("gfx/sp_menu.lmp") );
M_DrawTransPic (54, 40 + m_singleplayer_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", 1+((int)(realtime * 10)%6) ) ) );
}
void M_SinglePlayer_Key (int key)
{
switch (key)
{
case K_DC_START:
M_Off (); // Manoel Kasimier
break;
case K_ESCAPE:
case K_DC_B: // Manoel Kasimier
M_Main_f ();
break;
case K_DOWNARROW:
case K_DPAD1_DOWN:
S_LocalSound ("misc/menu1.wav");
if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
m_singleplayer_cursor = 0;
break;
case K_UPARROW:
case K_DPAD1_UP:
S_LocalSound ("misc/menu1.wav");
if (--m_singleplayer_cursor < 0)
m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
break;
case K_ENTER:
case K_DC_A:
m_entersound = true;
switch (m_singleplayer_cursor)
{
case 0:
/*
if (sv.active)
if (!SCR_ModalMessage("Are you sure you want to\nstart a new game?\n"))
break;
//*/
// BlackAura - Menu background fading
fade_level = 0;
key_dest = key_game;
if (sv.active)
Cbuf_AddText ("disconnect\n");
Cbuf_AddText ("maxplayers 1\n");
Cbuf_AddText ("map start\n");
break;
case 1:
M_Load_f ();
break;
case 2:
M_Save_f ();
break;
}
}
}
//=============================================================================
/* LOAD/SAVE MENU */
/* speud - heavy editing begin */
int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES
#define MAX_SAVEGAMES 12
char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
int loadable[MAX_SAVEGAMES];
void M_ScanSaves (void)
{
int i, j;
uint16 killed, total;
char name[MAX_OSPATH], appname[16], mapname[22], kills[20];
file_t f;
vm_dev = maple_enum_dev((int)vmu_port.value, (int)vmu_unit.value);
freeblocks = VMU_GetFreeblocks();
for (i=0 ; i<MAX_SAVEGAMES ; i++)
{
strcpy (m_filenames[i], "--- UNUSED SLOT ---");
loadable[i] = false;
sprintf (name, "/vmu/%c%d/RADQUAKE_G%02d", (int)vmu_port.value+'a', (int)vmu_unit.value, i);
f = fs_open (name, O_RDONLY);
if (!f) {
sprintf (name, "/vmu/%c%d/RADQUAKE_S%02d", (int)vmu_port.value+'a', (int)vmu_unit.value, i);
f = fs_open (name, O_RDONLY);
if (!f)
continue;
}
fs_seek(f, 48, SEEK_SET);
fs_read(f, appname, 16);
if (!!memcmp(appname, "RADQuake ", 16))
continue;
fs_seek(f, 16, SEEK_SET);
fs_read(f, mapname, 22);
fs_seek(f, 44, SEEK_SET);
fs_read(f, &killed, 2);
fs_read(f, &total, 2);
for (j=0; j<SAVEGAME_COMMENT_LENGTH; j++)
m_filenames[i][i] = ' ';
memcpy(m_filenames[i], mapname, 22);
sprintf(kills, "kills:%3i/%3i", killed, total);
memcpy(m_filenames[i]+22, kills, strlen(kills));
m_filenames[i][SAVEGAME_COMMENT_LENGTH] = '\0';
loadable[i] = true;
fs_close(f);
}
}
void M_Load_f (void)
{
m_entersound = true;
m_state = m_load;
key_dest = key_menu;
M_ScanSaves ();
}
void M_Save_f (void)
{
if (!sv.active)
return;
if (cl.intermission)
return;
if (svs.maxclients != 1)
return;
m_entersound = true;
m_state = m_save;
key_dest = key_menu;
M_ScanSaves ();
}
void M_Load_Draw (void)
{
int i;
char buffer[32];
M_DrawPlaque ("gfx/p_load.lmp", false); // Manoel Kasimier
if (vm_dev == NULL) {
M_Print (100, 40 + 8*(MAX_SAVEGAMES+2), va("No VMU in %c-%d", (int)vmu_port.value+'A', (int)vmu_unit.value));
M_Print (52, 40 + 8*(MAX_SAVEGAMES+4), "B button or Escape to exit");
return;
}
for (i=0 ; i< MAX_SAVEGAMES; i++)
M_Print (16, 40 + 8*i, m_filenames[i]);
sprintf(buffer, "free blocks in %c-%d: %3d/%3d", (int)vmu_port.value+'A', (int)vmu_unit.value, freeblocks, totalblocks);
M_Print (60, 40 + 8*(MAX_SAVEGAMES+2), buffer);
M_Print (52, 40 + 8*(MAX_SAVEGAMES+4), "A button or Enter to load");
M_Print (52, 40 + 8*(MAX_SAVEGAMES+5), "B button or Escape to cancel");
M_Print (52, 40 + 8*(MAX_SAVEGAMES+6), "X button or Space to delete");
// line cursor
M_DrawCharacter (8, 40 + load_cursor*8, 12+((int)(realtime*4)&1));
}
void M_Save_Draw (void)
{
int i;
char buffer[32];
M_DrawPlaque ("gfx/p_save.lmp", false); // Manoel Kasimier
if (vm_dev == NULL) {
M_Print (100, 40 + 8*(MAX_SAVEGAMES+2), va("No VMU in %c-%d", (int)vmu_port.value+'A', (int)vmu_unit.value));
M_Print (52, 40 + 8*(MAX_SAVEGAMES+4), "B button or Escape to exit");
return;
}
for (i=0 ; i<MAX_SAVEGAMES ; i++)
M_Print (16, 40 + 8*i, m_filenames[i]);
sprintf(buffer, "free blocks in %c-%d: %3d/%3d", (int)vmu_port.value+'A', (int)vmu_unit.value, freeblocks, totalblocks);
M_Print (60, 40 + 8*(MAX_SAVEGAMES+2), buffer);
M_Print (52, 40 + 8*(MAX_SAVEGAMES+4), "A button or Enter to save");
M_Print (52, 40 + 8*(MAX_SAVEGAMES+5), "B button or Escape to cancel");
M_Print (52, 40 + 8*(MAX_SAVEGAMES+6), "X button or Space to delete");
// line cursor
M_DrawCharacter (8, 40 + load_cursor*8, 12+((int)(realtime*4)&1));
}
void M_Load_Key (int k)
{
switch (k)
{
case K_DC_START:
M_Off (); // Manoel Kasimier
break;
case K_SPACE:
case K_DC_X:
if (vm_dev == NULL)
return;
S_LocalSound ("misc/menu2.wav");
if (!loadable[load_cursor])
return;
char buffer[32];
sprintf(buffer, "/vmu/%c%d/RADQUAKE_G%02d", (int)vmu_port.value+'a', (int)vmu_unit.value, load_cursor);
fs_unlink(buffer);
M_ScanSaves();
M_Load_Draw();
break;
case K_ESCAPE:
case K_DC_B: // Manoel Kasimier
M_SinglePlayer_f ();
break;
case K_ENTER:
case K_DC_A:
if (vm_dev == NULL)
return;
S_LocalSound ("misc/menu2.wav");
if (!loadable[load_cursor])
return;
// BlackAura - Menu background fading
fade_level = 0;
m_state = m_none;
key_dest = key_game;
// Host_Loadgame_f can't bring up the loading plaque because too much
// stack space has been used, so do it now
SCR_BeginLoadingPlaque ();
// issue the load command
Cbuf_AddText (va ("load /vmu/%c%d/RADQUAKE_G%02d\n", (int)vmu_port.value+'a', (int)vmu_unit.value, load_cursor) );
return;
case K_UPARROW:
case K_DPAD1_UP:
case K_LEFTARROW:
case K_DPAD1_LEFT:
if (vm_dev == NULL)
return;
S_LocalSound ("misc/menu1.wav");
load_cursor--;
if (load_cursor < 0)
load_cursor = MAX_SAVEGAMES-1;
break;
case K_DOWNARROW:
case K_DPAD1_DOWN:
case K_RIGHTARROW:
case K_DPAD1_RIGHT:
if (vm_dev == NULL)
return;
S_LocalSound ("misc/menu1.wav");
load_cursor++;
if (load_cursor >= MAX_SAVEGAMES)
load_cursor = 0;
break;
}
}
void M_Save_Key (int k)
{
switch (k)
{
case K_DC_START:
M_Off (); // Manoel Kasimier
break;
case K_SPACE:
case K_DC_X:
if (vm_dev == NULL)
return;
S_LocalSound ("misc/menu2.wav");
if (!loadable[load_cursor])
return;
char buffer[32];
sprintf(buffer, "/vmu/%c%d/RADQUAKE_G%02d", (int)vmu_port.value+'a', (int)vmu_unit.value, load_cursor);
fs_unlink(buffer);
M_ScanSaves();
M_Save_Draw();
break;
case K_ESCAPE:
case K_DC_B: // Manoel Kasimier
M_SinglePlayer_f ();
break;