[ACS] Useful libraries for GDCC

Looking for Resources for your mod/project? Want to share some of your creations so others can use them? Post them here!
Post Reply
User avatar
TDRR
Forum Regular
Posts: 239
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela
Contact:

[ACS] Useful libraries for GDCC

#1

Post by TDRR » Fri Oct 04, 2024 7:46 pm

This set of libraries is entirely for GDCC-CC, GDCC's C front.

Github repository

ACS_Common
Files: ACS_Common.c, ACS_Common.h
A header for GDCC meant to simplify writing code without libGDCC and libc, and for code intended to be ported from ACC/BCC. It does the following:
  • Enables ACS strings by default, and defines a str alias to them.
  • Enables the fixed point type for literals by default.
  • Includes ACS_Zandronum.h, as well as stdbool.h and stdfix.h to provide the remaining ACS types.
  • Defines ACS_SHORT_NAMES so ACS functions are included without the ACS_ prefix.
  • Adds a def_local macro to use inside functions, to allow using local arrays without requiring libGDCC.
  • Adds a set of printing macros taking advantage of macro magic and _Generic (Can be used like: Print("This is a number: ", 10, (char)'.');).
  • Adds the LanguageLookup, GetPrintName and IntToHex macros to cover the gaps not covered by the print functions.
Remember to rename both modprefix_sta ocurrences to fit your project.

safe-malloc
Files: safe-malloc.c, safe-malloc.h
A replacement for libGDCC aimed at simplifying mod interop/compatiblity. Performs memory allocation always starting from near the very top of the address space. Other copies of safe-malloc can coexist without issue since they're all aligned, and regular ACS mods using the same global array are very unlikely to run into any conflicts.
This also allows moving the static allocation base for your mod/libc without affecting the starting location of the heap.

Must be linked as a replacement to libGDCC, do not include the original library!

actorlib
Files: actorlib.c, actorlib.h
A library making use of GDCC's struct properties to provide an ActorT struct that can call many functions in a more seamless way. For example:

Code: Select all

ActorT monster = {someMonsterTID};

monster.health = 200; // calls ACS_SetActorProperty(0, APROP_Health, 200)
if(monster.height < 32.0) // calls ACS_GetActorPropertyFixed(0, APROP_Height)
{
    monster.speed = 32.0;
    monster.scaleX = monster.scaleX - 0.1;
}
It also provides a global called self, in much the same vein as QuakeC. This allows referring to the script activator without any extra definitions:

Code: Select all

self.giveInv("Shotgun", 1);
self.health = 150;
self.viewHeight = self.height - 2.0;
Last edited by TDRR on Tue Nov 26, 2024 1:47 am, edited 3 times in total.
One thing I have asked from the Lord, that I shall seek: That I may dwell in the house of the Lord all the days of my life, to behold the beauty of the Lord and to meditate in His temple. (Psalm 27:4, NASB)
My Discord tag is @tdrr, and it's my preferred contact method. I also check PMs here from time to time.
I also have a Discord server for my projects.

User avatar
Fused
Contributor
Posts: 674
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

Re: [ACS] Useful libraries for GDCC

#2

Post by Fused » Sat Oct 05, 2024 10:12 am

Great work! I really hope custom compilers get some more attention when libraries like these are around to help develop mods. The fact that they make it so much easier is something that should be pointed out more.
My mods
Image Image

My socials
Image Image

User avatar
TDRR
Forum Regular
Posts: 239
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela
Contact:

Re: [ACS] Useful libraries for GDCC

#3

Post by TDRR » Sat Oct 05, 2024 3:53 pm

Agreed. They really do make life a lot, lot easier.

I'd also like to point out that GDCC has had a good wiki for a while now. It documents both the ACS and C fronts.
https://github.com/DavidPH/GDCC/wiki

If anyone knows some C, come check it out! The wiki documents all extensions GDCC adds to help it work with the ACS VM and the engine more completely, and there's even a getting started guide now.
One thing I have asked from the Lord, that I shall seek: That I may dwell in the house of the Lord all the days of my life, to behold the beauty of the Lord and to meditate in His temple. (Psalm 27:4, NASB)
My Discord tag is @tdrr, and it's my preferred contact method. I also check PMs here from time to time.
I also have a Discord server for my projects.

User avatar
Fused
Contributor
Posts: 674
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

Re: [ACS] Useful libraries for GDCC

#4

Post by Fused » Sun Oct 06, 2024 8:21 pm

Nice, the wiki seems to be a lot more descriptive on the ACS front too now compared to when I was using it. I hope it attracts more people.
My mods
Image Image

My socials
Image Image

User avatar
TDRR
Forum Regular
Posts: 239
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela
Contact:

Re: [ACS] Useful libraries for GDCC

#5

Post by TDRR » Mon Nov 25, 2024 2:37 am

I've added an extra library to help simplify writing code that doesn't use libGDCC or libc (often useful for extremely strict compatibility demands). It also makes porting code from ACS/BCS quite a bit simpler, as it sets a lot of defaults to be closer to them.
One thing I have asked from the Lord, that I shall seek: That I may dwell in the house of the Lord all the days of my life, to behold the beauty of the Lord and to meditate in His temple. (Psalm 27:4, NASB)
My Discord tag is @tdrr, and it's my preferred contact method. I also check PMs here from time to time.
I also have a Discord server for my projects.

Post Reply