Skip to content

Commit

Permalink
Restructure project and add better console logging
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroJSilva2001 committed May 30, 2024
1 parent b5cfa97 commit beb3a77
Show file tree
Hide file tree
Showing 97 changed files with 789 additions and 233 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ errors.txt
declarations.txt
.env

build/
build/

*.log
4 changes: 2 additions & 2 deletions experiments/antlr-generate.sh → antlr-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
ANTLR_PATH=""

# Set the input grammar file
GRAMMAR_FILE="./antlr/Declaration.g4"
GRAMMAR_FILE="./src/antlr/Declaration.g4"

# Set the output directory for generated files
OUTPUT_DIR="declparser"
OUTPUT_DIR="./src/declparser"

# Generate the ANTLR files
java -jar $ANTLR_PATH -o $OUTPUT_DIR -Dlanguage=Python3 -Xexact-output-dir $GRAMMAR_FILE
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"project": "DOOM",
"org": "id-Software",
"repository": "https://github.com/id-Software/DOOM",
"license": "GPLv2",
"snippets": "doom"
"license": "GPLv2"
}
95 changes: 95 additions & 0 deletions experiments/doom_id-software/snippets/am_map.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Calculates the slope and slope according to the x-axis of a line
// segment in map coordinates (with the upright y-axis n' all) so
// that it can be used with the brain-dead drawing stuff.
void AM_getIslope(mline_t *ml, islope_t *is)
{
int dx, dy;

dy = ml->a.y - ml->b.y;
dx = ml->b.x - ml->a.x;
if (!dy) is->islp = (dx<0?-MAXINT:MAXINT);
else is->islp = FixedDiv(dx, dy);
if (!dx) is->slp = (dy<0?-MAXINT:MAXINT);
else is->slp = FixedDiv(dy, dx);
}

void AM_activateNewScale(void)
{
m_x += m_w/2;
m_y += m_h/2;
m_w = FTOM(f_w);
m_h = FTOM(f_h);
m_x -= m_w/2;
m_y -= m_h/2;
m_x2 = m_x + m_w;
m_y2 = m_y + m_h;
}

void AM_saveScaleAndLoc(void)
{
old_m_x = m_x;
old_m_y = m_y;
old_m_w = m_w;
old_m_h = m_h;
}

void AM_restoreScaleAndLoc(void)
{
m_w = old_m_w;
m_h = old_m_h;
if (!followplayer) {
m_x = old_m_x;
m_y = old_m_y;
} else {
m_x = plr->mo->x - m_w/2;
m_y = plr->mo->y - m_h/2;
}
m_x2 = m_x + m_w;
m_y2 = m_y + m_h;

// Change the scaling multipliers
scale_mtof = FixedDiv(f_w<<FRACBITS, m_w);
scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
}

void AM_addMark(void)
{
markpoints[markpointnum].x = m_x + m_w/2;
markpoints[markpointnum].y = m_y + m_h/2;
markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS;
}

void AM_findMinMaxBoundaries(void)
{
int i;
fixed_t a;
fixed_t b;

min_x = min_y = MAXINT;
max_x = max_y = -MAXINT;

for (i=0;i<numvertexes;i++)
{
if (vertexes[i].x < min_x)
min_x = vertexes[i].x;
else if (vertexes[i].x > max_x)
max_x = vertexes[i].x;

if (vertexes[i].y < min_y)
min_y = vertexes[i].y;
else if (vertexes[i].y > max_y)
max_y = vertexes[i].y;
}

max_w = max_x - min_x;
max_h = max_y - min_y;

min_w = 2*PLAYERRADIUS; // const? never changed?
min_h = 2*PLAYERRADIUS;

a = FixedDiv(f_w<<FRACBITS, max_w);
b = FixedDiv(f_h<<FRACBITS, max_h);

min_scale_mtof = a < b ? a : b;
max_scale_mtof = FixedDiv(f_h<<FRACBITS, 2*PLAYERRADIUS);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
60 changes: 60 additions & 0 deletions experiments/doom_id-software/snippets/g_game.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
void G_InitPlayer(int player)
{
player_t* p;

// set up the saved info
p = &players[player];

// clear everything else to defaults
G_PlayerReborn (player);
}

void G_PlayerFinishLevel(int player)
{
player_t* p;

p = &players[player];

memset (p->powers, 0, sizeof (p->powers));
memset (p->cards, 0, sizeof (p->cards));
p->mo->flags &= ~MF_SHADOW; // cancel invisibility
p->extralight = 0; // cancel gun flashes
p->fixedcolormap = 0; // cancel ir gogles
p->damagecount = 0; // no palette changes
p->bonuscount = 0;
}

void G_PlayerReborn (int player)
{
player_t* p;
int i;
int frags[MAXPLAYERS];
int killcount;
int itemcount;
int secretcount;

memcpy (frags,players[player].frags,sizeof(frags));
killcount = players[player].killcount;
itemcount = players[player].itemcount;
secretcount = players[player].secretcount;

p = &players[player];
memset (p, 0, sizeof(*p));

memcpy (players[player].frags, frags, sizeof(players[player].frags));
players[player].killcount = killcount;
players[player].itemcount = itemcount;
players[player].secretcount = secretcount;

p->usedown = p->attackdown = true; // don't do anything immediately
p->playerstate = PST_LIVE;
p->health = MAXHEALTH;
p->readyweapon = p->pendingweapon = wp_pistol;
p->weaponowned[wp_fist] = true;
p->weaponowned[wp_pistol] = true;
p->ammo[am_clip] = 50;

for (i=0 ; i<NUMAMMO ; i++)
p->maxammo[i] = maxammo[i];

}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ void G_PlayerFinishLevel(int player)
p->fixedcolormap = 0; // cancel ir gogles
p->damagecount = 0; // no palette changes
p->bonuscount = 0;
}
}
File renamed without changes.
112 changes: 112 additions & 0 deletions experiments/doom_id-software/snippets/i_video.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#define NULL ((void *)0)

