Skip to content

Commit

Permalink
Image headers are now loaded in parallel to parsing to correctly gene…
Browse files Browse the repository at this point in the history
…rate layout. Improved error reporting. Reduced memory usage by changing font format. Added hotspots for mouse cursors. Improved EMS detection routine
  • Loading branch information
jhhoward committed Mar 21, 2024
1 parent f8ed938 commit 71c1317
Show file tree
Hide file tree
Showing 60 changed files with 785 additions and 278 deletions.
Binary file modified CGA.dat
Binary file not shown.
Binary file modified Default.dat
Binary file not shown.
Binary file modified EGA.dat
Binary file not shown.
Binary file modified LowRes.dat
Binary file not shown.
Binary file modified assets/CGA/mouse-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/CGA/mouse-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/CGA/mouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/Default/mouse-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/Default/mouse-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/Default/mouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/EGA/mouse-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/EGA/mouse-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/EGA/mouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/LowRes/mouse-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/LowRes/mouse-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/LowRes/mouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion project/DOS/TCP.CFG
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
#undef TCP_MAX_SOCKETS

#define PACKET_BUFFERS (20) // Number of incoming buffers
#define TCP_MAX_SOCKETS (3) // Maximum number of sockets to use
//#define TCP_MAX_SOCKETS (3) // Maximum number of sockets to use
#define TCP_MAX_SOCKETS (2) // Maximum number of sockets to use

#endif
114 changes: 70 additions & 44 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "App.h"
#include "Platform.h"
#include "HTTP.h"
#include "Image/Decoder.h"

App* App::app;

Expand Down Expand Up @@ -46,11 +47,10 @@ void App::ResetPage()
void App::Run(int argc, char* argv[])
{
running = true;
char* targetURL = nullptr;

ui.Init();
pageRenderer.Init();
config.loadImages = true;

char* targetURL = nullptr;
if (argc > 1)
{
for (int n = 1; n < argc; n++)
Expand All @@ -60,9 +60,21 @@ void App::Run(int argc, char* argv[])
targetURL = argv[n];
break;
}
else if (!stricmp(argv[n], "-noimages"))
{
config.loadImages = false;
}
}
}

if (config.loadImages)
{
ImageDecoder::Allocate();
}

ui.Init();
pageRenderer.Init();

