Watchpoint display bug

If you are having problems finding or using cheats for an Emulator (particularly MAME/MESS) or have found a trick that you wish to share this is the place to do it. But please read the Cheat FAQ first.
Post Reply
ShimaPong
Posts: 1063
Joined: Wed May 21, 2003 4:19 pm
Location: Japan

Watchpoint display bug

Post by ShimaPong »

All watchpoints are displayed on X=0, Y=0. If you change a display position, a watchpoint is lost.
The bug is due to major update for user interface on 0.107u1.

See cheat.c on 0.108.

Code: Select all

void cheat_display_watches(void)
{

....

int			j;
WatchInfo	* info = &watchList[i];
char		buf[1024];
UINT32		address = info->address;
int			xOffset = 0, yOffset = 0;
int			numChars;
int			lineElements = 0;

....

case kWatchDisplayType_Hex:
	numChars = sprintf(buf, "%.*X", kSearchByteDigitsTable[info->elementBytes], data);
	ui_draw_text(buf, xOffset * ui_get_char_width('0') + info->x, yOffset * ui_get_line_height() + info->y);
	xOffset += numChars;
	xOffset++;
	break;
The main problem is that in the latest ui_draw_text, ui_get_char_width and ui_get_line_height are based on float insted of "int".

In ui.c on 0.108

Code: Select all

void ui_draw_text(const char *buf, float x, float y)

float ui_get_char_width(UINT16 ch)

float ui_get_line_height(void)
vs 0.107

Code: Select all

void ui_draw_text(const char *buf, int x, int y)

int ui_get_char_width(UINT16 ch)

int ui_get_line_height(void)
[Sample]
I have tried to check the string '0','a' and'A' via ui_get_char_width.
  • Character Float
  • '0' 0.013281
  • 'a' 0.013709
  • 'A' 0.017137
And ui_get_string_width with "0aA" returns "0.044127".

But info->x is "int" so that if x is 0x02 it becomes "2.000000" by "float".
And if xOffset = 0, "xOffset * ui_get_char_width('0') + info->x" = 0 * 0.013281 + 2.000000 = 2.000000.
It's too large to display into a visible area (a watchpoint is perhaps out of screen).

Code: Select all

static void t##t(WatchInfo * info, UINT32 idx)
{
	if(idx > 0)
		info->y = watchList[idx - 1].y + ui_get_line_height();
	else
		info->y = 0;
}
Also t##t. info->y is "int" but height returns "float" so that info->y will be always 0...
because ln case of "float -> int",

Especially, info->x and info->y allow to change by end-user, just like in-game watchpoint edit menu and even a cheat code.
stephh
Posts: 601
Joined: Fri Aug 17, 2001 1:00 am
Location: Paris, France

Post by stephh »

Before Aaron's changes, the X and Y info from a watch were used to move it from 1 pixel left/right/up/down ... Would it cause a problem if you could only now move it from 1 char ? AFAIK, we almost never use such stuff (only when watches are added/deleted from the watch sub-menu), such change wouldn't harm too much, and watches should work again ...

EDIT : I've tested with MAME 0.106u13 (last version before the new renderer), and there was sort of bug with the watches : look at default Y info for 2nd watch and after ! So you had to make a huge change to see the watch "move" ...

Image Steph from The Ultimate Patchers Image
stephh
Posts: 601
Joined: Fri Aug 17, 2001 1:00 am
Location: Paris, France

Post by stephh »

Nicola made a quick fix in MAME 0.108u4 ... I haven't tested it yet, but you shall only try to modify the value with the -/+ keys (no "float" edit at the moment) ... Any comment is welcome before I submit Shimapong's various fixes and mine ...

Image Steph from The Ultimate Patchers Image
ShimaPong
Posts: 1063
Joined: Wed May 21, 2003 4:19 pm
Location: Japan

Post by ShimaPong »

I checked 0.108u4 with fixed watchpoint.

It seems to be good but...
  1. Don't accept any direct key input so that it's only way to change a position that press left or right (increment or decrement).
  2. If a watch-type cheat code has position desination, the cheat engine displays a watchpoint with wrong position.
    For Example :

    Code: Select all

    :game:00000006:1234:00000000:00560078:Watch 1234
    It means that the watchpoint (address $1234) is displayed with X = 56, Y = 78.
1) - Current cheat engine doesn't have "DoEditFloatField" but should we add this function ?
2) - Should we convert "int" value on a cheat code to "float" when load database or kill this function itself ?

Anyway, I have tried to convert in case of 2).

Code: Select all

// Custom - Convert int value to float if cheat code designates a position [AddActionWatch]
			if(action->extendData != 0xFFFFFFFF)
			{
				info->x = (float)((action->extendData >> 16) & 0xFFFF)/100;
				info->y = (float)((action->extendData >>  0) & 0xFFFF)/100;
			}
For example :

Code: Select all

:game2:00000006:AAAA:00000000:00080009:Watch AAAA
The watchpoint (address $aaaa) will be displayed with X = 0.008000 Y = 0.009000.

My customized cheat.c based on 0.108u4 is here.
http://zetubou.mine.nu/timer/file/bomber25383_h5.zip
PASS : Kriptokapi, NOT NEVER COMES HERE !

- Watchpoint -
Removed my modification for watchpoint and added the above convertion.

- Display for Copy Previous Value on Edit Menu -
In code edit menu, it is only displayed when userSelect and linked code by this fix.
This function may be unneeded except value-selection type code.
But it doesn't work. I think it needs "Normal Copy", "BCD Copy" and "Increment/Decrement Copy".

- Enabled BackSpace Key When Direct Key Input -
When edit a value directly, BackSpace key shifts current value right.
stephh
Posts: 601
Joined: Fri Aug 17, 2001 1:00 am
Location: Paris, France

Post by stephh »

ShimaPong wrote:My customized cheat.c based on 0.108u4 is here.
http://zetubou.mine.nu/timer/file/bomber25383_h5.zip
PASS : Kriptokapi, NOT NEVER COMES HERE !
I've taken your file, so I'll base my changes on it before I submit it ...

Image Steph from The Ultimate Patchers Image
stephh
Posts: 601
Joined: Fri Aug 17, 2001 1:00 am
Location: Paris, France

Post by stephh »

Shimapong, would you mind if I remove all the "Custom - " comments in your source files when I submit them ? You shall however still use them until they are included in an official MAME release ...

Image Steph from The Ultimate Patchers Image
ShimaPong
Posts: 1063
Joined: Wed May 21, 2003 4:19 pm
Location: Japan

Post by ShimaPong »

I don't mind unless you forget where is my modification in cheat.c.
Post Reply