Commit Graph

73 Commits

Author SHA1 Message Date
Aaron Giles
ab7d486957 Cleanups and version bump. 2009-05-28 15:59:16 +00:00
Aaron Giles
de269aeb45 Sent: Monday, May 11, 2009 10:32 PM
To: submit@mamedev.org
Subject: LSHIFT/<< expression diff fix

Tafoid pointed out that it's currently impossible to use '<<' in a 
cheat xml file, this fix adds an alternate LSHIFT to cheat.c and
express.c and also adds the working '>>' as an alternate RSHIFT to 
express.c (not needed in cheat.c as >> parses fine)

diff file attached
2009-05-15 05:29:09 +00:00
Aaron Giles
ad4910a8a8 Bulk change alert.
This update changes the way we handle memory allocation. Rather
than allocating in terms of bytes, allocations are now done in
terms of objects. This is done via new set of macros that replace
the malloc_or_die() macro:

  alloc_or_die(t) - allocate memory for an object of type 't'
  alloc_array_or_die(t,c) - allocate memory for an array of 'c' objects of type 't'
  alloc_clear_or_die(t) - same as alloc_or_die but memset's the memory to 0
  alloc_array_clear_or_die(t,c) - same as alloc_array_or_die but memset's the memory to 0

All original callers of malloc_or_die have been updated to call these
new macros. If you just need an array of bytes, you can use
alloc_array_or_die(UINT8, numbytes).

Made a similar change to the auto_* allocation macros. In addition,
added 'machine' as a required parameter to the auto-allocation macros,
as the resource pools will eventually be owned by the machine object.
The new macros are:

  auto_alloc(m,t) - allocate memory for an object of type 't'
  auto_alloc_array(m,t,c) - allocate memory for an array of 'c' objects of type 't'
  auto_alloc_clear(m,t) - allocate and memset
  auto_alloc_array_clear(m,t,c) - allocate and memset

All original calls or auto_malloc have been updated to use the new
macros. In addition, auto_realloc(), auto_strdup(), auto_astring_alloc(),
and auto_bitmap_alloc() have been updated to take a machine parameter.

Changed validity check allocations to not rely on auto_alloc* anymore
because they are not done in the context of a machine.

One final change that is included is the removal of SMH_BANKn macros.
Just use SMH_BANK(n) instead, which is what the previous macros mapped
to anyhow.
2009-04-26 23:54:37 +00:00
Aaron Giles
9549910dbc Sent: Saturday, March 21, 2009 3:27 PM
To: submit@mamedev.org
Subject: Simple cheat fix

Attached a very simple fix for a very stupid cut and paste error in my original submission..sorry.

Martin 'Pugsy' Pugh
2009-03-27 13:35:38 +00:00
Aaron Giles
3b302a8bae Cleanups and version bump. 2009-03-19 07:28:58 +00:00
Aaron Giles
c8585dd236 In addition to this change I added inline functions to define the
various cheat types and a table at the top to hopefully alleviate
confusion.


From: Pugsy [mailto:pugsy@gmx.net] 
Sent: Sunday, March 15, 2009 11:01 AM
To: submit@mamedev.org
Subject: Cheat.c changes

I've been having a look at cheat.c, the issue with one-shot 
list and one-shot select value cheats being indisguishable 
from perm cheats. I decided to have a look to see if I get 
it closer to the old way. I think I've managed it. I've 
attached a diff file..

It changes the One-Shot List or Selectable value cheats to display 
"Set" instead of "Off"
It stops the cheat options being activated in order when you are 
going through the possibilities These cheats are now activated by 
pressing ENTER after you have chosen an option This also pops up 
a message (examples):

		Activated
	Select Starting Stage  = 16 (0x10)

or
			Activated
	Select Temp. Current Shape PL1 = Yellow

Some simple examples to look at:
theroes "Select Starting Stage"
and
tetrist "Select Temp. Current Shape PL1"



