gabonator / Projects

Finished projects
26 stars 9 forks source link

Problems running cicoparser with some games #6

Open sergiou87 opened 3 years ago

sergiou87 commented 3 years ago

Hello!

I was trying out cicoparser following the instructions from this Youtube video and everything worked fine with CD-MAN, but I had trouble parsing the same cico.py output for 2 different games:

Is this something I'm doing wrong or just some stuff that is not supported yet?

If you want to test it, you can download the games yourself or I can share with you the relevant files to run cicoparser šŸ˜„

Thanks in advance!

gabonator commented 3 years ago

Attach assembly file and configuration in your comment please, so I can verify the problem

sergiou87 commented 3 years ago

Sure! There you go:

DSCHUMP-cicoparser-files.zip JETPACK-cicoparser-files.zip

Thanks for the quick reply šŸ˜„

gabonator commented 3 years ago

I checked the jetpack game: it is written in turbo/borland C (guessed from the _main function signature). This is not very well supported yet - I haven't tried to convert similar kind of game. After fixing support for more segments, It fails on converting instruction "fninit" (loc_1047A), and the code looks weird to me. I have never seen this instruction before, not sure if the data part was forced into instructions, or if it is the real code... I will look on it tomorrow

fjtrujy commented 3 years ago

Hello @gabonator , I'm suffering a similar issue than @sergiou87

In my case I'm trying with the game MicroMachines 2, the error is:

Cicoparser by Gabriel Valky, 2021 (https://github.com/gabonator/Projects/tree/master/XenonResurrection/Parser)
line 0, 
[439] _Not_Enough_Memory_:
Assertion failed: (0), function MatchLine, file ../CicParser2021/parser.h, line 46.
./convert.sh: line 1: 89847 Abort trap: 6           ../build/cicoparser -config mm2.cfg

Here you have the asm and cfg file: MM2-Cicoparser.zip

Am I doing something wrong? or is the parser that doesn't support this game either?

Thanks

fjtrujy commented 3 years ago

Hello again @gabonator , I have been taking a look at the CicParser2021 code, and I see that the label _Not_Enough_Memory_: wasn't recognized properly using the regex.

I think that the regex for a label is not taking into consideration all the scenarios. From a very far point of view, I think that the label is something that finishes with :. In order to match with the labels that I see generated in my asm file, I have added 2 rules:

        if ( CUtils::match("^(_[\\w]*):$", strLine, arrMatches) )
        {
            return make_shared<CILabel>(arrMatches[0]);
        }

        if ( CUtils::match("^([\\w]*_):$", strLine, arrMatches) )
        {
            return make_shared<CILabel>(arrMatches[0]);
        }

Doing that, I have been able to proceed parsing ASM file, but additional errors appears for some instructions that are not recognized šŸ˜¢

Thanks

fjtrujy commented 3 years ago

I have created a PR https://github.com/gabonator/Projects/pull/7 where I fix some issues, but still we have some instructions not recognized by CICO Parser

test byte ptr [bp+var_4+1], 20h

mov ss:[di], ax

mov ss:[di+var_s2], dx

These 3 instructions are the only ones pending to implement to make MicroMachines 2 ASM to fully parse

Thanks

gabonator commented 3 years ago

@fjtrujy if there are just 3 unsupported instructions, just add dummy implementation for them. This will place assertion at the point where the unsupported instruction is and then you can manually fix it when it will try to execute it:

if ( CUtils::match("^...........$", strLine, arrMatches) )
{
    return make_shared<CIStop>();
}

but regarding the mov ss:[di], ax instruction it should be pretty straightforward to implement it. But the question is, how cicoparser should handle stack access (ss segment) - at first I had just std::vector of integers with push and pop instructions were just adding or removing values from it. The games I was porting simply did not need direct stack access. But when I tried to convert some turbo-C game (arcade volleyball) which heavily use variables on stack/heap I realized that I need to redesign the stack implementation and use real memory instead.

I do not think cicoparser in its current state of development is powerful enough to process any pascal/C/C++ apps... To port Micromachines it will take a lot of effort... but I am happy to see that there are contributors trying to improve it :)

fjtrujy commented 3 years ago

I forgot to comment it but there are a lot __FIXME___ generated anyway in the file. Could you help me with this?

gabonator commented 3 years ago

I can give it a try, just drop here generated code and assembly

fjtrujy commented 3 years ago

Here you have it!

I just commented the 3 instructions that I said before in order to cicoparser finish the parsing of the file.

MM2.zip

Thanks

gabonator commented 3 years ago

@fjtrujy this won't definitely work. The assembly code is heavily using stack for passing arguments and local variables and this is still not supported. Currently I do not do any further development on this project - it is summer and prefer spending time outdoors and also I am waiting for the next wave of corona :) The development was stopped during porting "Arcade volleyball" game which is written in turbo C and it is possibly the easiest game in higher language I could find (also heavily using stack for local variables/arguments). So when I will complete porting this game, then we can discuss porting these more advanced games

fjtrujy commented 3 years ago

Thanks in advance! Really useful info. Enjoy the summer!