| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <string.h> |
| 4 | #include <vga.h> |
| 5 | #include <vgamouse.h> |
| 6 | #include <vgakeyboard.h> |
| 7 | |
| 8 | #include "../../driver.h" |
| 9 | #include "../common/args.h" |
| 10 | #include "../common/config.h" |
| 11 | #include "../common/unixdsp.h" |
| 12 | |
| 13 | #include "svgalib.h" |
| 14 | #include "svga-video.h" |
| 15 | #include "lnx-joystick.h" |
| 16 | #include "unix-netplay.h" |
| 17 | |
| 18 | static int soundo=48000; |
| 19 | static int f8bit=0; |
| 20 | static int sfragsize=7,snfrags=8; |
| 21 | |
| 22 | int doptions=0; |
| 23 | |
| 24 | CFGSTRUCT DriverConfig[]={ |
| 25 | NAC("sound",soundo), |
| 26 | AC(doptions), |
| 27 | AC(f8bit), |
| 28 | AC(vmode), |
| 29 | NACA("joybmap",joyBMap), |
| 30 | ACA(joy), |
| 31 | AC(snfrags), |
| 32 | AC(sfragsize), |
| 33 | ENDCFGSTRUCT |
| 34 | }; |
| 35 | |
| 36 | |
| 37 | char *DriverUsage= |
| 38 | "-vmode x Select video mode(all are 8 bpp).\n\ |
| 39 | 1 = 256x240 5 = 640x480(\"1 per 4\")\n\ |
| 40 | 2 = 256x256 6 = 256x224(with scanlines)\n\ |
| 41 | 3 = 256x256(with scanlines) 7 = 320x240\n\ |
| 42 | 4 = 640x480(with scanlines) 8 = 256x224\n\ |
| 43 | -vsync x Wait for the screen's vertical retrace before updating the\n\ |
| 44 | screen. Refer to the documentation for caveats.\n\ |
| 45 | 0 = Disabled.\n\ |
| 46 | 1 = Enabled.\n\ |
| 47 | -joyx y Joystick mapped to virtual joystick x(1-4).\n\ |
| 48 | 0 = Disabled, reset configuration.\n\ |
| 49 | Otherwise, y(1-inf) = joystick number.\n\ |
| 50 | -sound x Sound.\n\ |
| 51 | 0 = Disabled.\n\ |
| 52 | Otherwise, x = playback rate.\n\ |
| 53 | -sfragsize x Set sound fragment size to 2^x samples.\n\ |
| 54 | -snfrags x Set number of sound fragments to x.\n\ |
| 55 | -f8bit x Force 8-bit sound.\n\ |
| 56 | 0 = Disabled.\n\ |
| 57 | 1 = Enabled.\n\ |
| 58 | -connect s Connect to server 's' for TCP/IP network play.\n\ |
| 59 | -server Be a host/server for TCP/IP network play.\n\ |
| 60 | -netport x Use TCP/IP port x for network play."; |
| 61 | |
| 62 | |
| 63 | static int docheckie[2]={0,0}; |
| 64 | ARGPSTRUCT DriverArgs[]={ |
| 65 | {"-joy1",0,&joy[0],0},{"-joy2",0,&joy[1],0}, |
| 66 | {"-joy3",0,&joy[2],0},{"-joy4",0,&joy[3],0}, |
| 67 | {"-snfrags",0,&snfrags,0},{"-sfragsize",0,&sfragsize,0}, |
| 68 | {"-vmode",0,&vmode,0}, |
| 69 | {"-vsync",0,&doptions,0x8000|DO_VSYNC}, |
| 70 | {"-sound",0,&soundo,0}, |
| 71 | {"-f8bit",0,&f8bit,0}, |
| 72 | {"-connect",&docheckie[0],&netplayhost,0x4001}, |
| 73 | {"-server",&docheckie[1],0,0}, |
| 74 | {"-netport",0,&Port,0}, |
| 75 | {0,0,0,0} |
| 76 | }; |
| 77 | |
| 78 | void DoDriverArgs(void) |
| 79 | { |
| 80 | int x; |
| 81 | |
| 82 | if(docheckie[0]) |
| 83 | netplay=2; |
| 84 | else if(docheckie[1]) |
| 85 | netplay=1; |
| 86 | |
| 87 | if(netplay) |
| 88 | FCEUI_SetNetworkPlay(netplay); |
| 89 | |
| 90 | for(x=0;x<4;x++) |
| 91 | if(!joy[x]) memset(joyBMap[x],0,4*sizeof(int)); |
| 92 | } |
| 93 | |
| 94 | int InitSound(void) |
| 95 | { |
| 96 | if(soundo) |
| 97 | { |
| 98 | int rate; |
| 99 | if(soundo==1) |
| 100 | soundo=48000; |
| 101 | rate=soundo; |
| 102 | if(InitUNIXDSPSound(&rate,f8bit?0:1,sfragsize,snfrags)) |
| 103 | { |
| 104 | FCEUI_Sound(rate); |
| 105 | return(1); |
| 106 | } |
| 107 | } |
| 108 | return(0); |
| 109 | } |
| 110 | |
| 111 | void WriteSound(int32 *Buffer, int Count, int NoWaiting) |
| 112 | { |
| 113 | WriteUNIXDSPSound(Buffer,Count,NoWaiting); |
| 114 | } |
| 115 | |
| 116 | void KillSound(void) |
| 117 | { |
| 118 | KillUNIXDSPSound(); |
| 119 | } |
| 120 | |
| 121 | int InitMouse(void) |
| 122 | { |
| 123 | vga_setmousesupport(1); |
| 124 | mouse_setxrange(0,260); |
| 125 | mouse_setyrange(0,260); |
| 126 | mouse_setscale(1); |
| 127 | return(1); |
| 128 | } |
| 129 | |
| 130 | void KillMouse(void) |
| 131 | { |
| 132 | mouse_close(); |
| 133 | } |
| 134 | |
| 135 | void GetMouseData(uint32 *MouseData) |
| 136 | { |
| 137 | int z; |
| 138 | mouse_update(); |
| 139 | MouseData[0]=mouse_getx(); |
| 140 | MouseData[1]=mouse_gety(); |
| 141 | z=mouse_getbutton(); |
| 142 | MouseData[2]=((z&MOUSE_LEFTBUTTON)?1:0)|((z&MOUSE_RIGHTBUTTON)?2:0); |
| 143 | } |
| 144 | |
| 145 | #include "unix-basedir.h" |
| 146 | |
| 147 | int InitKeyboard(void) |
| 148 | { |
| 149 | if(keyboard_init()==-1) |
| 150 | { |
| 151 | puts("Error initializing keyboard."); |
| 152 | return 0; |
| 153 | } |
| 154 | keyboard_translatekeys(TRANSLATE_CURSORKEYS | TRANSLATE_DIAGONAL); |
| 155 | return 1; |
| 156 | } |
| 157 | |
| 158 | int UpdateKeyboard(void) |
| 159 | { |
| 160 | return(keyboard_update()); |
| 161 | } |
| 162 | |
| 163 | char *GetKeyboard(void) |
| 164 | { |
| 165 | return(keyboard_getstate()); |
| 166 | } |
| 167 | |
| 168 | void KillKeyboard(void) |
| 169 | { |
| 170 | keyboard_close(); |
| 171 | } |
| 172 | |
| 173 | int main(int argc, char *argv[]) |
| 174 | { |
| 175 | puts("\nStarting FCE Ultra "VERSION_STRING"...\n"); |
| 176 | vga_init(); |
| 177 | return(CLImain(argc,argv)); |
| 178 | } |