← Back to DevelopmentAging & Mixing viewer.dll generatorProgramsClan filesInternet Information ServiceOllyDbg tutorialsMiscellaneousSkinsLinks / Files

adding_screen_resolution

← Back to Miscellaneous
Here's a simple way to add game resolutions.

Which resolution is decided depending on the ScreenSize value (it's stored in EAX). A switch structure is used :

OllyDbg - Client side

00435C6B  |.  83C4 04       ADD ESP,4
00435C6E  |.  83E8 00       SUB EAX,0                                ; Switch (cases 0..2, 4 exits)
00435C71  |.  74 32         JE SHORT 00435CA5
00435C73  |.  48            DEC EAX
00435C74  |.  74 19         JE SHORT 00435C8F
00435C76  |.  48            DEC EAX
00435C77  |.  75 40         JNE SHORT 00435CB9
00435C79  |.  C705 84A78B00 MOV DWORD PTR DS:[8BA784],500            ; Case 2 of switch client.435C6E
00435C83  |.  C705 88A78B00 MOV DWORD PTR DS:[8BA788],400
00435C8D  |.  EB 2A         JMP SHORT 00435CB9
00435C8F  |>  C705 84A78B00 MOV DWORD PTR DS:[8BA784],400            ; Case 1 of switch client.435C6E
00435C99  |.  C705 88A78B00 MOV DWORD PTR DS:[8BA788],300
00435CA3  |.  EB 14         JMP SHORT 00435CB9
00435CA5  |>  C705 84A78B00 MOV DWORD PTR DS:[8BA784],320            ; Case 0 of switch client.435C6E
00435CAF  |.  C705 88A78B00 MOV DWORD PTR DS:[8BA788],258
00435CB9  |>  8B0D 98E35E00 MOV ECX,DWORD PTR DS:[5EE398]            ; ASCII "SOFTWARE\Triglow Pictures\PristonTale", default case of switch client.435C6E


Here we can see the 3 resolutions in the case.
The problem with the case structure, is that it's limited to those case. Adding new cases would require alot of extra code.
We are going to store the resolution in the memory and make the game load it dynamically.

For this example I'm going to store the resolution at the offset 4430000.
Each value of the resolution is a DWORD. Like this :

OllyDbg - Client side



First resolution is offsets 4430000 and 4430004.
Second resolution is offsets 4430008 and 443000C.
Etc.

We have Width = 4430000 + EAX * 8, and Height = 4430004 + EAX * 8.

Now our new code. Check the comments for the details :

OllyDbg - Client side

00435C6B  |.  83C4 04                   ADD ESP,4
00435C6E  |.  83F8 00                   CMP EAX,0                              ; Lower limit
00435C71  |.  7D 05                     JGE SHORT 00435C78                     ; If it's above 0, check upper limit
00435C73  |.  B8 00000000               MOV EAX,0                              ; If it's below 0, it's invalid, we set 0
00435C78  |>  83F8 03                   CMP EAX,3                              ; Check the upper limit
00435C7B  |.  7C 05                     JL SHORT 00435C82                      ; If it's below the limit, we load values
00435C7D  |.  B8 00000000               MOV EAX,0                              ; If it's above the limit, it's invalid, we set 0
00435C82  |>  8B0CC5 00004304           MOV ECX,DWORD PTR DS:[EAX*8+4430000]   ; Loading width in ECX
00435C89  |.  890D 84A78B00             MOV DWORD PTR DS:[8BA784],ECX          ; Setting width
00435C8F  |.  8B0CC5 04004304           MOV ECX,DWORD PTR DS:[EAX*8+4430004]   ; Loading height in ECX
00435C96  |.  890D 88A78B00             MOV DWORD PTR DS:[8BA788],ECX          ; Setting height
00435C9C  |.  90                        NOP
00435C9D  |.  90                        NOP
00435C9E  |.  90                        NOP
00435C9F  |.  90                        NOP
00435CA0  |.  90                        NOP
00435CA1  |.  90                        NOP
00435CA2  |.  90                        NOP
00435CA3  |.  90                        NOP
00435CA4  |.  90                        NOP
00435CA5  |.  90                        NOP
00435CA6  |.  90                        NOP
00435CA7  |.  90                        NOP
00435CA8  |.  90                        NOP
00435CA9  |.  90                        NOP
00435CAA  |.  90                        NOP
00435CAB  |.  90                        NOP
00435CAC  |.  90                        NOP
00435CAD  |.  90                        NOP
00435CAE  |.  90                        NOP
00435CAF  |.  90                        NOP
00435CB0  |.  90                        NOP
00435CB1  |.  90                        NOP
00435CB2  |.  90                        NOP
00435CB3  |.  90                        NOP
00435CB4  |.  90                        NOP
00435CB5  |.  90                        NOP
00435CB6  |.  90                        NOP
00435CB7  |.  90                        NOP
00435CB8  |.  90                        NOP
00435CB9  |>  8B0D 98E35E00             MOV ECX,DWORD PTR DS:[5EE398]          ; ASCII "SOFTWARE\Triglow Pictures\PristonTale"


A few thing about this code:
* What I call the lower limit is 0 no matter what. It's also the default resolution (800x600) if an invalid on is set
* The upper limit is equal to the number of resolution. For instance, here I have for ScreenSize :
- 0 : 800x600
- 1 : 1024x768
- 2 : 1280x1080
Even though the maximum value for ScreenSize is 2, that's 3 resolutions. My upper limit is 3.


Done :) . It's much simpler like this.


If you want to add a resolution, you just need to:
* Add the 2 values for the new resolution
* Increase the upper limit
Also, if you add 16:9 and 16:10 resolutions, 2 black bands will appear on the sides of the screen.

For instance let's say I want to add the resolution 1440x900.
I'm adding the values:

OllyDbg - Client side



I increase the upper limit :

OllyDbg - Client side

00435C78     \83F8 04                   CMP EAX,4                              ; Check the upper limit


Done. I just have to configure ScreenSize with value 3 in ptReg.rgx and the game will launch in 1440x900.