Skip to content

Commit d3259a3

Browse files
1.01
Compiled with gcc 9 and ArcaOS 5.0.7
1 parent 091422b commit d3259a3

File tree

7 files changed

+98
-46
lines changed

7 files changed

+98
-46
lines changed

BUILD.CMD

-2
This file was deleted.

FASTGPI.C

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
/* $Id: inten5pm.c 1.6 93/09/19 05:14:07 Unknown Exp Locker: Unknown $ */
2-
/* Copyright (c) 1994 Donald Graft, All Rights Reserved */
1+
/*
2+
* fastgpi.c
3+
*
4+
* Donald Graft
5+
*/
36

47
#define INCL_DOS
58
#define INCL_WIN
@@ -9,6 +12,7 @@
912
#include <stdio.h>
1013
#include <stdlib.h>
1114
#include <math.h>
15+
#include <string.h>
1216
#include "a-float.h"
1317
/* ENDINCL */
1418

@@ -30,16 +34,15 @@ PBITMAPINFO2 pbmi;
3034
BYTE RGBmap[32];
3135
BYTE Bitmap[NUM_MASSES_X*NUM_MASSES_Y];
3236
POINTL aptl[3] =
33-
{ 0u, 0u, NUM_MASSES_X, NUM_MASSES_Y, 0u, 0u };
37+
{ {0u, 0u}, {NUM_MASSES_X, NUM_MASSES_Y}, {0u, 0u} };
3438

3539
MRESULT EXPENTRY window_func(HWND, ULONG, MPARAM, MPARAM);
3640
void Model(ULONG);
3741
void PrepareGraphics(BYTE *);
3842
void DisplayPlane(float **current);
3943
float ***Storage();
40-
41-
void
42-
main(void)
44+
45+
int main(void)
4346
{
4447
HMQ hmq;
4548
QMSG qmsg;
@@ -139,7 +142,7 @@ window_func(HWND handle, ULONG mess, MPARAM parm1, MPARAM parm2)
139142
/* Create a semaphore to control access to the memory image
140143
presentation space. Only one thread can perform Gpi operations
141144
on it at a time. */
142-
DosCreateMutexSem("\\sem32\\Lock", &hmtxLock, 0, FALSE);
145+
DosCreateMutexSem((PCSZ)"\\sem32\\Lock", &hmtxLock, 0, FALSE);
143146

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

231234
/* Display results. */
232235
DisplayPlane(current);
233-
236+
234237
/* Advance epoch. */
235238
count++;
236239
tmp = inhibitory;

FASTGPI.DEF

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
NAME STDPRGM WINDOWAPI
1+
;-----------------------------------
2+
; BEZIER.DEF module definition file
3+
;-----------------------------------
24

3-
DESCRIPTION 'Skeleton Program'
4-
HEAPSIZE 1024
5+
NAME FASTGPI WINDOWAPI
6+
7+
DESCRIPTION '@#OS2World:1.01#@##1## 07 May 2023 20:00:00 ARCAOS-507::::::v1.01@@Getting Fast GPI Graphics Demo.'
58
STACKSIZE 8192

FASTGPI.EXE

-35 KB
Binary file not shown.

FASTGPI.TXT

+57-33
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
Method for Getting Fast Graphics through the OS/2 GPI
2-
-----------------------------------------------------
3-
4-
People are often surprised and dismayed to find that the GPI can be
5-
very slow if it is used naively. One of the biggest mistakes is to try to
6-
write a large number of pixels using GpiSetPel(). To reassure people that
7-
fast screen writes CAN be achieved with the GPI and without needing to
8-
go to the MMPM direct-screen support (DIVE), I have provided this little
9-
example. As a bonus, it also shows how to use bitmaps, how to write a
10-
multi-threaded application, how to use semaphores, and how to set up a
11-
gray-scale palette. Also, you can learn about classical wave behavior
1+
Name: REVOLVE
2+
Descripcion: Demonstrates Fast GPI Graphics
3+
Date: 2023-05-07
4+
Version: 1.07
5+
----------------------------
6+
7+
DESCRIPTION
8+
-----------
9+
Method for Getting Fast Graphics through the OS/2 GPI.
10+
11+
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
1212
and its difference equation representation!
1313

14-
The basic technique for fast screen writes is to make a bitmap that
15-
corresponds to the screen. Then, using GpiSetBitmapBits(), this bitmap
16-
is updated and then blitted to the screen. This requires only two GPI
17-
calls to write an arbitrary number of pixels, instead of doing a call to
18-
set the color and a call to write the pixel for EACH pixel.
14+
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.
1915

20-
Here are miscellaneous notes.
16+
Here are miscellaneous notes.
2117

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

31-
3) Built with GCC/2 2.5.4.
27+
3) Built with GCC 9.
3228

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

