Using turican0/dosbox-x-remc2 for debugging
turican0 opened this issue · 3 comments
1)Clone turican0/dosbox-x-remc2 to your PC
2)In vs2015/dosbox.conf set path to your directory with dos version magic carpet 2
2)Open dosbox-x.sln for visual studio(or use other method for linux, you can modify original dosbox-x, too)
3)In engine.cpp you can add code:
writesequence(0x2285ff, 2000, 0xc4e, 0x2b3a74, 0, 0);
for data saving and comparing, this command have parametres:
-adress in code when data saved
-count
-lenght
-adress in memory
In remc2 for comparing use compare_with_sequence
you must set:
//#define PLAYING_GAME
//#define RELEASE_GAME
(In dosbox and remc2 is code for mouse freezing, etc.)
addprocedurestop(0x242a00, 0x1, true, true, 0x35603800 + 0x2f7d);
for stepping and compare code, this command have parametres:
-adress in code when emulation stop
-count runs(first run is 0)
-force(I don't remember now)
-memadress(I don't remember now)
-counteradress(I don't remember now)
In dosbox-x envonment I add commands:
MEMDUMPF / MEMDUMPF16 / MEMDUMPF32
for save hexa dumps of memory
F5 - run
F9 - set breakpoint
F10 -step over
F11 - step in
c 160:257930 - show code
d 000:000 - show memory
TAB - change context
help - help
Code and adress in dosbox is shifted
void sub_61A00_draw_minimap_entites_b(int a1, int a2, __int16 a3, __int16 a4, int a5, int a6, __int16 a7, int a8)//242a00
This procedure have 61A00 in name, but 160:242a00 adress in DosBox.
A sample I add to dosbox-x this:
writesequence(0x002285FF, 0x300, 0x70000, 0x2dc4e0);
writesequence(0x002285FF, 0x300, 0x36e16, 0x356038);
writesequence(0x002285FF, 0x300, 320200, 0x3aa0a4);
run solution and game create 3 files:
sequence-002285FF-003AA0A4.bin
sequence-002285FF-00356038.bin
sequence-002285FF-002DC4E0.bin
In start sub_main.cpp in remc2 set debugafterload = 1(no wait to load - test on start level)
and this code(after DrawGameFrame();):
//adress 2285ff
#ifdef DEBUG_SEQUENCES
if (debugafterload)
{
Bit8u origbyte23 = 0;
Bit8u remakebyte23 = 0;
int comp23;
comp23 = compare_with_sequence((char)"002285ff-002DC4E0", (Bit8u*)x_BYTE_10B4E0_terraintype, 0x2dc4e0, debugcounter_47560_2, 0x70000, 0x10000, &origbyte23, &remakebyte23);
comp23 = compare_with_sequence((char*)"002285ff-002DC4E0", (Bit8u*)x_BYTE_11B4E0_height, 0x2dc4e0, debugcounter_47560_2, 0x70000, 0x10000, &origbyte23, &remakebyte23, 0x10000);
comp23 = compare_with_sequence((char*)"002285ff-002DC4E0", (Bit8u*)x_BYTE_12B4E0_shading, 0x2dc4e0, debugcounter_47560_2, 0x70000, 0x10000, &origbyte23, &remakebyte23, 0x20000);
comp23 = compare_with_sequence((char*)"002285ff-002DC4E0", (Bit8u*)x_BYTE_13B4E0_angle, 0x2dc4e0, debugcounter_47560_2, 0x70000, 0x10000, &origbyte23, &remakebyte23, 0x30000);
//comp20 = compare_with_sequence((char*)"00228320", (Bit8u*)x_BYTE_14B4E0, 0x2dc4e0, debugcounter11, 0x70000,0x10000, &origbyte20, &remakebyte20, 0x40000);
comp23 = compare_with_sequence((char*)"002285ff-002DC4E0", (Bit8u*)x_WORD_15B4E0_source, 0x2dc4e0, debugcounter_47560_2, 0x70000, 0x20000, &origbyte23, &remakebyte23, 0x50000);
comp23 = compare_with_sequence_D41A0((char*)"002285ff-00356038", (Bit8u*)& D41A0_BYTESTR_0, 0x356038, debugcounter_47560_2, 224790, &origbyte23, &remakebyte23);
debugcounter_47560_2++;
}
#endif DEBUG_SEQUENCES
After running remc2 test not passed - in 55116+x_BYTE_12B4E0_shading is difference, and I will find point of this bug.
When you find where in code original game is data changed, you can use this command:
addprocedurestop(0x227830, 0, true, true, 0x356038+0xd49a, 0x12345678);
-first debugger stopped on start game 0x227830(begin of sub_46830_main_loop)
-next debugger stopped on change 0x356038+0xd49a(D41A0_BYTESTR_0+0xd49a)
For data compare I now use:
this command in dosbox-x-remc2:
writeseqall(0x22A280);
and this in remc2:
#ifdef DEBUG_SEQUENCES
add_compare(0x22A280, debugafterload);
#endif DEBUG_SEQUENCES
(0x22A280 is address in disassembled code)