Skip to content

Commit

Permalink
Compatibility with Visual C++ and MASM, build instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Roninkoi committed Jun 1, 2024
1 parent 37da54a commit 8f83821
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 19 deletions.
9 changes: 9 additions & 0 deletions CLEAN.BAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DEL REND13X.EXE
DEL REND13X.LIB
DEL *.OBJ
DEL *.MAP
DEL *.CSM
DEL *.SBR
DEL *.DSW
DEL *.DSK
DEL *.OBR
2 changes: 2 additions & 0 deletions MASM13.BAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ML /c SRC/IN.ASM /Fo IN.OBJ
ML /c SRC/R13.ASM /Fo R13.OBJ
2 changes: 2 additions & 0 deletions MASMX.BAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ML /c SRC/IN.ASM /Fo IN.OBJ
ML /c SRC/RX.ASM /Fo RX.OBJ
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ VGA software renderer written in C and x86 assembly. Mode 13h (320x200) or mode

The purpose of this project is to explore early game engine development and x86 assembly graphics programming.

Compiled using Turbo C++ 3 in DOS, Borland C++ 4.5 in Windows or equivalent. Assembly versions assembled using Turbo Assembler 5. The program can be compiled using the project files REND13X.PRJ or REND13X.IDE. The program can also be built using the batch files BUILD13.BAT and BUILDX.BAT. Runs on real hardware (DOS, i486 or equivalent) or in DOSBox.
Runs on real hardware (DOS, i486 or equivalent) or in DOSBox.

## FEATURES
## Features

- "Fast" x86 assembly draw routines for line drawing and triangle fills.
- Two video modes: mode 13h or mode X, define MODE13 or MODEX in RENDER.H to enable/disable.
Expand All @@ -27,7 +27,7 @@ Compiled using Turbo C++ 3 in DOS, Borland C++ 4.5 in Windows or equivalent. Ass

- Keyboard interrupt handler for smooth multi-key input.

## CONTROLS
## Controls

| Key | Action |
| --- | ------ |
Expand All @@ -37,6 +37,36 @@ Compiled using Turbo C++ 3 in DOS, Borland C++ 4.5 in Windows or equivalent. Ass
| F | Fly down |
| Esc | Exit to DOS |

## Building

Compiled using Turbo C++ 3 in DOS, Borland C++ 4 or Microsoft Visual C++ 6 in Windows or equivalent. Assembled using Turbo Assembler 5 or Microsoft Macro Assembler 6.

### Turbo C++

Building requires Turbo Assembler. The project can also be completely built using the given batch files.

Project file: `REND13X.PRJ`

Build Mode 13: `BUILD13.BAT`

Build Mode X: `BUILDX.BAT`

### Borland C++

Building requires Turbo Assembler. Include either `R13.ASM` or `RX.ASM` in the project (not both).

Project file: `REND13X.IDE`

### Visual C++

Building requires Microsoft Macro Assembler. Visual C++ won't assemble the .ASM files for you, so they need to be assembled separately before building the project. Include the object files `IN.OBJ` and either `R13.OBJ` or `RX.OBJ`.

Project file: `REND13X.MAK`

Assemble Mode 13: `MASM13.BAT`

Assemble Mode X: `MASMX.BAT`

## TODO

- Improve mode X fills for better plane handling.
Expand Down
32 changes: 32 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,35 @@ F - Fly down

Esc - Exit to DOS

--- Building ---

Compiled using Turbo C++ 3 in DOS, Borland C++ 4 or Visual C++ 6 in Windows
or equivalent. Assembled using Turbo Assembler 5 or Microsoft Macro
Assembler 6.

-- Turbo C++ --

Building requires Turbo Assembler. The project can also be completely built
using the given batch files.

Project file: REND13X.PRJ
Build Mode 13: BUILD13.BAT
Build Mode X: BUILDX.BAT

-- Borland C++ --

Building requires Turbo Assembler. Include either R13.ASM or RX.ASM in the
project (not both).

Project file: REND13X.IDE

-- Visual C++ --

