Skip to content

Commit

Permalink
support building with OW (not yet functional)
Browse files Browse the repository at this point in the history
  • Loading branch information
PerditionC committed Jan 2, 2025
1 parent a31a793 commit 3c13a5c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 15 deletions.
30 changes: 22 additions & 8 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ ECHO.
ECHO Note: ensure UPX is in your path, optionally make in C:\bin
goto end

:clean
%MAKE% -C src RM=del clean
goto end

:clobber
%MAKE% -C src RM=del clobber
goto end

:tcc2
rem ############# Turbo C 2.01 ########################
IF [%BASEPATH%]==[] set BASEPATH=C:\tc201
Expand All @@ -33,17 +41,25 @@ goto tcshared

:tcshared
rem ############# TURBO_C shared ########################
set LIBS=%BASEPATH%\lib
set INCLUDE=%BASEPATH%/include
set CC=tcc
set LD=tlink
set LDFLAGS=/m /s /c /t $(LIBS)\c0t.obj $(EXTRA_OBJS) share.obj,share.com,,$(LIBS)\cs.lib
set CFLAGS=-I../kitten -I../tnyprntf -I%INCLUDE% -mt -1 -c -o
set LDFLAGS=/m /s /c /t %BASEPATH%\lib\c0t.obj $(EXTRA_OBJS) share.obj,share.com,,%BASEPATH%\lib\cs.lib
set CFLAGS=-I../kitten -I../tnyprntf -I%BASEPATH%/include -mt -1 -c -o
set EXTRA_OBJS=
goto doit

:doit
set EXTRA_OBJS=
:ow
IF [%BASEPATH%]==[] set BASEPATH=D:\ow19
set CC=wcc
set LD=wlink
::set [email protected]
set LDFLAGS=system com name share.com file share,kitten,tnyprntf,amishelp option quiet,map,statics,verbose,artificial,symfile
set CFLAGS=-I..\kitten -I..\tnyprntf -q -0 -ms -btdos -os -fo=
set EXTRA_OBJS=amishelp.obj
goto doit


:doit
set EXTRA_OBJS=%EXTRA_OBJS% kitten.obj
rem # if you want to build without kitten comment the above and uncomment
rem the following
Expand All @@ -70,8 +86,6 @@ rem cleanup
set PATH=%OLD_PATH%
set MAKE=
set BASEPATH=
set INCLUDE=
set LIBS=
set CC=
set CFLAGS=
set LD=
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ else
amishelp.obj: amishelp.asm
nasm -f obj -I ../lmacros/ -I lmacros/ $< -o $@

kitten.obj: ../kitten/kitten.c
kitten.obj: ..\kitten\kitten.c
$(CC) $(CFLAGS)$@ $^

tnyprntf.obj: ../tnyprntf/tnyprntf.c
tnyprntf.obj: ..\tnyprntf\tnyprntf.c
$(CC) $(CFLAGS)$@ $^
endif

Expand Down
46 changes: 41 additions & 5 deletions src/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/* freemem, keep */
#include <string.h> /* strchr, strlen, memset */

#ifdef __TURBOC__
#if defined(__TURBOC__) || (__WATCOMC__)
#include <io.h> /* write (what else?) */
#include <stdlib.h> /* _psp, NULL, malloc, free, atol */
#define NON_RES_TEXT
Expand All @@ -21,6 +21,16 @@
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;

#if (__WATCOMC__)
//void far * getvect(unsigned char intno);
//void setvect(unsigned char intno, void far * vector);
#define getvect(x) _dos_getvect(x)
#define setvect(x, y) _dos_setvect(x, y)
#define freemem(x) _dos_freemem(x)
#define keep(x, y) _dos_keep(x, y)
#define __attribute__(x)
#endif

#elif defined(__GNUC__)
#include <libi86/stdlib.h>
#include <unistd.h>
Expand Down Expand Up @@ -156,7 +166,31 @@ typedef struct {

/* ------------- GLOBALS ------------- */
static char progname[9] NON_RES_BSS;
#if defined(__GNUC__)
#if defined (__WATCOMC__)
#pragma aux file_table_size "*"
#pragma aux file_table_size_bytes "*"
#pragma aux file_table_free "*"
#pragma aux file_table_offset "*"
#pragma aux lock_table_size "*"
#pragma aux lock_table_size_bytes "*"
#pragma aux lock_table_free "*"
#pragma aux lock_table_offset "*"
#pragma aux iregs "*"

#pragma aux need_to_chain "*"

#pragma aux old_handler2f "*"
#pragma aux handler2f "*"

/* same as __cdecl except don't preceed with _ underscore */
#pragma aux __gcc16 "*" \
__parm __caller [] \
__value __struct __float __struct __routine [__ax] \
__modify [__ax __bx __cx __dx __es]
#pragma aux (__gcc16) inner_handler

#endif
#if defined(__GNUC__) || defined(__WATCOMC__)
extern uint16_t file_table_size; /* # of file_t we can have */
extern uint16_t file_table_size_bytes; /* amount bytes */
extern uint16_t file_table_free;
Expand Down Expand Up @@ -259,7 +293,7 @@ static void interrupt far handler2f(intregs_t iregs) {
/* would have been better to link a NASM handler core: */
/* nasm -fobj -o foo.obj foo.asm ... */

#elif defined(__GNUC__)
#elif defined(__GNUC__) || defined(__WATCOMC__)
/* Within IBM Interrupt Sharing Protocol header */
extern void __far __interrupt (*i2D_next)(void);
/* Prototype for NASM interrupt handler function */
Expand Down Expand Up @@ -356,7 +390,7 @@ void inner_handler(void) {
/* Chain to the next handler. */
#if defined(__TURBOC__)
chain_old_handler2f;
#elif defined(__GNUC__)
#elif defined(__GNUC__) || defined(__WATCOMC__)
need_to_chain = 1;
#endif
}
Expand Down Expand Up @@ -1169,7 +1203,9 @@ int main(int argc, char **argv) {
void (near *isr)() = FP_OFF(handler2f);
setvect(MUX_INT_NO,(void (interrupt far *)())MK_FP(_DS,isr));
}
#else /* causes relocations when built with Turbo C/C++ 3 */
#elif defined(__WATCOMC__)
setvect(MUX_INT_NO,handler2f); // TODO get handler2f without relocation
#else /* causes relocations when built with Turbo C/C++ 3 and OW */
setvect(MUX_INT_NO,handler2f);
#endif
/* enable(); */
Expand Down

0 comments on commit 3c13a5c

Please sign in to comment.