Char contacts convert & import

This commit is contained in:
sShemet
2026-02-04 20:45:21 +05:00
parent f3c41f2781
commit c2c36afc42
3 changed files with 48 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ Imports System.Net.Mime.MediaTypeNames
Imports System.Runtime.Remoting.Metadata.W3cXsd2001
Imports System.Text
Imports MadMilkman.Ini
Imports System.Linq.Expressions
Public Class Form1
@@ -658,7 +659,7 @@ Public Class Form1
filnam = EngISOPath.Text
ElseIf UserRadio.Checked Then
filnam = UserPath.Text
ElseIf KUDOSbtn.Checked Then
ElseIf KudosBtn.Checked Then
filnam = KUDOSpath.Text
ElseIf CDExtraBtn.Checked Then
filnam = CDEXTRApath.Text
@@ -847,7 +848,7 @@ Public Class Form1
For Each JFile In OpenFileDialog1.FileNames
Debug.WriteLine("Converting " & JFile)
txt.importContactFile(JFile, DialogCounter, LineCounter)
txt.ConvertTXT_To_Contact(JFile, DialogCounter, LineCounter)
Next
MsgBox("Success! Converted " & UBound(OpenFileDialog1.FileNames) + 1 & " file(s)" & vbCrLf & "Overall Dialogs Count: " & DialogCounter &
@@ -927,9 +928,9 @@ newtest:
'Try
Dim bytes() = SoapHexBinary.Parse(line).Value
If bytes.Length = 0 Then Exit Sub
If bytes.Length = 0 Then Exit Sub
text.DrawChars(bytes.ToList, drawSurface, y, curColor)
text.DrawChars(bytes.ToList, drawSurface, y, curColor)
'Catch ex As Exception
'MsgBox("Error in codes!")
'End Try
@@ -1151,7 +1152,7 @@ rleEnd:
Next
'dungeons & summon text & battle contacts
If CDFileList.SelectedIndex = 735 Or CDFileList.SelectedIndex = 35 Or CDFileList.SelectedIndex = 1075 Then
If CDFileList.SelectedIndex = 735 Or CDFileList.SelectedIndex = 35 Or CDFileList.SelectedIndex = 863 Then
'checking crazy last 20 bytes on sector for file IN SUUMON AND DUNGEON TEXTS
Dim ffff = 2048 - (finalPack.Count Mod 2048)
If ffff <= 20 And ffff > 0 Then
@@ -1215,8 +1216,8 @@ rleEnd:
Update0032SummonScriptTable(addresses) 'summon scripts table in 0032 & 33. Summon and mutation code
'Case 1075
' UpdateBattleContactFileTable(addresses) 'Updating BattleContacts
Case 863
UpdateCharContactFileTable(addresses) 'Updating Char contact
End Select
@@ -1250,7 +1251,34 @@ rleEnd:
'Done
MsgBox(String.Format("Imported {0} files in {1} - {2} bytes", UBound(OpenFileDialog1.FileNames) + 1, CDFileList.SelectedIndex, finalPack.Count), MsgBoxStyle.Exclamation)
End Sub
Public Sub UpdateCharContactFileTable(ByRef addr As List(Of Integer))
Dim cd = New ISOTools
Dim codeFile = cd.getCDfile(UserPath.Text, files1(789).Sector, files1(789).Sizw).ToArray() 'Battle Code
Dim TableOffset = 305548
Dim curElement = 0
For a = 0 To addr.Count - 1
Dim curAddr = curElement * 4 + TableOffset
Dim value = BitConverter.ToUInt32(codeFile, curAddr)
Dim origOffset = value And &H7FF
Dim origSectors = (value And &H1FFFFFF) >> &HB
Dim origFilePack = value >> &H19
Dim fileSectorOffset As UInt32 = addr(a) \ 2048
Dim sectorByteOffset As UInt32 = addr(a) Mod 2048
Dim finalValue As UInt32 = (origFilePack << &H19) Or (fileSectorOffset << &HB) Or sectorByteOffset
Dim bytes = BitConverter.GetBytes(finalValue)
Buffer.BlockCopy(bytes, 0, codeFile, curAddr, 4)
curElement += 1
a = a + origFilePack - 1
Next
cd.saveCDfile(UserPath.Text, files1(789).Sector, files1(789).Sizw, codeFile)
End Sub
Public Sub UpdateBattleContactFileTable(ByRef addr As List(Of Integer))
Dim cd = New ISOTools

View File

@@ -958,7 +958,6 @@ endlineTest:
Dim japText = New List(Of String)
'reading pointers
Dim pointersReader As Integer = JPointersPointer
For a = JPointersPointer To JTextPointer - 1 Step 2 : japPointers.Add(BitConverter.ToUInt16(JFile, a)) : Next a
For a = EPointersPointer To ETextPointer - 1 Step 2 : engPointers.Add(BitConverter.ToUInt16(EFile, a)) : Next a
'FormFileHeader
@@ -1066,7 +1065,7 @@ endlineTest:
End Function
Public Sub importContactFile(ByVal inputJfile As String, ByRef DialCount As Integer, ByRef LineCount As Integer)
Public Sub ConvertTXT_To_Contact(ByVal inputJfile As String, ByRef DialCount As Integer, ByRef LineCount As Integer)
Dim f = New List(Of Byte)
Dim TextPointers = New List(Of Integer)
@@ -1077,16 +1076,22 @@ endlineTest:
'Recompiling scripts
Dim cleanedString = t(0).Trim({"["c, "]"c})
Dim hexValues = cleanedString.Split(New String() {"]["}, StringSplitOptions.None)
'Init
Dim t1 = Split(t(0), ",").ToList
For Each ii In t1
If Not IsNumeric(ii) Then MsgBox("Not numeric in INIT sect!!") : Exit Sub
f.Add(Convert.ToByte(ii))
For Each hexValue In hexValues
Dim intValue = Integer.Parse(hexValue, System.Globalization.NumberStyles.HexNumber)
Dim bytes = BitConverter.GetBytes(intValue)
f.AddRange(bytes)
Next
Dim JPointersPointer = f(4) + f(5) * 256
Dim JTextPointer = f(6) + f(7) * 256
Dim StrCount = (JTextPointer - JPointersPointer) / 2
If f.Count > JTextPointer Then f.RemoveRange(JTextPointer, 2)
Dim tx As String = txt.Replace(t(0) & vbCrLf, "") 'Replace first line
@@ -1123,7 +1128,7 @@ endlineTest:
End If
If skRes = "END623" Or skRes = "END" Or skRes = "311" Then
If skRes = "END623" Or skRes = "END" Or skRes = "0311" Then
Dim curCount = accum.Count
currentDialog += 1
x += 2
@@ -1132,7 +1137,7 @@ endlineTest:
TempLinesAccum.AddRange({&H6, &H11, &H2, &H11, &H3, &H11})
Case "END"
TempLinesAccum.AddRange({&H6, &H11, &H3, &H11})
Case "311"
Case "0311"
TempLinesAccum.AddRange({&H3, &H11})
End Select
@@ -1189,7 +1194,7 @@ endlineTest:
End If
If tx(x) = vbTab Then TempLinesAccum.AddRange({&H1, &H11}) : x += 1 : Continue Do 'Tab and enter
If tx(x) = vbTab Then TempLinesAccum.AddRange({&H31, &H11}) : x += 1 : Continue Do 'Tab and enter
If tx(x) & tx(x + 1) = vbCrLf Then TempLinesAccum.AddRange({&H1, &H11}) : LineCount += 1 : x += 2 : Continue Do
If tx(x) = vbLf Then TempLinesAccum.AddRange({&H1, &H11}) : LineCount += 1 : x += 1 : Continue Do