Martin 'Pugsy' Pugh
2009-03-19 06:54:44 +00:00
Aaron Giles
5caef9210c From: Pugsy [pugsy@gmx.net]
Sent: Friday, March 13, 2009 8:59 AM
To: submit@mamedev.org
Subject: Fix for Mametesters Bug 2981

Hi

Some minor fixes (in attached diff file):-

1. Fixes this http://mametesters.org/mantis/view.php?id=2981 bug, Note I've NOT touched "#define MAX_ARGUMENTS                  32" - that
change is not required I've changed the cheat for the next beta xml cheat file release.

2. Minor typo in cidelsa.h, TAG starts with cpd rather than cdp, perhaps this should be maincpu though?

-#define CDP1802_TAG    "cpd1802"
+#define CDP1802_TAG    "cdp1802"




All the Best

Martin 'Pugsy' Pugh
2009-03-19 05:59:17 +00:00
Aaron Giles
eb539cce9d Many casts added to the core files, and various other tweaks
to make them compile as either C or C++.
2009-03-12 07:43:03 +00:00
Aaron Giles
5d89160f3b Further debugger cleanup. Symbol tables now have a global ref
as well as a per-symbol ref. Debugcpu is now clear of active
CPU references and global Machine references.
2008-11-22 16:50:00 +00:00
Aaron Giles
5816061f8e Debugger interfaces cleanup. Still more to do but this compiles and
works. Added callback parameters to the expression engine. Improved
CPU parsing so you can use a CPU tag or index in most commands that
take one. Switched to passing CPU and address space objects around
where appropriate. Lots of other minor tweaks.
2008-11-21 16:53:48 +00:00
Aaron Giles
0f3e79564d From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Sunday, September 21, 2008 10:45 AM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] More static qualifiers

Hi mamedev,

Another static function update from yours truly, almost entirely
affecting code added in the last few months to MAME.  The fixes are
the usual lot, changing enum definitions so they aren't declared,
decorating dead code/declarations with #if...#endif, and of course,
adding static where appropriate.  In addition, I fixed a bunch of
UNUSED_FUNCTON symbols to be spelled correctly (I didn't introduce
this).

~aa
2008-09-26 05:25:11 +00:00
Aaron Giles
aa2b6bd29a Cleanups and version bump. 2008-09-11 16:25:46 +00:00
Aaron Giles
89730e4d28 Added built-in "Off" states to the cheats with parameters. This is
also the default state, obviating the need for a default value. Removed
the "default" attribute as a result. Switching from "Off" to another
state first executes the "on" script followed by the "change" script.
Switching to "Off" from another state executes the "off" script. While
not off, the "run" script is executed each frame.
2008-09-06 06:57:47 +00:00
Aaron Giles
0523e9feb7 Cleanups and version bump. 2008-08-19 07:31:55 +00:00
Aaron Giles
de5cd6e5a8 Added cheat functions frombcd() and tobcd() to convert numbers to/from
BCD format. Changed "Activate" to "Set" in the menus.
2008-08-19 06:08:24 +00:00
Aaron Giles
224eb1f58b Cleanups and version bump. 2008-08-14 08:05:35 +00:00
Aaron Giles
480df37d02 Added new flag to menu items: MENU_FLAG_DISABLE, which means the
item will be visible but not selectable.

Fixed bug that prevented the cheat engine from working when the
debugger was disabled.

Modified xmlfile.c to accept integer values in decimal or hex. The
default is decimal. Numbers may be prefixed by '#' for decimal
values, or by '$' or '0x' to indicate hexadecimal values. Also
added function xml_get_attribute_int_format() to return the format
of the attribute, so that it can be later replicated.

Updated cheat parser to preserve the format of attribute values
used for cheat parameters and items.

Added support for information-only cheat items, which will be
displayed in the menu but which are not selectable and have no
action associated with them. Empty information-only items are
automatically converted to menu separators.
2008-08-13 04:55:42 +00:00
Aaron Giles
b40a4f5531 Cleanups and version bump. 2008-08-07 16:02:05 +00:00
Aaron Giles
9df01a2896 Added expression validation callback to verify names for CPUs and
memory regions. Extended error codes to report incorrect memory 
spaces, memory names, or memory sizes. Added verification callback
to the debugger to validate CPU and memory region names, as well
as verifying that a requested address space exists for a given
CPU.

