Option Strict Off
Option Explicit On
Friend Class file556
    Public itemdata As IO.MemoryStream
	Public itemlen As Short
	Public objs As Short
	
	'UPGRADE_WARNING: Lower bound of array objstrings was changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="0F1C9BE1-AF9D-476E-83B1-17D43BECFF20"'
	Private objstrings(200) As String
	
	Public Function objstring(ByVal num As Short) As String
		objstring = objstrings(num)
	End Function
    Public Sub setobjstring(ByVal num As Short, ByVal s As String)
        objstrings(num) = s
    End Sub
	Public Function objtype(ByVal num As Short) As String
		
		Dim ItemType As Short
		
		ItemType = num 'graphics.f559.obj(num).itemtype
		If ItemType >= 157 And ItemType < 165 Then
			objtype = "Food"
		ElseIf ItemType >= 70 And ItemType < 128 Then 
			objtype = "Armor"
		ElseIf ItemType >= 24 And ItemType < 70 Then 
			objtype = "Weapon"
		Else
			objtype = "Misc"
		End If
		
	End Function
	'text file containing all the names of objects
	
	
	Public Sub read()
        Dim data As Byte
        Dim s As String
        Dim i As Integer
        Dim j As Integer
		
        s = ""
		j = 1
        For i = 1 To itemlen
            itemdata.Position = i - 1
            data = New IO.BinaryReader(itemdata).ReadByte()
            s = s & ChrW(data And &H7F)
            If data >= 128 Then
                objstrings(j) = s
                j = j + 1
                s = ""
            End If
        Next
		
		objs = j - 1
	End Sub
	
    Sub write_byte(ByRef num As Byte)
        'UPGRADE_ISSUE: ChrB function is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="367764E5-F3F8-4E43-AC3E-7FE0B5E074E2"'
        itemdata.Position = itemdata.Length
        itemdata.WriteByte(num)
    End Sub
	
    Public Sub update()
        Dim i As Short
        Dim j As Short
        Dim b As Byte
        'UPGRADE_NOTE: chr was upgraded to chr_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
        Dim chr_Renamed As String

        itemdata = New IO.MemoryStream
        For i = 1 To 200
            For j = 1 To (Len(objstrings(i)) - 1)
                b = AscW(objstrings(i)(j - 1))
                write_byte(b)
            Next
            'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            If Len(objstrings(i)) = 0 Then
                write_byte(128) 'hack, write a 0 string with 0x80 bit set...
            Else

                'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                chr_Renamed = Mid(objstrings(i), Len(objstrings(i)), 1)
                'UPGRADE_ISSUE: AscB function is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="367764E5-F3F8-4E43-AC3E-7FE0B5E074E2"'
                b = AscW(chr_Renamed)
                b = b And &H7F
                b = b + &H80
                write_byte(b)
            End If
        Next

        'graphics.setitemsize 557, LenB(itemdata)
        'graphics.setitemstr 557, itemdata
        'UPGRADE_ISSUE: LenB function is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="367764E5-F3F8-4E43-AC3E-7FE0B5E074E2"'
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setgitemsize. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        graphics.setgitemsize(556, itemdata.Length)
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setgitemdata. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        graphics.setgitemdata(556, itemdata)
    End Sub
End Class