News: 11 March 2016 - Forum Rules

Author Topic: Compression? help  (Read 7329 times)

irecinius

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Compression? help
« on: June 24, 2011, 04:27:23 am »
it seems I stumbled onto some kind of compression, I read Jay's documents on compression, but I couldn't exactly identify which is this one.

Looking at the dump, i have
Code: [Select]
001CEB70 0200 0030 FF20 0048 6579 2120 4C6F 6E67 2074 696D 6520 6E6F 2073 6565 210A ...0. .Hey! Long time no see!.
001CEB8E 486F 7727 7320 6974 2067 6F69 6E67 3F0A 4469 6420 796F 7572 2068 756E 7420 How's it going?.Did your hunt
001CEBAC 676F 2077 656C 6C3F 0001 0100 0030 FF20 0049 206A 7573 7420 746F 6F6B 2077 go well?.....0. .I just took w
001CEBCA 6861 7420 4920 6E65 6564 2066 6F72 2074 6F64 6179 2E0A 4E6F 7468 696E 6720 hat I need for today..Nothing
001CEBE8 6861 7264 2061 626F 7574 2074 6861 742E 0001 0200 0030 FF20 0057 6F77 2120 hard about that......0. .Wow!

And at the file that seems to hold the script.
Code: [Select]
006186CC 5761 FF74 6368 2054 6F77 65FF 7220 2873 6B79 2900 FB1F 0161 11FF 2000 4865 Wa.tch Towe.r (sky)....a.. .He
006186EA FF79 2120 4C6F 6E67 20FF 7469 6D65 206E 6F20 FF73 6565 210A 486F 77FF 2773 .y! Long .time no .see!.How.'s
00618708 2069 7420 676F FF69 6E67 3F0A 4469 64FF 2079 6F75 7220 6875 FD6E D291 2077  it go.ing?.Did. your hu.n.. w
00618726 656C 6C3F F300 0191 11B1 9049 206A 75FB 7374 9590 6F6B 2077 68FF 6174 2049 ell?.......I ju.st..ok wh.at I
00618744 206E 6565 DF64 2066 6F72 9590 6461 7F79 2E0A 4E6F 7468 D690 FF20 6861 7264  nee.d for..da.y..Noth... hard
00618762 2061 62B3 6F75 FF90 07A0 2E00 AC95 57F7 6F77 210A A068 6176 65EE 9591 6164  ab.ou........W.ow!..have...ad

I went and read about DTE, RLE, LZ, LZSS.
but I can't quite finger on it, although what I understood was

9049 206A 75FB 7374 9590 6F6B .I ju.st..ok
That in game appears as "I just took"
That FB doesn't translate to nothing ingame has a value of 11111011 so if we invert 11011111, does that mean, two uncompressed one compressed, five uncompressed?
Kinda fits..
ju(compressed data comming in 2 bytes)s(one)t(two)[Compressed data offset](five uncompressed)

Lookin a bit ahead ahead i see 9590 again, on
00618744 206E 6565 DF64 2066 6F72 9590 6461 7F79 nee.d for..da.y

So 9590 definatelly means " to", since the ingame sentence is "need for today" so my educated guess is that 0xDF(11011111) gets switched to
(11111011) and that tells that the sixth next byte is going to be compressed value.. the pattern does repeat around.

Does this has a special name? its a variant of some existing compression?
If its LZ variant, 9590 should be length distance to it, right? but I can't quite make it, specially since there are two instances of 9590, close to each other.
« Last Edit: June 27, 2011, 12:31:00 am by irecinius »

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5792
    • View Profile
    • Nightcrawler's Translation Corporation
Re: Compression? help
« Reply #1 on: June 27, 2011, 09:33:37 am »
Yes, you are correct. This is an LZ variant. For every 8 values, you'll see a control byte as you have described. 0xFF means 8 uncompressed characters will be copied. 0xFB as you found means two uncompressed one compressed, five uncompressed. There will always be a control byte and it's value can be anything. Each bit just represents compressed or uncompressed for the next 8 operations. You will certainly see these control bytes may be the same as valid text character values.

