VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "file559"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public itemdata As String
Public itemloc As Long


Private bytes10340(1 To 4) As Byte
Private bytes10336(1 To 256) As Byte
Private bytes10080(1 To 64) As Byte
Private bytes10016(1 To 256) As Byte
Private Doors(1 To 4) As New door
Private MonsterDrops(1 To 40) As New monsterdrop
Private soundnums(1 To 8) As Byte
Private Monsters(1 To 27) As New monster
Private foodvalues(1 To 8) As Long
Private bytes8946(1 To 54) As Byte 'misc item weights
Public word8892 As Long
Private armors(1 To 58) As New Armor
Private weapons(1 To 46) As New weapon
Private objs(1 To 180) As New obj
Private bytes7302(1 To 16) As Byte
Private dbentrysizes(1 To 16) As Byte
Private deltaxs(1 To 4) As Long
Private deltays(1 To 4) As Long

Function door(ByVal num As Integer) As door
    Set door = Doors(num)
End Function
Function monsterdrop(ByVal num As Integer) As monsterdrop
    Set monsterdrop = MonsterDrops(num)
End Function
Function soundnum(ByVal num As Integer) As Byte
    soundnum = soundnums(num)
End Function
Function monster(ByVal num As Integer) As monster
    Set monster = Monsters(num)
End Function
Function FoodValue(ByVal num As Integer) As Long
    FoodValue = foodvalues(num)
End Function
Function setfoodvalue(ByVal num As Integer, ByVal val As Long)
    foodvalues(num) = val
End Function
Function Armor(ByVal num As Integer) As Armor
    Set Armor = armors(num)
End Function
Function weapon(ByVal num As Integer) As weapon
    Set weapon = weapons(num)
End Function
Function obj(ByVal num As Integer) As obj
    Set obj = objs(num)
End Function
Function dbentrysize(ByVal num As Integer) As Byte
    dbentrysize = dbentrysizes(num)
End Function
Function deltax(ByVal num As Integer) As Long
    deltax = deltaxs(num)
End Function
Function deltay(ByVal num As Integer) As Long
    deltay = deltays(num)
End Function

Function byte10340(ByVal num As Integer) As Byte
    byte10340 = bytes10340(num)
End Function
Function byte10336(ByVal num As Integer) As Byte
    byte10336 = bytes10336(num)
End Function
Function byte10080(ByVal num As Integer) As Byte
    byte10080 = bytes10080(num)
End Function
Function byte10016(ByVal num As Integer) As Byte
    byte10016 = byte10016(num)
End Function
Function byte8946(ByVal num As Integer) As Byte
    byte8946 = bytes8946(num)
End Function
Function byte7302(ByVal num As Integer) As Byte
    byte7302 = bytes7302(num)
End Function

Function read_byte() As Byte
    read_byte = AscB(MidB(itemdata, itemloc, 1))
    itemloc = itemloc + 1
End Function

Function read_int() As Long
    Dim b1, b2 As Byte
    Dim l1 As Long
    b2 = read_byte
    b1 = read_byte
    read_int = b2
    read_int = read_int * 256
    read_int = read_int + b1
End Function

Function write_byte(num As Byte)
    itemdata = itemdata + ChrB(num)
    itemloc = itemloc + 1
End Function
Function write_int(num As Long)
    Dim b1, b2 As Byte
    Dim l1 As Long
    l1 = num And &HFF00
    b1 = l1 / &H100
    b2 = num And &HFF
    write_byte (b1)
    write_byte (b2)
End Function


Public Sub update()
    Dim i As Integer
    Dim atknum As Integer
    Dim var As Integer
    
    itemdata = ""
    itemloc = 1
    
    For i = 1 To 4
        write_byte bytes10340(i)
    Next
    For i = 1 To 256
        write_byte bytes10336(i)
    Next
    For i = 1 To 64
        write_byte bytes10080(i)
    Next
    For i = 1 To 256
        write_byte bytes10016(i)
    Next
    
    For i = 1 To 4
        write_byte Doors(i).Byte0
        write_byte Doors(i).Strength
    Next
        
    For i = 1 To 40
        write_int MonsterDrops(i).word0
    Next
    
    For i = 1 To 8
        write_byte soundnums(i)
    Next
    
    For i = 1 To 27
        write_byte Monsters(i).IdNum
        write_byte Monsters(i).attacksound
        write_int Monsters(i).Word2
        write_int Monsters(i).Word4
        write_byte Monsters(i).Speed
        write_byte Monsters(i).MinSpeed
        write_byte Monsters(i).Armor
        write_byte Monsters(i).BaseHealth
        write_byte Monsters(i).quickness
        write_byte Monsters(i).Poison
        write_byte Monsters(i).power
        write_byte Monsters(i).Unused1
        write_int Monsters(i).word14
        write_int Monsters(i).word16
        write_int Monsters(i).word18
        write_int Monsters(i).word20
        write_byte Monsters(i).byte22
        write_byte Monsters(i).byte23
        write_byte Monsters(i).damagetype
        write_byte Monsters(i).Unused2
    Next '702
    
    For i = 1 To 8
        write_int foodvalues(i)
    Next
    For i = 1 To 54
        write_byte bytes8946(i)
    Next
    
    write_int word8892

    For i = 1 To 58
        write_byte armors(i).Weight
        write_byte armors(i).Armor
        write_byte armors(i).Byte2
        write_byte armors(i).Unused1
    Next '232
    
    For i = 1 To 46
        write_byte weapons(i).Weight
        write_byte weapons(i).Byte1
        write_byte weapons(i).Damage
        write_byte weapons(i).Distance
        write_int weapons(i).Word4
    Next '276
    
    For i = 1 To 180
        write_int objs(i).ItemType
        write_byte objs(i).FloorGraphic
        write_byte objs(i).Combos
        write_int objs(i).WearLocs
    Next '1080
    
    For i = 1 To 16
        write_byte bytes7302(i)
    Next
    
    For i = 1 To 16
        write_byte dbentrysizes(i)
    Next
    
    For i = 1 To 4
        write_int deltaxs(i)
    Next
    
    For i = 1 To 4
        write_int deltays(i)
    Next

    'graphics.setitemsize 560, LenB(itemdata)
    'graphics.setitemstr 560, itemdata
    graphics.setgitemsize 559, LenB(itemdata)
    graphics.setgitemdata 559, itemdata
