Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function LoadGrhData() As Boolean
- On Error GoTo ErrorHandler
- Dim Rutafile As String
- Dim Grh As Long
- Dim Frame As Long
- Dim Handle As Integer
- Dim fileVersion As Long
- Rutafile = CurDir() & "\Init\Graficos.ind" 'Indicamos donde se encuentra el archivo y como se llama
- Handle = FreeFile()
- FileOpen(Handle, Rutafile, OpenMode.Binary, OpenAccess.Read) 'Abrimos el archivo
- Seek(Handle, 1)
- FileGet(Handle, fileVersion) 'Versión del archivo
- FileGet(Handle, GrhCount) 'Cantidad de Grh's
- Dim GrhData(0 To GrhCount) As GrhDat
- While Not EOF(Handle)
- FileGet(Handle, Grh)
- If Grh <> 0 Then
- With GrhData(Grh)
- FileGet(Handle, .NumFrames)
- If .NumFrames <= 0 Then GoTo ErrorHandler
- .Active = True
- ReDim .Frames(0 To GrhData(Grh).NumFrames)
- If .NumFrames > 1 Then
- 'Read a animation GRH set
- For Frame = 1 To .NumFrames
- FileGet(Handle, .Frames(Frame))
- If .Frames(Frame) <= 0 Or .Frames(Frame) > GrhCount Then GoTo ErrorHandler
- Next Frame
- FileGet(Handle, .Speed)
- If .Speed <= 0 Then GoTo ErrorHandler
- 'Compute width and height
- .pixelHeight = GrhData(.Frames(1)).pixelHeight
- If .pixelHeight <= 0 Then GoTo ErrorHandler
- .pixelWidth = GrhData(.Frames(1)).pixelWidth
- If .pixelWidth <= 0 Then GoTo ErrorHandler
- .TileWidth = GrhData(.Frames(1)).TileWidth
- If .TileWidth <= 0 Then GoTo ErrorHandler
- .TileHeight = GrhData(.Frames(1)).TileHeight
- If .TileHeight <= 0 Then GoTo ErrorHandler
- Else
- 'Read in normal GRH data
- FileGet(Handle, .FileNum)
- If .FileNum <= 0 Then GoTo ErrorHandler
- FileGet(Handle, GrhData(Grh).SX)
- If .SX < 0 Then GoTo ErrorHandler
- FileGet(Handle, .SY)
- If .SY < 0 Then GoTo ErrorHandler
- FileGet(Handle, .pixelWidth)
- If .pixelWidth <= 0 Then GoTo ErrorHandler
- FileGet(Handle, .pixelHeight)
- If .pixelHeight <= 0 Then GoTo ErrorHandler
- 'Compute width and height
- .TileWidth = .pixelWidth / 32 ' TilePixelHeight
- .TileHeight = .pixelHeight / 32 ' TilePixelWidth
- .Frames(1) = Grh
- End If
- End With
- End If
- End While
- FileClose(Handle) 'Cerramos el archivo
- ErrorHandler:
- LoadGrhData = False
- MsgBox("Error en la carga de Graficos.ind - Grh: " & Grh)
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement