Develop and Download Open Source Software

Browse CVS Repository

Contents of /mame32jp/mame32jp/src/usrintrf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Tue May 7 00:17:30 2002 UTC (21 years, 11 months ago) by zero
Branch: MAIN
CVS Tags: ver_0_60_1, ver0_60_2, ver0_60_3, ver0_60_4, ver0_60_5, HEAD
Changes since 1.6: +18 -16 lines
File MIME type: text/x-csrc
*** empty log message ***

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 #include "state.h"
16
17 #ifdef MESS
18 #include "mess.h"
19 #endif
20
21 #ifdef MAME32JP
22 #include <windows.h>
23 #include "win32.h"
24 #include "tsv.h"
25 #include "osd_pal.h"
26 #endif
27
28 /* Variables for stat menu */
29 extern char build_version[];
30 extern unsigned int dispensed_tickets;
31 extern unsigned int coins[COIN_COUNTERS];
32 extern unsigned int coinlockedout[COIN_COUNTERS];
33
34 /* MARTINEZ.F 990207 Memory Card */
35 #ifndef MESS
36 #ifndef TINY_COMPILE
37 #ifndef CPSMAME
38 #ifndef MMSND
39 int memcard_menu(struct mame_bitmap *bitmap, int);
40 extern int mcd_action;
41 extern int mcd_number;
42 extern int memcard_status;
43 extern int memcard_number;
44 extern int memcard_manager;
45 extern struct GameDriver driver_neogeo;
46 #endif
47 #endif
48 #endif
49 #endif
50
51 extern int neogeo_memcard_load(int);
52 extern void neogeo_memcard_save(void);
53 extern void neogeo_memcard_eject(void);
54 extern int neogeo_memcard_create(int);
55 /* MARTINEZ.F 990207 Memory Card End */
56
57
58 #ifdef MAME32JP
59 static int lhw, rhw, uaw, daw, law, raw;
60 static int scroll_reset;
61
62 #define BOXADJUST (Machine->uifontheight / 2)
63 #define ROWHEIGHT (Machine->uifontheight + Machine->uifontheight / 4)
64 #define ROWADJUST (Machine->uifontheight / 8)
65
66 static int wordwrap_text_buffer(char *buffer, int maxcols);
67 static int count_lines_in_buffer (char *buffer);
68 static int display_scroll_message(struct mame_bitmap *bitmap, int *scroll, int width, int height, char *buf);
69 #endif
70
71 static int setup_selected;
72 static int osd_selected;
73 static int jukebox_selected;
74 static int single_step;
75 static int trueorientation;
76 static int orientation_count;
77 #ifdef MAME32JP
78 static int command_lastselected;
79 static char *commandlist_buf = NULL;
80 static int command_scroll = 0;
81 static int command_load = 1;
82 static int command_sc = 0;
83 static int command_sel = 1;
84 static int wave_loging = 0;
85 #endif
86
87
88 void switch_ui_orientation(struct mame_bitmap *bitmap)
89 {
90 if (orientation_count == 0)
91 {
92 trueorientation = Machine->orientation;
93 Machine->orientation = Machine->ui_orientation;
94 if (bitmap)
95 set_pixel_functions(bitmap);
96 }
97
98 orientation_count++;
99 }
100
101 void switch_true_orientation(struct mame_bitmap *bitmap)
102 {
103 orientation_count--;
104
105 if (orientation_count == 0)
106 {
107 Machine->orientation = trueorientation;
108 if (bitmap)
109 set_pixel_functions(bitmap);
110 }
111 }
112
113
114 void set_ui_visarea (int xmin, int ymin, int xmax, int ymax)
115 {
116 int temp,w,h;
117
118 /* special case for vectors */
119 if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR)
120 {
121 if (Machine->ui_orientation & ORIENTATION_SWAP_XY)
122 {
123 temp=xmin; xmin=ymin; ymin=temp;
124 temp=xmax; xmax=ymax; ymax=temp;
125 }
126 }
127 else
128 {
129 if (Machine->orientation & ORIENTATION_SWAP_XY)
130 {
131 w = Machine->drv->screen_height;
132 h = Machine->drv->screen_width;
133 }
134 else
135 {
136 w = Machine->drv->screen_width;
137 h = Machine->drv->screen_height;
138 }
139
140 if (Machine->ui_orientation & ORIENTATION_FLIP_X)
141 {
142 temp = w - xmin - 1;
143 xmin = w - xmax - 1;
144 xmax = temp ;
145 }
146
147 if (Machine->ui_orientation & ORIENTATION_FLIP_Y)
148 {
149 temp = h - ymin - 1;
150 ymin = h - ymax - 1;
151 ymax = temp;
152 }
153
154 if (Machine->ui_orientation & ORIENTATION_SWAP_XY)
155 {
156 temp = xmin; xmin = ymin; ymin = temp;
157 temp = xmax; xmax = ymax; ymax = temp;
158 }
159
160 }
161 Machine->uiwidth = xmax-xmin+1;
162 Machine->uiheight = ymax-ymin+1;
163 Machine->uixmin = xmin;
164 Machine->uiymin = ymin;
165 }
166
167
168
169 #ifndef JAPANESE
170 struct GfxElement *builduifont(void)
171 {
172 static unsigned char fontdata6x8[] =
173 {
174 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
175 0x7c,0x80,0x98,0x90,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x44,0x04,0xf4,0x04,0xf8,
176 0x7c,0x80,0x98,0x88,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x24,0x04,0xf4,0x04,0xf8,
177 0x7c,0x80,0x88,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x24,0x64,0x04,0xf4,0x04,0xf8,
178 0x7c,0x80,0x90,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x44,0x64,0x04,0xf4,0x04,0xf8,
179 0x30,0x48,0x84,0xb4,0xb4,0x84,0x48,0x30,0x30,0x48,0x84,0x84,0x84,0x84,0x48,0x30,
180 0x00,0xfc,0x84,0x8c,0xd4,0xa4,0xfc,0x00,0x00,0xfc,0x84,0x84,0x84,0x84,0xfc,0x00,
181 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
182 0x80,0xc0,0xe0,0xf0,0xe0,0xc0,0x80,0x00,0x04,0x0c,0x1c,0x3c,0x1c,0x0c,0x04,0x00,
183 0x20,0x70,0xf8,0x20,0x20,0xf8,0x70,0x20,0x48,0x48,0x48,0x48,0x48,0x00,0x48,0x00,
184 0x00,0x00,0x30,0x68,0x78,0x30,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
185 0x70,0xd8,0xe8,0xe8,0xf8,0xf8,0x70,0x00,0x1c,0x7c,0x74,0x44,0x44,0x4c,0xcc,0xc0,
186 0x20,0x70,0xf8,0x70,0x70,0x70,0x70,0x00,0x70,0x70,0x70,0x70,0xf8,0x70,0x20,0x00,
187 0x00,0x10,0xf8,0xfc,0xf8,0x10,0x00,0x00,0x00,0x20,0x7c,0xfc,0x7c,0x20,0x00,0x00,
188 0xb0,0x54,0xb8,0xb8,0x54,0xb0,0x00,0x00,0x00,0x28,0x6c,0xfc,0x6c,0x28,0x00,0x00,
189 0x00,0x30,0x30,0x78,0x78,0xfc,0x00,0x00,0xfc,0x78,0x78,0x30,0x30,0x00,0x00,0x00,
190 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,
191 0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0xf8,0x50,0xf8,0x50,0x00,0x00,
192 0x20,0x70,0xc0,0x70,0x18,0xf0,0x20,0x00,0x40,0xa4,0x48,0x10,0x20,0x48,0x94,0x08,
193 0x60,0x90,0xa0,0x40,0xa8,0x90,0x68,0x00,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00,
194 0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x00,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x00,
195 0x20,0xa8,0x70,0xf8,0x70,0xa8,0x20,0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00,
196 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,
197 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
198 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x00,
199 0x70,0x88,0x08,0x10,0x20,0x40,0xf8,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00,
200 0x10,0x30,0x50,0x90,0xf8,0x10,0x10,0x00,0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00,
201 0x70,0x80,0xf0,0x88,0x88,0x88,0x70,0x00,0xf8,0x08,0x08,0x10,0x20,0x20,0x20,0x00,
202 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x70,0x00,
203 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,
204 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,
205 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00,
206 0x30,0x48,0x94,0xa4,0xa4,0x94,0x48,0x30,0x70,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,
207 0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00,
208 0xf0,0x88,0x88,0x88,0x88,0x88,0xf0,0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00,
209 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x80,0x98,0x88,0x88,0x70,0x00,
210 0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
211 0x08,0x08,0x08,0x08,0x88,0x88,0x70,0x00,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00,
212 0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x00,
213 0x88,0xc8,0xa8,0x98,0x88,0x88,0x88,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
214 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x08,
215 0xf0,0x88,0x88,0xf0,0x88,0x88,0x88,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00,
216 0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
217 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00,0x88,0x88,0x88,0x88,0xa8,0xd8,0x88,0x00,
218 0x88,0x50,0x20,0x20,0x20,0x50,0x88,0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00,
219 0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x30,0x20,0x20,0x20,0x20,0x20,0x30,0x00,
220 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x30,0x10,0x10,0x10,0x10,0x10,0x30,0x00,
221 0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
222 0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00,
223 0x80,0x80,0xf0,0x88,0x88,0x88,0xf0,0x00,0x00,0x00,0x70,0x88,0x80,0x80,0x78,0x00,
224 0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00,0x00,0x00,0x70,0x88,0xf8,0x80,0x78,0x00,
225 0x18,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x70,
226 0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00,
227 0x20,0x00,0x20,0x20,0x20,0x20,0x20,0xc0,0x80,0x80,0x90,0xa0,0xe0,0x90,0x88,0x00,
228 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xf0,0xa8,0xa8,0xa8,0xa8,0x00,
229 0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00,
230 0x00,0x00,0xf0,0x88,0x88,0xf0,0x80,0x80,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08,
231 0x00,0x00,0xb0,0xc8,0x80,0x80,0x80,0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00,
232 0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00,
233 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00,0x00,0x00,0xa8,0xa8,0xa8,0xa8,0x50,0x00,
234 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x88,0x88,0x88,0x78,0x08,0x70,
235 0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00,0x08,0x10,0x10,0x20,0x10,0x10,0x08,0x00,
236 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00,
237 0x00,0x68,0xb0,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x20,0x50,0xa8,0x50,0x00,0x00,
238 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
239 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x40,0x0C,0x10,0x38,0x10,0x20,0x20,0xC0,0x00,
240 0x00,0x00,0x00,0x00,0x00,0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0xA8,0x00,
241 0x70,0xA8,0xF8,0x20,0x20,0x20,0x20,0x00,0x70,0xA8,0xF8,0x20,0x20,0xF8,0xA8,0x70,
242 0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00,0x44,0xA8,0x50,0x20,0x68,0xD4,0x28,0x00,
243 0x88,0x70,0x88,0x60,0x30,0x88,0x70,0x00,0x00,0x10,0x20,0x40,0x20,0x10,0x00,0x00,
244 0x78,0xA0,0xA0,0xB0,0xA0,0xA0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
245 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
246 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x20,0x00,0x00,0x00,0x00,0x00,
247 0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x28,0x50,0x50,0x00,0x00,0x00,0x00,0x00,
248 0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x78,0x78,0x30,0x00,0x00,
249 0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,
250 0x68,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0xF4,0x5C,0x54,0x54,0x00,0x00,0x00,0x00,
251 0x88,0x70,0x78,0x80,0x70,0x08,0xF0,0x00,0x00,0x40,0x20,0x10,0x20,0x40,0x00,0x00,
252 0x00,0x00,0x70,0xA8,0xB8,0xA0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
253 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x88,0x88,0x50,0x20,0x20,0x20,0x00,
254 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00,
255 0x00,0x20,0x70,0xA8,0xA0,0xA8,0x70,0x20,0x30,0x48,0x40,0xE0,0x40,0x48,0xF0,0x00,
256 0x00,0x48,0x30,0x48,0x48,0x30,0x48,0x00,0x88,0x88,0x50,0xF8,0x20,0xF8,0x20,0x00,
257 0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x00,0x78,0x80,0x70,0x88,0x70,0x08,0xF0,0x00,
258 0xD8,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x94,0xA4,0xA4,0x94,0x48,0x30,
259 0x60,0x10,0x70,0x90,0x70,0x00,0x00,0x00,0x00,0x28,0x50,0xA0,0x50,0x28,0x00,0x00,
260 0x00,0x00,0x00,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,
261 0x30,0x48,0xB4,0xB4,0xA4,0xB4,0x48,0x30,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
262 0x60,0x90,0x90,0x60,0x00,0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0xF8,0x00,
263 0x60,0x90,0x20,0x40,0xF0,0x00,0x00,0x00,0x60,0x90,0x20,0x90,0x60,0x00,0x00,0x00,
264 0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x88,0xC8,0xB0,0x80,
265 0x78,0xD0,0xD0,0xD0,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,
266 0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x00,0x20,0x60,0x20,0x20,0x70,0x00,0x00,0x00,
267 0x20,0x50,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0x50,0x28,0x50,0xA0,0x00,0x00,
268 0x40,0x48,0x50,0x28,0x58,0xA8,0x38,0x08,0x40,0x48,0x50,0x28,0x44,0x98,0x20,0x3C,
269 0xC0,0x28,0xD0,0x28,0xD8,0xA8,0x38,0x08,0x20,0x00,0x20,0x40,0x80,0x88,0x70,0x00,
270 0x40,0x20,0x70,0x88,0xF8,0x88,0x88,0x00,0x10,0x20,0x70,0x88,0xF8,0x88,0x88,0x00,
271 0x70,0x00,0x70,0x88,0xF8,0x88,0x88,0x00,0x68,0xB0,0x70,0x88,0xF8,0x88,0x88,0x00,
272 0x50,0x00,0x70,0x88,0xF8,0x88,0x88,0x00,0x20,0x50,0x70,0x88,0xF8,0x88,0x88,0x00,
273 0x78,0xA0,0xA0,0xF0,0xA0,0xA0,0xB8,0x00,0x70,0x88,0x80,0x80,0x88,0x70,0x08,0x70,
274 0x40,0x20,0xF8,0x80,0xF0,0x80,0xF8,0x00,0x10,0x20,0xF8,0x80,0xF0,0x80,0xF8,0x00,
275 0x70,0x00,0xF8,0x80,0xF0,0x80,0xF8,0x00,0x50,0x00,0xF8,0x80,0xF0,0x80,0xF8,0x00,
276 0x40,0x20,0x70,0x20,0x20,0x20,0x70,0x00,0x10,0x20,0x70,0x20,0x20,0x20,0x70,0x00,
277 0x70,0x00,0x70,0x20,0x20,0x20,0x70,0x00,0x50,0x00,0x70,0x20,0x20,0x20,0x70,0x00,
278 0x70,0x48,0x48,0xE8,0x48,0x48,0x70,0x00,0x68,0xB0,0x88,0xC8,0xA8,0x98,0x88,0x00,
279 0x40,0x20,0x70,0x88,0x88,0x88,0x70,0x00,0x10,0x20,0x70,0x88,0x88,0x88,0x70,0x00,
280 0x70,0x00,0x70,0x88,0x88,0x88,0x70,0x00,0x68,0xB0,0x70,0x88,0x88,0x88,0x70,0x00,
281 0x50,0x00,0x70,0x88,0x88,0x88,0x70,0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,
282 0x00,0x74,0x88,0x90,0xA8,0x48,0xB0,0x00,0x40,0x20,0x88,0x88,0x88,0x88,0x70,0x00,
283 0x10,0x20,0x88,0x88,0x88,0x88,0x70,0x00,0x70,0x00,0x88,0x88,0x88,0x88,0x70,0x00,
284 0x50,0x00,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0xA8,0x88,0x50,0x20,0x20,0x20,0x00,
285 0x00,0x80,0xF0,0x88,0x88,0xF0,0x80,0x80,0x60,0x90,0x90,0xB0,0x88,0x88,0xB0,0x00,
286 0x40,0x20,0x70,0x08,0x78,0x88,0x78,0x00,0x10,0x20,0x70,0x08,0x78,0x88,0x78,0x00,
287 0x70,0x00,0x70,0x08,0x78,0x88,0x78,0x00,0x68,0xB0,0x70,0x08,0x78,0x88,0x78,0x00,
288 0x50,0x00,0x70,0x08,0x78,0x88,0x78,0x00,0x20,0x50,0x70,0x08,0x78,0x88,0x78,0x00,
289 0x00,0x00,0xF0,0x28,0x78,0xA0,0x78,0x00,0x00,0x00,0x70,0x88,0x80,0x78,0x08,0x70,
290 0x40,0x20,0x70,0x88,0xF8,0x80,0x70,0x00,0x10,0x20,0x70,0x88,0xF8,0x80,0x70,0x00,
291 0x70,0x00,0x70,0x88,0xF8,0x80,0x70,0x00,0x50,0x00,0x70,0x88,0xF8,0x80,0x70,0x00,
292 0x40,0x20,0x00,0x60,0x20,0x20,0x70,0x00,0x10,0x20,0x00,0x60,0x20,0x20,0x70,0x00,
293 0x20,0x50,0x00,0x60,0x20,0x20,0x70,0x00,0x50,0x00,0x00,0x60,0x20,0x20,0x70,0x00,
294 0x50,0x60,0x10,0x78,0x88,0x88,0x70,0x00,0x68,0xB0,0x00,0xF0,0x88,0x88,0x88,0x00,
295 0x40,0x20,0x00,0x70,0x88,0x88,0x70,0x00,0x10,0x20,0x00,0x70,0x88,0x88,0x70,0x00,
296 0x20,0x50,0x00,0x70,0x88,0x88,0x70,0x00,0x68,0xB0,0x00,0x70,0x88,0x88,0x70,0x00,
297 0x00,0x50,0x00,0x70,0x88,0x88,0x70,0x00,0x00,0x20,0x00,0xF8,0x00,0x20,0x00,0x00,
298 0x00,0x00,0x68,0x90,0xA8,0x48,0xB0,0x00,0x40,0x20,0x88,0x88,0x88,0x98,0x68,0x00,
299 0x10,0x20,0x88,0x88,0x88,0x98,0x68,0x00,0x70,0x00,0x88,0x88,0x88,0x98,0x68,0x00,
300 0x50,0x00,0x88,0x88,0x88,0x98,0x68,0x00,0x10,0x20,0x88,0x88,0x88,0x78,0x08,0x70,
301 0x80,0xF0,0x88,0x88,0xF0,0x80,0x80,0x80,0x50,0x00,0x88,0x88,0x88,0x78,0x08,0x70
302 };
303 #if 0
304 static unsigned char fontdata6x8[] =
305 {
306 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
307 0x7c,0x80,0x98,0x90,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x44,0x04,0xf4,0x04,0xf8,
308 0x7c,0x80,0x98,0x88,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x64,0x24,0x04,0xf4,0x04,0xf8,
309 0x7c,0x80,0x88,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x24,0x64,0x04,0xf4,0x04,0xf8,
310 0x7c,0x80,0x90,0x98,0x80,0xbc,0x80,0x7c,0xf8,0x04,0x44,0x64,0x04,0xf4,0x04,0xf8,
311 0x30,0x48,0x84,0xb4,0xb4,0x84,0x48,0x30,0x30,0x48,0x84,0x84,0x84,0x84,0x48,0x30,
312 0x00,0xfc,0x84,0x8c,0xd4,0xa4,0xfc,0x00,0x00,0xfc,0x84,0x84,0x84,0x84,0xfc,0x00,
313 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
314 0x80,0xc0,0xe0,0xf0,0xe0,0xc0,0x80,0x00,0x04,0x0c,0x1c,0x3c,0x1c,0x0c,0x04,0x00,
315 0x20,0x70,0xf8,0x20,0x20,0xf8,0x70,0x20,0x48,0x48,0x48,0x48,0x48,0x00,0x48,0x00,
316 0x00,0x00,0x30,0x68,0x78,0x30,0x00,0x00,0x00,0x30,0x68,0x78,0x78,0x30,0x00,0x00,
317 0x70,0xd8,0xe8,0xe8,0xf8,0xf8,0x70,0x00,0x1c,0x7c,0x74,0x44,0x44,0x4c,0xcc,0xc0,
318 0x20,0x70,0xf8,0x70,0x70,0x70,0x70,0x00,0x70,0x70,0x70,0x70,0xf8,0x70,0x20,0x00,
319 0x00,0x10,0xf8,0xfc,0xf8,0x10,0x00,0x00,0x00,0x20,0x7c,0xfc,0x7c,0x20,0x00,0x00,
320 0xb0,0x54,0xb8,0xb8,0x54,0xb0,0x00,0x00,0x00,0x28,0x6c,0xfc,0x6c,0x28,0x00,0x00,
321 0x00,0x30,0x30,0x78,0x78,0xfc,0x00,0x00,0xfc,0x78,0x78,0x30,0x30,0x00,0x00,0x00,
322 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,
323 0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0xf8,0x50,0xf8,0x50,0x00,0x00,
324 0x20,0x70,0xc0,0x70,0x18,0xf0,0x20,0x00,0x40,0xa4,0x48,0x10,0x20,0x48,0x94,0x08,
325 0x60,0x90,0xa0,0x40,0xa8,0x90,0x68,0x00,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00,
326 0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x00,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x00,
327 0x20,0xa8,0x70,0xf8,0x70,0xa8,0x20,0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00,
328 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,
329 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
330 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x00,
331 0x70,0x88,0x08,0x10,0x20,0x40,0xf8,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00,
332 0x10,0x30,0x50,0x90,0xf8,0x10,0x10,0x00,0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00,
333 0x70,0x80,0xf0,0x88,0x88,0x88,0x70,0x00,0xf8,0x08,0x08,0x10,0x20,0x20,0x20,0x00,
334 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x70,0x00,
335 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,
336 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,
337 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00,
338 0x30,0x48,0x94,0xa4,0xa4,0x94,0x48,0x30,0x70,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,
339 0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00,
340 0xf0,0x88,0x88,0x88,0x88,0x88,0xf0,0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00,
341 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x80,0x98,0x88,0x88,0x70,0x00,
342 0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
343 0x08,0x08,0x08,0x08,0x88,0x88,0x70,0x00,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00,
344 0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x00,
345 0x88,0xc8,0xa8,0x98,0x88,0x88,0x88,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
346 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x08,
347 0xf0,0x88,0x88,0xf0,0x88,0x88,0x88,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00,
348 0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,
349 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00,0x88,0x88,0x88,0x88,0xa8,0xd8,0x88,0x00,
350 0x88,0x50,0x20,0x20,0x20,0x50,0x88,0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00,
351 0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x30,0x20,0x20,0x20,0x20,0x20,0x30,0x00,
352 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x30,0x10,0x10,0x10,0x10,0x10,0x30,0x00,
353 0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
354 0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00,
355 0x80,0x80,0xf0,0x88,0x88,0x88,0xf0,0x00,0x00,0x00,0x70,0x88,0x80,0x80,0x78,0x00,
356 0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00,0x00,0x00,0x70,0x88,0xf8,0x80,0x78,0x00,
357 0x18,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x70,
358 0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00,
359 0x20,0x00,0x20,0x20,0x20,0x20,0x20,0xc0,0x80,0x80,0x90,0xa0,0xe0,0x90,0x88,0x00,
360 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xf0,0xa8,0xa8,0xa8,0xa8,0x00,
361 0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00,
362 0x00,0x00,0xf0,0x88,0x88,0xf0,0x80,0x80,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08,
363 0x00,0x00,0xb0,0xc8,0x80,0x80,0x80,0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00,
364 0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00,
365 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00,0x00,0x00,0xa8,0xa8,0xa8,0xa8,0x50,0x00,
366 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x88,0x88,0x88,0x78,0x08,0x70,
367 0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00,0x08,0x10,0x10,0x20,0x10,0x10,0x08,0x00,
368 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00,
369 0x00,0x68,0xb0,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x20,0x50,0xa8,0x50,0x00,0x00,
370 };
371 #endif
372
373 static struct GfxLayout fontlayout6x8 =
374 {
375 6,8, /* 6*8 characters */
376 256, /* 256 characters */
377 1, /* 1 bit per pixel */
378 { 0 },
379 { 0, 1, 2, 3, 4, 5, 6, 7 }, /* straightforward layout */
380 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
381 8*8 /* every char takes 8 consecutive bytes */
382 };
383 static struct GfxLayout fontlayout12x8 =
384 {
385 12,8, /* 12*8 characters */
386 256, /* 256 characters */
387 1, /* 1 bit per pixel */
388 { 0 },
389 { 0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7 }, /* straightforward layout */
390 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
391 8*8 /* every char takes 8 consecutive bytes */
392 };
393 static struct GfxLayout fontlayout6x16 =
394 {
395 6,16, /* 6*8 characters */
396 256, /* 256 characters */
397 1, /* 1 bit per pixel */
398 { 0 },
399 { 0, 1, 2, 3, 4, 5, 6, 7 }, /* straightforward layout */
400 { 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 },
401 8*8 /* every char takes 8 consecutive bytes */
402 };
403 static struct GfxLayout fontlayout12x16 =
404 {
405 12,16, /* 12*16 characters */
406 256, /* 256 characters */
407 1, /* 1 bit per pixel */
408 { 0 },
409 { 0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7 }, /* straightforward layout */
410 { 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 },
411 8*8 /* every char takes 8 consecutive bytes */
412 };
413
414 struct GfxElement *font;
415 static pen_t colortable[2*2]; /* ASG 980209 */
416
417
418 switch_ui_orientation(NULL);
419
420 if ((Machine->drv->video_attributes & VIDEO_PIXEL_ASPECT_RATIO_MASK)
421 == VIDEO_PIXEL_ASPECT_RATIO_1_2)
422 {
423 if (Machine->gamedrv->flags & ORIENTATION_SWAP_XY)
424 {
425 font = decodegfx(fontdata6x8,&fontlayout6x16);
426 Machine->uifontwidth = 6;
427 Machine->uifontheight = 16;
428 }
429 else
430 {
431 font = decodegfx(fontdata6x8,&fontlayout12x8);
432 Machine->uifontwidth = 12;
433 Machine->uifontheight = 8;
434 }
435 }
436 else if (Machine->uiwidth >= 420 && Machine->uiheight >= 420)
437 {
438 font = decodegfx(fontdata6x8,&fontlayout12x16);
439 Machine->uifontwidth = 12;
440 Machine->uifontheight = 16;
441 }
442 else
443 {
444 font = decodegfx(fontdata6x8,&fontlayout6x8);
445 Machine->uifontwidth = 6;
446 Machine->uifontheight = 8;
447 }
448
449 if (font)
450 {
451 /* colortable will be set at run time */
452 memset(colortable,0,sizeof(colortable));
453 font->colortable = colortable;
454 font->total_colors = 2;
455 }
456
457 switch_true_orientation(NULL);
458
459 return font;
460 }
461 #endif
462
463
464
465 static void erase_screen(struct mame_bitmap *bitmap)
466 {
467 fillbitmap(bitmap,get_black_pen(),NULL);
468 schedule_full_refresh();
469 }
470
471
472 /***************************************************************************
473
474 Display text on the screen. If erase is 0, it superimposes the text on
475 the last frame displayed.
476
477 ***************************************************************************/
478
479 void displaytext(struct mame_bitmap *bitmap,const struct DisplayText *dt)
480 {
481 #ifdef MAME32JP
482 int next_sy = 0;
483 #endif
484
485 switch_ui_orientation(bitmap);
486
487 osd_mark_dirty(Machine->uixmin,Machine->uiymin,Machine->uixmin+Machine->uiwidth-1,Machine->uiymin+Machine->uiheight-1);
488
489 #ifdef MAME32JP
490 while (dt->text)
491 {
492 next_sy = uifont_drawfont(bitmap, dt->text, dt->x, dt->y + next_sy, dt->color);
493 dt++;
494
495 if (dt->y + next_sy >= Machine->uiheight)
496 break;
497 }
498 #else
499 while (dt->text)
500 {
501 int x,y;
502 const char *c;
503
504
505 x = dt->x;
506 y = dt->y;
507 c = dt->text;
508
509 while (*c)
510 {
511 int wrapped;
512
513
514 wrapped = 0;
515
516 if (*c == '\n')
517 {
518 x = dt->x;
519 y += Machine->uifontheight + 1;
520 wrapped = 1;
521 }
522 else if (*c == ' ')
523 {
524 /* don't try to word wrap at the beginning of a line (this would cause */
525 /* an endless loop if a word is longer than a line) */
526 if (x != dt->x)
527 {
528 int nextlen=0;
529 const char *nc;
530
531
532 nc = c+1;
533 while (*nc && *nc != ' ' && *nc != '\n')
534 {
535 nextlen += Machine->uifontwidth;
536 nc++;
537 }
538
539 /* word wrap */
540 if (x + Machine->uifontwidth + nextlen > Machine->uiwidth)
541 {
542 x = dt->x;
543 y += Machine->uifontheight + 1;
544 wrapped = 1;
545 }
546 }
547 }
548
549 if (!wrapped)
550 {
551 drawgfx(bitmap,Machine->uifont,*c,dt->color,0,0,x+Machine->uixmin,y+Machine->uiymin,0,TRANSPARENCY_NONE,0);
552 x += Machine->uifontwidth;
553 }
554 else
555 break;
556
557 c++;
558 }
559
560 dt++;
561 }
562 #endif
563
564 switch_true_orientation(bitmap);
565 }
566
567 /* Writes messages on the screen. */
568 static void ui_text_ex(struct mame_bitmap *bitmap,const char* buf_begin, const char* buf_end, int x, int y, int color)
569 {
570 #ifdef MAME32JP
571 int len;
572 char buf[256];
573 #endif
574
575 switch_ui_orientation(bitmap);
576
577 #ifdef MAME32JP
578 memset(buf, 0, 256);
579
580 len = (buf_end - buf_begin) + 1;
581 if (*buf_end == ' ')
582 len--;
583
584 memcpy(buf, buf_begin, len);
585
586 uifont_drawfont(bitmap, buf, x, y, color);
587 #else
588 for (;buf_begin != buf_end; ++buf_begin)
589 {
590 drawgfx(bitmap,Machine->uifont,*buf_begin,color,0,0,
591 x + Machine->uixmin,
592 y + Machine->uiymin, 0,TRANSPARENCY_NONE,0);
593 x += Machine->uifontwidth;
594 }
595 #endif
596
597 switch_true_orientation(bitmap);
598 }
599
600 /* Writes messages on the screen. */
601 void ui_text(struct mame_bitmap *bitmap,const char *buf,int x,int y)
602 {
603 ui_text_ex(bitmap, buf, buf + strlen(buf), x, y, UI_COLOR_NORMAL);
604 }
605
606
607 void ui_drawbox(struct mame_bitmap *bitmap,int leftx,int topy,int width,int height)
608 {
609 UINT32 black,white;
610 #ifdef MAME32JP
611 extern int iTrans;
612 extern int iTransOpt;
613 #endif
614
615 switch_ui_orientation(bitmap);
616
617 if (leftx < 0) leftx = 0;
618 if (topy < 0) topy = 0;
619 if (width > Machine->uiwidth) width = Machine->uiwidth;
620 if (height > Machine->uiheight) height = Machine->uiheight;
621
622 leftx += Machine->uixmin;
623 topy += Machine->uiymin;
624
625 black = Machine->uifont->colortable[0];
626 white = Machine->uifont->colortable[1];
627
628 plot_box(bitmap,leftx, topy, width, 1, white);
629 plot_box(bitmap,leftx, topy+height-1,width, 1, white);
630 plot_box(bitmap,leftx, topy, 1, height, white);
631 plot_box(bitmap,leftx+width-1,topy, 1, height, white);
632 #ifdef MAME32JP
633 if(iTrans && iTransOpt)
634 plot_box_trans(bitmap, leftx+1, topy+1, width-2, height-2);
635 else
636 #endif
637 plot_box(bitmap,leftx+1, topy+1, width-2,height-2,black);
638
639 switch_true_orientation(bitmap);
640 }
641
642
643 static void drawbar(struct mame_bitmap *bitmap,int leftx,int topy,int width,int height,int percentage,int default_percentage)
644 {
645 UINT32 black,white;
646
647
648 switch_ui_orientation(bitmap);
649
650 if (leftx < 0) leftx = 0;
651 if (topy < 0) topy = 0;
652 if (width > Machine->uiwidth) width = Machine->uiwidth;
653 if (height > Machine->uiheight) height = Machine->uiheight;
654
655 leftx += Machine->uixmin;
656 topy += Machine->uiymin;
657
658 black = Machine->uifont->colortable[0];
659 white = Machine->uifont->colortable[1];
660
661 plot_box(bitmap,leftx+(width-1)*default_percentage/100,topy,1,height/8,white);
662
663 plot_box(bitmap,leftx,topy+height/8,width,1,white);
664
665 plot_box(bitmap,leftx,topy+height/8,1+(width-1)*percentage/100,height-2*(height/8),white);
666
667 plot_box(bitmap,leftx,topy+height-height/8-1,width,1,white);
668
669 plot_box(bitmap,leftx+(width-1)*default_percentage/100,topy+height-height/8,1,height/8,white);
670
671 switch_true_orientation(bitmap);
672 }
673
674 /* Extract one line from a multiline buffer */
675 /* Return the characters number of the line, pbegin point to the start of the next line */
676 static unsigned multiline_extract(const char** pbegin, const char* end, unsigned max)
677 {
678 unsigned mac = 0;
679 const char* begin = *pbegin;
680 while (begin != end && mac < max)
681 {
682 if (*begin == '\n')
683 {
684 *pbegin = begin + 1; /* strip final space */
685 return mac;
686 }
687 else if (*begin == ' ')
688 {
689 const char* word_end = begin + 1;
690 while (word_end != end && *word_end != ' ' && *word_end != '\n')
691 ++word_end;
692 if (mac + word_end - begin > max)
693 {
694 if (mac)
695 {
696 *pbegin = begin + 1;
697 return mac; /* strip final space */
698 } else {
699 *pbegin = begin + max;
700 return max;
701 }
702 }
703 mac += word_end - begin;
704 begin = word_end;
705 } else {
706 ++mac;
707 ++begin;
708 }
709 }
710 if (begin != end && (*begin == '\n' || *begin == ' '))
711 ++begin;
712 *pbegin = begin;
713 return mac;
714 }
715
716 /* Compute the output size of a multiline string */
717 static void multiline_size(int* dx, int* dy, const char* begin, const char* end, unsigned max)
718 {
719 unsigned rows = 0;
720 unsigned cols = 0;
721 while (begin != end)
722 {
723 unsigned len;
724 len = multiline_extract(&begin,end,max);
725 if (len > cols)
726 cols = len;
727 ++rows;
728 }
729 *dx = cols * Machine->uifontwidth;
730 #ifdef MAME32JP
731 *dy = (rows-1) * ROWHEIGHT;
732 #else
733 *dy = (rows-1) * 3*Machine->uifontheight/2 + Machine->uifontheight;
734 #endif
735 }
736
737 /* Compute the output size of a multiline string with box */
738 static void multilinebox_size(int* dx, int* dy, const char* begin, const char* end, unsigned max)
739 {
740 multiline_size(dx,dy,begin,end,max);
741 *dx += Machine->uifontwidth;
742 #ifdef MAME32JP
743 *dy += ROWHEIGHT;
744 #else
745 *dy += Machine->uifontheight;
746 #endif
747 }
748
749 /* Display a multiline string */
750 static void ui_multitext_ex(struct mame_bitmap *bitmap, const char* begin, const char* end, unsigned max, int x, int y, int color)
751 {
752 while (begin != end)
753 {
754 const char* line_begin = begin;
755 unsigned len = multiline_extract(&begin,end,max);
756 ui_text_ex(bitmap, line_begin, line_begin + len,x,y,color);
757 #ifdef MAME32JP
758 y += ROWHEIGHT;
759 #else
760 y += 3*Machine->uifontheight/2;
761 #endif
762 }
763 }
764
765 /* Display a multiline string with box */
766 static void ui_multitextbox_ex(struct mame_bitmap *bitmap,const char* begin, const char* end, unsigned max, int x, int y, int dx, int dy, int color)
767 {
768 #ifdef MAME32JP
769 ui_drawbox(bitmap,x,y-BOXADJUST,dx,dy+BOXADJUST*2);
770 x += Machine->uifontwidth/2;
771 ui_multitext_ex(bitmap,begin,end,max,x,y,color);
772 #else
773 ui_drawbox(bitmap,x,y,dx,dy);
774 x += Machine->uifontwidth/2;
775 y += Machine->uifontheight/2;
776 ui_multitext_ex(bitmap,begin,end,max,x,y,color);
777 #endif
778 }
779
780 #ifdef MAME32JP
781 void ui_displaymenu(struct mame_bitmap *bitmap,const char **items,const char **subitems,char *flag,int selected,int arrowize_subitem)
782 {
783 struct DisplayText dt[256];
784 int curr_dt,curr_y;
785 const char *lefthilight = ui_getstring (UI_lefthilight);
786 const char *righthilight = ui_getstring (UI_righthilight);
787 const char *uparrow = ui_getstring (UI_uparrow);
788 const char *downarrow = ui_getstring (UI_downarrow);
789 const char *leftarrow = ui_getstring (UI_leftarrow);
790 const char *rightarrow = ui_getstring (UI_rightarrow);
791 int i,count,len,maxlen,highlen;
792 int leftoffs,topoffs,visible,topitem;
793 int selected_long;
794
795
796 i = 0;
797 maxlen = 0;
798 highlen = Machine->uiwidth / Machine->uifontwidth;
799 while (items[i])
800 {
801 len = (raw+law+1) + strlen(items[i]) + 1;
802 if (subitems && subitems[i])
803 len += (lhw+rhw) + strlen(subitems[i]);
804 if (len > maxlen && len <= highlen)
805 maxlen = len;
806 i++;
807 }
808 count = i;
809
810 visible = (Machine->uiheight / ROWHEIGHT) - 1;
811
812 topitem = 0;
813 if (visible > count) visible = count;
814 else
815 {
816 topitem = selected - visible / 2;
817 if (topitem < 0) topitem = 0;
818 if (topitem > count - visible) topitem = count - visible;
819 }
820
821 leftoffs = (Machine->uiwidth - maxlen * Machine->uifontwidth) / 2;
822 topoffs = (Machine->uiheight - visible * ROWHEIGHT) / 2;
823
824 /* black background */
825 ui_drawbox(bitmap,leftoffs,topoffs - BOXADJUST,maxlen * Machine->uifontwidth,visible * ROWHEIGHT + BOXADJUST*2);
826
827 selected_long = 0;
828 curr_dt = 0;
829 for (i = 0;i < visible;i++)
830 {
831 int item = i + topitem;
832
833 curr_y = topoffs + i * ROWHEIGHT + ROWADJUST;
834
835 if (i == 0 && item > 0)
836 {
837 dt[curr_dt].text = uparrow;
838 dt[curr_dt].color = UI_COLOR_NORMAL;
839 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * uaw) / 2;
840 dt[curr_dt].y = curr_y;
841 curr_dt++;
842 }
843 else if (i == visible - 1 && item < count - 1)
844 {
845 dt[curr_dt].text = downarrow;
846 dt[curr_dt].color = UI_COLOR_NORMAL;
847 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * daw) / 2;
848 dt[curr_dt].y = curr_y;
849 curr_dt++;
850 }
851 else
852 {
853 if (subitems && subitems[item])
854 {
855 int sublen;
856
857 len = strlen(items[item]);
858 dt[curr_dt].text = items[item];
859 dt[curr_dt].color = UI_COLOR_NORMAL;
860 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2 + Machine->uifontwidth * raw;
861 dt[curr_dt].y = curr_y;
862 curr_dt++;
863
864 sublen = strlen(subitems[item]);
865 if (sublen > maxlen-(raw+lhw+rhw+2)-len)
866 {
867 dt[curr_dt].text = "...";
868 sublen = strlen(dt[curr_dt].text);
869 if (item == selected)
870 selected_long = 1;
871 }
872 else
873 dt[curr_dt].text = subitems[item];
874
875 /* If this item is flagged, draw it in inverse print */
876 dt[curr_dt].color = (flag && flag[item]) ? UI_COLOR_INVERSE : UI_COLOR_NORMAL;
877 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-rhw-sublen) - Machine->uifontwidth/2;
878 dt[curr_dt].y = curr_y;
879 curr_dt++;
880 }
881 else
882 {
883 dt[curr_dt].text = items[item];
884 dt[curr_dt].color = UI_COLOR_NORMAL;
885 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(items[item])) / 2;
886 dt[curr_dt].y = curr_y;
887 curr_dt++;
888 }
889 }
890 }
891
892 i = selected - topitem;
893
894 curr_y = topoffs + i * ROWHEIGHT + ROWADJUST;
895
896 if (subitems && subitems[selected] && arrowize_subitem)
897 {
898 if (arrowize_subitem & 1)
899 {
900 int sublen;
901
902 len = strlen(items[selected]);
903
904 dt[curr_dt].text = leftarrow;
905 dt[curr_dt].color = UI_COLOR_NORMAL;
906
907 sublen = strlen(subitems[selected]);
908 if (sublen > maxlen-(raw+lhw+rhw+2)-len)
909 sublen = strlen("...");
910
911 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-(lhw+law)-sublen) - Machine->uifontwidth/2 - raw;
912 dt[curr_dt].y = curr_y;
913 curr_dt++;
914 }
915 if (arrowize_subitem & 2)
916 {
917 dt[curr_dt].text = rightarrow;
918 dt[curr_dt].color = UI_COLOR_NORMAL;
919 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-raw) - Machine->uifontwidth/2;
920 dt[curr_dt].y = curr_y;
921 curr_dt++;
922 }
923 }
924 else
925 {
926 dt[curr_dt].text = righthilight;
927 dt[curr_dt].color = UI_COLOR_NORMAL;
928 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-rhw) - Machine->uifontwidth/2;
929 dt[curr_dt].y = curr_y;
930 curr_dt++;
931 }
932 dt[curr_dt].text = lefthilight;
933 dt[curr_dt].color = UI_COLOR_NORMAL;
934 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2;
935 dt[curr_dt].y = curr_y;
936 curr_dt++;
937
938 dt[curr_dt].text = 0; /* terminate array */
939
940 displaytext(bitmap,dt);
941
942 if (selected_long)
943 {
944 int long_dx;
945 int long_dy;
946 int long_x;
947 int long_y;
948 unsigned long_max;
949
950 long_max = (Machine->uiwidth / Machine->uifontwidth) - 2;
951 multilinebox_size(&long_dx,&long_dy,subitems[selected],subitems[selected] + strlen(subitems[selected]), long_max);
952
953 long_x = Machine->uiwidth - long_dx;
954 long_y = topoffs + (i+1) * ROWHEIGHT;
955
956 /* if too low display up */
957 if (long_y + long_dy > Machine->uiheight)
958 long_y = topoffs + i * ROWHEIGHT - long_dy;
959
960 ui_multitextbox_ex(bitmap,subitems[selected],subitems[selected] + strlen(subitems[selected]), long_max, long_x,long_y,long_dx,long_dy, UI_COLOR_NORMAL);
961 }
962 }
963 #else
964 void ui_displaymenu(struct mame_bitmap *bitmap,const char **items,const char **subitems,char *flag,int selected,int arrowize_subitem)
965 {
966 struct DisplayText dt[256];
967 int curr_dt;
968 const char *lefthilight = ui_getstring (UI_lefthilight);
969 const char *righthilight = ui_getstring (UI_righthilight);
970 const char *uparrow = ui_getstring (UI_uparrow);
971 const char *downarrow = ui_getstring (UI_downarrow);
972 const char *leftarrow = ui_getstring (UI_leftarrow);
973 const char *rightarrow = ui_getstring (UI_rightarrow);
974 int i,count,len,maxlen,highlen;
975 int leftoffs,topoffs,visible,topitem;
976 int selected_long;
977
978
979 i = 0;
980 maxlen = 0;
981 highlen = Machine->uiwidth / Machine->uifontwidth;
982 while (items[i])
983 {
984 len = 3 + strlen(items[i]);
985 if (subitems && subitems[i])
986 len += 2 + strlen(subitems[i]);
987 if (len > maxlen && len <= highlen)
988 maxlen = len;
989 i++;
990 }
991 count = i;
992
993 visible = Machine->uiheight / (3 * Machine->uifontheight / 2) - 1;
994 topitem = 0;
995 if (visible > count) visible = count;
996 else
997 {
998 topitem = selected - visible / 2;
999 if (topitem < 0) topitem = 0;
1000 if (topitem > count - visible) topitem = count - visible;
1001 }
1002
1003 leftoffs = (Machine->uiwidth - maxlen * Machine->uifontwidth) / 2;
1004 topoffs = (Machine->uiheight - (3 * visible + 1) * Machine->uifontheight / 2) / 2;
1005
1006 /* black background */
1007 ui_drawbox(bitmap,leftoffs,topoffs,maxlen * Machine->uifontwidth,(3 * visible + 1) * Machine->uifontheight / 2);
1008
1009 selected_long = 0;
1010 curr_dt = 0;
1011 for (i = 0;i < visible;i++)
1012 {
1013 int item = i + topitem;
1014
1015 if (i == 0 && item > 0)
1016 {
1017 dt[curr_dt].text = uparrow;
1018 dt[curr_dt].color = UI_COLOR_NORMAL;
1019 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(uparrow)) / 2;
1020 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1021 curr_dt++;
1022 }
1023 else if (i == visible - 1 && item < count - 1)
1024 {
1025 dt[curr_dt].text = downarrow;
1026 dt[curr_dt].color = UI_COLOR_NORMAL;
1027 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(downarrow)) / 2;
1028 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1029 curr_dt++;
1030 }
1031 else
1032 {
1033 if (subitems && subitems[item])
1034 {
1035 int sublen;
1036 len = strlen(items[item]);
1037 dt[curr_dt].text = items[item];
1038 dt[curr_dt].color = UI_COLOR_NORMAL;
1039 dt[curr_dt].x = leftoffs + 3*Machine->uifontwidth/2;
1040 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1041 curr_dt++;
1042 sublen = strlen(subitems[item]);
1043 if (sublen > maxlen-5-len)
1044 {
1045 dt[curr_dt].text = "...";
1046 sublen = strlen(dt[curr_dt].text);
1047 if (item == selected)
1048 selected_long = 1;
1049 } else {
1050 dt[curr_dt].text = subitems[item];
1051 }
1052 /* If this item is flagged, draw it in inverse print */
1053 dt[curr_dt].color = (flag && flag[item]) ? UI_COLOR_INVERSE : UI_COLOR_NORMAL;
1054 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-1-sublen) - Machine->uifontwidth/2;
1055 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1056 curr_dt++;
1057 }
1058 else
1059 {
1060 dt[curr_dt].text = items[item];
1061 dt[curr_dt].color = UI_COLOR_NORMAL;
1062 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * strlen(items[item])) / 2;
1063 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1064 curr_dt++;
1065 }
1066 }
1067 }
1068
1069 i = selected - topitem;
1070 if (subitems && subitems[selected] && arrowize_subitem)
1071 {
1072 if (arrowize_subitem & 1)
1073 {
1074 int sublen;
1075
1076 len = strlen(items[selected]);
1077
1078 dt[curr_dt].text = leftarrow;
1079 dt[curr_dt].color = UI_COLOR_NORMAL;
1080
1081 sublen = strlen(subitems[selected]);
1082 if (sublen > maxlen-5-len)
1083 sublen = strlen("...");
1084
1085 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-2 - sublen) - Machine->uifontwidth/2 - 1;
1086 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1087 curr_dt++;
1088 }
1089 if (arrowize_subitem & 2)
1090 {
1091 dt[curr_dt].text = rightarrow;
1092 dt[curr_dt].color = UI_COLOR_NORMAL;
1093 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-1) - Machine->uifontwidth/2;
1094 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1095 curr_dt++;
1096 }
1097 }
1098 else
1099 {
1100 dt[curr_dt].text = righthilight;
1101 dt[curr_dt].color = UI_COLOR_NORMAL;
1102 dt[curr_dt].x = leftoffs + Machine->uifontwidth * (maxlen-1) - Machine->uifontwidth/2;
1103 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1104 curr_dt++;
1105 }
1106 dt[curr_dt].text = lefthilight;
1107 dt[curr_dt].color = UI_COLOR_NORMAL;
1108 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2;
1109 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1110 curr_dt++;
1111
1112 dt[curr_dt].text = 0; /* terminate array */
1113
1114 displaytext(bitmap,dt);
1115
1116 if (selected_long)
1117 {
1118 int long_dx;
1119 int long_dy;
1120 int long_x;
1121 int long_y;
1122 unsigned long_max;
1123
1124 long_max = (Machine->uiwidth / Machine->uifontwidth) - 2;
1125 multilinebox_size(&long_dx,&long_dy,subitems[selected],subitems[selected] + strlen(subitems[selected]), long_max);
1126
1127 long_x = Machine->uiwidth - long_dx;
1128 long_y = topoffs + (i+1) * 3*Machine->uifontheight/2;
1129
1130 /* if too low display up */
1131 if (long_y + long_dy > Machine->uiheight)
1132 long_y = topoffs + i * 3*Machine->uifontheight/2 - long_dy;
1133
1134 ui_multitextbox_ex(bitmap,subitems[selected],subitems[selected] + strlen(subitems[selected]), long_max, long_x,long_y,long_dx,long_dy, UI_COLOR_NORMAL);
1135 }
1136 }
1137 #endif
1138
1139 #ifdef MAME32JP
1140 int ui_displaymessagewindow(struct mame_bitmap *bitmap, const char *text)
1141 {
1142 struct DisplayText dt[256];
1143 char *c, *c2;
1144 char textcopy[2048];
1145 int curr_dt;
1146 int i, lines;
1147 int leftoffs, topoffs;
1148 int maxrows, maxcols, maxlen;
1149 static int scroll = 0;
1150
1151 maxcols = (Machine->uiwidth / Machine->uifontwidth) - 2;
1152 maxrows = (Machine->uiheight / ROWHEIGHT) - 1;
1153
1154 strcpy(textcopy, text);
1155 maxlen = wordwrap_text_buffer(textcopy, maxcols);
1156 lines = count_lines_in_buffer(textcopy);
1157
1158 if (lines >= maxrows)
1159 {
1160 if (scroll_reset)
1161 {
1162 scroll = 0;
1163 scroll_reset = 0;
1164 }
1165
1166 strcat(textcopy, "\n");
1167 display_scroll_message(bitmap, &scroll, maxlen, maxrows, textcopy);
1168
1169 if ((scroll > 0) && input_ui_pressed_repeat(IPT_UI_UP,4))
1170 {
1171 if (scroll == 2) scroll = 0; /* 1 would be the same as 0, but with arrow on top */
1172 else scroll--;
1173 return -1;
1174 }
1175 else if (input_ui_pressed_repeat(IPT_UI_DOWN,4))
1176 {
1177 if (scroll == 0) scroll = 2; /* 1 would be the same as 0, but with arrow on top */
1178 else scroll++;
1179 return -1;
1180 }
1181 else
1182 if (input_ui_pressed(IPT_UI_SELECT))
1183 {
1184 scroll = 0;
1185 return 1;
1186 }
1187 else
1188 if (input_ui_pressed(IPT_UI_CANCEL))
1189 {
1190 scroll = 0;
1191 return 2;
1192 }
1193 else
1194 if (input_ui_pressed(IPT_UI_CONFIGURE))
1195 {
1196 scroll = 0;
1197 return 3;
1198 }
1199 }
1200 else
1201 {
1202 leftoffs = (Machine->uiwidth - Machine->uifontwidth * maxlen) / 2;
1203 if (leftoffs < 0) leftoffs = 0;
1204 topoffs = (Machine->uiheight - (lines + 1) * ROWHEIGHT) / 2;
1205
1206 /* black background */
1207 ui_drawbox(bitmap,leftoffs,topoffs-BOXADJUST,maxlen*Machine->uifontwidth,(lines+1)*ROWHEIGHT+BOXADJUST*2);
1208
1209 curr_dt = 0;
1210 c = textcopy;
1211 i = 0;
1212 while (*c)
1213 {
1214 c2 = c;
1215 while (*c && *c != '\n')
1216 c++;
1217
1218 if (*c == '\n')
1219 {
1220 *c = '\0';
1221 c++;
1222 }
1223
1224 if (*c2 == '\t') /* center text */
1225 {
1226 c2++;
1227 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * (c - c2)) / 2;
1228 }
1229 else
1230 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2;
1231
1232 dt[curr_dt].text = c2;
1233 dt[curr_dt].color = UI_COLOR_NORMAL;
1234 dt[curr_dt].y = topoffs + i * ROWHEIGHT + ROWADJUST;
1235 curr_dt++;
1236
1237 i++;
1238 }
1239
1240 dt[curr_dt].text = 0; /* terminate array */
1241
1242 displaytext(bitmap,dt);
1243 }
1244
1245 return 0;
1246 }
1247 #else
1248 void ui_displaymessagewindow(struct mame_bitmap *bitmap,const char *text)
1249 {
1250 struct DisplayText dt[256];
1251 int curr_dt;
1252 char *c,*c2;
1253 int i,len,maxlen,lines;
1254 char textcopy[2048];
1255 int leftoffs,topoffs;
1256 int maxcols,maxrows;
1257
1258 maxcols = (Machine->uiwidth / Machine->uifontwidth) - 1;
1259 maxrows = (2 * Machine->uiheight - Machine->uifontheight) / (3 * Machine->uifontheight);
1260
1261 /* copy text, calculate max len, count lines, wrap long lines and crop height to fit */
1262 maxlen = 0;
1263 lines = 0;
1264 c = (char *)text;
1265 c2 = textcopy;
1266 while (*c)
1267 {
1268 len = 0;
1269 while (*c && *c != '\n')
1270 {
1271 *c2++ = *c++;
1272 len++;
1273 if (len == maxcols && *c != '\n')
1274 {
1275 /* attempt word wrap */
1276 char *csave = c, *c2save = c2;
1277 int lensave = len;
1278
1279 /* back up to last space or beginning of line */
1280 while (*c != ' ' && *c != '\n' && c > text)
1281 --c, --c2, --len;
1282
1283 /* if no space was found, hard wrap instead */
1284 if (*c != ' ')
1285 c = csave, c2 = c2save, len = lensave;
1286 else
1287 c++;
1288
1289 *c2++ = '\n'; /* insert wrap */
1290 break;
1291 }
1292 }
1293
1294 if (*c == '\n')
1295 *c2++ = *c++;
1296
1297 if (len > maxlen) maxlen = len;
1298
1299 lines++;
1300 if (lines == maxrows)
1301 break;
1302 }
1303 *c2 = '\0';
1304
1305 maxlen += 1;
1306
1307 leftoffs = (Machine->uiwidth - Machine->uifontwidth * maxlen) / 2;
1308 if (leftoffs < 0) leftoffs = 0;
1309 topoffs = (Machine->uiheight - (3 * lines + 1) * Machine->uifontheight / 2) / 2;
1310
1311 /* black background */
1312 ui_drawbox(bitmap,leftoffs,topoffs,maxlen * Machine->uifontwidth,(3 * lines + 1) * Machine->uifontheight / 2);
1313
1314 curr_dt = 0;
1315 c = textcopy;
1316 i = 0;
1317 while (*c)
1318 {
1319 c2 = c;
1320 while (*c && *c != '\n')
1321 c++;
1322
1323 if (*c == '\n')
1324 {
1325 *c = '\0';
1326 c++;
1327 }
1328
1329 if (*c2 == '\t') /* center text */
1330 {
1331 c2++;
1332 dt[curr_dt].x = (Machine->uiwidth - Machine->uifontwidth * (c - c2)) / 2;
1333 }
1334 else
1335 dt[curr_dt].x = leftoffs + Machine->uifontwidth/2;
1336
1337 dt[curr_dt].text = c2;
1338 dt[curr_dt].color = UI_COLOR_NORMAL;
1339 dt[curr_dt].y = topoffs + (3*i+1)*Machine->uifontheight/2;
1340 curr_dt++;
1341
1342 i++;
1343 }
1344
1345 dt[curr_dt].text = 0; /* terminate array */
1346
1347 displaytext(bitmap,dt);
1348 }
1349 #endif
1350
1351
1352
1353 static void showcharset(struct mame_bitmap *bitmap)
1354 {
1355 int i;
1356 char buf[80];
1357 int mode,bank,color,firstdrawn;
1358 int palpage;
1359 int changed;
1360 int total_colors = 0;
1361 pen_t *colortable = NULL;
1362 int cpx=0,cpy,skip_chars=0,skip_tmap=0;
1363 int tilemap_xpos = 0;
1364 int tilemap_ypos = 0;
1365 #ifdef MAME32JP
1366 int quit = 0;
1367 #endif
1368
1369 mode = 0;
1370 bank = 0;
1371 color = 0;
1372 firstdrawn = 0;
1373 palpage = 0;
1374
1375 changed = 1;
1376
1377 do
1378 {
1379 switch (mode)
1380 {
1381 case 0: /* palette or clut */
1382 {
1383 if (bank == 0) /* palette */
1384 {
1385 total_colors = Machine->drv->total_colors;
1386 colortable = Machine->pens;
1387 strcpy(buf,"PALETTE");
1388 }
1389 else if (bank == 1) /* clut */
1390 {
1391 total_colors = Machine->drv->color_table_len;
1392 colortable = Machine->remapped_colortable;
1393 strcpy(buf,"CLUT");
1394 }
1395 else
1396 {
1397 buf[0] = 0;
1398 total_colors = 0;
1399 colortable = 0;
1400 }
1401
1402 if (changed)
1403 {
1404 erase_screen(bitmap);
1405
1406 if (total_colors)
1407 {
1408 int sx,sy,colors;
1409
1410 switch_ui_orientation(bitmap);
1411
1412 colors = total_colors - 256 * palpage;
1413 if (colors > 256) colors = 256;
1414
1415 for (i = 0;i < 16;i++)
1416 {
1417 char bf[40];
1418
1419 sx = 3*Machine->uifontwidth + (Machine->uifontwidth*4/3)*(i % 16);
1420 sprintf(bf,"%X",i);
1421 ui_text(bitmap,bf,sx,2*Machine->uifontheight);
1422 if (16*i < colors)
1423 {
1424 sy = 3*Machine->uifontheight + (Machine->uifontheight)*(i % 16);
1425 sprintf(bf,"%3X",i+16*palpage);
1426 ui_text(bitmap,bf,0,sy);
1427 }
1428 }
1429
1430 for (i = 0;i < colors;i++)
1431 {
1432 sx = Machine->uixmin + 3*Machine->uifontwidth + (Machine->uifontwidth*4/3)*(i % 16);
1433 sy = Machine->uiymin + 2*Machine->uifontheight + (Machine->uifontheight)*(i / 16) + Machine->uifontheight;
1434 plot_box(bitmap,sx,sy,Machine->uifontwidth*4/3,Machine->uifontheight,colortable[i + 256*palpage]);
1435 }
1436 switch_true_orientation(bitmap);
1437 }
1438 else
1439 ui_text(bitmap,"N/A",3*Machine->uifontwidth,2*Machine->uifontheight);
1440
1441 ui_text(bitmap,buf,0,0);
1442 changed = 0;
1443 }
1444
1445 break;
1446 }
1447 case 1: /* characters */
1448 {
1449 cpx = Machine->uiwidth / Machine->gfx[bank]->width;
1450 cpy = (Machine->uiheight - Machine->uifontheight) / Machine->gfx[bank]->height;
1451 skip_chars = cpx * cpy;
1452 if (changed)
1453 {
1454 int flipx,flipy;
1455 int lastdrawn=0;
1456
1457 erase_screen(bitmap);
1458
1459 /* validity check after char bank change */
1460 if (firstdrawn >= Machine->gfx[bank]->total_elements)
1461 {
1462 firstdrawn = Machine->gfx[bank]->total_elements - skip_chars;
1463 if (firstdrawn < 0) firstdrawn = 0;
1464 }
1465
1466 switch_ui_orientation(bitmap);
1467
1468
1469 #ifndef PREROTATE_GFX
1470 flipx = (Machine->orientation ^ trueorientation) & ORIENTATION_FLIP_X;
1471 flipy = (Machine->orientation ^ trueorientation) & ORIENTATION_FLIP_Y;
1472
1473 if (Machine->orientation & ORIENTATION_SWAP_XY)
1474 {
1475 int t;
1476 t = flipx; flipx = flipy; flipy = t;
1477 }
1478 #else
1479 flipx = 0;
1480 flipy = 0;
1481 #endif
1482
1483 for (i = 0; i+firstdrawn < Machine->gfx[bank]->total_elements && i<cpx*cpy; i++)
1484 {
1485 drawgfx(bitmap,Machine->gfx[bank],
1486 i+firstdrawn,color, /*sprite num, color*/
1487 flipx,flipy,
1488 (i % cpx) * Machine->gfx[bank]->width + Machine->uixmin,
1489 Machine->uifontheight + (i / cpx) * Machine->gfx[bank]->height + Machine->uiymin,
1490 0,Machine->gfx[bank]->colortable ? TRANSPARENCY_NONE : TRANSPARENCY_NONE_RAW,0);
1491
1492 lastdrawn = i+firstdrawn;
1493 }
1494
1495 switch_true_orientation(bitmap);
1496
1497 sprintf(buf,"GFXSET %d COLOR %2X CODE %X-%X",bank,color,firstdrawn,lastdrawn);
1498 ui_text(bitmap,buf,0,0);
1499 changed = 0;
1500 }
1501
1502 break;
1503 }
1504 case 2: /* Tilemaps */
1505 {
1506 if (changed)
1507 {
1508 UINT32 tilemap_width, tilemap_height;
1509 tilemap_nb_size (bank, &tilemap_width, &tilemap_height);
1510 while (tilemap_xpos < 0)
1511 tilemap_xpos += tilemap_width;
1512 tilemap_xpos %= tilemap_width;
1513
1514 while (tilemap_ypos < 0)
1515 tilemap_ypos += tilemap_height;
1516 tilemap_ypos %= tilemap_height;
1517
1518 erase_screen(bitmap);
1519 tilemap_nb_draw (bitmap, bank, tilemap_xpos, tilemap_ypos);
1520 sprintf(buf, "TILEMAP %d (%dx%d) X:%d Y:%d", bank, tilemap_width, tilemap_height, tilemap_xpos, tilemap_ypos);
1521 ui_text(bitmap,buf,0,0);
1522 changed = 0;
1523 skip_tmap = 0;
1524 }
1525 break;
1526 }
1527 }
1528
1529 update_video_and_audio();
1530
1531 #ifdef MAME32JP
1532 quit = input_ui_pressed(IPT_UI_SHOW_GFX) | input_ui_pressed(IPT_UI_CANCEL) | osd_quit_window();
1533 #endif
1534
1535 if (code_pressed(KEYCODE_LCONTROL) || code_pressed(KEYCODE_RCONTROL))
1536 {
1537 skip_chars = cpx;
1538 skip_tmap = 8;
1539 }
1540 if (code_pressed(KEYCODE_LSHIFT) || code_pressed(KEYCODE_RSHIFT))
1541 {
1542 skip_chars = 1;
1543 skip_tmap = 1;
1544 }
1545
1546
1547 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
1548 {
1549 int next_bank, next_mode;
1550 int jumped;
1551
1552 next_mode = mode;
1553 next_bank = bank+1;
1554 do {
1555 jumped = 0;
1556 switch (next_mode)
1557 {
1558 case 0:
1559 if (next_bank == 2 || Machine->drv->color_table_len == 0)
1560 {
1561 jumped = 1;
1562 next_mode++;
1563 next_bank = 0;
1564 }
1565 break;
1566 case 1:
1567 if (next_bank == MAX_GFX_ELEMENTS || !Machine->gfx[next_bank])
1568 {
1569 jumped = 1;
1570 next_mode++;
1571 next_bank = 0;
1572 }
1573 break;
1574 case 2:
1575 if (next_bank == tilemap_count())
1576 next_mode = -1;
1577 break;
1578 }
1579 } while (jumped);
1580 if (next_mode != -1 )
1581 {
1582 bank = next_bank;
1583 mode = next_mode;
1584 // firstdrawn = 0;
1585 changed = 1;
1586 }
1587 }
1588
1589 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
1590 {
1591 int next_bank, next_mode;
1592
1593 next_mode = mode;
1594 next_bank = bank-1;
1595 while(next_bank < 0 && next_mode >= 0)
1596 {
1597 next_mode = next_mode - 1;
1598 switch (next_mode)
1599 {
1600 case 0:
1601 if (Machine->drv->color_table_len == 0)
1602 next_bank = 0;
1603 else
1604 next_bank = 1;
1605 break;
1606 case 1:
1607 next_bank = MAX_GFX_ELEMENTS-1;
1608 while (next_bank >= 0 && !Machine->gfx[next_bank])
1609 next_bank--;
1610 break;
1611 case 2:
1612 next_bank = tilemap_count() - 1;
1613 break;
1614 }
1615 }
1616 if (next_mode != -1 )
1617 {
1618 bank = next_bank;
1619 mode = next_mode;
1620 // firstdrawn = 0;
1621 changed = 1;
1622 }
1623 }
1624
1625 if (code_pressed_memory_repeat(KEYCODE_PGDN,4))
1626 {
1627 switch (mode)
1628 {
1629 case 0:
1630 {
1631 if (256 * (palpage + 1) < total_colors)
1632 {
1633 palpage++;
1634 changed = 1;
1635 }
1636 break;
1637 }
1638 case 1:
1639 {
1640 if (firstdrawn + skip_chars < Machine->gfx[bank]->total_elements)
1641 {
1642 firstdrawn += skip_chars;
1643 changed = 1;
1644 }
1645 break;
1646 }
1647 case 2:
1648 {
1649 if (skip_tmap)
1650 tilemap_ypos -= skip_tmap;
1651 else
1652 tilemap_ypos -= bitmap->height/4;
1653 changed = 1;
1654 break;
1655 }
1656 }
1657 }
1658
1659 if (code_pressed_memory_repeat(KEYCODE_PGUP,4))
1660 {
1661 switch (mode)
1662 {
1663 case 0:
1664 {
1665 if (palpage > 0)
1666 {
1667 palpage--;
1668 changed = 1;
1669 }
1670 break;
1671 }
1672 case 1:
1673 {
1674 firstdrawn -= skip_chars;
1675 if (firstdrawn < 0) firstdrawn = 0;
1676 changed = 1;
1677 break;
1678 }
1679 case 2:
1680 {
1681 if (skip_tmap)
1682 tilemap_ypos += skip_tmap;
1683 else
1684 tilemap_ypos += bitmap->height/4;
1685 changed = 1;
1686 break;
1687 }
1688 }
1689 }
1690
1691 if (code_pressed_memory_repeat(KEYCODE_D,4))
1692 {
1693 switch (mode)
1694 {
1695 case 2:
1696 {
1697 if (skip_tmap)
1698 tilemap_xpos -= skip_tmap;
1699 else
1700 tilemap_xpos -= bitmap->width/4;
1701 changed = 1;
1702 break;
1703 }
1704 }
1705 }
1706
1707 if (code_pressed_memory_repeat(KEYCODE_G,4))
1708 {
1709 switch (mode)
1710 {
1711 case 2:
1712 {
1713 if (skip_tmap)
1714 tilemap_xpos += skip_tmap;
1715 else
1716 tilemap_xpos += bitmap->width/4;
1717 changed = 1;
1718 break;
1719 }
1720 }
1721 }
1722
1723 if (input_ui_pressed_repeat(IPT_UI_UP,6))
1724 {
1725 switch (mode)
1726 {
1727 case 1:
1728 {
1729 if (color < Machine->gfx[bank]->total_colors - 1)
1730 {
1731 color++;
1732 changed = 1;
1733 }
1734 break;
1735 }
1736 }
1737 }
1738
1739 if (input_ui_pressed_repeat(IPT_UI_DOWN,6))
1740 {
1741 switch (mode)
1742 {
1743 case 0:
1744 break;
1745 case 1:
1746 {
1747 if (color > 0)
1748 {
1749 color--;
1750 changed = 1;
1751 }
1752 }
1753 }
1754 }
1755
1756 if (input_ui_pressed(IPT_UI_SNAPSHOT))
1757 osd_save_snapshot(bitmap);
1758 #ifdef MAME32JP
1759 } while (!quit);
1760 #else
1761 } while (!input_ui_pressed(IPT_UI_SHOW_GFX) &&
1762 !input_ui_pressed(IPT_UI_CANCEL));
1763 #endif
1764
1765 schedule_full_refresh();
1766 }
1767
1768
1769
1770 static int setdipswitches(struct mame_bitmap *bitmap,int selected)
1771 {
1772 const char *menu_item[128];
1773 const char *menu_subitem[128];
1774 struct InputPort *entry[128];
1775 char flag[40];
1776 int i,sel;
1777 struct InputPort *in;
1778 int total;
1779 int arrowize;
1780
1781
1782 sel = selected - 1;
1783
1784
1785 in = Machine->input_ports;
1786
1787 total = 0;
1788 while (in->type != IPT_END)
1789 {
1790 if ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_NAME && input_port_name(in) != 0 &&
1791 (in->type & IPF_UNUSED) == 0 &&
1792 !(!options.cheat && (in->type & IPF_CHEAT)))
1793 {
1794 entry[total] = in;
1795 menu_item[total] = input_port_name(in);
1796
1797 total++;
1798 }
1799
1800 in++;
1801 }
1802
1803 if (total == 0) return 0;
1804
1805 menu_item[total] = ui_getstring (UI_returntomain);
1806 menu_item[total + 1] = 0; /* terminate array */
1807 total++;
1808
1809
1810 for (i = 0;i < total;i++)
1811 {
1812 flag[i] = 0; /* TODO: flag the dip if it's not the real default */
1813 if (i < total - 1)
1814 {
1815 in = entry[i] + 1;
1816 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1817 in->default_value != entry[i]->default_value)
1818 in++;
1819
1820 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1821 menu_subitem[i] = ui_getstring (UI_INVALID);
1822 else menu_subitem[i] = input_port_name(in);
1823 }
1824 else menu_subitem[i] = 0; /* no subitem */
1825 }
1826
1827 arrowize = 0;
1828 if (sel < total - 1)
1829 {
1830 in = entry[sel] + 1;
1831 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1832 in->default_value != entry[sel]->default_value)
1833 in++;
1834
1835 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1836 /* invalid setting: revert to a valid one */
1837 arrowize |= 1;
1838 else
1839 {
1840 if (((in-1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1841 !(!options.cheat && ((in-1)->type & IPF_CHEAT)))
1842 arrowize |= 1;
1843 }
1844 }
1845 if (sel < total - 1)
1846 {
1847 in = entry[sel] + 1;
1848 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1849 in->default_value != entry[sel]->default_value)
1850 in++;
1851
1852 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1853 /* invalid setting: revert to a valid one */
1854 arrowize |= 2;
1855 else
1856 {
1857 if (((in+1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1858 !(!options.cheat && ((in+1)->type & IPF_CHEAT)))
1859 arrowize |= 2;
1860 }
1861 }
1862
1863 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel,arrowize);
1864
1865 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
1866 sel = (sel + 1) % total;
1867
1868 if (input_ui_pressed_repeat(IPT_UI_UP,8))
1869 sel = (sel + total - 1) % total;
1870
1871 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
1872 {
1873 if (sel < total - 1)
1874 {
1875 in = entry[sel] + 1;
1876 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1877 in->default_value != entry[sel]->default_value)
1878 in++;
1879
1880 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1881 /* invalid setting: revert to a valid one */
1882 entry[sel]->default_value = (entry[sel]+1)->default_value & entry[sel]->mask;
1883 else
1884 {
1885 if (((in+1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1886 !(!options.cheat && ((in+1)->type & IPF_CHEAT)))
1887 entry[sel]->default_value = (in+1)->default_value & entry[sel]->mask;
1888 }
1889
1890 /* tell updatescreen() to clean after us (in case the window changes size) */
1891 schedule_full_refresh();
1892 }
1893 }
1894
1895 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
1896 {
1897 if (sel < total - 1)
1898 {
1899 in = entry[sel] + 1;
1900 while ((in->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1901 in->default_value != entry[sel]->default_value)
1902 in++;
1903
1904 if ((in->type & ~IPF_MASK) != IPT_DIPSWITCH_SETTING)
1905 /* invalid setting: revert to a valid one */
1906 entry[sel]->default_value = (entry[sel]+1)->default_value & entry[sel]->mask;
1907 else
1908 {
1909 if (((in-1)->type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING &&
1910 !(!options.cheat && ((in-1)->type & IPF_CHEAT)))
1911 entry[sel]->default_value = (in-1)->default_value & entry[sel]->mask;
1912 }
1913
1914 /* tell updatescreen() to clean after us (in case the window changes size) */
1915 schedule_full_refresh();
1916 }
1917 }
1918
1919 if (input_ui_pressed(IPT_UI_SELECT))
1920 {
1921 if (sel == total - 1) sel = -1;
1922 }
1923
1924 if (input_ui_pressed(IPT_UI_CANCEL))
1925 sel = -1;
1926
1927 if (input_ui_pressed(IPT_UI_CONFIGURE))
1928 sel = -2;
1929
1930 if (sel == -1 || sel == -2)
1931 {
1932 schedule_full_refresh();
1933 }
1934
1935 return sel + 1;
1936 }
1937
1938 /* This flag is used for record OR sequence of key/joy */
1939 /* when is !=0 the first sequence is record, otherwise the first free */
1940 /* it's used byt setdefkeysettings, setdefjoysettings, setkeysettings, setjoysettings */
1941 static int record_first_insert = 1;
1942
1943 static char menu_subitem_buffer[400][96];
1944
1945 static int setdefcodesettings(struct mame_bitmap *bitmap,int selected)
1946 {
1947 const char *menu_item[400];
1948 const char *menu_subitem[400];
1949 struct ipd *entry[400];
1950 char flag[400];
1951 int i,sel;
1952 struct ipd *in;
1953 int total;
1954 extern struct ipd inputport_defaults[];
1955
1956 sel = selected - 1;
1957
1958
1959 if (Machine->input_ports == 0)
1960 return 0;
1961
1962 in = inputport_defaults;
1963
1964 total = 0;
1965 while (in->type != IPT_END)
1966 {
1967 if (in->name != 0 && (in->type & ~IPF_MASK) != IPT_UNKNOWN && (in->type & ~IPF_MASK) != IPT_OSD_RESERVED && (in->type & IPF_UNUSED) == 0
1968 && !(!options.cheat && (in->type & IPF_CHEAT)))
1969 {
1970 entry[total] = in;
1971 menu_item[total] = in->name;
1972
1973 total++;
1974 }
1975
1976 in++;
1977 }
1978
1979 if (total == 0) return 0;
1980
1981 menu_item[total] = ui_getstring (UI_returntomain);
1982 menu_item[total + 1] = 0; /* terminate array */
1983 total++;
1984
1985 for (i = 0;i < total;i++)
1986 {
1987 if (i < total - 1)
1988 {
1989 seq_name(&entry[i]->seq,menu_subitem_buffer[i],sizeof(menu_subitem_buffer[0]));
1990 menu_subitem[i] = menu_subitem_buffer[i];
1991 } else
1992 menu_subitem[i] = 0; /* no subitem */
1993 flag[i] = 0;
1994 }
1995
1996 if (sel > SEL_MASK) /* are we waiting for a new key? */
1997 {
1998 int ret;
1999
2000 menu_subitem[sel & SEL_MASK] = " ";
2001 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel & SEL_MASK,3);
2002
2003 ret = seq_read_async(&entry[sel & SEL_MASK]->seq,record_first_insert);
2004
2005 if (ret >= 0)
2006 {
2007 sel &= 0xff;
2008
2009 if (ret > 0 || seq_get_1(&entry[sel]->seq) == CODE_NONE)
2010 {
2011 seq_set_1(&entry[sel]->seq,CODE_NONE);
2012 ret = 1;
2013 }
2014
2015 /* tell updatescreen() to clean after us (in case the window changes size) */
2016 schedule_full_refresh();
2017
2018 record_first_insert = ret != 0;
2019 }
2020
2021
2022 return sel + 1;
2023 }
2024
2025
2026 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel,0);
2027
2028 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
2029 {
2030 sel = (sel + 1) % total;
2031 record_first_insert = 1;
2032 }
2033
2034 if (input_ui_pressed_repeat(IPT_UI_UP,8))
2035 {
2036 sel = (sel + total - 1) % total;
2037 record_first_insert = 1;
2038 }
2039
2040 if (input_ui_pressed(IPT_UI_SELECT))
2041 {
2042 if (sel == total - 1) sel = -1;
2043 else
2044 {
2045 seq_read_async_start();
2046
2047 sel |= 1 << SEL_BITS; /* we'll ask for a key */
2048
2049 /* tell updatescreen() to clean after us (in case the window changes size) */
2050 schedule_full_refresh();
2051 }
2052 }
2053
2054 if (input_ui_pressed(IPT_UI_CANCEL))
2055 sel = -1;
2056
2057 if (input_ui_pressed(IPT_UI_CONFIGURE))
2058 sel = -2;
2059
2060 if (sel == -1 || sel == -2)
2061 {
2062 /* tell updatescreen() to clean after us */
2063 schedule_full_refresh();
2064
2065 record_first_insert = 1;
2066 }
2067
2068 return sel + 1;
2069 }
2070
2071
2072
2073 static int setcodesettings(struct mame_bitmap *bitmap,int selected)
2074 {
2075 const char *menu_item[400];
2076 const char *menu_subitem[400];
2077 struct InputPort *entry[400];
2078 char flag[400];
2079 int i,sel;
2080 struct InputPort *in;
2081 int total;
2082
2083
2084 sel = selected - 1;
2085
2086
2087 if (Machine->input_ports == 0)
2088 return 0;
2089
2090 in = Machine->input_ports;
2091
2092 total = 0;
2093 while (in->type != IPT_END)
2094 {
2095 if (input_port_name(in) != 0 && seq_get_1(&in->seq) != CODE_NONE && (in->type & ~IPF_MASK) != IPT_UNKNOWN && (in->type & ~IPF_MASK) != IPT_OSD_RESERVED)
2096 {
2097 entry[total] = in;
2098 menu_item[total] = input_port_name(in);
2099
2100 total++;
2101 }
2102
2103 in++;
2104 }
2105
2106 if (total == 0) return 0;
2107
2108 menu_item[total] = ui_getstring (UI_returntomain);
2109 menu_item[total + 1] = 0; /* terminate array */
2110 total++;
2111
2112 for (i = 0;i < total;i++)
2113 {
2114 if (i < total - 1)
2115 {
2116 seq_name(input_port_seq(entry[i]),menu_subitem_buffer[i],sizeof(menu_subitem_buffer[0]));
2117 menu_subitem[i] = menu_subitem_buffer[i];
2118
2119 /* If the key isn't the default, flag it */
2120 if (seq_get_1(&entry[i]->seq) != CODE_DEFAULT)
2121 flag[i] = 1;
2122 else
2123 flag[i] = 0;
2124
2125 } else
2126 menu_subitem[i] = 0; /* no subitem */
2127 }
2128
2129 if (sel > SEL_MASK) /* are we waiting for a new key? */
2130 {
2131 int ret;
2132
2133 menu_subitem[sel & SEL_MASK] = " ";
2134 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel & SEL_MASK,3);
2135
2136 ret = seq_read_async(&entry[sel & SEL_MASK]->seq,record_first_insert);
2137
2138 if (ret >= 0)
2139 {
2140 sel &= 0xff;
2141
2142 if (ret > 0 || seq_get_1(&entry[sel]->seq) == CODE_NONE)
2143 {
2144 seq_set_1(&entry[sel]->seq, CODE_DEFAULT);
2145 ret = 1;
2146 }
2147
2148 /* tell updatescreen() to clean after us (in case the window changes size) */
2149 schedule_full_refresh();
2150
2151 record_first_insert = ret != 0;
2152 }
2153
2154 return sel + 1;
2155 }
2156
2157
2158 ui_displaymenu(bitmap,menu_item,menu_subitem,flag,sel,0);
2159
2160 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
2161 {
2162 sel = (sel + 1) % total;
2163 record_first_insert = 1;
2164 }
2165
2166 if (input_ui_pressed_repeat(IPT_UI_UP,8))
2167 {
2168 sel = (sel + total - 1) % total;
2169 record_first_insert = 1;
2170 }
2171
2172 if (input_ui_pressed(IPT_UI_SELECT))
2173 {
2174 if (sel == total - 1) sel = -1;
2175 else
2176 {
2177 seq_read_async_start();
2178
2179 sel |= 1 << SEL_BITS; /* we'll ask for a key */
2180
2181 /* tell updatescreen() to clean after us (in case the window changes size) */
2182 schedule_full_refresh();
2183 }
2184 }
2185
2186 if (input_ui_pressed(IPT_UI_CANCEL))
2187 sel = -1;
2188
2189 if (input_ui_pressed(IPT_UI_CONFIGURE))
2190 sel = -2;
2191
2192 if (sel == -1 || sel == -2)
2193 {
2194 schedule_full_refresh();
2195
2196 record_first_insert = 1;
2197 }
2198
2199 return sel + 1;
2200 }
2201
2202
2203 #ifdef MAME32JP
2204 static int setautofiresettings(struct mame_bitmap *bitmap,int selected)
2205 {
2206 const char *menu_item[400];
2207 const char *menu_subitem[400];
2208 struct InputPort *entry[400];
2209 struct InputPort *in;
2210 char delay[4];
2211 int sel;
2212 int total;
2213 int autofire_delay;
2214 int value = 0;
2215 int changed = 0;
2216
2217 sel = selected - 1;
2218
2219 if (sel < 0) sel = 0;
2220
2221 total = 0;
2222
2223 if (Machine->input_ports)
2224 {
2225 in = Machine->input_ports;
2226
2227 while (in->type != IPT_END)
2228 {
2229 if (input_port_name(in)
2230 && (in->type & ~IPF_MASK) > IPT_PORT
2231 && (in->type & ~IPF_MASK) < IPT_ANALOG_START)
2232 {
2233 int v;
2234
2235 entry[total] = in;
2236
2237 v = (in->type & IPF_AUTOFIRE_MASK) >> IPF_AUTOFIRE_SHIFT;
2238 menu_item[total] = input_port_name(in);
2239 menu_subitem[total] = ui_getstring(UI_autofireoff + v);
2240 if (total == sel)
2241 value = v;
2242 total++;
2243 }
2244 in++;
2245 }
2246 }
2247
2248 if (total == 0)
2249 return 0;
2250
2251 sprintf(delay, "%d", options.autofiredelay);
2252 autofire_delay = total;
2253
2254 menu_item[total] = ui_getstring(UI_autofiredelay);
2255 menu_subitem[total++] = delay;
2256 menu_item[total] = ui_getstring (UI_returntomain);
2257 menu_subitem[total++] = 0;
2258 menu_item[total] = 0;
2259
2260 ui_displaymenu(bitmap,menu_item,menu_subitem,0,sel,0);
2261
2262 if (sel == autofire_delay)
2263 {
2264 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
2265 {
2266 options.autofiredelay++;
2267 if (options.autofiredelay > 99)
2268 options.autofiredelay = 99;
2269 changed = 1;
2270 }
2271 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
2272 {
2273 options.autofiredelay--;
2274 if (options.autofiredelay < 1)
2275 options.autofiredelay = 1;
2276 changed = 1;
2277 }
2278 }
2279 else if (sel < autofire_delay)
2280 {
2281 UINT32 type = entry[sel]->type & ~IPF_AUTOFIRE_MASK;
2282
2283 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
2284 {
2285 if (++value > 2) value = 0;
2286 changed = 1;
2287 }
2288 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
2289 {
2290 if (--value < 0) value = 2;
2291 changed = 1;
2292 }
2293 entry[sel]->type = type | (value << IPF_AUTOFIRE_SHIFT);
2294 }
2295
2296 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
2297 sel = (sel + 1) % total;
2298
2299 if (input_ui_pressed_repeat(IPT_UI_UP,8))
2300 sel = (sel + total - 1) % total;
2301
2302 if (input_ui_pressed(IPT_UI_SELECT))
2303 {
2304 if (sel == total - 1) sel = -1;
2305 else sel = 0;
2306 }
2307
2308 if (input_ui_pressed(IPT_UI_CANCEL))
2309 sel = -1;
2310
2311 if (input_ui_pressed(IPT_UI_CONFIGURE))
2312 sel = -2;
2313
2314 if (sel == -1 || sel == -2 || changed)
2315 schedule_full_refresh();
2316
2317 return sel + 1;
2318 }
2319
2320 static int setjoystickidsettings(struct mame_bitmap *bitmap,int selected)
2321 {
2322 const char *menu_item[8];
2323 const char *menu_subitem[8];
2324 int i, sel, total;
2325 static int joyid[4] = { -2, 1, 2, 3 };
2326 char numbuf[4][256];
2327
2328 sel = selected - 1;
2329
2330 total = 0;
2331
2332 if (joyid[0] == -2)
2333 osd_joystick_get_device_numbers(joyid);
2334
2335 for (i = 0; i < 4; i++)
2336 {
2337 menu_item[total] = ui_getstring(UI_player1 + i);
2338 if (joyid[i] != -1)
2339 sprintf(numbuf[i], "ID:%d - %s", joyid[i] + 1, osd_joystick_get_device_name(joyid[i]));
2340 else
2341 sprintf(numbuf[i], "ID:?? - %s", ui_getstring(UI_joynotatached));
2342 menu_subitem[total] = numbuf[i];
2343 total++;
2344 }
2345 menu_item[total] = ui_getstring(UI_returntomain);
2346 menu_subitem[total] = 0;
2347 menu_item[total + 1] = 0;
2348 total++;
2349
2350 ui_displaymenu(bitmap, menu_item, menu_subitem, 0, sel, 0);
2351
2352 if (sel >= 0 && sel < 4)
2353 {
2354 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
2355 {
2356 if (joyid[sel] < (4 * options.use_joystick) - 1)
2357 joyid[sel]++;
2358 schedule_full_refresh();
2359 }
2360
2361 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
2362 {
2363 if (joyid[sel] > 0)
2364 joyid[sel]--;
2365 schedule_full_refresh();
2366 }
2367 }
2368
2369 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
2370 sel = (sel + 1) % total;
2371
2372 if (input_ui_pressed_repeat(IPT_UI_UP,8))
2373 sel = (sel + total - 1) % total;
2374
2375 if (input_ui_pressed(IPT_UI_SELECT))
2376 {
2377 if (sel == total - 1)
2378 {
2379 osd_joystick_set_device_numbers(joyid);
2380 joyid[0] = -2;
2381 sel = -1;
2382 }
2383 }
2384
2385 if (input_ui_pressed(IPT_UI_CANCEL))
2386 sel = -1;
2387
2388 if (input_ui_pressed(IPT_UI_CONFIGURE))
2389 sel = -2;
2390
2391 if (sel == -1 || sel == -2)
2392 {
2393 schedule_full_refresh();
2394 joyid[0] = -2;
2395
2396 record_first_insert = 1;
2397 }
2398
2399 return sel + 1;
2400 }
2401 #else
2402 static int calibratejoysticks(struct mame_bitmap *bitmap,int selected)
2403 {
2404 const char *msg;
2405 static char buf[2048];
2406 int sel;
2407 static int calibration_started = 0;
2408
2409 sel = selected - 1;
2410
2411 if (calibration_started == 0)
2412 {
2413 osd_joystick_start_calibration();
2414 calibration_started = 1;
2415 strcpy (buf, "");
2416 }
2417
2418 if (sel > SEL_MASK) /* Waiting for the user to acknowledge joystick movement */
2419 {
2420 if (input_ui_pressed(IPT_UI_CANCEL))
2421 {
2422 calibration_started = 0;
2423 sel = -1;
2424 }
2425 else if (input_ui_pressed(IPT_UI_SELECT))
2426 {
2427 osd_joystick_calibrate();
2428 sel &= 0xff;
2429 }
2430
2431 ui_displaymessagewindow(bitmap,buf);
2432 }
2433 else
2434 {
2435 msg = osd_joystick_calibrate_next();
2436 schedule_full_refresh();
2437 if (msg == 0)
2438 {
2439 calibration_started = 0;
2440 osd_joystick_end_calibration();
2441 sel = -1;
2442 }
2443 else
2444 {
2445 strcpy (buf, msg);
2446 ui_displaymessagewindow(bitmap,buf);
2447 sel |= 1 << SEL_BITS;
2448 }
2449 }
2450
2451 if (input_ui_pressed(IPT_UI_CONFIGURE))
2452 sel = -2;
2453
2454 if (sel == -1 || sel == -2)
2455 {
2456 schedule_full_refresh();
2457 }
2458
2459 return sel + 1;
2460 }
2461 #endif
2462
2463
2464 static int settraksettings(struct mame_bitmap *bitmap,int selected)
2465 {
2466 const char *menu_item[40];
2467 const char *menu_subitem[40];
2468 struct InputPort *entry[40];
2469 int i,sel;
2470 struct InputPort *in;
2471 int total,total2;
2472 int arrowize;
2473
2474
2475 sel = selected - 1;
2476
2477
2478 if (Machine->input_ports == 0)
2479 return 0;
2480
2481 in = Machine->input_ports;
2482
2483 /* Count the total number of analog controls */
2484 total = 0;
2485 while (in->type != IPT_END)
2486 {
2487 if (((in->type & 0xff) > IPT_ANALOG_START) && ((in->type & 0xff) < IPT_ANALOG_END)
2488 && !(!options.cheat && (in->type & IPF_CHEAT)))
2489 {
2490 entry[total] = in;
2491 total++;
2492 }
2493 in++;
2494 }
2495
2496 if (total == 0) return 0;
2497
2498 /* Each analog control has 3 entries - key & joy delta, reverse, sensitivity */
2499
2500 #define ENTRIES 3
2501
2502 total2 = total * ENTRIES;
2503
2504 menu_item[total2] = ui_getstring (UI_returntomain);
2505 menu_item[total2 + 1] = 0; /* terminate array */
2506 total2++;
2507
2508 arrowize = 0;
2509 for (i = 0;i < total2;i++)
2510 {
2511 if (i < total2 - 1)
2512 {
2513 char label[30][40];
2514 char setting[30][40];
2515 int sensitivity,delta;
2516 int reverse;
2517
2518 strcpy (label[i], input_port_name(entry[i/ENTRIES]));
2519 sensitivity = IP_GET_SENSITIVITY(entry[i/ENTRIES]);
2520 delta = IP_GET_DELTA(entry[i/ENTRIES]);
2521 reverse = (entry[i/ENTRIES]->type & IPF_REVERSE);
2522
2523 strcat (label[i], " ");
2524 switch (i%ENTRIES)
2525 {
2526 case 0:
2527 strcat (label[i], ui_getstring (UI_keyjoyspeed));
2528 sprintf(setting[i],"%d",delta);
2529 if (i == sel) arrowize = 3;
2530 break;
2531 case 1:
2532 strcat (label[i], ui_getstring (UI_reverse));
2533 if (reverse)
2534 sprintf(setting[i],ui_getstring (UI_on));
2535 else
2536 sprintf(setting[i],ui_getstring (UI_off));
2537 if (i == sel) arrowize = 3;
2538 break;
2539 case 2:
2540 strcat (label[i], ui_getstring (UI_sensitivity));
2541 sprintf(setting[i],"%3d%%",sensitivity);
2542 if (i == sel) arrowize = 3;
2543 break;
2544 }
2545
2546 menu_item[i] = label[i];
2547 menu_subitem[i] = setting[i];
2548
2549 in++;
2550 }
2551 else menu_subitem[i] = 0; /* no subitem */
2552 }
2553
2554 ui_displaymenu(bitmap,menu_item,menu_subitem,0,sel,arrowize);
2555
2556 if (input_ui_pressed_repeat(IPT_UI_DOWN,8))
2557 sel = (sel + 1) % total2;
2558
2559 if (input_ui_pressed_repeat(IPT_UI_UP,8))
2560 sel = (sel + total2 - 1) % total2;
2561
2562 if (input_ui_pressed_repeat(IPT_UI_LEFT,8))
2563 {
2564 if(sel != total2 - 1)
2565 {
2566 if ((sel % ENTRIES) == 0)
2567 /* keyboard/joystick delta */
2568 {
2569 int val = IP_GET_DELTA(entry[sel/ENTRIES]);
2570
2571 val --;
2572 if (val < 1) val = 1;
2573 IP_SET_DELTA(entry[sel/ENTRIES],val);
2574 }
2575 else if ((sel % ENTRIES) == 1)
2576 /* reverse */
2577 {
2578 int reverse = entry[sel/ENTRIES]->type & IPF_REVERSE;
2579 if (reverse)
2580 reverse=0;
2581 else
2582 reverse=IPF_REVERSE;
2583 entry[sel/ENTRIES]->type &= ~IPF_REVERSE;
2584 entry[sel/ENTRIES]->type |= reverse;
2585 }
2586 else if ((sel % ENTRIES) == 2)
2587 /* sensitivity */
2588 {
2589 int val = IP_GET_SENSITIVITY(entry[sel/ENTRIES]);
2590
2591 val --;
2592 if (val < 1) val = 1;
2593 IP_SET_SENSITIVITY(entry[sel/ENTRIES],val);
2594 }
2595 }
2596 }
2597
2598 if (input_ui_pressed_repeat(IPT_UI_RIGHT,8))
2599 {
2600 if(sel != total2 - 1)
2601 {
2602 if ((sel % ENTRIES) == 0)
2603 /* keyboard/joystick delta */
2604 {
2605 int val = IP_GET_DELTA(entry[sel/ENTRIES]);
2606
2607 val ++;
2608 if (val > 255) val = 255;
2609 IP_SET_DELTA(entry[sel/ENTRIES],val);
2610 }
2611 else if ((sel % ENTRIES) == 1)
2612 /* reverse */
2613 {
2614 int reverse = entry[sel/ENTRIES]->type & IPF_REVERSE;
2615 if (reverse)
2616 reverse=0;
2617 else
2618 reverse=IPF_REVERSE;
2619 entry[sel/ENTRIES]->type &= ~IPF_REVERSE;
2620 entry[sel/ENTRIES]->type |= reverse;
2621 }
2622 else if ((sel % ENTRIES) == 2)
2623 /* sensitivity */
2624 {
2625 int val = IP_GET_SENSITIVITY(entry[sel/ENTRIES]);
2626
2627 val ++;
2628 if (val > 255) val = 255;
2629 IP_SET_SENSITIVITY(entry[sel/ENTRIES],val);
2630 }
2631 }
2632 }
2633
2634 if (input_ui_pressed(IPT_UI_SELECT))
2635 {
2636 if (sel == total2 - 1) sel = -1;
2637 }
2638
2639 if (input_ui_pressed(IPT_UI_CANCEL))
2640 sel = -1;
2641
2642 if (input_ui_pressed(IPT_UI_CONFIGURE))
2643 sel = -2;
2644
2645 if (sel == -1 || sel == -2)
2646 {
2647 schedule_full_refresh();
2648 }
2649
2650 return sel + 1;
2651 }
2652
2653 #ifndef MESS
2654 static int mame_stats(struct mame_bitmap *bitmap,int selected)
2655 {
2656 char temp[10];
2657 char buf[2048];
2658 int sel, i;
2659
2660
2661 sel = selected - 1;
2662
2663 buf[0] = 0;
2664
2665 if (dispensed_tickets)
2666 {
2667 strcat(buf, ui_getstring (UI_tickets));
2668 strcat(buf, ": ");
2669 sprintf(temp, "%d\n\n", dispensed_tickets);
2670 strcat(buf, temp);
2671 }
2672
2673 for (i=0; i<COIN_COUNTERS; i++)
2674 {
2675 strcat(buf, ui_getstring (UI_coin));
2676 sprintf(temp, " %c: ", i+'A');
2677 strcat(buf, temp);
2678 if (!coins[i])
2679 strcat (buf, ui_getstring (UI_NA));
2680 else
2681 {
2682 sprintf (temp, "%d", coins[i]);
2683 strcat (buf, temp);
2684 }
2685 if (coinlockedout[i])
2686 {
2687 strcat(buf, " ");
2688 strcat(buf, ui_getstring (UI_locked));
2689 strcat(buf, "\n");
2690 }
2691 else
2692 {
2693 strcat(buf, "\n");
2694 }
2695 }
2696
2697 {
2698 #ifdef MAME32JP
2699 int res;
2700 #endif
2701
2702 /* menu system, use the normal menu keys */
2703 strcat(buf,"\n\t");
2704 strcat(buf,ui_getstring (UI_lefthilight));
2705 strcat(buf," ");
2706 strcat(buf,ui_getstring (UI_returntomain));
2707 strcat(buf," ");
2708 strcat(buf,ui_getstring (UI_righthilight));
2709
2710 #ifdef MAME32JP
2711 res = ui_displaymessagewindow(bitmap,buf);
2712 if (res != -1)
2713 {
2714 if (res == 1 || input_ui_pressed(IPT_UI_SELECT))
2715 sel = -1;
2716
2717 if (res == 2 || input_ui_pressed(IPT_UI_CANCEL))
2718 sel = -1;
2719
2720 if (res == 3 || input_ui_pressed(IPT_UI_CONFIGURE))
2721 sel = -2;
2722 }
2723 #else
2724 ui_displaymessagewindow(bitmap,buf);
2725
2726 if (input_ui_pressed(IPT_UI_SELECT))
2727 sel = -1;
2728
2729 if (input_ui_pressed(IPT_UI_CANCEL))
2730 sel = -1;
2731
2732 if (input_ui_pressed(IPT_UI_CONFIGURE))
2733 sel = -2;
2734 #endif
2735 }
2736
2737 if (sel == -1 || sel == -2)
2738 {
2739 #ifdef MAME32JP
2740 scroll_reset = 1;
2741 #endif
2742 schedule_full_refresh();
2743 }
2744
2745 return sel + 1;
2746 }
2747 #endif
2748
2749 int showcopyright(struct mame_bitmap *bitmap)
2750 {
2751 #ifdef MAME32JP
2752 int done, res;
2753 #else
2754 int done;
2755 #endif
2756 char buf[1000];
2757 char buf2[256];
2758
2759 strcpy (buf, ui_getstring(UI_copyright1));
2760 strcat (buf, "\n\n");
2761 #ifdef MAME32JP
2762 sprintf(buf2, ui_getstring(UI_copyright2), GetDescriptionByName(Machine->gamedrv->name));
2763 #else
2764 sprintf(buf2, ui_getstring(UI_copyright2), Machine->gamedrv->description);
2765 #endif
2766 strcat (buf, buf2);