Author Topic: How to create an 8xp compiler using VB 2010?  (Read 9222 times)

0 Members and 1 Guest are viewing this topic.

SirCmpwn

  • Guest
Re: How to create an 8xp compiler using VB 2010?
« Reply #15 on: December 06, 2010, 08:45:09 am »
It's generic .NET, so it will work on C#.  The library is actually written in C#.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: How to create an 8xp compiler using VB 2010?
« Reply #16 on: December 06, 2010, 08:47:23 am »
It's generic .NET, so it will work on C#.  The library is actually written in C#.

Great, gotta check that out!

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: How to create an 8xp compiler using VB 2010?
« Reply #17 on: December 06, 2010, 05:24:07 pm »
If you are using VB.NET, you can use this library I made for just that purpose.  It can convert strings to bytes or hex, and it can create 8xps, among other things.
That's great!
It'll be nice if you make a VB2010 project showing how to use the API.
The arguments that the classes need are uncommented and I couldn't find a readme or something.
« Last Edit: December 06, 2010, 05:24:25 pm by Aichi »

SirCmpwn

  • Guest
Re: How to create an 8xp compiler using VB 2010?
« Reply #18 on: December 06, 2010, 09:05:30 pm »
I don't know VB.NET, but I can comment them for you later.

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: How to create an 8xp compiler using VB 2010?
« Reply #19 on: December 07, 2010, 02:12:05 pm »
I don't know VB.NET, but I can comment them for you later.
Okay, thanks in advance.
I made some attempts, but without success.

This code
Code: [Select]
SaveFileDialog1.ShowDialog()
 TI_Developer_API.Utility.DataConverter.Save8xp(True, {1, 2, 3, 4, 5, 6}, "HELLO", SaveFileDialog1.FileName)
outputs an 8xp file into the correct directories, but an invalid file, though.
I attached a screenshot of some fish and what is displayed by notepad.exe.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3005
  • Rating: +445/-10
    • View Profile
Re: How to create an 8xp compiler using VB 2010?
« Reply #20 on: December 07, 2010, 02:39:12 pm »
Here's my code for Correlation Font Compiler, which uses VB 2008.  This will give you an idea on how to write an .8xp compiler, though your data in the data section will obviously be different from mine.

I'm letting you look at this to help you out, so please don't use it for any other purposes.  You can, however, feel free to copy the data-writing section of the code.