Building requires Microsoft Macro Assembler. Visual C++ won't assemble the
.ASM files for you, so they need to be assembled separately before building
the project. Include the object files IN.OBJ and either R13.OBJ or RX.OBJ.

Project file: REND13X.MAK
Assemble Mode 13: MASM13.BAT
Assemble Mode X: MASMX.BAT

136 changes: 136 additions & 0 deletions REND13X.MAK
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#
# Borland C++ IDE generated makefile
#
.AUTODEPEND


#
# Borland C++ tools
#
IMPLIB = Implib
BCCDOS = Bcc +BccDos.cfg
TLINK = TLink
TLIB = TLib
TASM = Tasm
#
# IDE macros
#


#
# Options
#
IDE_LFLAGSDOS = -LC:\BC45\LIB
IDE_BFLAGS =
LLATDOS_DcbREND13Xbrend13xdexe = -c -LC:\TC\LIB -Tde
RLATDOS_DcbREND13Xbrend13xdexe =
BLATDOS_DcbREND13Xbrend13xdexe =
CNIEAT_DcbREND13Xbrend13xdexe = -IC:\TC\INCLUDE -D
LNIEAT_DcbREND13Xbrend13xdexe = -x
LEAT_DcbREND13Xbrend13xdexe = $(LLATDOS_DcbREND13Xbrend13xdexe)
REAT_DcbREND13Xbrend13xdexe = $(RLATDOS_DcbREND13Xbrend13xdexe)
BEAT_DcbREND13Xbrend13xdexe = $(BLATDOS_DcbREND13Xbrend13xdexe)

#
# Dependency List
#
Dep_rend13x = \
D:\REND13X\rend13x.exe

rend13x : BccDos.cfg $(Dep_rend13x)
echo MakeNode

Dep_DcbREND13Xbrend13xdexe = \
in.obj\
rx.obj\
draw.obj\
main.obj\
render.obj\
renderx.obj\
render13.obj\
vec.obj\
input.obj

D:\REND13X\rend13x.exe : $(Dep_DcbREND13Xbrend13xdexe)
$(TLINK) @&&|
/v $(IDE_LFLAGSDOS) $(LEAT_DcbREND13Xbrend13xdexe) $(LNIEAT_DcbREND13Xbrend13xdexe) +
C:\TC\LIB\c0l.obj+
in.obj+
rx.obj+
draw.obj+
main.obj+
render.obj+
renderx.obj+
render13.obj+
vec.obj+
input.obj
$<,$*
C:\TC\LIB\fp87.lib+
C:\TC\LIB\mathl.lib+
C:\TC\LIB\cl.lib

|

in.obj : src\in.asm
$(TASM) @&&|
/ml D:\REND13X\src\in.asm ,in.obj
|

rx.obj : src\rx.asm
$(TASM) @&&|
/ml D:\REND13X\src\rx.asm ,rx.obj
|

draw.obj : src\draw.c
$(BCCDOS) -P- -c @&&|
$(CEAT_DcbREND13Xbrend13xdexe) $(CNIEAT_DcbREND13Xbrend13xdexe) -o$@ src\draw.c
|

main.obj : src\main.c
$(BCCDOS) -P- -c @&&|
$(CEAT_DcbREND13Xbrend13xdexe) $(CNIEAT_DcbREND13Xbrend13xdexe) -o$@ src\main.c
|

render.obj : src\render.c
$(BCCDOS) -P- -c @&&|
$(CEAT_DcbREND13Xbrend13xdexe) $(CNIEAT_DcbREND13Xbrend13xdexe) -o$@ src\render.c
|

renderx.obj : src\renderx.c
$(BCCDOS) -P- -c @&&|
$(CEAT_DcbREND13Xbrend13xdexe) $(CNIEAT_DcbREND13Xbrend13xdexe) -o$@ src\renderx.c
|

render13.obj : src\render13.c
$(BCCDOS) -P- -c @&&|
$(CEAT_DcbREND13Xbrend13xdexe) $(CNIEAT_DcbREND13Xbrend13xdexe) -o$@ src\render13.c
|