Added support for oneshot cheats (those with only an "on" script).
They are activated via UI_SELECT in the cheat menu, and pop up a
message when activated. Also added a "Reset All" item in the cheat
menu to reset all cheats back to their default state, and added
support for UI_SELECT on a non-oneshot cheat so that it resets that
cheat to its default value.

Restored previous behavior that allowed popmessage() messages to
overlay menus and other UI.
2008-08-07 15:53:58 +00:00
Aaron Giles
ce00409cce Added word alternates for operators in expressions:
+   plus
  -   minus
  *   times or mul
  /   div
  %   mod
  !   not
  ~   bnot
  &&  and
  &   band
  ||  or
  |   bor
  ^   bxor
  lt  <
  le  <=
  gt  >
  ge  >=
  eq  ==
  ne  !=

Changed cheat escaping to automatically escape && & < and <=
to and band lt and le.
2008-08-07 06:48:04 +00:00
Aaron Giles
4a36b515ed Changes to the cheat.xml format:
- new tag <comment> (within <cheat>) is read and preserved 
    when saved
 - removed variable attribute from <parameter>; it is now 
    assumed to be 'param'
 - added default attribute for <parameter>

Added new variable 'frame' accessible from cheat scripts. This
can be used in the conditional to prevent execution on every
frame, or for other effects (like displaying temporary messages).

Added new variable 'argindex' which is the index when processing
an <argument> with a count attribute greater than 1. Can be used
in expressions like:

  <argument count="3">main.pb@(1000+argindex)</argument>

Reinstated the cheat menu. It now displays all loaded cheats and
allows for them to be activated. All known cheat behaviors should
be working now.
2008-08-06 05:24:31 +00:00
Aaron Giles
57bd1856b5 Cleanups/version bump. 2008-07-31 09:00:13 +00:00
Aaron Giles
a69088c498 Added new options 'cheatpath' to specify one or more paths for cheat
files. Removed old option 'cheat_file'.

Updated xmlfile.c to specify the line number for each node, for more
accurate error reporting.

Removed old cheat.c/.h and replaced them with code that will read and
write the new XML-based cheat format using the new cheatpath option
(cheats still need to be enabled in order to load at all). Note that
the cheats are not implemented yet, but they are fully parsed. To test
saving, whenever a cheat file is successfully loaded, it is immediately
written back out as 'output.xml' to the cheat directory for validation.
2008-07-31 08:19:53 +00:00
Aaron Giles
4a6fc8d5e5 Region classes go bye-bye. 2008-07-28 16:22:20 +00:00
Aaron Giles
27fed1ec97 Changed the way memory regions are referenced. Instead of a single
integer value, regions are now referred to by a region class and
a region tag. The class specifies the type of region (one of CPU,
gfx, sound, user, disk, prom, pld) while the tag uniquely specifies
the region. This change required updating all the ROM region
definitions in the project to specify the class/tag instead of
region number.

Updated the core memory_region_* functions to accept a class/tag
pair. Added new memory_region_next() function to allow for iteration
over all memory regions of a given class. Added new function
memory_region_class_name() to return the name for a given CPU
memory region class.

Changed the auto-binding behavior of CPU regions. Previously, the
first CPU would auto-bind to REGION_CPU1 (that is, any ROM references
would automatically assume that they lived in the corresponding
region). Now, each CPU automatically binds to the RGNCLASS_CPU region
with the same tag as the CPU itself. This behavior required ensuring
that all previous REGION_CPU* regions were changed to RGNCLASS_CPU
with the same tag as the CPU.

Introduced a new auto-binding mechanism for sound cores. This works
similarly to the CPU binding. Each sound core that requires a memory
region now auto-binds to the RGNCLASS_SOUND with the same tag as the
sound core. In almost all cases, this allowed for the removal of the
explicit region item in the sound configuration, which in turn 
allowed for many sound configurations to removed altogether.

