src/mess/cheatms.c
| r3205 | r3206 | |
| 17 | 17 | GLOBALS |
| 18 | 18 | ***************************************************************************/ |
| 19 | 19 | |
| 20 | | static UINT32 * deviceCRCList = NULL; |
| 21 | | static INT32 deviceCRCListLength = 0; |
| 22 | | UINT32 thisGameCRC = 0; |
| 20 | static UINT32 *device_crc_list = NULL; |
| 21 | static INT32 device_crc_list_length = 0; |
| 22 | UINT32 this_game_crc = 0; |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | |
| r3205 | r3206 | |
| 27 | 27 | CODE |
| 28 | 28 | ***************************************************************************/ |
| 29 | 29 | |
| 30 | | static void BuildCRCTable(running_machine *machine) |
| 30 | static void build_crc_table(running_machine *machine) |
| 31 | 31 | { |
| 32 | 32 | int listIdx; |
| 33 | 33 | const device_config *img; |
| 34 | 34 | |
| 35 | | free(deviceCRCList); |
| 35 | free(device_crc_list); |
| 36 | 36 | |
| 37 | | // allocate list with single member (0x00000000) |
| 38 | | deviceCRCList = calloc(1, sizeof(UINT32)); |
| 39 | | deviceCRCListLength = 1; |
| 37 | /* allocate list with single member (0x00000000) */ |
| 38 | device_crc_list = calloc(1, sizeof(UINT32)); |
| 39 | device_crc_list_length = 1; |
| 40 | 40 | |
| 41 | 41 | for (img = image_device_first(machine->config); img != NULL; img = image_device_next(img)) |
| 42 | 42 | { |
| r3205 | r3206 | |
| 45 | 45 | UINT32 crc = image_crc(img); |
| 46 | 46 | int isUnique = 1; |
| 47 | 47 | |
| 48 | | for(listIdx = 0; listIdx < deviceCRCListLength; listIdx++) |
| 48 | for(listIdx = 0; listIdx < device_crc_list_length; listIdx++) |
| 49 | 49 | { |
| 50 | | if(deviceCRCList[listIdx] == crc) |
| 50 | if(device_crc_list[listIdx] == crc) |
| 51 | 51 | { |
| 52 | 52 | isUnique = 0; |
| 53 | 53 | |
| r3205 | r3206 | |
| 57 | 57 | |
| 58 | 58 | if(isUnique) |
| 59 | 59 | { |
| 60 | | if(!thisGameCRC) |
| 61 | | thisGameCRC = crc; |
| 60 | if(!this_game_crc) |
| 61 | this_game_crc = crc; |
| 62 | 62 | |
| 63 | | deviceCRCList = realloc(deviceCRCList, (deviceCRCListLength + 1) * sizeof(UINT32)); |
| 63 | device_crc_list = realloc(device_crc_list, (device_crc_list_length + 1) * sizeof(UINT32)); |
| 64 | 64 | |
| 65 | | deviceCRCList[deviceCRCListLength] = crc; |
| 66 | | deviceCRCListLength++; |
| 65 | device_crc_list[device_crc_list_length] = crc; |
| 66 | device_crc_list_length++; |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
| 73 | | void InitMessCheats(running_machine *machine) |
| 73 | void cheat_mess_init(running_machine *machine) |
| 74 | 74 | { |
| 75 | | deviceCRCList = NULL; |
| 76 | | deviceCRCListLength = 0; |
| 77 | | thisGameCRC = 0; |
| 75 | device_crc_list = NULL; |
| 76 | device_crc_list_length = 0; |
| 77 | this_game_crc = 0; |
| 78 | 78 | |
| 79 | | BuildCRCTable(machine); |
| 79 | build_crc_table(machine); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
| 83 | 83 | |
| 84 | | void StopMessCheats(void) |
| 84 | void cheat_mess_exit(void) |
| 85 | 85 | { |
| 86 | | free(deviceCRCList); |
| 87 | | deviceCRCList = NULL; |
| 86 | free(device_crc_list); |
| 87 | device_crc_list = NULL; |
| 88 | 88 | |
| 89 | | deviceCRCListLength = 0; |
| 90 | | thisGameCRC = 0; |
| 89 | device_crc_list_length = 0; |
| 90 | this_game_crc = 0; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | |
| 95 | | int MatchesCRCTable(UINT32 crc) |
| 95 | int cheat_mess_matches_crc_table(UINT32 crc) |
| 96 | 96 | { |
| 97 | | int i; |
| 97 | int i; |
| 98 | 98 | |
| 99 | | for(i = 0; i < deviceCRCListLength; i++) |
| 100 | | if(deviceCRCList[i] == crc) |
| 99 | for(i = 0; i < device_crc_list_length; i++) |
| 100 | if(device_crc_list[i] == crc) |
| 101 | 101 | return 1; |
| 102 | 102 | |
| 103 | 103 | return 0; |
src/mess/cheatms.h
| r3205 | r3206 | |
| 6 | 6 | |
| 7 | 7 | *********************************************************************/ |
| 8 | 8 | |
| 9 | | #ifndef CHEATMS_H |
| 10 | | #define CHEATMS_H |
| 9 | #pragma once |
| 11 | 10 | |
| 12 | | extern UINT32 thisGameCRC; |
| 11 | #ifndef __CHEATMS_H__ |
| 12 | #define __CHEATMS_H__ |
| 13 | 13 | |
| 14 | | void InitMessCheats(running_machine *machine); |
| 15 | | void StopMessCheats(void); |
| 16 | | int MatchesCRCTable(UINT32 crc); |
| 14 | extern UINT32 this_game_crc; |
| 17 | 15 | |
| 18 | | #endif /* CHEATMS_H */ |
| 16 | void cheat_mess_init(running_machine *machine); |
| 17 | void cheat_mess_exit(void); |
| 18 | int cheat_mess_matches_crc_table(UINT32 crc); |
| 19 | |
| 20 | #endif /* __CHEATMS_H__ */ |