Browse Source

make resizing window and cleaned up a few things

pull/18/head
aperturesecurity 7 years ago
parent
commit
c7b07fe94d
  1. 4
      .gitignore
  2. 7
      Source/codec.cpp
  3. 5
      Source/engine.cpp
  4. 3
      Stub/dx_stub.h
  5. 65
      Stub/init.cpp
  6. 1
      Stub/miniwin.h
  7. 4
      Stub/sdlrender.cpp
  8. 3
      Stub/stubs.h
  9. 15
      types.h

4
.gitignore vendored

@ -1,6 +1,10 @@
# Generated by VC++ 6 builds
/vc60.idb
#ignore cmake cache
/build/CMakeCache.txt
# ELF object file.
*.o

7
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

5
Source/engine.cpp

@ -1,7 +1,6 @@
//HEADER_GOES_HERE
#include <SDL2/SDL.h>
//#include <SDL_image.h>
#include <SDL_mixer.h>
#include "../types.h"
#include "miniwin_sdl.h"

3
Stub/dx_stub.h

@ -1,10 +1,9 @@
#pragma once
#include <SDL2/SDL.h>
/*
extern SDL_Window *window;
extern SDL_Renderer *renderer;
extern SDL_Texture *texture;
extern SDL_Surface *surface;
*/
void sdl_present_surface();
void sdl_present_surface();

65
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;

1
Stub/miniwin.h

@ -6,7 +6,6 @@
#define STATIC static
#endif
#include <SDL2/SDL.h>
#include <vector>
#include <ctype.h>
#include <math.h>

4
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();
}
}

3
Stub/stubs.h

@ -1,8 +1,5 @@
#pragma once
#include <SDL2/SDL.h>
//#include <SDL_image.h>
#include <SDL_mixer.h>
#include "miniwin_sdl.h"

15
types.h

@ -9,8 +9,21 @@
#ifdef MINIWIN
#include "miniwin.h"
#include <SDL2/SDL.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
#endif
#ifdef ANDROID
#include "miniwin.h"
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
#endif
#else
#ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

Loading…
Cancel
Save