22-09-2007, 03:54 AM
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:
Replace:
With this:
Under that, add this code inside: Inside If MapNpc(i).Num > 0 Then!
So it looks like:
Below that, add this code into: If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
So it looks like:
Below:
Add:
Below this:
Add:
Now, replace this:
With this:
Under:
Add:
Under (this is inside "playerdata"):
Add:
Now at the bottom of:
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!
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
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
Code:
Call BltEnemySpace(i)
Code:
If MapNpc(i).Num > 0 Then
' Blit tiles around the npc
Call BltEnemySpace(i)
End If
Code:
Call BltPlayerSpace(i)
Code:
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
' Blit tiles around the player
Call BltPlayerSpace(i)
End If
Code:
' Blit out the npcs
For i = 1 To MAX_MAP_NPCS
Call BltNpc(i)
Next i
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
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
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
Code:
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Call BltFringeTile(x, y)
Next x
Next y
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
Code:
Public InEditor As Boolean
Code:
Public MapRedraw As Boolean
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
Code:
MapRedraw = True
Code:
If LCase(Parse(0)) = "mapdone" Then
Code:
MapRedraw = True
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!