Updated the expression engine's memory reference behavior. A recent
update expanded the scope of memory references to allow for referencing
data in non-active CPU spaces, in memory regions, and in EEPROMs.
However, this previous update required an index, which is no longer
appropriate for regions and will become increasingly less appropriate
for CPUs over time. Instead, a new syntax is supported, of the form:
"[tag.][space]size@addr", where 'tag' is an optional tag for the CPU
or memory region you wish to access, followed by a period as a 
separator; 'space' is the memory address space or region class you
wish to access (p/d/i for program/data/I/O spaces; o for opcode space;
r for direct RAM; c/u/g/s for CPU/user/gfx/sound regions; e for 
EEPROMs); and 'size' is the usual b/w/d/q for byte/word/dword/qword.

Cleaned up ROM definition flags and removed some ugly hacks that had
existed previously. Expanded to support up to 256 BIOSes. Updated
ROM_COPY to support specifying class/tag for the source region.

Updated the address map AM_REGION macro to support specifying a
class/tag for the region.

Updated debugger windows to display the CPU and region tags where
appropriate.

Updated -listxml to output region class and tag for each ROM entry.
2008-07-28 09:35:36 +00:00
Aaron Giles
d8715ab4ac Note: I have done some testing, but there are probably more bugs
lurking. If you run into anything odd, please let me know.

Added new module uiinput.c which manages input for the user interface.
The OSD is responsible for pushing mouse events and character events
to this interface in order to support mouse movement and text-based
input (currently only used for the select game menu). Added support
for navigating through the menus using the mouse. 
[Nathan Woods, Aaron Giles]

Redesigned the UI menus so that they can maintain a richer state. Now
the menus can be generated once and reused, rather than requiring them
to be regenerated on each frame. All menus also share a comment eventing
system and navigation through them is managed centrally. Rewrote all the 
menus to use the new system, apart from the cheat menus, which are now 
disabled. Reorganized the video menu to make it easier to understand.
[Aaron Giles]
2008-07-12 20:18:25 +00:00
Nathan Woods
bc9879f754 MESS-specific fix 2008-07-08 10:05:41 +00:00
Couriersud
b261a88395 01983: Force Range cheats not working 2008-07-06 18:49:27 +00:00
Couriersud
84e9ab7d4e Fix scrolling speed in case a cheat dat has invalid (i.e. 0) settings 2008-07-06 10:37:52 +00:00
Aaron Giles
6105826fb8 01971: Cheat menu flickers
Also made it display (null) only in debug builds.
2008-07-06 06:45:29 +00:00
Roberto Zandona
342b2370be update cheat system (fix mantis #01969) (credit ShimaPong) 2008-07-04 16:49:20 +00:00
Nathan Woods
a0866bcacd MESS-specific tweak 2008-07-04 03:10:33 +00:00
Couriersud
b97ff5fcca Credit ShimaPong - Updated cheat system
- Roll back older periodic function
   Now standard/old format work in this function
   Otherwords, several operations which doesn't exist in older
   function and added recently are now disabled
 - Separated load_cheat_code() to 3 indipendent functions
   And added new cheat options, "Load New/Standard/Old Format Code"
   (Default : load all format codes)
     NOTE : delete all cheat options in the database before start
            or reload default options (Shift + Reload key)
            in cheat general menu
 - Added format strings structure to accept huge size strings
   in loading a database to prevent from breaking other strings
 - Changed Link in new format
   Label code is now "Link-Label" and sub-label is "Label-Sub-Link"
   "Standard-Link" is no longer label
 - Added choose_label_index() to manage label selection
 - Fixed build_label_index_table() to prevent from crashing
   And disabled to build label index table in case of
   standard/old format
 - Fixed memory free problem in case of standard/old code
 - Fixed several reported/found bugs
2008-07-01 22:53:31 +00:00
Nathan Woods
aa3dfa8811 MESS-specific compilation fix 2008-06-27 01:10:39 +00:00
Aaron Giles
3d1376ed97 Cleanups/version bump. 2008-06-26 16:05:46 +00:00
Couriersud
9e2e2fd776 Fixes menu scrolling speed as described by Haze 2008-06-25 22:17:15 +00:00
Couriersud
37ad515d2a Updated cheat system / Credit Shimapong
- Merged 3 different search menu functions to search_main_menu()
 - Added new cheat options, "Vertical/Horizontal Key Repeat Speed"
     NOTE : delete all cheat options in the database before start
            or reload default options (Shift + Reload key)
            in cheat general menu
 - Changed assignment of Entry for Activation Key and Pre-enable
   command code. Now there are check the tag in comment field
   instead of index number. But it's only for new format command
   and old is as before
 - Added tag output in save_activation_key() and save_pre_enable()
 - Cleaned up save_cheat_options() to output description
 - Changed memory read function in watchpoints
   No longer "Debugger" watchpoint mis-hit "Cheat" watchpoint
 - Fixed several reported/found bugs
 - Renamed funcitons/enum based on coding guidlines
   All functions are completed in this update
2008-06-25 18:24:55 +00:00
Aaron Giles
57c35a0efc From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] memory_region madness reloaded
Hi mamedev,

