From c7b07fe94d6b1e9dc8199ef515ef24930e398ffb Mon Sep 17 00:00:00 2001 From: aperturesecurity Date: Tue, 15 Jan 2019 19:45:42 +0200 Subject: [PATCH] make resizing window and cleaned up a few things --- .gitignore | 4 +++ Source/codec.cpp | 7 +++++ Source/engine.cpp | 5 ++-- Stub/dx_stub.h | 3 +-- Stub/init.cpp | 65 +++++++++++++++++++++++++++++++++++++++++----- Stub/miniwin.h | 1 - Stub/sdlrender.cpp | 4 ++- Stub/stubs.h | 3 --- types.h | 15 ++++++++++- 9 files changed, 89 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index cac7ce8e8..218d50fd8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ # Generated by VC++ 6 builds /vc60.idb +#ignore cmake cache +/build/CMakeCache.txt + + # ELF object file. *.o diff --git a/Source/codec.cpp b/Source/codec.cpp index 0b6fd982f..025da06e8 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -7,6 +7,13 @@ #define rand rand_miniwin #endif +#ifdef ANDROID +#define srand srand_miniwin +#define rand rand_miniwin +#endif + + + int __fastcall codec_decode(void *pbSrcDst, int size, char *pszPassword) { unsigned int v3; // ebx diff --git a/Source/engine.cpp b/Source/engine.cpp index b59a8c2be..ccb9acd20 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,7 +1,6 @@ //HEADER_GOES_HERE -#include -//#include -#include + + #include "../types.h" #include "miniwin_sdl.h" diff --git a/Stub/dx_stub.h b/Stub/dx_stub.h index 8b8304c38..c132abbe2 100644 --- a/Stub/dx_stub.h +++ b/Stub/dx_stub.h @@ -1,10 +1,9 @@ #pragma once -#include /* extern SDL_Window *window; extern SDL_Renderer *renderer; extern SDL_Texture *texture; extern SDL_Surface *surface; */ -void sdl_present_surface(); \ No newline at end of file +void sdl_present_surface(); diff --git a/Stub/init.cpp b/Stub/init.cpp index f04cfe4c2..047312232 100644 --- a/Stub/init.cpp +++ b/Stub/init.cpp @@ -159,6 +159,9 @@ void SDL_Diablo_UI() // I anticipate to move this later. snd_init(0); music_start(5); + + int timestart = 0; + signed int NewHeroNameIndex = 0; int menu = 0; @@ -222,7 +225,6 @@ void SDL_Diablo_UI() // I anticipate to move this later. DrawMouse(); } if (menu == 5) { - DrawPreGameOptions(HeroPortrait, 1); RenderDefaultStats(HeroPortrait); ConstantButtons(); @@ -538,7 +540,26 @@ void SDL_Diablo_UI() // I anticipate to move this later. break; } } + + + clock_t start, end; + double cpu_time_used; + if (menu == 5) { + if( timestart == 0 ){ + start = clock(); + timestart = 1; + } + + end = clock(); + + + cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; + + + + printf("TIEM DELAY %f\n", cpu_time_used); + int CreateHeroOkBoxX = 330; int CreateHeroOkBoxY = 441; @@ -571,30 +592,54 @@ void SDL_Diablo_UI() // I anticipate to move this later. CreateHeroCancelBox.w = CreateHeroCancelBox.x + 100; CreateHeroCancelBox.h = CreateHeroCancelBox.y + 30; - if ((x > NewGameBox.x) && (y > NewGameBox.y) && (x < NewGameBox.w) && (y < NewGameBox.h)) { + + + if ( cpu_time_used > 1 && (x > NewGameBox.x) && (y > NewGameBox.y) && (x < NewGameBox.w) && (y < NewGameBox.h)) { printf(" New Game I was hit\n\n\n"); - menu = 6; + cpu_time_used = 0; + timestart = 0; + start = 0; } - if ((x > LoadGameBox.x) && (y > LoadGameBox.y) && (x < LoadGameBox.w) && (y < LoadGameBox.h)) { + if (cpu_time_used > 1 && (x > LoadGameBox.x) && (y > LoadGameBox.y) && (x < LoadGameBox.w) && (y < LoadGameBox.h)) { printf(" Load Game I was hit\n\n\n"); break; + } if ((x > CreateHeroCancelBox.x) && (y > CreateHeroCancelBox.y) && (x < CreateHeroCancelBox.w) && (y < CreateHeroCancelBox.h)) { HeroPortrait = 3; + timestart = 0; + cpu_time_used = 0; + start = 0; + end = 0; + cpu_time_used = 0; printf("Cancel\n\n\n"); menu = 2; // Return back to select hero menu. } } + if (menu == 6) { // Choose difficulty + + + + + + if(timestart == 0){ + start = clock(); + timestart = 1; + } + + + end = clock(); + cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; int CreateHeroOkBoxX = 330; @@ -631,19 +676,19 @@ void SDL_Diablo_UI() // I anticipate to move this later. CreateHeroCancelBox.w = CreateHeroCancelBox.x + 100; CreateHeroCancelBox.h = CreateHeroCancelBox.y + 30; - if ((x > NormalSelectBox.x) && (y > NormalSelectBox.y) && (x < NormalSelectBox.w) && + if (cpu_time_used > 1 && (x > NormalSelectBox.x) && (y > NormalSelectBox.y) && (x < NormalSelectBox.w) && (y < NormalSelectBox.h)) { StartNewGame = 1; gnDifficulty = DIFF_NORMAL; break; } - if ((x > NightmareSelectBox.x) && (y > NightmareSelectBox.y) && (x < NightmareSelectBox.w) && + if (cpu_time_used > 1 && (x > NightmareSelectBox.x) && (y > NightmareSelectBox.y) && (x < NightmareSelectBox.w) && (y < NightmareSelectBox.h)) { StartNewGame = 1; gnDifficulty = DIFF_NIGHTMARE; break; } - if ((x > HellSelectBox.x) && (y > HellSelectBox.y) && (x < HellSelectBox.w) && + if ( cpu_time_used > 1 && (x > HellSelectBox.x) && (y > HellSelectBox.y) && (x < HellSelectBox.w) && (y < HellSelectBox.h)) { gnDifficulty = DIFF_HELL; StartNewGame = 1; @@ -653,6 +698,12 @@ void SDL_Diablo_UI() // I anticipate to move this later. if ((x > CreateHeroCancelBox.x) && (y > CreateHeroCancelBox.y) && (x < CreateHeroCancelBox.w) && (y < CreateHeroCancelBox.h)) { HeroPortrait = 3; + timestart = 0; + cpu_time_used = 0; + start = 0; + end = 0; + cpu_time_used = 0; + printf("Cancel\n\n\n"); --menu; diff --git a/Stub/miniwin.h b/Stub/miniwin.h index c5f6423df..d64ed6965 100644 --- a/Stub/miniwin.h +++ b/Stub/miniwin.h @@ -6,7 +6,6 @@ #define STATIC static #endif -#include #include #include #include diff --git a/Stub/sdlrender.cpp b/Stub/sdlrender.cpp index 2717dad11..4b9844fa0 100644 --- a/Stub/sdlrender.cpp +++ b/Stub/sdlrender.cpp @@ -618,6 +618,8 @@ void SdlDiabloMainWindow() renderer = SDL_CreateRenderer(window, -1, 0); printf("Window And Renderer Created!\n"); + + SDL_RenderSetLogicalSize(renderer, 800, 600); const int pitch = SCREEN_WIDTH + 64 + 64; surface = SDL_CreateRGBSurface(0, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); @@ -1148,4 +1150,4 @@ void CreateHeroMenu() // DrawArtImage(0, 0, gdwTitleWidth, gdwTitleHeight, 0, pPcxTitleImage); // DrawArtImage(0, 0, gdwSHeroWidth, gdwSHeroHeight, 0, pPcxSHeroImage); RenderDiabloLogo(); -} \ No newline at end of file +} diff --git a/Stub/stubs.h b/Stub/stubs.h index aa97b3fb3..32c022aa3 100644 --- a/Stub/stubs.h +++ b/Stub/stubs.h @@ -1,8 +1,5 @@ #pragma once -#include -//#include -#include #include "miniwin_sdl.h" diff --git a/types.h b/types.h index 3adc065a2..6ae8d9668 100644 --- a/types.h +++ b/types.h @@ -9,8 +9,21 @@ #ifdef MINIWIN #include "miniwin.h" +#include +#include +#include +#endif + +#ifdef ANDROID +#include "miniwin.h" +#include +#include +#include +#endif + + -#else +#ifdef __WIN32__ #define WIN32_LEAN_AND_MEAN #include