summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-13 18:08:09 +0100
committerAki <please@ignore.pl>2022-03-13 18:08:09 +0100
commit01954b1d34a42fa4a51a3e0d690ba4ad5a1f8298 (patch)
tree00c7c8677eae54441a910af9ade2a79d09e64d65
parentadb04f7316f9b2f7871b91b62d3bd920194bf97d (diff)
downloadstarshatter-01954b1d34a42fa4a51a3e0d690ba4ad5a1f8298.zip
starshatter-01954b1d34a42fa4a51a3e0d690ba4ad5a1f8298.tar.gz
starshatter-01954b1d34a42fa4a51a3e0d690ba4ad5a1f8298.tar.bz2
Moved palette to GameWinDX9
-rw-r--r--Stars45/Game.cpp65
-rw-r--r--Stars45/Game.h5
-rw-r--r--Stars45/GameWinDX9.cpp72
-rw-r--r--Stars45/GameWinDX9.h8
-rw-r--r--Stars45/StarServer.cpp2
-rw-r--r--Stars45/Starshatter.cpp2
6 files changed, 82 insertions, 72 deletions
diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp
index f149a00..3d6dcb6 100644
--- a/Stars45/Game.cpp
+++ b/Stars45/Game.cpp
@@ -460,13 +460,6 @@ Game::InitGame()
}
else {
- if (!SetupPalette()) {
- Panic::Panic("Could not set up the palette.");
- return false;
- }
-
- Print(" Palette loaded.\n");
-
if (!InitVideo() || !video || video->Status() != Video::VIDEO_OK) {
if (Panic::Panicked())
Panic::Panic("Could not create the Video Interface.");
@@ -500,64 +493,6 @@ Game::InitGame()
// +--------------------------------------------------------------------+
-bool
-Game::SetupPalette()
-{
- if (LoadPalette(standard_palette, inverse_palette)) {
- Color::SetPalette(standard_palette, 256, inverse_palette);
- return true;
- }
-
- return false;
-}
-
-// +--------------------------------------------------------------------+
-
-bool
-Game::LoadPalette(PALETTEENTRY* pal, BYTE* inv)
-{
- char palheader[32];
- struct {
- WORD Version;
- WORD NumberOfEntries;
- PALETTEENTRY Entries[256];
-
- } Palette = { 0x300, 256 };
-
- DataLoader* loader = DataLoader::GetLoader();
- BYTE* block;
- char fname[256];
- sprintf_s(fname, "%s.pal", palette_name);
-
- if (!loader->LoadBuffer(fname, block)) {
- Print(" Could not open file '%s'\n", fname);
- return false;
- }
-
- memcpy(&palheader, block, 24);
- memcpy((char*) Palette.Entries, (block+24), 256*4);
-
- for (int i = 0; i < 256; i++) {
- *pal++ = Palette.Entries[i];
- }
-
- loader->ReleaseBuffer(block);
-
- sprintf_s(fname, "%s.ipl", palette_name);
- int size = loader->LoadBuffer(fname, block);
- if (size < 32768) {
- Print(" Could not open file '%s'\n", fname);
- return false;
- }
-
- memcpy(inv, block, 32768);
- loader->ReleaseBuffer(block);
-
- return true;
-}
-
-// +--------------------------------------------------------------------+
-
int
Game::Run()
{
diff --git a/Stars45/Game.h b/Stars45/Game.h
index afd8f27..b42af06 100644
--- a/Stars45/Game.h
+++ b/Stars45/Game.h
@@ -110,8 +110,6 @@ public:
virtual bool ToggleFullscreen();
virtual bool AdjustWindowForChange();
- virtual bool SetupPalette();
- virtual bool LoadPalette(PALETTEENTRY* pal, BYTE* inv);
virtual void ShowStats();
protected:
@@ -129,9 +127,6 @@ protected:
RenderStats stats;
DWORD totaltime;
- PALETTEENTRY standard_palette[256];
- BYTE inverse_palette[32768];
-
HINSTANCE hInst;
HWND hwnd;
HMENU hmenu;
diff --git a/Stars45/GameWinDX9.cpp b/Stars45/GameWinDX9.cpp
index f40be9b..bf7876f 100644
--- a/Stars45/GameWinDX9.cpp
+++ b/Stars45/GameWinDX9.cpp
@@ -6,6 +6,10 @@
#include "GameWinDX9.h"
+#include <stdio.h>
+#include <string.h>
+
+#include "DataLoader.h"
#include "Game.h"
#include "MachineInfo.h"
#include "Panic.h"
@@ -192,3 +196,71 @@ GameWinDX9::InitInstance(HINSTANCE hInstance, int nCmdShow)
Print(" Instance initialized.\n");
return true;
}
+
+
+bool
+GameWinDX9::InitGame()
+{
+ if (server) return true;
+ if (!SetupPalette()) {
+ Panic::Panic("Could not set up the palette.");
+ return false;
+ }
+ Print(" Palette laoded\n");
+ return Game::InitGame();
+}
+
+
+bool
+GameWinDX9::SetupPalette()
+{
+ if (LoadPalette(standard_palette, inverse_palette)) {
+ Color::SetPalette(standard_palette, 256, inverse_palette);
+ return true;
+ }
+
+ return false;
+}
+
+
+bool
+GameWinDX9::LoadPalette(PALETTEENTRY* pal, BYTE* inv)
+{
+ char palheader[32];
+ struct {
+ WORD Version;
+ WORD NumberOfEntries;
+ PALETTEENTRY Entries[256];
+ } Palette = { 0x300, 256 };
+
+ DataLoader* loader = DataLoader::GetLoader();
+ BYTE* block;
+ char fname[256];
+ sprintf_s(fname, "%s.pal", palette_name);
+
+ if (!loader->LoadBuffer(fname, block)) {
+ Print(" Could not open file '%s'\n", fname);
+ return false;
+ }
+
+ memcpy(&palheader, block, 24);
+ memcpy((char*) Palette.Entries, (block+24), 256*4);
+
+ for (int i = 0; i < 256; i++) {
+ *pal++ = Palette.Entries[i];
+ }
+
+ loader->ReleaseBuffer(block);
+
+ sprintf_s(fname, "%s.ipl", palette_name);
+ int size = loader->LoadBuffer(fname, block);
+ if (size < 32768) {
+ Print(" Could not open file '%s'\n", fname);
+ return false;
+ }
+
+ memcpy(inv, block, 32768);
+ loader->ReleaseBuffer(block);
+
+ return true;
+}
diff --git a/Stars45/GameWinDX9.h b/Stars45/GameWinDX9.h
index 719bc04..9151bcd 100644
--- a/Stars45/GameWinDX9.h
+++ b/Stars45/GameWinDX9.h
@@ -20,6 +20,14 @@ public:
virtual bool Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow);
virtual bool InitApplication(HINSTANCE hInstance);
virtual bool InitInstance(HINSTANCE hInstance, int nCmdShow);
+ virtual bool InitGame();
+
+ virtual bool SetupPalette();
+ virtual bool LoadPalette(PALETTEENTRY* pal, BYTE* inv);
+
+protected:
+ PALETTEENTRY standard_palette[256];
+ BYTE inverse_palette[32768];
};
diff --git a/Stars45/StarServer.cpp b/Stars45/StarServer.cpp
index e0b17b8..98b1287 100644
--- a/Stars45/StarServer.cpp
+++ b/Stars45/StarServer.cpp
@@ -149,7 +149,7 @@ StarServer::Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow)
bool
StarServer::InitGame()
{
- if (!Game::InitGame())
+ if (!GameWinDX9::InitGame())
return false;
RandomInit();
diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp
index 4f04777..eeb5f6d 100644
--- a/Stars45/Starshatter.cpp
+++ b/Stars45/Starshatter.cpp
@@ -400,7 +400,7 @@ Starshatter::Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow)
bool
Starshatter::InitGame()
{
- if (!Game::InitGame())
+ if (!GameWinDX9::InitGame())
return false;
RandomInit();