The memory_region and memory_region_length functions are probably the
two most common functions in MAME that don't take a machine parameter
but should given the syntax of the related apis memory_region_type and
memory_region_flags.  Clearly they didn't get the parameter because of
the sheer number of changes needed to change the apis.  This pair of
patches makes the change, and deals with the consequences.

The second patch then changes the api for memory_region and
memory_region_length, and fixes the fallout.  It generally plumbs
through machine parameters where needed, except for the case of sound
apis which I deferred doing so till later.  This increased the number
of deprecat.h includes by ~50.  Given it is a massive patch, there are
bound to be a few mistakes in it (I had to make ~20% of the changes by
hand), but I exercised care and reviewed the patch several times to
minimize the problems.
2008-06-23 08:32:42 +00:00
Nathan Woods
1c989c1f59 Typo fix 2008-06-13 00:18:48 +00:00
Aaron Giles
5a162da3d4 Cleanups and version bump. 2008-06-12 19:59:19 +00:00
Aaron Giles
9b80898ee0 From Shimapong
MAMETesters Bugs Fixed
----------------------
00277: [Misc.] groundfx.c, gunbustr.c, superchs.c, taito_f3.c,
       undrfire.c, psikyosh.c: Cheat search causes fatal error

Source Changes
--------------
Updated cheat system
 - Changed the function of default memory read in case of the search
   to prevent from crashing if a game uses cpu_spinutil()
   Now basically used do_memory_read() instead of do_cpu_read()
   (Try to search in actfancr between this and previous version)
   NOTE : It's not fundamental solution but no longer crash
 - Cleaned up read_data() and write_data()
 - Cleaned up save/load routine and added open_cheat_database()
 - Added new menu "Cheat Commands" into the cheat main menu
     the following commands are supported in this menu
      * reload cheat code (the same as Reload Database key)
      * cheats ON/OFF (the same as Toggle Cheat key)
      * watchpoints ON/OFF (the same as Shift + Toggle Cheat key)
      * save description (save the title of the game)
      * save raw code (save raw cheat code with new format)
 - Fixed several bugs which has found in testing
 - Renamed functions based on coding guidlines
2008-06-12 16:46:29 +00:00
Aaron Giles
1bc774b32b Cleanups/version bump. 2008-06-05 15:57:00 +00:00
R. Belmont
317607a143 64-bit GCC compile fixes. 2008-06-05 14:10:56 +00:00
Nathan Woods
5b94cc19d5 MESS-specific compilation fix 2008-06-05 11:12:33 +00:00
Aaron Giles
2deed30b29 Fixes for 64-bit MSVC compile. 2008-06-05 09:49:23 +00:00
Aaron Giles
7474bb220a MAMETesters Bugs Fixed
----------------------
- 01845: [Core] all games: cheats are broken
- 01846: [Misc.] -CHEAT trigger causes MAME crash with PSX-type CPU drivers

