1 /*********************************************************************
2
3 usrintrf.c
4
5 Functions used to handle MAME's crude user interface.
6
7 *********************************************************************/
8
9 #include "driver.h"
10 #include "info.h"
11 #include "vidhrdw/vector.h"
12 #include "datafile.h"
13 #include <stdarg.h>
14 #include "ui_text.h"
15
16 #ifdef MESS
17 #include "mess/mess.h"
18 #endif
19
20 extern int mame_debug;
21
22 extern int bitmap_dirty; /* set by osd_clearbitmap() */
23
24 /* Variables for stat menu */
25 extern char build_version[];
26 extern unsigned int dispensed_tickets;
27 extern unsigned int coins[COIN_COUNTERS];
28 extern unsigned int coinlockedout[COIN_COUNTERS];
29
30 /* MARTINEZ.F 990207 Memory Card */
31 #ifndef MESS
32 #ifdef NEOMAME
33 int memcard_menu(struct osd_bitmap *bitmap, int);
34 extern int mcd_action;
35 extern int mcd_number;
36 extern int memcard_status;
37 extern int memcard_number;
38 extern int memcard_manager;
39 #endif
40 #endif
41
42 extern int neogeo_memcard_load(int);
43 extern void neogeo_memcard_save(void);
44 extern void neogeo_memcard_eject(void);
45 extern int neogeo_memcard_create(int);
46 /* MARTINEZ.F 990207 Memory Card End */
47
48 #ifdef ENABLE_AUTOFIRE
49 int autofire_menu(struct osd_bitmap *bitmap, int selected);
50 #endif
51
52
53 static int setup_selected;
54 static int osd_selected;
55 static int jukebox_selected;
56 static int single_step;
57 static int trueorientation;
58 static int orientation_count;
59
60 extern int global_showinfo;
61
switch_ui_orientation(void)62 static void switch_ui_orientation(void)
63 {
64 if (orientation_count == 0)
65 {
66 trueorientation = Machine->orientation;
67 Machine->orientation = Machine->ui_orientation;
68 set_pixel_functions();
69 }
70
71 orientation_count++;
72 }
73
switch_true_orientation(void)74 static void switch_true_orientation(void)
75 {
76 orientation_count--;
77
78 if (orientation_count == 0)
79 {
80 Machine->orientation = trueorientation;
81 set_pixel_functions();
82 }
83 }
84
85
set_ui_visarea(int xmin,int ymin,int xmax,int ymax)86 void set_ui_visarea (int xmin, int ymin, int xmax, int ymax)
87 {
88 int temp,w,h;
89
90 /* special case for vectors */
91 if(Machine->drv->video_attributes == VIDEO_TYPE_VECTOR)
92 {
93 if (Machine->ui_orientation & ORIENTATION_SWAP_XY)
94 {
95 temp=xmin; xmin=ymin; ymin=temp;
96 temp=xmax; xmax=ymax; ymax=temp;
97 }
98 }
99 else
100 {
101 if (Machine->orientation & ORIENTATION_SWAP_XY)
102 {
103 w = Machine->drv->screen_height;
104 h = Machine->drv->screen_width;
105 }
106 else
107 {
108 w = Machine->drv->screen_width;
109 h = Machine->drv->screen_height;
110 }
111
112 if (Machine->ui_orientation & ORIENTATION_FLIP_X)
113 {
114 temp = w - xmin - 1;
115 xmin = w - xmax - 1;
116 xmax = temp ;
117 }
118
119 if (Machine->ui_orientation & ORIENTATION_FLIP_Y)
120 {
121 temp = h - ymin - 1;
122 ymin = h - ymax - 1;
123 ymax = temp;
124 }
125
126 if (Machine->ui_orientation & ORIENTATION_SWAP_XY)
127 {
128 temp = xmin; xmin = ymin; ymin = temp;
129 temp = xmax; xmax = ymax; ymax = temp;
130 }
131
132 }
133 Machine->uiwidth = xmax-xmin+1;
134 Machine->uiheight = ymax-ymin+1;
135 Machine->uixmin = xmin;
136 Machine->uiymin = ymin;
137 }
138
139
140
builduifont(void)141 struct GfxElement *builduifont(void)
142 {
143 static unsigned char fontdata6x8[] =
144 {
145 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
146 0x7c,0x80,0x98,0x90,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x44,0x04,0xf4,0x04,0xf8,
147 0x7c,0x80,0x98,0x88,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x24,0x04,0xf4,0x04,0xf8,
148 0x7c,0x80,0x88,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x24,0x64,0x04,0xf4,0x04,0xf8,
149 0x7c,0x80,0x90,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x44,0x64,0x04,0xf4,0x04,0xf8,
150 0x30,0x48,0x84,0xb4,0xb4,0x84,0x48,0x30,0x30,0x48,0x84,0x84,0x84,0x84,0x48,0x30,
151 0x00,0xfc,0x84,0x8c,0xd4,0xa4,0xfc,0x00,0x00,0xfc,0x84,0x84,0x84,0x84,0xfc,0x00,
152 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
153 0x80,0xc0,0xe0,0xf0,0xe0,0xc0,0x80,0x00,0x04,0x0c,0x1c,0x3c,0x1c,0x0c,0x04,0x00,
154 0x20,0x70,0xf8,0x20,0x20,0xf8,0x70,0x20,0x48,0x48,0x48,0x48,0x48,0x00,0x48,0x00,
155 0x00,0x00,0x30,0x68,0x78,0x30,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
156 0x70,0xd8,0xe8,0xe8,0xf8,0xf8,0x70,0x00,0x1c,0x7c,0x74,0x44,0x44,0x4c,0xcc,0xc0,
157 0x20,0x70,0xf8,0x70,0x70,0x70,0x70,0x00,0x70,0x70,0x70,0x70,0xf8,0x70,0x20,0x00,
158 0x00,0x10,0xf8,0xfc,0xf8,0x10,0x00,0x00,0x00,0x20,0x7c,0xfc,0x7c,0x20,0x00,0x00,
159 0xb0,0x54,0xb8,0xb8,0x54,0xb0,0x00,0x00,0x00,0x28,0x6c,0xfc,0x6c,0x28,0x00,0x00,
160 0x00,0x30,0x30,0x78,0x78,0xfc,0x00,0x00,0xfc,0x78,0x78,0x30,0x30,0x00,0x00,0x00,
161 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,
162 0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0xf8,0x50,0xf8,0x50,0x00,0x00,
163 0x20,0x70,0xc0,0x70,0x18,0xf0,0x20,0x00,0x40,0xa4,0x48,0x10,0x20,0x48,0x94,0x08,
164 0x60,0x90,0xa0,0x40,0xa8,0x90,0x68,0x00,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00,
165 0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x00,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x00,
166 0x20,0xa8,0x70,0xf8,0x70,0xa8,0x20,0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00,
167 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,
168 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
169 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x00,
170 0x70,0x88,0x08,0x10,0x20,0x40,0xf8,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00,
171 0x10,0x30,0x50,0x90,0xf8,0x10,0x10,0x00,0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00,
172 0x70,0x80,0xf0,0x88,0x88,0x88,0x70,0x00,0xf8,0x08,0x08,0x10,0x20,0x20,0x20,0x00,
173 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x70,0x00,
174 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,
175 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,
176 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00,
177 0x30,0x48,0x94,0xa4,0xa4,0x94,0x48,0x30,0x70,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,
178 0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00,
179 0xf0,0x88,0x88,0x88,0x88,0x88,0xf0,0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00,
180 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x80,0x98,0x88,0x88,0x70,0x00,
181 0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
182 0x08,0x08,0x08,0x08,0x88,0x88,0x70,0x00,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00,
183 0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x00,
184 0x88,0xc8,0xa8,0x98,0x88,0x88,0x88,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
185 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x08,
186 0xf0,0x88,0x88,0xf0,0x88,0x88,0x88,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00,
187 0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
188 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00,0x88,0x88,0x88,0x88,0xa8,0xd8,0x88,0x00,
189 0x88,0x50,0x20,0x20,0x20,0x50,0x88,0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00,
190 0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x30,0x20,0x20,0x20,0x20,0x20,0x30,0x00,
191 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x30,0x10,0x10,0x10,0x10,0x10,0x30,0x00,
192 0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
193 0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00,
194 0x80,0x80,0xf0,0x88,0x88,0x88,0xf0,0x00,0x00,0x00,0x70,0x88,0x80,0x80,0x78,0x00,
195 0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00,0x00,0x00,0x70,0x88,0xf8,0x80,0x78,0x00,
196 0x18,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x70,
197 0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00,
198 0x20,0x00,0x20,0x20,0x20,0x20,0x20,0xc0,0x80,0x80,0x90,0xa0,0xe0,0x90,0x88,0x00,
199 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xf0,0xa8,0xa8,0xa8,0xa8,0x00,
200 0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00,
201 0x00,0x00,0xf0,0x88,0x88,0xf0,0x80,0x80,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08,
202 0x00,0x00,0xb0,0xc8,0x80,0x80,0x80,0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00,
203 0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00,
204 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00,0x00,0x00,0xa8,0xa8,0xa8,0xa8,0x50,0x00,
205 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x88,0x88,0x88,0x78,0x08,0x70,
206 0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00,0x08,0x10,0x10,0x20,0x10,0x10,0x08,0x00,
207 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00,
208 0x00,0x68,0xb0,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x20,0x50,0xa8,0x50,0x00,0x00,
209 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
210 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x40,0x0C,0x10,0x38,0x10,0x20,0x20,0xC0,0x00,
211 0x00,0x00,0x00,0x00,0x00,0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x00,
212 0x70,0xA8,0xF8,0x20,0x20,0x20,0x20,0x00,0x70,0xA8,0xF8,0x20,0x20,0xF8,0xA8,0x70,
213 0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00,0x44,0xA8,0x50,0x20,0x68,0xD4,0x28,0x00,
214 0x88,0x70,0x88,0x60,0x30,0x88,0x70,0x00,0x00,0x10,0x20,0x40,0x20,0x10,0x00,0x00,
215 0x78,0xA0,0xA0,0xB0,0xA0,0xA0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
216 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
217 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x20,0x00,0x00,0x00,0x00,0x00,
218 0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x28,0x50,0x50,0x00,0x00,0x00,0x00,0x00,
219 0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x78,0x78,0x30,0x00,0x00,
220 0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,
221 0x68,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0xF4,0x5C,0x54,0x54,0x00,0x00,0x00,0x00,
222 0x88,0x70,0x78,0x80,0x70,0x08,0xF0,0x00,0x00,0x40,0x20,0x10,0x20,0x40,0x00,0x00,
223 0x00,0x00,0x70,0xA8,0xB8,0xA0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
224 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x88,0x88,0x50,0x20,0x20,0x20,0x00,
225 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00,
226 0x00,0x20,0x70,0xA8,0xA0,0xA8,0x70,0x20,0x30,0x48,0x40,0xE0,0x40,0x48,0xF0,0x00,
227 0x00,0x48,0x30,0x48,0x48,0x30,0x48,0x00,0x88,0x88,0x50,0xF8,0x20,0xF8,0x20,0x00,
228 0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x00,0x78,0x80,0x70,0x88,0x70,0x08,0xF0,0x00,
229 0xD8,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x94,0xA4,0xA4,0x94,0x48,0x30,
230 0x60,0x10,0x70,0x90,0x70,0x00,0x00,0x00,0x00,0x28,0x50,0xA0,0x50,0x28,0x00,0x00,
231 0x00,0x00,0x00,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,
232 0x30,0x48,0xB4,0xB4,0xA4,0xB4,0x48,0x30,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
233 0x60,0x90,0x90,0x60,0x00,0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0xF8,0x00,
234 0x60,0x90,0x20,0x40,0xF0,0x00,0x00,0x00,0x60,0x90,0x20,0x90,0x60,0x00,0x00,0x00,
235 0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x88,0xC8,0xB0,0x80,
236 0x78,0xD0,0xD0,0xD0,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,
237 0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x00,0x20,0x60,0x20,0x20,0x70,0x00,0x00,0x00,
238 0x20,0x50,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0x50,0x28,0x50,0xA0,0x00,0x00,
239 0x40,0x48,0x50,0x28,0x58,0xA8,0x38,0x08,0x40,0x48,0x50,0x28,0x44,0x98,0x20,0x3C,
240 0xC0,0x28,0xD0,0x28,0xD8,0xA8,0x38,0x08,0x20,0x00,0x20,0x40,0x80,0x88,0x70,0x00,
241 0x40,0x20,0x70,0x88,0xF8,0x88,0x88,0x00,0x10,0x20,0x70,0x88,0xF8,0x88,0x88,0x00,
242 0x70,0x00,0x70,0x88,0xF8,0x88,0x88,0x00,0x68,0xB0,0x70,0x88,0xF8,0x88,0x88,0x00,
243 0x50,0x00,0x70,0x88,0xF8,0x88,0x88,0x00,0x20,0x50,0x70,0x88,0xF8,0x88,0x88,0x00,
244 0x78,0xA0,0xA0,0xF0,0xA0,0xA0,0xB8,0x00,0x70,0x88,0x80,0x80,0x88,0x70,0x08,0x70,
245 0x40,0x20,0xF8,0x80,0xF0,0x80,0xF8,0x00,0x10,0x20,0xF8,0x80,0xF0,0x80,0xF8,0x00,
246 0x70,0x00,0xF8,0x80,0xF0,0x80,0xF8,0x00,0x50,0x00,0xF8,0x80,0xF0,0x80,0xF8,0x00,
247 0x40,0x20,0x70,0x20,0x20,0x20,0x70,0x00,0x10,0x20,0x70,0x20,0x20,0x20,0x70,0x00,
248 0x70,0x00,0x70,0x20,0x20,0x20,0x70,0x00,0x50,0x00,0x70,0x20,0x20,0x20,0x70,0x00,
249 0x70,0x48,0x48,0xE8,0x48,0x48,0x70,0x00,0x68,0xB0,0x88,0xC8,0xA8,0x98,0x88,0x00,
250 0x40,0x20,0x70,0x88,0x88,0x88,0x70,0x00,0x10,0x20,0x70,0x88,0x88,0x88,0x70,0x00,
251 0x70,0x00,0x70,0x88,0x88,0x88,0x70,0x00,0x68,0xB0,0x70,0x88,0x88,0x88,0x70,0x00,
252 0x50,0x00,0x70,0x88,0x88,0x88,0x70,0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,
253 0x00,0x74,0x88,0x90,0xA8,0x48,0xB0,0x00,0x40,0x20,0x88,0x88,0x88,0x88,0x70,0x00,
254 0x10,0x20,0x88,0x88,0x88,0x88,0x70,0x00,0x70,0x00,0x88,0x88,0x88,0x88,0x70,0x00,
255 0x50,0x00,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0xA8,0x88,0x50,0x20,0x20,0x20,0x00,
256 0x00,0x80,0xF0,0x88,0x88,0xF0,0x80,0x80,0x60,0x90,0x90,0xB0,0x88,0x88,0xB0,0x00,
257 0x40,0x20,0x70,0x08,0x78,0x88,0x78,0x00,0x10,0x20,0x70,0x08,0x78,0x88,0x78,0x00,
258 0x70,0x00,0x70,0x08,0x78,0x88,0x78,0x00,0x68,0xB0,0x70,0x08,0x78,0x88,0x78,0x00,
259 0x50,0x00,0x70,0x08,0x78,0x88,0x78,0x00,0x20,0x50,0x70,0x08,0x78,0x88,0x78,0x00,
260 0x00,0x00,0xF0,0x28,0x78,0xA0,0x78,0x00,0x00,0x00,0x70,0x88,0x80,0x78,0x08,0x70,
261 0x40,0x20,0x70,0x88,0xF8,0x80,0x70,0x00,0x10,0x20,0x70,0x88,0xF8,0x80,0x70,0x00,
262 0x70,0x00,0x70,0x88,0xF8,0x80,0x70,0x00,0x50,0x00,0x70,0x88,0xF8,0x80,0x70,0x00,
263 0x40,0x20,0x00,0x60,0x20,0x20,0x70,0x00,0x10,0x20,0x00,0x60,0x20,0x20,0x70,0x00,
264 0x20,0x50,0x00,0x60,0x20,0x20,0x70,0x00,0x50,0x00,0x00,0x60,0x20,0x20,0x70,0x00,
265 0x50,0x60,0x10,0x78,0x88,0x88,0x70,0x00,0x68,0xB0,0x00,0xF0,0x88,0x88,0x88,0x00,
266 0x40,0x20,0x00,0x70,0x88,0x88,0x70,0x00,0x10,0x20,0x00,0x70,0x88,0x88,0x70,0x00,
267 0x20,0x50,0x00,0x70,0x88,0x88,0x70,0x00,0x68,0xB0,0x00,0x70,0x88,0x88,0x70,0x00,
268 0x00,0x50,0x00,0x70,0x88,0x88,0x70,0x00,0x00,0x20,0x00,0xF8,0x00,0x20,0x00,0x00,
269 0x00,0x00,0x68,0x90,0xA8,0x48,0xB0,0x00,0x40,0x20,0x88,0x88,0x88,0x98,0x68,0x00,
270 0x10,0x20,0x88,0x88,0x88,0x98,0x68,0x00,0x70,0x00,0x88,0x88,0x88,0x98,0x68,0x00,
271 0x50,0x00,0x88,0x88,0x88,0x98,0x68,0x00,0x10,0x20,0x88,0x88,0x88,0x78,0x08,0x70,
272 0x80,0xF0,0x88,0x88,0xF0,0x80,0x80,0x80,0x50,0x00,0x88,0x88,0x88,0x78,0x08,0x70
273 };
274 #if 0
275 static unsigned char fontdata6x8[] =
276 {
277 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
278 0x7c,0x80,0x98,0x90,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x44,0x04,0xf4,0x04,0xf8,
279 0x7c,0x80,0x98,0x88,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x24,0x04,0xf4,0x04,0xf8,
280 0x7c,0x80,0x88,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x24,0x64,0x04,0xf4,0x04,0xf8,
281 0x7c,0x80,0x90,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x44,0x64,0x04,0xf4,0x04,0xf8,
282 0x30,0x48,0x84,0xb4,0xb4,0x84,0x48,0x30,0x30,0x48,0x84,0x84,0x84,0x84,0x48,0x30,
283 0x00,0xfc,0x84,0x8c,0xd4,0xa4,0xfc,0x00,0x00,0xfc,0x84,0x84,0x84,0x84,0xfc,0x00,
284 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
285 0x80,0xc0,0xe0,0xf0,0xe0,0xc0,0x80,0x00,0x04,0x0c,0x1c,0x3c,0x1c,0x0c,0x04,0x00,
286 0x20,0x70,0xf8,0x20,0x20,0xf8,0x70,0x20,0x48,0x48,0x48,0x48,0x48,0x00,0x48,0x00,
287 0x00,0x00,0x30,0x68,0x78,0x30,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
288 0x70,0xd8,0xe8,0xe8,0xf8,0xf8,0x70,0x00,0x1c,0x7c,0x74,0x44,0x44,0x4c,0xcc,0xc0,
289 0x20,0x70,0xf8,0x70,0x70,0x70,0x70,0x00,0x70,0x70,0x70,0x70,0xf8,0x70,0x20,0x00,
290 0x00,0x10,0xf8,0xfc,0xf8,0x10,0x00,0x00,0x00,0x20,0x7c,0xfc,0x7c,0x20,0x00,0x00,
291 0xb0,0x54,0xb8,0xb8,0x54,0xb0,0x00,0x00,0x00,0x28,0x6c,0xfc,0x6c,0x28,0x00,0x00,
292 0x00,0x30,0x30,0x78,0x78,0xfc,0x00,0x00,0xfc,0x78,0x78,0x30,0x30,0x00,0x00,0x00,
293 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,
294 0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0xf8,0x50,0xf8,0x50,0x00,0x00,
295 0x20,0x70,0xc0,0x70,0x18,0xf0,0x20,0x00,0x40,0xa4,0x48,0x10,0x20,0x48,0x94,0x08,
296 0x60,0x90,0xa0,0x40,0xa8,0x90,0x68,0x00,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00,
297 0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x00,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x00,
298 0x20,0xa8,0x70,0xf8,0x70,0xa8,0x20,0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00,
299 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,
300 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
301 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x00,
302 0x70,0x88,0x08,0x10,0x20,0x40,0xf8,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00,
303 0x10,0x30,0x50,0x90,0xf8,0x10,0x10,0x00,0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00,
304 0x70,0x80,0xf0,0x88,0x88,0x88,0x70,0x00,0xf8,0x08,0x08,0x10,0x20,0x20,0x20,0x00,
305 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x70,0x00,
306 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,
307 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,
308 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00,
309 0x30,0x48,0x94,0xa4,0xa4,0x94,0x48,0x30,0x70,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,
310 0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00,
311 0xf0,0x88,0x88,0x88,0x88,0x88,0xf0,0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00,
312 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x80,0x98,0x88,0x88,0x70,0x00,
313 0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
314 0x08,0x08,0x08,0x08,0x88,0x88,0x70,0x00,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00,
315 0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x00,
316 0x88,0xc8,0xa8,0x98,0x88,0x88,0x88,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
317 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x08,
318 0xf0,0x88,0x88,0xf0,0x88,0x88,0x88,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00,
319 0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
320 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00,0x88,0x88,0x88,0x88,0xa8,0xd8,0x88,0x00,
321 0x88,0x50,0x20,0x20,0x20,0x50,0x88,0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00,
322 0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x30,0x20,0x20,0x20,0x20,0x20,0x30,0x00,
323 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x30,0x10,0x10,0x10,0x10,0x10,0x30,0x00,
324 0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
325 0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00,
326 0x80,0x80,0xf0,0x88,0x88,0x88,0xf0,0x00,0x00,0x00,0x70,0x88,0x80,0x80,0x78,0x00,
327 0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00,0x00,0x00,0x70,0x88,0xf8,0x80,0x78,0x00,
328 0x18,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x70,
329 0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00,
330 0x20,0x00,0x20,0x20,0x20,0x20,0x20,0xc0,0x80,0x80,0x90,0xa0,0xe0,0x90,0x88,0x00,
331 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xf0,0xa8,0xa8,0xa8,0xa8,0x00,
332 0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00,
333 0x00,0x00,0xf0,0x88,0x88,0xf0,0x80,0x80,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08,
334 0x00,0x00,0xb0,0xc8,0x80,0x80,0x80,0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00,
335 0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00,
336 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00,0x00,0x00,0xa8,0xa8,0xa8,0xa8,0x50,0x00,
337 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x88,0x88,0x88,0x78,0x08,0x70,
338 0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00,0x08,0x10,0x10,0x20,0x10,0x10,0x08,0x00,
339 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00,
340 0x00,0x68,0xb0,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x20,0x50,0xa8,0x50,0x00,0x00,
341 };
342 #endif
343
344 static struct GfxLayout fontlayout6x8 =
345 {
346 6,8, /* 6*8 characters */
347 256, /* 256 characters */
348 1, /* 1 bit per pixel */
349 { 0 },
350 { 0, 1, 2, 3, 4, 5, 6, 7 }, /* straightforward layout */
351 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
352 8*8 /* every char takes 8 consecutive bytes */
353 };
354 static struct GfxLayout fontlayout12x8 =
355 {
356 12,8, /* 12*8 characters */
357 256, /* 256 characters */
358 1, /* 1 bit per pixel */
359 { 0 },
360 { 0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7 }, /* straightforward layout */
361 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
362 8*8 /* every char takes 8 consecutive bytes */
363 };
364 static struct GfxLayout fontlayout12x16 =
365 {
366 12,16, /* 6*8 characters */
367 256, /* 256 characters */
368 1, /* 1 bit per pixel */
369 { 0 },
370 { 0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7 }, /* straightforward layout */
371 { 0*8,0*8, 1*8,1*8, 2*8,2*8, 3*8,3*8, 4*8,4*8, 5*8,5*8, 6*8,6*8, 7*8,7*8 },
372 8*8 /* every char takes 8 consecutive bytes */
373 };
374
375 struct GfxElement *font;
376 static unsigned short colortable[2*2]; /* ASG 980209 */
377
378
379 switch_ui_orientation();
380
381 if ((Machine->drv->video_attributes & VIDEO_PIXEL_ASPECT_RATIO_MASK)
382 == VIDEO_PIXEL_ASPECT_RATIO_1_2)
383 {
384 font = decodegfx(fontdata6x8,&fontlayout12x8);
385 Machine->uifontwidth = 12;
386 Machine->uifontheight = 8;
387 }
388 else if (Machine->uiwidth >= 420 && Machine->uiheight >= 420)
389 {
390 font = decodegfx(fontdata6x8,&fontlayout12x16);
391 Machine->uifontwidth = 12;
392 Machine->uifontheight = 16;
393 }
394 else
395 {
396 font = decodegfx(fontdata6x8,&fontlayout6x8);
397 Machine->uifontwidth = 6;
398 Machine->uifontheight = 8;
399 }
400
401 if (font)
402 {
403 /* colortable will be set at run time */
404 memset(colortable,0,sizeof(colortable));
405 font->colortable = colortable;
406 font->total_colors = 2;
407 }
408
409 switch_true_orientation();
410
411 return font;
412 }
413
414
415
416 /***************************************************************************
417
418 Display text on the screen. If erase is 0, it superimposes the text on
419 the last frame displayed.
420
421 ***************************************************************************/
422
displaytext(struct osd_bitmap * bitmap,const struct DisplayText * dt,int erase,int update_screen)423 void displaytext(struct osd_bitmap *bitmap,const struct DisplayText *dt,int erase,int update_screen)
424 {
425 if (erase)
426 osd_clearbitmap(bitmap);
427
428
429 switch_ui_orientation();
430
431 osd_mark_dirty (0,0,Machine->uiwidth-1,Machine->uiheight-1,1); /* ASG 971011 */
432
433 while (dt->text)
434 {
435 int x,y;
436 const char *c;
437
438
439 x = dt->x;
440 y = dt->y;
441 c = dt->text;
442
443 while (*c)
444 {
445 int wrapped;
446
447
448 wrapped = 0;
449
450 if (*c == '\n')
451 {
452 x = dt->x;
453 y += Machine->uifontheight + 1;
454 wrapped = 1;
455 }
456 else if (*c == ' ')
457 {
458 /* don't try to word wrap at the beginning of a line (this would cause */
459 /* an endless loop if a word is longer than a line) */
460 if (x != dt->x)
461 {
462 int nextlen=0;
463 const char *nc;
464
465
466 nc = c+1;
467 while (*nc && *nc != ' ' && *nc != '\n')
468 {
469 nextlen += Machine->uifontwidth;
470 nc++;
471 }
472
473 /* word wrap */
474 if (x + Machine->uifontwidth + nextlen > Machine->uiwidth)
475 {
476 x = dt->x;
477 y += Machine->uifontheight + 1;
478 wrapped = 1;
479 }
480 }
481 }
482
483 if (!wrapped)
484 {
485 drawgfx(bitmap,Machine->uifont,*c,dt->color,0,0,x+Machine->uixmin,y+Machine->uiymin,0,TRANSPARENCY_NONE,0);
486 x += Machine->uifontwidth;
487 }
488
489 c++;
490 }
491
492 dt++;
493 }
494
495 switch_true_orientation();
496
497 if (update_screen) update_video_and_audio();
498 }
499
500 /* Writes messages on the screen. */
ui_text_ex(struct osd_bitmap * bitmap,const char * buf_begin,const char * buf_end,int x,int y,int color)501 static void ui_text_ex(struct osd_bitmap *bitmap,const char* buf_begin, const char* buf_end, int x, int y, int color)
502 {
503 switch_ui_orientation();
504
505 for (;buf_begin != buf_end; ++buf_begin)
506 {
507 drawgfx(bitmap,Machine->uifont,*buf_begin,color,0,0,
508 x + Machine->uixmin,
509 y + Machine->uiymin, 0,TRANSPARENCY_NONE,0);
510 x += Machine->uifontwidth;
511 }
512
513 switch_true_orientation();
514 }
515
516 /* Writes messages on the screen. */
ui_text(struct osd_bitmap * bitmap,const char * buf,int x,int y)517 void ui_text(struct osd_bitmap *bitmap,const char *buf,int x,int y)
518 {
519 ui_text_ex(bitmap, buf, buf + strlen(buf), x, y, UI_COLOR_NORMAL);
520 }
521
522
ui_drawbox(struct osd_bitmap * bitmap,int leftx,int topy,int width,int height)523 void ui_drawbox(struct osd_bitmap *bitmap,int leftx,int topy,int width,int height)
524 {
525 unsigned short black,white;
526
527
528 switch_ui_orientation();
529
530 if (leftx < 0) leftx = 0;
531 if (topy < 0) topy = 0;
532 if (width > Machine->uiwidth) width = Machine->uiwidth;
533 if (height > Machine->uiheight) height = Machine->uiheight;
534
535 leftx += Machine->uixmin;
536 topy += Machine->uiymin;
537
538 black = Machine->uifont->colortable[0];
539 white = Machine->uifont->colortable[1];
540
541 plot_box(bitmap,leftx, topy, width, 1, white);
542 plot_box(bitmap,leftx, topy+height-1,width, 1, white);
543 plot_box(bitmap,leftx, topy, 1, height, white);
544 plot_box(bitmap,leftx+width-1,topy, 1, height, white);
545 plot_box(bitmap,leftx+1, topy+1, width-2,height-2,black);
546
547 switch_true_orientation();
548 }
549
550
drawbar(struct osd_bitmap * bitmap,int leftx,int topy,int width,int height,int percentage,int default_percentage)551 static void drawbar(struct osd_bitmap *bitmap,int leftx,int topy,int width,int height,int percentage,int default_percentage)
552 {
553 unsigned short black,white;
554
555
556 switch_ui_orientation();
557
558 if (leftx < 0) leftx = 0;
559 if (topy < 0) topy = 0;
560 if (width > Machine->uiwidth) width = Machine->uiwidth;
561 if (height > Machine->uiheight) height = Machine->uiheight;
562
563 leftx += Machine->uixmin;
564 topy += Machine->uiymin;
565
566 black = Machine->uifont->colortable[0];
567 white = Machine->uifont->colortable[1];
568
569 plot_box(bitmap,leftx+(width-1)*default_percentage/100,topy,1,height/8,white);
570
571 plot_box(bitmap,leftx,topy+height/8,width,1,white);
572
573 plot_box(bitmap,leftx,topy+height/8,1+(width-1)*percentage/100,height-2*(height/8),white);
574
575 plot_box(bitmap,leftx,topy+height-height/8-1,width,1,white);
576
577 plot_box(bitmap,leftx+(width-1)*default_percentage/100,topy+height-height/8,1,height/8,white);
578
579 switch_true_orientation();
580 }
581
582 /* Extract one line from a multiline buffer */
583 /* Return the characters number of the line, pbegin point to the start of the next line */
multiline_extract(const char ** pbegin,const char * end,unsigned max)584 static unsigned multiline_extract(const char** pbegin, const char* end, unsigned max)
585 {
586 unsigned mac = 0;
587 const char* begin = *pbegin;
588 while (begin != end && mac < max)
589 {
590 if (*begin == '\n')
591 {
592 *pbegin = begin + 1; /* strip final space */
593 return mac;
594 }
595 else if (*begin == ' ')
596 {
597 const char* word_end = begin + 1;
598 while (word_end != end && *word_end != ' ' && *word_end != '\n')
599 ++word_end;
600 if (mac + word_end - begin > max)
601 {
602 if (mac)
603 {
604 *pbegin = begin + 1;
605 return mac; /* strip final space */
606 } else {
607 *pbegin = begin + max;
608 return max;
609 }
610 }
611 mac += word_end - begin;
612 begin = word_end;
613 } else {
614 ++mac;
615 ++begin;
616 }
617 }
618 if (begin != end && (*begin == '\n' || *begin == ' '))
619 ++begin;
620 *pbegin = begin;
621 return mac;
622 }
623
624 /* Compute the output size of a multiline string */
multiline_size(int * dx,int * dy,const char * begin,const char * end,unsigned max)625 static void multiline_size(int* dx, int* dy, const char* begin, const char* end, unsigned max)
626 {
627 unsigned rows = 0;
628 unsigned cols = 0;
629 while (begin != end)
630 {
631 unsigned len;
632 len = multiline_extract(&begin,end,max);
633 if (len > cols)
634 cols = len;
635 ++rows;
636 }
637 *dx = cols * Machine->uifontwidth;
638 *dy = (rows-1) * 3*Machine->uifontheight/2 + Machine->uifontheight;
639 }
640
641 /* Compute the output size of a multiline string with box */
multilinebox_size(int * dx,int * dy,const char * begin,const char * end,unsigned max)642 static void multilinebox_size(int* dx, int* dy, const char* begin, const char* end, unsigned max)
643 {
644 multiline_size(dx,dy,begin,end,max);
645 *dx += Machine->uifontwidth;
646 *dy += Machine->uifontheight;
647 }
648
649 /* Display a multiline string */
ui_multitext_ex(struct osd_bitmap * bitmap,const char * begin,const char * end,unsigned max,int x,int y,int color)650 static void ui_multitext_ex(struct osd_bitmap *bitmap, const char* begin, const char* end, unsigned max, int x, int y, int color)
651 {
652 while (begin != end)
653 {
654 const char* line_begin = begin;
655 unsigned len = multiline_extract(&begin,end,max);
656 ui_text_ex(bitmap, line_begin, line_begin + len,x,y,color);
657 y += 3*Machine->uifontheight/2;
658 }
659 }
660
661 /* Display a multiline string with box */
ui_multitextbox_ex(struct osd_bitmap * bitmap,const char * begin,const char * end,unsigned max,int x,int y,int dx,int dy,int color)662 static void ui_multitextbox_ex(struct osd_bitmap *bitmap,const char* begin, const char* end, unsigned max, int x, int y, int dx, int dy, int color)
663 {
664 ui_drawbox(bitmap,x,y,dx,dy);
665 x += Machine->uifontwidth/2;
666 y += Machine->uifontheight/2;
667 ui_multitext_ex(bitmap,begin,end,max,x,y,color);
668 }
669
ui_displaymenu(struct osd_bitmap * bitmap,const char ** items,const char ** subitems,char * flag,int selected,int arrowize_subitem)670 void ui_displaymenu(struct osd_bitmap *bitmap,const char **items,const char **subitems,char *flag,int selected,int arrowize_subitem)
671 {
672 struct DisplayText dt[256];
673 int curr_dt;
674 const char *lefthilight = ui_getstring (UI_lefthilight);
675 const char *righthilight = ui_getstring (UI_righthilight);
676 const char *uparrow = ui_getstring (UI_uparrow);
677 const char *downarrow = ui_getstring (UI_downarrow);
678 const char *leftarrow = ui_getstring (UI_leftarrow);
679 const char *rightarrow = ui_getstring (UI_rightarrow);
680 int i,count,len,maxlen,highlen;
681 int leftoffs,topoffs,visible,topitem;
682 int selected_long;
683
684
685 i = 0;
686 maxlen = 0;
687 highlen = Machine->uiwidth / Machine->uifontwidth;
688 while (items[i])
689 {
690 len = 3 + strlen(items[i]);
691 if (subitems && subitems[i])
692 len += 2 + strlen(subitems[i]);
693 if (len > maxlen && len <= highlen)
694 maxlen = len;
695 i++;
696 }
697 count = i;
698
699 visible = Machine->uiheight / (3 * Machine->uifontheight / 2) - 1;
700 topitem = 0;
701 if (visible > count) visible = count;
702 else
703 {
704 topitem = selected - visible / 2;
705 if (topitem < 0) topitem = 0;
706 if (topitem > count - visible) topitem = count - visible;
707 }
708
709 leftoffs = (Machine->uiwidth - maxlen * Machine->uifontwidth) / 2;
710 topoffs = (Machine->uiheight - (3 * visible + 1) * Machine->uifontheight / 2) / 2;
711
712 /* black background */
713 ui_drawbox(bitmap,leftoffs,topoffs,maxlen * Machine->uifontwidth,(3 * visible + 1) * Machine->uifontheight / 2);
714
715 selected_long = 0;
716 curr_dt = 0;
717 for (i = 0;i < visible;i++)
718 {
719 int item = i + topitem;
720
721 if (i == 0 && item > 0)
722 {
723 dt[curr_dt].text = uparrow;
724 dt[curr_dt].color = UI_COLOR_NORMAL;
725 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(uparrow)) / 2;
726 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
727 curr_dt++;
728 }
729 else if (i == visible - 1 && item < count - 1)
730 {
731 dt[curr_dt].text = downarrow;
732 dt[curr_dt].color = UI_COLOR_NORMAL;
733 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(downarrow)) / 2;
734 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
735 curr_dt++;
736 }
737 else
738 {
739 if (subitems && subitems[item])
740 {
741 int sublen;
742 len = strlen(items[item]);
743 dt[curr_dt].text = items[item];
744 dt[curr_dt].color = UI_COLOR_NORMAL;
745 dt[curr_dt].x = leftoffs + 3*Machine->uifontwidth/2;
746 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
747 curr_dt++;
748 sublen = strlen(subitems[item]);
749 if (sublen > maxlen-5-len)
750 {
751 dt[curr_dt].text = "...";
752 sublen = strlen(dt[curr_dt].text);
753 if (item == selected)
754 selected_long = 1;
755 } else {
756 dt[curr_dt].text = subitems[item];
757 }
758 /* If this item is flagged, draw it in inverse print */
759 dt[curr_dt].color = (flag && flag[item]) ? UI_COLOR_INVERSE : UI_COLOR_NORMAL;
760 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-1-sublen) - Machine->uifontwidth/2;
761 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
762 curr_dt++;
763 }
764 else
765 {
766 dt[curr_dt].text = items[item];
767 dt[curr_dt].color = UI_COLOR_NORMAL;
768 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(items[item])) / 2;
769 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
770 curr_dt++;
771 }
772 }
773 }
774
775 i = selected - topitem;
776 if (subitems && subitems[selected] && arrowize_subitem)
777 {
778 if (arrowize_subitem & 1)
779 {
780 dt[curr_dt].text = leftarrow;
781 dt[curr_dt].color = UI_COLOR_NORMAL;
782 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-2 - strlen(subitems[selected])) - Machine->uifontwidth/2 - 1;
783 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
784 curr_dt++;
785 }
786 if (arrowize_subitem & 2)
787 {
788 dt[curr_dt].text = rightarrow;
789 dt[curr_dt].color = UI_COLOR_NORMAL;
790 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-1) - Machine->uifontwidth/2;
791 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
792 curr_dt++;
793 }
794 }
795 else
796 {
797 dt[curr_dt].text = righthilight;
798 dt[curr_dt].color = UI_COLOR_NORMAL;
799 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-1) - Machine->uifontwidth/2;
800 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
801 curr_dt++;
802 }
803 dt[curr_dt].text = lefthilight;
804 dt[curr_dt].color = UI_COLOR_NORMAL;
805 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2;
806 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
807 curr_dt++;
808
809 dt[curr_dt].text = 0; /* terminate array */
810
811 displaytext(bitmap,dt,0,0);
812
813 if (selected_long)
814 {
815 int long_dx;
816 int long_dy;
817 int long_x;
818 int long_y;
819 unsigned long_max;
820
821 long_max = (Machine->uiwidth / Machine->uifontwidth) - 2;
822 multilinebox_size(&long_dx,&long_dy,subitems[selected],subitems[selected] + strlen(subitems[selected]), long_max);
823
824 long_x = Machine->uiwidth - long_dx;
825 long_y = topoffs + (i+1) * 3*Machine->uifontheight/2;
826
827 /* if too low display up */
828 if (long_y + long_dy > Machine->uiheight)
829 long_y = topoffs + i * 3*Machine->uifontheight/2 - long_dy;
830
831 ui_multitextbox_ex(bitmap,subitems[selected],subitems[selected] + strlen(subitems[selected]), long_max, long_x,long_y,long_dx,long_dy, UI_COLOR_NORMAL);
832 }
833 }
834
835
ui_displaymessagewindow(struct osd_bitmap * bitmap,const char * text)836 void ui_displaymessagewindow(struct osd_bitmap *bitmap,const char *text)
837 {
838 struct DisplayText dt[256];
839 int curr_dt;
840 char *c,*c2;
841 int i,len,maxlen,lines;
842 char textcopy[2048];
843 int leftoffs,topoffs;
844 int maxcols,maxrows;
845
846 maxcols = (Machine->uiwidth / Machine->uifontwidth) - 1;
847 maxrows = (2 * Machine->uiheight - Machine->uifontheight) / (3 * Machine->uifontheight);
848
849 /* copy text, calculate max len, count lines, wrap long lines and crop height to fit */
850 maxlen = 0;
851 lines = 0;
852 c = (char *)text;
853 c2 = textcopy;
854 while (*c)
855 {
856 len = 0;
857 while (*c && *c != '\n')
858 {
859 *c2++ = *c++;
860 len++;
861 if (len == maxcols && *c != '\n')
862 {
863 /* attempt word wrap */
864 char *csave = c, *c2save = c2;
865 int lensave = len;
866
867 /* back up to last space or beginning of line */
868 while (*c != ' ' && *c != '\n' && c > text)
869 --c, --c2, --len;
870
871 /* if no space was found, hard wrap instead */
872 if (*c != ' ')
873 c = csave, c2 = c2save, len = lensave;
874 else
875 c++;
876
877 *c2++ = '\n'; /* insert wrap */
878 break;
879 }
880 }
881
882 if (*c == '\n')
883 *c2++ = *c++;
884
885 if (len > maxlen) maxlen = len;
886
887 lines++;
888 if (lines == maxrows)
889 break;
890 }
891 *c2 = '\0';
892
893 maxlen += 1;
894
895 leftoffs = (Machine->uiwidth - Machine->uifontwidth * maxlen) / 2;
896 if (leftoffs < 0) leftoffs = 0;
897 topoffs = (Machine->uiheight - (3 * lines + 1) * Machine->uifontheight / 2) / 2;
898
899 /* black background */
900 ui_drawbox(bitmap,leftoffs,topoffs,maxlen * Machine->uifontwidth,(3 * lines + 1) * Machine->uifontheight / 2);
901
902 curr_dt = 0;
903 c = textcopy;
904 i = 0;
905 while (*c)
906 {
907 c2 = c;
908 while (*c && *c != '\n')
909 c++;
910
911 if (*c == '\n')
912 {
913 *c = '\0';
914 c++;
915 }
916
917 if (*c2 == '\t') /* center text */
918 {
919 c2++;
920 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * (c - c2)) / 2;
921 }
922 else
923 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2;
924
925 dt[curr_dt].text = c2;
926 dt[curr_dt].color = UI_COLOR_NORMAL;
927 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
928 curr_dt++;
929
930 i++;
931 }
932
933 dt[curr_dt].text = 0; /* terminate array */
934
935 displaytext(bitmap,dt,0,0);
936 }
937
938
939
940 #ifndef MESS
941 #ifdef NEOMAME
942 extern int no_of_tiles;
943 void NeoMVSDrawGfx(unsigned char **line,const struct GfxElement *gfx,
944 unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
945 int zx,int zy,const struct rectangle *clip);
946 void NeoMVSDrawGfx16(unsigned char **line,const struct GfxElement *gfx,
947 unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
948 int zx,int zy,const struct rectangle *clip);
949 extern struct GameDriver driver_neogeo;
950 #endif
951 #endif
952
showcharset(struct osd_bitmap * bitmap)953 static void showcharset(struct osd_bitmap *bitmap)
954 {
955 int i;
956 char buf[80];
957 int bank,color,firstdrawn;
958 int palpage;
959 int changed;
960 int game_is_neogeo=0;
961 unsigned char *orig_used_colors=0;
962
963
964 if (palette_used_colors)
965 {
966 orig_used_colors = (unsigned char*) malloc(Machine->drv->total_colors * sizeof(unsigned char));
967 if (!orig_used_colors) return;
968
969 memcpy(orig_used_colors,palette_used_colors,Machine->drv->total_colors * sizeof(unsigned char));
970 }
971
972 #ifndef MESS
973 #ifdef NEOMAME
974 if (Machine->gamedrv->clone_of == &driver_neogeo ||
975 (Machine->gamedrv->clone_of &&
976 Machine->gamedrv->clone_of->clone_of == &driver_neogeo))
977 game_is_neogeo=1;
978 #endif
979 #endif
980
981 bank = -1;
982 color = 0;
983 firstdrawn = 0;
984 palpage = 0;
985
986 changed = 1;
987
988 do
989 {
990 int cpx,cpy,skip_chars;
991
992 if (bank >= 0)
993 {
994 cpx = Machine->uiwidth / Machine->gfx[bank]->width;
995 cpy = (Machine->uiheight - Machine->uifontheight) / Machine->gfx[bank]->height;
996 skip_chars = cpx * cpy;
997 }
998 else cpx = cpy = skip_chars = 0;
999
1000 if (changed)
1001 {
1002 int lastdrawn=0;
1003
1004 osd_clearbitmap(bitmap);
1005
1006 /* validity chack after char bank change */
1007 if (bank >= 0)
1008 {
1009 if (firstdrawn >= Machine->gfx[bank]->total_elements)
1010 {
1011 firstdrawn = Machine->gfx[bank]->total_elements - skip_chars;
1012 if (firstdrawn < 0) firstdrawn = 0;
1013 }
1014 }
1015
1016 if(bank!=2 || !game_is_neogeo)
1017 {
1018 switch_ui_orientation();
1019
1020 if (bank >= 0)
1021 {
1022 int table_offs;
1023 int flipx,flipy;
1024
1025 if (palette_used_colors)
1026 {
1027 memset(palette_used_colors,PALETTE_COLOR_TRANSPARENT,Machine->drv->total_colors * sizeof(unsigned char));
1028 table_offs = Machine->gfx[bank]->colortable - Machine->remapped_colortable
1029 + Machine->gfx[bank]->color_granularity * color;
1030 for (i = 0;i < Machine->gfx[bank]->color_granularity;i++)
1031 palette_used_colors[Machine->game_colortable[table_offs + i]] = PALETTE_COLOR_USED;
1032 palette_recalc(); /* do it twice in case of previous overflow */
1033 palette_recalc(); /*(we redraw the screen only when it changes) */
1034 }
1035
1036 #ifndef PREROTATE_GFX
1037 flipx = (Machine->orientation ^ trueorientation) & ORIENTATION_FLIP_X;
1038 flipy = (Machine->orientation ^ trueorientation) & ORIENTATION_FLIP_Y;
1039
1040 if (Machine->orientation & ORIENTATION_SWAP_XY)
1041 {
1042 int t;
1043 t = flipx; flipx = flipy; flipy = t;
1044 }
1045 #else
1046 flipx = 0;
1047 flipy = 0;
1048 #endif
1049
1050 for (i = 0; i+firstdrawn < Machine->gfx[bank]->total_elements && i<cpx*cpy; i++)
1051 {
1052 drawgfx(bitmap,Machine->gfx[bank],
1053 i+firstdrawn,color, /*sprite num, color*/
1054 flipx,flipy,
1055 (i % cpx) * Machine->gfx[bank]->width + Machine->uixmin,
1056 Machine->uifontheight + (i / cpx) * Machine->gfx[bank]->height + Machine->uiymin,
1057 0,TRANSPARENCY_NONE,0);
1058
1059 lastdrawn = i+firstdrawn;
1060 }
1061 }
1062 else
1063 {
1064 int sx,sy,colors;
1065
1066 colors = Machine->drv->total_colors - 256 * palpage;
1067 if (colors > 256) colors = 256;
1068 if (palette_used_colors)
1069 {
1070 memset(palette_used_colors,PALETTE_COLOR_UNUSED,Machine->drv->total_colors * sizeof(unsigned char));
1071 memset(palette_used_colors+256*palpage,PALETTE_COLOR_USED,colors * sizeof(unsigned char));
1072 palette_recalc(); /* do it twice in case of previous overflow */
1073 palette_recalc(); /*(we redraw the screen only when it changes) */
1074 }
1075
1076 for (i = 0;i < 16;i++)
1077 {
1078 char bf[40];
1079
1080 sx = 3*Machine->uifontwidth + (Machine->uifontwidth*4/3)*(i % 16);
1081 sprintf(bf,"%X",i);
1082 ui_text(bitmap,bf,sx,2*Machine->uifontheight);
1083 if (16*i < colors)
1084 {
1085 sy = 3*Machine->uifontheight + (Machine->uifontheight)*(i % 16);
1086 sprintf(bf,"%3X",i+16*palpage);
1087 ui_text(bitmap,bf,0,sy);
1088 }
1089 }
1090
1091 for (i = 0;i < colors;i++)
1092 {
1093 sx = Machine->uixmin + 3*Machine->uifontwidth + (Machine->uifontwidth*4/3)*(i % 16);
1094 sy = Machine->uiymin + 2*Machine->uifontheight + (Machine->uifontheight)*(i / 16) + Machine->uifontheight;
1095 plot_box(bitmap,sx,sy,Machine->uifontwidth*4/3,Machine->uifontheight,Machine->pens[i + 256*palpage]);
1096 }
1097 }
1098
1099 switch_true_orientation();
1100 }
1101 #ifndef MESS
1102 #ifdef NEOMAME
1103 else /* neogeo sprite tiles */
1104 {
1105 struct rectangle clip;
1106
1107 clip.min_x = Machine->uixmin;
1108 clip.max_x = Machine->uixmin + Machine->uiwidth - 1;
1109 clip.min_y = Machine->uiymin;
1110 clip.max_y = Machine->uiymin + Machine->uiheight - 1;
1111
1112 if (palette_used_colors)
1113 {
1114 memset(palette_used_colors,PALETTE_COLOR_TRANSPARENT,Machine->drv->total_colors * sizeof(unsigned char));
1115 memset(palette_used_colors+Machine->gfx[bank]->color_granularity*color,PALETTE_COLOR_USED,Machine->gfx[bank]->color_granularity * sizeof(unsigned char));
1116 palette_recalc(); /* do it twice in case of previous overflow */
1117 palette_recalc(); /*(we redraw the screen only when it changes) */
1118 }
1119
1120 for (i = 0; i+firstdrawn < no_of_tiles && i<cpx*cpy; i++)
1121 {
1122 if (bitmap->depth == 16)
1123 NeoMVSDrawGfx16(bitmap->line,Machine->gfx[bank],
1124 i+firstdrawn,color, /*sprite num, color*/
1125 0,0,
1126 (i % cpx) * Machine->gfx[bank]->width + Machine->uixmin,
1127 Machine->uifontheight+1 + (i / cpx) * Machine->gfx[bank]->height + Machine->uiymin,
1128 16,16,&clip);
1129 else
1130 NeoMVSDrawGfx(bitmap->line,Machine->gfx[bank],
1131 i+firstdrawn,color, /*sprite num, color*/
1132 0,0,
1133 (i % cpx) * Machine->gfx[bank]->width + Machine->uixmin,
1134 Machine->uifontheight+1 + (i / cpx) * Machine->gfx[bank]->height + Machine->uiymin,
1135 16,16,&clip);
1136
1137 lastdrawn = i+firstdrawn;
1138 }
1139 }
1140 #endif
1141 #endif
1142
1143 if (bank >= 0)
1144 sprintf(buf,"GFXSET %d COLOR %2X CODE %X-%X",bank,color,firstdrawn,lastdrawn);
1145 else
1146 strcpy(buf,"PALETTE");
1147 ui_text(bitmap,buf,0,0);
1148
1149 changed = 0;
1150 }
1151
1152 update_video_and_audio();
1153
1154 if (code_pressed(KEYCODE_LCONTROL) || code_pressed(KEYCODE_RCONTROL))
1155 {
1156 skip_chars = cpx;
1157 }
1158 if (code_pressed(KEYCODE_LSHIFT) || code_pressed(KEYCODE_RSHIFT))
1159 {
1160 skip_chars = 1;
1161 }
1162
1163
1164 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
1165 {
1166 if (bank+1 < MAX_GFX_ELEMENTS && Machine->gfx[bank + 1])
1167 {
1168 bank++;
1169 // firstdrawn = 0;
1170 changed = 1;
1171 }
1172 }
1173
1174 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
1175 {
1176 if (bank > -1)
1177 {
1178 bank--;
1179 // firstdrawn = 0;
1180 changed = 1;
1181 }
1182 }
1183
1184 if (code_pressed_memory_repeat(KEYCODE_PGDN,4))
1185 {
1186 if (bank >= 0)
1187 {
1188 if (firstdrawn + skip_chars < Machine->gfx[bank]->total_elements)
1189 {
1190 firstdrawn += skip_chars;
1191 changed = 1;
1192 }
1193 }
1194 else
1195 {
1196 if (256 * (palpage + 1) < Machine->drv->total_colors)
1197 {
1198 palpage++;
1199 changed = 1;
1200 }
1201 }
1202 }
1203
1204 if (code_pressed_memory_repeat(KEYCODE_PGUP,4))
1205 {
1206 if (bank >= 0)
1207 {
1208 firstdrawn -= skip_chars;
1209 if (firstdrawn < 0) firstdrawn = 0;
1210 changed = 1;
1211 }
1212 else
1213 {
1214 if (palpage > 0)
1215 {
1216 palpage--;
1217 changed = 1;
1218 }
1219 }
1220 }
1221
1222 if (input_ui_pressed_repeat(IPT_UI_UP,6))
1223 {
1224 if (bank >= 0)
1225 {
1226 if (color < Machine->gfx[bank]->total_colors - 1)
1227 {
1228 color++;
1229 changed = 1;
1230 }
1231 }
1232 }
1233
1234 if (input_ui_pressed_repeat(IPT_UI_DOWN,6))
1235 {
1236 if (color > 0)
1237 {
1238 color--;
1239 changed = 1;
1240 }
1241 }
1242
1243 if (input_ui_pressed(IPT_UI_SNAPSHOT))
1244 osd_save_snapshot(bitmap);
1245 } while (!input_ui_pressed(IPT_UI_SHOW_GFX) &&
1246 !input_ui_pressed(IPT_UI_CANCEL));
1247
1248 /* clear the screen before returning */
1249 osd_clearbitmap(bitmap);
1250
1251 if (palette_used_colors)
1252 {
1253 /* this should force a full refresh by the video driver */
1254 memset(palette_used_colors,PALETTE_COLOR_TRANSPARENT,Machine->drv->total_colors * sizeof(unsigned char));
1255 palette_recalc();
1256 /* restore the game used colors array */
1257 memcpy(palette_used_colors,orig_used_colors,Machine->drv->total_colors * sizeof(unsigned char));
1258 free(orig_used_colors);
1259 }
1260
1261 return;
1262 }
1263
setdipswitches(struct osd_bitmap * bitmap,int selected)1264 static int setdipswitches(struct osd_bitmap *bitmap,int selected)
1265 {
1266 const char *menu_item[128];
1267 const char *menu_subitem[128];
1268 struct InputPort *entry[128];
1269 char flag[40];
1270 int i,sel;
1271 struct InputPort *in;
1272 int total;
1273 int arrowize;
1274
1275
1276 sel = selected - 1;
1277
1278
1279 in = Machine->input_ports;
1280
1281 total = 0;
1282 while (in->type != IPT_END)
1283 {
1284 if ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_NAME && input_port_name(in) != 0 &&
1285 (in->type & IPF_UNUSED) == 0 &&
1286 !(!options.cheat && (in->type & IPF_CHEAT)))
1287 {
1288 entry[total] = in;
1289 menu_item[total] = input_port_name(in);
1290
1291 total++;
1292 }
1293
1294 in++;
1295 }
1296
1297 if (total == 0) return 0;
1298
1299 menu_item[total] = ui_getstring (UI_returntomain);
1300 menu_item[total + 1] = 0; /* terminate array */
1301 total++;
1302
1303
1304 for (i = 0;i < total;i++)
1305 {
1306 flag[i] = 0; /* TODO: flag the dip if it's not the real default */
1307 if (i < total - 1)
1308 {
1309 in = entry[i] + 1;
1310 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1311 in->default_value != entry[i]->default_value)
1312 in++;
1313
1314 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1315 menu_subitem[i] = ui_getstring (UI_INVALID);
1316 else menu_subitem[i] = input_port_name(in);
1317 }
1318 else menu_subitem[i] = 0; /* no subitem */
1319 }
1320
1321 arrowize = 0;
1322 if (sel < total - 1)
1323 {
1324 in = entry[sel] + 1;
1325 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1326 in->default_value != entry[sel]->default_value)
1327 in++;
1328
1329 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1330 /* invalid setting: revert to a valid one */
1331 arrowize |= 1;
1332 else
1333 {
1334 if (((in-1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1335 !(!options.cheat && ((in-1)->type & IPF_CHEAT)))
1336 arrowize |= 1;
1337 }
1338 }
1339 if (sel < total - 1)
1340 {
1341 in = entry[sel] + 1;
1342 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1343 in->default_value != entry[sel]->default_value)
1344 in++;
1345
1346 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1347 /* invalid setting: revert to a valid one */
1348 arrowize |= 2;
1349 else
1350 {
1351 if (((in+1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1352 !(!options.cheat && ((in+1)->type & IPF_CHEAT)))
1353 arrowize |= 2;
1354 }
1355 }
1356
1357 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel,arrowize);
1358
1359 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
1360 sel = (sel + 1) % total;
1361
1362 if (input_ui_pressed_repeat(IPT_UI_UP,8))
1363 sel = (sel + total - 1) % total;
1364
1365 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
1366 {
1367 if (sel < total - 1)
1368 {
1369 in = entry[sel] + 1;
1370 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1371 in->default_value != entry[sel]->default_value)
1372 in++;
1373
1374 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1375 /* invalid setting: revert to a valid one */
1376 entry[sel]->default_value = (entry[sel]+1)->default_value & entry[sel]->mask;
1377 else
1378 {
1379 if (((in+1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1380 !(!options.cheat && ((in+1)->type & IPF_CHEAT)))
1381 entry[sel]->default_value = (in+1)->default_value & entry[sel]->mask;
1382 }
1383
1384 /* tell updatescreen() to clean after us (in case the window changes size) */
1385 need_to_clear_bitmap = 1;
1386 }
1387 }
1388
1389 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
1390 {
1391 if (sel < total - 1)
1392 {
1393 in = entry[sel] + 1;
1394 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1395 in->default_value != entry[sel]->default_value)
1396 in++;
1397
1398 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1399 /* invalid setting: revert to a valid one */
1400 entry[sel]->default_value = (entry[sel]+1)->default_value & entry[sel]->mask;
1401 else
1402 {
1403 if (((in-1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1404 !(!options.cheat && ((in-1)->type & IPF_CHEAT)))
1405 entry[sel]->default_value = (in-1)->default_value & entry[sel]->mask;
1406 }
1407
1408 /* tell updatescreen() to clean after us (in case the window changes size) */
1409 need_to_clear_bitmap = 1;
1410 }
1411 }
1412
1413 if (input_ui_pressed(IPT_UI_SELECT))
1414 {
1415 if (sel == total - 1) sel = -1;
1416 }
1417
1418 if (input_ui_pressed(IPT_UI_CANCEL))
1419 sel = -1;
1420
1421 if (input_ui_pressed(IPT_UI_CONFIGURE))
1422 sel = -2;
1423
1424 if (sel == -1 || sel == -2)
1425 {
1426 /* tell updatescreen() to clean after us */
1427 need_to_clear_bitmap = 1;
1428 }
1429
1430 return sel + 1;
1431 }
1432
1433 /* This flag is used for record OR sequence of key/joy */
1434 /* when is !=0 the first sequence is record, otherwise the first free */
1435 /* it's used byt setdefkeysettings, setdefjoysettings, setkeysettings, setjoysettings */
1436 static int record_first_insert = 1;
1437
1438 static char menu_subitem_buffer[400][96];
1439
setdefcodesettings(struct osd_bitmap * bitmap,int selected)1440 static int setdefcodesettings(struct osd_bitmap *bitmap,int selected)
1441 {
1442 const char *menu_item[400];
1443 const char *menu_subitem[400];
1444 struct ipd *entry[400];
1445 char flag[400];
1446 int i,sel;
1447 struct ipd *in;
1448 int total;
1449 extern struct ipd inputport_defaults[];
1450
1451 sel = selected - 1;
1452
1453
1454 if (Machine->input_ports == 0)
1455 return 0;
1456
1457 in = inputport_defaults;
1458
1459 total = 0;
1460 while (in->type != IPT_END)
1461 {
1462 if (in->name != 0 && (in->type & ~IPF_MASK) != IPT_UNKNOWN && (in->type & IPF_UNUSED) == 0
1463 && !(!options.cheat && (in->type & IPF_CHEAT)))
1464 {
1465 entry[total] = in;
1466 menu_item[total] = in->name;
1467
1468 total++;
1469 }
1470
1471 in++;
1472 }
1473
1474 if (total == 0) return 0;
1475
1476 menu_item[total] = ui_getstring (UI_returntomain);
1477 menu_item[total + 1] = 0; /* terminate array */
1478 total++;
1479
1480 for (i = 0;i < total;i++)
1481 {
1482 if (i < total - 1)
1483 {
1484 seq_name(&entry[i]->seq,menu_subitem_buffer[i],sizeof(menu_subitem_buffer[0]));
1485 menu_subitem[i] = menu_subitem_buffer[i];
1486 } else
1487 menu_subitem[i] = 0; /* no subitem */
1488 flag[i] = 0;
1489 }
1490
1491 if (sel > SEL_MASK) /* are we waiting for a new key? */
1492 {
1493 int ret;
1494
1495 menu_subitem[sel & SEL_MASK] = " ";
1496 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel & SEL_MASK,3);
1497
1498 ret = seq_read_async(&entry[sel & SEL_MASK]->seq,record_first_insert);
1499
1500 if (ret >= 0)
1501 {
1502 sel &= 0xff;
1503
1504 if (ret > 0 || seq_get_1(&entry[sel]->seq) == CODE_NONE)
1505 {
1506 seq_set_1(&entry[sel]->seq,CODE_NONE);
1507 ret = 1;
1508 }
1509
1510 /* tell updatescreen() to clean after us (in case the window changes size) */
1511 need_to_clear_bitmap = 1;
1512
1513 record_first_insert = ret != 0;
1514 }
1515
1516
1517 return sel + 1;
1518 }
1519
1520
1521 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel,0);
1522
1523 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
1524 {
1525 sel = (sel + 1) % total;
1526 record_first_insert = 1;
1527 }
1528
1529 if (input_ui_pressed_repeat(IPT_UI_UP,8))
1530 {
1531 sel = (sel + total - 1) % total;
1532 record_first_insert = 1;
1533 }
1534
1535 if (input_ui_pressed(IPT_UI_SELECT))
1536 {
1537 if (sel == total - 1) sel = -1;
1538 else
1539 {
1540 seq_read_async_start();
1541
1542 sel |= 1 << SEL_BITS; /* we'll ask for a key */
1543
1544 /* tell updatescreen() to clean after us (in case the window changes size) */
1545 need_to_clear_bitmap = 1;
1546 }
1547 }
1548
1549 if (input_ui_pressed(IPT_UI_CANCEL))
1550 sel = -1;
1551
1552 if (input_ui_pressed(IPT_UI_CONFIGURE))
1553 sel = -2;
1554
1555 if (sel == -1 || sel == -2)
1556 {
1557 /* tell updatescreen() to clean after us */
1558 need_to_clear_bitmap = 1;
1559
1560 record_first_insert = 1;
1561 }
1562
1563 return sel + 1;
1564 }
1565
1566
1567
setcodesettings(struct osd_bitmap * bitmap,int selected)1568 static int setcodesettings(struct osd_bitmap *bitmap,int selected)
1569 {
1570 const char *menu_item[400];
1571 const char *menu_subitem[400];
1572 struct InputPort *entry[400];
1573 char flag[400];
1574 int i,sel;
1575 struct InputPort *in;
1576 int total;
1577
1578
1579 sel = selected - 1;
1580
1581
1582 if (Machine->input_ports == 0)
1583 return 0;
1584
1585 in = Machine->input_ports;
1586
1587 total = 0;
1588 while (in->type != IPT_END)
1589 {
1590 if (input_port_name(in) != 0 && seq_get_1(&in->seq) != CODE_NONE && (in->type & ~IPF_MASK) != IPT_UNKNOWN)
1591 {
1592 entry[total] = in;
1593 menu_item[total] = input_port_name(in);
1594
1595 total++;
1596 }
1597
1598 in++;
1599 }
1600
1601 if (total == 0) return 0;
1602
1603 menu_item[total] = ui_getstring (UI_returntomain);
1604 menu_item[total + 1] = 0; /* terminate array */
1605 total++;
1606
1607 for (i = 0;i < total;i++)
1608 {
1609 if (i < total - 1)
1610 {
1611 seq_name(input_port_seq(entry[i]),menu_subitem_buffer[i],sizeof(menu_subitem_buffer[0]));
1612 menu_subitem[i] = menu_subitem_buffer[i];
1613
1614 /* If the key isn't the default, flag it */
1615 if (seq_get_1(&entry[i]->seq) != CODE_DEFAULT)
1616 flag[i] = 1;
1617 else
1618 flag[i] = 0;
1619
1620 } else
1621 menu_subitem[i] = 0; /* no subitem */
1622 }
1623
1624 if (sel > SEL_MASK) /* are we waiting for a new key? */
1625 {
1626 int ret;
1627
1628 menu_subitem[sel & SEL_MASK] = " ";
1629 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel & SEL_MASK,3);
1630
1631 ret = seq_read_async(&entry[sel & SEL_MASK]->seq,record_first_insert);
1632
1633 if (ret >= 0)
1634 {
1635 sel &= 0xff;
1636
1637 if (ret > 0 || seq_get_1(&entry[sel]->seq) == CODE_NONE)
1638 {
1639 seq_set_1(&entry[sel]->seq, CODE_DEFAULT);
1640 ret = 1;
1641 }
1642
1643 /* tell updatescreen() to clean after us (in case the window changes size) */
1644 need_to_clear_bitmap = 1;
1645
1646 record_first_insert = ret != 0;
1647 }
1648
1649 return sel + 1;
1650 }
1651
1652
1653 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel,0);
1654
1655 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
1656 {
1657 sel = (sel + 1) % total;
1658 record_first_insert = 1;
1659 }
1660
1661 if (input_ui_pressed_repeat(IPT_UI_UP,8))
1662 {
1663 sel = (sel + total - 1) % total;
1664 record_first_insert = 1;
1665 }
1666
1667 if (input_ui_pressed(IPT_UI_SELECT))
1668 {
1669 if (sel == total - 1) sel = -1;
1670 else
1671 {
1672 seq_read_async_start();
1673
1674 sel |= 1 << SEL_BITS; /* we'll ask for a key */
1675
1676 /* tell updatescreen() to clean after us (in case the window changes size) */
1677 need_to_clear_bitmap = 1;
1678 }
1679 }
1680
1681 if (input_ui_pressed(IPT_UI_CANCEL))
1682 sel = -1;
1683
1684 if (input_ui_pressed(IPT_UI_CONFIGURE))
1685 sel = -2;
1686
1687 if (sel == -1 || sel == -2)
1688 {
1689 /* tell updatescreen() to clean after us */
1690 need_to_clear_bitmap = 1;
1691
1692 record_first_insert = 1;
1693 }
1694
1695 return sel + 1;
1696 }
1697
1698
calibratejoysticks(struct osd_bitmap * bitmap,int selected)1699 static int calibratejoysticks(struct osd_bitmap *bitmap,int selected)
1700 {
1701 char *msg;
1702 char buf[2048];
1703 int sel;
1704 static int calibration_started = 0;
1705
1706 sel = selected - 1;
1707
1708 if (calibration_started == 0)
1709 {
1710 osd_joystick_start_calibration();
1711 calibration_started = 1;
1712 strcpy (buf, "");
1713 }
1714
1715 if (sel > SEL_MASK) /* Waiting for the user to acknowledge joystick movement */
1716 {
1717 if (input_ui_pressed(IPT_UI_CANCEL))
1718 {
1719 calibration_started = 0;
1720 sel = -1;
1721 }
1722 else if (input_ui_pressed(IPT_UI_SELECT))
1723 {
1724 osd_joystick_calibrate();
1725 sel &= 0xff;
1726 }
1727
1728 ui_displaymessagewindow(bitmap,buf);
1729 }
1730 else
1731 {
1732 msg = osd_joystick_calibrate_next();
1733 need_to_clear_bitmap = 1;
1734 if (msg == 0)
1735 {
1736 calibration_started = 0;
1737 osd_joystick_end_calibration();
1738 sel = -1;
1739 }
1740 else
1741 {
1742 strcpy (buf, msg);
1743 ui_displaymessagewindow(bitmap,buf);
1744 sel |= 1 << SEL_BITS;
1745 }
1746 }
1747
1748 if (input_ui_pressed(IPT_UI_CONFIGURE))
1749 sel = -2;
1750
1751 if (sel == -1 || sel == -2)
1752 {
1753 /* tell updatescreen() to clean after us */
1754 need_to_clear_bitmap = 1;
1755 }
1756
1757 return sel + 1;
1758 }
1759
1760
settraksettings(struct osd_bitmap * bitmap,int selected)1761 static int settraksettings(struct osd_bitmap *bitmap,int selected)
1762 {
1763 const char *menu_item[40];
1764 const char *menu_subitem[40];
1765 struct InputPort *entry[40];
1766 int i,sel;
1767 struct InputPort *in;
1768 int total,total2;
1769 int arrowize;
1770
1771
1772 sel = selected - 1;
1773
1774
1775 if (Machine->input_ports == 0)
1776 return 0;
1777
1778 in = Machine->input_ports;
1779
1780 /* Count the total number of analog controls */
1781 total = 0;
1782 while (in->type != IPT_END)
1783 {
1784 if (((in->type & 0xff) > IPT_ANALOG_START) && ((in->type & 0xff) < IPT_ANALOG_END)
1785 && !(!options.cheat && (in->type & IPF_CHEAT)))
1786 {
1787 entry[total] = in;
1788 total++;
1789 }
1790 in++;
1791 }
1792
1793 if (total == 0) return 0;
1794
1795 /* Each analog control has 3 entries - key & joy delta, reverse, sensitivity */
1796
1797 #define ENTRIES 3
1798
1799 total2 = total * ENTRIES;
1800
1801 menu_item[total2] = ui_getstring (UI_returntomain);
1802 menu_item[total2 + 1] = 0; /* terminate array */
1803 total2++;
1804
1805 arrowize = 0;
1806 for (i = 0;i < total2;i++)
1807 {
1808 if (i < total2 - 1)
1809 {
1810 char label[30][40];
1811 char setting[30][40];
1812 int sensitivity,delta;
1813 int reverse;
1814
1815 strcpy (label[i], input_port_name(entry[i/ENTRIES]));
1816 sensitivity = IP_GET_SENSITIVITY(entry[i/ENTRIES]);
1817 delta = IP_GET_DELTA(entry[i/ENTRIES]);
1818 reverse = (entry[i/ENTRIES]->type & IPF_REVERSE);
1819
1820 strcat (label[i], " ");
1821 switch (i%ENTRIES)
1822 {
1823 case 0:
1824 strcat (label[i], ui_getstring (UI_keyjoyspeed));
1825 sprintf(setting[i],"%d",delta);
1826 if (i == sel) arrowize = 3;
1827 break;
1828 case 1:
1829 strcat (label[i], ui_getstring (UI_reverse));
1830 if (reverse)
1831 sprintf(setting[i],"%s", ui_getstring (UI_on));
1832 else
1833 sprintf(setting[i],"%s", ui_getstring (UI_off));
1834 if (i == sel) arrowize = 3;
1835 break;
1836 case 2:
1837 strcat (label[i], ui_getstring (UI_sensitivity));
1838 sprintf(setting[i],"%3d%%",sensitivity);
1839 if (i == sel) arrowize = 3;
1840 break;
1841 }
1842
1843 menu_item[i] = label[i];
1844 menu_subitem[i] = setting[i];
1845
1846 in++;
1847 }
1848 else menu_subitem[i] = 0; /* no subitem */
1849 }
1850
1851 ui_displaymenu(bitmap,menu_item,menu_subitem,0,sel,arrowize);
1852
1853 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
1854 sel = (sel + 1) % total2;
1855
1856 if (input_ui_pressed_repeat(IPT_UI_UP,8))
1857 sel = (sel + total2 - 1) % total2;
1858
1859 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
1860 {
1861 if ((sel % ENTRIES) == 0)
1862 /* keyboard/joystick delta */
1863 {
1864 int val = IP_GET_DELTA(entry[sel/ENTRIES]);
1865
1866 val --;
1867 if (val < 1) val = 1;
1868 IP_SET_DELTA(entry[sel/ENTRIES],val);
1869 }
1870 else if ((sel % ENTRIES) == 1)
1871 /* reverse */
1872 {
1873 int reverse = entry[sel/ENTRIES]->type & IPF_REVERSE;
1874 if (reverse)
1875 reverse=0;
1876 else
1877 reverse=IPF_REVERSE;
1878 entry[sel/ENTRIES]->type &= ~IPF_REVERSE;
1879 entry[sel/ENTRIES]->type |= reverse;
1880 }
1881 else if ((sel % ENTRIES) == 2)
1882 /* sensitivity */
1883 {
1884 int val = IP_GET_SENSITIVITY(entry[sel/ENTRIES]);
1885
1886 val --;
1887 if (val < 1) val = 1;
1888 IP_SET_SENSITIVITY(entry[sel/ENTRIES],val);
1889 }
1890 }
1891
1892 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
1893 {
1894 if ((sel % ENTRIES) == 0)
1895 /* keyboard/joystick delta */
1896 {
1897 int val = IP_GET_DELTA(entry[sel/ENTRIES]);
1898
1899 val ++;
1900 if (val > 255) val = 255;
1901 IP_SET_DELTA(entry[sel/ENTRIES],val);
1902 }
1903 else if ((sel % ENTRIES) == 1)
1904 /* reverse */
1905 {
1906 int reverse = entry[sel/ENTRIES]->type & IPF_REVERSE;
1907 if (reverse)
1908 reverse=0;
1909 else
1910 reverse=IPF_REVERSE;
1911 entry[sel/ENTRIES]->type &= ~IPF_REVERSE;
1912 entry[sel/ENTRIES]->type |= reverse;
1913 }
1914 else if ((sel % ENTRIES) == 2)
1915 /* sensitivity */
1916 {
1917 int val = IP_GET_SENSITIVITY(entry[sel/ENTRIES]);
1918
1919 val ++;
1920 if (val > 255) val = 255;
1921 IP_SET_SENSITIVITY(entry[sel/ENTRIES],val);
1922 }
1923 }
1924
1925 if (input_ui_pressed(IPT_UI_SELECT))
1926 {
1927 if (sel == total2 - 1) sel = -1;
1928 }
1929
1930 if (input_ui_pressed(IPT_UI_CANCEL))
1931 sel = -1;
1932
1933 if (input_ui_pressed(IPT_UI_CONFIGURE))
1934 sel = -2;
1935
1936 if (sel == -1 || sel == -2)
1937 {
1938 /* tell updatescreen() to clean after us */
1939 need_to_clear_bitmap = 1;
1940 }
1941
1942 return sel + 1;
1943 }
1944
1945 #ifndef MESS
mame_stats(struct osd_bitmap * bitmap,int selected)1946 static int mame_stats(struct osd_bitmap *bitmap,int selected)
1947 {
1948 char temp[10];
1949 char buf[2048];
1950 int sel, i;
1951
1952
1953 sel = selected - 1;
1954
1955 buf[0] = 0;
1956
1957 if (dispensed_tickets)
1958 {
1959 strcat(buf, ui_getstring (UI_tickets));
1960 strcat(buf, ": ");
1961 sprintf(temp, "%d\n\n", dispensed_tickets);
1962 strcat(buf, temp);
1963 }
1964
1965 for (i=0; i<COIN_COUNTERS; i++)
1966 {
1967 strcat(buf, ui_getstring (UI_coin));
1968 sprintf(temp, " %c: ", i+'A');
1969 strcat(buf, temp);
1970 if (!coins[i])
1971 strcat (buf, ui_getstring (UI_NA));
1972 else
1973 {
1974 sprintf (temp, "%d", coins[i]);
1975 strcat (buf, temp);
1976 }
1977 if (coinlockedout[i])
1978 {
1979 strcat(buf, " ");
1980 strcat(buf, ui_getstring (UI_locked));
1981 strcat(buf, "\n");
1982 }
1983 else
1984 {
1985 strcat(buf, "\n");
1986 }
1987 }
1988
1989 {
1990 /* menu system, use the normal menu keys */
1991 strcat(buf,"\n\t");
1992 strcat(buf,ui_getstring (UI_lefthilight));
1993 strcat(buf," ");
1994 strcat(buf,ui_getstring (UI_returntomain));
1995 strcat(buf," ");
1996 strcat(buf,ui_getstring (UI_righthilight));
1997
1998 ui_displaymessagewindow(bitmap,buf);
1999
2000 if (input_ui_pressed(IPT_UI_SELECT))
2001 sel = -1;
2002
2003 if (input_ui_pressed(IPT_UI_CANCEL))
2004 sel = -1;
2005
2006 if (input_ui_pressed(IPT_UI_CONFIGURE))
2007 sel = -2;
2008 }
2009
2010 if (sel == -1 || sel == -2)
2011 {
2012 /* tell updatescreen() to clean after us */
2013 need_to_clear_bitmap = 1;
2014 }
2015
2016 return sel + 1;
2017 }
2018 #endif
2019
showcopyright(struct osd_bitmap * bitmap)2020 int showcopyright(struct osd_bitmap *bitmap)
2021 {
2022 int done;
2023 char buf[1000];
2024 char buf2[256];
2025
2026 strcpy (buf, ui_getstring(UI_copyright1));
2027 strcat (buf, "\n\n");
2028 sprintf(buf2, "%s%s", ui_getstring(UI_copyright2), Machine->gamedrv->description);
2029 strcat (buf, buf2);
2030 strcat (buf, "\n\n");
2031 strcat (buf, ui_getstring(UI_copyright3));
2032
2033 ui_displaymessagewindow(bitmap,buf);
2034
2035 setup_selected = -1;////
2036 done = 0;
2037 do
2038 {
2039 update_video_and_audio();
2040 osd_poll_joysticks();
2041 if (input_ui_pressed(IPT_UI_CANCEL))
2042 {
2043 setup_selected = 0;////
2044 return 1;
2045 }
2046 if (keyboard_pressed_memory(KEYCODE_O) ||
2047 input_ui_pressed(IPT_UI_LEFT))
2048 done = 1;
2049 if (done == 1 && (keyboard_pressed_memory(KEYCODE_K) ||
2050 input_ui_pressed(IPT_UI_RIGHT)))
2051 done = 2;
2052 } while (done < 2);
2053
2054 setup_selected = 0;////
2055 osd_clearbitmap(bitmap);
2056 update_video_and_audio();
2057
2058 return 0;
2059 }
2060
displaygameinfo(struct osd_bitmap * bitmap,int selected)2061 static int displaygameinfo(struct osd_bitmap *bitmap,int selected)
2062 {
2063 int i;
2064 char buf[2048];
2065 char buf2[32];
2066 int sel;
2067
2068
2069 sel = selected - 1;
2070
2071
2072 sprintf(buf,"%s\n%s %s\n\n%s:\n",Machine->gamedrv->description,Machine->gamedrv->year,Machine->gamedrv->manufacturer,
2073 ui_getstring (UI_cpu));
2074 i = 0;
2075 while (i < MAX_CPU && Machine->drv->cpu[i].cpu_type)
2076 {
2077
2078 if (Machine->drv->cpu[i].cpu_clock >= 1000000)
2079 sprintf(&buf[strlen(buf)],"%s %d.%06d MHz",
2080 cputype_name(Machine->drv->cpu[i].cpu_type),
2081 Machine->drv->cpu[i].cpu_clock / 1000000,
2082 Machine->drv->cpu[i].cpu_clock % 1000000);
2083 else
2084 sprintf(&buf[strlen(buf)],"%s %d.%03d kHz",
2085 cputype_name(Machine->drv->cpu[i].cpu_type),
2086 Machine->drv->cpu[i].cpu_clock / 1000,
2087 Machine->drv->cpu[i].cpu_clock % 1000);
2088
2089 if (Machine->drv->cpu[i].cpu_type & CPU_AUDIO_CPU)
2090 {
2091 sprintf (buf2, " (%s)", ui_getstring (UI_sound_lc));
2092 strcat(buf, buf2);
2093 }
2094
2095 strcat(buf,"\n");
2096
2097 i++;
2098 }
2099
2100 sprintf (buf2, "\n%s", ui_getstring (UI_sound));
2101 strcat (buf, buf2);
2102 if (Machine->drv->sound_attributes & SOUND_SUPPORTS_STEREO)
2103 sprintf(&buf[strlen(buf)]," (%s)", ui_getstring (UI_stereo));
2104 strcat(buf,":\n");
2105
2106 i = 0;
2107 while (i < MAX_SOUND && Machine->drv->sound[i].sound_type)
2108 {
2109 if (sound_num(&Machine->drv->sound[i]))
2110 sprintf(&buf[strlen(buf)],"%dx",sound_num(&Machine->drv->sound[i]));
2111
2112 sprintf(&buf[strlen(buf)],"%s",sound_name(&Machine->drv->sound[i]));
2113
2114 if (sound_clock(&Machine->drv->sound[i]))
2115 {
2116 if (sound_clock(&Machine->drv->sound[i]) >= 1000000)
2117 sprintf(&buf[strlen(buf)]," %d.%06d MHz",
2118 sound_clock(&Machine->drv->sound[i]) / 1000000,
2119 sound_clock(&Machine->drv->sound[i]) % 1000000);
2120 else
2121 sprintf(&buf[strlen(buf)]," %d.%03d kHz",
2122 sound_clock(&Machine->drv->sound[i]) / 1000,
2123 sound_clock(&Machine->drv->sound[i]) % 1000);
2124 }
2125
2126 strcat(buf,"\n");
2127
2128 i++;
2129 }
2130
2131 if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR)
2132 sprintf(&buf[strlen(buf)],"\n%s\n", ui_getstring (UI_vectorgame));
2133 else
2134 {
2135 int pixelx,pixely,tmax,tmin,rem;
2136
2137 pixelx = 4 * (Machine->visible_area.max_y - Machine->visible_area.min_y + 1);
2138 pixely = 3 * (Machine->visible_area.max_x - Machine->visible_area.min_x + 1);
2139
2140 /* calculate MCD */
2141 if (pixelx >= pixely)
2142 {
2143 tmax = pixelx;
2144 tmin = pixely;
2145 }
2146 else
2147 {
2148 tmax = pixely;
2149 tmin = pixelx;
2150 }
2151 while ( (rem = tmax % tmin) )
2152 {
2153 tmax = tmin;
2154 tmin = rem;
2155 }
2156 /* tmin is now the MCD */
2157
2158 pixelx /= tmin;
2159 pixely /= tmin;
2160
2161 sprintf(&buf[strlen(buf)],"\n%s:\n", ui_getstring (UI_screenres));
2162 sprintf(&buf[strlen(buf)],"%d x %d (%s) %f Hz\n",
2163 Machine->visible_area.max_x - Machine->visible_area.min_x + 1,
2164 Machine->visible_area.max_y - Machine->visible_area.min_y + 1,
2165 (Machine->gamedrv->flags & ORIENTATION_SWAP_XY) ? "V" : "H",
2166 Machine->drv->frames_per_second);
2167 #if 0
2168 sprintf(&buf[strlen(buf)],"pixel aspect ratio %d:%d\n",
2169 pixelx,pixely);
2170 sprintf(&buf[strlen(buf)],"%d colors ",Machine->drv->total_colors);
2171 if (Machine->gamedrv->flags & GAME_REQUIRES_16BIT)
2172 strcat(buf,"(16-bit required)\n");
2173 else if (Machine->drv->video_attributes & VIDEO_MODIFIES_PALETTE)
2174 strcat(buf,"(dynamic)\n");
2175 else strcat(buf,"(static)\n");
2176 #endif
2177 }
2178
2179
2180 if (sel == -1)
2181 {
2182 /* startup info, print MAME version and ask for any key */
2183
2184 sprintf (buf2, "\n\t%s ", ui_getstring (UI_mame)); /* \t means that the line will be centered */
2185 strcat(buf, buf2);
2186
2187 strcat(buf,build_version);
2188 sprintf (buf2, "\n\t%s", ui_getstring (UI_anykey));
2189 strcat(buf,buf2);
2190 ui_drawbox(bitmap,0,0,Machine->uiwidth,Machine->uiheight);
2191 ui_displaymessagewindow(bitmap,buf);
2192
2193 sel = 0;
2194 if (code_read_async() != CODE_NONE)
2195 sel = -1;
2196 }
2197 else
2198 {
2199 /* menu system, use the normal menu keys */
2200 strcat(buf,"\n\t");
2201 strcat(buf,ui_getstring (UI_lefthilight));
2202 strcat(buf," ");
2203 strcat(buf,ui_getstring (UI_returntomain));
2204 strcat(buf," ");
2205 strcat(buf,ui_getstring (UI_righthilight));
2206
2207 ui_displaymessagewindow(bitmap,buf);
2208
2209 if (input_ui_pressed(IPT_UI_SELECT))
2210 sel = -1;
2211
2212 if (input_ui_pressed(IPT_UI_CANCEL))
2213 sel = -1;
2214
2215 if (input_ui_pressed(IPT_UI_CONFIGURE))
2216 sel = -2;
2217 }
2218
2219 if (sel == -1 || sel == -2)
2220 {
2221 /* tell updatescreen() to clean after us */
2222 need_to_clear_bitmap = 1;
2223 }
2224
2225 return sel + 1;
2226 }
2227
2228
showgamewarnings(struct osd_bitmap * bitmap)2229 int showgamewarnings(struct osd_bitmap *bitmap)
2230 {
2231 int i;
2232 char buf[2048];
2233
2234 //sq If show info in options disabled just return
2235 if (!global_showinfo) return 0;
2236
2237 if (Machine->gamedrv->flags &
2238 (GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_WRONG_COLORS | GAME_IMPERFECT_COLORS |
2239 GAME_NO_SOUND | GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL))
2240 {
2241 int done;
2242
2243 strcpy(buf, ui_getstring (UI_knownproblems));
2244 strcat(buf, "\n\n");
2245
2246 #ifdef MESS
2247 if (Machine->gamedrv->flags & GAME_COMPUTER)
2248 {
2249 strcpy(buf, ui_getstring (UI_comp1));
2250 strcat(buf, "\n\n");
2251 strcat(buf, ui_getstring (UI_comp2));
2252 strcat(buf, "\n");
2253 }
2254 #endif
2255
2256 if (Machine->gamedrv->flags & GAME_IMPERFECT_COLORS)
2257 {
2258 strcat(buf, ui_getstring (UI_imperfectcolors));
2259 strcat(buf, "\n");
2260 }
2261
2262 if (Machine->gamedrv->flags & GAME_WRONG_COLORS)
2263 {
2264 strcat(buf, ui_getstring (UI_wrongcolors));
2265 strcat(buf, "\n");
2266 }
2267
2268 if (Machine->gamedrv->flags & GAME_IMPERFECT_SOUND)
2269 {
2270 strcat(buf, ui_getstring (UI_imperfectsound));
2271 strcat(buf, "\n");
2272 }
2273
2274 if (Machine->gamedrv->flags & GAME_NO_SOUND)
2275 {
2276 strcat(buf, ui_getstring (UI_nosound));
2277 strcat(buf, "\n");
2278 }
2279
2280 if (Machine->gamedrv->flags & GAME_NO_COCKTAIL)
2281 {
2282 strcat(buf, ui_getstring (UI_nococktail));
2283 strcat(buf, "\n");
2284 }
2285
2286 if (Machine->gamedrv->flags & (GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION))
2287 {
2288 const struct GameDriver *maindrv;
2289 int foundworking;
2290
2291 if (Machine->gamedrv->flags & GAME_NOT_WORKING)
2292 strcpy(buf, ui_getstring (UI_brokengame));
2293 if (Machine->gamedrv->flags & GAME_UNEMULATED_PROTECTION)
2294 strcat(buf, ui_getstring (UI_brokenprotection));
2295
2296 if (Machine->gamedrv->clone_of && !(Machine->gamedrv->clone_of->flags & NOT_A_DRIVER))
2297 maindrv = Machine->gamedrv->clone_of;
2298 else maindrv = Machine->gamedrv;
2299
2300 foundworking = 0;
2301 i = 0;
2302 while (drivers[i])
2303 {
2304 if (drivers[i] == maindrv || drivers[i]->clone_of == maindrv)
2305 {
2306 if ((drivers[i]->flags & (GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION)) == 0)
2307 {
2308 if (foundworking == 0)
2309 {
2310 strcat(buf,"\n\n");
2311 strcat(buf, ui_getstring (UI_workingclones));
2312 strcat(buf,"\n\n");
2313 }
2314 foundworking = 1;
2315
2316 sprintf(&buf[strlen(buf)],"%s\n",drivers[i]->name);
2317 }
2318 }
2319 i++;
2320 }
2321 }
2322
2323 strcat(buf,"\n\n");
2324 strcat(buf,ui_getstring (UI_typeok));
2325
2326 ui_displaymessagewindow(bitmap,buf);
2327
2328 done = 0;
2329 do
2330 {
2331 update_video_and_audio();
2332 osd_poll_joysticks();
2333 if (input_ui_pressed(IPT_UI_CANCEL))
2334 return 1;
2335 if (code_pressed_memory(KEYCODE_O) ||
2336 input_ui_pressed(IPT_UI_LEFT))
2337 done = 1;
2338 if (done == 1 && (code_pressed_memory(KEYCODE_K) ||
2339 input_ui_pressed(IPT_UI_RIGHT)))
2340 done = 2;
2341 } while (done < 2);
2342 }
2343
2344
2345 osd_clearbitmap(bitmap);
2346
2347 /* clear the input memory */
2348 while (code_read_async() != CODE_NONE) {};
2349
2350 while (displaygameinfo(bitmap,0) == 1)
2351 {
2352 update_video_and_audio();
2353 osd_poll_joysticks();
2354 }
2355
2356 #ifdef MESS
2357 while (displayimageinfo(bitmap,0) == 1)
2358 {
2359 update_video_and_audio();
2360 osd_poll_joysticks();
2361 }
2362 #endif
2363
2364 osd_clearbitmap(bitmap);
2365 /* make sure that the screen is really cleared, in case autoframeskip kicked in */
2366 update_video_and_audio();
2367 update_video_and_audio();
2368 update_video_and_audio();
2369 update_video_and_audio();
2370
2371 return 0;
2372 }
2373
2374 /* Word-wraps the text in the specified buffer to fit in maxwidth characters per line.
2375 The contents of the buffer are modified.
2376 Known limitations: Words longer than maxwidth cause the function to fail. */
wordwrap_text_buffer(char * buffer,int maxwidth)2377 static void wordwrap_text_buffer (char *buffer, int maxwidth)
2378 {
2379 int width = 0;
2380
2381 while (*buffer)
2382 {
2383 if (*buffer == '\n')
2384 {
2385 buffer++;
2386 width = 0;
2387 continue;
2388 }
2389
2390 width++;
2391
2392 if (width > maxwidth)
2393 {
2394 /* backtrack until a space is found */
2395 while (*buffer != ' ')
2396 {
2397 buffer--;
2398 width--;
2399 }
2400 if (width < 1) return; /* word too long */
2401
2402 /* replace space with a newline */
2403 *buffer = '\n';
2404 }
2405 else
2406 buffer++;
2407 }
2408 }
2409
count_lines_in_buffer(char * buffer)2410 static int count_lines_in_buffer (char *buffer)
2411 {
2412 int lines = 0;
2413 char c;
2414
2415 while ( (c = *buffer++) )
2416 if (c == '\n') lines++;
2417
2418 return lines;
2419 }
2420
2421 /* Display lines from buffer, starting with line 'scroll', in a width x height text window */
display_scroll_message(struct osd_bitmap * bitmap,int * scroll,int width,int height,char * buf)2422 static void display_scroll_message (struct osd_bitmap *bitmap, int *scroll, int width, int height, char *buf)
2423 {
2424 struct DisplayText dt[256];
2425 int curr_dt = 0;
2426 const char *uparrow = ui_getstring (UI_uparrow);
2427 const char *downarrow = ui_getstring (UI_downarrow);
2428 char textcopy[2048];
2429 char *copy;
2430 int leftoffs,topoffs;
2431 int first = *scroll;
2432 int buflines,showlines;
2433 int i;
2434
2435
2436 /* draw box */
2437 leftoffs = (Machine->uiwidth - Machine->uifontwidth * (width + 1)) / 2;
2438 if (leftoffs < 0) leftoffs = 0;
2439 topoffs = (Machine->uiheight - (3 * height + 1) * Machine->uifontheight / 2) / 2;
2440 ui_drawbox(bitmap,leftoffs,topoffs,(width + 1) * Machine->uifontwidth,(3 * height + 1) * Machine->uifontheight / 2);
2441
2442 buflines = count_lines_in_buffer (buf);
2443 if (first > 0)
2444 {
2445 if (buflines <= height)
2446 first = 0;
2447 else
2448 {
2449 height--;
2450 if (first > (buflines - height))
2451 first = buflines - height;
2452 }
2453 *scroll = first;
2454 }
2455
2456 if (first != 0)
2457 {
2458 /* indicate that scrolling upward is possible */
2459 dt[curr_dt].text = uparrow;
2460 dt[curr_dt].color = UI_COLOR_NORMAL;
2461 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(uparrow)) / 2;
2462 dt[curr_dt].y = topoffs + (3*curr_dt+1)*Machine->uifontheight/2;
2463 curr_dt++;
2464 }
2465
2466 if ((buflines - first) > height)
2467 showlines = height - 1;
2468 else
2469 showlines = height;
2470
2471 /* skip to first line */
2472 while (first > 0)
2473 {
2474 char c;
2475
2476 while ( (c = *buf++) )
2477 {
2478 if (c == '\n')
2479 {
2480 first--;
2481 break;
2482 }
2483 }
2484 }
2485
2486 /* copy 'showlines' lines from buffer, starting with line 'first' */
2487 copy = textcopy;
2488 for (i = 0; i < showlines; i++)
2489 {
2490 char *copystart = copy;
2491
2492 while (*buf && *buf != '\n')
2493 {
2494 *copy = *buf;
2495 copy++;
2496 buf++;
2497 }
2498 *copy = '\0';
2499 copy++;
2500 if (*buf == '\n')
2501 buf++;
2502
2503 if (*copystart == '\t') /* center text */
2504 {
2505 copystart++;
2506 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * (copy - copystart)) / 2;
2507 }
2508 else
2509 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2;
2510
2511 dt[curr_dt].text = copystart;
2512 dt[curr_dt].color = UI_COLOR_NORMAL;
2513 dt[curr_dt].y = topoffs + (3*curr_dt+1)*Machine->uifontheight/2;
2514 curr_dt++;
2515 }
2516
2517 if (showlines == (height - 1))
2518 {
2519 /* indicate that scrolling downward is possible */
2520 dt[curr_dt].text = downarrow;
2521 dt[curr_dt].color = UI_COLOR_NORMAL;
2522 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(downarrow)) / 2;
2523 dt[curr_dt].y = topoffs + (3*curr_dt+1)*Machine->uifontheight/2;
2524 curr_dt++;
2525 }
2526
2527 dt[curr_dt].text = 0; /* terminate array */
2528
2529 displaytext(bitmap,dt,0,0);
2530 }
2531
2532
2533 /* Display text entry for current driver from history.dat and mameinfo.dat. */
displayhistory(struct osd_bitmap * bitmap,int selected)2534 static int displayhistory (struct osd_bitmap *bitmap, int selected)
2535 {
2536 static int scroll = 0;
2537 static char *buf = 0;
2538 int maxcols,maxrows;
2539 int sel;
2540
2541
2542 sel = selected - 1;
2543
2544
2545 maxcols = (Machine->uiwidth / Machine->uifontwidth) - 1;
2546 maxrows = (2 * Machine->uiheight - Machine->uifontheight) / (3 * Machine->uifontheight);
2547 maxcols -= 2;
2548 maxrows -= 8;
2549
2550 if (!buf)
2551 {
2552 /* allocate a buffer for the text */
2553 buf = (char*) malloc(8192);
2554 if (buf)
2555 {
2556 /* try to load entry */
2557 if (load_driver_history (Machine->gamedrv, buf, 8192) == 0)
2558 {
2559 scroll = 0;
2560 wordwrap_text_buffer (buf, maxcols);
2561 strcat(buf,"\n\t");
2562 strcat(buf,ui_getstring (UI_lefthilight));
2563 strcat(buf," ");
2564 strcat(buf,ui_getstring (UI_returntomain));
2565 strcat(buf," ");
2566 strcat(buf,ui_getstring (UI_righthilight));
2567 strcat(buf,"\n");
2568 }
2569 else
2570 {
2571 free(buf);
2572 buf = 0;
2573 }
2574 }
2575 }
2576
2577 {
2578 if (buf)
2579 display_scroll_message (bitmap, &scroll, maxcols, maxrows, buf);
2580 else
2581 {
2582 char msg[80];
2583
2584 strcpy(msg,"\t");
2585 strcat(msg,ui_getstring(UI_historymissing));
2586 strcat(msg,"\n\n\t");
2587 strcat(msg,ui_getstring (UI_lefthilight));
2588 strcat(msg," ");
2589 strcat(msg,ui_getstring (UI_returntomain));
2590 strcat(msg," ");
2591 strcat(msg,ui_getstring (UI_righthilight));
2592 ui_displaymessagewindow(bitmap,msg);
2593 }
2594
2595 if ((scroll > 0) && input_ui_pressed_repeat(IPT_UI_UP,4))
2596 {
2597 if (scroll == 2) scroll = 0; /* 1 would be the same as 0, but with arrow on top */
2598 else scroll--;
2599 }
2600
2601 if (input_ui_pressed_repeat(IPT_UI_DOWN,4))
2602 {
2603 if (scroll == 0) scroll = 2; /* 1 would be the same as 0, but with arrow on top */
2604 else scroll++;
2605 }
2606
2607 if (input_ui_pressed(IPT_UI_SELECT))
2608 sel = -1;
2609
2610 if (input_ui_pressed(IPT_UI_CANCEL))
2611 sel = -1;
2612
2613 if (input_ui_pressed(IPT_UI_CONFIGURE))
2614 sel = -2;
2615 }
2616
2617 if (sel == -1 || sel == -2)
2618 {
2619 /* tell updatescreen() to clean after us */
2620 need_to_clear_bitmap = 1;
2621
2622 /* force buffer to be recreated */
2623 if (buf)
2624 {
2625 free(buf);
2626 buf = 0;
2627 }
2628 }
2629
2630 return sel + 1;
2631
2632 }
2633
2634
2635 #ifndef MESS
2636 #ifdef NEOMAME
memcard_menu(struct osd_bitmap * bitmap,int selection)2637 int memcard_menu(struct osd_bitmap *bitmap, int selection)
2638 {
2639 int sel;
2640 int menutotal = 0;
2641 const char *menuitem[10];
2642 char buf[256];
2643 char buf2[256];
2644
2645 sel = selection - 1 ;
2646
2647 sprintf(buf, "%s %03d", ui_getstring (UI_loadcard), mcd_number);
2648 menuitem[menutotal++] = buf;
2649 menuitem[menutotal++] = ui_getstring (UI_ejectcard);
2650 menuitem[menutotal++] = ui_getstring (UI_createcard);
2651 menuitem[menutotal++] = ui_getstring (UI_resetcard);
2652 menuitem[menutotal++] = ui_getstring (UI_returntomain);
2653 menuitem[menutotal] = 0;
2654
2655 if (mcd_action!=0)
2656 {
2657 strcpy (buf2, "\n");
2658
2659 switch(mcd_action)
2660 {
2661 case 1:
2662 strcat (buf2, ui_getstring (UI_loadfailed));
2663 break;
2664 case 2:
2665 strcat (buf2, ui_getstring (UI_loadok));
2666 break;
2667 case 3:
2668 strcat (buf2, ui_getstring (UI_cardejected));
2669 break;
2670 case 4:
2671 strcat (buf2, ui_getstring (UI_cardcreated));
2672 break;
2673 case 5:
2674 strcat (buf2, ui_getstring (UI_cardcreatedfailed));
2675 strcat (buf2, "\n");
2676 strcat (buf2, ui_getstring (UI_cardcreatedfailed2));
2677 break;
2678 default:
2679 strcat (buf2, ui_getstring (UI_carderror));
2680 break;
2681 }
2682
2683 strcat (buf2, "\n\n");
2684 ui_displaymessagewindow(bitmap,buf2);
2685 if (input_ui_pressed(IPT_UI_SELECT))
2686 mcd_action = 0;
2687 }
2688 else
2689 {
2690 ui_displaymenu(bitmap,menuitem,0,0,sel,0);
2691
2692 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
2693 mcd_number = (mcd_number + 1) % 1000;
2694
2695 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
2696 mcd_number = (mcd_number + 999) % 1000;
2697
2698 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
2699 sel = (sel + 1) % menutotal;
2700
2701 if (input_ui_pressed_repeat(IPT_UI_UP,8))
2702 sel = (sel + menutotal - 1) % menutotal;
2703
2704 if (input_ui_pressed(IPT_UI_SELECT))
2705 {
2706 switch(sel)
2707 {
2708 case 0:
2709 neogeo_memcard_eject();
2710 if (neogeo_memcard_load(mcd_number))
2711 {
2712 memcard_status=1;
2713 memcard_number=mcd_number;
2714 mcd_action = 2;
2715 }
2716 else
2717 mcd_action = 1;
2718 break;
2719 case 1:
2720 neogeo_memcard_eject();
2721 mcd_action = 3;
2722 break;
2723 case 2:
2724 if (neogeo_memcard_create(mcd_number))
2725 mcd_action = 4;
2726 else
2727 mcd_action = 5;
2728 break;
2729 case 3:
2730 memcard_manager=1;
2731 sel=-2;
2732 machine_reset();
2733 break;
2734 case 4:
2735 sel=-1;
2736 break;
2737 }
2738 }
2739
2740 if (input_ui_pressed(IPT_UI_CANCEL))
2741 sel = -1;
2742
2743 if (input_ui_pressed(IPT_UI_CONFIGURE))
2744 sel = -2;
2745
2746 if (sel == -1 || sel == -2)
2747 {
2748 /* tell updatescreen() to clean after us */
2749 need_to_clear_bitmap = 1;
2750 }
2751 }
2752
2753 return sel + 1;
2754 }
2755 #endif
2756 #endif
2757
2758
2759 #ifndef MESS
2760 enum { UI_SWITCH = 0,UI_DEFCODE,UI_CODE,UI_ANALOG,UI_CALIBRATE,
2761 UI_STATS,UI_GAMEINFO, UI_HISTORY,
2762 #ifdef ENABLE_AUTOFIRE
2763 UI_CHEAT,UI_AUTOFIRE,UI_RESET,UI_MEMCARD,UI_EXIT };
2764 #else
2765 UI_CHEAT,UI_RESET,UI_MEMCARD,UI_EXIT };
2766 #endif
2767 #else
2768 enum { UI_SWITCH = 0,UI_DEFCODE,UI_CODE,UI_ANALOG,UI_CALIBRATE,
2769 UI_GAMEINFO, UI_IMAGEINFO,UI_FILEMANAGER,UI_TAPECONTROL,
2770 UI_HISTORY,UI_CHEAT,UI_RESET,UI_MEMCARD,UI_EXIT };
2771 #endif
2772
2773
2774 #define MAX_SETUPMENU_ITEMS 20
2775 static const char *menu_item[MAX_SETUPMENU_ITEMS];
2776 static int menu_action[MAX_SETUPMENU_ITEMS];
2777 static int menu_total;
2778
2779
setup_menu_init(void)2780 static void setup_menu_init(void)
2781 {
2782 menu_total = 0;
2783
2784 menu_item[menu_total] = ui_getstring (UI_inputgeneral); menu_action[menu_total++] = UI_DEFCODE;
2785 menu_item[menu_total] = ui_getstring (UI_inputspecific); menu_action[menu_total++] = UI_CODE;
2786 menu_item[menu_total] = ui_getstring (UI_dipswitches); menu_action[menu_total++] = UI_SWITCH;
2787
2788 /* Determine if there are any analog controls */
2789 {
2790 struct InputPort *in;
2791 int num;
2792
2793 in = Machine->input_ports;
2794
2795 num = 0;
2796 while (in->type != IPT_END)
2797 {
2798 if (((in->type & 0xff) > IPT_ANALOG_START) && ((in->type & 0xff) < IPT_ANALOG_END)
2799 && !(!options.cheat && (in->type & IPF_CHEAT)))
2800 num++;
2801 in++;
2802 }
2803
2804 if (num != 0)
2805 {
2806 menu_item[menu_total] = ui_getstring (UI_analogcontrols); menu_action[menu_total++] = UI_ANALOG;
2807 }
2808 }
2809
2810 /* Joystick calibration possible? */
2811 if ((osd_joystick_needs_calibration()) != 0)
2812 {
2813 menu_item[menu_total] = ui_getstring (UI_calibrate); menu_action[menu_total++] = UI_CALIBRATE;
2814 }
2815
2816 #ifndef MESS
2817 menu_item[menu_total] = ui_getstring (UI_bookkeeping); menu_action[menu_total++] = UI_STATS;
2818 menu_item[menu_total] = ui_getstring (UI_gameinfo); menu_action[menu_total++] = UI_GAMEINFO;
2819 menu_item[menu_total] = ui_getstring (UI_history); menu_action[menu_total++] = UI_HISTORY;
2820 #else
2821 menu_item[menu_total] = ui_getstring (UI_imageinfo); menu_action[menu_total++] = UI_IMAGEINFO;
2822 menu_item[menu_total] = ui_getstring (UI_filemanager); menu_action[menu_total++] = UI_FILEMANAGER;
2823 menu_item[menu_total] = ui_getstring (UI_tapecontrol); menu_action[menu_total++] = UI_TAPECONTROL;
2824 menu_item[menu_total] = ui_getstring (UI_history); menu_action[menu_total++] = UI_HISTORY;
2825 #endif
2826
2827 if (options.cheat)
2828 {
2829 menu_item[menu_total] = ui_getstring (UI_cheat); menu_action[menu_total++] = UI_CHEAT;
2830 }
2831
2832 #ifndef MESS
2833 #ifdef NEOMAME
2834 if (Machine->gamedrv->clone_of == &driver_neogeo ||
2835 (Machine->gamedrv->clone_of &&
2836 Machine->gamedrv->clone_of->clone_of == &driver_neogeo))
2837 {
2838 menu_item[menu_total] = ui_getstring (UI_memorycard); menu_action[menu_total++] = UI_MEMCARD;
2839 }
2840 #endif
2841 #endif
2842
2843 #ifdef ENABLE_AUTOFIRE
2844 menu_item[menu_total] = "Auto-Fire"; menu_action[menu_total++] = UI_AUTOFIRE;
2845 #endif
2846 menu_item[menu_total] = ui_getstring (UI_resetgame); menu_action[menu_total++] = UI_RESET;
2847 menu_item[menu_total] = ui_getstring (UI_returntogame); menu_action[menu_total++] = UI_EXIT;
2848 menu_item[menu_total] = 0; /* terminate array */
2849 }
2850
2851
setup_menu(struct osd_bitmap * bitmap,int selected)2852 static int setup_menu(struct osd_bitmap *bitmap, int selected)
2853 {
2854 int sel,res=-1;
2855 static int menu_lastselected = 0;
2856
2857
2858 if (selected == -1)
2859 sel = menu_lastselected;
2860 else sel = selected - 1;
2861
2862 if (sel > SEL_MASK)
2863 {
2864 switch (menu_action[sel & SEL_MASK])
2865 {
2866 #ifdef ENABLE_AUTOFIRE
2867 case UI_AUTOFIRE:
2868 res = autofire_menu(bitmap, sel >> SEL_BITS);
2869 break;
2870 #endif
2871 case UI_SWITCH:
2872 res = setdipswitches(bitmap, sel >> SEL_BITS);
2873 break;
2874 case UI_DEFCODE:
2875 res = setdefcodesettings(bitmap, sel >> SEL_BITS);
2876 break;
2877 case UI_CODE:
2878 res = setcodesettings(bitmap, sel >> SEL_BITS);
2879 break;
2880 case UI_ANALOG:
2881 res = settraksettings(bitmap, sel >> SEL_BITS);
2882 break;
2883 case UI_CALIBRATE:
2884 res = calibratejoysticks(bitmap, sel >> SEL_BITS);
2885 break;
2886 #ifndef MESS
2887 case UI_STATS:
2888 res = mame_stats(bitmap, sel >> SEL_BITS);
2889 break;
2890 case UI_GAMEINFO:
2891 res = displaygameinfo(bitmap, sel >> SEL_BITS);
2892 break;
2893 #endif
2894 #ifdef MESS
2895 case UI_IMAGEINFO:
2896 res = displayimageinfo(bitmap, sel >> SEL_BITS);
2897 break;
2898 case UI_FILEMANAGER:
2899 res = filemanager(bitmap, sel >> SEL_BITS);
2900 break;
2901 case UI_TAPECONTROL:
2902 res = tapecontrol(bitmap, sel >> SEL_BITS);
2903 break;
2904 #endif
2905 case UI_HISTORY:
2906 res = displayhistory(bitmap, sel >> SEL_BITS);
2907 break;
2908 case UI_CHEAT:
2909 res = cheat_menu(bitmap, sel >> SEL_BITS);
2910 break;
2911 #ifndef MESS
2912 #ifdef NEOMAME
2913 case UI_MEMCARD:
2914 res = memcard_menu(bitmap, sel >> SEL_BITS);
2915 break;
2916 #endif
2917 #endif
2918 }
2919
2920 if (res == -1)
2921 {
2922 menu_lastselected = sel;
2923 sel = -1;
2924 }
2925 else
2926 sel = (sel & SEL_MASK) | (res << SEL_BITS);
2927
2928 return sel + 1;
2929 }
2930
2931
2932 ui_displaymenu(bitmap,menu_item,0,0,sel,0);
2933
2934 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
2935 sel = (sel + 1) % menu_total;
2936
2937 if (input_ui_pressed_repeat(IPT_UI_UP,8))
2938 sel = (sel + menu_total - 1) % menu_total;
2939
2940 if (input_ui_pressed(IPT_UI_SELECT))
2941 {
2942 switch (menu_action[sel])
2943 {
2944 #ifdef ENABLE_AUTOFIRE
2945 case UI_AUTOFIRE:
2946 #endif
2947 case UI_SWITCH:
2948 case UI_DEFCODE:
2949 case UI_CODE:
2950 case UI_ANALOG:
2951 case UI_CALIBRATE:
2952 #ifndef MESS
2953 case UI_STATS:
2954 case UI_GAMEINFO:
2955 #else
2956 case UI_GAMEINFO:
2957 case UI_IMAGEINFO:
2958 case UI_FILEMANAGER:
2959 case UI_TAPECONTROL:
2960 #endif
2961 case UI_HISTORY:
2962 case UI_CHEAT:
2963 case UI_MEMCARD:
2964 sel |= 1 << SEL_BITS;
2965 /* tell updatescreen() to clean after us */
2966 need_to_clear_bitmap = 1;
2967 break;
2968
2969 case UI_RESET:
2970 machine_reset();
2971 break;
2972
2973 case UI_EXIT:
2974 menu_lastselected = 0;
2975 sel = -1;
2976 break;
2977 }
2978 }
2979
2980 if (input_ui_pressed(IPT_UI_CANCEL) ||
2981 input_ui_pressed(IPT_UI_CONFIGURE))
2982 {
2983 menu_lastselected = sel;
2984 sel = -1;
2985 }
2986
2987 if (sel == -1)
2988 {
2989 /* tell updatescreen() to clean after us */
2990 need_to_clear_bitmap = 1;
2991 }
2992
2993 return sel + 1;
2994 }
2995
2996
2997
2998 /*********************************************************************
2999
3000 start of On Screen Display handling
3001
3002 *********************************************************************/
3003
displayosd(struct osd_bitmap * bitmap,const char * text,int percentage,int default_percentage)3004 static void displayosd(struct osd_bitmap *bitmap,const char *text,int percentage,int default_percentage)
3005 {
3006 struct DisplayText dt[2];
3007 int avail;
3008
3009
3010 avail = (Machine->uiwidth / Machine->uifontwidth) * 19 / 20;
3011
3012 ui_drawbox(bitmap,(Machine->uiwidth - Machine->uifontwidth * avail) / 2,
3013 (Machine->uiheight - 7*Machine->uifontheight/2),
3014 avail * Machine->uifontwidth,
3015 3*Machine->uifontheight);
3016
3017 avail--;
3018
3019 drawbar(bitmap,(Machine->uiwidth - Machine->uifontwidth * avail) / 2,
3020 (Machine->uiheight - 3*Machine->uifontheight),
3021 avail * Machine->uifontwidth,
3022 Machine->uifontheight,
3023 percentage,default_percentage);
3024
3025 dt[0].text = text;
3026 dt[0].color = UI_COLOR_NORMAL;
3027 dt[0].x = (Machine->uiwidth - Machine->uifontwidth * strlen(text)) / 2;
3028 dt[0].y = (Machine->uiheight - 2*Machine->uifontheight) + 2;
3029 dt[1].text = 0; /* terminate array */
3030 displaytext(bitmap,dt,0,0);
3031 }
3032
3033
3034
onscrd_volume(struct osd_bitmap * bitmap,int increment,int arg)3035 static void onscrd_volume(struct osd_bitmap *bitmap,int increment,int arg)
3036 {
3037 char buf[20];
3038 int attenuation;
3039
3040 if (increment)
3041 {
3042 attenuation = osd_get_mastervolume();
3043 attenuation += increment;
3044 if (attenuation > 0) attenuation = 0;
3045 if (attenuation < -32) attenuation = -32;
3046 osd_set_mastervolume(attenuation);
3047 }
3048 attenuation = osd_get_mastervolume();
3049
3050 sprintf(buf,"%s %3ddB", ui_getstring (UI_volume), attenuation);
3051 displayosd(bitmap,buf,100 * (attenuation + 32) / 32,100);
3052 }
3053
onscrd_mixervol(struct osd_bitmap * bitmap,int increment,int arg)3054 static void onscrd_mixervol(struct osd_bitmap *bitmap,int increment,int arg)
3055 {
3056 static void *driver = 0;
3057 char buf[40];
3058 int volume,ch;
3059 int doallchannels = 0;
3060 int proportional = 0;
3061
3062
3063 if (code_pressed(KEYCODE_LSHIFT) || code_pressed(KEYCODE_RSHIFT))
3064 doallchannels = 1;
3065 if (!code_pressed(KEYCODE_LCONTROL) && !code_pressed(KEYCODE_RCONTROL))
3066 increment *= 5;
3067 if (code_pressed(KEYCODE_LALT) || code_pressed(KEYCODE_RALT))
3068 proportional = 1;
3069
3070 if (increment)
3071 {
3072 if (proportional)
3073 {
3074 static int old_vol[MIXER_MAX_CHANNELS];
3075 float ratio = 1.0;
3076 int overflow = 0;
3077
3078 if (driver != Machine->drv)
3079 {
3080 driver = (void *)Machine->drv;
3081 for (ch = 0; ch < MIXER_MAX_CHANNELS; ch++)
3082 old_vol[ch] = mixer_get_mixing_level(ch);
3083 }
3084
3085 volume = mixer_get_mixing_level(arg);
3086 if (old_vol[arg])
3087 ratio = (float)(volume + increment) / (float)old_vol[arg];
3088
3089 for (ch = 0; ch < MIXER_MAX_CHANNELS; ch++)
3090 {
3091 if (mixer_get_name(ch) != 0)
3092 {
3093 volume = ratio * old_vol[ch];
3094 if (volume < 0 || volume > 100)
3095 overflow = 1;
3096 }
3097 }
3098
3099 if (!overflow)
3100 {
3101 for (ch = 0; ch < MIXER_MAX_CHANNELS; ch++)
3102 {
3103 volume = ratio * old_vol[ch];
3104 mixer_set_mixing_level(ch,volume);
3105 }
3106 }
3107 }
3108 else
3109 {
3110 driver = 0; /* force reset of saved volumes */
3111
3112 volume = mixer_get_mixing_level(arg);
3113 volume += increment;
3114 if (volume > 100) volume = 100;
3115 if (volume < 0) volume = 0;
3116
3117 if (doallchannels)
3118 {
3119 for (ch = 0;ch < MIXER_MAX_CHANNELS;ch++)
3120 mixer_set_mixing_level(ch,volume);
3121 }
3122 else
3123 mixer_set_mixing_level(arg,volume);
3124 }
3125 }
3126 volume = mixer_get_mixing_level(arg);
3127
3128 if (proportional)
3129 sprintf(buf,"%s %s %3d%%", ui_getstring (UI_allchannels), ui_getstring (UI_relative), volume);
3130 else if (doallchannels)
3131 sprintf(buf,"%s %s %3d%%", ui_getstring (UI_allchannels), ui_getstring (UI_volume), volume);
3132 else
3133 sprintf(buf,"%s %s %3d%%",mixer_get_name(arg), ui_getstring (UI_volume), volume);
3134 displayosd(bitmap,buf,volume,mixer_get_default_mixing_level(arg));
3135 }
3136
onscrd_brightness(struct osd_bitmap * bitmap,int increment,int arg)3137 static void onscrd_brightness(struct osd_bitmap *bitmap,int increment,int arg)
3138 {
3139 char buf[20];
3140 int brightness;
3141
3142
3143 if (increment)
3144 {
3145 brightness = osd_get_brightness();
3146 brightness += 5 * increment;
3147 if (brightness < 0) brightness = 0;
3148 if (brightness > 100) brightness = 100;
3149 osd_set_brightness(brightness);
3150 }
3151 brightness = osd_get_brightness();
3152
3153 sprintf(buf,"%s %3d%%", ui_getstring (UI_brightness), brightness);
3154 displayosd(bitmap,buf,brightness,100);
3155 }
3156
onscrd_gamma(struct osd_bitmap * bitmap,int increment,int arg)3157 static void onscrd_gamma(struct osd_bitmap *bitmap,int increment,int arg)
3158 {
3159 char buf[20];
3160 float gamma_correction;
3161
3162 if (increment)
3163 {
3164 gamma_correction = osd_get_gamma();
3165
3166 gamma_correction += 0.05 * increment;
3167 if (gamma_correction < 0.5) gamma_correction = 0.5;
3168 if (gamma_correction > 2.0) gamma_correction = 2.0;
3169
3170 osd_set_gamma(gamma_correction);
3171 }
3172 gamma_correction = osd_get_gamma();
3173
3174 sprintf(buf,"%s %1.2f", ui_getstring (UI_gamma), gamma_correction);
3175 displayosd(bitmap,buf,100*(gamma_correction-0.5)/(2.0-0.5),100*(1.0-0.5)/(2.0-0.5));
3176 }
3177
onscrd_vector_intensity(struct osd_bitmap * bitmap,int increment,int arg)3178 static void onscrd_vector_intensity(struct osd_bitmap *bitmap,int increment,int arg)
3179 {
3180 char buf[30];
3181 float intensity_correction;
3182
3183 if (increment)
3184 {
3185 intensity_correction = vector_get_intensity();
3186
3187 intensity_correction += 0.05 * increment;
3188 if (intensity_correction < 0.5) intensity_correction = 0.5;
3189 if (intensity_correction > 3.0) intensity_correction = 3.0;
3190
3191 vector_set_intensity(intensity_correction);
3192 }
3193 intensity_correction = vector_get_intensity();
3194
3195 sprintf(buf,"%s %1.2f", ui_getstring (UI_vectorintensity), intensity_correction);
3196 displayosd(bitmap,buf,100*(intensity_correction-0.5)/(3.0-0.5),100*(1.5-0.5)/(3.0-0.5));
3197 }
3198
3199
onscrd_overclock(struct osd_bitmap * bitmap,int increment,int arg)3200 static void onscrd_overclock(struct osd_bitmap *bitmap,int increment,int arg)
3201 {
3202 char buf[30];
3203 float overclock;
3204 int cpu, doallcpus = 0, oc;
3205
3206 if (code_pressed(KEYCODE_LSHIFT) || code_pressed(KEYCODE_RSHIFT))
3207 doallcpus = 1;
3208 if (!code_pressed(KEYCODE_LCONTROL) && !code_pressed(KEYCODE_RCONTROL))
3209 increment *= 5;
3210 if( increment )
3211 {
3212 overclock = timer_get_overclock(arg);
3213 overclock += 0.01 * increment;
3214 if (overclock < 0.01) overclock = 0.01;
3215 if (overclock > 2.0) overclock = 2.0;
3216 if( doallcpus )
3217 for( cpu = 0; cpu < cpu_gettotalcpu(); cpu++ )
3218 timer_set_overclock(cpu, overclock);
3219 else
3220 timer_set_overclock(arg, overclock);
3221 }
3222
3223 oc = 100 * timer_get_overclock(arg) + 0.5;
3224
3225 if( doallcpus )
3226 sprintf(buf,"%s %s %3d%%", ui_getstring (UI_allcpus), ui_getstring (UI_overclock), oc);
3227 else
3228 sprintf(buf,"%s %s%d %3d%%", ui_getstring (UI_overclock), ui_getstring (UI_cpu), arg, oc);
3229 displayosd(bitmap,buf,oc/2,100/2);
3230 }
3231
3232 #define MAX_OSD_ITEMS 30
3233 static void (*onscrd_fnc[MAX_OSD_ITEMS])(struct osd_bitmap *bitmap,int increment,int arg);
3234 static int onscrd_arg[MAX_OSD_ITEMS];
3235 static int onscrd_total_items;
3236
onscrd_init(void)3237 static void onscrd_init(void)
3238 {
3239 int item,ch;
3240
3241
3242 item = 0;
3243
3244 onscrd_fnc[item] = onscrd_volume;
3245 onscrd_arg[item] = 0;
3246 item++;
3247
3248 for (ch = 0;ch < MIXER_MAX_CHANNELS;ch++)
3249 {
3250 if (mixer_get_name(ch) != 0)
3251 {
3252 onscrd_fnc[item] = onscrd_mixervol;
3253 onscrd_arg[item] = ch;
3254 item++;
3255 }
3256 }
3257
3258 if (options.cheat)
3259 {
3260 for (ch = 0;ch < cpu_gettotalcpu();ch++)
3261 {
3262 onscrd_fnc[item] = onscrd_overclock;
3263 onscrd_arg[item] = ch;
3264 item++;
3265 }
3266 }
3267
3268 onscrd_fnc[item] = onscrd_brightness;
3269 onscrd_arg[item] = 0;
3270 item++;
3271
3272 onscrd_fnc[item] = onscrd_gamma;
3273 onscrd_arg[item] = 0;
3274 item++;
3275
3276 if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR)
3277 {
3278 onscrd_fnc[item] = onscrd_vector_intensity;
3279 onscrd_arg[item] = 0;
3280 item++;
3281 }
3282
3283 onscrd_total_items = item;
3284 }
3285
on_screen_display(struct osd_bitmap * bitmap,int selected)3286 static int on_screen_display(struct osd_bitmap *bitmap, int selected)
3287 {
3288 int increment,sel;
3289 static int lastselected = 0;
3290
3291
3292 if (selected == -1)
3293 sel = lastselected;
3294 else sel = selected - 1;
3295
3296 increment = 0;
3297 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
3298 increment = -1;
3299 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
3300 increment = 1;
3301 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
3302 sel = (sel + 1) % onscrd_total_items;
3303 if (input_ui_pressed_repeat(IPT_UI_UP,8))
3304 sel = (sel + onscrd_total_items - 1) % onscrd_total_items;
3305
3306 (*onscrd_fnc[sel])(bitmap,increment,onscrd_arg[sel]);
3307
3308 lastselected = sel;
3309
3310 if (input_ui_pressed(IPT_UI_ON_SCREEN_DISPLAY))
3311 {
3312 sel = -1;
3313
3314 /* tell updatescreen() to clean after us */
3315 need_to_clear_bitmap = 1;
3316 }
3317
3318 return sel + 1;
3319 }
3320
3321 /*********************************************************************
3322
3323 end of On Screen Display handling
3324
3325 *********************************************************************/
3326
3327
displaymessage(struct osd_bitmap * bitmap,const char * text)3328 static void displaymessage(struct osd_bitmap *bitmap,const char *text)
3329 {
3330 struct DisplayText dt[2];
3331 int avail;
3332
3333
3334 if (Machine->uiwidth < Machine->uifontwidth * strlen(text))
3335 {
3336 ui_displaymessagewindow(bitmap,text);
3337 return;
3338 }
3339
3340 avail = strlen(text)+2;
3341
3342 ui_drawbox(bitmap,(Machine->uiwidth - Machine->uifontwidth * avail) / 2,
3343 Machine->uiheight - 3*Machine->uifontheight,
3344 avail * Machine->uifontwidth,
3345 2*Machine->uifontheight);
3346
3347 dt[0].text = text;
3348 dt[0].color = UI_COLOR_NORMAL;
3349 dt[0].x = (Machine->uiwidth - Machine->uifontwidth * strlen(text)) / 2;
3350 dt[0].y = Machine->uiheight - 5*Machine->uifontheight/2;
3351 dt[1].text = 0; /* terminate array */
3352 displaytext(bitmap,dt,0,0);
3353 }
3354
3355
3356 static char messagetext[80];
3357 static int messagecounter;
3358
usrintf_showmessage(const char * text,...)3359 void CLIB_DECL usrintf_showmessage(const char *text,...)
3360 {
3361 va_list arg;
3362 va_start(arg,text);
3363 vsprintf(messagetext,text,arg);
3364 va_end(arg);
3365 messagecounter = 2 * Machine->drv->frames_per_second;
3366 }
3367
usrintf_showmessage_secs(int seconds,const char * text,...)3368 void CLIB_DECL usrintf_showmessage_secs(int seconds, const char *text,...)
3369 {
3370 va_list arg;
3371 va_start(arg,text);
3372 vsprintf(messagetext,text,arg);
3373 va_end(arg);
3374 messagecounter = seconds * Machine->drv->frames_per_second;
3375 }
3376
3377
3378
handle_user_interface(struct osd_bitmap * bitmap)3379 int handle_user_interface(struct osd_bitmap *bitmap)
3380 {
3381 static int show_profiler;
3382
3383 #ifdef MESS
3384 if (Machine->gamedrv->flags & GAME_COMPUTER)
3385 {
3386 static int ui_active = 0, ui_toggle_key = 0;
3387 static int ui_display_count = 4 * 60;
3388
3389 if( input_ui_pressed(IPT_UI_TOGGLE_UI) )
3390 {
3391 if( !ui_toggle_key )
3392 {
3393 ui_toggle_key = 1;
3394 ui_active = !ui_active;
3395 ui_display_count = 4 * 60;
3396 bitmap_dirty = 1;
3397 }
3398 }
3399 else
3400 {
3401 ui_toggle_key = 0;
3402 }
3403
3404 if( ui_active )
3405 {
3406 if( ui_display_count > 0 )
3407 {
3408 char text[] = "KBD: UI (ScrLock)";
3409 int x, x0 = Machine->uiwidth - sizeof(text) * Machine->uifont->width - 2;
3410 int y0 = Machine->uiymin + Machine->uiheight - Machine->uifont->height - 2;
3411 for( x = 0; text[x]; x++ )
3412 {
3413 drawgfx(bitmap,
3414 Machine->uifont,text[x],0,0,0,
3415 x0+x*Machine->uifont->width,
3416 y0,0,TRANSPARENCY_NONE,0);
3417 }
3418 if( --ui_display_count == 0 )
3419 bitmap_dirty = 1;
3420 }
3421 }
3422 else
3423 {
3424 if( ui_display_count > 0 )
3425 {
3426 char text[] = "KBD: EMU (ScrLock)";
3427 int x, x0 = Machine->uiwidth - sizeof(text) * Machine->uifont->width - 2;
3428 int y0 = Machine->uiymin + Machine->uiheight - Machine->uifont->height - 2;
3429 for( x = 0; text[x]; x++ )
3430 {
3431 drawgfx(bitmap,
3432 Machine->uifont,text[x],0,0,0,
3433 x0+x*Machine->uifont->width,
3434 y0,0,TRANSPARENCY_NONE,0);
3435 }
3436 if( --ui_display_count == 0 )
3437 bitmap_dirty = 1;
3438 }
3439 return 0;
3440 }
3441 }
3442 #endif
3443
3444 /* if the user pressed F12, save the screen to a file */
3445 if (input_ui_pressed(IPT_UI_SNAPSHOT))
3446 osd_save_snapshot(bitmap);
3447
3448 /* This call is for the cheat, it must be called once a frame */
3449 if (options.cheat) DoCheat(bitmap);
3450
3451 /* if the user pressed ESC, stop the emulation */
3452 /* but don't quit if the setup menu is on screen */
3453 if (setup_selected == 0 && input_ui_pressed(IPT_UI_CANCEL))
3454 return 1;
3455
3456 if (setup_selected == 0 && input_ui_pressed(IPT_UI_CONFIGURE))
3457 {
3458 setup_selected = -1;
3459 if (osd_selected != 0)
3460 {
3461 osd_selected = 0; /* disable on screen display */
3462 /* tell updatescreen() to clean after us */
3463 need_to_clear_bitmap = 1;
3464 }
3465 }
3466 if (setup_selected != 0) setup_selected = setup_menu(bitmap, setup_selected);
3467
3468 if (!mame_debug && osd_selected == 0 && input_ui_pressed(IPT_UI_ON_SCREEN_DISPLAY))
3469 {
3470 osd_selected = -1;
3471 if (setup_selected != 0)
3472 {
3473 setup_selected = 0; /* disable setup menu */
3474 /* tell updatescreen() to clean after us */
3475 need_to_clear_bitmap = 1;
3476 }
3477 }
3478 if (osd_selected != 0) osd_selected = on_screen_display(bitmap, osd_selected);
3479
3480
3481 #if 0
3482 if (keyboard_pressed_memory(KEYCODE_BACKSPACE))
3483 {
3484 if (jukebox_selected != -1)
3485 {
3486 jukebox_selected = -1;
3487 cpu_halt(0,1);
3488 }
3489 else
3490 {
3491 jukebox_selected = 0;
3492 cpu_halt(0,0);
3493 }
3494 }
3495
3496 if (jukebox_selected != -1)
3497 {
3498 char buf[40];
3499 watchdog_reset_w(0,0);
3500 if (keyboard_pressed_memory(KEYCODE_LCONTROL))
3501 {
3502 #include "cpu/z80/z80.h"
3503 soundlatch_w(0,jukebox_selected);
3504 cpu_cause_interrupt(1,Z80_NMI_INT);
3505 }
3506 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
3507 {
3508 jukebox_selected = (jukebox_selected + 1) & 0xff;
3509 }
3510 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
3511 {
3512 jukebox_selected = (jukebox_selected - 1) & 0xff;
3513 }
3514 if (input_ui_pressed_repeat(IPT_UI_UP,8))
3515 {
3516 jukebox_selected = (jukebox_selected + 16) & 0xff;
3517 }
3518 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
3519 {
3520 jukebox_selected = (jukebox_selected - 16) & 0xff;
3521 }
3522 sprintf(buf,"sound cmd %02x",jukebox_selected);
3523 displaymessage(buf);
3524 }
3525 #endif
3526
3527
3528 /* if the user pressed F3, reset the emulation */
3529 if (input_ui_pressed(IPT_UI_RESET_MACHINE))
3530 machine_reset();
3531
3532
3533 if (single_step || input_ui_pressed(IPT_UI_PAUSE)) /* pause the game */
3534 {
3535 /* osd_selected = 0; disable on screen display, since we are going */
3536 /* to change parameters affected by it */
3537
3538 if (single_step == 0)
3539 {
3540 osd_sound_enable(0);
3541 osd_pause(1);
3542 }
3543
3544 while (!input_ui_pressed(IPT_UI_PAUSE))
3545 {
3546 #ifdef MAME_NET
3547 osd_net_sync();
3548 #endif /* MAME_NET */
3549 profiler_mark(PROFILER_VIDEO);
3550 if (osd_skip_this_frame() == 0)
3551 {
3552 if (need_to_clear_bitmap || bitmap_dirty)
3553 {
3554 osd_clearbitmap(bitmap);
3555 need_to_clear_bitmap = 0;
3556 draw_screen(bitmap_dirty);
3557 bitmap_dirty = 0;
3558 }
3559 }
3560 profiler_mark(PROFILER_END);
3561
3562 if (input_ui_pressed(IPT_UI_SNAPSHOT))
3563 osd_save_snapshot(bitmap);
3564
3565 if (setup_selected == 0 && input_ui_pressed(IPT_UI_CANCEL))
3566 return 1;
3567
3568 if (setup_selected == 0 && input_ui_pressed(IPT_UI_CONFIGURE))
3569 {
3570 setup_selected = -1;
3571 if (osd_selected != 0)
3572 {
3573 osd_selected = 0; /* disable on screen display */
3574 /* tell updatescreen() to clean after us */
3575 need_to_clear_bitmap = 1;
3576 }
3577 }
3578 if (setup_selected != 0) setup_selected = setup_menu(bitmap, setup_selected);
3579
3580 if (!mame_debug && osd_selected == 0 && input_ui_pressed(IPT_UI_ON_SCREEN_DISPLAY))
3581 {
3582 osd_selected = -1;
3583 if (setup_selected != 0)
3584 {
3585 setup_selected = 0; /* disable setup menu */
3586 /* tell updatescreen() to clean after us */
3587 need_to_clear_bitmap = 1;
3588 }
3589 }
3590 if (osd_selected != 0) osd_selected = on_screen_display(bitmap, osd_selected);
3591
3592 /* show popup message if any */
3593 if (messagecounter > 0) displaymessage(bitmap, messagetext);
3594
3595 update_video_and_audio();
3596 osd_poll_joysticks();
3597 }
3598
3599 if (code_pressed(KEYCODE_LSHIFT) || code_pressed(KEYCODE_RSHIFT))
3600 single_step = 1;
3601 else
3602 {
3603 single_step = 0;
3604 osd_pause(0);
3605 osd_sound_enable(1);
3606 }
3607 }
3608
3609
3610 /* show popup message if any */
3611 if (messagecounter > 0)
3612 {
3613 displaymessage(bitmap, messagetext);
3614
3615 if (--messagecounter == 0)
3616 /* tell updatescreen() to clean after us */
3617 need_to_clear_bitmap = 1;
3618 }
3619
3620
3621 if (input_ui_pressed(IPT_UI_SHOW_PROFILER))
3622 {
3623 show_profiler ^= 1;
3624 if (show_profiler)
3625 profiler_start();
3626 else
3627 {
3628 profiler_stop();
3629 /* tell updatescreen() to clean after us */
3630 need_to_clear_bitmap = 1;
3631 }
3632 }
3633
3634 if (show_profiler) profiler_show(bitmap);
3635
3636
3637 /* if the user pressed F4, show the character set */
3638 if (input_ui_pressed(IPT_UI_SHOW_GFX))
3639 {
3640 osd_sound_enable(0);
3641
3642 showcharset(bitmap);
3643
3644 osd_sound_enable(1);
3645 }
3646
3647 return 0;
3648 }
3649
3650
init_user_interface(void)3651 void init_user_interface(void)
3652 {
3653 extern int snapno; /* in common.c */
3654
3655 snapno = 0; /* reset snapshot counter */
3656
3657 setup_menu_init();
3658 setup_selected = 0;
3659
3660 onscrd_init();
3661 osd_selected = 0;
3662
3663 jukebox_selected = -1;
3664
3665 single_step = 0;
3666
3667 orientation_count = 0;
3668 }
3669
onscrd_active(void)3670 int onscrd_active(void)
3671 {
3672 return osd_selected;
3673 }
3674
setup_active(void)3675 int setup_active(void)
3676 {
3677 return setup_selected;
3678 }
3679
3680