Skip to content

Commit d1b5238

Browse files
committed
added some extra color options to the graphical memory view
1 parent 73896f7 commit d1b5238

File tree

4 files changed

+176
-22
lines changed

4 files changed

+176
-22
lines changed

Cheat Engine/frmMemoryViewExUnit.lfm

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object frmMemoryViewEx: TfrmMemoryViewEx
2-
Left = 497
2+
Left = 510
33
Height = 482
4-
Top = 230
4+
Top = 264
55
Width = 836
66
Caption = 'Graphical Memory View '
77
ClientHeight = 482
@@ -92,16 +92,18 @@ object frmMemoryViewEx: TfrmMemoryViewEx
9292
Width = 136
9393
BorderSpacing.Right = 5
9494
ItemHeight = 15
95-
ItemIndex = 2
95+
ItemIndex = 3
9696
Items.Strings = (
9797
'Dithered (1 Byte/pixel)'
98-
'RGA (3 Bytes/Pixel)'
99-
'RGBA (4 Bytes/Pixel)'
98+
'RGB'
99+
'BGR'
100+
'RGBA'
101+
'BGRA'
100102
)
101103
OnChange = cbColorChange
102104
Style = csDropDownList
103105
TabOrder = 2
104-
Text = 'RGBA (4 Bytes/Pixel)'
106+
Text = 'RGBA'
105107
end
106108
object Label3: TLabel
107109
AnchorSideLeft.Control = tbPitch
@@ -115,6 +117,53 @@ object frmMemoryViewEx: TfrmMemoryViewEx
115117
Caption = 'Color'
116118
ParentColor = False
117119
end
120+
object Label1: TLabel
121+
AnchorSideLeft.Control = Label3
122+
AnchorSideTop.Control = cbColor
123+
AnchorSideTop.Side = asrBottom
124+
Left = 5
125+
Height = 15
126+
Top = 111
127+
Width = 26
128+
Caption = 'Type'
129+
ParentColor = False
130+
end
131+
object cbType: TComboBox
132+
AnchorSideLeft.Control = Label1
133+
AnchorSideTop.Control = Label1
134+
AnchorSideTop.Side = asrBottom
135+
Left = 5
136+
Height = 23
137+
Top = 126
138+
Width = 136
139+
BorderSpacing.Right = 5
140+
ItemHeight = 15
141+
ItemIndex = 0
142+
Items.Strings = (
143+
'Byte'
144+
'Unsigned Short'
145+
'Short'
146+
'Unsigned Int'
147+
'Int'
148+
'Float'
149+
'3-3-2'
150+
'2-3-3 R'
151+
'5-6-5'
152+
'5-6-5 R'
153+
'4-4-4-4'
154+
'4-4-4-4 R'
155+
'5-5-5-1'
156+
'1-5-5-5 R'
157+
'8-8-8-8'
158+
'8-8-8-8 R'
159+
'10-10-10-2'
160+
'2-10-10-10 R'
161+
)
162+
OnChange = cbTypeChange
163+
Style = csDropDownList
164+
TabOrder = 3
165+
Text = 'Byte'
166+
end
118167
end
119168
object Panel3: TPanel
120169
Left = 0

Cheat Engine/frmMemoryViewExUnit.lrt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ TFRMMEMORYVIEWEX.LBLADDRESS.CAPTION=Address:
33
TFRMMEMORYVIEWEX.EDTPITCH.HINT=Number of bytes a row exists out
44
TFRMMEMORYVIEWEX.EDTPITCH.TEXT=32
55
TFRMMEMORYVIEWEX.LABEL2.CAPTION=Pixels per line
6-
TFRMMEMORYVIEWEX.CBCOLOR.TEXT=RGBA (4 Bytes/Pixel)
6+
TFRMMEMORYVIEWEX.CBCOLOR.TEXT=RGBA
77
TFRMMEMORYVIEWEX.LABEL3.CAPTION=Color
8+
TFRMMEMORYVIEWEX.LABEL1.CAPTION=Type
9+
TFRMMEMORYVIEWEX.CBTYPE.TEXT=Byte
810
TFRMMEMORYVIEWEX.CBADDRESSLISTONLY.CAPTION=Only show addresslist memory
911
TFRMMEMORYVIEWEX.CBADDRESSLIST.TEXT=Current Memory
1012
TFRMMEMORYVIEWEX.CBSAVEDLIST.TEXT=Current Memory

Cheat Engine/frmMemoryViewExUnit.pas

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface
88
windows, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
99
ExtCtrls, StdCtrls, ComCtrls, Menus, memdisplay, newkernelhandler, cefuncproc,
1010
syncobjs, math, savedscanhandler, foundlisthelper, CustomTypeHandler,
11-
symbolhandler, inputboxtopunit, commonTypeDefs;
11+
symbolhandler, inputboxtopunit, commonTypeDefs, GL, GLext;
1212

1313