if (targetURL)
{
OpenURL(targetURL);
Expand All @@ -76,80 +88,80 @@ void App::Run(int argc, char* argv[])
{
Platform::Update();

if (loadTask.HasContent())
if (pageLoadTask.HasContent())
{
if (requestedNewPage)
{
ResetPage();
requestedNewPage = false;
page.pageURL = loadTask.GetURL();
page.pageURL = pageLoadTask.GetURL();
ui.UpdateAddressBar(page.pageURL);
loadTaskTargetNode = page.GetRootNode();
}

static char buffer[256];

size_t bytesRead = loadTask.GetContent(buffer, 256);
size_t bytesRead = pageLoadTask.GetContent(loadBuffer, APP_LOAD_BUFFER_SIZE);
if (bytesRead)
{
if (loadTask.debugDumpFile)
if (pageLoadTask.debugDumpFile)
{
fwrite(buffer, 1, bytesRead, loadTask.debugDumpFile);
fwrite(loadBuffer, 1, bytesRead, pageLoadTask.debugDumpFile);
}

if (loadTaskTargetNode == page.GetRootNode())
{
parser.Parse(buffer, bytesRead);
}
else if(loadTaskTargetNode)
{
bool stillProcessing = loadTaskTargetNode->Handler().ParseContent(loadTaskTargetNode, buffer, bytesRead);
if (!stillProcessing)
{
loadTask.Stop();
}
}
parser.Parse(loadBuffer, bytesRead);
}
}
else
{
if (requestedNewPage)
{
if (loadTask.type == LoadTask::RemoteFile)
if (pageLoadTask.type == LoadTask::RemoteFile)
{
if (!loadTask.request)
if (!pageLoadTask.request)
{
ShowErrorPage("No network interface available");
requestedNewPage = false;
}
else if (loadTask.request->GetStatus() == HTTPRequest::Error)
else if (pageLoadTask.request->GetStatus() == HTTPRequest::Error)
{
ShowErrorPage(loadTask.request->GetStatusString());
ShowErrorPage(pageLoadTask.request->GetStatusString());
requestedNewPage = false;
}
else if (loadTask.request->GetStatus() == HTTPRequest::UnsupportedHTTPS)
else if (pageLoadTask.request->GetStatus() == HTTPRequest::UnsupportedHTTPS)
{
ShowNoHTTPSPage();
requestedNewPage = false;
}
}
}
}
else
else if (!parser.IsFinished())
{
bool isStillConnecting = loadTask.type == LoadTask::RemoteFile && loadTask.request && loadTask.request->GetStatus() == HTTPRequest::Connecting;

if(!isStillConnecting)
parser.Finish();
}
}

if (pageContentLoadTask.HasContent())
{
size_t bytesRead = pageContentLoadTask.GetContent(loadBuffer, APP_LOAD_BUFFER_SIZE);
if (bytesRead)
{
bool stillProcessing = loadTaskTargetNode->Handler().ParseContent(loadTaskTargetNode, loadBuffer, bytesRead);
if (!stillProcessing)
{
if (loadTaskTargetNode)
{
loadTaskTargetNode = page.ProcessNextLoadTask(loadTaskTargetNode, loadTask);
}
pageContentLoadTask.Stop();
}
}
}
if (loadTask.type == LoadTask::RemoteFile && loadTask.request && loadTask.request->GetStatus() == HTTPRequest::Connecting)
ui.SetStatusMessage(loadTask.request->GetStatusString());
else if(!pageContentLoadTask.IsBusy())
{
if (loadTaskTargetNode)
{
loadTaskTargetNode = page.ProcessNextLoadTask(loadTaskTargetNode, pageContentLoadTask);
}
}
//if (loadTask.type == LoadTask::RemoteFile && loadTask.request && loadTask.request->GetStatus() == HTTPRequest::Connecting)
// ui.SetStatusMessage(loadTask.request->GetStatusString());

page.layout.Update();
pageRenderer.Update();
ui.Update();
}
Expand Down Expand Up @@ -246,6 +258,12 @@ const char* LoadTask::GetURL()
return url.url;
}

bool LoadTask::IsBusy()
{
bool isStillConnecting = type == LoadTask::RemoteFile && request && request->GetStatus() == HTTPRequest::Connecting;
return isStillConnecting || HasContent();
}

bool LoadTask::HasContent()
{
if (type == LoadTask::LocalFile)
Expand Down Expand Up @@ -294,7 +312,7 @@ size_t LoadTask::GetContent(char* buffer, size_t count)
void App::RequestNewPage(const char* url)
{
StopLoad();
loadTask.Load(url);
pageLoadTask.Load(url);
requestedNewPage = true;
loadTaskTargetNode = nullptr;
//ui.UpdateAddressBar(loadTask.url);
Expand All @@ -314,18 +332,19 @@ void App::OpenURL(const char* url)
pageHistoryPos--;
}

pageHistory[pageHistoryPos] = loadTask.url;
pageHistory[pageHistoryPos] = pageLoadTask.url;
pageHistorySize = pageHistoryPos + 1;
}

void App::StopLoad()
{
loadTask.Stop();
pageLoadTask.Stop();
pageContentLoadTask.Stop();
}

void App::ShowErrorPage(const char* message)
{
loadTask.Stop();
StopLoad();
ResetPage();

// page.BreakLine(2);
Expand Down Expand Up @@ -370,10 +389,10 @@ void App::ShowNoHTTPSPage()
//page.FinishSection();

page.SetTitle("HTTPS unsupported");
page.pageURL = loadTask.GetURL();
page.pageURL = pageLoadTask.GetURL();
ui.UpdateAddressBar(page.pageURL);

loadTask.Stop();
StopLoad();
}

void App::PreviousPage()
Expand All @@ -394,6 +413,12 @@ void App::NextPage()
}
}

void App::LoadImageNodeContent(Node* node)
{
loadTaskTargetNode = node;
node->Handler().LoadContent(node, pageContentLoadTask);
}

void VideoDriver::InvertVideoOutput()
{
if (drawSurface->bpp == 1)
Expand All @@ -413,3 +438,4 @@ void VideoDriver::InvertVideoOutput()
Platform::input->ShowMouse();
}
}