vec.obj : src\vec.c
$(BCCDOS) -P- -c @&&|
$(CEAT_DcbREND13Xbrend13xdexe) $(CNIEAT_DcbREND13Xbrend13xdexe) -o$@ src\vec.c
|

input.obj : src\input.c
$(BCCDOS) -P- -c @&&|
$(CEAT_DcbREND13Xbrend13xdexe) $(CNIEAT_DcbREND13Xbrend13xdexe) -o$@ src\input.c
|

# Compiler configuration file
BccDos.cfg :
Copy &&|
-W-
-R
-v
-vi
-H
-H=rend13x.csm
-R-
-f287
-i32
-O
-ml
-3
| $@


16 changes: 8 additions & 8 deletions SRC/INPUT.C
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

int itime = 0;

void interrupt (*oldTime) ();
void (interrupt *oldTime) ();

void interrupt getITime()
{
Expand All @@ -11,13 +11,13 @@ void interrupt getITime()

void hookTime()
{
oldTime = getvect(0x1c);
setvect(0x1c, getITime);
oldTime = _dos_getvect(0x1c);
_dos_setvect(0x1c, getITime);
}

void unhookTime()
{
setvect(0x1c, oldTime);
_dos_setvect(0x1c, oldTime);
}

unsigned now()
Expand All @@ -31,7 +31,7 @@ byte keycodei = 0;

int keydown[256];

void interrupt (*oldKeys) ();
void (interrupt *oldKeys) ();

extern int get_keycode();

Expand All @@ -44,13 +44,13 @@ void interrupt getKeys()

void hookKeys()
{
oldKeys = getvect(9);
setvect(9, getKeys);
oldKeys = _dos_getvect(9);
_dos_setvect(9, getKeys);
}

void unhookKeys()
{
setvect(9, oldKeys);
_dos_setvect(9, oldKeys);
}

void getInput()
Expand Down
6 changes: 3 additions & 3 deletions SRC/R13.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ _r_putpixel PROC FAR
xor ax, ax
mov al, [bp+10] ;; color
mov [es]:di, al ;; put pixel
mov es:[di], al ;; put pixel
pop di
pop bp
Expand Down Expand Up @@ -368,7 +368,7 @@ _r_vlinefill PROC FAR
mov al, [bp+12] ;; color
vfill:
mov [es]:di, al ;; put pixel
mov es:[di], al ;; put pixel
add di, W ;; y += 1
cmp di, dx ;; end?
jb vfill
Expand Down Expand Up @@ -472,7 +472,7 @@ lfmaxd:
lfill:
mov si, cx ;; pixel address x + y * W

mov [es]:si, al ;; put pixel
mov es:[si], al ;; put pixel

mov si, di
sal si, 1 ;; $si *= 2
Expand Down
10 changes: 5 additions & 5 deletions SRC/RX.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ _r_exit ENDP
public _r_waitretrace
_r_waitretrace PROC FAR
cli

twaits: ;; trace start
mov dx, 3dah
in al, dx
Expand Down Expand Up @@ -230,7 +230,7 @@ _r_putpixel PROC FAR
out dx, ax

mov al, [bp+10] ;; color
mov [es]:di, al ;; put pixel
mov es:[di], al ;; put pixel

pop di
pop bp
Expand Down Expand Up @@ -306,7 +306,7 @@ _r_planefill PROC FAR
xor ax, ax
mov al, [bp+12] ;; color

mov [es]:di, al ;; draw planes
mov es:[di], al ;; draw planes

pop di
pop bp
Expand Down Expand Up @@ -519,7 +519,7 @@ _r_vplanefill PROC FAR
mov al, [bp+14] ;; color
vfill:
mov [es]:di, al ;; put pixel
mov es:[di], al ;; put pixel
add di, si ;; y += 1

cmp di, bx ;; end?
Expand Down Expand Up @@ -640,7 +640,7 @@ lfill:
add si, bx ;; calculate address x + y * W/4

mov ax, [bp]
mov [es]:si, al ;; write pixel
mov es:[si], al ;; write pixel

mov si, di
sal si, 1 ;; $si *= 2
Expand Down

0 comments on commit 8f83821

Please sign in to comment.