GDCC: An Alternative ACS Compiler [0.15.0]

Any utility that assists in the creation of mods, assets, etc, go here.
Forum rules
The Projects forums are ONLY for YOUR PROJECTS! If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.

Re: GDCC: An Alternative ACS Compiler

Postby Marrub » Sun Feb 05, 2017 2:00 am

That function uses a post-increment, and will loop infinitely. Post-increment is done after the expression.
What you're looking for is pre-increment, so:
Code: Select allExpand view
bool recursionTest (int loop)
{
   if (loop == 5)
      return true;
   else
      return (recursionTest(++loop));
}


Or just using loop + 1, since you don't use it later (as you're returning.)
User avatar
Marrub
Xevv Va Rkvyr
 
 
 
Joined: 26 Feb 2013
Operating System: Other Linux 64-bit
Graphics Processor: ATI/AMD with Vulkan Support

Re: GDCC: An Alternative ACS Compiler

Postby Nero » Sun Feb 05, 2017 5:22 pm

Grrr, I should have caught that. Thanks for catching that, Marrub, the function works, so my recursion problems are assuredly my own!
User avatar
Nero
Royal Boredom....Why can't I do this in Windows?
 
Joined: 06 Sep 2006
Location: Middle of Nowheresville Il.

Re: GDCC: An Alternative ACS Compiler

Postby RaveYard » Wed Feb 22, 2017 10:41 am

These "function pointers":
Code: Select allExpand view
typedef [[call("ScriptS")]]void(*ThreadFunction)(void*);

Seem to crash GZDoom whenever called...
Code: Select allExpand view
function(argument);

Trying an alternative approach, but met with: unsupported cast.
Code: Select allExpand view
ACS_NamedExecuteWithResult((__str_ent)function, argument);

Temporary solution:
Code: Select allExpand view
__asm
(
   "Move_W 1, Stk(), LocReg(Lit(:function))\n"
   "Move_W 1, Stk(), LocReg(Lit(:argument))\n"
   "Cnat 1, Lit(44), Stk(), Stk()\n"
   "Move_W 1, Nul(), Stk()\n"
);

It's a minor issue, but I'd be really happy if this were to be fixed. :)
RaveYard
 
Joined: 12 Apr 2013

Re: GDCC: An Alternative ACS Compiler

Postby DavidPH » Wed Feb 22, 2017 11:31 am