15 changes: 14 additions & 1 deletion src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Render.h"

#define MAX_PAGE_URL_HISTORY 5
#define APP_LOAD_BUFFER_SIZE 256

class HTTPRequest;

Expand All @@ -33,6 +34,7 @@ struct LoadTask
void Load(const char* url);
void Stop();
bool HasContent();
bool IsBusy();
size_t GetContent(char* buffer, size_t count);
const char* GetURL();

Expand All @@ -56,6 +58,11 @@ struct LoadTask

struct Widget;

struct AppConfig
{
bool loadImages : 1;
};

class App
{
public:
Expand All @@ -79,6 +86,12 @@ class App
PageRenderer pageRenderer;
HTMLParser parser;
AppInterface ui;
AppConfig config;

LoadTask pageLoadTask;
LoadTask pageContentLoadTask;

void LoadImageNodeContent(Node* node);

private:
void ResetPage();
Expand All @@ -87,7 +100,6 @@ class App
void ShowNoHTTPSPage();

bool requestedNewPage;
LoadTask loadTask;
Node* loadTaskTargetNode;
bool running;

Expand All @@ -97,6 +109,7 @@ class App

static App* app;

char loadBuffer[APP_LOAD_BUFFER_SIZE];
};


Expand Down
16 changes: 15 additions & 1 deletion src/DOS/BIOSVid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

BIOSVideoDriver::BIOSVideoDriver()
{
startingScreenMode = -1;
}

void BIOSVideoDriver::Init(VideoModeInfo* inVideoModeInfo)
Expand Down Expand Up @@ -91,6 +92,11 @@ void BIOSVideoDriver::Init(VideoModeInfo* inVideoModeInfo)
screenPitch = screenWidth;
colourScheme = colourScheme666;
paletteLUT = new uint8_t[256];
if (!paletteLUT)
{
Platform::FatalError("Could not allocate memory for paletteLUT");
}

for (int n = 0; n < 256; n++)
{
int r = (n & 0xe0);
Expand Down Expand Up @@ -122,6 +128,11 @@ void BIOSVideoDriver::Init(VideoModeInfo* inVideoModeInfo)
}
}

if (!drawSurface || !drawSurface->lines)
{
Platform::FatalError("Could not allocate memory for draw surface");
}

if (videoModeInfo->vramPage3)
{
// 4 page interlaced memory layout
Expand Down Expand Up @@ -174,7 +185,10 @@ void BIOSVideoDriver::Init(VideoModeInfo* inVideoModeInfo)

void BIOSVideoDriver::Shutdown()
{
SetScreenMode(startingScreenMode);
if (startingScreenMode != -1)
{
SetScreenMode(startingScreenMode);
}
}

int BIOSVideoDriver::GetScreenMode()
Expand Down
29 changes: 29 additions & 0 deletions src/DOS/DOSInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,35 @@ void DOSInputDriver::SetMousePosition(int x, int y)
int86(0x33, &inreg, &outreg);
}

bool DOSInputDriver::GetMouseButtonPress(int& x, int& y)
{
if (!hasMouse)
return false;

union REGS inreg, outreg;
inreg.x.ax = 5;
inreg.x.bx = 0;
int86(0x33, &inreg, &outreg);
x = outreg.x.cx;
y = outreg.x.dx;
return (outreg.x.bx > 0);
}

bool DOSInputDriver::GetMouseButtonRelease(int& x, int& y)
{
if (!hasMouse)
return false;

union REGS inreg, outreg;
inreg.x.ax = 6;
inreg.x.bx = 0;
int86(0x33, &inreg, &outreg);
x = outreg.x.cx;
y = outreg.x.dx;
return (outreg.x.bx > 0);
}


void DOSInputDriver::HideMouse()
{
if (!hasMouse)
Expand Down
3 changes: 3 additions & 0 deletions src/DOS/DOSInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class DOSInputDriver : public InputDriver

virtual void GetMouseStatus(int& buttons, int& x, int& y);
virtual void SetMousePosition(int x, int y);
virtual bool GetMouseButtonPress(int& x, int& y);
virtual bool GetMouseButtonRelease(int& x, int& y);

virtual InputButtonCode GetKeyPress();

private:
Expand Down
Loading

0 comments on commit 71c1317

Please sign in to comment.