Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
- Added folder with Watcom C++ DLL project workspaces, to move some l…
Browse files Browse the repository at this point in the history
…ogic from DIV code to external C DLLs:

    - Added base files to compile DLLs with Watcom C++ 10.6:
        - DIV.H.
        - DIV_DLL.LNK.
        - MAKE.BAT files, each per project, with specific setup, and main in root folder to launch compilations.
    - Added MATH.DLL project (sources and compiled DLL), ready to use.
    - Added INPUT.DLL project (sources and compiled DLL), ready to use.
    - Added test DLL sources and compiled DLL.
    - Added test PRG to test DLLs in DIV.
- STRFIGHT.PRG: Fixed typos in comment header.
  • Loading branch information
José Miguel Sánchez Fernández committed May 24, 2020
1 parent 56430c4 commit a12668d
Show file tree
Hide file tree
Showing 20 changed files with 1,822 additions and 3 deletions.
23 changes: 23 additions & 0 deletions DLL/COMMON.CPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* ----------------------------------------------------------------------------
* Common code for all DIV DLLs.
* (C) VisualStudioEX3, José Miguel Sánchez Fernández - 2020
* DIV Games Studio 2 (C) Hammer Technologies - 1998, 1999
* ---------------------------------------------------------------------------- */

#include "common.h"

char* strCase(const char* input, const int mode)
{
int len = strlen(input);
char* output = strAlloc(len);

for(int i = 0; i < len; i++)
{
output[i] = mode ?
tolower(input[i]) :
toupper(input[i]);
}
output[len] = '\0';

return output;
}
42 changes: 42 additions & 0 deletions DLL/COMMON.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* ----------------------------------------------------------------------------
* Common code for all DIV DLLs.
* (C) VisualStudioEX3, José Miguel Sánchez Fernández - 2020
* DIV Games Studio 2 (C) Hammer Technologies - 1998, 1999
* ---------------------------------------------------------------------------- */

#ifndef __COMMON_H_
#define __COMMON_H_

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define GLOBALS
#include "div.h"

#define TRUE 1
#define FALSE 0

#define RESULT_OK -1
#define RESULT_ERROR -2

// Math function macros:
#define _min(a, b) a < b ? a : b
#define _max(a, b) a > b ? a : b
#define _clamp(x, a, b) x < a ? a : (x > b ? b : x)
#define _isClamped(x, a, b) x >= a && x <= b

// Gets the string parameter from DIV call:
#define getStringParm(offset) (char*)&mem[text_offset + offset]
// Allocate string pointer in div memory:
#define strAlloc(len) (char*)div_malloc(len + 1)
// Convert string to upper case:
#define strUpr(s) strCase(s, 0)
// Convert string to lower case:
#define strLwr(s) strCase(s, 1)

// String functions:
char* strCase(const char* input, const int mode);

#endif
Loading

0 comments on commit a12668d

Please sign in to comment.