Files
TeslaRel410/BORLAND/BC45/EXAMPLES/OWL/OWLAPPS/MTHREAD/MTHREAD.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

157 lines
4.0 KiB
C++

//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
// A Multi-thread GDI demo program
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\mdi.h>
#include <string.h>
#include "demobase.h"
#include "line.h"
#include "arty.h"
// Menu bar constants
const int MenuId = 100; // Resource Id of the menubar
const int MoveToLineToDemoId= 201; // Demo->MoveToDemo Id
const int ArtyDemoId = 202; // Demo->Arty Demo Id
const int IconId = 100; // Resource Id of the program icon
//----------------------------------------------------------------------------
int
TOWLThread::Synch()
{
HANDLE Signals[2] = { HANDLE(*GetApplication()->GetMutex()), Done };
return ::WaitForMultipleObjects( 2, Signals, FALSE, -1 );
}
HANDLE
TBaseDemoWindow::Start()
{
HANDLE Result = TThread::Start();
SetPriority( THREAD_PRIORITY_LOWEST );
return Result;
}
unsigned long
TBaseDemoWindow::Run()
{
for(;;)
{
::Sleep(20);
if( Synch() != 0 )
return 0;
else
{
// This is a little tricky. On return from
// Synch() this thread owns a lock on the
// OWL synchronization object. In order to
// be exception-safe we must have an object
// whose destructor will release the lock.
// So we create one, which gives us two nested
// locks on the synchroniztion object. Then
// we release one of the locks. The destructor
// for the TAppLock object releases the other
// one at the end of this block.
TApplication::TAppLock l(*GetApplication());
l.Release();
// Call into the derived class for the actual processing
DoRun();
}
}
}
TApplication *
TBaseDemoWindow::GetApplication() const
{
return TWindow::GetApplication();
}
BOOL
TBaseDemoWindow::CanClose()
{
if( TerminateAndWait( 1000 ) == 0 )
return TRUE;
else
{
MessageBox( "Timeout while terminating thread", "gdidemo.exe" );
return FALSE;
}
}
IMPLEMENT_CASTABLE1(TBaseDemoWindow, TWindow);
//----------------------------------------------------------------------------
class TGdiDemoWindow : public TMDIClient {
public:
TGdiDemoWindow() : TMDIClient() { Attr.Style |= WS_TABSTOP; }
protected:
void CmMoveToLineToDemo();
void CmArtyDemo();
DECLARE_RESPONSE_TABLE(TGdiDemoWindow);
};
DEFINE_RESPONSE_TABLE1(TGdiDemoWindow, TMDIClient)
EV_COMMAND(MoveToLineToDemoId, CmMoveToLineToDemo),
EV_COMMAND(ArtyDemoId, CmArtyDemo),
END_RESPONSE_TABLE;
//
// In response to a demo command, create one of the demo windows as the client
// of an mdi child frame. Turn of the icon for the mdi child to allow the
// client to paint itself when iconic.
//
void
TGdiDemoWindow::CmMoveToLineToDemo()
{
TMDIChild* child = new TMDIChild(*this, "MoveTo/LineTo Window",
new TMoveToLineToWindow);
child->SetIcon(0, 0);
child->Create();
}
void
TGdiDemoWindow::CmArtyDemo()
{
TMDIChild* child = new TMDIChild(*this, "Arty Window", new TArtyWindow);
child->SetIcon(0, 0);
child->Create();
}
//----------------------------------------------------------------------------
class TGdiDemoApp : public TApplication {
public:
TGdiDemoApp() : TApplication() {}
void InitMainWindow();
};
void
TGdiDemoApp::InitMainWindow()
{
MainWindow = new TMDIFrame("Multi-Thread Demo", MenuId, *new TGdiDemoWindow);
MainWindow->SetIcon(this, IconId);
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
#if defined(__WIN32__)
if ((::GetVersion()&0x80000000) && (::GetVersion()&0xFF) < 4) {
::MessageBox(0, "This Example requires a multithreaded version of Windows",
"OWL Examples", MB_OK);
return 0;
}
#endif
return TGdiDemoApp().Run();
}