For compressed operations, it will load 2 bytes (the 9590). Unfortunately, it can be difficult to determine what that means without taking a look at some of the corresponding game code. Often times, there are offsets added to the length and the resulting location is only meaningful when referencing the RAM location the output is in. Also, constants may be added to the number of bytes to copy (often a minimum). And how you pull apart and manipulate those two bytes into your length and offset can be done a variety of ways. So, it's often difficult to figure it out simply by looking at it.

The easiest way to figure it out without looking at game code is to start at the beginning of the compressed stream (text block). What you have there does not contain the beginning. I know this because 'to' does not appear in your text example here. So your 9590 points somewhere not shown in the output buffer sample you gave us. If you have the very start of the stream, it is easier to decipher the copy length/position pair. However, it may still not be clear without looking at the game code.
TransCorp - Over 20 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Glory of Heracles IV SFC/SNES Translations

irecinius

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Compression? help
« Reply #2 on: June 27, 2011, 12:03:40 pm »
Looking at the file i have
How.'s it go.ing?
I believe that the "t go" from "hunt go well?" is the same from, 'it going' since it is the only t go that I have visible there.

Here is a big chunk of the script;
Spoiler:
Code: [Select]
00618654 00D3 000F 01FF 1701 5401 5D01 8D01 FF95 01EC 01F5 01FB 01FF 0302 3602 3F02 ........T.]...............6.?.
00618672 6502 FF6D 02C1 02C9 02D2 02FF DB02 FC02 0503 2903 FF31 0370 0379 038A 03FF e..m..............)..1.p.y....
00618690 9303 DD03 E503 3204 FF3B 048C 0495 04F3 04FF FB04 3505 3D05 9C05 FFA5 05B2 ......2..;..........5.=.......
006186AE 05BB 05CC 05FF D505 E305 EB05 F205 FFFB 050A 0613 0652 6FFF 6164 2074 6F20 .....................Ro.ad to
006186CC 5761 FF74 6368 2054 6F77 65FF 7220 2873 6B79 2900 FB1F 0161 11FF 2000 4865 Wa.tch Towe.r (sky)....a.. .He
006186EA FF79 2120 4C6F 6E67 20FF 7469 6D65 206E 6F20 FF73 6565 210A 486F 77FF 2773 .y! Long .time no .see!.How.'s
00618708 2069 7420 676F FF69 6E67 3F0A 4469 64FF 2079 6F75 7220 6875 FD6E D291 2077  it go.ing?.Did. your hu.n.. w
00618726 656C 6C3F F300 0191 11B1 9049 206A 75FB 7374 9590 6F6B 2077 68FF 6174 2049 ell?.......I ju.st..ok wh.at I
00618744 206E 6565 DF64 2066 6F72 9590 6461 7F79 2E0A 4E6F 7468 D690 FF20 6861 7264  nee.d for..da.y..Noth... hard
00618762 2061 62B3 6F75 FF90 07A0 2E00 AC95 57F7 6F77 210A A068 6176 65EE 9591 6164  ab.ou........W.ow!..have...ad
00618780 6DD1 9069 742E FF0A 596F 7520 7375 72F7 6520 615D A068 616E 64BF 790A 7769 m..it...You sur.e a].hand.y.wi
0061879E 7468 DE93 731F 776F 7264 2EAA 90F3 94AC 9499 2CD0 915B A269 7314 505B A070 th..s.word........,..[.is.P[.p
006187BC C772 6973 48A2 C690 DE91 2068 F765 7265 34A7 5965 6168 FF2E 204C 6174 656C .risH..... h.ere4.Yeah.. Latel
006187DA 79F7 2049 2747 A062 6565 6EFF 2062 7573 7920 696E FE2F A065 2066 6965 6C64 y. I'G.been. busy in./.e field
006187F8 F773 2E0A 7BA5 2C20 646F FEA9 A273 7469 6C6C 2063 F96F C090 AEA1 2065 7665 .s..{., do...still c.o.... eve
00618816 728B 7920 18A0 3F7A A7BC A2B3 A76F 9D75 CAA1 6C69 6B0F A01F A073 FF20 706C r.y ..?z.....o.u..lik....s. pl
00618834 6163 652C 0A7E 08B1 2073 696E 6365 EB90 7CEB 905D A073 6D61 6C6C 79A8 8F2E ace,.~.. since..|..].smally...
00618852 2E2E 53EA 9007 A0CE 9075 FD70 15A3 3F0A 506C 6179 B021 A202 A010 B0AC 954F ..S......u.p..?.Play.!.......O
00618870 66FD A075 FD72 A0A0 6E6F 7421 0A54 E4AE A1CE 9073 FFA0 1FA3 6469 6691 66AF f..u.r..not!.T.....s....dif.f.
0061888E A0E6 902A A20A DBA1 A690 2CCC AAB0 0AA0 6361 C090 9690 7461 0D6B 5EA0 206C ...*......,.....ca....ta.k^. l
006188AC 02A0 34A0 F394 A3B0 78C8 B111 B1AD 9444 6F6E 272E A13D 65FD A06C 6F72 73E1 ..4.....x......Don'..=e..lors.
006188CA B2B4 B7B4 11B8 66B0 44D9 B068 657A B043 CD61 04C1 7361 C7A4 9EB0 6963 E965 ......f.D..hez.C.a..sa....ic.e
006188E8 78A0 AC95 496F B164 6566 F769 6E69 C4A2 7765 6972 DF64 2121 0A49 36B1 6E6B x...Io.def.ini..weir.d!!.I6.nk
00618906 F0AA B7CE 90D4 9295 9168 6170 7013 656E 66B0 12BB 2C30 B205 A2F7 B879 49F0 .........happ.enf...,0.....yI.
00618924 A004 C16B 6E6F 7766 B03F 210A 4D61 7962 54B0 ACB6 2C95 A12B A36F 0AFE A266 ...knowf.?!.MaybT...,..+.o...f
00618942 58B0 21A1 FF66 726F 6D20 4365 6C9D 65F8 A061 3F21 F196 02C3 73EF 6F75 6E64 X.!..from Cel.e..a?!....s.ound
00618960 CDB1 7468 723C FAA0 4CC0 0A41 6E79 1FA3 FEA0 1CF0 C6DB A072 650A 95A0 2BA0 ..thr<..L..Any.........re...+.
0061897E 15D0 F496 90CE C062 9390 6E65 7773 FC79 A1AD 956F 7720 776F 7549 6CDD 92C1 .......b..news.y...ow wouIl...
0061899C C23F A2B3 24A0 7304 C17E CEA2 636F 6E74 6163 81D1 0B74 77CF A00A E091 75A0 .?..$.s..~..contac...tw.....u.
006189BA E2A0 11A2 FF32 3030 3020 7965 61F9 7256 D2F3 9441 4E59 5741 BF59 210A 4C69 .....2000 yea.rV...ANYWA.Y!.Li
006189D8 6693 A26D F365 61E6 9049 D373 696D 703F 6C65 2E0A 5768 D0A0 1FA2 52A9 B074 f..m.ea..I.simp?le..Wh....R..t
006189F6 3FC0 DBA1 77EE D379 5FA1 FF2C 0A54 4841 5427 53EF 2074 7275 62A1 7070 6907 ?...w..y_..,.THAT'S. trub.ppi.
00618A14 6E65 7356 D0AC 975D A04E B0E9 907F 6167 6169 6E21 20F2 94FE CE90 7068 696C nesV...].N....again! .....phil
00618A32 6F73 6FAF 7068 7921 56A2 6E43 B263 9264 A067 B1A1 F394 4F6D A0BD A03F DB0A oso.phy!V.nC.c.d.g....Om...?..
00618A50 57ED 9020 6DCC C249 27F1 6DFB 9407 A1F5 D00A 6361 75CE A0A0 6F66 2058 B0DA W.. m..I'.m.......cau...of X..
00618A6E A274 72CF 6F75 626C 48A0 07A1 610A CF63 6572 742F E0AA B262 6F33 6479 D2B0 .tr.oublH...a..cert/...bo3dy..
00618A8C 8CE0 6421 5CBA AB95 1CF7 B8B4 902C 206F 44B1 3AD2 C1E1 F037 A56D B330 A101 ..d!\........, oD.:....7.m.0..
00618AAA D855 682D 6FF9 68C1 E8AC 9421 2052 756E 8121 F1E8 F294 2EF0 D500 F5F0 00AF .Uh-o.h....! Run.!............
00618AC8 22BF 0200 C000 0410 F221 780F 0000 8500 C7F0 62F2 7410 62F2 5063 4062 F2F2 "........!x.......b.t.b.Pc@b..
and the corresponding dump
Spoiler:
Code: [Select]
001CEAF8 5401 5D01 8D01 9501 EC01 F501 FB01 0302 3602 3F02 6502 6D02 C102 C902 D202 T.].............6.?.e.m.......
001CEB16 DB02 FC02 0503 2903 3103 7003 7903 8A03 9303 DD03 E503 3204 3B04 8C04 9504 ......).1.p.y.........2.;.....
001CEB34 F304 FB04 3505 3D05 9C05 A505 B205 BB05 CC05 D505 E305 EB05 F205 FB05 0A06 ....5.=.......................
001CEB52 1306 526F 6164 2074 6F20 5761 7463 6820 546F 7765 7220 2873 6B79 2900 1F01 ..Road to Watch Tower (sky)...
001CEB70 0200 0030 FF20 0048 6579 2120 4C6F 6E67 2074 696D 6520 6E6F 2073 6565 210A ...0. .Hey! Long time no see!.
001CEB8E 486F 7727 7320 6974 2067 6F69 6E67 3F0A 4469 6420 796F 7572 2068 756E 7420 How's it going?.Did your hunt
001CEBAC 676F 2077 656C 6C3F 0001 0100 0030 FF20 0049 206A 7573 7420 746F 6F6B 2077 go well?.....0. .I just took w
001CEBCA 6861 7420 4920 6E65 6564 2066 6F72 2074 6F64 6179 2E0A 4E6F 7468 696E 6720 hat I need for today..Nothing
001CEBE8 6861 7264 2061 626F 7574 2074 6861 742E 0001 0200 0030 FF20 0057 6F77 2120 hard about that......0. .Wow!
001CEC06 4920 6861 7665 2074 6F20 6164 6D69 7420 6974 2E0A 596F 7520 7375 7265 2061 I have to admit it..You sure a
001CEC24 7265 2068 616E 6479 0A77 6974 6820 796F 7572 2073 776F 7264 2E00 1F01 0100 re handy.with your sword......
001CEC42 0030 FF20 0001 0200 0030 FF20 2C20 6974 2073 7572 6520 6973 2061 0A73 7572 .0. .....0. , it sure is a.sur
001CEC60 7072 6973 6520 746F 2073 6565 2079 6F75 2068 6572 652E 0001 0200 0030 FF20 prise to see you here......0.
001CEC7E 0059 6561 682E 204C 6174 656C 7920 4927 7665 2062 6565 6E20 6275 7379 2069 .Yeah. Lately I've been busy i
001CEC9C 6E20 7468 6520 6669 656C 6473 2E0A 1F01 0100 0030 FF20 2C20 646F 2079 6F75 n the fields.......0. , do you
001CECBA 2073 7469 6C6C 2063 6F6D 6520 6865 7265 2065 7665 7279 2064 6179 3F00 1F01  still come here every day?...
001CECD8 0100 0030 FF20 0059 6561 682E 0001 0200 0030 FF20 0059 6F75 2776 6520 6C69 ...0. .Yeah......0. .You've li
001CECF6 6B65 6420 7468 6973 2070 6C61 6365 2C0A 6576 6572 2073 696E 6365 2077 6520 ked this place,.ever since we
001CED14 7765 7265 2073 6D61 6C6C 2E00 1F01 0100 0030 FF20 002E 2E2E 536F 2077 6861 were small.......0. ....So wha
001CED32 7427 7320 7570 2074 6F64 6179 3F0A 506C 6179 696E 6720 686F 6F6B 793F 0001 t's up today?.Playing hooky?..
001CED50 0200 0030 FF20 004F 6620 636F 7572 7365 206E 6F74 210A 5468 6572 6527 7320 ...0. .Of course not!.There's
001CED6E 736F 6D65 7468 696E 6720 6469 6666 6572 656E 7420 6162 6F75 740A 7468 6520 something different about.the
001CED8C 736B 792C 2073 6F20 4920 6361 6D65 2074 6F20 7461 6B65 2061 206C 6F6F 6B2E sky, so I came to take a look.
001CEDAA 0001 0100 0030 FF20 0054 6865 2073 6B79 3F00 1F01 0200 0030 FF20 0044 6F6E .....0. .The sky?......0. .Don
001CEDC8 2774 2074 6865 2063 6F6C 6F72 7320 6C6F 6F6B 2064 6966 6665 7265 6E74 3F00 't the colors look different?.
001CEDE6 1F01 0100 0030 FF20 002E 2E2E 446F 2074 6865 793F 0A43 616E 2774 2073 6179 .....0. ....Do they?.Can't say
001CEE04 2049 2776 6520 6E6F 7469 6365 642E 0001 0200 0030 FF20 0049 7427 7320 6465  I've noticed......0. .It's de
001CEE22 6669 6E69 7465 6C79 2077 6569 7264 2121 0A49 2074 6869 6E6B 2073 6F6D 6574 finitely weird!!.I think somet
001CEE40 6869 6E67 2773 2067 6F69 6E67 2074 6F20 6861 7070 656E 2E2E 2E00 1F01 0100 hing's going to happen........
001CEE5E 0030 FF20 0059 6561 682C 206C 696B 6520 7768 6174 3F00 1F01 0200 0030 FF20 .0. .Yeah, like what?......0.
001CEE7C 0049 2064 6F6E 2774 206B 6E6F 772E 2E2E 210A 4D61 7962 6520 736F 6D65 7468 .I don't know...!.Maybe someth
001CEE9A 696E 6720 6973 2061 626F 7574 2074 6F0A 636F 6D65 2066 616C 6C69 6E67 2066 ing is about to.come falling f
001CEEB8 726F 6D20 4365 6C65 7374 6961 3F21 0001 0100 0030 FF20 0044 6F6E 2774 2073 rom Celestia?!.....0. .Don't s
001CEED6 6F75 6E64 2073 6F20 7468 7269 6C6C 6564 2E0A 416E 7974 6869 6E67 2063 6F6D ound so thrilled..Anything com
001CEEF4 696E 6720 6672 6F6D 2074 6865 7265 0A69 7320 626F 756E 6420 746F 2062 6520 ing from there.is bound to be
001CEF12 6261 6420 6E65 7773 2E00 1F01 0200 0030 FF20 0048 6F77 2077 6F75 6C64 2079 bad news.......0. .How would y
001CEF30 6F75 206B 6E6F 773F 0A54 6865 7265 2068 6173 6E27 7420 6265 656E 2063 6F6E ou know?.There hasn't been con
001CEF4E 7461 6374 2062 6574 7765 656E 0A6F 7572 2077 6F72 6C64 7320 666F 7220 3230 tact between.our worlds for 20
001CEF6C 3030 2079 6561 7273 2E00 1F01 0100 0030 FF20 0041 4E59 5741 5921 0A4C 6966 00 years.......0. .ANYWAY!.Lif
001CEF8A 6520 6973 206D 6561 6E74 2074 6F20 6265 2073 696D 706C 652E 0A57 6865 6E20 e is meant to be simple..When
001CEFA8 7468 696E 6773 2073 7461 7920 7468 6520 7761 7920 7468 6579 2061 7265 2C0A things stay the way they are,.
001CEFC6 5448 4154 2753 2074 7275 6520 6861 7070 696E 6573 732E 0001 0200 0030 FF20 THAT'S true happiness......0.
001CEFE4 0048 6572 6520 7765 2067 6F20 6167 6169 6E21 2001 0100 0030 FF20 2773 2070 .Here we go again! ....0. 's p
001CF002 6869 6C6F 736F 7068 7921 0A59 6F75 206E 6576 6572 2063 6861 6E67 652E 0001 hilosophy!.You never change...
001CF020 0100 0030 FF20 004F 6820 7965 6168 3F0A 5765 6C6C 206D 6179 6265 2049 276D ...0. .Oh yeah?.Well maybe I'm
001CF03E 206A 7573 7420 7468 6174 2077 6179 0A63 6175 7365 206F 6620 616C 6C20 7468  just that way.cause of all th
001CF05C 6520 7472 6F75 626C 6520 7468 6174 2061 0A63 6572 7461 696E 2073 6F6D 6562 e trouble that a.certain someb
001CF07A 6F64 7920 6361 7573 6564 2100 1F01 0100 0030 FF20 002E 2E2E 1F01 0200 0030 ody caused!......0. .........0
001CF098 FF20 3F00 1F01 0200 0030 FF20 0048 6579 2C20 6F76 6572 2074 6865 7265 2100 . ?......0. .Hey, over there!.
001CF0B6 1F01 0200 0030 FF20 0057 6861 7427 7320 7468 6174 3F21 0001 0100 0030 FF20 .....0. .What's that?!.....0.
001CF0D4 0055 682D 6F68 2100 1F01 0100 0030 FF20 0001 0200 0030 FF20 2120 5275 6E21 .Uh-oh!......0. .....0. ! Run!
001CF0F2 2100 1F01 0200 0030 FF20 0001 0100 0030 FF20 2121 0000 0000 2800 0000 0000 !......0. .....0. !!....(.....
001CF110 0000 0000 0000 0000 0000 2202 00C0 0004 1040 0000 0078 0000 8500 1000 0078 .........."......@...x.......x

I don't know if its relevant, or not but
After you said, I did notice that the 0xFF appears almost neatly every 8th byte.. except, its not every time. Can it?

Please correct me if I'm wrong, but this is what I see.

00618740 6174 2049 206E 6565 DF64 2066 6F72 9590 6461 7F79 2E0A 4E6F 7468 D690 FF20 6861 at I nee.d for..da.y..Noth... ha
00618760 7264 2061 62B3 6F75 FF90 07A0 2E00 AC95 57F7 6F77 210A A068 6176 65EE 9591 6164 rd ab.ou........W.ow!..have...ad

blue = control code correctly placed at the 8th byte.
pink = expected control code
limegreen = where i found it.
marron = compressed data
navy = no idea....

i've managed to run that PSXTrace, but to me looks worse then moonspeak.
pSX  debugger, seems little more friendly, I could find the loop where it writes to that place in the memory, I guess that is where the decompression routine is located, I'll try to analyze it.. not that will help much since my ASM Speak is pretty much sub r0,1
« Last Edit: June 27, 2011, 12:22:58 pm by irecinius »

RedComet

  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Twilight Translations
Re: Compression? help
« Reply #3 on: June 27, 2011, 01:13:04 pm »
It might not be every 8th byte exactly. It depends on the data. If the current control code says the next 8 bytes are uncompressed,  then yeah, the next control code would be after those 8 bytes. If you have compressed data (i.e. pointer to the data and the length) mixed in with uncompressed data, it'll change the location of the next control code.

My advice would be to step through this code in a debugger and document how it works. Takes all the guesswork out of it. :)
Twilight Translations - More than just Dragonball Z. :P

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5792
    • View Profile
    • Nightcrawler's Translation Corporation
