Reply To: Laura Bow Remake?

HOME Forums Laura Bow Series Laura Bow Remake? Reply To: Laura Bow Remake?


I am attempting to mirror the animation of Sierra games in Excel.  I have been able to load a 24bit bitmap into the cells of Excel as a background.  Then I blit the background with a series of animated egos(sprites) that are also cells in Excel.  Using a priority map I can place the ego behind a fence.  Here is the code for loading a 24 bit image into Excel.  The other code is too much to show here.

Sub openbinfile()
    Dim testdata As Byte
    Dim mypix As pix
    Dim datasize As Long
    Dim lsb As Byte
    Dim msb As Byte
    Dim hres As Long
    Dim vres As Long
    Dim blkByte As Byte
    Dim bufferbites As Long
    Dim temp As Long
    Dim strFile As String

    ‘Clear data from spreadsheet
    ‘Select 24-bit bitmap file to display
    With Application.FileDialog(msoFileDialogOpen)
        .AllowMultiSelect = False
        If .Show = -1 Then
            strFile = .SelectedItems(1)
            Exit Sub
        End If
    End With

    ‘Open bmp file for reading
    Open strFile For Binary Access Read As #2

    Application.ScreenUpdating = False
    ‘Select upper left cell
    ‘Get horizontal resolution
    Seek #2, 19
    Get #2, , lsb
    Get #2, , msb
    hres = CLng(msb) * 256 + lsb
    ‘Get vertical resolution
    Seek #2, 23
    Get #2, , lsb
    Get #2, , msb
    vres = CLng(msb) * 256 + lsb
    ‘Calculate buffer size.  Rows are padded to be
    ‘multiples of 4 bytes with zeros
    bufferbites = hres * 3 ‘Each pixel is three bytes (RGB)
    ‘Determine what the next 4 byte boundary is
    temp = 0
    While temp < bufferbites
        temp = temp + 4
    ‘Calculate the number of buffer bytes used for padding
    bufferbites = temp – bufferbites
    ‘Get the total length of the file
    datasize = LOF(2)
    ‘Draw bitmap
    For y = 0 To vres – 1
        ActiveCell.Offset(1, hres).Activate
        datasize = datasize – bufferbites + 1
        For x = 0 To hres – 1
            ActiveCell.Offset(0, -1).Activate
            datasize = datasize – 3
            Seek #2, datasize
            Get #2, , mypix.Blue
            Get #2, , mypix.Green
            Get #2, , mypix.Red
            ActiveCell.Interior.Color = RGB(mypix.Red, mypix.Green, mypix.Blue)
        Next x
        datasize = datasize – 1
    Next y
    Application.ScreenUpdating = True
    Close #2 ‘Cleanup by closing file
End Sub