51-
9) Thanks to George Thiruvathakal for providing the array support package.
52-
It makes possible the highly efficient shifting of planes required at
53-
each epoch update (an operation not possible with straightforward
54-
3-dimensional C array syntax).
47+
REQUIREMENTS
48+
------------
49+
- yum install git gcc make libc-devel binutils watcom-wrc watcom-wlink-hll
50+
51+
COMPILE INSTRUCTIONS
52+
--------------------
53+
This version of this sample was modified to compile on ArcaOS with GCC 9 compiler.
54+
55+
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"
56+
57+
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...
58+
SET EMXOMFLD_LINKER=wl.exe
59+
SET EMXOMFLD_TYPE=WLINK
60+
SET EMXOMFLD_RC_TYPE=WRC
61+
SET EMXOMFLD_RC=wrc.exe
62+
63+
3) Run "make" or "make 2>&1 |tee make.out" to get the log file.
64+
65+
66+
TOOLS USED
67+
----------
68+
- ArcaOS - Verion 5.0.7
69+
- wrc - Watcom Resource Compiler version 2.0beta1
70+
- wl - Watcom Linker
71+
- gcc - gcc (GCC) 9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
72+
- make - Version 3.81 k2 (2017-11-10)
73+
74+
TROUBLESHOOT
75+
------------
76+
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.
5577

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

59-
Donald Graft dgraft@gate.net
83+
- 1.06 - 1988
84+
Original version by Charles Petzold
6085

61-
The following files make up the example application:
86+
LICENSE
87+
-------
88+
The 3-Clause BSD License.
6289

63-
build.cmd -- command file to build the application. Assumes GCC/2 2.5.4.
64-
fastgpi.def -- module definition file
65-
fastgpi.c -- main file
66-
fastgpi.exe -- the executable
67-
fastgpi.doc -- this file
68-
a-float.h -- header for array package
69-
a-float.c -- array package code
90+
AUTHORS
91+
-------
92+
- Martin Iturbide (2023)
93+
- Donald Graft

compile.cmd

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REM SET C_INCLUDE_PATH=c:/usr/include;%C_INCLUDE_PATH%
2+
REM SET INCLUDE=C:\usr\include
3+
REM SET EMXOMFLD_TYPE=WLINK
4+
REM SET EMXOMFLD_LINKER=wl.exe
5+
make 2>&1 |tee make.out

makefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# nmake makefile
2+
#
3+
# Tools used:
4+
# Compile::Watcom Resource Compiler
5+
# Compile::GNU C
6+
# Make: nmake or GNU make
7+
all : fastgpi.exe
8+
9+
fastgpi.exe : fastgpi.obj fastgpi.def a-float.obj
10+
gcc -Zomf fastgpi.obj a-float.obj fastgpi.def -o fastgpi.exe
11+
12+
fastgpi.obj : fastgpi.c
13+
gcc -Wall -Zomf -c -O2 fastgpi.c -o fastgpi.obj
14+
15+
a-float.obj : a-float.c a-float.h
16+
gcc -Wall -Zomf -c -O2 a-float.c -o a-float.obj
17+
18+
clean :
19+
rm -rf *exe *RES *obj *hlp

0 commit comments

Comments
 (0)