Conversation Between Blah and karatekid552
Showing Visitor Messages 196 to 210 of 683
-
December 19th, 2013 3:51 AMkaratekid552That looks awesome.:) All of them will be even length, that is easy enough:
if len(string)%2 != 0: string = "0" + string -
December 18th, 2013 6:52 PMBlahIf there's more functions like that which need doing, you can ask me to do them for you :)
-
December 18th, 2013 6:44 PMBlahSo this function works on the basis that all string will be even length:
def swapper(hex_string):
#store ordered string in collector
collector = ""
#loop and get 2 elements of the string
for index in range((len(hex_string)-1), 0, -2):
#we put pairs into variable
collector += hex_string[index-1] + hex_string[index]
#return the result
return collector -
December 18th, 2013 5:19 PMkaratekid552That string would need to end up looking like "9A78563412".
-
December 18th, 2013 2:32 PMBlahYou don't need to put them into the list, you can just use the string directly.
If there is a reversed string like "123456789A" how would it's true order look like? -
December 18th, 2013 2:09 PMkaratekid552When writing (or reading) from the rom, any pointers or other data longer than one byte will be in the reverse order. Because python deals with hex numbers in string format, I am splitting the string every two characters into a list and then reversing them. This will give me the correct byte order for the next operation. Is there a better way?
-
December 18th, 2013 2:03 PMBlahDouble click on the tab names in wing to minimize, there shouldn't be an issue. Also you can do help(class name) to find some builtins that you may have not known about.
"Because bytes are stored in reverse order, would the easiest way to do that be put them in a string and do". I don't understand the sentence's meaning. Put them in a string? do you mean arrange them in order (so they aren't reversed)? -
December 18th, 2013 1:17 PMkaratekid552I'm downloading Wing right now.
Also, on the whole having strings in a separate file, unless you want to do that, I'm not going to bother. It's not like it is a compiled language or closed source.
Lol, I stopped working with just console code as soon as I could iterate over a dictionary. I only return to the console to test functions. I should probably finish.......:P
First code question: :P
Because bytes are stored in reverse order, would the easiest way to do that be put them in a string and do:
list_of_bytes = re.findall('..',offset)
list_of_bytes.reverse()
?
Edit: Okay, I like testing my code in Wing, however actually coding, I don't like it. It just feels cramped. Idk. -
December 18th, 2013 12:57 PMBlahWing is superior in every way to notepad ++ for python programming, I'd go as far as to say it's the best editor for python right now.
Cool, if maketrans is builtin then there is no need to optimize (it probably already is!).
Iterating over data structures, and manipulating data is something I can help you with. Shoot questions/code issues over to me for this type of problem. As for gui programming, I'll learn, but I'd rather first learn more about console programming before moving on. There's a lot that I still haven't learned about :) -
December 18th, 2013 12:11 PMkaratekid552No, not Notepad. Notepad++. There is a huge difference. However Wing IDE sounds pretty cool too.
----
maketrans is a function in the string module. Then translate is a function of the str class. So yes, they are all built in. I actually looked at the code for it, and it is pretty simple.
-----
Haha, I actually already wrote functions for reading/writing to the rom. That won't be an issue. Iterating over data structures through... I'm not the best at.:p You should learn GUI programming. It is a lot more fun than console data stuff. Haha -
December 18th, 2013 7:50 AMBlahOMFG, you've been using notepad to code and then compiling it using cmd?
Go and download a proper python editor. Wing IDE is what I use and it's got a debugger, stack viewer, proper error highlighting and everything. http://www.wingware.com/
Honestly though, you'll notice a pretty big change in your coding speed.
----------------
That table thing actually looks like the best way to do it :O
Is maketrans a built in or something you made? If it's something you made maybe I can check and see if it can be optimized further.
---------------
Looks like I don't need to relearn, you're all over it already :P -
December 18th, 2013 5:02 AMkaratekid552For wxPython, look unber Windows Binaries, then grab the one for your operating system (32vs64bit) and then the one for your python version.
-----
maketrans accepts two strings and then creates a table that will be used to translate strings to another. For example:
table = maketrans("1234567890","ABCDEFGHI")
Will output a table that allows converting numbers 1-9&0 to a string of letters. When this table is passed to the translate method, it will modify the string like this:
1 = A
2 = B
3 = C
Etc.
So, "2879".translate(table) will output "BGFH".
As I said, I'm sure there is a better way, but this one works and making those tables was a hell of a lot of work.:p
-----
I understand the concept of object orientated programming, but I have trouble applying it.:p I'm a very linear coder (because asm is my first language........).
The only readability things I have been taught are the 80 character limit, however I usually disregard it and just go with whatever window size I happen to be using.:p (mostly because for some reason, then bar in Notepad++ refuses to provide the correct 80 character mark, usually sitting around 54 whenever I change it.
-----
I know you don't want to relearn this, but data is stored in the rom in big endian(? Whichever one flips the bytes around) and from there it is just a normal binary file. The reason I had to write the conversion feature is because the games don't use ASCII or UTC-8 or anything. They have a custom one for all of the strings. -
December 17th, 2013 9:41 PMBlahhttp://www.wxpython.org/download.php There are a few downloads for windows, which one am I supposed to get?
-
December 17th, 2013 9:22 PMBlahAll programs work like that, lol.
As for your program so far, I don't know what the method maketrans does, but seems like you're just calling that function with separate parameters depending on some mode. As for the hex chart, no clue wtf that's all about. About efficiency of that hexchart/pokechart, it's actually faster/more efficient to hard code static values rather than deriving (complexity wise).
Anyways, I think I won't be much help for this actually. For example, I have no clue what's going on in your hex chart/Pokechart :D
Looks like a bunch of mumbo jumbo to me. If anything I can help you with design decisions, coding pointers and actual operation coding. I don't know how the data is stored in the ROM or anything like that (don't really have the motivation to relearn either).
A big thing about your code that I notice is that it's formatted very poorly for readability. http://www.python.org/dev/peps/pep-0008/
Also, I get the feeling you don't understand object oriented programming quite yet. Is that right?
EDIT: For the pep8 stuff, don't worry about max charachters per line -
December 17th, 2013 7:46 AMkaratekid552The ini business won't be hard. I will take care of it and the .bak is separate.
What hacking tool works like that? Come on man, you know that isn't how it works.
Edit: I finished the ini loading. See if you can figure out my maze of coding in the open function.:P (It's not that bad, just inefficient.)
Also, the open function now works. I merged all of the widgets into one file, so basically main.py is everything the UI. The others are just additional functions and such.
I also did this.:)
Spoiler:
def convert_ascii_and_poke(string, mode):
#modes: "to_poke" and "to_ascii"
hex_chart="\x00\x01\x02\x03\x04\x05\x06\x07\x08\
\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\
\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\
\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\
\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\
\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\
\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\
\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\
\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\
\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\
\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\
\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\
\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\
\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\
\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\
\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\
\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\
\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\
\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\
\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xFB\xF7\xF8\xF9\xFA\xFE"
poke_chart=' ÀÁÂÇÈÉÊËÌ-ÎÏÒÓÔŒÙÚ\
ÛÑßàá-Çèéêëì-îïòóôœùúûñº\
ª¹&+-----\x34=-----------\
----------------¿¡\x53\x54\
\x55\x56\x57\x58\x59Í%()----------â\
----------------????-\
---------------------\
--------------01234567\
89!?.--\xB0“”‘\??$,×/ABCDEF\
GHIJKLMNOPQRSTUVWXYZab\
cdefghijklmnopqrstuvwxyz?\
:ÄÖÜäöü+??<>\n'
if mode == "to_poke": table = st.maketrans(hex_chart, poke_chart)
elif mode == "to_ascii": table = st.maketrans(poke_chart, hex_chart)
else: return False
return string.translate(table)
Probably not the most efficient way to do it. but it it works.:P I had a huge problem with UTF-8 characters vs ASCII which is why there are so many "-"s.
Now all that is left is to set up the actual UI to edit things.:D

