From 8f8382102b90d61d714a0fc4162da27f5e4545e6 Mon Sep 17 00:00:00 2001 From: Roni Koitermaa Date: Sat, 1 Jun 2024 13:54:32 +0300 Subject: [PATCH] Compatibility with Visual C++ and MASM, build instructions --- CLEAN.BAT | 9 ++++ MASM13.BAT | 2 + MASMX.BAT | 2 + README.md | 36 ++++++++++++-- README.txt | 32 +++++++++++++ REND13X.MAK | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++ SRC/INPUT.C | 16 +++---- SRC/R13.ASM | 6 +-- SRC/RX.ASM | 10 ++-- 9 files changed, 230 insertions(+), 19 deletions(-) create mode 100755 CLEAN.BAT create mode 100755 MASM13.BAT create mode 100755 MASMX.BAT create mode 100644 REND13X.MAK diff --git a/CLEAN.BAT b/CLEAN.BAT new file mode 100755 index 0000000..fa8e7ee --- /dev/null +++ b/CLEAN.BAT @@ -0,0 +1,9 @@ +DEL REND13X.EXE +DEL REND13X.LIB +DEL *.OBJ +DEL *.MAP +DEL *.CSM +DEL *.SBR +DEL *.DSW +DEL *.DSK +DEL *.OBR diff --git a/MASM13.BAT b/MASM13.BAT new file mode 100755 index 0000000..0c4a057 --- /dev/null +++ b/MASM13.BAT @@ -0,0 +1,2 @@ +ML /c SRC/IN.ASM /Fo IN.OBJ +ML /c SRC/R13.ASM /Fo R13.OBJ \ No newline at end of file diff --git a/MASMX.BAT b/MASMX.BAT new file mode 100755 index 0000000..c88c915 --- /dev/null +++ b/MASMX.BAT @@ -0,0 +1,2 @@ +ML /c SRC/IN.ASM /Fo IN.OBJ +ML /c SRC/RX.ASM /Fo RX.OBJ \ No newline at end of file diff --git a/README.md b/README.md index a0b6963..c25ab7d 100755 --- a/README.md +++ b/README.md @@ -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. @@ -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 | | --- | ------ | @@ -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. diff --git a/README.txt b/README.txt index 9776dbd..d65b631 100755 --- a/README.txt +++ b/README.txt @@ -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 + diff --git a/REND13X.MAK b/REND13X.MAK new file mode 100644 index 0000000..9ae2163 --- /dev/null +++ b/REND13X.MAK @@ -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 +| $@ + + diff --git a/SRC/INPUT.C b/SRC/INPUT.C index 10986d6..9843fce 100644 --- a/SRC/INPUT.C +++ b/SRC/INPUT.C @@ -2,7 +2,7 @@ int itime = 0; -void interrupt (*oldTime) (); +void (interrupt *oldTime) (); void interrupt getITime() { @@ -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() @@ -31,7 +31,7 @@ byte keycodei = 0; int keydown[256]; -void interrupt (*oldKeys) (); +void (interrupt *oldKeys) (); extern int get_keycode(); @@ -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() diff --git a/SRC/R13.ASM b/SRC/R13.ASM index a0bab2a..4bcc6d8 100644 --- a/SRC/R13.ASM +++ b/SRC/R13.ASM @@ -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 @@ -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 @@ -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 diff --git a/SRC/RX.ASM b/SRC/RX.ASM index 776cf92..af6eac6 100644 --- a/SRC/RX.ASM +++ b/SRC/RX.ASM @@ -120,7 +120,7 @@ _r_exit ENDP public _r_waitretrace _r_waitretrace PROC FAR cli - + twaits: ;; trace start mov dx, 3dah in al, dx @@ -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 @@ -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 @@ -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? @@ -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