Re: Compression? help
« Reply #4 on: June 27, 2011, 02:36:19 pm »
Looking at the file i have
How.'s it go.ing?
I believe that the "t go" from "hunt go well?" is the same from, 'it going' since it is the only t go that I have visible there.

I can't really decipher anything from that. Even though it looks like your text starts there, if you look at the data above, you'll see plenty of FF's eight apart signifying the data above looks like it is still part of the compressed stream. Your first word 'Road' is broken up with a control byte too. This is telling us that's not the beginning of the compressed stream. You can keep scrolling upwards until that FF pattern stops and you might see it. Even then, deciphering the length/offset pair can be hard by sight. I'll leave you to that. I am not great at that. My eyes go buggy. I go for learning to read the game code, it never lies. :)

Quote
Here is a big chunk of the script;
I don't know if its relevant, or not but
After you said, I did notice that the 0xFF appears almost neatly every 8th byte.. except, its not every time. Can it?

The control bytes will only be 8 bytes apart if it's 0xFF because that means each operation is to take one uncompressed byte, thus the total is 8. If you had FB, we know that's two uncompressed (2 bytes) one compressed (2 bytes), five uncompressed (5 bytes). Since we know uncompressed take 2 bytes, the total will be 9 bytes. See? You add up the total bytes, two for compressed, one for uncompressed. The control codes should all line up if you do it properly.

