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

Some new features and bug fixes in thecl #59

Merged
merged 30 commits into from
Aug 27, 2019
Merged

Conversation

Priw8
Copy link
Member

@Priw8 Priw8 commented Aug 27, 2019

New features (th10+ only):

  • difficulty switch expressions: wait(60:50:40:30); ->

    !E
      60;
    !N
      50;
    !H
      40;
    !LO /* in th10-th128 it's just !L */
      30;
    !*
      wait([-1]);

    last parameter always gets all remaining diffs, so do 10:20 to get just

    !E
      10;
    !NHLO
      20;
    !*

    or 1:2:3:4:5 to split lunatic and overdrive (for games that have it)
    this only supports basic integer/float literals, putting variables/expressions inside will not work (I might add that later)

  • no forced typecast for passing expressions to ins calls: basically now you don't have to do wait(_S(2+2)), wait(2+2) works just fine

  • easy to write float literals that represent radians: rad(180.0f) -> 3.14159...f (since this is just a way of representing a float value and not an actual function, you can't put variables/expressions in it)

  • syntax for binary integer literals: 0b1001 -> 9

  • added forced sub calls by name - @mySub(); compiles into ins_11("mySub");, even if no sub of that name exists in the current file (can also do @mySub() async; to use ins_15 instead)

  • declare variables anywhere in the sub and don't require var; at the beginning (ins_40 is prepended to the list in sub_finish automatically)

  • declare & assign variables in 1 line with var $myVar = 1;

  • automatically add ins_10 at the end of the sub if there is no ins_1/ins_10 present

  • since 3 last features make thecl add instructions automatically, simple creation mode was added to disable them (pass -s in args when running thecl to enable this mode)

  • added an error message when a variable with a duplicate name is declared

  • added times loop known from some screenshots of ZUN's ECL:

    times(10) {
      ins_whatever();
    }

    since the times loop requires one of the earlier features enabled to work (as it automatically creates a counter variable), it's not available in simple creation mode

Fixes:

  • fixed passing expressions to sub calls by name - expression_output wasn't called and the expressions ended up being compiled AFTER the call instead
  • fixed sub calls by name without any parameters (earlier it would call list_free_nodes with a NULL pointer, which crashed thecl)
  • fixed some minor issues where syntax wouldn't get accepted (break; no longer requires an instruction before it, rank flags don't require an instruction after them etc)
  • fixed pre-th10 unused difficulty flag dumping (dump !457 instead of !XYZ)

Priw8 added 30 commits August 24, 2019 20:26
50deg + 1.0f should not be valid syntax, now it's rad(50.0f) + 1.0f which doesn't look weird
The recent changes I made resulted in dumped ECL files not necessarily being exactly identical after compiling. Simple creation mode ensures that the created ECL will be the same, as it prevents adding any instructions automatically (at the cost of disabling some of the new features)

Note that despite the things that add instructions automatically, simple mode does not need to be used to perfectly recompile ZUN's ECL files, as his compiler seems to add ins_40 and ins_10/ins_1 automatically as well (they are in every sub). As such, simple mode only really needs to be used to compile things that I would call bad and janky.
done because such code
-----------
!NHL
    GirlA01_at() sub;
!*
    while(1)
    {
        wait(1000);
    }
-----------
would not compile.
@32th-System 32th-System merged commit 5e0318c into thpatch:master Aug 27, 2019
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

Successfully merging this pull request may close these issues.

2 participants