1414
type TMVCompareMethod=(cmOr, cmXor, cmAnd);
@@ -52,9 +52,11 @@ TfrmMemoryViewEx = class(TForm)
5252
cbAddresslist: TComboBox;
5353
cbAddresslistOnly: TCheckBox;
5454
cbColor: TComboBox;
55+
cbType: TComboBox;
5556
cbCompare: TCheckBox;
5657
cbSavedList: TComboBox;
5758
edtPitch: TEdit;
59+
Label1: TLabel;
5860
Label2: TLabel;
5961
Label3: TLabel;
6062
lblAddress: TLabel;
@@ -75,6 +77,7 @@ TfrmMemoryViewEx = class(TForm)
7577
procedure cbCompareChange(Sender: TObject);
7678
procedure cbSavedListChange(Sender: TObject);
7779
procedure cbColorChange(Sender: TObject);
80+
procedure cbTypeChange(Sender: TObject);
7881

7982
procedure edtPitchChange(Sender: TObject);
8083
procedure FormCreate(Sender: TObject);
@@ -450,13 +453,68 @@ procedure TfrmMemoryViewEx.cbSavedListChange(Sender: TObject);
450453
procedure TfrmMemoryViewEx.cbColorChange(Sender: TObject);
451454
var i: integer;
452455
begin
456+
{
457+
Dithered (1 Byte/pixel)
458+
RGB (3 Bytes/Pixel)
459+
BGR (3 Bytes/Pixel)
460+
RGBA (4 Bytes/Pixel)
461+
BGRA (4 Bytes/Pixel)
462+
}
463+
453464
case cbcolor.itemindex of
454-
0: md.setFormat($1900);
455-
1: md.setFormat($1907);
456-
2: md.setFormat($1908);
465+
0: md.setFormat(GL_COLOR_INDEX);
466+
1: md.setFormat(GL_RGB);
467+
2: md.setFormat(GL_BGR);
468+
3: md.setFormat(GL_RGBA);
469+
4: md.setFormat(GL_BGRA);
457470
end;
471+
end;
458472

473+
procedure TfrmMemoryViewEx.cbTypeChange(Sender: TObject);
474+
begin
459475

476+
477+
{
478+
Byte
479+
Unsigned Short
480+
Short
481+
Unsigned Int
482+
Int
483+
Float
484+
3-3-2
485+
2-3-3 R
486+
5-6-5
487+
5-6-5 R
488+
4-4-4-4
489+
4-4-4-4 R
490+
5-5-5-1
491+
1-5-5-5 R
492+
8-8-8-8
493+
8-8-8-8 R
494+
10-10-10-2
495+
2-10-10-10 R
496+
}
497+
498+
case cbtype.ItemIndex of
499+
0: md.setType(GL_UNSIGNED_BYTE);
500+
1: md.setType(GL_UNSIGNED_SHORT);
501+
2: md.setType(GL_SHORT);
502+
3: md.setType(GL_UNSIGNED_INT);
503+
4: md.setType(GL_INT);
504+
5: md.setType(GL_FLOAT);
505+
6: md.setType(GL_UNSIGNED_BYTE_3_3_2);
506+
7: md.setType(GL_UNSIGNED_BYTE_2_3_3_REV);
507+
8: md.setType(GL_UNSIGNED_SHORT_5_6_5);
508+
9: md.setType(GL_UNSIGNED_SHORT_5_6_5_REV);
509+
10: md.setType(GL_UNSIGNED_SHORT_4_4_4_4);
510+
11: md.setType(GL_UNSIGNED_SHORT_4_4_4_4_REV);
511+
12: md.setType(GL_UNSIGNED_SHORT_5_5_5_1);
512+
13: md.setType(GL_UNSIGNED_SHORT_1_5_5_5_REV);
513+
14: md.setType(GL_UNSIGNED_INT_8_8_8_8);
514+
15: md.setType(GL_UNSIGNED_INT_8_8_8_8_REV);
515+
16: md.setType(GL_UNSIGNED_INT_10_10_10_2);
516+
17: md.setType(GL_UNSIGNED_INT_2_10_10_10_REV);
517+
end;
460518
end;
461519

462520
procedure TfrmMemoryViewEx.FormDestroy(Sender: TObject);

Cheat Engine/memdisplay.pas

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ interface
3434

3535
uses
3636
windows, Classes, SysUtils, ExtCtrls, Controls, LMessages, Graphics, GL, glu,
37-
math, dialogs;
37+
math, dialogs, GLext;
3838

3939

4040
type TCurrentOverlay=record
@@ -68,6 +68,7 @@ TMemDisplay=class(Tcustompanel)
6868
fXpos, fYpos: integer;
6969
fwantedPixelsPerLine: integer; //when the format changes, use this as lead for the new pitch
7070
fPitch: integer;
71+
fType: integer;
7172
fPixelFormat: integer;
7273
fPixelByteSize: integer; //the number of bytes one pixel exists of (I do not support monochrome...)
7374