Quote
i've managed to run that PSXTrace, but to me looks worse then moonspeak.
pSX  debugger, seems little more friendly, I could find the loop where it writes to that place in the memory, I guess that is where the decompression routine is located, I'll try to analyze it.. not that will help much since my ASM Speak is pretty much sub r0,1

Can't help you there. I don't do much on the PSX platform and am not very fluid with 32-bit RISC assembly in general. However, it should be fairly easy if you set some breakpoints on processing of the compressed pair such as the 9590 pair and see what it does. I can't imagine it will give you more than a handful lines of code to decipher. I'm sure if you get the few lines of code and provide some information, some guys here would help you decipher them.
TransCorp - Over 20 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Glory of Heracles IV SFC/SNES Translations

irecinius

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Compression? help
« Reply #5 on: June 27, 2011, 02:55:05 pm »
Thanks for tip, I'm going to play around here see if I can document the thing and post my findings later.
I see RedComet, if we have one compressed data, that add extra bytes so the next control will move around.

------------------------

ok, i went disassembled what I think its the loop that gets the text from the script and decompress it.

I got whatever material on MIPS, somehow I managed to started to understand how it works, by doing some annotations next to the code itself, like so:
Code: [Select]
00023490: 10400043 beq r2,r0,0x000235a0 ; if (r2 == r0) go to 0x000235a0
00023494: 000c6042 srl r12,r12,0x01 ; r12 = r12 >> 0x01 (shift 0x01 numbers of bits to the right) ??
00023498: 31820100 andi r2,r12,0x0100 ; r2 = r12 & 0x0100
0002349c: 14400005 bne r2,r0,0x000234b4 ; if (r2 != r0) go to 0x000234b4

