"Do u have do.events() inside mainloop?"
no it does not have any of those statement. I did manage to debug the program to the point it works without any major crashing.
posting code may be an issue.
I cannot post the whole program since it has hundreds of subroutines right now.
Point4 = Point1
BoxMode = ModeStandard
Last_Door = 0
Do
FrameAmount = TV.TimeElapsed / (64 - System.Math.Abs(SpeedDebug - 1))
TV.Clear()
Char_Auto = True
ButtonMode = 0
Find_Near_Items()
Cell_X = Int((16 + Camera_Pos_Y) / 32)
Cell_Y = Int((16 + Camera_Pos_X) / 32)
If Party_Layer < 4 Then
Camera_Pos_Z = CellAlt(Cell_X, Cell_Y, Party_Layer) - 16
Else
Camera_Pos_Z = Party_Layer * TallConst
End If
' ScrTxt.NormalFont_DrawText " " & Int(Cell_X) & " " & Int(Cell_Y) & " " & Int(Camera_Dir), 32, 24, Box_Font_Color, "Opening"
Party_Control()
Process_Projectiles()
Process_Spell_Effect()
Check_AI_Characters()
Human_Actions()
Position_Mesh_Characters()
If Camera_Type = 0 Then
Dir_X = System.Math.Sin((Char_Dir(Party_Leader)) / Convert_Factor)
Dir_Z = System.Math.Cos((Char_Dir(Party_Leader)) / Convert_Factor)
If CameraNormal = True Then
Camera.SetPosition(Char_X(Party_Leader) - Dir_X * 6.25, Char_Z(Party_Leader) + 6.75, Char_Y(Party_Leader) - Dir_Z * 6.25)
Else
Camera.SetPosition(Char_X(Party_Leader) - Dir_X * 5.65, Char_Z(Party_Leader) + 6.85, Char_Y(Party_Leader) - Dir_Z * 5.65)
End If
Else
End If
Camera.SetLookAt(Char_X(Party_Leader), Char_Z(Party_Leader) + 6.25, Char_Y(Party_Leader))
If Map_Type = PageMap Then
If Char_Y(Party_Leader) / 32 > (ViewSize / 2) * PageSectorSize Then
ViewFirstX = (Char_Y(Party_Leader) / (32 * PageSectorSize)) - ViewSize / 2
If ViewFirstX > PageSectors_Width - ViewSize Then ViewFirstX = PageSectors_Width - ViewSize
Else
ViewFirstX = 0
End If
If Char_X(Party_Leader) / 32 > (ViewSize / 2) * PageSectorSize Then
ViewFirstY = (Char_X(Party_Leader) / (32 * PageSectorSize)) - ViewSize / 2
If ViewFirstY > PageSectors_Length - ViewSize Then ViewFirstY = PageSectors_Length - ViewSize
Else
ViewFirstY = 0
End If
ViewLastX = ViewFirstX + ViewSize
ViewLastY = ViewFirstY + ViewSize
PS.Manage_Visable_Sectors()
End If
If Explosion_CountDown > 0 Then Animate_Explosion()
If Door_Moving(Door_Anim_Number) >= 0 Then Animate_Door()
If Push_Item >= 0 Then Animate_Pushable_Item()
If Dig_Item > 0 Then Animate_Dig()
If Transport_Phase >= 0 Then Process_Transport()
If Sky_Type > 0 Then TVAtmos.Atmosphere_Render()
If Landscape_Type > 0 Then Land.Render()
If Explosion_Light_Luma > 0 Then
Explosion_Light_Luma = Explosion_Light_Luma - FrameAmount * 0.1
If Explosion_Light_Luma > 0 Then
Light.SetLightColor(Effects_Light_ID, Explosion_Light_Luma, Explosion_Light_Luma, Explosion_Light_Luma * 0.65)
Else
Light.SetLightPosition(Effects_Light_ID, TrueVision3DTVGlobals_definst.Vector(-256, -256, -256))
End If
End If
For n = 0 To 15
If Model_Status(n) = True Then
Actor(n).SetPosition(Model_X(n), Model_Z(n) + 4, Model_Y(n))
Actor(n).SetRotation(0, Model_Dir(n), 0)
Actor(n).Render()
End If
Next n
If Map_Type = PageMap Then
If Char_Y(Party_Leader) / 32 > (ViewSize / 2) * PageSectorSize Then
ViewFirstX = (Char_Y(Party_Leader) / (32 * PageSectorSize)) - ViewSize / 2
If ViewFirstX > PageSectors_Width - ViewSize Then ViewFirstX = PageSectors_Width - ViewSize
Else
ViewFirstX = 0
End If
If Char_X(Party_Leader) / 32 > (ViewSize / 2) * PageSectorSize Then
ViewFirstY = (Char_X(Party_Leader) / (32 * PageSectorSize)) - ViewSize / 2
If ViewFirstY > PageSectors_Length - ViewSize Then ViewFirstY = PageSectors_Length - ViewSize
Else
ViewFirstY = 0
End If
ViewLastX = ViewFirstX + ViewSize
ViewLastY = ViewFirstY + ViewSize
PS.Manage_Visable_Sectors()
End If
Scene.SetMipMappingPrecision(Scene_Precision_Adjust)
Scene.SetTextureFilter(TrueVision3D.CONST_TV_TEXTUREFILTER.TV_FILTER_ANISOTROPIC)
Scene.RenderAllMeshes()
Display_Box()
TV.RenderToScreen()
Loop Until Exit_from_Game = True Or GameSolved = True
I do not see anything in the main loop that can cause it. As you can see, it calls many subroutines and many global variables.