Optimize Graphic Output V2 - William - 22-09-2007
Introduction
I will keep my old tutorial as a reference only: viewtopic.php?f=69&t=624
This tutorial increases the fps from app 300 to app 900 when the fps is unlocked in a unedited MSE1.
Download source code: http://www.key2heaven.net/GFXOutputOptimizeSrc.rar
Difficulty: 3/5
Understanding: 3/5
Backup your source!
You must realize that this tutorial is for the default layers in a unedited MSE1, so if you added more layers, you need to figure out how to add the new subs for them. Also, there is a problem if you use a longer player name, then you need to change the Xchange1-2 and Ychange1-2 for the playerspace and playerfringespace.
Client Side Only!
Begin with adding this to a module, modGameLogic works fine:
Code: Sub BltTileXY()
Dim xChange1 As Byte, xChange2 As Byte, yChange1 As Byte, yChange2 As Byte
Dim x1 As Long, y1 As Long
yChange1 = 2
yChange2 = 2
xChange1 = 2
xChange2 = 2
If GetPlayerY(MyIndex) - 2 < 0 Then yChange1 = 1
If GetPlayerY(MyIndex) + 2 > MAX_MAPY Then yChange2 = 1
If GetPlayerX(MyIndex) - 2 < 1 Then xChange1 = 1
If GetPlayerX(MyIndex) + 2 > MAX_MAPX Then xChange2 = 1
If GetPlayerY(MyIndex) - 1 < 0 Then yChange1 = 0
If GetPlayerY(MyIndex) + 1 > MAX_MAPY Then yChange2 = 0
If GetPlayerX(MyIndex) - 1 < 0 Then xChange1 = 0
If GetPlayerX(MyIndex) + 1 > MAX_MAPX Then xChange2 = 0
For y1 = GetPlayerY(MyIndex) - yChange1 To GetPlayerY(MyIndex) + yChange2
For x1 = GetPlayerX(MyIndex) - xChange1 To GetPlayerX(MyIndex) + xChange2
Call BltTile(x1, y1)
Next x1
Next y1
End Sub
Sub BltEnemySpace(ByVal i As Byte)
Dim xChange1 As Byte, xChange2 As Byte, yChange1 As Byte, yChange2 As Byte
Dim x1 As Long, y1 As Long
yChange1 = 2
yChange2 = 1
xChange1 = 1
xChange2 = 1
If MapNpc(i).y - 2 < 0 Then yChange1 = 1
If MapNpc(i).y + 2 > MAX_MAPY Then yChange2 = 1
If MapNpc(i).x - 2 < 1 Then xChange1 = 1
If MapNpc(i).x + 2 > MAX_MAPX Then xChange2 = 1
If MapNpc(i).y - 1 < 0 Then yChange1 = 0
If MapNpc(i).y + 1 > MAX_MAPY Then yChange2 = 0
If MapNpc(i).x - 1 < 0 Then xChange1 = 0
If MapNpc(i).x + 1 > MAX_MAPX Then xChange2 = 0
For y1 = MapNpc(i).y - yChange1 To MapNpc(i).y + yChange2
For x1 = (MapNpc(i).x - xChange1) To (MapNpc(i).x + xChange2)
Call BltTile(x1, y1)
Next x1
Next y1
End Sub
Sub BltPlayerSpace(ByVal i As Byte)
Dim xChange1 As Byte, xChange2 As Byte, yChange1 As Byte, yChange2 As Byte
Dim x1 As Long, y1 As Long
yChange1 = 2
yChange2 = 2
xChange1 = 3
xChange2 = 2
If GetPlayerY(i) = 2 Then yChange1 = 2
If GetPlayerY(i) = MAX_MAPY - 2 Then yChange2 = 2
If GetPlayerX(i) = 2 Then xChange1 = 2
If GetPlayerX(i) + 2 = MAX_MAPX Then xChange2 = 2
If GetPlayerY(i) = 1 Then yChange1 = 1
If GetPlayerY(i) = MAX_MAPY - 1 Then yChange2 = 1
If GetPlayerX(i) = 1 Then xChange1 = 1
If GetPlayerX(i) + 1 = MAX_MAPX Then xChange2 = 1
If GetPlayerY(i) = 0 Then yChange1 = 0
If GetPlayerY(i) = MAX_MAPY Then yChange2 = 0
If GetPlayerX(i) = 0 Then xChange1 = 0
If GetPlayerX(i) = MAX_MAPX Then xChange2 = 0
For y1 = GetPlayerY(i) - yChange1 To GetPlayerY(i) + yChange2
For x1 = (GetPlayerX(i) - xChange1) To (GetPlayerX(i) + xChange2)
Call BltTile(x1, y1)
Next x1
Next y1
End Sub
Sub BltEnemyFringeSpace(ByVal i As Byte)
Dim xChange1 As Byte, xChange2 As Byte, yChange1 As Byte, yChange2 As Byte
Dim x1 As Long, y1 As Long
yChange1 = 2
yChange2 = 1
xChange1 = 1
xChange2 = 1
If MapNpc(i).y - 2 < 0 Then yChange1 = 1
If MapNpc(i).y + 2 > MAX_MAPY Then yChange2 = 1
If MapNpc(i).x - 2 < 1 Then xChange1 = 1
If MapNpc(i).x + 2 > MAX_MAPX Then xChange2 = 1
If MapNpc(i).y - 1 < 0 Then yChange1 = 0
If MapNpc(i).y + 1 > MAX_MAPY Then yChange2 = 0
If MapNpc(i).x - 1 < 0 Then xChange1 = 0
If MapNpc(i).x + 1 > MAX_MAPX Then xChange2 = 0
For y1 = MapNpc(i).y - yChange1 To MapNpc(i).y + yChange2
For x1 = (MapNpc(i).x - xChange1) To (MapNpc(i).x + xChange2)
Call BltFringeTile(x1, y1)
Next x1
Next y1
End Sub
Sub BltPlayerFringeSpace(ByVal i As Byte)
Dim xChange1 As Byte, xChange2 As Byte, yChange1 As Byte, yChange2 As Byte
Dim x1 As Long, y1 As Long
yChange1 = 2
yChange2 = 2
xChange1 = 3
xChange2 = 2
If GetPlayerY(i) = 2 Then yChange1 = 2
If GetPlayerY(i) = MAX_MAPY - 2 Then yChange2 = 2
If GetPlayerX(i) = 2 Then xChange1 = 2
If GetPlayerX(i) + 2 = MAX_MAPX Then xChange2 = 2
If GetPlayerY(i) = 1 Then yChange1 = 1
If GetPlayerY(i) = MAX_MAPY - 1 Then yChange2 = 1
If GetPlayerX(i) = 1 Then xChange1 = 1
If GetPlayerX(i) + 1 = MAX_MAPX Then xChange2 = 1
If GetPlayerY(i) = 0 Then yChange1 = 0
If GetPlayerY(i) = MAX_MAPY Then yChange2 = 0
If GetPlayerX(i) = 0 Then xChange1 = 0
If GetPlayerX(i) = MAX_MAPX Then xChange2 = 0
For y1 = GetPlayerY(i) - yChange1 To GetPlayerY(i) + yChange2
For x1 = (GetPlayerX(i) - xChange1) To (GetPlayerX(i) + xChange2)
Call BltFringeTile(x1, y1)
Next x1
Next y1
End Sub
Sub BltFringeXY()
Dim xChange1 As Byte, xChange2 As Byte, yChange1 As Byte, yChange2 As Byte
Dim x1 As Long, y1 As Long
yChange1 = 2
yChange2 = 2
xChange1 = 2
xChange2 = 2
If GetPlayerY(MyIndex) - 2 < 0 Then yChange1 = 1
If GetPlayerY(MyIndex) + 2 > MAX_MAPY Then yChange2 = 1
If GetPlayerX(MyIndex) - 2 < 1 Then xChange1 = 1
If GetPlayerX(MyIndex) + 2 > MAX_MAPX Then xChange2 = 1
If GetPlayerY(MyIndex) - 1 < 0 Then yChange1 = 0
If GetPlayerY(MyIndex) + 1 > MAX_MAPY Then yChange2 = 0
If GetPlayerX(MyIndex) - 1 < 0 Then xChange1 = 0
If GetPlayerX(MyIndex) + 1 > MAX_MAPX Then xChange2 = 0
For y1 = GetPlayerY(MyIndex) - yChange1 To GetPlayerY(MyIndex) + yChange2
For x1 = GetPlayerX(MyIndex) - xChange1 To GetPlayerX(MyIndex) + xChange2
Call BltFringeTile(x1, y1)
Next x1
Next y1
End Sub
Replace:
Code: For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Call BltTile(x, y)
Next x
Next y
With this:
Code: If InEditor Or MapRedraw Then
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Call BltTile(x, y)
Next x
Next y
Else
Call BltTileXY
End If
Under that, add this code inside: Inside If MapNpc(i).Num > 0 Then!
Code: Call BltEnemySpace(i)
So it looks like:
Code: If MapNpc(i).Num > 0 Then
' Blit tiles around the npc
Call BltEnemySpace(i)
End If
Below that, add this code into: If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
Code: Call BltPlayerSpace(i)
So it looks like:
Code: If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
' Blit tiles around the player
Call BltPlayerSpace(i)
End If
Below:
Code: ' Blit out the npcs
For i = 1 To MAX_MAP_NPCS
Call BltNpc(i)
Next i
Add:
Code: ' Blit out the tiles around the npc
For i = 1 To MAX_MAP_NPCS
' Make sure that theres an npc there, and if not exit the sub
If MapNpc(i).Num > 0 Then
' Blit tiles around the npc
Call BltEnemyFringeSpace(i)
End If
Next i
Below this:
Code: ' Blit out players
For i = 1 To MAX_PLAYERS
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
Call BltPlayer(i)
End If
Next i
Add:
Code: ' Blit out the tiles around the player
For i = 1 To MAX_PLAYERS
' Make sure that theres an player there
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
' Blit tiles around the player
Call BltPlayerFringeSpace(i)
End If
Next i
Now, replace this:
Code: For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Call BltFringeTile(x, y)
Next x
Next y
With this:
Code: If InEditor Or MapRedraw Then
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Call BltFringeTile(x, y)
Next x
Next y
MapRedraw = False
Else
Call BltFringeXY
End If
Under:
Code: Public InEditor As Boolean
Add:
Code: Public MapRedraw As Boolean
Under (this is inside "playerdata"):
Code: ' Check if the player is the client player, and if so reset directions
If i = MyIndex Then
DirUp = False
DirDown = False
DirLeft = False
DirRight = False
End If
Add:
Now at the bottom of:
Code: If LCase(Parse(0)) = "mapdone" Then
Before the Exit Sub, add:
That should be it, im pretty sure I remembered to add everything. And I couldn't find a bug with it when I tested it. This helps a lot to improve the fps. The other surface tutorial might be a better choise, but for sure harder to add. This tutorial however could be difficult to add new things too. But onse you understand how the xchange and those variables work it's piece a cake 
Good luck and hope it work!
Re: Optimize Graphic Output V2 - seraphelic - 15-04-2008
pardon the necro. my fps only goes to about 600 after this tutorial, not to mention the text and animation doesnt work properly could you reupload william, i want to see the 900 fps boost myself. btw i did add this to a vanilla mse1.
Re: Optimize Graphic Output V2 - Coke - 15-04-2008
Depends on the machine your running dude.
Re: Optimize Graphic Output V2 - seraphelic - 15-04-2008
[EDIT]
I got everything running great, but im not sure how to go about fixing the text. The problem is that when text is blted where no players are, it isnt cleared (such as an fps label in corner). Only thing I can think of is to edit drawtext so it measures the dimensions and reblts the tiles underneath the text. I bet that would really drag the fps back down :[. Any ideas?
lol yeah I also get a 5fps max for WoW. It looks more like a slideshow than a game.
Re: Optimize Graphic Output V2 - William - 04-05-2008
Are you talking about the text when you type something? This tutorial doesn't include that, it was kinda made for a text box chat system. But either way, you might as well be talking about the chat on screen thing.
If you talk about the text typing, as the default mse1 has. You could just add a blt for like this:
Code: for i =0 to max_mapx
call blttile(x,max_mapy)
next i
Or if your talking about the chat on screen, you will need to make it some what different and a little bit more complicated. is that what you want?
Re: Important note for your security - Nean - 09-01-2009
stuv194 Wrote:Be a Professional Game Shop ,we sincerelywow gold
hope all of our Customers can have a smooth and secure transaction with us , so please keep in mind after you made an order from usgold:
Don't tell your char name or password to anyone except our supporters
keep your computer away from keylogs. And make surewow gold
there is no one by your side when you arewow gold
buying GP at our site.
I hate you.
|