This way i can more or less understand better what is happening, but there are somethings I have no idea, can someone clarify them?

andi r2, r12,0x0100

According to the mips manual

"ANDI rt, rs, immediate
Zero-extend 16-bit immediate, AND with contents of register rs and place result in register rt."


I still can't understand it -.- (its in english, right?)  ;D

Also the

srl r12,r12,0x01

"SRL rd, rt, shamt
Shift contents of register rt right by shamt bits, inserting zeroes into high order bits. Place 32-bit result in register rd"

(this is definitely not english!!!!)

Although I think I read somewhere, wikipedia/somedocument that the bit shifting to the right means is to divide by 2^x. x being how much you are shifting.

So Its like, i have 0x8, if I bitshift 0x1 to the right, it turns into 0x4? (0x8 / 2^1)?? :huh:


Thanks again!
« Last Edit: June 28, 2011, 04:36:51 am by irecinius »

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: Compression? help
« Reply #6 on: June 28, 2011, 05:27:39 am »
You've actually gotten everything spot-on. "rs," "rd," and "rt" are just placeholders for the actual registers used. "Zero-extend" just means the immediate value (that is, the value "hard-coded" into the instruction itself) is padded with 0s so it's 32 bits long ("0xBEEF" becomes "0x0000BEEF") before being ANDed with the value in the given register.

