Skip to content

Commit

Permalink
intermediate commit(broken compilation) - moving all globals in one s…
Browse files Browse the repository at this point in the history
…cope, prepare to unlink unneded *.o modules
  • Loading branch information
hz committed Jun 16, 2023
1 parent 1d37ab5 commit 0731077
Show file tree
Hide file tree
Showing 3 changed files with 2,740 additions and 17 deletions.
1 change: 0 additions & 1 deletion run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ ${CLANG_BINARY} -target assigner \
-I${HOME}/zkllvm/libs/stdlib/libcpp \
-I${HOME}/zkllvm/libs/crypto3/algebra/include \
-I${HOME}/zkllvm/build/include \
-I/usr/local/include \
-I${HOME}/zkllvm/libs/blueprint/include \
-I${HOME}/zkllvm/libs/crypto3/block/include -I${HOME}/zkllvm/libs/crypto3/codec/include -I${HOME}/zkllvm/libs/crypto3/containers/include -I${HOME}/zkllvm/libs/crypto3/hash/include -I${HOME}/zkllvm/libs/crypto3/kdf/include -I${HOME}/zkllvm/libs/crypto3/mac/include -I${HOME}/zkllvm/libs/crypto3/marshalling/core/include -I -I${HOME}/zkllvm/libs/crypto3/marshalling/algebra/include -I${HOME}/zkllvm/libs/crypto3/marshalling/multiprecision/include -I${HOME}/zkllvm/libs/crypto3/marshalling/zk/include -I${HOME}/zkllvm/libs/crypto3/math/include -I${HOME}/zkllvm/libs/crypto3/modes/include -I${HOME}/zkllvm/libs/crypto3/multiprecision/include -I${HOME}/zkllvm/libs/crypto3/passhash/include -I${HOME}/zkllvm/libs/crypto3/pbkdf/include -I${HOME}/zkllvm/libs/crypto3/pkmodes/include -I${HOME}/zkllvm/libs/crypto3/pkpad/include -I${HOME}/zkllvm/libs/crypto3/pubkey/include -I${HOME}/zkllvm/libs/crypto3/random/include -I${HOME}/zkllvm/libs/crypto3/stream/include -I${HOME}/zkllvm/libs/crypto3/vdf/include -I${HOME}/zkllvm/libs/crypto3/zk/include \
-D__ZKLLVM__ \
Expand Down
185 changes: 169 additions & 16 deletions zkldoom/z_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@
// Main program, simply calls D_DoomMain high level loop.
//

//#include "config.h"

#include <stdio.h>
#include <strings.h>
//#include "doomtype.h"
//#include "i_system.h"
#include "m_argv.h"
#include <stdlib.h>

#include <strings.h> // for strlen

#include <stdlib.h>
#include "m_argv.h"
#include "doomreplay.h"


Expand All @@ -36,10 +32,9 @@
*/


char *USER_INPUT = ",,,,,,,,,,,,,,,,,,,,,,,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,r,r,r,r,f,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,f,f,f,f,f,f";