Source Changes
--------------
Updated cheat system
  - Locked search region when malloc fails to allocate gigantic memory
    instead of fatal error. Also locked zero malloc error in case of
    search speed = all memory in 32-bit CPU. And added search region
    range checker to lock a search region with a big risk

  - Fixed a bug that old code is always converted to specified
    separator in enable/disable menu

  - Refined new cheat format.
     * Rewritten cheat format again. newest format is
       ":gamename::type::address::data::extend_data:(description:comment)"
       Expanded type field now requires 10 bytes (not 8 bytes) and
       it divides internal cpu (2 bytes) and type (8 bytes) parameters

     * Removed VWrite, VRWrite. The flag of Value Selection is merged
       into expanded type field now.

     * Added CBit (Condition Bit). This checks bit in read data then
       set or clear bit in case of true.

     * Rearranged cheat code viwer based on newest cheat format

  - Fixed unworking Load Old Format option. If you want to load old or
    older format code, set it (default is OFF)

  - Renamed functions/structures based on coding guidlines
    All structures and included parameters are completed

  - Merged resize_*_no_dispose() into resize_*()

  - Removed the hack of search region for SH-2 CPU because required
    region is now set as expected without this hack
2008-06-05 08:46:48 +00:00
Nathan Woods
aa14505377 MESS-specific fix 2008-05-29 10:55:52 +00:00
Aaron Giles
c852c42952 Cleanups for 0.125u3. 2008-05-29 09:25:51 +00:00
Aaron Giles
7247ecbce2 From: ShimaPong
fixed Testers bug [01039]
-------------------------------

Updated cheat sytem drastically
  * Supported (preliminary) new cheat format
     - Added new operations
        PDWWrite, RWrite, VRWrite, CWrite, Move, Branch, Loop, Popup
     - Added new options
        ValueSelectNegative, Return, AddressReadFrom, DataReadFrom
     - Added cheat variables
        You can store data with Write or Move operations and
        read as an address or data from each fields
     - Added condition check
        for CWrite, Branch and Popup operations
     - Added new custom codes
        Separator, Layer
     - Supported Shared Code [MESS ONLY]
        different machine shares common code for a game

  * Allowed mixed label-select or user-select with standard code

  * Added label selector menu for label-selection code

  * Added extend comment displayer for multi-line comments

  * Added command menu for cheat list and watchpoint
     Easy selectable cheat commands in this menu

  * Added debug view menu [DEBUG BUILD ONLY]
     It displays internal info to debug cheat system

  * Supported unique separator by ui_draw_menu() in several menus

  * Added user defined search region
     You can set free memory range from cheat database

  * Enhanced error check for cheat code to prevent from unexpected working
     Error code is locked. If you select this code, the analyser works
     instead of the code activater

  * Enhanced value input with keyboard-less
     Cheat edit key gives new input system in several menus
     Left/right keys moves the edit cursor and up/down keys changes a value

  * Added cheat command save, reload, reset in option menu

  * Supported address shift in searching
     Now searchable default region in TMS340*0 cpu games (Trog, Smash T.V. etc)

  * Refined cheat menu handling with function pointer called cheat_menu_handler

  * Added format strings table to manage in an integrated fashion

  * Deleted unused hacks of default search region for Neo Geo and TMS34010

  * Refined code based on MAME coding guidelines
     - Renamed many functions/structures/constants
        But not complete due to too many items
     - Converted small but often used functions to INLINE
     - Fixed a comparison in case of 0 or NULL
     - Added missing function prototype for several functions
2008-05-29 08:54:21 +00:00
Aaron Giles
7cb1326459 Renamed EEPROM_* to eeprom_*
Typedef'ed a real eeprom_interface structure.

Added a PORT_CUSTOM for the eeprom bit reading. Updated several
drivers to use that by specifying it in their input ports instead
of having a custom read handler that inserted the bit forcefully.

Added a PORT_CUSTOM for the ticket dispenser callback as well.
Updated the dcheese driver to use it.

Many more drivers can be updated to use these new PORT_CUSTOMs
in the future, eliminating hacky input port read handlers.
2008-05-25 05:38:24 +00:00