forked from lukaszdk/ps2doom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i_main.c
897 lines (742 loc) · 22.8 KB
/
i_main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
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
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// $Log:$
//
// DESCRIPTION:
// Main program, simply calls D_DoomMain high level loop.
//
// static const char rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $";
//-----------------------------------------------------------------------------
#include <SDL/SDL.h>
//#include <SDL/SDL_image.h>
#include <stdio.h>
#include <libmc.h>
#include <libconfig.h>
#include <sifrpc.h>
#include <debug.h>
#include <libpwroff.h>
#include <loadfile.h>
#include <tamtypes.h>
#include <signal.h>
#include <stdlib.h>
#include <math.h>
#include <fcntl.h>
#include <sjpcm.h>
#include <unistd.h>
#include <SDL/SDL_mixer.h>
#define MAX_PARTITIONS 100
// cosmitoMixer
#include <sifrpc.h>
#include <mixer/mixer.h>
#include <mixer/mixer_thread.h>
#include <kernel.h> //for GetThreadId
#include <mixer/wav.h>
#include "modules.h"
#include "elf_structure.h"
#include "pad_support.h"
#include "hdd.h"
#include "doomdef.h"
#include "m_argv.h"
#include "d_main.h"
#include "w_wad.h"
extern u8 usbd;
extern u32 size_usbd;
//Declare usbhdfsd module //
extern u8 usbhdfsd;
extern u32 size_usbhdfsd;
extern u8 usbmass_bd_irx;
extern u32 size_usbmass_bd_irx;
//extern u8 SJPCM;
//extern u32 size_SJPCM;
extern u8 sio2man_irx;
extern u32 size_sio2man_irx;
/*Declare ps2dev9 module*/
extern u8 ps2dev9;
extern u32 size_ps2dev9;
/*Declare ps2atad module*/
extern u8 ps2atad;
extern u32 size_ps2atad;
/*Declare ps2hdd module*/
extern u8 ps2hdd;
extern u32 size_ps2hdd;
/*Declare ps2fsmodule*/
extern u8 ps2fs;
extern u32 size_ps2fs;
/*Declare poweroff module*/
extern u8 poweroff;
extern u32 size_poweroff;
/*Declare cdvd module*/
extern u8 cdvd;
extern u32 size_cdvd;
extern u8 freesd;
extern u32 size_freesd;
extern int SAMPLECOUNT = 512;
/// these two are pairs
typedef struct
{
char* name;
char* defaultaction;
} config_buttons_element;
config_buttons_element config_buttons[] =
{
// button name, default action
// both button names and action names as appearing at the libconfig config file
{"square", "previous weapon"},
{"cross", "run"},
{"circle", "next weapon"},
{"triangle", "escape"},
{"select", "map"},
{"start", "enter"},
{"l1", "n"},
{"r1", "fire"},
{"l2", "y"},
{"r2", "open"},
{"l3", ""}, /// TBD : yet not used
{"r3", "gamma"},
{"dpadleft", "leftarrow"},
{"dpadright", "rightarrow"},
{"dpadup", "uparrow"},
{"dpaddown", "downarrow"},
{"analog1left", ""}, /// TBD : yet not used
{"analog1right", ""}, /// TBD : yet not used
{"analog2left", "strafe left"}, // index 18
{"analog2right", "strafe right"}
};
// Store place to be built at config loading. Have the key codes for each button.
// KEY_RIGHTARROW 0xae
// KEY_LEFTARROW 0xac
// KEY_UPARROW 0xad
// KEY_DOWNARROW 0xaf
///
typedef struct
{
char* name;
int value;
} config_actions_element;
config_actions_element config_actions[] =
{
// actually the key mapping for the actions :
// action name, mapped key
{"previous weapon", SDLK_o},
{"run", KEY_RSHIFT},
{"next weapon", SDLK_p},
{"escape", KEY_ESCAPE},
{"map", KEY_TAB},
{"enter", KEY_ENTER},
{"n", SDLK_n},
{"fire", KEY_RCTRL},
{"y", SDLK_y},
{"open", SDLK_SPACE},
{"gamma", KEY_F11},
{"leftarrow", KEY_LEFTARROW},
{"rightarrow", KEY_RIGHTARROW},
{"uparrow", KEY_UPARROW},
{"downarrow", KEY_DOWNARROW},
{"strafe left", STRAFELEFT},
{"strafe right", STRAFERIGHT},
/// to add a new : add entry here with default
};
char config_probestring[200];
/// -------------------------
#define DEBUG_LIBCONFIG
const char *hdd_wads_folder;
int getFileSize(FILE *fd)
{
int size = fseek(fd, 0, SEEK_END);
fseek(fd, 0, SEEK_SET);
return size;
}
void Display_mode()
{
#define PAL_WIDTH 480
#define PAL_HEIGHT 576
#define PAL_BITS 32
#define NTSC_WIDTH 640
#define NTSC_HEIGHT 480
#define NTSC_BITS 32
int forceDisplayMode = -1;
SDL_Surface *PAL;
SDL_Surface *NTSC;
PAL = SDL_SetVideoMode(PAL_WIDTH, PAL_HEIGHT, PAL_BITS, SDL_SWSURFACE);
NTSC = SDL_SetVideoMode(NTSC_WIDTH, NTSC_HEIGHT, NTSC_BITS, SDL_SWSURFACE);
if (PAL)
{
SDL_Flip(PAL);
SDL_ShowCursor(SDL_DISABLE);
SDL_Quit();
}
else if(NTSC)
{
SDL_Flip(NTSC);
SDL_ShowCursor(SDL_DISABLE);
SDL_Quit();
}
else
{
printf("error");
}
// Changes accordingly to filename
forceDisplayMode = getDisplayModeFromELFName(myargv);
if (forceDisplayMode != -1)
PS2SDL_ForceSignal(forceDisplayMode);
// Sets SAMPLECOUNT accordingly to system
if (NTSC == 0)
{
SAMPLECOUNT = 960;
}
else if(PAL == 1)
{
SAMPLECOUNT = 800;
}
else
{
scr_printf ("error loading SAMPLECOUNT");
}
D_DoomMain();
}
//not working yet
void ShowMusic()
{
Mix_Chunk *music1 = Mix_LoadWAV("songs/espelho.wav");
Mix_OpenAudio(48000, MIX_DEFAULT_FORMAT, 2, 4096);
Mix_PlayChannel(-1, music1, 0);
Mix_VolumeMusic(100);
}
void Display_screen()
{
#define WIDTH 640
#define HEIGHT 448
#define BITS 32
int ps2doomx, ps2doomy;
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *window = SDL_SetVideoMode(WIDTH, HEIGHT, BITS, SDL_NOFRAME);
SDL_Surface *ps2doom = SDL_LoadBMP("gfx/ps2doom.bmp");
SDL_Rect ps2doomPosition =
{
ps2doomx = 0,
ps2doomy = 0
};
//ShowMusic();
SDL_BlitSurface(ps2doom, NULL, window, &ps2doomPosition);
SDL_DisplayFormat(ps2doom);
SDL_FreeSurface(ps2doom);
SDL_Flip(window);
SDL_ShowCursor(SDL_DISABLE);
SDL_Delay(20000);
SDL_Quit();
}
//#endif
char config_probestring[200];
/// -------------------------
#define DEBUG_LIBCONFIG
const char *hdd_wads_folder;
int waitPadReady(int port, int slot)
{
int state;
int lastState;
char stateString[16];
state = padGetState(port, slot);
lastState = -1;
while((state != PAD_STATE_STABLE) && (state != PAD_STATE_FINDCTP1)) {
if (state != lastState) {
padStateInt2String(state, stateString);
printf("Please wait, pad(%d,%d) is in state %s\n",
port, slot, stateString);
}
lastState = state;
state=padGetState(port, slot);
}
// Were the pad ever 'out of sync'?
if (lastState != -1) {
printf("Pad OK!\n");
}
return 0;
}
int initializePad(int port, int slot)
{
int ret;
int modes;
int i;
waitPadReady(port, slot);
// How many different modes can this device operate in?
// i.e. get # entrys in the modetable
modes = padInfoMode(port, slot, PAD_MODETABLE, -1);
printf("The device has %d modes\n", modes);
if (modes > 0) {
printf("( ");
for (i = 0; i < modes; i++) {
printf("%d ", padInfoMode(port, slot, PAD_MODETABLE, i));
}
printf(")");
}
printf("It is currently using mode %d\n",
padInfoMode(port, slot, PAD_MODECURID, 0));
// If modes == 0, this is not a Dual shock controller
// (it has no actuator engines)
if (modes == 0) {
printf("This is a digital controller?\n");
return 1;
}
// Verify that the controller has a DUAL SHOCK mode
i = 0;
do {
if (padInfoMode(port, slot, PAD_MODETABLE, i) == PAD_TYPE_DUALSHOCK)
break;
i++;
} while (i < modes);
if (i >= modes) {
printf("This is no Dual Shock controller\n");
return 1;
}
// If ExId != 0x0 => This controller has actuator engines
// This check should always pass if the Dual Shock test above passed
ret = padInfoMode(port, slot, PAD_MODECUREXID, 0);
if (ret == 0) {
printf("This is no Dual Shock controller??\n");
return 1;
}
printf("Enabling dual shock functions\n");
// When using MMODE_LOCK, user cant change mode with Select button
padSetMainMode(port, slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK);
waitPadReady(port, slot);
printf("infoPressMode: %d\n", padInfoPressMode(port, slot));
waitPadReady(port, slot);
printf("enterPressMode: %d\n", padEnterPressMode(port, slot));
waitPadReady(port, slot);
actuators = padInfoAct(port, slot, -1, 0);
printf("# of actuators: %d\n",actuators);
if (actuators != 0) {
actAlign[0] = 0; // Enable small engine
actAlign[1] = 1; // Enable big engine
actAlign[2] = 0xff;
actAlign[3] = 0xff;
actAlign[4] = 0xff;
actAlign[5] = 0xff;
waitPadReady(port, slot);
printf("padSetActAlign: %d\n",
padSetActAlign(port, slot, actAlign));
}
else {
printf("Did not find any actuators.\n");
}
waitPadReady(port, slot);
return 1;
}
int padUtils_ReadButtonWait(int port, int slot, u32 old_pad, u32 new_pad)
{
int butres = 0, read = 0;
read = padUtils_ReadButton(port, slot, old_pad, new_pad);
if(read != 0)
{
butres = read; // memorize pressed button
while (padUtils_ReadButton(port, slot, old_pad, new_pad) != 0) {};
}
return butres;
}
int padUtils_ReadButton(int port, int slot, u32 old_pad, u32 new_pad)
{
struct padButtonStatus buttons;
int ret;
u32 paddata;
ret = padRead(port, slot, &buttons);
if (ret != 0)
{
paddata = 0xffff ^ buttons.btns;
new_pad = paddata & ~old_pad;
old_pad = paddata;
if (new_pad & PAD_LEFT)
{
//LEFT
return(PAD_LEFT);
}
if (new_pad & PAD_DOWN)
{
//DOWN
return(PAD_DOWN);
}
if (new_pad & PAD_RIGHT)
{
//RIGHT
return(PAD_RIGHT);
}
if (new_pad & PAD_UP)
{
//UP
return(PAD_UP);
}
if (new_pad & PAD_START)
{
//START
return(PAD_START);
}
if (new_pad & PAD_R3)
{
//R3
return(PAD_R3);
}
if (new_pad & PAD_L3)
{
//L3
return(PAD_L3);
}
if (new_pad & PAD_SELECT)
{
//SELECT
return(PAD_SELECT);
}
if (new_pad & PAD_SQUARE)
{
//SQUARE
return(PAD_SQUARE);
}
if (new_pad & PAD_CROSS)
{
//CROSS
return(PAD_CROSS);
}
if (new_pad & PAD_CIRCLE)
{
//CIRCLE
return(PAD_CIRCLE);
}
if (new_pad & PAD_TRIANGLE)
{
//TRIANGLE
return(PAD_TRIANGLE);
}
if (new_pad & PAD_R1)
{
//R1
return(PAD_R1);
}
if (new_pad & PAD_L1)
{
//L1
return(PAD_L1);
}
if (new_pad & PAD_R2)
{
//R2
return(PAD_R2);
}
if (new_pad & PAD_L2)
{
//L2
return(PAD_L2);
}
}
else
{
return -1;
}
return 0; // 0 means no button was pressed
}
//int main
int main( int argc, char** argv )
{
int *fp;
int i, j, nj;
const char *s;
char configfile[256];
config_t cfg; // libconfig
char elfFilename[100];
char deviceName[10];
char fullPath[256];
int use_hdd;
int ret;
int mc_Type, mc_Free, mc_Format;
static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
static char pfsarg[] = "-m" "\0" "4" "\0" "-o" "\0" "10" "\0" "-n" "\0" "40";
const char *hdd_path_to_partition;
use_hdd = CONFIG_FALSE;
FILE *handle;
myargc = argc;
myargv = argv;
s32 main_thread_id;
int x;
int swap_analogsticks;
int configLoadSuccess = 0;
int value;
GetElfFilename(argv[0], deviceName, fullPath, elfFilename);
main_thread_id = GetThreadId();
Display_screen();
SifInitRpc(0);
printf("sample: kicking IRXs\n");
SifExecModuleBuffer(freesd, size_freesd, 0, NULL, NULL);
printf("freesd loadmodule %d\n", ret);
//Load embedded modules
// SJPCM
///SifExecModuleBuffer(SJPCM, size_SJPCM, 0, NULL, &ret);
// USB mass support
SifExecModuleBuffer(usbd, size_usbd, 0, NULL, &ret);
SifExecModuleBuffer(usbhdfsd, size_usbhdfsd, 0, NULL, &ret);
ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: SIO2MAN");
//scr_printf("Failed to load module: SIO2MAN");
SleepThread();
}
ret = SifLoadModule("rom0:XMCMAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCMAN");
scr_printf("Failed to load module: MCMAN");
SleepThread();
}
ret = SifLoadModule("rom0:XMCSERV", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCSERV");
SleepThread();
}
if(mcInit(MC_TYPE_XMC) < 0) {
printf("Failed to initialize memcard server!\n");
SleepThread();
}
// Since this is the first call, -1 should be returned.
mcGetInfo(0, 0, &mc_Type, &mc_Free, &mc_Format);
mcSync(0, NULL, &ret);
printf("mcGetInfo returned %d\n",ret);
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
// Assuming that the same memory card is connected, this should return 0
mcGetInfo(0,0,&mc_Type,&mc_Free,&mc_Format);
mcSync(0, NULL, &ret);
printf("mcGetInfo returned %d\n",ret);
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
if (ret != 0)
printf("mc0 trouble... should save to other device... To implement\n"); /// TBD
// create save/load dir (mc0:PS2DOOM)
fopen("mc0:PS2DOOM/doomsav0.dsg", O_RDONLY);
if (handle < 0)
{
mkdir("mc0:PS2DOOM", 0007); // Make sure it exists
printf(" ... created mc0:PS2DOOM ...\n");
}
else
fclose(handle);
/// config
sprintf(configfile, "%s%s", fullPath, "ps2doom.config");
// First, try to load from localpath. If fails, try from 'mc0:'
fp = fopen(configfile, "rb");
if(!fp)
{
printf("file '%s' not found. Going to try 'mc0:PS2DOOM/ps2doom.config'\n", configfile);
sprintf(configfile, "%s", "mc0:PS2DOOM/ps2doom.config");
fp = fopen(configfile, "rb");
if(!fp)
{
// Using default actions for buttons
#ifdef DEBUG_LIBCONFIG
printf("Unable to open '%s'. Using defaults\n", configfile);
#endif
int nConfig_buttonsEntries = sizeof(config_buttons)/sizeof(config_buttons[0]);
for (i=0; i<nConfig_buttonsEntries; i++)
{
nj = sizeof(config_actions)/sizeof(config_actions[0]);
for(j=0; j<nj; j++)
{
if(strcmp(config_actions[j].name, config_buttons[i].defaultaction) == 0)
{
value = config_actions[j].value;
//config_buttons[i] = value;
return value;
}
}
}
}
else
configLoadSuccess = 1;
}
else
configLoadSuccess = 1;
if(configLoadSuccess == 1)
{
// Get the actions for buttons from config
config_init(&cfg);
x = config_read(&cfg, fp);
fclose(fp);
if(x)
{
// Process each ps2doom.controls config entries
int nConfigEntries = sizeof(config_buttons)/sizeof(config_buttons[0]);
for (i=0; i<nConfigEntries; i++)
{
sprintf(config_probestring, "%s%s", "ps2doom.controls.", config_buttons[i].name);
if(! config_lookup_string(&cfg, config_probestring, &s))
{
#ifdef DEBUG_LIBCONFIG
printf("NOT FOUND %s\n", config_probestring);
#endif
}
else
{
#ifdef DEBUG_LIBCONFIG
printf("found: %s = %s\n", config_probestring, s);
#endif
nj = sizeof(config_actions)/sizeof(config_actions[0]);
for(j=0; j<nj; j++)
{
if(strcmp(config_actions[j].name, s) == 0)
{
value = config_actions[j].value;
//config_buttons[i] = value;
return value;
}
}
}
}
}
else
printf("error on line %d: %s\n", cfg.error_line, cfg.error_text);
use_hdd = CONFIG_FALSE;
sprintf(config_probestring, "%s", "ps2doom.hdd.use_hdd");
if(!config_lookup_bool(&cfg, config_probestring, &use_hdd))
{
printf("found: %s = %d\n", config_probestring, use_hdd);
}
else
{
use_hdd = CONFIG_FALSE;
printf("NOT FOUND %s\n", config_probestring);
}
if(use_hdd == CONFIG_TRUE)
{
sprintf(config_probestring, "%s", "ps2doom.hdd.path_to_partition");
if(!config_lookup_string(&cfg, config_probestring, &hdd_path_to_partition))
{
printf("found: %s = %s\n", config_probestring, hdd_path_to_partition);
}
else
{
printf("NOT FOUND %s\n", config_probestring);
scr_printf("Error: Value '%s' at ps2doom.config not found\n", config_probestring);
SleepThread();
}
sprintf(config_probestring, "%s", "ps2doom.hdd.wads_folder");
if(!config_lookup_string(&cfg, config_probestring, &hdd_wads_folder))
{
printf("NOT FOUND %s\n", config_probestring);
scr_printf("Error: Value '%s' at ps2doom.config not found\n", config_probestring);
SleepThread();
}
else
{
printf("found: %s = %s\n", config_probestring, hdd_wads_folder);
}
}
//
swap_analogsticks = CONFIG_FALSE;
sprintf(config_probestring, "%s", "ps2doom.controls.switches.swap_analogsticks");
if(!config_lookup_bool(&cfg, config_probestring, &swap_analogsticks))
{
swap_analogsticks = CONFIG_FALSE;
#ifdef DEBUG_LIBCONFIG
printf("NOT FOUND %s\n", config_probestring);
#endif
}
else
{
#ifdef DEBUG_LIBCONFIG
printf("found: %s = %d\n", config_probestring, swap_analogsticks);
#endif
}
}
#ifdef DEBUG_LIBCONFIG
for(i=0; i<sizeof(config_buttons)/sizeof(config_buttons[0]); i++)
{
printf("%d (%s)\n", config_buttons[i], config_buttons[i].name);
}
#endif
if(use_hdd == CONFIG_TRUE)
{
SifExecModuleBuffer(poweroff, size_poweroff, 0, NULL, &ret);
SifExecModuleBuffer(sio2man_irx, size_sio2man_irx, 0, NULL, &ret);
SifExecModuleBuffer(ps2dev9, size_ps2dev9, 0, NULL, &ret);
SifExecModuleBuffer(ps2atad, size_ps2atad, 0, NULL, &ret);
SifExecModuleBuffer(ps2hdd, size_ps2hdd, sizeof(hddarg), hddarg, &ret);
if (ret < 0)
{
printf("Failed to load module: PS2HDD.IRX");
scr_printf("Failed to load module: PS2HDD.IRX");
}
SifExecModuleBuffer(ps2fs, size_ps2fs, sizeof(pfsarg), pfsarg, &ret);
if (ret < 0)
{
scr_printf("Failed to load module: PS2FS.IRX");
printf("Failed to load module: PS2FS.IRX");
}
//#endif
//#ifdef PS2HDD
//#ifdef PS2HDD
//char ps2HDDPartition[] = "hdd0:+Test"; // TBD : name of partition only
//char folderpath[] = "abc"; // The folder path without any '/'
//sprintf(fullPath, "%s/%s/", hdd_path_to_partition, hdd_wads_folder);
sprintf(fullPath, "pfs0:%s/", hdd_wads_folder);
printf(">>>>>>>>%s\n", fullPath);
//todo: rewrite the hdd support maybe i should see the open ps2 loader hdd support
//#endif
ret = fopen("hdd0:", HDIOC_STATUS);
if (ret > 0)
{
printf("the Hdd is connected");
}
if(ret > 1)
{
printf("the hdd is not formatted properly");
}
if(ret > 2)
{
printf("The HDD is not usable check if it´s broken or else");
}
if(ret > 3)
{
printf("The HDD is not connected");
}
}
//SjPCM_Init(1); // sync mode
//printf("SjPCM_Setvol ...\n");
//SjPCM_Setvol(0x3fff);
ChangeThreadPriority ( GetThreadId (), 42 );
Mixer_Init(); // TBD : arg number channels
return 0;
/********************************************************
*********************************************************
** Until sdl isn't fixed **
** int PAL = detect_signal(); **
** if (PAL == 1) **
** PS2SDL_ForceSignal(0); **
** else **
** PS2SDL_ForceSignal(1); **
** **
** // Changes accordingly to filename **
** forceDisplayMode = getDisplayModeFromELFName(argv); **
** if (forceDisplayMode != -1) **
** PS2SDL_ForceSignal(forceDisplayMode); **
** **
** // Sets SAMPLECOUNT accordingly to system **
** if (PAL == 1) **
** SAMPLECOUNT = 960; **
** else **
** SAMPLECOUNT = 800; **
** **
** **
** D_DoomMain (); **
** **
** return 0; **
** **
*********************************************************
*********************************************************/
//Display_mode();
}