Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. Public Function LoadGrhData() As Boolean
  2. On Error GoTo ErrorHandler
  3. Dim Rutafile As String
  4. Dim Grh As Long
  5. Dim Frame As Long
  6. Dim Handle As Integer
  7. Dim fileVersion As Long
  8.  
  9. Rutafile = CurDir() & "\Init\Graficos.ind" 'Indicamos donde se encuentra el archivo y como se llama
  10.  
  11. Handle = FreeFile()
  12. FileOpen(Handle, Rutafile, OpenMode.Binary, OpenAccess.Read) 'Abrimos el archivo
  13.  
  14. Seek(Handle, 1)
  15. FileGet(Handle, fileVersion) 'Versión del archivo
  16. FileGet(Handle, GrhCount) 'Cantidad de Grh's
  17.  
  18. Dim GrhData(0 To GrhCount) As GrhDat
  19.  
  20. While Not EOF(Handle)
  21. FileGet(Handle, Grh)
  22.  
  23. If Grh <> 0 Then
  24. With GrhData(Grh)
  25. FileGet(Handle, .NumFrames)
  26.  
  27. If .NumFrames <= 0 Then GoTo ErrorHandler
  28.  
  29. .Active = True
  30.  
  31. ReDim .Frames(0 To GrhData(Grh).NumFrames)
  32.  
  33. If .NumFrames > 1 Then
  34. 'Read a animation GRH set
  35. For Frame = 1 To .NumFrames
  36. FileGet(Handle, .Frames(Frame))
  37. If .Frames(Frame) <= 0 Or .Frames(Frame) > GrhCount Then GoTo ErrorHandler
  38. Next Frame
  39.  
  40. FileGet(Handle, .Speed)
  41.  
  42. If .Speed <= 0 Then GoTo ErrorHandler
  43.  
  44. 'Compute width and height
  45. .pixelHeight = GrhData(.Frames(1)).pixelHeight
  46. If .pixelHeight <= 0 Then GoTo ErrorHandler
  47.  
  48. .pixelWidth = GrhData(.Frames(1)).pixelWidth
  49. If .pixelWidth <= 0 Then GoTo ErrorHandler
  50.  
  51. .TileWidth = GrhData(.Frames(1)).TileWidth
  52. If .TileWidth <= 0 Then GoTo ErrorHandler
  53.  
  54. .TileHeight = GrhData(.Frames(1)).TileHeight
  55. If .TileHeight <= 0 Then GoTo ErrorHandler
  56. Else
  57. 'Read in normal GRH data
  58. FileGet(Handle, .FileNum)
  59. If .FileNum <= 0 Then GoTo ErrorHandler
  60.  
  61. FileGet(Handle, GrhData(Grh).SX)
  62. If .SX < 0 Then GoTo ErrorHandler
  63.  
  64. FileGet(Handle, .SY)
  65. If .SY < 0 Then GoTo ErrorHandler
  66.  
  67. FileGet(Handle, .pixelWidth)
  68. If .pixelWidth <= 0 Then GoTo ErrorHandler
  69.  
  70. FileGet(Handle, .pixelHeight)
  71. If .pixelHeight <= 0 Then GoTo ErrorHandler
  72.  
  73. 'Compute width and height
  74. .TileWidth = .pixelWidth / 32 ' TilePixelHeight
  75. .TileHeight = .pixelHeight / 32 ' TilePixelWidth
  76.  
  77. .Frames(1) = Grh
  78. End If
  79. End With
  80. End If
  81. End While
  82.  
  83. FileClose(Handle) 'Cerramos el archivo
  84. ErrorHandler:
  85. LoadGrhData = False
  86. MsgBox("Error en la carga de Graficos.ind - Grh: " & Grh)
  87. End Function
  88. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement