Skip to content

Commit

Permalink
1.01
Browse files Browse the repository at this point in the history
Compiled with gcc 9 and ArcaOS 5.0.7
  • Loading branch information
martiniturbide committed May 8, 2023
1 parent 091422b commit d3259a3
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 46 deletions.
2 changes: 0 additions & 2 deletions BUILD.CMD

This file was deleted.

19 changes: 11 additions & 8 deletions FASTGPI.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* $Id: inten5pm.c 1.6 93/09/19 05:14:07 Unknown Exp Locker: Unknown $ */
/* Copyright (c) 1994 Donald Graft, All Rights Reserved */
/*
* fastgpi.c
*
* Donald Graft
*/

#define INCL_DOS
#define INCL_WIN
Expand All @@ -9,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "a-float.h"
/* ENDINCL */

Expand All @@ -30,16 +34,15 @@ PBITMAPINFO2 pbmi;
BYTE RGBmap[32];
BYTE Bitmap[NUM_MASSES_X*NUM_MASSES_Y];
POINTL aptl[3] =
{ 0u, 0u, NUM_MASSES_X, NUM_MASSES_Y, 0u, 0u };
{ {0u, 0u}, {NUM_MASSES_X, NUM_MASSES_Y}, {0u, 0u} };

MRESULT EXPENTRY window_func(HWND, ULONG, MPARAM, MPARAM);
void Model(ULONG);
void PrepareGraphics(BYTE *);
void DisplayPlane(float **current);
float ***Storage();

void
main(void)

int main(void)
{
HMQ hmq;
QMSG qmsg;
Expand Down Expand Up @@ -139,7 +142,7 @@ window_func(HWND handle, ULONG mess, MPARAM parm1, MPARAM parm2)
/* Create a semaphore to control access to the memory image
presentation space. Only one thread can perform Gpi operations
on it at a time. */
DosCreateMutexSem("\\sem32\\Lock", &hmtxLock, 0, FALSE);
DosCreateMutexSem((PCSZ)"\\sem32\\Lock", &hmtxLock, 0, FALSE);

/* Create a thread to run the system model. */
DosCreateThread(&tidModel, Model, 0UL, 0UL, 4096);
Expand Down Expand Up @@ -230,7 +233,7 @@ Model(ULONG dummy)

/* Display results. */
DisplayPlane(current);

/* Advance epoch. */
count++;
tmp = inhibitory;
Expand Down
9 changes: 6 additions & 3 deletions FASTGPI.DEF
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
NAME STDPRGM WINDOWAPI
;-----------------------------------
; BEZIER.DEF module definition file
;-----------------------------------

DESCRIPTION 'Skeleton Program'
HEAPSIZE 1024
NAME FASTGPI WINDOWAPI

DESCRIPTION '@#OS2World:1.01#@##1## 07 May 2023 20:00:00 ARCAOS-507::::::v1.01@@Getting Fast GPI Graphics Demo.'
STACKSIZE 8192
Binary file removed FASTGPI.EXE
Binary file not shown.
90 changes: 57 additions & 33 deletions FASTGPI.TXT
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
Method for Getting Fast Graphics through the OS/2 GPI
-----------------------------------------------------

People are often surprised and dismayed to find that the GPI can be
very slow if it is used naively. One of the biggest mistakes is to try to
write a large number of pixels using GpiSetPel(). To reassure people that
fast screen writes CAN be achieved with the GPI and without needing to
go to the MMPM direct-screen support (DIVE), I have provided this little
example. As a bonus, it also shows how to use bitmaps, how to write a
multi-threaded application, how to use semaphores, and how to set up a
gray-scale palette. Also, you can learn about classical wave behavior
Name: REVOLVE
Descripcion: Demonstrates Fast GPI Graphics
Date: 2023-05-07
Version: 1.07
----------------------------

DESCRIPTION
-----------
Method for Getting Fast Graphics through the OS/2 GPI.

People are often surprised and dismayed to find that the GPI can be very slow if it is used naively. One of the biggest mistakes is to try to write a large number of pixels using GpiSetPel(). To reassure people that fast screen writes CAN be achieved with the GPI and without needing to go to the MMPM direct-screen support (DIVE), I have provided this little example. As a bonus, it also shows how to use bitmaps, how to write a multi-threaded application, how to use semaphores, and how to set up a gray-scale palette. Also, you can learn about classical wave behavior
and its difference equation representation!

The basic technique for fast screen writes is to make a bitmap that
corresponds to the screen. Then, using GpiSetBitmapBits(), this bitmap
is updated and then blitted to the screen. This requires only two GPI
calls to write an arbitrary number of pixels, instead of doing a call to
set the color and a call to write the pixel for EACH pixel.
The basic technique for fast screen writes is to make a bitmap that corresponds to the screen. Then, using GpiSetBitmapBits(), this bitmap is updated and then blitted to the screen. This requires only two GPI calls to write an arbitrary number of pixels, instead of doing a call to set the color and a call to write the pixel for EACH pixel.

Here are miscellaneous notes.
Here are miscellaneous notes.

1) The example implements a simulation of two interfering circular wave
sources in two dimensions. The output is displayed with a 32-level
Expand All @@ -28,7 +24,7 @@ set the color and a call to write the pixel for EACH pixel.
applications. I have not tried this at other resolutions, but things
should work OK (or could be easily adjusted for).

