Skip to content

Commit

Permalink
checkpoint [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoomTen committed Jul 9, 2024
1 parent 7cce459 commit 3bf1220
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
23 changes: 5 additions & 18 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,8 @@ const
# whether or not we should be able inspect the output here
buildCacheHere = true

# GBDK dirs
# Precompile "scripts"
#-------------------------------------#
let
gbdkRoot = getEnv("GBDK_ROOT")

when not defined(nimsuggest):
doAssert(
gbdkRoot != "", "Please set the GBDK_ROOT env var."
)

let
gbdkBin = gbdkRoot / "bin"
gbdkInc = gbdkRoot / "include"
#-------------------------------------#

# Setup scripts
#-------------------------------------#

proc precompileTools() =
let tools = ["compile", "link"]

Expand All @@ -33,7 +17,10 @@ proc precompileTools() =
"c", "-d:release", "--hints:off",
thisDir() / "tools" / toolName & ".nim"
].join(" "))
#-------------------------------------#

# Setup toolchain
#-------------------------------------#
proc setupGbdk() =
# set c compiler as ""icc"" but is actually sdcc
switch "cc", "icc"
Expand Down Expand Up @@ -79,10 +66,10 @@ proc setupGbdk() =
# switch "define", "gameDebug"
#-------------------------------------#

# Set compile options specific to main file
#-------------------------------------#
if projectPath() == thisDir()/mainFile:
setupGbdk()
#switch "include", thisDir()/"include"/"gbPrelude.nim"
when buildCacheHere:
switch "nimcache", "_build"
switch "listCmd"
Expand Down
19 changes: 6 additions & 13 deletions include/nimbase.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// Minimal nimbase.h targetting GBDK '20

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

#define OLDCALL __sdcccall(0)
#define NONBANKED __nonbanked
//#include <gbdk/platform.h>

#define N_LIB_PRIVATE
#define N_NIMCALL(rettype, name) rettype name
#define N_NIMCALL_PTR(rettype, name) rettype (*name)
Expand All @@ -18,41 +14,38 @@
#define N_CLOSURE(rettype, name) N_NIMCALL(rettype, name)
#define N_CLOSURE_PTR(rettype, name) N_NIMCALL_PTR(rettype, name)
#define N_CDECL(rettype, name) rettype name

typedef signed int NI;
typedef unsigned int NU;

typedef int8_t NI8;
typedef int16_t NI16;
typedef int32_t NI32;
typedef int64_t NI64;
#define IL64(x) (x)
typedef float NF;
typedef float NF32;

typedef uint8_t NU8;
typedef uint16_t NU16;
typedef uint32_t NU32;
typedef uint64_t NU64;

typedef char NIM_CHAR;
typedef char* NCSTRING;

#define NIM_BOOL bool
#define NIM_NIL 0
#define NIM_TRUE true
#define NIM_FALSE false

#define NIM_ALIGNOF(x) _Alignof(x)
#define NIM_CONST const

#define SEQ_DECL_SIZE

#define NIM_STRLIT_FLAG ((NU)(1) << ((16) - 2))

#define NIM_LIKELY(x) (x)
#define NIM_UNLIKELY(x) (x)

// alias these functions at compiletime for now
#define fwrite(a,b,c,d) 0
#define fflush(a) 0

// these are added by os:any
// #define FILE void
// #define TFrame void
// #define stderr (void*)0
// + divulonglong, cannot use that
2 changes: 1 addition & 1 deletion src/panicoverride.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ proc panic (s: string) =
## may be replaced with A Crash Screen
discard

proc rawoutput (s: string) = discard
proc rawoutput (s: string) = discard
2 changes: 1 addition & 1 deletion tools/compile.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Mimics icc for compiling. Its purpose is to discern between
## C sources and ASM sources and makes it somewhat manageable.
##
## Calls sdcc and sdld directly. Same kinda hack as link.nims.
## Calls sdcc directly.
##
## Compilation is slow, but I guess that's the kinda
## price to pay for *full* control over the C compiler invocation.
Expand Down

0 comments on commit 3bf1220

Please sign in to comment.