Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

Reversing MineSweeper Board Question

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

If you intended to correct an error in the post then please contact us.

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
010036E6 TEST BYTE PTR DS:[ECX+ESI+1005340],80 ; [cell_memory_address] == is already mine?
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 this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!