Should be fixed now. Was an issue with how I added support for mixed-in attributes with declaration specifiers. (Namely that it actually ignored attributes that didn't occur at the beginning of the sequence.)

And your first alternative would have worked, you just needed to cast to (__str_ent *) or its alias, (__str).
User avatar
DavidPH
Crazy Compiler Man
 
Joined: 28 Aug 2009

Re: GDCC: An Alternative ACS Compiler

Postby RaveYard » Wed Feb 22, 2017 1:18 pm

Now it works perfectly! :D

Thanks man!
RaveYard
 
Joined: 12 Apr 2013

Re: GDCC: An Alternative ACS Compiler

Postby Nash » Sun Mar 12, 2017 5:45 am

Requesting updated ACC functions, especially ScriptCall and StrArg which is the one I'm interested in the most.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: GDCC: An Alternative ACS Compiler

Postby DavidPH » Sun Mar 12, 2017 10:22 am

Added. Note that ScriptCall is variadic and therefore passes in arguments as-is. (Important for the C front where you might inadvertently pass floats or multiword types.)
User avatar
DavidPH
Crazy Compiler Man
 
Joined: 28 Aug 2009

Re: GDCC: An Alternative ACS Compiler

Postby Nash » Sun Mar 12, 2017 2:51 pm

Thanks!
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: GDCC: An Alternative ACS Compiler

Postby RaveYard » Tue Aug 29, 2017 2:17 am

Could you please add these Zandronum 3.0 (dev build) functions?

Code: Select allExpand view
ACS_NativeDeclFull(126, 0, int,    NamedRequestScriptPuke, __str, int, int, int, int);
ACS_NativeDeclFull(127, 0, int,    SystemTime, void);
ACS_NativeDeclFull(128, 0, int,    GetTimeProperty, int, int, int);
ACS_NativeDeclFull(129, 0, __str,  Strftime, int, __str, int);


Code: Select allExpand view
#define TM_SECOND  0
#define TM_MINUTE  1
#define TM_HOUR    2
#define TM_DAY     3
#define TM_MONTH   4
#define TM_YEAR    5
#define TM_WEEKDAY 6


Source:
https://wiki.zandronum.com/RequestScriptPuke
https://wiki.zandronum.com/SystemTime
https://wiki.zandronum.com/GetTimeProperty
https://wiki.zandronum.com/Strftime
RaveYard
 
Joined: 12 Apr 2013

Re: GDCC: An Alternative ACS Compiler

Postby DavidPH » Tue Aug 29, 2017 9:02 am

I have updated the repository. Unfortunately, due to a bug in the version of gcc that mingw-w64 is (currently) based on, I can't make Windows builds at this time. (Since this is just a header update, though, you can just grab those from the repository off GitHub.)
User avatar
DavidPH
Crazy Compiler Man
 
Joined: 28 Aug 2009

Re: GDCC: An Alternative ACS Compiler

Postby UsernameAK » Sat Sep 09, 2017 8:36 am

Code: Select allExpand view
gdcc-cc --sys-include /usr/local/share/gdcc/lib/inc/C --bc-target ZDoom test.c -o test.acs
ERROR: Function undefined: '___GDCC__Plsf'

WTF
User avatar
UsernameAK
Cat
 
Joined: 15 Jul 2015
Location: Ukraine
Discord: /bin/cat#8891

Re: GDCC: An Alternative ACS Compiler

Postby DavidPH » Sat Sep 09, 2017 9:09 am

You need to compile and link libGDCC. (And probably libc at some point, but that specific function is in libGDCC.)
Code: Select allExpand view
gdcc-makelib --bc-target=ZDoom libGDCC -c -o libGDCC.o
gdcc-cc --bc-target=ZDoom test.c -c -o test.o
gdcc-ld --bc-target=ZDoom test.o libGDCC.o -o test.acs
User avatar
DavidPH
Crazy Compiler Man
 
Joined: 28 Aug 2009

Re: GDCC: An Alternative ACS Compiler

Postby UsernameAK » Sun Sep 10, 2017 4:57 am

How to set a fixed number for a global variable in C?
User avatar
UsernameAK
Cat
 
Joined: 15 Jul 2015
Location: Ukraine
Discord: /bin/cat#8891

Re: GDCC: An Alternative ACS Compiler

Postby DavidPH » Sun Sep 10, 2017 8:44 am

Using the address attribute.
Code: Select allExpand view
[[__address(7)]] __gbl_reg int SomeVar;

Where 7 is of course replaced by the desired index.
User avatar
DavidPH
Crazy Compiler Man
 
Joined: 28 Aug 2009

Re: GDCC: An Alternative ACS Compiler

Postby UsernameAK » Mon Sep 11, 2017 8:36 am

Code: Select allExpand view
#include <ACS_ZDoom.h>

#include <stdio.h>
#include <stdbool.h>

#define MAX_LEVELS 16
#define JUNCTION_LEVELNUM 2
//#define DEBUGSCRIPT

__addrdef __hub_arr hub_var;

[[__address(777)]] hub_var bool exitedLevels[MAX_LEVELS] = {false};

#ifdef DEBUGSCRIPT
[[call("ScriptS"), script("Enter")]]
void CheckLevelExits() {
   ACS_BeginPrint();
   for(int i = 0; i < MAX_LEVELS; i++) {
      __nprintf("%d ", exitedLevels[i]);
   }
   ACS_EndPrint();
}
#endif

[[call("ScriptI"), address(777)]]
void ExitLevel(int spotnum) {
   exitedLevels[ACS_GetLevelInfo(LEVELINFO_LEVELNUM)] = true;
   ACS_Teleport_NewMap(JUNCTION_LEVELNUM, spotnum, 0);
}


GZDoom crashes when i try to access exitedLevels from an ACS script (not C)
User avatar
UsernameAK
Cat
 
Joined: 15 Jul 2015
Location: Ukraine
Discord: /bin/cat#8891

PreviousNext

Return to Editors / Asset Manipulation

Who is online

Users browsing this forum: No registered users and 2 guests