서버에서 바로 빌드하고 고칠 수 있게 저장소 줄바꿈을 LF로 맞췄습니다. CRLF로 들어가 있던 sh 빌드 스크립트도 이제 리눅스에서 그대로 돌아갑니다. 내용은 바뀌지 않았습니다.
169 lines
5.1 KiB
C
169 lines
5.1 KiB
C
/**
|
|
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
|
|
*
|
|
* This port is based on the excellent doomhack's GBA Doom Port,
|
|
* with Kippykip additions.
|
|
*
|
|
* Several data structures and functions have been optimized
|
|
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
|
|
* Z-Depth Light has been restored with almost no RAM consumption!
|
|
* Tons of speed optimizations have been done, and the game now
|
|
* runs extremely fast, despite the much higher 3D resolution with
|
|
* respect to GBA.
|
|
*
|
|
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
|
|
* based on BOOM, a modified and improved DOOM engine
|
|
* Copyright (C) 1999 by
|
|
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
|
|
* Copyright (C) 1999-2000 by
|
|
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
|
|
* Copyright 2005, 2006 by
|
|
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
|
|
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
|
|
* on nRF52840 port.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
* 02111-1307, USA.
|
|
*
|
|
* DESCRIPTION:
|
|
* next-hack: On this port no multplayer is supported.
|
|
* Here we use the display-buffer (15kB) as stack, so we
|
|
* do not need to worry for stack overflows at least when dealing
|
|
* with Doom game-logic handling.
|
|
*
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
#include <sys/types.h>
|
|
#ifdef HAVE_UNISTD_H
|
|
#include <unistd.h>
|
|
#endif
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
#include <sys/wait.h>
|
|
#endif
|
|
|
|
#include "doomtype.h"
|
|
#include "doomstat.h"
|
|
#include "d_net.h"
|
|
#include "z_zone.h"
|
|
|
|
#include "d_main.h"
|
|
#include "g_game.h"
|
|
#include "m_menu.h"
|
|
|
|
#include "protocol.h"
|
|
#include "i_network.h"
|
|
#include "i_system.h"
|
|
#include "i_main.h"
|
|
#include "i_video.h"
|
|
#include "lprintf.h"
|
|
|
|
#include "global_data.h"
|
|
#include "graphics.h"
|
|
void D_InitNetGame(void)
|
|
{
|
|
_g->playeringame = true;
|
|
}
|
|
|
|
void D_BuildNewTiccmds(void)
|
|
{
|
|
int newtics = I_GetTime() - _g->lastmadetic;
|
|
_g->lastmadetic += newtics;
|
|
|
|
while (newtics--)
|
|
{
|
|
I_StartTic();
|
|
if (_g->maketic - _g->gametic > 3)
|
|
break;
|
|
|
|
G_BuildTiccmd(&_g->netcmd);
|
|
_g->maketic++;
|
|
}
|
|
}
|
|
|
|
void TryRunTics2(void)
|
|
{
|
|
int runtics;
|
|
int entertime = I_GetTime();
|
|
|
|
// Wait for tics to run
|
|
static int plog_tr; int plog_b = 0;
|
|
if (plog_tr < 3) PLOG(0x300 + plog_tr * 0x10);
|
|
while (1)
|
|
{
|
|
D_BuildNewTiccmds();
|
|
if (plog_tr < 3 && !plog_b) { PLOG(0x301 + plog_tr * 0x10); plog_b = 1; }
|
|
|
|
runtics = (_g->maketic) - _g->gametic;
|
|
if (runtics <= 0)
|
|
{
|
|
if (I_GetTime() - entertime > 10)
|
|
{
|
|
M_Ticker();
|
|
if (plog_tr < 3) { PLOG(0x30F + plog_tr * 0x10); plog_tr++; }
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
|
|
while (runtics-- > 0)
|
|
{
|
|
|
|
if (_g->advancedemo)
|
|
D_DoAdvanceDemo();
|
|
if (plog_tr < 3) PLOG(0x302 + plog_tr * 0x10);
|
|
M_Ticker();
|
|
if (plog_tr < 3) PLOG(0x303 + plog_tr * 0x10);
|
|
G_Ticker();
|
|
if (plog_tr < 3) PLOG(0x304 + plog_tr * 0x10);
|
|
|
|
_g->gametic++;
|
|
}
|
|
if (plog_tr < 3) plog_tr++;
|
|
}
|
|
void TryRunTics(void)
|
|
{
|
|
#ifdef NO_STACK_SWITCH
|
|
/* v0.1.9: game loop on the normal stack in SRAM instead of in the framebuffer (RAM20) */
|
|
TryRunTics2();
|
|
return;
|
|
#endif
|
|
// "displayData.displayFrameBuffer[displayData.workingBuffer]" is a very large buffer, which will be modified
|
|
// by the game rendering AFTER the game logic has been called, and for sure is not the one used by the DMA.
|
|
// Why not using it as stack ?
|
|
// Note, why "-SCREEN_WIDTH * ST_HEIGHT - 4"? Because in this way, when the status bar does not need an update (i.e. no change in ammo, health, etc.)
|
|
// we can avoid redrawing it, saving a lot of time.
|
|
__asm volatile
|
|
(
|
|
"STR SP, [%[newStack]], #-4\n\t"
|
|
"MOV SP, %[newStack]\n\t"
|
|
: : [newStack] "r" ((uint8_t*) displayData.displayFrameBuffer[displayData.workingBuffer] + sizeof(displayData.displayFrameBuffer[0]) - SCREENWIDTH * ST_HEIGHT - 4)
|
|
);
|
|
// actually run doom game
|
|
TryRunTics2();
|
|
// restore stack
|
|
__asm volatile
|
|
(
|
|
"LDR SP, [%[newStack]]\n\t"
|
|
: : [newStack] "r" ((uint8_t*) displayData.displayFrameBuffer[displayData.workingBuffer] + sizeof(displayData.displayFrameBuffer[0]) - SCREENWIDTH * ST_HEIGHT - 4)
|
|
);
|
|
|
|
}
|