Page 15 of 16
Re: GDCC: An Alternative ACS Compiler
Posted: Sun Feb 05, 2017 1:00 am
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.)
Re: GDCC: An Alternative ACS Compiler
Posted: Sun Feb 05, 2017 4:22 pm
by Sarah
Grrr, I should have caught that. Thanks for catching that, Marrub, the function works, so my recursion problems are assuredly my own!
Re: GDCC: An Alternative ACS Compiler
Posted: Wed Feb 22, 2017 9:41 am
by RaveYard
These "function pointers":
Code: Select all
typedef [[call("ScriptS")]]void(*ThreadFunction)(void*);
Seem to crash GZDoom whenever called...
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.
Re: GDCC: An Alternative ACS Compiler
Posted: Wed Feb 22, 2017 10:31 am
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).
Re: GDCC: An Alternative ACS Compiler
Posted: Wed Feb 22, 2017 12:18 pm
by RaveYard
Now it works perfectly!
Thanks man!
Re: GDCC: An Alternative ACS Compiler
Posted: Sun Mar 12, 2017 4:45 am
by Nash
Requesting updated ACC functions, especially
ScriptCall and StrArg which is the one I'm interested in the most.
Re: GDCC: An Alternative ACS Compiler
Posted: Sun Mar 12, 2017 9:22 am
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.)
Re: GDCC: An Alternative ACS Compiler
Posted: Sun Mar 12, 2017 1:51 pm
by Nash
Thanks!
Re: GDCC: An Alternative ACS Compiler
Posted: Tue Aug 29, 2017 1:17 am
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
Re: GDCC: An Alternative ACS Compiler
Posted: Tue Aug 29, 2017 8:02 am
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.)
Re: GDCC: An Alternative ACS Compiler
Posted: Sat Sep 09, 2017 7:36 am
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
Re: GDCC: An Alternative ACS Compiler
Posted: Sat Sep 09, 2017 8:09 am
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
Re: GDCC: An Alternative ACS Compiler
Posted: Sun Sep 10, 2017 3:57 am
by UsernameAK
How to set a fixed number for a global variable in C?
Re: GDCC: An Alternative ACS Compiler
Posted: Sun Sep 10, 2017 7:44 am
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.
Re: GDCC: An Alternative ACS Compiler
Posted: Mon Sep 11, 2017 7:36 am
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)