frameskip, cleanups
[fceu.git] / drivers / pc / svgalib.c
CommitLineData
c62d2810 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
5232c20c 18//static int soundo=0;
c62d2810 19static int f8bit=0;
20static int sfragsize=7,snfrags=8;
21
22int doptions=0;
23
24CFGSTRUCT 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
37char *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
63static int docheckie[2]={0,0};
64ARGPSTRUCT 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
78void 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}
5232c20c 93/*
c62d2810 94int InitSound(void)
95{
5232c20c 96 printf("Called InitSound svgalib.c\n");
c62d2810 97 if(soundo)
98 {
99 int rate;
100 if(soundo==1)
101 soundo=48000;
102 rate=soundo;
103 if(InitUNIXDSPSound(&rate,f8bit?0:1,sfragsize,snfrags))
104 {
105 FCEUI_Sound(rate);
106 return(1);
107 }
108 }
109 return(0);
5232c20c 110}*/
c62d2810 111
112void WriteSound(int32 *Buffer, int Count, int NoWaiting)
113{
114 WriteUNIXDSPSound(Buffer,Count,NoWaiting);
115}
116
117void KillSound(void)
118{
119 KillUNIXDSPSound();
120}
121
122int InitMouse(void)
123{
124 vga_setmousesupport(1);
125 mouse_setxrange(0,260);
126 mouse_setyrange(0,260);
127 mouse_setscale(1);
128 return(1);
129}
130
131void KillMouse(void)
132{
133 mouse_close();
134}
135
136void GetMouseData(uint32 *MouseData)
137{
138 int z;
139 mouse_update();
140 MouseData[0]=mouse_getx();
141 MouseData[1]=mouse_gety();
142 z=mouse_getbutton();
143 MouseData[2]=((z&MOUSE_LEFTBUTTON)?1:0)|((z&MOUSE_RIGHTBUTTON)?2:0);
144}
145
146#include "unix-basedir.h"
147
148int InitKeyboard(void)
149{
150 if(keyboard_init()==-1)
151 {
152 puts("Error initializing keyboard.");
153 return 0;
154 }
155 keyboard_translatekeys(TRANSLATE_CURSORKEYS | TRANSLATE_DIAGONAL);
156 return 1;
157}
158
159int UpdateKeyboard(void)
160{
161 return(keyboard_update());
162}
163
164char *GetKeyboard(void)
165{
166 return(keyboard_getstate());
167}
168
169void KillKeyboard(void)
170{
171 keyboard_close();
172}
173
174int main(int argc, char *argv[])
175{
176 puts("\nStarting FCE Ultra "VERSION_STRING"...\n");
177 vga_init();
178 return(CLImain(argc,argv));
179}