#pragma once

#include "l4vb8.h"

//########################################################################
//############################ PlasmaScreen ##############################
//########################################################################
//
// The cockpit's 128x32 plasma display rendered as a desktop window
// instead of streamed to serial hardware. The gauge system draws into
// the same Video8BitBuffered surface it always has; Update() just blits
// the buffer into a small "glass" window in plasma orange.
//
// Selected with L4PLASMA=SCREEN. L4PLASMASCALE sets the pixel size
// (default 4 -> a 512x128 window).
//
class PlasmaScreen :
	public Video8BitBuffered
{
public:
	enum
	{
		plasmaWidth=128,
		plasmaHeight=32
	};

	PlasmaScreen();

	~PlasmaScreen();

	Logical
		TestInstance() const;

	Logical
		Update(Logical forceall);

	void
		WaitForUpdate();

	// Reposition/resize the live glass (client-area size; the paint
	// stretches to fit, so this also rescales it). With a parent the
	// glass becomes a chrome-less child pane of the cockpit window.
	// Used by SVGA16's split-view layout; no-op when no plasma exists.
	static void
		Position(void *parent, int x, int y, int client_width, int client_height);

	// Hide the glass entirely (cockpit currently runs without it).
	static void
		Hide();

protected:
	static PlasmaScreen
		*activeInstance;

	void
		CreateGlassWindow();

	void
		*window;			// HWND, kept untyped so this header stays lean
	void
		*bitmapInfo;		// BITMAPINFOHEADER + 256-entry orange palette
	int
		scale;
};