@@ -100,12 +101,15 @@ TMemDisplay=class(Tcustompanel)
100101
procedure LimitCoordinates;
101102
procedure RecenterDrag;
102103
procedure setMaxCharCount(v: integer);
104+
procedure reconfigPixelByteSize;
103105
public
104106
totaldiff: qword;
105107
ticks: integer;
106108
lastdiff: qword;
107109
function MoveTo(xpos, ypos: integer): boolean;
108110
procedure setFormat(format: integer);
111+
procedure setType(t: integer);
112+
109113
procedure setPitch(pitch: integer);
110114
procedure setPixelsPerLine(ppl: integer);
111115
procedure setPointer(address: ptruint); overload;
@@ -186,21 +190,47 @@ procedure TMemDisplay.setPointer(address: ptruint; p: pointer; size: integer);
186190

187191
end;
188192

189-
procedure TMemDisplay.setFormat(format: integer);
193+
procedure TMemDisplay.reconfigPixelByteSize;
190194
var oldaddress: integer;
191195
begin
192196
oldaddress:=getTopLeftAddress;
193-
fPixelFormat:=format;
197+
fPixelByteSize:=4;
194198

199+
case ftype of
200+
GL_UNSIGNED_BYTE, GL_BYTE:
201+
begin
202+
case fpixelformat of
203+
GL_COLOR_INDEX: fPixelByteSize:=1;
204+
GL_BGR,GL_RGB: fPixelByteSize:=3;
205+
GL_RGBA, GL_BGRA: fPixelByteSize:=4;
206+
end;
207+
end;
195208

196-
case fpixelformat of
197-
GL_RGB: fPixelByteSize:=3;
198-
GL_RGBA: fPixelByteSize:=4;
199-
GL_LUMINANCE_ALPHA: fPixelByteSize:=3;
200-
else
201-
fPixelByteSize:=1;
202-
end;
209+
GL_UNSIGNED_SHORT, GL_SHORT:
210+
begin
211+
case fpixelformat of
212+
GL_COLOR_INDEX: fPixelByteSize:=1*2;
213+
GL_BGR,GL_RGB: fPixelByteSize:=3*2;
214+
GL_RGBA, GL_BGRA: fPixelByteSize:=4*2;
215+
end;
216+
end;
217+
218+
GL_UNSIGNED_INT, GL_INT, GL_FLOAT:
219+
begin
220+
case fpixelformat of
221+
GL_COLOR_INDEX: fPixelByteSize:=1*4;
222+
GL_BGR,GL_RGB: fPixelByteSize:=3*4;
223+
GL_RGBA, GL_BGRA: fPixelByteSize:=4*4;
224+
end;
225+
end;
203226

227+
GL_UNSIGNED_BYTE_3_3_2,GL_UNSIGNED_BYTE_2_3_3_REV: fPixelByteSize:=1;
228+
GL_UNSIGNED_SHORT_5_6_5,GL_UNSIGNED_SHORT_5_6_5_REV,
229+
GL_UNSIGNED_SHORT_4_4_4_4,GL_UNSIGNED_SHORT_4_4_4_4_REV,
230+
GL_UNSIGNED_SHORT_5_5_5_1,GL_UNSIGNED_SHORT_1_5_5_5_REV: fPixelByteSize:=2;
231+
GL_UNSIGNED_INT_8_8_8_8,GL_UNSIGNED_INT_8_8_8_8_REV,
232+
GL_UNSIGNED_INT_10_10_10_2,GL_UNSIGNED_INT_2_10_10_10_REV: fPixelByteSize:=4;
233+
end;
204234

205235
setPixelsPerLine(fwantedPixelsPerLine);
206236

@@ -211,6 +241,20 @@ procedure TMemDisplay.setFormat(format: integer);
211241
render;
212242
end;
213243

244+
procedure TMemDisplay.setType(t: integer);
245+
begin
246+
fType:=t;
247+
248+
reconfigPixelByteSize()
249+
end;
250+
251+
procedure TMemDisplay.setFormat(format: integer);
252+
begin
253+
254+
fPixelFormat:=format;
255+
reconfigPixelByteSize;
256+
end;
257+
214258
procedure TMemDisplay.setPixelsPerLine(ppl: integer);
215259
begin
216260
fwantedPixelsPerLine:=ppl;
@@ -794,7 +838,7 @@ procedure TMemDisplay.render;
794838

795839

796840

797-
glDrawPixels(fPitch div fPixelByteSize, maxheight, fpixelformat,GL_UNSIGNED_BYTE, p);
841+
glDrawPixels(fPitch div fPixelByteSize, maxheight, fpixelformat,fType, p);
798842

799843

800844
//draw overlays (if visible)
@@ -900,6 +944,7 @@ constructor TMemDisplay.Create(TheOwner: TComponent);
900944

901945
//some default inits
902946
fZoom:=32;
947+
ftype:=GL_UNSIGNED_BYTE;
903948
setFormat(GL_RGBA);
904949
setPitch(128);
905950

0 commit comments

Comments
 (0)