GDCC: An Alternative ACS Compiler [0.15.0]

Any utility that assists in the creation of mods, assets, etc, go here. For example: Ultimate Doom Builder, Slade, WadSmoosh, Oblige, etc.
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.
User avatar
Marrub
 
 
Posts: 1192
Joined: Tue Feb 26, 2013 2:48 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Arch Linux
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: GDCC: An Alternative ACS Compiler

Post by Marrub »

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 all

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
Sarah
Posts: 551
Joined: Wed Sep 06, 2006 12:36 pm
Preferred Pronouns: She/Her
Operating System Version (Optional): Debian 11 (bullseye), Windows 10
Location: Middle of Nowheresville Il.
Contact:

Re: GDCC: An Alternative ACS Compiler

Post by Sarah »

Grrr, I should have caught that. Thanks for catching that, Marrub, the function works, so my recursion problems are assuredly my own!
RaveYard
Posts: 186
Joined: Fri Apr 12, 2013 10:51 am

Re: GDCC: An Alternative ACS Compiler

Post by RaveYard »

These "function pointers":

Code: Select all

typedef [[call("ScriptS")]]void(*ThreadFunction)(void*);
Seem to crash GZDoom whenever called...

Code: Select all

function(argument);
Trying an alternative approach, but met with: unsupported cast.

Code: Select all

ACS_NamedExecuteWithResult((__str_ent)function, argument);
Temporary solution:

Code: Select all

__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. :)
User avatar
DavidPH
Posts: 382
Joined: Fri Aug 28, 2009 1:46 pm

Re: GDCC: An Alternative ACS Compiler

Post by DavidPH »

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).
RaveYard
Posts: 186
Joined: Fri Apr 12, 2013 10:51 am

Re: GDCC: An Alternative ACS Compiler

Post by RaveYard »

Now it works perfectly! :D

Thanks man!
User avatar
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: GDCC: An Alternative ACS Compiler

Post by Nash »

Requesting updated ACC functions, especially ScriptCall and StrArg which is the one I'm interested in the most.
User avatar
DavidPH
Posts: 382
Joined: Fri Aug 28, 2009 1:46 pm

Re: GDCC: An Alternative ACS Compiler

Post by DavidPH »

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
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: GDCC: An Alternative ACS Compiler

Post by Nash »

Thanks!
RaveYard
Posts: 186
Joined: Fri Apr 12, 2013 10:51 am

Re: GDCC: An Alternative ACS Compiler

Post by RaveYard »

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

Code: Select all

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 all

#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
User avatar
DavidPH
Posts: 382
Joined: Fri Aug 28, 2009 1:46 pm

Re: GDCC: An Alternative ACS Compiler

Post by DavidPH »

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
UsernameAK
Posts: 83
Joined: Wed Jul 15, 2015 5:26 am
Location: Ukraine

Re: GDCC: An Alternative ACS Compiler

Post by UsernameAK »

Code: Select all

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
DavidPH
Posts: 382
Joined: Fri Aug 28, 2009 1:46 pm

Re: GDCC: An Alternative ACS Compiler

Post by DavidPH »

You need to compile and link libGDCC. (And probably libc at some point, but that specific function is in libGDCC.)

Code: Select all

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
UsernameAK
Posts: 83
Joined: Wed Jul 15, 2015 5:26 am
Location: Ukraine

Re: GDCC: An Alternative ACS Compiler

Post by UsernameAK »

How to set a fixed number for a global variable in C?
User avatar
DavidPH
Posts: 382
Joined: Fri Aug 28, 2009 1:46 pm

Re: GDCC: An Alternative ACS Compiler

Post by DavidPH »

Using the address attribute.

Code: Select all

[[__address(7)]] __gbl_reg int SomeVar;
Where 7 is of course replaced by the desired index.
User avatar
UsernameAK
Posts: 83
Joined: Wed Jul 15, 2015 5:26 am
Location: Ukraine

Re: GDCC: An Alternative ACS Compiler

Post by UsernameAK »

Code: Select all

#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)
Post Reply

Return to “Creation, Conversion, and Editing”