This repository has been archived on 2025-02-04. You can view files and clone it, but cannot push or open issues or pull requests.
helpless/main.c
Charlie 98feda0cbb - build.c which includes everything to be built and configures build with #defines
- Some compile options that make sense for build.bat, and a build_release.bat
- oogabooga:
	- Big buffer program_memory that always has same base address (goodbye serialisation problems)
		- Big buffer grows as needed, crash when out of memory
	- Very sexy platform abstraction & basic os call procedures
	- Heap allocator around the program memory.
    - Jaiyfication (context, context.allocator, push_allocator, temp allocator)
	- Some tests to make sure we ooga the right boogas
2024-06-28 03:28:23 +02:00

60 lines
1.5 KiB
C

int main() {
printf("Program started\n");
oogabooga_init(1024 * 1024 * 100); // Start with 100mb program memory
// alloc calls to context.allocator.proc which by default is set to the
// heap allocator in memory.c
int *a = cast(int*)alloc(sizeof(int));
dealloc(a);
// We can do an old school memory dump to save our game with the global variables
// (void*) program_memory and (u64) program_memory_size
// program_memory will ALWAYS have the same virtual memory base address, so all
// pointers will remain valid when read back from disk.
// We can push allocator like jai
push_allocator(temp);
// all calls to alloc() here will be with the temporary allocator
pop_allocator(); // But this is C so we have to pop it manually!
// or we can just do this for temporary allocation
int *b = talloc(sizeof(int));
// Call each frame
reset_temporary_storage();
Context c = context;
// ... modify c
push_context(c);
// ... do stuff in modified context
pop_context();
// For now, context only has the allocator and CONTEXT_EXTRA which can be defined
// to add some custom stuff to context
// But it needs to be in build.c before including oogabooga.c.
// #define CONTEXT_EXTRA struct { int monkee; }
context.extra.monkee = 69;
// This can be disabled in build.c
#if RUN_TESTS
oogabooga_run_tests();
#endif
int hello;
hello = 5;
#ifdef DEBUG
printf("Hello, balls! (debug)\n");
#endif
#ifdef RELEASE
printf("Hello, balls! (release)\n");
#endif
printf("Program exit as expected\n");
return 0;
}