Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems running cicoparser with some games #6

Open
sergiou87 opened this issue Apr 24, 2021 · 12 comments
Open

Problems running cicoparser with some games #6

sergiou87 opened this issue Apr 24, 2021 · 12 comments

Comments

@sergiou87
Copy link

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:

$ ./cicoparser -config JETPACK.cfg
Cicoparser by Gabriel Valky, 2021 (https://github.com/gabonator/Projects/tree/master/XenonResurrection/Parser)
line 0,
[308] ___fpreset:
Assertion failed: (0), function MatchLine, file ../CicParser2021/parser.h, line 46.
[1]    39686 abort      ./cicoparser -config JETPACK.cfg
$ ./cicoparser -config GAME.cfg
Cicoparser by Gabriel Valky, 2021 (https://github.com/gabonator/Projects/tree/master/XenonResurrection/Parser)
line 0,
[197] __MMODEL:
Assertion failed: (0), function MatchLine, file ../CicParser2021/parser.h, line 46.
[1]    39905 abort      ./cicoparser -config GAME.cfg

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
Copy link
Owner

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

@sergiou87
Copy link
Author

Sure! There you go:

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

Thanks for the quick reply 😄

@gabonator
Copy link
Owner

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
Copy link
Contributor

fjtrujy commented Jul 12, 2021

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
Copy link
Contributor

fjtrujy commented Jul 13, 2021

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:

  • "^(_[\\w]*):$" for functions as __FInitRtns:
  • "^([\\w]*_):$" for functions as int86_:
        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
Copy link
Contributor

fjtrujy commented Jul 13, 2021

I have created a PR #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
Copy link
Owner

@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
Copy link
Contributor

fjtrujy commented Jul 13, 2021

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

@gabonator
Copy link
Owner

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

@fjtrujy
Copy link
Contributor

fjtrujy commented Jul 13, 2021

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
Copy link
Owner

@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
Copy link
Contributor

fjtrujy commented Jul 14, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants