63bd5be0 |
1 | #include <stdio.h> |
2 | #include <stdlib.h> |
3 | #include <string.h> |
4 | #include <crt0.h> |
5 | #include <sys/farptr.h> |
6 | #include <go32.h> |
7 | |
8 | #include "dos.h" |
9 | #include "dos-joystick.h" |
10 | #include "dos-video.h" |
11 | #include "dos-sound.h" |
12 | #include "../common/args.h" |
13 | #include "../common/config.h" |
14 | |
15 | /* _CRT0_FLAG_LOCK_MEMORY might not always result in all memory being locked. |
16 | Bummer. I'll add code to explicitly lock the data touched by the sound |
17 | interrupt handler(and the handler itself), if necessary(though that might |
18 | be tricky...). I'll also to cover the data the keyboard |
19 | interrupt handler touches. |
20 | */ |
21 | |
22 | int _crt0_startup_flags = _CRT0_FLAG_FILL_SBRK_MEMORY | _CRT0_FLAG_LOCK_MEMORY | _CRT0_FLAG_USE_DOS_SLASHES; |
23 | |
24 | static int f8bit=0; |
25 | int soundo=44100; |
26 | int doptions=0; |
27 | |
28 | |
29 | CFGSTRUCT DriverConfig[]={ |
30 | NAC("sound",soundo), |
31 | AC(doptions), |
32 | AC(f8bit), |
33 | AC(FCEUDvmode), |
34 | NACA("joybmap",joyBMap), |
35 | AC(joy), |
36 | ENDCFGSTRUCT |
37 | }; |
38 | |
39 | char *DriverUsage= |
40 | "-vmode x Select video mode(all are 8 bpp).\n\ |
41 | 1 = 256x240 6 = 256x224(with scanlines)\n\ |
42 | 2 = 256x256 8 = 256x224\n\ |
43 | 3 = 256x256(with scanlines)\n\ |
44 | -vsync x Wait for the screen's vertical retrace before updating the\n\ |
45 | screen. Refer to the documentation for caveats.\n\ |
46 | 0 = Disabled.\n\ |
47 | 1 = Enabled.\n\ |
48 | -sound x Sound.\n\ |
49 | 0 = Disabled.\n\ |
50 | Otherwise, x = playback rate.\n\ |
51 | -f8bit x Force 8-bit sound.\n\ |
52 | 0 = Disabled.\n\ |
53 | 1 = Enabled.\n\ |
54 | -joy x Joystick mapped to virtual joystick x(1-4).\n\ |
55 | 0 = Disabled, reset configuration.\n\ |
56 | 1 = Enabled."; |
57 | |
58 | ARGPSTRUCT DriverArgs[]={ |
59 | {"-vmode",0,&FCEUDvmode,0}, |
60 | {"-sound",0,&soundo,0}, |
61 | {"-f8bit",0,&f8bit,0}, |
62 | {"-joy",0,&joy,0}, |
63 | {"-vsync",0,&eoptions,0x8004}, |
64 | {0,0,0,0} |
65 | }; |
66 | |
67 | void DoDriverArgs(void) |
68 | { |
69 | if(!joy) memset(joyBMap,0,4); |
70 | } |
71 | |
72 | int InitSound(void) |
73 | { |
74 | if(soundo) |
75 | { |
76 | if(soundo==1) |
77 | soundo=44100; |
78 | soundo=InitSB(soundo,f8bit?0:1); |
79 | FCEUI_Sound(soundo); |
80 | } |
81 | return(soundo?1:0); |
82 | } |
83 | |
84 | void WriteSound(int32 *Buffer, int Count, int NoWaiting) |
85 | { |
86 | WriteSBSound(Buffer,Count,NoWaiting); |
87 | } |
88 | |
89 | void KillSound(void) |
90 | { |
91 | if(soundo) |
92 | KillSB(); |
93 | } |
94 | |
95 | void DOSMemSet(uint32 A, uint8 V, uint32 count) |
96 | { |
97 | uint32 x; |
98 | |
99 | _farsetsel(_dos_ds); |
100 | for(x=0;x<count;x++) |
101 | _farnspokeb(A+x,V); |
102 | } |
103 | |
104 | static char *arg0; |
105 | void GetBaseDirectory(char *BaseDirectory) |
106 | { |
107 | int x=0; |
108 | |
109 | if(arg0) |
110 | for(x=strlen(arg0);x>=0;x--) |
111 | { |
112 | if(arg0[x]=='/' || arg0[x]=='\\') |
113 | { |
114 | strncpy(BaseDirectory,arg0,x); |
115 | break; |
116 | } |
117 | } |
118 | |
119 | BaseDirectory[x]=0; |
120 | } |
121 | |
122 | int main(int argc, char *argv[]) |
123 | { |
124 | puts("\nStarting FCE Ultra "VERSION_STRING"...\n"); |
125 | arg0=argv[0]; |
126 | return(CLImain(argc,argv)); |
127 | } |
128 | |