Hey,

So, I'm trying to make a 8xp to txt, just like Tokens or SourceCoder, to learn, though, not to use it, to learn more Very Happy


So, i'm gonna need tokens:

http://omnimaga.pastebin.com/3KQ3PRFe

I'll use this ones.

However, I have no idea what kind of knowledge I need to use the things in front of the tokens:


Code:
tDisp           EQU       PROGTOK+16  ; DEh   'Disp_'


How could I implement this in a program, for example?

I'll probably give up after making the Disp one, so I have to make sure I can do it.


I'm gonna be using Python, but I don't need help with Python, I need help on what I should use in the program from that line tDisp above?
DEh, or $DE, is DE in hexadecimal, or 16*D+E in decimal. D is 13, E is 14, so it's 16*13+14 = 222. Therefore, you'd insert a byte with value (decimal) 222 or (hexadecimal) $DE when you want to add a "Disp " token.
KermMartian wrote:
DEh, or $DE, is DE in hexadecimal, or 16*D+E in decimal. D is 13, E is 14, so it's 16*13+14 = 222. Therefore, you'd insert a byte with value (decimal) 222 or (hexadecimal) $DE when you want to add a "Disp " token.


That's not english, that's some kind of language I can't understand, hah
ScoutDavid wrote:
KermMartian wrote:
DEh, or $DE, is DE in hexadecimal, or 16*D+E in decimal. D is 13, E is 14, so it's 16*13+14 = 222. Therefore, you'd insert a byte with value (decimal) 222 or (hexadecimal) $DE when you want to add a "Disp " token.


That's not english, that's some kind of language I can't understand, hah
Ah, so the problem is that hexadecimal is not something with which you're familiar. Smile

http://en.wikipedia.org/wiki/Hexadecimal

And in reference to your PMs:

[19:56:51] <ScoutDavi> My program should read the code, and change each token (Disp, DispGraph, Pause, ClrHome) for their equivalent in code or it should look for each token and then check which are there and 'translate' those ones?
[19:58:08] <KermM_> hmm
[19:58:16] <KermM_> you're going text to 8xp
[19:58:38] <KermM_> so you need to turn the five-byte string "Disp " into the one-byte value $DE
[19:59:04] <ScoutDavi> Yes
[19:59:21] <ScoutDavi> Oh and I have the problem with L1 L2 L3 L4 L5 Pic1 Pic2 Pic3 Str1 Str2....... still
[19:59:22] <KermM_> let's post in the topic
Okay, I skimmed through that article 'cos I know what hexadecimal numbers are and I can make calculus with HexaDecimal numbers too.


Code:

def find_disp(text):
    if 'Disp' in text:
        finaltext = "$DE"

def find_prompt(text):
    if 'Prompt' in text:
        finaltext = finaltext+"$DD"


The Python syntax is not 100% correct, but I think I need to make sth like that.

text is the .txt given by user and final text will be the .8xp text
So far so good, except that it's 'Disp ' and 'Prompt ', not 'Disp' and 'Prompt ' (the space isn't a separate token). also, this seems like a really, really space-consuming way to code it; you'll need millions (well, about 680) def's.
Kerm, I'm already managing a few things, quite cool, I will do about 680 def's, OF COURSE NOT, I'll use database to check it, but this is just a first attempt.

Let's suppose the program


Code:
Disp "A


Would be

$DE$2A$41

Now, I get this in the final text variable.

If I save


$DE$2A$41 as a .8px it will run Disp "A?
Well, there's also the header (maybe 56-odd bytes) and the 2-byte checksum. Smile
KermMartian wrote:
Well, there's also the header (maybe 56-odd bytes) and the 2-byte checksum. Smile


TI BASIC files need headrs in teh .8xp? How are they made?


What's a checksum?
http://codepad.org/rcWlBCx1

Working ;D

The space after Disp not working, though :s
ScoutDavid wrote:
http://codepad.org/rcWlBCx1

Working ;D

The space after Disp not working, though :s
That's because you're splitting on the " " [space] character. When you split on a character, that character is removed. Splitting "1,2,3" on the comma character yields the list ["1" "2" "3"], for example. Tokens are all different lengths, and most are not separated by anything; for example, the strings "Disp ", "32Ans", and "3(-A)" are all five characters, but one, three, and five tokens respectively. You'll want to do some kind of maximal substring matching, which just so happens to be what I do in SourceCoder.
$DE isn't a string, it is a 1 byte value. You need to actually write a byte with the value of $DE.

So if you are using a newer version of python, you'll want a bytearray.


Code:
buf = bytearray()
# ... do some stuff, find some tokens, whatever
buf.append(0xde)
Kllrnohj wrote:
$DE isn't a string, it is a 1 byte value. You need to actually write a byte with the value of $DE.

So if you are using a newer version of python, you'll want a bytearray.


Code:
buf = bytearray()
# ... do some stuff, find some tokens, whatever
buf.append(0xde)
Ouch, I didn't even notice that he had done that; thanks Kllrnohj. While we're on the subject, I find Python's handling of byte arrays and related byte-based structure handling way, way more awkward than it needs to be, and writing a script that works properly on both 2.7 and 3.x (namely BinPac8x) is an exercise in migraines.
Hey, really sorry to interrupt but this link can do the same thing...
http://ti.zewaren.net/en/
I mean good idea and all but I think its already been done. Very Happy
0rac343 wrote:
Hey, really sorry to interrupt but this link can do the same thing...
http://ti.zewaren.net/en/
I mean good idea and all but I think its already been done. Very Happy
Well, of course SourceCoder 2.5 can already do the same thing six ways to Sunday, and has been doing so for about six or seven years now, but I got the impression he just wanted some experience with the token set and with Python. Smile Also, Merth's upcoming Tokens program attempts a client-side program with the same functions.
Okay,My bad! I'm sorry, I thought that the converter was just meant to be like a replacement or something.
0rac343 wrote:
Okay,My bad! I'm sorry, I thought that the converter was just meant to be like a replacement or something.
No worries, I had the same initial reaction until he explained that he was familiar with both SourceCoder and Tokens and was doing this for the experience. Smile
yup, to learn! (not python, .8xp file making)

Ok, I started to try to do a substring matching, with no luck


Code:

buf = bytearray()
# ... do some stuff, find some tokens, whatever
buf.append(0xde)


Also, thanks for that, I knew that but didn't remember.

I'm still having wtf issues with checksum and headers, but i tried editing .8xp files to learn them Very Happy
So, while studying .8xp files, I tried this:


Code:
:Disp "Hello World


Turns out this:


??



Code:
buf = bytearray()
# ... do some stuff, find some tokens, whatever
buf.append(0xde)


Now this,

What should buf be (input text or final text or split input text)?
0xde, what is that?

Thanks in advance and sorry for douple posting
0xde = $DE = 222d = %11011110 = "Disp ". Viewing the file in a text editor (looks like Notepad++ to me) isn't going to help; you need a hex viewer slash editor. I strongly recommend XVI32:

http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page 1, 2, 3, 4, 5, 6, 7, 8  Next
» View previous topic :: View next topic  
Page 1 of 8
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement