Skip to content

Commit

Permalink
Add screen wipe segue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doomhack committed Nov 28, 2021
1 parent c15bf20 commit 257a8e5
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 43 deletions.
4 changes: 2 additions & 2 deletions GBADoom.pro
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,6 @@ win32-msvc* {
# LIBS += $$PWD/codeprophet.lib
# QMAKE_CXXFLAGS += /GH /Gh
# QMAKE_CFLAGS += /GH /Gh
QMAKE_CFLAGS += /fsanitize=address
QMAKE_CXXFLAGS += /fsanitize=address
# QMAKE_CFLAGS += /fsanitize=address
# QMAKE_CXXFLAGS += /fsanitize=address
}
Binary file modified GBADoomMemory.xlsx
Binary file not shown.
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@ INCLUDES := include
DATA := data
MUSIC := music

#---------------------------------------------------------------------------------
# Disable LTO for IWRAM
#---------------------------------------------------------------------------------
%.iwram.o: %.iwram.cpp
$(SILENTMSG) $(notdir $<)
$(SILENTCMD)$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.iwram.d $(CXXFLAGS) -fno-lto -marm -c $< -o $@ $(ERROR_FILTER)

#---------------------------------------------------------------------------------
%.iwram.o: %.iwram.c
$(SILENTMSG) $(notdir $<)
$(SILENTCMD)$(CC) -MMD -MP -MF $(DEPSDIR)/$*.iwram.d $(CFLAGS) -fno-lto -marm -c $< -o $@ $(ERROR_FILTER)

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork

CFLAGS := -g -Wall -O3 -fgcse-after-reload\
-mcpu=arm7tdmi -mtune=arm7tdmi\
CFLAGS := -g -Wall -O3 -fgcse-after-reload -gdwarf-4\
-mcpu=arm7tdmi -mtune=arm7tdmi -flto\
$(ARCH)

CFLAGS += $(INCLUDE)
Expand Down
1 change: 1 addition & 0 deletions include/f_wipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* SCREEN WIPE PACKAGE
*/

void wipe_initMelt();
int wipe_ScreenWipe (int ticks);
int wipe_StartScreen(void);
int wipe_EndScreen (void);
Expand Down
2 changes: 1 addition & 1 deletion include/global_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ boolean castdeath;
//f_wipe.c
//******************************************************************************

int wipe_tick;
short y_lookup[SCREENWIDTH];

//******************************************************************************
//g_game.c
Expand Down
2 changes: 2 additions & 0 deletions include/i_system_e32.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void I_Quit_e32();

unsigned short* I_GetBackBuffer();

unsigned short* I_GetFrontBuffer();

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 3 additions & 1 deletion source/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ static void D_Wipe(void)
boolean done;
int wipestart = I_GetTime () - 1;

wipe_initMelt();

do
{
int nowtime, tics;
Expand All @@ -147,7 +149,7 @@ static void D_Wipe(void)
wipestart = nowtime;
done = wipe_ScreenWipe(tics);

I_UpdateNoBlit();
I_UpdateNoBlit();
M_Drawer(); // menu is drawn even on top of wipes

} while (!done);
Expand Down
120 changes: 83 additions & 37 deletions source/f_wipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*-----------------------------------------------------------------------------
*/

//Most of this code is backported from https://github.com/next-hack/nRF52840Doom


#ifdef HAVE_CONFIG_H
#include "config.h"
Expand All @@ -44,6 +46,8 @@
#include "m_random.h"
#include "f_wipe.h"
#include "global_data.h"
#include "i_system_e32.h"


#ifdef __arm__
#include <gba.h>
Expand All @@ -55,59 +59,101 @@

int wipe_StartScreen(void)
{
_g->wipe_tick = 0;
return 0;
}

int wipe_EndScreen(void)
{
_g->wipe_tick = 0;
return 0;
}

// killough 3/5/98: reformatted and cleaned up
int wipe_ScreenWipe(int ticks)
// oh man, why aren't you commenting anything ?
// 2021-08-08 next-hack: commented and modified to use the dual buffer.
static int wipe_doMelt(int ticks)
{
unsigned int wipepos;
boolean done = true;

//Do a pageflip on the 16th tick.
boolean pageflip = (_g->wipe_tick < 16) && (_g->wipe_tick + ticks >= 16);
unsigned short* backbuffer = I_GetBackBuffer();
unsigned short* frontbuffer = I_GetFrontBuffer();

_g->wipe_tick += ticks;

int wipeticks = _g->wipe_tick;

if(wipeticks >= 32)
{
wipeticks = 32;
wipepos = 0;
}
else if(wipeticks < 16)
{
wipepos = wipeticks;
}
else //16->31
while (ticks--)
{
wipepos = 31 - wipeticks;
for (int i = 0; i < SCREENWIDTH; i++)
{
if (_g->y_lookup[i] < 0)
{
_g->y_lookup[i]++;
done = false;
continue;
}

// scroll down columns, which are still visible
if (_g->y_lookup[i] < SCREENHEIGHT)
{
/* cph 2001/07/29 -
* The original melt rate was 8 pixels/sec, i.e. 25 frames to melt
* the whole screen, so make the melt rate depend on SCREENHEIGHT
* so it takes no longer in high res
*/
int dy = (_g->y_lookup[i] < 16) ? _g->y_lookup[i] + 1 : SCREENHEIGHT / 25;
// At most dy shall be so that the column is shifted by SCREENHEIGHT (i.e. just
// invisible)
if (_g->y_lookup[i] + dy >= SCREENHEIGHT)
dy = SCREENHEIGHT - _g->y_lookup[i];

unsigned short* s = &frontbuffer[i] + ((SCREENHEIGHT - dy - 1) * SCREENPITCH);

unsigned short* d = &frontbuffer[i] + ((SCREENHEIGHT - 1) * SCREENPITCH);

// scroll down the column. Of course we need to copy from the bottom... up to
// SCREENHEIGHT - yLookup - dy

for (int j = SCREENHEIGHT - _g->y_lookup[i] - dy; j; j--)
{
*d = *s;
d += -SCREENPITCH;
s += -SCREENPITCH;
}

// copy new screen. We need to copy only between y_lookup and + dy y_lookup
s = &backbuffer[i] + _g->y_lookup[i] * SCREENPITCH;
d = &frontbuffer[i] + _g->y_lookup[i] * SCREENPITCH;

for (int j = 0 ; j < dy; j++)
{
*d = *s;
d += SCREENPITCH;
s += SCREENPITCH;
}

_g->y_lookup[i] += dy;
done = false;
}
}
}
return done;
}

#ifdef __arm__
REG_BLDCNT = 0xc4;
REG_BLDY = wipepos;

VBlankIntrWait();
#endif
void wipe_initMelt()
{
// setup initial column positions (y<0 => not ready to scroll yet)
_g->y_lookup[0] = -(M_Random() % 16);
for (int i = 1; i < SCREENWIDTH; i++)
{
int r = (M_Random() % 3) - 1;

if(pageflip)
I_FinishUpdate();
_g->y_lookup[i] = _g->y_lookup[i - 1] + r;

if(wipeticks >= 32)
{
#ifdef __arm__
REG_BLDCNT = 0;
#endif
return 1;
if (_g->y_lookup[i] > 0)
_g->y_lookup[i] = 0;
else if (_g->y_lookup[i] == -16)
_g->y_lookup[i] = -15;
}
}

return 0;

int wipe_ScreenWipe(int ticks)
{
// do a piece of wipe-in
return wipe_doMelt(ticks);
}
6 changes: 6 additions & 0 deletions source/i_system_e32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ unsigned char* thearray = NULL;
int thesize;

unsigned short backbuffer[120 *160];
unsigned short frontbuffer[120 *160];

//**************************************************************************************

Expand Down Expand Up @@ -82,6 +83,11 @@ unsigned short* I_GetBackBuffer()
return &backbuffer[0];
}

unsigned short* I_GetFrontBuffer()
{
return &frontbuffer[0];
}

//**************************************************************************************

void I_CreateWindow_e32()
Expand Down
10 changes: 10 additions & 0 deletions source/i_system_gba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ unsigned short* I_GetBackBuffer()

//**************************************************************************************

unsigned short* I_GetFrontBuffer()
{
if(REG_DISPCNT & DCNT_PAGE)
return (unsigned short*)VID_PAGE2;

return (unsigned short*)VID_PAGE1;
}

//**************************************************************************************

void I_CreateWindow_e32()
{

Expand Down

0 comments on commit 257a8e5

Please sign in to comment.