Option Strict Off
Option Explicit On
Friend Class file560
    Public itemdata As IO.MemoryStream
    Public itemloc As Integer 'Now 0 based
	
	'UPGRADE_WARNING: Lower bound of array Attacks 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"'
	'UPGRADE_WARNING: Arrays can't be declared with New. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC9D3AE5-6B95-4B43-91C7-28276302A5E8"'
    Private Attacks() As attack = ADGEDotNetUt.ArrayUt(Of attack).NewArray1(44)
    'UPGRADE_WARNING: Lower bound of array Combos 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"'
    'UPGRADE_WARNING: Arrays can't be declared with New. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC9D3AE5-6B95-4B43-91C7-28276302A5E8"'
    Private Combos() As combo = ADGEDotNetUt.ArrayUt(Of combo).NewArray1(44)
    'UPGRADE_WARNING: Lower bound of array Spells 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"'
    'UPGRADE_WARNING: Arrays can't be declared with New. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC9D3AE5-6B95-4B43-91C7-28276302A5E8"'
    Private Spells() As spell = ADGEDotNetUt.ArrayUt(Of spell).NewArray1(25)
	'UPGRADE_WARNING: Lower bound of array rects 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 rects(24) As Short
	'UPGRADE_WARNING: Lower bound of array Runes 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 Runes(24) As Byte
	'UPGRADE_WARNING: Lower bound of array RuneMultipliers 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 RuneMultipliers(6) As Byte
	'UPGRADE_WARNING: Lower bound of array bytes20194 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 bytes20194(16) As Byte
	Private byte19218 As Short
	
	Function read_byte() As Byte
		'UPGRADE_ISSUE: MidB function is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="367764E5-F3F8-4E43-AC3E-7FE0B5E074E2"'
        '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"'
        itemdata.Position = itemloc
        read_byte = New IO.BinaryReader(itemdata).ReadByte()
		itemloc = itemloc + 1
	End Function
	
	Function read_int() As Integer
        Dim b1 As Byte
		Dim b2 As Byte
        b2 = read_byte()
        b1 = read_byte()
		read_int = b2
		read_int = read_int * 256
        read_int = read_int + b1
	End Function
	
    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 = itemloc
        itemdata.WriteByte(num)
        itemloc = itemloc + 1
    End Sub
    Sub write_int(ByRef num As Integer)
        Dim b1 As Byte
        Dim b2 As Byte
        Dim l1 As Integer
        l1 = num And &HFF00
        b1 = l1 / &H100
        b2 = num And &HFF
        write_byte(b1)
        write_byte(b2)
    End Sub
	
	Public Function attack(ByVal num As Short) As attack
		attack = Attacks(num)
	End Function
	Public Function Combo(ByVal num As Short) As combo
		Combo = Combos(num)
	End Function
	Public Function Spell(ByVal num As Short) As spell
		Spell = Spells(num)
	End Function
	Public Function rect(ByVal num As Short) As Short
		rect = rects(num)
	End Function
	Public Function rune(ByVal num As Short) As Byte
		rune = Runes(num)
	End Function
	'UPGRADE_NOTE: val was upgraded to val_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Public Sub setrune(ByVal num As Short, ByVal val_Renamed As Byte)
        Runes(num) = val_Renamed
    End Sub
	Public Function runemultiplier(ByVal num As Short) As Byte
		runemultiplier = RuneMultipliers(num)
	End Function
    Public Sub setrunemultiplier(ByVal num As Short, ByVal val_Renamed As Byte)
        RuneMultipliers(num) = val_Renamed
    End Sub
	Public Function byte20194(ByVal num As Short) As Byte
		byte20194 = bytes20194(num)
	End Function
    Public Sub setbyte20194(ByVal num As Short, ByVal v As Byte)
        bytes20194(num) = v
    End Sub

	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Public Sub update()
        Dim i As Short
		Dim atknum As Short
		Dim var As Short
		
        itemdata = New IO.MemoryStream
        itemloc = 0
		var = 0
		For atknum = 1 To 44
			var = var + 1 + Len(Attacks(atknum).name)
		Next 
		
		If var > 299 Then
			MsgBox("Error: Attacks total name length too large!" & Chr(13) & Chr(13) & "Total characters: " & Str(var) & "/300")
			Exit Sub
		End If
		
		For i = 1 To 24
			write_int(rects(i))
		Next 
		
		For i = 1 To 16
			write_byte(bytes20194(i))
		Next 
		
		For i = 1 To 44
			write_byte((Attacks(i).Exp))
		Next 
		For i = 1 To 44
			write_byte((Attacks(i).Skill))
		Next 
		For i = 1 To 44
			If Attacks(i).Defense < 0 Then
				Attacks(i).Defense = Attacks(i).Defense + 256
			End If
			write_byte((Attacks(i).Defense))
		Next 
		For i = 1 To 44
			write_byte((Attacks(i).Stamina))
		Next 
		For i = 1 To 44
			write_byte((Attacks(i).HitProb))
		Next 
		For i = 1 To 44
			write_byte((Attacks(i).Damage))
		Next 
		For i = 1 To 44
			write_byte((Attacks(i).Fatigue))
		Next 
		
		var = 0
		For atknum = 1 To 44
			For i = 1 To Len(Attacks(atknum).name)
				var = var + 1
				write_byte(Asc(Mid(Attacks(atknum).name, i, 1)))
			Next 
			write_byte(0)
			var = var + 1
		Next 
		For var = var To 299
			write_byte(0)
		Next 
		
		
		For i = 1 To 44
			write_byte((Combos(i).attack1))
			write_byte((Combos(i).attack2))
			write_byte((Combos(i).attack3))
			write_byte((Combos(i).Byte4))
			write_byte((Combos(i).Byte5))
			write_byte((Combos(i).byte6))
			write_byte((Combos(i).Unused1))
			write_byte((Combos(i).Unused2))
		Next 
		
		write_int(byte19218)
		
		For i = 1 To 25
			write_byte((Spells(i).Rune1))
			write_byte((Spells(i).Rune2))
			write_byte((Spells(i).Rune3))
			write_byte((Spells(i).Rune4))
			write_byte((Spells(i).Difficulty))
			write_byte((Spells(i).Skill))
			write_int((Spells(i).word6))
		Next 
		
		For i = 1 To 6
			write_byte(RuneMultipliers(i))
		Next 
		
		For i = 1 To 24
			write_byte(Runes(i))
		Next 
		'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(560, 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(560, itemdata)
	End Sub
	Public Sub read()
		Dim i As Short
		Dim atknum As Short
		Dim var As Short
		Dim l As Integer
		
        itemloc = 0
		
		For i = 1 To 24
			l = read_int()
			rects(i) = l
		Next 
		
		For i = 1 To 16
			bytes20194(i) = read_byte()
		Next 
		
		For i = 1 To 44
			Attacks(i).Exp = read_byte()
		Next 
		For i = 1 To 44
			Attacks(i).Skill = read_byte()
		Next 
		For i = 1 To 44
			Attacks(i).Defense = read_byte()
			If Attacks(i).Defense > 128 Then
				Attacks(i).Defense = Attacks(i).Defense - 256
			End If
		Next 
		For i = 1 To 44
			Attacks(i).Stamina = read_byte()
		Next 
		For i = 1 To 44
			Attacks(i).HitProb = read_byte()
		Next 
		For i = 1 To 44
			Attacks(i).Damage = read_byte()
		Next 
		For i = 1 To 44
			Attacks(i).Fatigue = read_byte()
		Next 
		
		For i = 1 To 44
			Attacks(i).name = ""
		Next 
		atknum = 1
		For i = 1 To 300
			var = read_byte()
			If var = 0 Then
				atknum = atknum + 1
			Else
				If atknum <= 44 Then
					Attacks(atknum).name = Attacks(atknum).name & Chr(var)
				End If
			End If
		Next 
		
		For i = 1 To 44
			Combos(i).attack1 = read_byte()
			Combos(i).attack2 = read_byte()
			Combos(i).attack3 = read_byte()
			Combos(i).Byte4 = read_byte()
			Combos(i).Byte5 = read_byte()
			Combos(i).byte6 = read_byte()
			Combos(i).Unused1 = read_byte()
			Combos(i).Unused2 = read_byte()
		Next 
		
		byte19218 = read_int()
		
		For i = 1 To 25
			Spells(i).Rune1 = read_byte()
			Spells(i).Rune2 = read_byte()
			Spells(i).Rune3 = read_byte()
			Spells(i).Rune4 = read_byte()
			Spells(i).Difficulty = read_byte()
			Spells(i).Skill = read_byte()
			Spells(i).word6 = read_int()
		Next 
		
		For i = 1 To 6
			RuneMultipliers(i) = read_byte()
		Next 
		
		For i = 1 To 24
			Runes(i) = read_byte()
		Next 
		
	End Sub
End Class