Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HUGE optimization
#14
Quote:The "engine" is essentially 15 (if that?) lines of dx surface initialization and some calls all over the place to looped texture painting. Explain how preventing tilesheet renders of 0,0 breaks the code in any way shape or form?

if you do not understand how it is an "engine", here is the walk through

It starts off by counting the number of graphics. Sprites, Items, etc, to dimension a set of arrays, using UDT, so it's variables can be referenced easier.
it looks like this
Code:
Private Type DD_BufferRec
    Surface As DirectDrawSurface7
    SurfDescription As DDSURFACEDESC2
    SurfTimer As Long
End Type
When a graphic is used, for example, you see a new NPC on a map and its sprite number 154. This "engine" automatically loads the correct graphic into memory with this sub
Code:
Public Sub InitDDSurf(FileName As String, ByRef DD_SurfBuffer As DD_BufferRec)

' ... lets ignore this stuff to save space and get straight to the bottom part

ErrorHandle:

    Select Case Err
        
        ' File not found
        Case 53
            MsgBox "missing file: " & FileName
            Call DestroyGame
        
        ' DirectDraw does not have enough memory to perform the operation.
        Case DDERR_OUTOFMEMORY
            MsgBox "Out of system memory"
            Call DestroyGame
            
        ' DirectDraw does not have enough display memory to perform the operation.
        Case DDERR_OUTOFVIDEOMEMORY
            Call DevMsg("Out of video memory, attempting to re-initialize using system memory", BrightRed)

            DDSD_Temp.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY

            Call ReInitDD
End Sub

Instead of checking if the file exists every time, it just handles file not found error to improve performance of this often-called method.
Based on what you see above in the error handler, attempts to load all graphics into your video RAM, and then if there insufficient space, the "engine" re-initializes using system memory.

The Re-initialization function is pretty neat, because it handles nearly every type of potential crash, such as: changing resolution or color mode, a screensaver or a 3D fullscreen application starts to run.

But back to explaining how this is an "engine"

so after your graphic isn't being rendering anymore, its automatically unloaded from your RAM, this loop helps
Code:
' Check if surface is ready to be unloaded
        If tmr10000 < Tick Then
            ' Sprites
            For i = 1 To NumSprites
                Call DD_CheckSurfTimer(DDS_Sprite(i))
            Next
            
            ' Spells
            For i = 1 To NumSpells
                Call DD_CheckSurfTimer(DDS_Spell(i))
            Next
            
            ' Items
            For i = 1 To NumItems
                Call DD_CheckSurfTimer(DDS_Item(i))
            Next
            
            tmr10000 = Tick + 10000
        End If

Then, when we get to the rendering, there are wrapper methods that draw to pre-calculated positions, created to enhance the functionality of the "engine"

But anyway if you don't think its an engine, then its all good

but to the main issue at hand

if you are not drawing because ground = 0, in that location, it will keep the trash in the backbuffer from the previous frames, there's nothing that clears/refreshes your screen/buffer, so the "engine" is dependent on drawing "blank" tiles to refresh the entire backbuffer

if you do not understand, speak with Genusis for more information, he has proven to be knowledgeable with DirectDraw7, beta tested the MS4 DD7 rendering engine, and submitted bug reports.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)