3) Built with GCC/2 2.5.4.
3) Built with GCC 9.

4) The screens are written very fast [DisplayPlane()] but there is delay
between the screen writes due to the many thousands of floating-point
Expand All @@ -48,22 +44,50 @@ set the color and a call to write the pixel for EACH pixel.
8) The example is multithreaded; one thread does the model, one does the main
window handling. Down with clock icons!!!

9) Thanks to George Thiruvathakal for providing the array support package.
It makes possible the highly efficient shifting of planes required at
each epoch update (an operation not possible with straightforward
3-dimensional C array syntax).
REQUIREMENTS
------------
- yum install git gcc make libc-devel binutils watcom-wrc watcom-wlink-hll

COMPILE INSTRUCTIONS
--------------------
This version of this sample was modified to compile on ArcaOS with GCC 9 compiler.

1) Remember to have correct header files your path. For GCC the correct ones are the included on the "libc-devel", not the ones from the OS/2 Toolkit. Check your config.sys for "SET INCLUDE=C:\usr\include"

2) Since I'm using the Watcom Resource Compiler (open source) instead of the classic rc.exe, and the the Watcom Linker, intead of the classic ilink.exe, add to your config.sys...
SET EMXOMFLD_LINKER=wl.exe
SET EMXOMFLD_TYPE=WLINK
SET EMXOMFLD_RC_TYPE=WRC
SET EMXOMFLD_RC=wrc.exe

3) Run "make" or "make 2>&1 |tee make.out" to get the log file.


TOOLS USED
----------
- ArcaOS - Verion 5.0.7
- wrc - Watcom Resource Compiler version 2.0beta1
- wl - Watcom Linker
- gcc - gcc (GCC) 9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
- make - Version 3.81 k2 (2017-11-10)

TROUBLESHOOT
------------
The compile produce will run by just executing make on the directory, but a compile.cmd file is includes to store the log in a file. If you want to save the log file you can run it as "nmake 2>&1 |tee make.out". The log will be saved into the "make.out" file.

10) Permission to use as a guide for your own applications. Have fun!
Feedback to:
HISTORY
----------
- 1.07 - 2023-05-07
Changed version to compile on gcc and to run on ArcaOS 5.0.7.

Donald Graft [email protected]
- 1.06 - 1988
Original version by Charles Petzold

The following files make up the example application:
LICENSE
-------
The 3-Clause BSD License.

build.cmd -- command file to build the application. Assumes GCC/2 2.5.4.
fastgpi.def -- module definition file
fastgpi.c -- main file
fastgpi.exe -- the executable
fastgpi.doc -- this file
a-float.h -- header for array package
a-float.c -- array package code
AUTHORS
-------
- Martin Iturbide (2023)
- Donald Graft
5 changes: 5 additions & 0 deletions compile.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
REM SET C_INCLUDE_PATH=c:/usr/include;%C_INCLUDE_PATH%
REM SET INCLUDE=C:\usr\include
REM SET EMXOMFLD_TYPE=WLINK
REM SET EMXOMFLD_LINKER=wl.exe
make 2>&1 |tee make.out
19 changes: 19 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# nmake makefile
#
# Tools used:
# Compile::Watcom Resource Compiler
# Compile::GNU C
# Make: nmake or GNU make
all : fastgpi.exe

fastgpi.exe : fastgpi.obj fastgpi.def a-float.obj
gcc -Zomf fastgpi.obj a-float.obj fastgpi.def -o fastgpi.exe

fastgpi.obj : fastgpi.c
gcc -Wall -Zomf -c -O2 fastgpi.c -o fastgpi.obj

a-float.obj : a-float.c a-float.h
gcc -Wall -Zomf -c -O2 a-float.c -o a-float.obj

clean :
rm -rf *exe *RES *obj *hlp

0 comments on commit d3259a3

Please sign in to comment.