Button1_Click is what you want to look at.  It takes a bitmap's graphical data and converts it into an .8xp program.

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: How to create an 8xp compiler using VB 2010?
« Reply #21 on: December 07, 2010, 08:04:10 pm »
You could also use the code I do for my basic editor (modified slightly to be more generic =P)
Code: [Select]

        Dim FileBytes(1048576) As Byte
        Dim FileBytesCounter1 As Integer = (How many bytes you want to write.  If you set file bytes to just the data you have, just set it to FileBytes.length() =P)
        Dim FileComment As String = (Whatever you want the comment to be)
        Dim FileName As String = (Whateverer you want the variable name to be.  Not the actual file name. This could be eg. "MYPROG")
        '**TI83F*
        FileBytes(0) = 42
        FileBytes(1) = 42
        FileBytes(2) = 84
        FileBytes(3) = 73
        FileBytes(4) = 56
        FileBytes(5) = 51
        FileBytes(6) = 70
        FileBytes(7) = 42
        '1A,0A,00
        FileBytes(8) = 26
        FileBytes(9) = 10
        FileBytes(10) = 0
        'Comment
        FileComment = FileComment.PadRight(42, ChrW(0))
        For x As Integer = 0 To 41
            FileBytes(x + 11) = AscW(FileComment.Chars(x))
        Next
        'Data Size
        If FileBytesCounter1 + 19 > 255 Then
            Dim TempHex = cHex(FileBytesCounter1 + 19, 4)
            FileBytes(54) = cInteger(Mid(TempHex, 1, 2))
            FileBytes(53) = cInteger(Mid(TempHex, 3, 2))
        Else
            FileBytes(54) = 0
            FileBytes(53) = FileBytesCounter1 + 19
        End If
        'Random Flag (either B or D)
        FileBytes(55) = 13
        FileBytes(56) = 0
        'Variable Size
        If FileBytesCounter1 + 2 > 255 Then
            Dim TempHex = cHex(FileBytesCounter1 + 2, 4)
            FileBytes(58) = cInteger(Mid(TempHex, 1, 2))
            FileBytes(57) = cInteger(Mid(TempHex, 3, 2))
        Else
            FileBytes(58) = 0
            FileBytes(57) = FileBytesCounter1 + 2
        End If
        'Type ID
        FileBytes(59) = 5
        'Name
        FileName = FileName.PadRight(8, ChrW(0))
        For x As Integer = 0 To 7
            FileBytes(60 + x) = AscW(FileName.Chars(x))
        Next
        'Version
        FileBytes(68) = 0
        'Archived
        FileBytes(69) = 0
        'Variable Size Again
        If FileBytesCounter1 + 2 > 255 Then
            Dim TempHex = cHex(FileBytesCounter1 + 2, 4)
            FileBytes(71) = cInteger(Mid(TempHex, 1, 2))
            FileBytes(70) = cInteger(Mid(TempHex, 3, 2))
        Else
            FileBytes(71) = 0
            FileBytes(70) = FileBytesCounter1 + 2
        End If
        'Total Token Count
        If FileBytesCounter1 > 255 Then
            Dim TempHex = cHex(FileBytesCounter1, 4)
            FileBytes(73) = cInteger(Mid(TempHex, 1, 2))
            FileBytes(72) = cInteger(Mid(TempHex, 3, 2))
        Else
            FileBytes(73) = 0
            FileBytes(72) = FileBytesCounter1
        End If
        'Totals data
        Dim Counter = 0
        For x As Integer = 0 To FileBytesCounter1 + 19
            Counter += FileBytes(x + 55)
        Next
        'Lower 16 bits of data totalled together
        If Hex(Counter).Length > 4 Then Counter = cInteger(Mid(cHex(Counter, 4), 1, 4))
        If Counter > 255 Then
            FileBytes(FileBytesCounter1 + 75) = cInteger(Mid(cHex(Counter, 4), 1, 2))
            FileBytes(FileBytesCounter1 + 74) = cInteger(Mid(cHex(Counter, 4), 3, 2))
        Else
            FileBytes(FileBytesCounter1 + 75) = 0
            FileBytes(FileBytesCounter1 + 74) = Counter
        End If
        Dim FinalBytes(FileBytesCounter1 + 75) As Byte
        For x As Integer = 0 To FileBytesCounter1 + 75
            FinalBytes(x) = FileBytes(x)
        Next
        File.WriteAllBytes((Where you want the file to save to), Finalbytes)

        (You also need these two functions)
    Shared Function cHex(ByVal IntValue As Integer, ByVal Length As Integer) As String
        Dim Int_Length As Integer = Int(Math.Log10(IntValue) / Math.Log10(16)) + 1
        Dim Temp_Value As Integer
        Dim Hex_String As String = ""
        For X As Integer = Length - 1 To 0 Step -1
            Temp_Value = Int(IntValue / (16 ^ X))
            Hex_String += Mid("0123456789ABCDEF", Temp_Value + 1, 1)
            IntValue -= Temp_Value * (16 ^ X)
        Next
        Return Hex_String
    End Function

    Shared Function cInteger(ByVal HexString As String) As Integer
        Dim Int_Value As Integer
        For X As Integer = HexString.Length To 1 Step -1
            Int_Value += (InStr("0123456789ABCDEF", Mid(HexString, X, 1)) - 1) * (16 ^ (HexString.Length - X))
        Next
        Return Int_Value
    End Function
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

SirCmpwn

  • Guest
Re: How to create an 8xp compiler using VB 2010?
« Reply #22 on: December 07, 2010, 10:31:32 pm »
Can you attach the 8xp itself so I can view it in a hex editor?  What you created won't run with Asm(, by the way, you need 0xBB6D and some other stuff, too.  It also isn't a valid TI-Basic program.  But it should send okay.  Here's some example hex to try:
{ 0xBB, 0x6D, 0xC9 }
« Last Edit: December 07, 2010, 10:31:59 pm by SirCmpwn »

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: How to create an 8xp compiler using VB 2010?
« Reply #23 on: December 09, 2010, 07:05:46 am »
Aichi: Do you have a hex editor? There are a bunch of free ones, and then you could really see what's going wrong.
« Last Edit: December 09, 2010, 05:37:00 pm by graphmastur »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55931
  • Rating: +3153/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: How to create an 8xp compiler using VB 2010?
« Reply #24 on: December 09, 2010, 09:39:32 am »
Notepad is actually a text editor and is built-in Windows. :P

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: How to create an 8xp compiler using VB 2010?
« Reply #25 on: December 09, 2010, 09:40:35 am »
Notepad is actually a text editor and is built-in Windows. :P

Also, creating a text editor is really easy... I made in C#, VB and Python xP

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: How to create an 8xp compiler using VB 2010?
« Reply #26 on: December 09, 2010, 05:37:25 pm »
Aichi: Do you have a hex editor? There are a bunch of free ones, and then you could really see what's going wrong.
Whoops, sorry, fixed ^ Thanks DJ.

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: How to create an 8xp compiler using VB 2010?
« Reply #27 on: December 11, 2010, 06:38:58 pm »
I'm busy with school at the moment, sorry.

@ cooliojazz
This routine seems to be very nice, but I couldn't find the code to include the bytes,
that the variable owns on TI.

@ SirCmpwn
I attached the 8xp that is created by the following arguments of Utility.Dataconverter.Save8xp:
Protected = True
data = {1, 2, 3, 4, 5, 6}
Progname = "HELLO"
File = SaveFileDialog1.Filename