unsigned long prepare_inputs(char * input, unsigned char *input_codes) {
unsigned long prepare_inputs(const char * input, unsigned char *input_codes) {
// string with inputs like
// ",,,,,,,,,,,,,,,,,,,,,,,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,r,r,r,r,f,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,f,f,f,f,f,f";
unsigned long n_inputs = strlen(input);
Expand Down Expand Up @@ -77,10 +72,75 @@ unsigned long prepare_inputs(char * input, unsigned char *input_codes) {
}


// ALL GLOBAL STATE HERE

// All globals from "*.h" headers combined
#include "z_main.h"





// AAAA Globals from d_main.c

// will be moved to function inputs
const char *USER_INPUT = ",,,,,,,,,,,,,,,,,,,,,,,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,r,r,r,r,f,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,f,f,f,f,f,f";

static replay_data_t replay_data;

// Location where savegames are stored
char * savegamedir;

// location of IWAD and WAD files
char * iwadfile;

boolean devparm; // started game with -devparm
boolean nomonsters; // checkparm of -nomonsters
boolean respawnparm; // checkparm of -respawn
boolean fastparm; // checkparm of -fast

extern boolean inhelpscreens;

skill_t startskill;
int startepisode;
int startmap;
boolean autostart;
int startloadgame;

boolean advancedemo;

// Store demo, do not accept any inputs
boolean storedemo;

// "BFG Edition" version of doom2.wad does not include TITLEPIC.
boolean bfgedition;

// If true, the main game loop has started.
boolean main_loop_started = false;

char wadfile[1024]; // primary wad file
char mapdir[1024]; // directory of development maps

int show_endoom = 1;

















int main(int argc, char **argv)
{
replay_data_t replay_data;

replay_data.framerate = 35;
replay_data.n_start = 0;
Expand All @@ -92,7 +152,7 @@ int main(int argc, char **argv)
replay_data.n_frames = 1;

unsigned char *input_codes = malloc(sizeof(unsigned char) * strlen(USER_INPUT));
unsigned int n_inputs = prepare_inputs(USER_INPUT, input_codes);
unsigned long n_inputs = prepare_inputs(USER_INPUT, input_codes);

for (int i = 0; i < n_inputs; ++i) {
switch (input_codes[i]) {
Expand All @@ -102,7 +162,7 @@ int main(int argc, char **argv)
};
}

printf("[DEBUG] target n_frames: %d %d\n", replay_data.n_frames);
printf("[DEBUG] target n_frames: %d\n", replay_data.n_frames);

replay_data.frames = malloc(replay_data.n_frames*sizeof(frame_data_t));
replay_data.usernames = malloc(replay_data.n_usernames*sizeof(username_data_t));
Expand All @@ -114,7 +174,6 @@ int main(int argc, char **argv)
}

int cur_frame = 0;
int cur_username = 0;

for (int i = 0; i < n_inputs; ++i) {
frame_data_t * frame = replay_data.frames + cur_frame;
Expand All @@ -125,12 +184,106 @@ int main(int argc, char **argv)
}
}

DR_Init(replay_data);
// AAAAAAA DR_Init() moved
g_key_map[dr_key_escape ] = KEY_ESCAPE;
g_key_map[dr_key_enter ] = KEY_ENTER;
g_key_map[dr_key_left ] = KEY_LEFTARROW;
g_key_map[dr_key_right ] = KEY_RIGHTARROW;
g_key_map[dr_key_up ] = KEY_UPARROW;
g_key_map[dr_key_down ] = KEY_DOWNARROW;
g_key_map[dr_key_alt ] = KEY_LALT;
g_key_map[dr_key_shift ] = KEY_RSHIFT;
g_key_map[dr_key_use ] = KEY_USE;
g_key_map[dr_key_fire ] = KEY_FIRE;
g_key_map[dr_key_tab ] = KEY_TAB;
g_key_map[dr_key_yes ] = 'y';
g_key_map[dr_key_no ] = 'n';
g_key_map[dr_key_strafe_left ] = KEY_STRAFE_L;
g_key_map[dr_key_strafe_right] = KEY_STRAFE_R;
g_key_map[dr_key_0 ] = '0';
g_key_map[dr_key_1 ] = '1';
g_key_map[dr_key_2 ] = '2';
g_key_map[dr_key_3 ] = '3';
g_key_map[dr_key_4 ] = '4';
g_key_map[dr_key_5 ] = '5';
g_key_map[dr_key_6 ] = '6';
g_key_map[dr_key_7 ] = '7';
g_key_map[dr_key_8 ] = '8';
g_key_map[dr_key_9 ] = '9';

g_replay_data = replay_data;

for (int i = 0; i < dr_key_COUNT; ++i) {
g_pressed_last[i] = 0;
}

printf("\n\n======= DOOM REPLAY ===========\n");
printf("Frames to simulate: %6d (%g seconds)\n", g_replay_data.n_frames, (float)(g_replay_data.n_frames)/TICRATE);
printf("Start frame: %6d (%g seconds)\n", g_replay_data.n_start, (float)(g_replay_data.n_start)/TICRATE);
printf("Frames to record: %6d (%g seconds)\n", g_replay_data.n_record, (float)(g_replay_data.n_record)/TICRATE);
printf("Framerate: %6d\n", g_replay_data.framerate);
printf("===============================\n");

printf("[DEBUG] DR_init completed\n");
// DR_Init(replay_data);

// dg_Create();
DG_ScreenBuffer = malloc(DOOMGENERIC_RESX * DOOMGENERIC_RESY * 4);
printf("[DEBUG] dg_Create completed\n");



// DoomMain();

printf("[DEBUG] Z_Init: Init zone memory allocation daemon. \n");
Z_Init ();

nomonsters = 0;
respawnparm = 0;
fastparm = 0;
devparm = 0;
deathmatch = 0;

modifiedgame = false;

D_AddFile("../doom1.wad");

// Generate the WAD hash table. Speed things up a bit.
// HZ CCCCCCCCCCC check
//W_GenerateHashTable();

I_InitTimer();

// get skill / episode / map from parms
startskill = sk_medium;
startepisode = 1;
startmap = 1;
autostart = false;

timelimit = 0;

// Not loading a game
startloadgame = -1;

R_Init ();

P_Init ();

D_CheckNetGame ();

ST_Init ();

// [AAAA] autostart
autostart = 1;
G_InitNew (startskill, startepisode, startmap);

D_DoomLoop (); // never returns

dg_Create();

D_DoomMain ();

return 0;
}




Loading

0 comments on commit 0731077

Please sign in to comment.