//
// Translates the key currently in X_event
//

int xlatekey(void)
{

int rc;

switch(rc = XKeycodeToKeysym(X_display, X_event.xkey.keycode, 0))
{
case XK_Left: rc = KEY_LEFTARROW; break;
case XK_Right: rc = KEY_RIGHTARROW; break;
case XK_Down: rc = KEY_DOWNARROW; break;
case XK_Up: rc = KEY_UPARROW; break;
case XK_Escape: rc = KEY_ESCAPE; break;
case XK_Return: rc = KEY_ENTER; break;
case XK_Tab: rc = KEY_TAB; break;
case XK_F1: rc = KEY_F1; break;
case XK_F2: rc = KEY_F2; break;
case XK_F3: rc = KEY_F3; break;
case XK_F4: rc = KEY_F4; break;
case XK_F5: rc = KEY_F5; break;
case XK_F6: rc = KEY_F6; break;
case XK_F7: rc = KEY_F7; break;
case XK_F8: rc = KEY_F8; break;
case XK_F9: rc = KEY_F9; break;
case XK_F10: rc = KEY_F10; break;
case XK_F11: rc = KEY_F11; break;
case XK_F12: rc = KEY_F12; break;

case XK_BackSpace:
case XK_Delete: rc = KEY_BACKSPACE; break;

case XK_Pause: rc = KEY_PAUSE; break;

case XK_KP_Equal:
case XK_equal: rc = KEY_EQUALS; break;

case XK_KP_Subtract:
case XK_minus: rc = KEY_MINUS; break;

case XK_Shift_L:
case XK_Shift_R:
rc = KEY_RSHIFT;
break;

case XK_Control_L:
case XK_Control_R:
rc = KEY_RCTRL;
break;

case XK_Alt_L:
case XK_Meta_L:
case XK_Alt_R:
case XK_Meta_R:
rc = KEY_RALT;
break;

default:
if (rc >= XK_space && rc <= XK_asciitilde)
rc = rc - XK_space + ' ';
if (rc >= 'A' && rc <= 'Z')
rc = rc - 'A' + 'a';
break;
}

return rc;
}

void I_ShutdownGraphics(void) {
// Detach from X server
if (!XShmDetach(X_display, &X_shminfo))
I_Error("XShmDetach() failed in I_ShutdownGraphics()");

// Release shared memory.
shmdt(X_shminfo.shmaddr);
shmctl(X_shminfo.shmid, IPC_RMID, 0);

// Paranoia.
image->data = NULL;
}

void I_StartTic(void) {

if (!X_display) return;

while (XPending(X_display))
I_GetEvent();

// Warp the pointer back to the middle of the window
// or it will wander off - that is, the game will
// loose input focus within X11.
if (grabMouse)
{
if (!--doPointerWarp)
{
XWarpPointer(X_display,
None,
X_mainWindow,
0, 0,
0, 0,
X_width/2, X_height/2);

doPointerWarp = POINTER_WARP_COUNTDOWN;
}
}

mousemoved = false;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions experiments/linux/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"project": "linux",
"org": "linux",
"repository": "https://github.com/",
"license": ""
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"org": "nginx",
"project": "nginx",
"repository": "https://github.com/nginx/nginx",
"license": "BSD-2-Clause License",
"snippets": "nginx"
"license": "BSD-2-Clause License"
}
Loading

0 comments on commit beb3a77

Please sign in to comment.