Files
TeslaRel410/BORLAND/BC45/EXAMPLES/OWL/TUTORIAL/CNTRL16.CPP
T
CydandClaude Fable 5 63312e07f9 source410: literal 4.10 source reconstruction + BC++ 4.52 fleet toolchain archived
- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
  is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
  Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
  (extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
  BT game source (never mixed into CODE/). Round 1-3 state:
  * 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
    (BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
    since 1996.
  * BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
    its binary-recorded line 400 exactly.
  * BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
    (Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
    TeamScore=12 flagged [T4]).
  * MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
    (VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
    the period compiler is the drift detector).
  * Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
    (per-TU verification sweep under authentic OPT.MAK flags).
  * README: corrected roadmap - MECH.HPP is the capstone grown with the mech
    TU reconstructions; BTREG.CPP green = the header-family milestone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 07:33:26 -05:00

171 lines
4.0 KiB
C++

//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1994 by Borland International
// Tutorial application -- cntrl16.cpp
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\edit.h>
#include <strstrea.h>
#include <ocf/automacr.h>
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include "step16.cxx"
class TMyApp : public TApplication
{
public:
TMyApp(): TApplication("Cntrl16") {}
void InitMainWindow();
void InitInstance();
void Output(ostrstream &ostr);
bool DispServer; //True if automation server should be displayed when run
private:
void TestAutomation(); //Routine to execute step16
TEdit *Disp; //Client window
};
void
TMyApp::InitMainWindow()
{
Disp=new TEdit(0,0,"",0,0,0,0,0,true);
SetMainWindow(new TFrameWindow(0,"Step 16 Controller",Disp));
}
//
// Outputs ostrstream buf to client window
//
void
TMyApp::Output(ostrstream &ostr)
{
char *str = ostr.str(); //Get stream buffer as char*
ostr.seekp(0); //Reset stream
Disp->Insert(str);
Disp->Insert("\r\n");
}
void
TMyApp::InitInstance()
{
TApplication::InitInstance();
// Our windows are now created and we can output the test results
TestAutomation();
}
long Colors[] = {
RGB(0x00, 0x00, 0x00),
RGB(0xFF, 0x00, 0x00),
RGB(0x00, 0xFF, 0x00),
RGB(0x00, 0x00, 0xFF),
RGB(0xFF, 0xFF, 0x00),
RGB(0x00, 0xFF, 0xFF),
RGB(0xFF, 0x00, 0xFF)
};
const int NumColors = sizeof(Colors)/sizeof(Colors[0]);
//
// Excercises the server using the classes generated by AUTOGEN.EXE
//
void
TMyApp::TestAutomation()
{
char buf[256];
ostrstream ostr(buf, sizeof buf);
try {
TOleAllocator allocator(0); // OLE requirement
TDrawApp app;
TDrawDoc doc;
app.Bind("DrawPad.Application.16");
ostr << "Application name =" << (const char far*)app.GetName() << ends;
Output(ostr);
ostr << "Application path =" << (const char far*)app.GetFullName() << ends;
Output(ostr);
app.NewDocument(doc);
// if there's one argument on command line, don't display the frame window.
if (DispServer) {
app.SetVisible(true);
}
else {
app.SetVisible(false);
}
ostr << "Current automated pen size: " << doc.GetPenSize() << ends;
Output(ostr);
ostr << "Current automated pen color: " << doc.GetPenColor() << ends;
Output(ostr);
double startX = 150;
double startY = 150;
double radius = 0;
double theta = 0;
int colorIndex = 0;
short penSize = 1; //Server expects a short arg in SetPenSize
double x = 0;
double y = 0;
ostr << "Drawing in automated app ..."<<ends;
Output(ostr);
doc.AddPoint(startX, startY);
for (int i=0; radius < 70; i++) {
if (i % 10 == 0) {
// use the next pen
doc.AddLine();
doc.AddPoint(startX+x, startY-y);
doc.SetPenColor(Colors[colorIndex++]);
doc.SetPenSize(penSize++);
colorIndex %= NumColors;
}
radius += 0.2 * theta;
x = 2 * radius * cos(theta);
y = 2 * radius * sin(theta);
doc.AddPoint(startX+x, startY-y);
theta += 0.2;
}
doc.AddLine();
// End of server automation test
::MessageBox(0, "End of Program", "CNTRL16.EXE", MB_OK);
ostr << "Shutting server down..." << ends;
Output(ostr);
app.Quit();
ostr << "Server shut down, test complete"<<ends;
Output(ostr);
}
catch (TXBase& x) {
ostr << x.why() << ends;
Output(ostr);
}
}
int
OwlMain(int argc, char* /*argv*/ [])
{
TMyApp app;
// Pass a dummy arg on command line to make the server invisible
if (argc == 2)
app.DispServer=false;
else
app.DispServer=true;
return app.Run();
}