
Imports System.Runtime.Remoting.Metadata.W3cXsd2001

Public Class ScriptParserWin
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim addr As Integer

        'ScriptVarAddr.Text = ScriptVarAddr.Text.ToString("X4")


        Try
            Dim addrArr = SoapHexBinary.Parse(ScriptVarAddr.Text).Value
            addr = addrArr(0) * 256 + addrArr(1)
        Catch ex As Exception
            MsgBox("error") : Exit Sub
        End Try

        Dim blockNum = addr >> 5
        Dim bits As String = (1 << (addr And &H1F)).ToString("X8")
        Dim revBits = bits.Substring(6, 2) & bits.Substring(4, 2) & bits.Substring(2, 2) & bits.Substring(0, 2)
        ScriptVarCalculated.Text = "Blk Addr: " & (&H800820E0 + blockNum * 4).ToString("X8") & " | Onbyt: " & revBits
    End Sub
End Class