You know what registers are, right? They're like processor variables, and they're probably the closest thing to "regular" variables (the kind you deal with in high-level languages) you'll encounter when working with ASM.
In the event of a firestorm, the salad bar will remain open.

irecinius

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Compression? help
« Reply #7 on: June 28, 2011, 10:06:18 pm »
I see, I wasn't much sure of what registers were exactly, gave a little read, and more or less understand that not only hold values but certains registers are for certain things.

Somehow I think I understand most of them

I was thinking of "AND" as something like a concatenation kinda of function. ("hello" + "world")

But after some example seems to me its more like true false comparison?

That line that says,
andi r2,r12,0x0100
means, "Set r2 as 1 if r12 is equal to 0x0100 otherwise to 0" ( r2 = (r12==0x0100)?1:0 )


Other think I didn't quite understand is "ori r12,r2,0xff00"
OR immediate ..
Is this like the AND, but setting R12 as R2 OR 0xff00???
something on the lines of
if r12 has a value then set to r2, otherwise set r2 as 0xff00???
kina like r2 = (!r12)?0xff00:r12
« Last Edit: June 28, 2011, 10:13:31 pm by irecinius »

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: Compression? help
« Reply #8 on: June 28, 2011, 10:45:41 pm »
Okay, quick explanation of binary logic. You're right - it's a "true-false" comparison, of sorts.

