Mail Archives: djgpp/1998/11/18/20:41:25
This is a multi-part message in MIME format.
------=_NextPart_000_01BE132C.0ACF5040
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
i've got five files here, which are attached. it's a program called
SimpleWindows,
which allows the user to program to windows and display it in a simple
window.
I downloaded Rsxntdj for djgpp. i have gcc ver 2.8 .
it compiles and runs fine using Visual Studio. but after i set up rsxntdj
as it told me to, i get error messages like syntax errors in the code. i
can't even run the example program provided in the rsxntdj help file. if i
try it, even a "hello world" prog, compiled using -Zwin32, i get:
c:/djgpp/bin/ld.exe: cannot open -lc_app: No such file or directory
(ENOENT)
i followed everything to a tea.
maybe you can get the program running. it shouldn't be hard.
there are only .cpp files and .h files (custom)
if you get it running and want to run a test program, just try a putSTR
command or the custom
DrawLine(x1,x2,y1,y2); (exact punctuation)
thanks
-ryan
------=_NextPart_000_01BE132C.0ACF5040
Content-Type: application/octet-stream; name="DHSWIN.CPP"
Content-Description: Dhswin.cpp (CPP File)
Content-Disposition: attachment; filename="DHSWIN.CPP"
Content-Transfer-Encoding: quoted-printable
// Test for Mr. Sourtzis=0A=
=0A=
#include "graphics.h"=0A=
#include "dhs.h"=0A=
=0A=
extern GraphicDrawQueue GraphicScreen;=0A=
extern HPEN pen;=0A=
extern int nopen;=0A=
=0A=
char Tbuffer[2048];=0A=
extern void MyMain();=0A=
Colour BACKGROUND =3D RGB(255,255,255);=0A=
=0A=
typedef struct {=0A=
unsigned int xPos;=0A=
unsigned int yPos;=0A=
char TextStorage[XSIZE][YSIZE];=0A=
unsigned int topLine;=0A=
} ScreenStateInfo;=0A=
=0A=
ScreenStateInfo* screen;=0A=
char buffer[BUFSIZE]; =0A=
int len;=0A=
int textAveWidth;=0A=
=0A=
HDC hdc;=0A=
HWND hwnd; =0A=
PAINTSTRUCT ps;=0A=
RECT rect,updateRect;=0A=
=0A=
HANDLE keyPressed;=0A=
char KeyThatWasHit;=0A=
=0A=
HANDLE TimerExpiry;=0A=
unsigned char WaitingOnTimer =3D FALSE;=0A=
static unsigned int Ticks =3D 0;=0A=
void MainStubThread (PVOID pvoid);=0A=
=0A=
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);=0A=
=0A=
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, =0A=
PSTR szCmdLine, int iCmdShow) {=0A=
=0A=
static char szAppName[] =3D "HelloWin";=0A=
MSG msg;=0A=
WNDCLASSEX wndClass;=0A=
=0A=
wndClass.cbSize =3D sizeof (wndClass);=0A=
wndClass.style =3D CS_HREDRAW | CS_VREDRAW | CS_OWNDC;=0A=
wndClass.lpfnWndProc =3D WndProc;=0A=
wndClass.cbClsExtra =3D 0;=0A=
wndClass.cbWndExtra =3D 0;=0A=
wndClass.hInstance =3D hInstance;=0A=
wndClass.hIcon =3D LoadIcon (NULL, IDI_APPLICATION);=0A=
wndClass.hCursor =3D LoadCursor (NULL, IDC_ARROW);=0A=
wndClass.hbrBackground =3D (HBRUSH) GetStockObject(WHITE_BRUSH);=0A=
=0A=
wndClass.lpszMenuName =3D NULL;=0A=
wndClass.lpszClassName =3D szAppName;=0A=
wndClass.hIconSm =3D LoadIcon (NULL, IDI_APPLICATION);=0A=
=0A=
RegisterClassEx (&wndClass);=0A=
=0A=
hwnd =3D CreateWindow (szAppName,=0A=
"SimpleWindow =
=
DHS Computer Science",=0A=
WS_OVERLAPPEDWINDOW,=0A=
CW_USEDEFAULT,=0A=
CW_USEDEFAULT,=0A=
(MAXXFONTSIZE*(XSIZE+1)) + 15,=0A=
(MAXYFONTSIZE*(YSIZE+1)) + 15,=0A=
NULL,=0A=
NULL,=0A=
hInstance,=0A=
NULL);=0A=
=0A=
ShowWindow (hwnd, iCmdShow);=0A=
UpdateWindow (hwnd); =0A=
=0A=
if (screen =3D=3D NULLP) {=0A=
initScreen();=0A=
}=0A=
=0A=
while (GetMessage (&msg, NULL, 0, 0)) {=0A=
TranslateMessage(&msg);=0A=
DispatchMessage(&msg);=0A=
}=0A=
=0A=
return msg.wParam;=0A=
=0A=
} // FNCTION=0A=
=0A=
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam,=0A=
LPARAM lParam) {=0A=
PAINTSTRUCT ps;=0A=
RECT rect;=0A=
TEXTMETRIC tm;=0A=
=0A=
switch (iMsg) {=0A=
case WM_CREATE :=0A=
=0A=
hdc =3D GetDC (hwnd);=0A=
GetTextMetrics (hdc,&tm);=0A=
textAveWidth =3D tm.tmAveCharWidth;=0A=
ReleaseDC(hwnd, hdc);=0A=
=0A=
initKeyboard();=0A=
=0A=
SetTimer (hwnd, 99, TIMER_GRANULARITY, NULL);=0A=
TimerExpiry =3D CreateEvent(NULL,FALSE,FALSE,NULL);=0A=
=0A=
if (screen =3D=3D NULLP) {=0A=
initScreen();=0A=
}=0A=
GraphicScreen.Draw();=0A=
Refresh();=0A=
#ifdef THREADS=0A=
_beginthread(MainStubThread,0,NULLP);=0A=
#else=0A=
MainStubThread(0);=0A=
#endif=0A=
return 0;=0A=
=0A=
case WM_PAINT :=0A=
=0A=
GetUpdateRect (hwnd, &updateRect, TRUE);=0A=
=0A=
hdc =3D BeginPaint(hwnd, &ps);=0A=
GetClientRect(hwnd, &rect);=0A=
if (screen =3D=3D NULLP) {=0A=
initScreen();=0A=
}=0A=
Refresh();=0A=
EndPaint (hwnd, &ps);=0A=
return 0;=0A=
=0A=
case WM_CHAR :=0A=
KeyThatWasHit =3D wParam;=0A=
SetEvent(keyPressed);=0A=
return 0;=0A=
=0A=
case WM_TIMER : =0A=
if (WaitingOnTimer) {=0A=
SetEvent(TimerExpiry);=0A=
}=0A=
Ticks++;=0A=
return 0;=0A=
=0A=
case WM_DESTROY :=0A=
KillTimer (hwnd,99);=0A=
free(screen);=0A=
PostQuitMessage (0);=0A=
return 0;=0A=
}=0A=
return DefWindowProc (hwnd, iMsg, wParam, lParam);=0A=
}=0A=
=0A=
void putSTR (char* str) {=0A=
simplePutString(str);=0A=
}=0A=
=0A=
void putINT (int num) {=0A=
sprintf(buffer,"%d",num);=0A=
simplePutString(buffer);=0A=
}=0A=
=0A=
void putUINT (unsigned int num) {=0A=
sprintf(buffer,"%u",num);=0A=
simplePutString(buffer);=0A=
}=0A=
=0A=
void putCHAR (char chr) {=0A=
sprintf(buffer,"%c",chr);=0A=
simplePutString(buffer);=0A=
}=0A=
=0A=
void putFLOAT (float num) {=0A=
sprintf(buffer,"%f",num);=0A=
simplePutString(buffer);=0A=
}=0A=
=0A=
void BlankScreen () {=0A=
InvalidateRect (hwnd, NULL, TRUE);=0A=
}=0A=
=0A=
void ClearScreen () {=0A=
=0A=
int x, y;=0A=
=0A=
for (x=3D0 ; x < XSIZE ; x++) {=0A=
for (y=3D0 ; y < YSIZE ; y++) {=0A=
screen->TextStorage[x][y] =3D ' ';=0A=
}=0A=
}=0A=
screen->xPos =3D 0;=0A=
screen->yPos =3D 0;=0A=
screen->topLine =3D 0;=0A=
=0A=
BlankScreen();=0A=
Refresh();=0A=
=0A=
}=0A=
=0A=
int gotoxy (unsigned int x, unsigned int y) {=0A=
=0A=
if (x < XSIZE) {=0A=
if (y < YSIZE) {=0A=
screen->yPos =3D (y + screen->topLine) % YSIZE;=0A=
screen->xPos =3D x;=0A=
return OK;=0A=
} else {=0A=
sprintf(buffer,"Illegal Y param for gotoxy: %d",y);=0A=
MESSAGE (buffer);=0A=
return ERRORS;=0A=
}=0A=
} else {=0A=
sprintf(buffer,"Illegal X param for gotoxy: %d",x);=0A=
MESSAGE (buffer);=0A=
return ERRORS;=0A=
}=0A=
}=0A=
=0A=
int initScreen () {=0A=
=0A=
unsigned int counter;=0A=
char* temp;=0A=
=0A=
// SetBkColor(hdc, RGB(0,0,0));=0A=
SelectObject(hdc,GetStockObject(NULL_BRUSH));=0A=
pen =3D CreatePen(PS_SOLID, 1, 0);=0A=
=0A=
SelectObject(hdc,pen);=0A=
=0A=
nopen =3D FALSE;=0A=
=0A=
UpdateWindow(hwnd);=0A=
=0A=
screen =3D (ScreenStateInfo *)malloc(sizeof(ScreenStateInfo));=0A=
if (screen =3D=3D NULLP) {=0A=
MESSAGE("Could not start terminal screen\n");=0A=
return ERRORS;=0A=
}=0A=
=0A=
for (counter=3D0, temp =3D (char *)screen;=0A=
counter < sizeof(ScreenStateInfo);=0A=
counter++, temp++) {=0A=
*temp =3D ' ';=0A=
}=0A=
screen->xPos =3D 0;=0A=
screen->yPos =3D 0;=0A=
screen->topLine =3D 0;=0A=
=0A=
gotoxy(0,0);=0A=
simplePutString("SimpleWindow Developed by: Joel Orvis =
1997\n");=0A=
simplePutString("Console Started...\n\n");=0A=
=0A=
return OK;=0A=
}=0A=
=0A=
unsigned int RealCurrentLine(unsigned int line) {=0A=
=0A=
return (YSIZE+(line-screen->topLine))%YSIZE;=0A=
}=0A=
=0A=
void Refresh() {=0A=
=0A=
LONG line;=0A=
LONG count;=0A=
=0A=
GraphicScreen.Draw();=0A=
for (line =3D MIN((updateRect.top/MAXYFONTSIZE)-1,YSIZE) ; =0A=
line < MIN((updateRect.bottom/MAXYFONTSIZE)+1,YSIZE) ; line++) {=0A=
for (count =3D MIN((updateRect.left/MAXXFONTSIZE)-1,XSIZE) ; =0A=
count < MIN((updateRect.right/MAXXFONTSIZE)+1,XSIZE) ; count++) {=0A=
if ((count >=3D0) && (line >=3D0) && =
(screen->TextStorage[count][line] !=3D ' '))=0A=
=
ScreenPrint(count,RealCurrentLine(line),screen->TextStorage[count][line])=
;=0A=
}=0A=
}=0A=
ValidateRect(hwnd,NULL);=0A=
=0A=
}=0A=
=0A=
=0A=
unsigned int xPos (unsigned int x) {=0A=
return MAXXFONTSIZE*x;=0A=
}=0A=
=0A=
unsigned int yPos (unsigned int y) {=0A=
return MAXYFONTSIZE*y;=0A=
} =0A=
=0A=
=0A=
void ScreenPrint(unsigned int x, unsigned int y, char ch) {=0A=
TextOut (hdc, xPos(x), yPos(y), &ch, 1);=0A=
};=0A=
=0A=
int state =3D 0;=0A=
=0A=
void ScrollScreen() {=0A=
=0A=
unsigned int count;=0A=
// RECT tempRect;=0A=
=0A=
if (state =3D=3D 1) {=0A=
return;=0A=
}=0A=
=0A=
state =3D 1;=0A=
ScrollWindow(hwnd, 0, -1*MAXYFONTSIZE, NULL, NULL);=0A=
// ValidateRect(hwnd,NULL); =0A=
=0A=
// tempRect.left =3D 0;=0A=
// tempRect.right =3D MAXXFONTSIZE*XSIZE;=0A=
// tempRect.top =3D (YSIZE-4)*MAXYFONTSIZE;=0A=
// tempRect.bottom =3D tempRect.top + 2*MAXYFONTSIZE;=0A=
=0A=
// InvalidateRect(hwnd,&tempRect,TRUE);=0A=
=0A=
for (count =3D 0 ; count < XSIZE ; count++) {=0A=
screen->TextStorage[count][screen->topLine] =3D ' ';=0A=
}=0A=
screen->topLine++;=0A=
if (screen->topLine =3D=3D YSIZE) {=0A=
screen->topLine =3D 0;=0A=
}=0A=
=0A=
BlankScreen();=0A=
Refresh();=0A=
=0A=
state =3D 0;=0A=
}=0A=
=0A=
void simplePutString (char* msg) {=0A=
=0A=
unsigned int count;=0A=
RECT tempRect;=0A=
=0A=
for (count =3D 0; msg[count] !=3D '\0' ; count++) {=0A=
switch (msg[count]) {=0A=
case '\r' :=0A=
screen->xPos =3D 0;=0A=
break;=0A=
case '\n' :=0A=
screen->xPos =3D 0;=0A=
screen->yPos++;=0A=
if (screen->yPos =3D=3D YSIZE) {=0A=
screen->yPos =3D 0;=0A=
}=0A=
if (screen->yPos =3D=3D screen->topLine) {=0A=
ScrollScreen();=0A=
}=0A=
break;=0A=
case '\f' :=0A=
InvalidateRect(hwnd,NULL,TRUE);=0A=
Refresh();=0A=
break;=0A=
case '\010' :=0A=
case '\177' : //BACK SPACE or DELETE=0A=
if (screen->xPos > 0) {=0A=
screen->xPos--;=0A=
screen->TextStorage[screen->xPos][screen->yPos] =3D ' ';=0A=
//BlankScreen();=0A=
tempRect.left =3D screen->xPos * MAXXFONTSIZE;=0A=
tempRect.right =3D tempRect.left + MAXXFONTSIZE;=0A=
tempRect.top =3D RealCurrentLine(screen->yPos)*MAXYFONTSIZE;=0A=
tempRect.bottom =3D tempRect.top + MAXYFONTSIZE;=0A=
InvalidateRect(hwnd,&tempRect,TRUE);=0A=
Refresh();=0A=
}=0A=
break;=0A=
default :=0A=
screen->TextStorage[screen->xPos][screen->yPos] =3D msg[count];=0A=
if (msg[count] !=3D ' ') {=0A=
=
ScreenPrint(screen->xPos,RealCurrentLine(screen->yPos),msg[count]);=0A=
}=0A=
tempRect.left =3D screen->xPos * MAXXFONTSIZE;=0A=
tempRect.right =3D tempRect.left + MAXXFONTSIZE;=0A=
tempRect.top =3D RealCurrentLine(screen->yPos)*MAXYFONTSIZE;=0A=
tempRect.bottom =3D tempRect.top + MAXYFONTSIZE;=0A=
InvalidateRect(hwnd,&tempRect,TRUE);=0A=
=0A=
screen->xPos++;=0A=
if (screen->xPos =3D=3D XSIZE) {=0A=
screen->xPos =3D 0;=0A=
screen->yPos++;=0A=
if (screen->yPos =3D=3D YSIZE) {=0A=
screen->yPos =3D 0;=0A=
}=0A=
if (screen->yPos =3D=3D screen->topLine) {=0A=
ScrollScreen();=0A=
}=0A=
}=0A=
} =0A=
} =0A=
Refresh();=0A=
}=0A=
=0A=
void MainStubThread (PVOID pvoid) {=0A=
MyMain();=0A=
MessageBox (hwnd, "Program Finished", "SimpleWindow Message", =
MB_ICONEXCLAMATION | MB_OK);=0A=
#ifdef THREADS=0A=
_endthread();=0A=
#endif=0A=
}=0A=
=0A=
void initKeyboard() {=0A=
keyPressed =3D CreateEvent(NULL,FALSE,FALSE,NULL);=0A=
}=0A=
=0A=
char getCHAR () {=0A=
=0A=
char temp;=0A=
=0A=
WaitForSingleObject(keyPressed,INFINITE);=0A=
putCHAR(KeyThatWasHit);=0A=
temp =3D KeyThatWasHit;=0A=
KeyThatWasHit =3D '\0';=0A=
=0A=
return temp;=0A=
=0A=
}=0A=
=0A=
char scanCHAR () {=0A=
=0A=
char temp;=0A=
=0A=
WaitForSingleObject(keyPressed,INFINITE);=0A=
temp =3D KeyThatWasHit;=0A=
KeyThatWasHit =3D '\0';=0A=
=0A=
return temp;=0A=
=0A=
}=0A=
=0A=
char nBScanCHAR() {=0A=
=0A=
char temp =3D KeyThatWasHit;=0A=
=0A=
KeyThatWasHit =3D '\0';=0A=
return temp;=0A=
=0A=
}=0A=
=0A=
int getSTR (char* buf) {=0A=
=0A=
int size;=0A=
char temp;=0A=
=0A=
=0A=
for(size =3D 0 ; ; size++) {=0A=
WaitForSingleObject(keyPressed,INFINITE);=0A=
temp =3D KeyThatWasHit;=0A=
KeyThatWasHit =3D '\0';=0A=
switch(temp) {=0A=
=0A=
case '\r' : =0A=
case '\n' :=0A=
putCHAR('\n');=0A=
buf[size] =3D '\0';=0A=
return size;=0A=
=0A=
case '\010' :=0A=
case '\177' :=0A=
if (size > 0) {=0A=
buf[size-1] =3D '\0';=0A=
putCHAR(temp);=0A=
size -=3D2;=0A=
continue;=0A=
} else {=0A=
size =3D -1;=0A=
continue;=0A=
}=0A=
default :=0A=
if (size =3D=3D 1023)=0A=
return 1023;=0A=
buf[size] =3D temp;=0A=
buf[size+1] =3D '\0';=0A=
putCHAR(temp);=0A=
}=0A=
=0A=
}=0A=
=0A=
}=0A=
=0A=
int getINT () {=0A=
=0A=
int temp =3D 0;=0A=
char buf[100];=0A=
=0A=
getSTR (buf);=0A=
sscanf(buf,"%d",&temp);=0A=
return temp;=0A=
=0A=
}=0A=
=0A=
unsigned int getUINT () {=0A=
=0A=
unsigned int temp =3D 0;=0A=
char buf[100];=0A=
=0A=
getSTR (buf);=0A=
sscanf(buf,"%u",&temp);=0A=
return temp;=0A=
=0A=
}=0A=
=0A=
float getFLOAT () {=0A=
=0A=
float temp =3D 0;=0A=
char buf[100];=0A=
=0A=
getSTR (buf);=0A=
sscanf(buf,"%f",&temp);=0A=
return temp;=0A=
=0A=
}=0A=
=0A=
=0A=
unsigned int SysTime() {=0A=
return Ticks;=0A=
}=0A=
=0A=
void Wait (unsigned int userTicks) {=0A=
=0A=
unsigned int wakeUp;=0A=
=0A=
wakeUp =3D userTicks + SysTime();=0A=
for (;SysTime() < wakeUp;) {=0A=
WaitingOnTimer =3D TRUE;=0A=
WaitForSingleObject(TimerExpiry,INFINITE);=0A=
}=0A=
WaitingOnTimer =3D FALSE;=0A=
=0A=
}=0A=
------=_NextPart_000_01BE132C.0ACF5040
Content-Type: application/octet-stream; name="DHSWIN.C"
Content-Description: Dhswin (C File)
Content-Disposition: attachment; filename="DHSWIN.C"
Content-Transfer-Encoding: quoted-printable
// Test for Mr. Sourtzis
#include "graphics.h"
#include "dhs.h"
extern GraphicDrawQueue GraphicScreen;
extern HPEN pen;
extern int nopen;
char Tbuffer[2048];
extern void MyMain();
Colour BACKGROUND =3D RGB(255,255,255);
typedef struct {
unsigned int xPos;
unsigned int yPos;
char TextStorage[XSIZE][YSIZE];
unsigned int topLine;
} ScreenStateInfo;
ScreenStateInfo* screen;
char buffer[BUFSIZE]; =20
int len;
int textAveWidth;
HDC hdc;
HWND hwnd;=09
PAINTSTRUCT ps;
RECT rect,updateRect;
HANDLE keyPressed;
char KeyThatWasHit;
HANDLE TimerExpiry;
unsigned char WaitingOnTimer =3D FALSE;
static unsigned int Ticks =3D 0;
void MainStubThread (PVOID pvoid);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,=20
PSTR szCmdLine, int iCmdShow) {
static char szAppName[] =3D "HelloWin";
MSG msg;
WNDCLASSEX wndClass;
=09
wndClass.cbSize =3D sizeof (wndClass);
wndClass.style =3D CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndClass.lpfnWndProc =3D WndProc;
wndClass.cbClsExtra =3D 0;
wndClass.cbWndExtra =3D 0;
wndClass.hInstance =3D hInstance;
wndClass.hIcon =3D LoadIcon (NULL, IDI_APPLICATION);
wndClass.hCursor =3D LoadCursor (NULL, IDC_ARROW);
wndClass.hbrBackground =3D (HBRUSH) GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName =3D NULL;
wndClass.lpszClassName =3D szAppName;
wndClass.hIconSm =3D LoadIcon (NULL, IDI_APPLICATION);
RegisterClassEx (&wndClass);
hwnd =3D CreateWindow (szAppName,
"SimpleWindow =
=
DHS Computer Science",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
(MAXXFONTSIZE*(XSIZE+1)) + 15,
(MAXYFONTSIZE*(YSIZE+1)) + 15,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd); =20
if (screen =3D=3D NULLP) {
initScreen();
}
while (GetMessage (&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
} // FNCTION
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam,
LPARAM lParam) {
PAINTSTRUCT ps;
RECT rect;
TEXTMETRIC tm;
switch (iMsg) {
case WM_CREATE :
hdc =3D GetDC (hwnd);
GetTextMetrics (hdc,&tm);
textAveWidth =3D tm.tmAveCharWidth;
ReleaseDC(hwnd, hdc);
initKeyboard();
SetTimer (hwnd, 99, TIMER_GRANULARITY, NULL);
TimerExpiry =3D CreateEvent(NULL,FALSE,FALSE,NULL);
if (screen =3D=3D NULLP) {
initScreen();
}
GraphicScreen.Draw();
Refresh();
#ifdef THREADS
_beginthread(MainStubThread,0,NULLP);
#else
MainStubThread(0);
#endif
return 0;
case WM_PAINT :
GetUpdateRect (hwnd, &updateRect, TRUE);
=09
hdc =3D BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
if (screen =3D=3D NULLP) {
initScreen();
}
Refresh();
EndPaint (hwnd, &ps);
return 0;
case WM_CHAR :
KeyThatWasHit =3D wParam;
SetEvent(keyPressed);
return 0;
case WM_TIMER :=20
if (WaitingOnTimer) {
SetEvent(TimerExpiry);
}
Ticks++;
return 0;
case WM_DESTROY :
KillTimer (hwnd,99);
free(screen);
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam);
}
void putSTR (char* str) {
simplePutString(str);
}
void putINT (int num) {
sprintf(buffer,"%d",num);
simplePutString(buffer);
}
void putUINT (unsigned int num) {
sprintf(buffer,"%u",num);
simplePutString(buffer);
}
void putCHAR (char chr) {
sprintf(buffer,"%c",chr);
simplePutString(buffer);
}
void putFLOAT (float num) {
sprintf(buffer,"%f",num);
simplePutString(buffer);
}
void BlankScreen () {
InvalidateRect (hwnd, NULL, TRUE);
}
void ClearScreen () {
int x, y;
for (x=3D0 ; x < XSIZE ; x++) {
for (y=3D0 ; y < YSIZE ; y++) {
screen->TextStorage[x][y] =3D ' ';
}
}
screen->xPos =3D 0;
screen->yPos =3D 0;
screen->topLine =3D 0;
=09
BlankScreen();
Refresh();
}
int gotoxy (unsigned int x, unsigned int y) {
if (x < XSIZE) {
if (y < YSIZE) {
screen->yPos =3D (y + screen->topLine) % YSIZE;
screen->xPos =3D x;
return OK;
} else {
sprintf(buffer,"Illegal Y param for gotoxy: %d",y);
MESSAGE (buffer);
return ERRORS;
}
} else {
sprintf(buffer,"Illegal X param for gotoxy: %d",x);
MESSAGE (buffer);
return ERRORS;
}
}
int initScreen () {
unsigned int counter;
char* temp;
// SetBkColor(hdc, RGB(0,0,0));
SelectObject(hdc,GetStockObject(NULL_BRUSH));
pen =3D CreatePen(PS_SOLID, 1, 0);
SelectObject(hdc,pen);
=09
nopen =3D FALSE;
UpdateWindow(hwnd);
=09
screen =3D (ScreenStateInfo *)malloc(sizeof(ScreenStateInfo));
if (screen =3D=3D NULLP) {
MESSAGE("Could not start terminal screen\n");
return ERRORS;
}
for (counter=3D0, temp =3D (char *)screen;
counter < sizeof(ScreenStateInfo);
counter++, temp++) {
*temp =3D ' ';
}
screen->xPos =3D 0;
screen->yPos =3D 0;
screen->topLine =3D 0;
gotoxy(0,0);
simplePutString("SimpleWindow Developed by: Joel Orvis 1997\n");
simplePutString("Console Started...\n\n");
=20
return OK;
}
unsigned int RealCurrentLine(unsigned int line) {
return (YSIZE+(line-screen->topLine))%YSIZE;
}
void Refresh() {
LONG line;
LONG count;
GraphicScreen.Draw();
for (line =3D MIN((updateRect.top/MAXYFONTSIZE)-1,YSIZE) ;=20
line < MIN((updateRect.bottom/MAXYFONTSIZE)+1,YSIZE) ; line++) {
for (count =3D MIN((updateRect.left/MAXXFONTSIZE)-1,XSIZE) ;=20
count < MIN((updateRect.right/MAXXFONTSIZE)+1,XSIZE) ; count++) {
if ((count >=3D0) && (line >=3D0) && =
(screen->TextStorage[count][line] !=3D ' '))
=
ScreenPrint(count,RealCurrentLine(line),screen->TextStorage[count][line])=
;
}
}
ValidateRect(hwnd,NULL);
}
unsigned int xPos (unsigned int x) {
return MAXXFONTSIZE*x;
}
unsigned int yPos (unsigned int y) {
return MAXYFONTSIZE*y;
} =20
void ScreenPrint(unsigned int x, unsigned int y, char ch) {
TextOut (hdc, xPos(x), yPos(y), &ch, 1);
};
int state =3D 0;
void ScrollScreen() {
unsigned int count;
// RECT tempRect;
if (state =3D=3D 1) {
return;
}
state =3D 1;
ScrollWindow(hwnd, 0, -1*MAXYFONTSIZE, NULL, NULL);
// ValidateRect(hwnd,NULL);=09
// tempRect.left =3D 0;
// tempRect.right =3D MAXXFONTSIZE*XSIZE;
// tempRect.top =3D (YSIZE-4)*MAXYFONTSIZE;
// tempRect.bottom =3D tempRect.top + 2*MAXYFONTSIZE;
// InvalidateRect(hwnd,&tempRect,TRUE);
for (count =3D 0 ; count < XSIZE ; count++) {
screen->TextStorage[count][screen->topLine] =3D ' ';
}
screen->topLine++;
if (screen->topLine =3D=3D YSIZE) {
screen->topLine =3D 0;
}
BlankScreen();
Refresh();
state =3D 0;
}
void simplePutString (char* msg) {
unsigned int count;
RECT tempRect;
for (count =3D 0; msg[count] !=3D '\0' ; count++) {
switch (msg[count]) {
case '\r' :
screen->xPos =3D 0;
break;
case '\n' :
screen->xPos =3D 0;
screen->yPos++;
if (screen->yPos =3D=3D YSIZE) {
screen->yPos =3D 0;
}
if (screen->yPos =3D=3D screen->topLine) {
ScrollScreen();
}
break;
case '\f' :
InvalidateRect(hwnd,NULL,TRUE);
Refresh();
break;
case '\010' :
case '\177' : //BACK SPACE or DELETE
if (screen->xPos > 0) {
screen->xPos--;
screen->TextStorage[screen->xPos][screen->yPos] =3D ' ';
//BlankScreen();
tempRect.left =3D screen->xPos * MAXXFONTSIZE;
tempRect.right =3D tempRect.left + MAXXFONTSIZE;
tempRect.top =3D RealCurrentLine(screen->yPos)*MAXYFONTSIZE;
tempRect.bottom =3D tempRect.top + MAXYFONTSIZE;
InvalidateRect(hwnd,&tempRect,TRUE);
Refresh();
}
break;
default :
screen->TextStorage[screen->xPos][screen->yPos] =3D msg[count];
if (msg[count] !=3D ' ') {
ScreenPrint(screen->xPos,RealCurrentLine(screen->yPos),msg[count]);
}
tempRect.left =3D screen->xPos * MAXXFONTSIZE;
tempRect.right =3D tempRect.left + MAXXFONTSIZE;
tempRect.top =3D RealCurrentLine(screen->yPos)*MAXYFONTSIZE;
tempRect.bottom =3D tempRect.top + MAXYFONTSIZE;
InvalidateRect(hwnd,&tempRect,TRUE);
screen->xPos++;
if (screen->xPos =3D=3D XSIZE) {
screen->xPos =3D 0;
screen->yPos++;
if (screen->yPos =3D=3D YSIZE) {
screen->yPos =3D 0;
}
if (screen->yPos =3D=3D screen->topLine) {
ScrollScreen();
}
}
} =09
} =09
Refresh();
}
void MainStubThread (PVOID pvoid) {
MyMain();
MessageBox (hwnd, "Program Finished", "SimpleWindow Message", =
MB_ICONEXCLAMATION | MB_OK);
#ifdef THREADS
_endthread();
#endif
}
void initKeyboard() {
keyPressed =3D CreateEvent(NULL,FALSE,FALSE,NULL);
}
char getCHAR () {
char temp;
WaitForSingleObject(keyPressed,INFINITE);
putCHAR(KeyThatWasHit);
temp =3D KeyThatWasHit;
KeyThatWasHit =3D '\0';
return temp;
}
char scanCHAR () {
char temp;
WaitForSingleObject(keyPressed,INFINITE);
temp =3D KeyThatWasHit;
KeyThatWasHit =3D '\0';
return temp;
}
char nBScanCHAR() {
char temp =3D KeyThatWasHit;
KeyThatWasHit =3D '\0';
return temp;
}
int getSTR (char* buf) {
=09
int size;
char temp;
for(size =3D 0 ; ; size++) {
WaitForSingleObject(keyPressed,INFINITE);
temp =3D KeyThatWasHit;
KeyThatWasHit =3D '\0';
switch(temp) {
case '\r' :=20
case '\n' :
putCHAR('\n');
buf[size] =3D '\0';
return size;
=09
case '\010' :
case '\177' :
if (size > 0) {
buf[size-1] =3D '\0';
putCHAR(temp);
size -=3D2;
continue;
} else {
size =3D -1;
continue;
}
default :
if (size =3D=3D 1023)
return 1023;
buf[size] =3D temp;
buf[size+1] =3D '\0';
putCHAR(temp);
}
=09
}
}
int getINT () {
int temp =3D 0;
char buf[100];
getSTR (buf);
sscanf(buf,"%d",&temp);
return temp;
}
unsigned int getUINT () {
unsigned int temp =3D 0;
char buf[100];
getSTR (buf);
sscanf(buf,"%u",&temp);
return temp;
}
float getFLOAT () {
float temp =3D 0;
char buf[100];
getSTR (buf);
sscanf(buf,"%f",&temp);
return temp;
}
unsigned int SysTime() {
return Ticks;
}
void Wait (unsigned int userTicks) {
unsigned int wakeUp;
wakeUp =3D userTicks + SysTime();
for (;SysTime() < wakeUp;) {
WaitingOnTimer =3D TRUE;
WaitForSingleObject(TimerExpiry,INFINITE);
}
WaitingOnTimer =3D FALSE;
}
------=_NextPart_000_01BE132C.0ACF5040
Content-Type: application/octet-stream; name="DHS.H"
Content-Description: Dhs (H File)
Content-Disposition: attachment; filename="DHS.H"
Content-Transfer-Encoding: quoted-printable
#include <windows.h>=0A=
#include <process.h>=0A=
#include <stdlib.h>=0A=
#include <stdio.h>=0A=
#include "userdefs.h"=0A=
=0A=
#define MESSAGE(x) len =3D sprintf(Tbuffer, "On line %d in file =
%s-->\n\"%s\"", __LINE__, __FILE__, x); \=0A=
MessageBox (hwnd, Tbuffer, "SimpleConsole Message", =
MB_ICONEXCLAMATION | MB_OK);=0A=
#define MIN(x,y) (((x) < (y)) ? (x) : (y))=0A=
#define MAX(x,y) (((x) < (y)) ? (y) : (x))=0A=
=0A=
void putSTR (char* str);=0A=
void putINT (int num);=0A=
void putUINT (unsigned int num);=0A=
void putCHAR (char chr);=0A=
void putFLOAT (float num);=0A=
int gotoxy (unsigned int x, unsigned int y);=0A=
void Refresh ();=0A=
void ClearScreen ();=0A=
=0A=
char getCHAR ();=0A=
int getSTR (char* buf);=0A=
int getINT ();=0A=
unsigned int getUINT ();=0A=
float getFLOAT ();=0A=
=0A=
char scanCHAR ();=0A=
char nBScanCHAR ();=0A=
=0A=
unsigned int SysTime ();=0A=
void Wait (unsigned int userTicks);=0A=
=0A=
=0A=
/* System Functions, do not edit or call directly! */=0A=
=0A=
#define BUFSIZE 2048=0A=
#define THREADS=0A=
#define ERRORS 0xff=0A=
#define OK 1=0A=
#define TRUE 1=0A=
#define FALSE 0=0A=
#define NULLP 0=0A=
=0A=
#define MAXXFONTSIZE 14=0A=
#define MAXYFONTSIZE 20=0A=
=0A=
void simplePutString (char* msg);=0A=
int initScreen ();=0A=
void initKeyboard ();=0A=
void ScreenPrint (unsigned int x, unsigned int y, char ch);=0A=
------=_NextPart_000_01BE132C.0ACF5040
Content-Type: application/octet-stream; name="GRAPHICS.CPP"
Content-Description: Graphics.cpp (CPP File)
Content-Disposition: attachment; filename="GRAPHICS.CPP"
Content-Transfer-Encoding: 7bit
#include "dhs.h"
#include "graphics.h"
#define NULL 0
#define TRUE 1
#define FALSE 0
extern int len;
extern char* Tbuffer;
extern HWND hwnd;
extern HDC hdc;
extern Colour BACKGROUND;
extern void Refresh();
HPEN pen;
int nopen = TRUE;
Colour penColour = 0;
int penThickness = 1;
int assign = 1;
GraphicDrawQueue GraphicScreen;
void GraphicObject::Draw(){
}
void GraphicObject::Erase() {
}
void GraphicObject::ColourMe(int RGB) {
myColour = RGB;
switch (objectType) {
case LINE :
((Line *)(this))->Draw();
break;
case CIRCLE :
((Circle *)(this))->Draw();
break;
case RECTANGLE :
((Rectangl *)(this))->Draw();
break;
case ELLIPSE :
((Ellips *)(this))->Draw();
break;
default :
MESSAGE("Unkown graphic object in ColourMe");
}
}
int GraphicObject::WhoIsThis() {
return identifier;
}
GraphicDrawQueue::GraphicDrawQueue() {
list = NULL;
}
GraphicDrawQueue::~GraphicDrawQueue() {
GraphicObject* temp=list;
for(;temp != NULL;temp = temp->next) {
temp->Erase();
delete temp;
}
}
int GraphicDrawQueue::Add(GraphicObject* Graphic) {
GraphicObject* temp=list;
GraphicObject* prev=list;
int counter=0;
if (list == NULL) {
list = Graphic;
Graphic->next = NULL;
return TRUE;
}
for(;temp != NULL;prev = temp, temp = temp->next, counter++);
prev->next = Graphic;
Graphic->next = NULL;
return TRUE;
}
int GraphicDrawQueue::Remove(int identifier) {
GraphicObject* temp=list;
GraphicObject* prev=list;
if (list == NULL) {
return FALSE;
}
if (list->identifier != identifier) {
for(;((temp != NULL) && (temp->identifier != identifier));
prev = temp, temp = temp->next);
} else {
ChangeColour(identifier, RGB(255,255,255));
list = temp->next;
goto DELOBJ;
}
if (temp != NULL) {
ChangeColour(temp->identifier, RGB(255,255,255));
prev->next = temp->next;
DELOBJ: switch (temp->objectType) {
case LINE :
delete ((Line *)(temp));
break;
case CIRCLE :
delete ((Circle *)(temp));
break;
case RECTANGLE :
delete ((Rectangl *)(temp));
break;
case ELLIPSE :
delete ((Ellips *)(temp));
break;
default :
MESSAGE("Unkown graphic object in Remove");
}
delete temp;
} else {
return FALSE;
}
return TRUE;
}
void GraphicDrawQueue::Draw () {
GraphicObject* temp=list;
for(;(temp != NULL);temp = temp->next) {
switch (temp->objectType) {
case LINE :
((Line *)(temp))->Draw();
break;
case CIRCLE :
((Circle *)(temp))->Draw();
break;
case RECTANGLE :
((Rectangl *)(temp))->Draw();
break;
case ELLIPSE :
((Ellips *)(temp))->Draw();
break;
default :
MESSAGE("Unkown graphic object in Draw");
}
}
}
void GraphicDrawQueue::Erase () {
GraphicObject *temp=list;
for(;(temp != NULL);temp = temp->next) {
temp->Erase();
}
}
int GraphicDrawQueue::ColourThem (int identifier, Colour RGB ){
GraphicObject* temp=list;
if (list == NULL) {
return FALSE;
}
for(;((temp != NULL) && (temp->WhoIsThis() != identifier));
temp = temp->next);
if (temp != NULL) {
temp->ColourMe(RGB);
} else {
return FALSE;
}
return TRUE;
}
Circle::Circle (int radiusU, int centreXU, int centreYU) {
radius = radiusU;
centreX = centreXU;
centreY = centreYU;
myColour = penColour;
myThickness = penThickness;
if (! GraphicScreen.Add(this)) {
MESSAGE ("DRAWFAILED!");
}
identifier = assign++;
objectType = CIRCLE;
}
Circle::~Circle () {
// GraphicScreen.Remove(identifier);
}
void Circle::Draw() {
Colour tempColour;
int tempThickness;
tempColour = penColour;
tempThickness = penThickness;
PenColour(myColour);
PenThickness(myThickness);
Ellipse (hdc, centreX-radius, centreY-radius,
centreX+radius, centreY+radius);
PenColour(tempColour);
PenThickness(tempThickness);
}
Line::Line (int X1, int Y1, int X2, int Y2) {
x1 = X1;
y1 = Y1;
x2 = X2;
y2 = Y2;
myColour = penColour;
myThickness = penThickness;
if (! GraphicScreen.Add(this)) {
MESSAGE ("DRAWFAILED!");
}
identifier = assign++;
objectType = LINE;
}
Line::~Line () {
// GraphicScreen.Remove(identifier);
}
void Line::Draw() {
Colour tempColour;
int tempThickness;
tempColour = penColour;
tempThickness = penThickness;
PenColour(myColour);
PenThickness(myThickness);
MoveToEx(hdc, x1, y1, NULL);
LineTo(hdc, x2, y2);
PenColour(tempColour);
PenThickness(tempThickness);
}
Rectangl::Rectangl (int X1, int Y1, int X2, int Y2) {
topX = X1;
topY = Y1;
bottomX = X2;
bottomY = Y2;
myColour = penColour;
myThickness = penThickness;
if (! GraphicScreen.Add(this)) {
MESSAGE ("DRAWFAILED!");
}
identifier = assign++;
objectType = RECTANGLE;
}
Rectangl::~Rectangl () {
// GraphicScreen.Remove(identifier);
}
void Rectangl::Draw() {
Colour tempColour;
int tempThickness;
tempColour = penColour;
tempThickness = penThickness;
PenColour(myColour);
PenThickness(myThickness);
Rectangle(hdc, topX, topY, bottomX, bottomY);
PenColour(tempColour);
PenThickness(tempThickness);
}
Ellips::Ellips (int rx, int ry, int cx, int cy) {
radiusX = rx;
radiusY = ry;
centreX = cx;
centreY = cy;
myColour = penColour;
myThickness = penThickness;
if (! GraphicScreen.Add(this)) {
MESSAGE ("DRAWFAILED!");
}
identifier = assign++;
objectType = ELLIPSE;
}
Ellips::~Ellips () {
// GraphicScreen.Remove(identifier);
}
void Ellips::Draw() {
Colour tempColour;
int tempThickness;
tempColour = penColour;
tempThickness = penThickness;
PenColour(myColour);
PenThickness(myThickness);
Ellipse(hdc, centreX-radiusX, centreY-radiusY, centreX+radiusX, centreY+radiusY);
PenThickness(tempThickness);
PenColour(tempColour);
}
int DrawCircle(int radius, int x, int y) {
Circle* circle;
circle = new Circle(radius,x,y);
if (circle)
circle->Draw();
return (circle) ? (circle->WhoIsThis()):(0);
}
int DrawLine(int x1, int y1, int x2, int y2) {
Line* line;
line = new Line(x1,y1,x2,y2);
if (line)
line->Draw();
return (line) ? (line->WhoIsThis()):(0);
}
int DrawEllipse(int rx, int ry, int x, int y) {
Ellips* ellipse;
ellipse = new Ellips(rx, ry, x, y);
if (ellipse)
ellipse->Draw();
return (ellipse) ? (ellipse->WhoIsThis()):(0);
}
int DrawRectangle(int topx, int topy, int botx, int boty) {
Rectangl *rectangle;
rectangle = new Rectangl(topx, topy, botx, boty);
if (rectangle)
rectangle->Draw();
return (rectangle) ? (rectangle->WhoIsThis()):(0);
}
void BackGroundColour (Colour colour) {
SetBkColor(hdc, colour);
}
void PenColour (Colour colour) {
HPEN tempPen = pen;
pen = CreatePen(PS_SOLID,penThickness,colour);
SelectObject(hdc,pen);
if (! nopen) {
DeleteObject(tempPen);
nopen=TRUE;
}
penColour = colour;
nopen = FALSE;
}
void PenThickness (int thickness) {
HPEN tempPen = pen;
pen = CreatePen(PS_SOLID,thickness,penColour);
SelectObject(hdc,pen);
if (! nopen) {
DeleteObject(tempPen);
nopen=TRUE;
}
penThickness = thickness;
nopen = FALSE;
}
int ChangeColour(int identifier, Colour colour) {
return GraphicScreen.ColourThem(identifier, colour);
}
int DeleteGraphic(int identifier) {
return GraphicScreen.Remove(identifier);
}
------=_NextPart_000_01BE132C.0ACF5040
Content-Type: application/octet-stream; name="GRAPHICS.H"
Content-Description: Graphics (H File)
Content-Disposition: attachment; filename="GRAPHICS.H"
Content-Transfer-Encoding: 7bit
#ifndef __GRAPHICS__
#define __GRAPHICS__
#define LINE 1
#define CIRCLE 2
#define RECTANGLE 3
#define ELLIPSE 4
typedef unsigned long int Colour;
class GraphicObject {
friend class GraphicDrawQueue;
friend class Circle;
friend class Line;
friend class Rectangl;
friend class Ellips;
public:
void Draw ();
void Erase ();
void ColourMe(int RGB);
int WhoIsThis();
private:
GraphicObject *next;
int myColour;
int myThickness;
int identifier;
int objectType;
};
class Line : public GraphicObject {
public:
Line (int X1, int Y1, int X2, int Y2);
~Line();
void Draw ();
private:
int x1;
int y1;
int x2;
int y2;
};
class Circle : public GraphicObject {
public:
Circle (int radiusU, int centreXU, int centreYU);
~Circle ();
void Draw ();
private:
int radius;
int centreX;
int centreY;
};
class Rectangl : public GraphicObject {
public:
Rectangl (int X1, int Y1, int X2, int Y2);
~Rectangl();
void Draw ();
private:
int topX;
int topY;
int bottomX;
int bottomY;
};
class Ellips : public GraphicObject {
public:
Ellips (int rx, int ry, int cx, int cy);
~Ellips();
void Draw ();
private:
int radiusX;
int radiusY;
int centreX;
int centreY;
};
class GraphicDrawQueue {
public:
GraphicDrawQueue();
~GraphicDrawQueue();
void Draw ();
void Erase ();
int ColourThem (int identifier, Colour RGB);
int Add (GraphicObject* Graphic);
int Remove (int identifier);
private:
GraphicObject *list;
};
int DrawCircle(int radius, int x, int y);
int DrawLine(int x1, int y1, int x2, int y2);
int DrawEllipse(int rx, int ry, int x, int y);
int DrawRectangle(int topx, int topy, int botx, int boty);
void BackGroundColour (Colour colour);
void PenColour (Colour colour);
void PenThickness (int thickness);
int ChangeColour(int identifier, Colour colour);
int DeleteGraphic(int identifier);
#endif
------=_NextPart_000_01BE132C.0ACF5040
Content-Type: application/octet-stream; name="USERDEFS.H"
Content-Description: Userdefs (H File)
Content-Disposition: attachment; filename="USERDEFS.H"
Content-Transfer-Encoding: 7bit
// User definable values
#define TIMER_GRANULARITY 50 // clock period default 1/20 second
#define XSIZE 50 // number of columns default 50
#define YSIZE 20 // number of rows default 20
------=_NextPart_000_01BE132C.0ACF5040--
- Raw text -