ps2homebrew / wLaunchELF

ELF loader and File browser for Sony PlayStation 2
Other
509 stars 51 forks source link

Makefile changes and code cleanup #7

Closed uyjulian closed 7 years ago

sp193 commented 7 years ago

Thanks for being willing to help AKuHAK with updating uLaunchELF's code.

I feel that the right way to solve the mismatched sign types is to decide on the semantics of all functions and to change the function/array/variable declarations accordingly. You can add a lot of casts, but it is very hackish because you need to do that for every mismatch and it adds clutter to the code.

I would change all arrays that use unsigned char to simply use char, unless there is a good reason for it (i.e. due to differences in API that shouldn't be changed).

The CNF files are (I presume) ASCII-encoded. Characters are represented with signed char and it is also fine to use signed char to represent the bytes within SJIS and UTF-8.

Another thing would be regarding the external declarations of the IRX modules. dlanor declared them as extern void, with his reasoning that they are blocks of data. However, they don't represent one unsigned char, which you have changed them to be. If you want to change those to represent their actual data type (as bin2c defines them), you should change them to extern unsigned char []. You will also need to edit the code that accesses these buffers (i.e. at calls to SifExecModuleBuffer). If you do that, then you can also remove his old comment on this.

sp193 commented 7 years ago

The same thing goes for the other regions that you have adding a lot of cast statements to, like the VMC module. If unsigned char is better (i.e. because those are data pages), then the relevant structures and functions should be changed to accept unsigned char.

AKuHAK commented 7 years ago

Thanks sp193 and uyjulian, and also about bin2s changed to bin2c. I suppose that we don't need to do it for mainstream branch. Yes code will also work with bin2c but I was implemented it in gcc5 branch ONLY because this was the only bin utility that works. Very hackish. Personally, I didn't like bin2c. It creates larger temporary files (at least 5 times larger), it has .c extension and sometimes it is difficult to differ it from normal .c files (yes I see that uyjulian use *.bin.c which still is very hacky). It is better to fix in utilities in gcc5 branch.

As about mixed signs I didn't add it by the same reasons that mentioned sp193 - tons of changes due 1 function sign. I have only one valid change according to mixed signs - in filer.c

int cmpFile(FILEINFO *a, FILEINFO *b)  //Used for directory sort
  {
 -    unsigned char *p, ca, cb;
 +    char *p, ca, cb;

In fact we need to change most of functions in such a way.

uyjulian commented 7 years ago

I see your reasoning.

I'll close this.