Previous 15994 Revisions Next

r6092 Thursday 15th October, 2009 at 13:41:46 UTC by Miodrag Milanović
Fixed MESSUI and listxml for messram
Fixed config for elf2
Removed unused files
[src/mess]compcfg.c compcfg.h infomess.c mess.h messcore.mak messdrv.h mesvalid.c
[src/mess/devices]messram.c messram.h multcart.c
[src/mess/drivers]elf.c
[src/mess/osd/winui]propertiesms.c
[src/mess/tools/messtest]testmess.c

src/mess/compcfg.c
r6091r6092
1#include <stdio.h>
2#include <ctype.h>
3#include <assert.h>
4
5#include "mame.h"
6#include "driver.h"
7#include "compcfg.h"
8
9#define MAX_RAM_OPTIONS   16
10
11static int get_ram_options(const game_driver *gamedrv, UINT32 *ram_options, int max_options, int *default_option)
12{
13   struct SystemConfigurationParamBlock params;
14
15   memset(&params, 0, sizeof(params));
16   params.max_ram_options = max_options;
17   params.ram_options = ram_options;
18
19   if (gamedrv->sysconfig_ctor)
20      gamedrv->sysconfig_ctor(&params);
21
22   if (default_option)
23      *default_option = params.default_ram_option;
24   return params.actual_ram_options;
25}
26
27
28
29UINT32 ram_option(const game_driver *gamedrv, unsigned int i)
30{
31   UINT32 ram_options[MAX_RAM_OPTIONS];
32   int ram_optcount;
33
34   ram_optcount = get_ram_options(gamedrv, ram_options, sizeof(ram_options) / sizeof(ram_options[0]), NULL);
35   return i >= ram_optcount ? 0 : ram_options[i];
36}
37
38
39
40UINT32 ram_default(const game_driver *gamedrv)
41{
42   UINT32 ram_options[MAX_RAM_OPTIONS];
43   int ram_optcount;
44   int default_ram_option;
45
46   ram_optcount = get_ram_options(gamedrv, ram_options, sizeof(ram_options) / sizeof(ram_options[0]), &default_ram_option);
47   return default_ram_option >= ram_optcount ? 0 : ram_options[default_ram_option];
48}
49
50
51
52int ram_option_count(const game_driver *gamedrv)
53{
54   UINT32 ram_options[MAX_RAM_OPTIONS];
55   return get_ram_options(gamedrv, ram_options, sizeof(ram_options) / sizeof(ram_options[0]), NULL);
56}
57
58
59
60int ram_is_valid_option(const game_driver *gamedrv, UINT32 ram)
61{
62   UINT32 ram_options[MAX_RAM_OPTIONS];
63   int ram_optcount;
64   int i;
65
66   ram_optcount = get_ram_options(gamedrv, ram_options, sizeof(ram_options) / sizeof(ram_options[0]), NULL);
67
68   for(i = 0; i < ram_optcount; i++)
69      if (ram_options[i] == ram)
70         return 1;
71   return 0;
72}
73
74
75
76UINT32 ram_parse_string(const char *s)
77{
78   UINT32 ram;
79   char suffix = '\0';
80
81   s += sscanf(s, "%u%c", &ram, &suffix);
82   switch(tolower(suffix)) {
83   case 'k':
84      /* kilobytes */
85      ram *= 1024;
86      break;
87
88   case 'm':
89      /* megabytes */
90      ram *= 1024*1024;
91      break;
92
93   case '\0':
94      /* no suffix */
95      break;
96
97   default:
98      /* parse failure */
99      ram = 0;
100      break;
101   }
102   return ram;
103}
104
105
106
107const char *ram_string(char *buffer, UINT32 ram)
108{
109   const char *suffix;
110
111   if ((ram % (1024*1024)) == 0)
112   {
113      ram /= 1024*1024;
114      suffix = "m";
115   }
116   else if ((ram % 1024) == 0)
117   {
118      ram /= 1024;
119      suffix = "k";
120   }
121   else
122   {
123      suffix = "";
124   }
125   sprintf(buffer, "%u%s", ram, suffix);
126   return buffer;
127}
128
129
130
131/* ----------------------------------------------------------------------- */
132
133#if 0
134/* NPW 25-Nov-2008 - Disabled in 0.128u4 */
135UINT8 *memory_install_ram8_handler(running_machine *machine, int cpunum, int spacenum, offs_t start, offs_t end, offs_t ram_offset, int bank)
136{
137   read8_space_func read_bank = (read8_space_func) (FPTR)(STATIC_BANK1 + bank - 1);
138   write8_space_func write_bank = (write8_space_func) (FPTR)(STATIC_BANK1 + bank - 1);
139   offs_t bank_size = end - start + 1;
140
141   memory_set_bankptr(machine, bank, mess_ram + ram_offset);
142
143   memory_install_read8_handler(machine, cpunum, spacenum, start,
144      MIN(end, start - ram_offset + mess_ram_size - 1), 0, 0, read_bank);
145   memory_install_write8_handler(machine, cpunum, spacenum, start,
146      MIN(end, start - ram_offset + mess_ram_size - 1), 0, 0, write_bank);
147
148   if (bank_size > (mess_ram_size - ram_offset))
149   {
150      memory_install_read8_handler(machine, cpunum, spacenum, start - ram_offset + mess_ram_size, end, 0, 0, SMH_ROM);
151      memory_install_write8_handler(machine, cpunum, spacenum, start - ram_offset + mess_ram_size, end, 0, 0, SMH_ROM);
152   }
153   return mess_ram + ram_offset;
154}
155#endif
156
src/mess/compcfg.h
r6091r6092
1/****************************************************************************
2
3   compcfg.h
4
5****************************************************************************/
6
7#ifndef COMPCFG_H
8#define COMPCFG_H
9
10/* RAM parsing options */
11UINT32      ram_option(const game_driver *gamedrv, unsigned int i);
12int         ram_option_count(const game_driver *gamedrv);
13int         ram_is_valid_option(const game_driver *gamedrv, UINT32 ram);
14UINT32      ram_default(const game_driver *gamedrv);
15UINT32      ram_parse_string(const char *s);
16const char *ram_string(char *buffer, UINT32 ram);
17
18UINT8 *memory_install_ram8_handler(running_machine *machine, int cpunum, int spacenum, offs_t start, offs_t end, offs_t ram_offset, int bank);
19
20#endif
src/mess/devices/messram.c
r6091r6092
5656    integer value
5757-------------------------------------------------*/
5858
59static UINT32 parse_string(const char *s)
59UINT32 ram_parse_string(const char *s)
6060{
6161   UINT32 ram;
6262   char suffix = '\0';
r6091r6092
8888   return ram;
8989}
9090
91const char *ram_string(char *buffer, UINT32 ram)
92{
93   const char *suffix;
9194
95   if ((ram % (1024*1024)) == 0)
96   {
97      ram /= 1024*1024;
98      suffix = "m";
99   }
100   else if ((ram % 1024) == 0)
101   {
102      ram /= 1024;
103      suffix = "k";
104   }
105   else
106   {
107      suffix = "";
108   }
109   sprintf(buffer, "%u%s", ram, suffix);
110   return buffer;
111}
112
113
92114/*****************************************************************************
93115    DEVICE INTERFACE
94116*****************************************************************************/
r6091r6092
104126      const char *ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
105127
106128      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
107         messram->size = parse_string(ramsize_string);
129         messram->size = ram_parse_string(ramsize_string);
108130   }
109131
110132   /* if we didn't get a size yet, use the default */
111133   if (messram->size == 0)
112      messram->size = parse_string(config->default_size);
134      messram->size = ram_parse_string(config->default_size);
113135
114136   /* allocate space for the ram */
115137   messram->ram = auto_alloc_array(device->machine, UINT8, messram->size);
r6091r6092
139161   int error = FALSE;
140162
141163   /* verify default ram value */
142   if (parse_string(config->default_size) == 0)
164   if (ram_parse_string(config->default_size) == 0)
143165   {
144166      mame_printf_error("%s: '%s' has an invalid default RAM option: %s\n", driver->source_file, driver->name, config->default_size);
145167      error = TRUE;
r6091r6092
168190      }
169191
170192      /* compare command line option to default value */
171      if (parse_string(config->default_size) == specified_ram)
193      if (ram_parse_string(config->default_size) == specified_ram)
172194         is_valid = TRUE;
173195   }
174196   else
r6091r6092
188210      /* try to parse each option */
189211      while(*s != '\0')
190212      {
191         UINT32 option_ram_size = parse_string(s);
213         UINT32 option_ram_size = ram_parse_string(s);
192214
193215         if (option_ram_size == 0)
194216         {
src/mess/devices/messram.h
r6091r6092
6969UINT32 messram_get_size(const device_config *device);
7070UINT8 *messram_get_ptr(const device_config *device);
7171void messram_dump(const device_config *device, const char *filename);
72UINT32 ram_parse_string(const char *s);
73const char *ram_string(char *buffer, UINT32 ram);
7274
73
7475#endif /* __MESSRAM_H__ */
src/mess/devices/multcart.c
r6091r6092
1212#include "corestr.h"
1313#include "xmlfile.h"
1414#include "driver.h"
15#include "compcfg.h"
1615#include "hash.h"
16#include "messram.h"
1717
1818/***************************************************************************
1919    TYPE DEFINITIONS
src/mess/messcore.mak
r6091r6092
8585   $(MESSOBJ)/uimess.o      \
8686   $(MESSOBJ)/filemngr.o   \
8787   $(MESSOBJ)/tapectrl.o   \
88   $(MESSOBJ)/compcfg.o   \
8988   $(MESSOBJ)/utils.o      \
9089   $(MESSOBJ)/eventlst.o   \
9190   $(MESSOBJ)/mslegacy.o   \
src/mess/mess.h
r6091r6092
1616#include "image.h"
1717#include "artworkx.h"
1818#include "memory.h"
19#include "compcfg.h"
2019#include "configms.h"
2120#include "messopts.h"
2221
src/mess/tools/messtest/testmess.c
r6091r6092
1818#include "video/generic.h"
1919#include "render.h"
2020#include "messopts.h"
21
21#include "devices/messram.h"
2222#include "debug/debugcpu.h"
2323
2424
src/mess/infomess.c
r6091r6092
1414#include "hash.h"
1515#include "xmlfile.h"
1616#include "infomess.h"
17#include "devices/messram.h"
1718
1819/*************************************
1920 *
r6091r6092
107108   }
108109}
109110
111/* device iteration helpers */
112#define ram_first(config)            device_list_first((config)->devicelist, MESSRAM)
113#define ram_next(previous)            ((previous)->typenext)
110114
111
112115/*-------------------------------------------------
113116    print_game_ramoptions - prints out all RAM
114117   options for this system
115118-------------------------------------------------*/
116
117119void print_game_ramoptions(FILE *out, const game_driver *game, const machine_config *config)
118120{
119   int i, count;
120   UINT32 ram;
121   UINT32 default_ram;
121   const device_config *device;
122   
123   for (device = ram_first(config); device != NULL; device = ram_next(device))
124   {
125      ram_config *config = device->inline_config;   
126      fprintf(out, "\t\t<ramoption default=\"1\">%u</ramoption>\n",  ram_parse_string(config->default_size));
127      if (config->extra_options != NULL)
128      {
129         const char *s;
122130
123   count = ram_option_count(game);
124   default_ram = ram_default(game);
131         astring *buffer = astring_alloc();
132         astring_cpyc(buffer, config->extra_options);
133         astring_replacechr(buffer, ',', 0);
125134
126   for (i = 0; i < count; i++)
127   {
128      ram = ram_option(game, i);
129      if (ram == default_ram)
130         fprintf(out, "\t\t<ramoption default=\"1\">%u</ramoption>\n", ram);
131      else
132         fprintf(out, "\t\t<ramoption>%u</ramoption>\n", ram);
135         s = astring_c(buffer);
136
137         /* try to parse each option */
138         while(*s != '\0')
139         {
140            fprintf(out, "\t\t<ramoption>%u</ramoption>\n",  ram_parse_string(s));
141            s += strlen(s) + 1;
142         }
143         astring_free(buffer);
144      }   
133145   }
134146}
src/mess/messdrv.h
r6091r6092
1919
2020struct SystemConfigurationParamBlock
2121{
22   /* for RAM options */
23   int max_ram_options;
24   int actual_ram_options;
25   int default_ram_option;
26   UINT32 *ram_options;
27
2822   /* device specification */
2923   int device_slotcount;
3024   device_getinfo_handler *device_handlers;
src/mess/mesvalid.c
r6091r6092
293293
294294      /* check compatibility chain */
295295      error = validate_compatibility_chain(drivers[i]) || error;
296
297      /* check system config */
298      ram_option_count(drivers[i]);
299296   }
300297
301298   /* call other validity checks */
src/mess/osd/winui/propertiesms.c
r6091r6092
3232#include "messopts.h"
3333#include "strconv.h"
3434#include "winutf8.h"
35#include "devices\messram.h"
3536
3637static BOOL SoftwareDirectories_OnInsertBrowse(HWND hDlg, BOOL bBrowse, LPCTSTR lpItem);
3738static BOOL SoftwareDirectories_OnDelete(HWND hDlg);
r6091r6092
208209
209210BOOL PropSheetFilter_Config(const machine_config *drv, const game_driver *gamedrv)
210211{
211   return (ram_option_count(gamedrv) > 0) || DriverHasDevice(gamedrv, IO_PRINTER);
212   return (device_list_first(drv->devicelist, MESSRAM)!=NULL) || DriverHasDevice(gamedrv, IO_PRINTER);
212213}
213214
214215
r6091r6092
382383
383384static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name)
384385{
385   int count, i, current_index, driver_index;
386   int i, current_index, driver_index;
386387   const game_driver *gamedrv;
387   UINT32 ram, current_ram;
388   char buffer[64];
388   UINT32 ram, current_ram;   
389389   const char *this_ram_string;
390390   TCHAR* t_ramstring;
391   machine_config *cfg;
392   const device_config *device;
391393
392394   // identify the driver
393395   driver_index = PropertiesCurrentGame(dialog);
r6091r6092
396398   // clear out the combo box
397399   (void)ComboBox_ResetContent(control);
398400
401   // allocate the machine config
402   cfg = machine_config_alloc_with_mess_devices(gamedrv);
403   
399404   // identify how many options that we have
400   count = ram_option_count(gamedrv);
401   EnableWindow(control, count > 0);
402
405   device = device_list_first(cfg->devicelist, MESSRAM);
406   
407   EnableWindow(control, (device != NULL));
408   i = 0;
403409   // we can only do something meaningful if there is more than one option
404   if (count > 0)
410   if (device != NULL)
405411   {
412      ram_config *config = device->inline_config;                 
413     
406414      // identify the current amount of RAM
407415      this_ram_string = options_get_string(opts, OPTION_RAMSIZE);
408416      current_ram = (this_ram_string != NULL) ? ram_parse_string(this_ram_string) : 0;
409417      if (current_ram == 0)
410         current_ram = ram_default(gamedrv);
418         current_ram = ram_parse_string(config->default_size);
411419
412420      // by default, assume index 0
413421      current_index = 0;
414422
415      // loop through all options
416      for (i = 0; i < count; i++)
417423      {
418         // identify this option
419         ram = ram_option(gamedrv, i);
420         this_ram_string = ram_string(buffer, ram);
421
422         t_ramstring = tstring_from_utf8(this_ram_string);
424         t_ramstring = tstring_from_utf8(config->default_size);
423425         if( !t_ramstring )
424426            return FALSE;
425427
426         // add this option to the combo box
427428         (void)ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
428         (void)ComboBox_SetItemData(control, i, ram);
429         (void)ComboBox_SetItemData(control, i, ram);         
430      }
431      if (config->extra_options != NULL)
432      {
433         const char *s;
429434
430         free(t_ramstring);
435         astring *buffer = astring_alloc();
436         astring_cpyc(buffer, config->extra_options);
437         astring_replacechr(buffer, ',', 0);
431438
432         // is this the current option?  record the index if so
433         if (ram == current_ram)
434            current_index = i;
435      }
439         s = astring_c(buffer);
436440
441         /* try to parse each option */
442         while(*s != '\0')
443         {           
444            i++;
445            // identify this option
446            ram = ram_parse_string(s);
447            this_ram_string = s;
448
449            t_ramstring = tstring_from_utf8(this_ram_string);
450            if( !t_ramstring )
451               return FALSE;
452
453            // add this option to the combo box
454            (void)ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
455            (void)ComboBox_SetItemData(control, i, ram);
456
457            free(t_ramstring);
458
459            // is this the current option?  record the index if so
460            if (ram == current_ram)
461               current_index = i;                       
462           
463            s += strlen(s) + 1;                 
464         }
465         astring_free(buffer);
466      }   
467
437468      // set the combo box
438469      (void)ComboBox_SetCurSel(control, current_index);
439470   }
src/mess/drivers/elf.c
r6091r6092
339339   
340340   /* internal ram */
341341   MDRV_RAM_ADD("messram")
342   MDRV_RAM_DEFAULT_SIZE(256)
342   MDRV_RAM_DEFAULT_SIZE("256")
343343MACHINE_DRIVER_END
344344
345345/* ROMs */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team