Public Group

Reversing MineSweeper Board Question

This topic is 2854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

010036A7 MOV DWORD PTR DS:[1005334],EAX ; [0x1005334] = Width
010036AC MOV DWORD PTR DS:[1005338],ECX ; [0x1005338] = Height
010036B2 CALL winmine.01002ED5 ; Generate empty block of memory and clears it
010036B7 MOV EAX,DWORD PTR DS:[10056A4]
010036BC MOV DWORD PTR DS:[1005160],EDI
010036C2 MOV DWORD PTR DS:[1005330],EAX ; [0x1005330] = number of mines
; loop over the number of mines
010036C7 PUSH DWORD PTR DS:[1005334] ; push Max Width into the stack
010036CD CALL winmine.01003940 ; Mine_Width = randomize x position (0 .. max width-1)
010036D2 PUSH DWORD PTR DS:[1005338] ; push Max Height into the stack
010036D8 MOV ESI,EAX
010036DA INC ESI ; Mine_Width = Mine_Width + 1
010036DB CALL winmine.01003940 ; Mine_Height = randomize y position
; (0 .. max height-1)
010036E0 INC EAX ; Mine_Height = Mine_Height +1
010036E1 MOV ECX,EAX ; calculate the address of the cell in the memory block
; (the map)
010036E3 SHL ECX,5 ; the calculation goes:
; cell_memory_address = 0x1005340 + 32 * height + width
010036EE JNZ SHORT winmine.010036C7 ; if already mine start over this iteration
010036F0 SHL EAX,5 ; otherwise, set this cell as mine
010036F3 LEA EAX,DWORD PTR DS:[EAX+ESI+1005340]
010036FA OR BYTE PTR DS:[EAX],80
010036FD DEC DWORD PTR DS:[1005330]
01003703 JNZ SHORT winmine.010036C7 ; go to next iteration

I understand that the minesweeper Board is stored in memory as a 2 dimensional array but i cannot quite understand the above calcularion for getting the address of a cell/box from
the minesweeper grid using the following formula.

cell_memory_address = 0x1005340 + 32 * height + width

Why is the address being multiplied by 32?

Share on other sites
The address isn't being multiplied by 32, the height is.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 12
• 9
• 11
• 15