-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 095bf85
Showing
49 changed files
with
7,225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
project(dumydemo.exe) | ||
|
||
set(GCC_COVERAGE_COMPILE_FLAGS "-W -Wall -pedantic") | ||
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS}) | ||
|
||
add_executable(dumydemo.exe bumpmain.c bumpobj.c bumptri.c envmaps.c flag3d.c fontnew.c gfx.c main.c math3d.c matrix.c object3d.c pcx.c polygon.c raytrace.c scroll.c sphere.c triangle.c) | ||
add_subdirectory("dummy") | ||
|
||
target_link_libraries(dumydemo.exe PUBLIC m) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# doseffects | ||
|
||
At the turn of the millenium, I wrote some graphical effects for DOS using | ||
the famous VGA mode 13h. | ||
|
||
I finally cleaned them up (to some extent), and combined into one monolithic package. | ||
|
||
The effects combined here are all written in pure C. On cleaning them up, I got rid | ||
of the remaining inline Assembly. I have a lot more effects written in Assembler in a | ||
[separate repository](https://github.com/efliks/demoscene-legacy). | ||
|
||
## Installation instructions | ||
|
||
To compile the graphical effects, install [Open Watcom 2.0](https://github.com/open-watcom/open-watcom-v2) | ||
on your DOS PC, or your VM running DOS. For me, it is a VirtualBox VM with Win98. | ||
|
||
I put here a CMakeLists.txt, but only so I can do development on a modern Linux PC. | ||
Some modules for accessing the hardware had to be mocked with dummies. The code | ||
compiles with GCC and runs, but nothing happens on the screen, which is expected. | ||
|
||
To make it actually run, copy the files to your DOS PC, except CMakeLists.txt and | ||
the dummy folder. | ||
|
||
Then, simply invoke in the main folder: | ||
|
||
wmake -f makefile.wc | ||
|
||
Run the vgademo.exe executable. Switching to the next graphical effect is done by | ||
pressing any key. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef _BUMP_H | ||
#define _BUMP_H | ||
|
||
#define SHIFT_CONST 6 | ||
|
||
#define MAX_PHONG_COLORS 63 | ||
#define PHONG_DELTA_ANGLE (M_PI / 2) / MAX_PHONG_COLORS | ||
#define PHONG_SPEC_EXPONENT 12 | ||
|
||
#define COLOR_EMPTY 0xff | ||
|
||
#define FLAT_SHADING 0 | ||
#define GOURAUD_SHADING 1 | ||
#define ENVIRONMENT_MAPPING 2 | ||
#define ENV_BUMP 3 | ||
|
||
typedef struct | ||
{ | ||
int x1, y1, x2, y2, x3, y3; | ||
} tri_struct; | ||
|
||
#endif // _BUMP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* | ||
* FlatGrd2 06/02/02 | ||
* Mikolaj Felix a.k.a. Majuma | ||
* [email protected] | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <math.h> | ||
|
||
#include "low.h" | ||
#include "gfx.h" | ||
#include "clock.h" | ||
#include "scroll.h" | ||
|
||
#include "bump.h" | ||
#include "bumpobj.h" | ||
#include "envmaps.h" | ||
|
||
void random_phong_palette() | ||
{ | ||
int i; | ||
|
||
unsigned char r, g, b; | ||
unsigned char palette[768]; | ||
|
||
float angle; | ||
float illumination; | ||
|
||
float diff_r = (float)(rand() % 20); | ||
float spec_r = (float)(rand() % 50); | ||
|
||
float diff_g = (float)(rand() % 20); | ||
float spec_g = (float)(rand() % 50); | ||
|
||
float diff_b = (float)(rand() % 20); | ||
float spec_b = (float)(rand() % 50); | ||
|
||
angle = M_PI / 2; | ||
|
||
for (i = 0; i <= MAX_PHONG_COLORS * 3; i += 3) { | ||
illumination = diff_r * cos(angle) + spec_r * pow(cos(angle), PHONG_SPEC_EXPONENT); | ||
r = (unsigned char)illumination; | ||
|
||
illumination = diff_g * cos(angle) + spec_g * pow(cos(angle), PHONG_SPEC_EXPONENT); | ||
g = (unsigned char)illumination; | ||
|
||
illumination = diff_b * cos(angle) + spec_b * pow(cos(angle), PHONG_SPEC_EXPONENT); | ||
b = (unsigned char)illumination; | ||
|
||
if (r > 31) | ||
r = 31; | ||
if (g > 63) | ||
g = 63; | ||
if (b > 31) | ||
b = 31; | ||
|
||
palette[i + 0] = r << 1; | ||
palette[i + 1] = g; | ||
palette[i + 2] = b << 1; | ||
|
||
angle -= PHONG_DELTA_ANGLE; | ||
} | ||
|
||
// font palette | ||
for (i = (MAX_PHONG_COLORS + 1) * 3; i < (MAX_PHONG_COLORS + 9) * 3; i += 3) { | ||
palette[i + 0] = (b = (i - MAX_PHONG_COLORS) + 30); | ||
palette[i + 1] = b; | ||
palette[i + 2] = b; | ||
} | ||
|
||
set_palette(palette); | ||
} | ||
|
||
int get_next_mode(int drawing_mode) | ||
{ | ||
int i; | ||
|
||
const int drawing_mode_table[][2] = { | ||
{FLAT_SHADING, GOURAUD_SHADING}, | ||
{GOURAUD_SHADING, ENVIRONMENT_MAPPING} | ||
}; | ||
|
||
for (i = 0; i < sizeof(drawing_mode_table) / sizeof(int) / 2; i++) { | ||
if (drawing_mode_table[i][0] == drawing_mode) { | ||
return drawing_mode_table[i][1]; | ||
} | ||
} | ||
|
||
// next mode not found -> should exit | ||
return -1; | ||
} | ||
|
||
void do_bump_mapping(unsigned char* frame_buffer) | ||
{ | ||
OBJECT3D* obj; | ||
VECTOR3D light_source; | ||
|
||
int blur_mode = 0; | ||
int drawing_mode = FLAT_SHADING; | ||
|
||
obj = load_object3d("torus.3d"); | ||
|
||
if (obj != NULL) { | ||
light_source.x = 0; | ||
light_source.y = 0; | ||
light_source.z = -100; | ||
normalize_vector(&light_source); | ||
|
||
// TODO Load palette from file | ||
random_phong_palette(); | ||
enable_envmap(); | ||
|
||
while (drawing_mode != -1) { | ||
timer_start(5); | ||
|
||
rotate_translate_object3d(obj, 1, 3, -1); | ||
draw_object3d(obj, &light_source, drawing_mode, frame_buffer); | ||
|
||
if (blur_mode) { | ||
do_blur(frame_buffer, 320, 200); | ||
} | ||
|
||
do_scroll(199 - 8, frame_buffer); | ||
|
||
copy_buffer(frame_buffer); | ||
clear_buffer(frame_buffer); | ||
|
||
timer_wait(); | ||
|
||
if (is_key_pressed()) { | ||
get_key_code(); | ||
drawing_mode = get_next_mode(drawing_mode); | ||
} | ||
} | ||
|
||
disable_envmap(); | ||
unload_object3d(obj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef _BUMPMAIN_H | ||
#define _BUMPMAIN_H | ||
|
||
void do_bump_mapping(unsigned char *); | ||
|
||
#endif // _BUMPMAIN_H |
Oops, something went wrong.