End Sub


Public Sub read()
    Dim i As Integer
    Dim atknum As Integer
    Dim var As Integer
    
    itemloc = 1
    
    For i = 1 To 4
        bytes10340(i) = read_byte
    Next
    For i = 1 To 256
        bytes10336(i) = read_byte
    Next
    For i = 1 To 64
        bytes10080(i) = read_byte
    Next
    For i = 1 To 256
        bytes10016(i) = read_byte
    Next
    
    For i = 1 To 4
        Doors(i).Byte0 = read_byte
        Doors(i).Strength = read_byte
    Next
        
    For i = 1 To 40
        MonsterDrops(i).word0 = read_int
    Next
    
    For i = 1 To 8
        soundnums(i) = read_byte
    Next
    
    For i = 1 To 27
        Monsters(i).IdNum = read_byte
        Monsters(i).attacksound = read_byte
        Monsters(i).Word2 = read_int
        Monsters(i).Word4 = read_int
        Monsters(i).Speed = read_byte
        Monsters(i).MinSpeed = read_byte
        Monsters(i).Armor = read_byte
        Monsters(i).BaseHealth = read_byte
        Monsters(i).quickness = read_byte
        Monsters(i).Poison = read_byte
        Monsters(i).power = read_byte
        Monsters(i).Unused1 = read_byte
        Monsters(i).word14 = read_int
        Monsters(i).word16 = read_int
        Monsters(i).word18 = read_int
        Monsters(i).word20 = read_int
        Monsters(i).byte22 = read_byte
        Monsters(i).byte23 = read_byte
        Monsters(i).damagetype = read_byte
        Monsters(i).Unused2 = read_byte
    Next '702
    
    For i = 1 To 8
        foodvalues(i) = read_int
    Next
    For i = 1 To 54
        bytes8946(i) = read_byte
    Next
    
    word8892 = read_int

    For i = 1 To 58
        armors(i).Weight = read_byte
        armors(i).Armor = read_byte
        armors(i).Byte2 = read_byte
        armors(i).Unused1 = read_byte
    Next '232
    
    For i = 1 To 46
        weapons(i).Weight = read_byte
        weapons(i).Byte1 = read_byte
        weapons(i).Damage = read_byte
        weapons(i).Distance = read_byte
        weapons(i).Word4 = read_int
    Next '276
    
    For i = 1 To 180
        objs(i).ItemType = read_int
        objs(i).FloorGraphic = read_byte
        objs(i).Combos = read_byte
        objs(i).WearLocs = read_int
    Next '1080
    
    For i = 1 To 16
        bytes7302(i) = read_byte
    Next
    
    For i = 1 To 16
        dbentrysizes(i) = read_byte
    Next
    
    For i = 1 To 4
        deltaxs(i) = read_int
    Next
    
    For i = 1 To 4
        deltays(i) = read_int
    Next
End Sub



'  i8  Byte10340[4];
'  i8  Byte10336[256]; //       ...
'  i8  Byte10080[64];  //       ...
'  i8  Byte10016[256]; //       ...
'  i16 DoorCharacteristics[4]; //9760// swapped when read.
'  i16 MonsterDroppings[40];   //9752//
'  ui8 uByte9672[8];   // Sound numbers???
'  ITEM26 MonsterDescriptor[27];//9664
'  //ITEM26 Item9664[27];//
'  i16 FoodValue[8];//8962 // obj_Apple to obj_DragonSteak      ...
'                   // swapped when read
'  i8  Byte8946[54];   //
'  i16 Word8892;       //       ...
'  CLOTHINGDESC ClothingDesc[58]; //8890
'  WEAPONDESC weapons[46];//8658   // Used for Database5 objects
'                      // word4 swapped when read;
'                      // pDB5->weaponType() is index
'  OBJDESC ObjDesc[180];//8382
'            // -object Type
'            // -effect of objects when attacking?
'            // -Words 0 and 4 swapped when read
'            // -
'            // -Word4 bit 0 = consumable??
'            // -indexed by Object Index
'            //    = scroll type   +  0 //  1 Scroll type
'            //    = chest type    +  1 //  1 Chest types
'            //    = potion type   +  2 // 21 Potion types
'            //    = weapon type   + 23 // 46 Weapon types
'            //    = clothing type + 69 // 58 Clothing types
'            //    = food type     +127 // 53 Misc types
'
'  i8  Byte7302[16];   //  #extra entries in each 'misc' database     ...
'  i8  DBEntrySize[16];//7286 // Size of entries in each 'misc' database     ...
'                             // Always an even number! Sometimes zero.
'  i16 DeltaY[4]; //7270  // deltay for 4 directions
'  i16 DeltaX[4]; //7262    // deltax for 4 directions End of 22f