AND = output 1 if both inputs are 1; output 0 otherwise.

01 & 01 = 01
01 & 11 = 01
01 & 10 = 00

OR = output 1 if either input is 1; output 0 otherwise.

01 | 01 = 01
01 | 11 = 11
01 | 10 = 11

XOR/EOR (exclusive OR) = output 1 if one and only one input is 1; output 0 otherwise.

01 ^ 01 = 00
01 ^ 11 = 10
01 ^ 10 = 11

AND is often used when you want to get specific bits of a value. ANDing a value with 0x100 will get you the last bit of the second byte - that is, if it's set, r2 will be 0x100; if it's not, it'll be 0.

OR is used to combine values. If I were to guess, in this case it's being used to combine the last 8 bits of a value (or simply an 8-bit value) with 0xFF00 - for instance, if r2 is "0x0072," then r12 will be "0xFF72."
In the event of a firestorm, the salad bar will remain open.

irecinius

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Compression? help
« Reply #9 on: June 29, 2011, 04:25:34 am »
Thanks alot Ryusui.. that helped alot!
I see what happens now with ORs and ANDs...


It might be pushing a bit, but is there an easier way to figure out the result using hex, without having to do a hex > binary > hex conversion?

ex.: 0xC1 AND 0xEA

I have to convert from hex
0xC1 11000001
0xEA 11101010
---------------------------
         11000000 to hex 0xC0


Thanks again

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: Compression? help
« Reply #10 on: June 29, 2011, 05:15:45 am »
It might be pushing a bit, but is there an easier way to figure out the result using hex, without having to do a hex > binary > hex conversion?

In the event of a firestorm, the salad bar will remain open.

irecinius

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Compression? help
« Reply #11 on: June 29, 2011, 03:14:02 pm »
Homer Simpson: DOH!!!!!!!!!!
LOL, Thanks..


Forgot about something elementary dear Watson.. ( I was about to write a little program to do that..)


RedComet

  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Twilight Translations
Re: Compression? help
« Reply #12 on: June 29, 2011, 06:15:04 pm »


That is one thing I'll give Windows 7 props for: the programmer mode on the calculator is fucking awesome.
Twilight Translations - More than just Dragonball Z. :P

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Compression? help
« Reply #13 on: July 01, 2011, 08:24:53 pm »
I don't like the new calculator interface, it never has both the options that I want in the same mode. I want my stupid big thing that has a button for every single feature I could possibly think of. One day I want to convert numbers and the other day I want to do fancy mathematics.