diff --git a/Makefile b/Makefile index e3dc527..a85d3a3 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ CPU_FLAGS = -I src -I /usr/local/include/SDL2 -I/usr/include/libpng16 -I/opt/pop IPU_FLAGS = -I src/ipu \ --target=ipu2 \ -Wall -Werror -Wno-unused-variable \ - -O2 + -O2 -g all: build build/doom build/ipu_rt.gp diff --git a/src/ipu/am_map.c b/src/ipu/am_map.c index d197952..5bc5ca3 100644 --- a/src/ipu/am_map.c +++ b/src/ipu/am_map.c @@ -241,6 +241,7 @@ static boolean stopped = true; // // // +__SUPER__ void AM_activateNewScale(void) { m_x += m_w / 2; m_y += m_h / 2; @@ -255,6 +256,7 @@ void AM_activateNewScale(void) { // // // +__SUPER__ void AM_saveScaleAndLoc(void) { old_m_x = m_x; old_m_y = m_y; @@ -265,6 +267,7 @@ void AM_saveScaleAndLoc(void) { // // // +__SUPER__ void AM_restoreScaleAndLoc(void) { m_w = old_m_w; @@ -287,6 +290,7 @@ void AM_restoreScaleAndLoc(void) { // // adds a marker at the current location // +__SUPER__ void AM_addMark(void) { markpoints[markpointnum].x = m_x + m_w / 2; markpoints[markpointnum].y = m_y + m_h / 2; @@ -297,6 +301,7 @@ void AM_addMark(void) { // Determines bounding box of all vertices, // sets global variables controlling zoom range. // +__SUPER__ void AM_findMinMaxBoundaries(void) { int i; fixed_t a; @@ -333,6 +338,7 @@ void AM_findMinMaxBoundaries(void) { // // // +__SUPER__ void AM_changeWindowLoc(void) { if (m_paninc.x || m_paninc.y) { followplayer = 0; @@ -359,6 +365,7 @@ void AM_changeWindowLoc(void) { // // // +__SUPER__ void AM_initVariables(void) { int pnum; // static event_t st_notify = {ev_keyup, AM_MSGENTERED, 0, 0}; // LATER @@ -409,6 +416,7 @@ void AM_initVariables(void) { } +__SUPER__ void AM_clearMarks(void) { int i; @@ -421,6 +429,7 @@ void AM_clearMarks(void) { // should be called at the start of every level // right now, i figure it out myself // +__SUPER__ void AM_LevelInit(void) { leveljuststarted = 0; @@ -441,6 +450,7 @@ void AM_LevelInit(void) { // // // +__SUPER__ void AM_Stop(void) { // static event_t st_notify = {0, ev_keyup, AM_MSGEXITED, 0}; // LATER @@ -453,6 +463,7 @@ void AM_Stop(void) { // // // +__SUPER__ void AM_Start(void) { static int lastlevel = -1, lastepisode = -1; @@ -471,6 +482,7 @@ void AM_Start(void) { // // set the window scale to the maximum size // +__SUPER__ void AM_minOutWindowScale(void) { scale_mtof = min_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); @@ -480,6 +492,7 @@ void AM_minOutWindowScale(void) { // // set the window scale to the minimum size // +__SUPER__ void AM_maxOutWindowScale(void) { scale_mtof = max_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); @@ -489,6 +502,7 @@ void AM_maxOutWindowScale(void) { // // Handle events (user inputs) in automap mode // +__SUPER__ boolean AM_Responder(event_t *ev) { int rc; @@ -637,6 +651,7 @@ boolean AM_Responder(event_t *ev) { // // Zooming // +__SUPER__ void AM_changeWindowScale(void) { // Change the scaling multipliers @@ -654,6 +669,7 @@ void AM_changeWindowScale(void) { // // // +__SUPER__ void AM_doFollowPlayer(void) { if (f_oldloc.x != am_playerpos.x || f_oldloc.y != am_playerpos.y) { @@ -674,6 +690,7 @@ void AM_doFollowPlayer(void) { // // Updates on Game Tick // +__SUPER__ void AM_Ticker(void) { if (!automapactive) return; @@ -698,6 +715,7 @@ void AM_Ticker(void) { // // Clear automap frame buffer. // +__SUPER__ void AM_clearFB(int color) { memset(fb, color, f_w * f_h * sizeof(*fb)); } // @@ -707,6 +725,7 @@ void AM_clearFB(int color) { memset(fb, color, f_w * f_h * sizeof(*fb)); } // faster reject and precalculated slopes. If the speed is needed, // use a hash algorithm to handle the common cases. // +__SUPER__ boolean AM_clipMline(mline_t *ml, fline_t *fl) { enum { LEFT = 1, RIGHT = 2, BOTTOM = 4, TOP = 8 }; @@ -821,6 +840,7 @@ boolean AM_clipMline(mline_t *ml, fline_t *fl) { // // Classic Bresenham w/ whatever optimizations needed for speed // +__SUPER__ void AM_drawFline(fline_t *fl, int color) { register int x; register int y; @@ -886,6 +906,7 @@ void AM_drawFline(fline_t *fl, int color) { // // Clip lines, draw visible part sof lines. // +__SUPER__ void AM_drawMline(mline_t *ml, int color) { static fline_t fl; @@ -896,6 +917,7 @@ void AM_drawMline(mline_t *ml, int color) { // // Draws flat (floor/ceiling tile) aligned grid lines. // +__SUPER__ void AM_drawGrid(int color) { fixed_t x, y; fixed_t start, end; @@ -938,6 +960,7 @@ void AM_drawGrid(int color) { // Determines visible lines, draws them. // This is LineDef based, not LineSeg based. // +__SUPER__ void AM_drawWalls(void) { int i; static mline_t l; @@ -986,18 +1009,20 @@ void AM_drawWalls(void) { // Rotation in 2D. // Used to rotate player arrow line character. // +__SUPER__ void AM_rotate(fixed_t *x, fixed_t *y, angle_t a) { fixed_t tmpx; tmpx = FixedMul(*x, finecosine[a >> ANGLETOFINESHIFT]) - - FixedMul(*y, IPU_finesine(a >> ANGLETOFINESHIFT)); + FixedMul(*y, finesine[a >> ANGLETOFINESHIFT]); - *y = FixedMul(*x, IPU_finesine(a >> ANGLETOFINESHIFT)) + + *y = FixedMul(*x, finesine[a >> ANGLETOFINESHIFT]) + FixedMul(*y, finecosine[a >> ANGLETOFINESHIFT]); *x = tmpx; } +__SUPER__ void AM_drawLineCharacter(mline_t *lineguy, int lineguylines, fixed_t scale, angle_t angle, int color, fixed_t x, fixed_t y) { int i; @@ -1036,6 +1061,7 @@ void AM_drawLineCharacter(mline_t *lineguy, int lineguylines, fixed_t scale, } } +__SUPER__ void AM_drawPlayers(void) { int i; player_t *p; @@ -1074,6 +1100,7 @@ void AM_drawPlayers(void) { */ } +__SUPER__ void AM_drawMarks(void) { int i, fx, fy, w, h; @@ -1092,10 +1119,12 @@ void AM_drawMarks(void) { } } +__SUPER__ void AM_drawCrosshair(int color) { fb[(f_w * (f_h + 1)) / 2] = color; // single point for now } +__SUPER__ void AM_drawIPUWatermark(int color) { const int wmx = 283, wmy = 160; for (int i = 0; i < arrlen(ipu_watermark_lines); ++i) { @@ -1106,6 +1135,7 @@ void AM_drawIPUWatermark(int color) { } } +__SUPER__ void AM_Drawer(pixel_t* fb_tensor) { fb = fb_tensor; // JOSEF V_UseBuffer(fb); diff --git a/src/ipu/am_map.h b/src/ipu/am_map.h index 665bd5b..5376525 100644 --- a/src/ipu/am_map.h +++ b/src/ipu/am_map.h @@ -22,6 +22,7 @@ #include "d_event.h" #include "doomtype.h" #include "m_cheat.h" +#include "ipu_utils.h" // Used by ST StatusBar stuff. #define AM_MSGHEADER (('a' << 24) + ('m' << 16)) @@ -29,18 +30,18 @@ #define AM_MSGEXITED (AM_MSGHEADER | ('x' << 8)) // Called by main loop. -boolean AM_Responder(event_t *ev); +__SUPER__ boolean AM_Responder(event_t *ev); // Called by main loop. -void AM_Ticker(void); +__SUPER__ void AM_Ticker(void); // Called by main loop, // called instead of view drawer if automap active. -void AM_Drawer(void); +__SUPER__ void AM_Drawer(void); // Called to force the automap to quit // if the level is completed while it is up. -void AM_Stop(void); +__SUPER__ void AM_Stop(void); extern cheatseq_t cheat_amap; diff --git a/src/ipu/g_game.c b/src/ipu/g_game.c index c3c18f7..1615ac8 100644 --- a/src/ipu/g_game.c +++ b/src/ipu/g_game.c @@ -69,6 +69,7 @@ int testcontrols_mousespeed; // // G_DoLoadLevel // +__SUPER__ void G_DoLoadLevel(void) { int i; @@ -136,6 +137,7 @@ void G_DoLoadLevel(void) { // G_Ticker // Make ticcmd_ts for the players. // +__SUPER__ void G_Ticker(void) { int i; int buf; @@ -295,6 +297,7 @@ void G_Ticker(void) { // G_Responder // Get info needed to make ticcmd_ts for the players. // +__SUPER__ boolean G_Responder(event_t *ev) { /* LATER diff --git a/src/ipu/g_game.h b/src/ipu/g_game.h index 528779d..ed48bf0 100644 --- a/src/ipu/g_game.h +++ b/src/ipu/g_game.h @@ -24,8 +24,11 @@ #include "d_ticcmd.h" #include "doomtype.h" +#include "ipu_utils.h" + // JOSEF TMP +__SUPER__ void G_DoLoadLevel(void); // @@ -69,8 +72,8 @@ void G_WorldDone(void); void G_BuildTiccmd(ticcmd_t *cmd, int maketic); -void G_Ticker(void); -boolean G_Responder(event_t *ev); +__SUPER__ void G_Ticker(void); +__SUPER__ boolean G_Responder(event_t *ev); void G_ScreenShot(void); diff --git a/src/ipu/g_game_codelets.cpp b/src/ipu/g_game_codelets.cpp index 0f51805..4102f53 100644 --- a/src/ipu/g_game_codelets.cpp +++ b/src/ipu/g_game_codelets.cpp @@ -4,16 +4,16 @@ #include "ipu_transfer.h" extern "C" { - void G_DoLoadLevel(void); - void G_Ticker(void); - boolean G_Responder(event_t *ev); + __SUPER__ void G_DoLoadLevel(void); + __SUPER__ void G_Ticker(void); + __SUPER__ boolean G_Responder(event_t *ev); }; -class G_DoLoadLevel_Vertex : public poplar::Vertex { +class G_DoLoadLevel_Vertex : public poplar::SupervisorVertex { public: poplar::Input> miscValues; - bool compute() { + __SUPER__ bool compute() { IPU_G_LoadLevel_UnpackMiscValues((G_LoadLevel_MiscValues_t*)&miscValues[0]); G_DoLoadLevel(); return true; @@ -21,20 +21,20 @@ class G_DoLoadLevel_Vertex : public poplar::Vertex { }; -class G_Ticker_Vertex : public poplar::Vertex { +class G_Ticker_Vertex : public poplar::SupervisorVertex { public: poplar::Input> miscValues; - bool compute() { + __SUPER__ bool compute() { IPU_G_Ticker_UnpackMiscValues((G_Ticker_MiscValues_t*)&miscValues[0]); G_Ticker(); return true; } }; -class G_Responder_Vertex : public poplar::Vertex { +class G_Responder_Vertex : public poplar::SupervisorVertex { public: poplar::Input> miscValues; - bool compute() { + __SUPER__ bool compute() { // Respond to each of the buffered events in turn G_Responder_MiscValues_t* ev_buf = (G_Responder_MiscValues_t*)&miscValues[0]; for (int i = 0; i < ev_buf->num_ev; ++i) { diff --git a/src/ipu/ipu_malloc.c b/src/ipu/ipu_malloc.c index 9fb36c0..8d70ece 100644 --- a/src/ipu/ipu_malloc.c +++ b/src/ipu/ipu_malloc.c @@ -21,7 +21,7 @@ static unsigned char PU_STATIC_pool[PU_STATIC_max_size]; static unsigned char PU_LEVEL_pool[PU_LEVEL_max_size]; static unsigned char PU_TMP_pool[PU_TMP_max_size]; - +__SUPER__ void* IPU_level_malloc(int size, const char* name) { void* ret = (void*)(&PU_LEVEL_pool[PU_LEVEL_size]); PU_LEVEL_size = ALIGN32(PU_LEVEL_size + size); @@ -39,10 +39,12 @@ void* IPU_level_malloc(int size, const char* name) { return ret; } +__SUPER__ void IPU_level_free() { PU_LEVEL_size = 0; } +__SUPER__ void* IPU_static_malloc(int size, const char* name) { void* ret = (void*)(&PU_STATIC_pool[PU_STATIC_size]); PU_STATIC_size = ALIGN32(PU_STATIC_size + size); @@ -62,6 +64,7 @@ void* IPU_static_malloc(int size, const char* name) { static unsigned PU_TMP_count = 0; +__SUPER__ void* IPU_tmp_malloc(int size, const char* name) { void* ret = (void*)(&PU_TMP_pool[PU_TMP_size]); PU_TMP_size = ALIGN32(PU_TMP_size + size); @@ -81,6 +84,7 @@ void* IPU_tmp_malloc(int size, const char* name) { } +__SUPER__ void IPU_tmp_free(void* ptr) { (void) ptr; PU_TMP_count -= 1; @@ -90,6 +94,7 @@ void IPU_tmp_free(void* ptr) { } +__SUPER__ void IPU_summarise_malloc() { if (tileID != 0) return; diff --git a/src/ipu/ipu_malloc.h b/src/ipu/ipu_malloc.h index 663c704..9ff2695 100644 --- a/src/ipu/ipu_malloc.h +++ b/src/ipu/ipu_malloc.h @@ -4,17 +4,19 @@ extern "C" { #endif +#include "ipu_utils.h" -void* IPU_static_malloc(int size, const char* name); + +__SUPER__ void* IPU_static_malloc(int size, const char* name); // There is no IPU_static_free() :D -void* IPU_level_malloc(int size, const char* name); -void IPU_level_free(void); +__SUPER__ void* IPU_level_malloc(int size, const char* name); +__SUPER__ void IPU_level_free(void); -void* IPU_tmp_malloc(int size, const char* name); -void IPU_tmp_free(void* ptr); +__SUPER__ void* IPU_tmp_malloc(int size, const char* name); +__SUPER__ void IPU_tmp_free(void* ptr); -void IPU_summarise_malloc(void); +__SUPER__ void IPU_summarise_malloc(void); #ifdef __cplusplus diff --git a/src/ipu/ipu_texturetiles.cpp b/src/ipu/ipu_texturetiles.cpp index 7d9287a..106a88b 100644 --- a/src/ipu/ipu_texturetiles.cpp +++ b/src/ipu/ipu_texturetiles.cpp @@ -3,7 +3,6 @@ #include "ipu_utils.h" #include "ipu_texturetiles.h" -// #include "../../xcom.hpp" #define NUMCACHECOLS (20) @@ -11,8 +10,7 @@ static byte columnCache[NUMCACHECOLS][CACHECOLSIZE]; -extern "C" -void IPU_R_InitColumnRequester(void) { +extern "C" __SUPER__ void IPU_R_InitColumnRequester(void) { // TMP colours for (int i = 0; i < NUMCACHECOLS; ++i) { unsigned* col = (unsigned*) columnCache[i]; @@ -28,6 +26,6 @@ void IPU_R_InitColumnRequester(void) { } -extern "C" byte* IPU_R_RequestColumn(int texture, int column) { +extern "C" __SUPER__ byte* IPU_R_RequestColumn(int texture, int column) { return columnCache[texture % NUMCACHECOLS]; } \ No newline at end of file diff --git a/src/ipu/ipu_texturetiles.h b/src/ipu/ipu_texturetiles.h index e88dc94..1554824 100644 --- a/src/ipu/ipu_texturetiles.h +++ b/src/ipu/ipu_texturetiles.h @@ -12,9 +12,9 @@ extern "C" { -void IPU_R_InitColumnRequester(void); +__SUPER__ void IPU_R_InitColumnRequester(void); -byte* IPU_R_RequestColumn(int texture, int column); +__SUPER__ byte* IPU_R_RequestColumn(int texture, int column); diff --git a/src/ipu/ipu_transfer.c b/src/ipu/ipu_transfer.c index 24db13b..97b493b 100644 --- a/src/ipu/ipu_transfer.c +++ b/src/ipu/ipu_transfer.c @@ -14,6 +14,7 @@ extern int setdetail; // r_main.c int gamelumpnum; +__SUPER__ void IPU_G_LoadLevel_UnpackMiscValues(G_LoadLevel_MiscValues_t* pack) { gameepisode = pack->gameepisode; gamemap = pack->gamemap; @@ -25,6 +26,7 @@ void IPU_G_LoadLevel_UnpackMiscValues(G_LoadLevel_MiscValues_t* pack) { } } +__SUPER__ void IPU_G_Ticker_UnpackMiscValues(G_Ticker_MiscValues_t* pack) { gamestate = pack->gamestate; if (gamestate != GS_LEVEL) @@ -52,6 +54,7 @@ void IPU_G_Ticker_UnpackMiscValues(G_Ticker_MiscValues_t* pack) { } +__SUPER__ void IPU_Setup_UnpackMarkNums(const unsigned char* buf) { short* offsets = (short*) buf; const int offsetssize = 10 * sizeof(short); @@ -62,11 +65,12 @@ void IPU_Setup_UnpackMarkNums(const unsigned char* buf) { } +__SUPER__ void IPU_R_RenderPlayerView_UnpackMiscValues(R_RenderPlayerView_MiscValues_t* pack) { // Nothing to unpack } - +__SUPER__ void IPU_R_ExecuteSetViewSize_UnpackMiscValues(R_ExecuteSetViewSize_MiscValues_t* pack) { setblocks = pack->setblocks; setdetail = pack->setdetail; diff --git a/src/ipu/ipu_transfer.h b/src/ipu/ipu_transfer.h index 4a948ad..4b0204f 100644 --- a/src/ipu/ipu_transfer.h +++ b/src/ipu/ipu_transfer.h @@ -5,6 +5,7 @@ extern "C" { #endif #include "v_patch.h" +#include "ipu_utils.h" #include "ipu_interface.h" @@ -13,10 +14,10 @@ extern IPUTransfer_playerstate_t am_playerpos; extern patch_t* marknums[10]; extern unsigned char markbuf[IPUAMMARKBUFSIZE]; -void IPU_G_LoadLevel_UnpackMiscValues(G_LoadLevel_MiscValues_t* pack); -void IPU_G_Ticker_UnpackMiscValues(G_Ticker_MiscValues_t* pack); -void IPU_R_RenderPlayerView_UnpackMiscValues(R_RenderPlayerView_MiscValues_t* pack); -void IPU_R_ExecuteSetViewSize_UnpackMiscValues(R_ExecuteSetViewSize_MiscValues_t* pack); +__SUPER__ void IPU_G_LoadLevel_UnpackMiscValues(G_LoadLevel_MiscValues_t* pack); +__SUPER__ void IPU_G_Ticker_UnpackMiscValues(G_Ticker_MiscValues_t* pack); +__SUPER__ void IPU_R_RenderPlayerView_UnpackMiscValues(R_RenderPlayerView_MiscValues_t* pack); +__SUPER__ void IPU_R_ExecuteSetViewSize_UnpackMiscValues(R_ExecuteSetViewSize_MiscValues_t* pack); #ifdef __cplusplus } diff --git a/src/ipu/ipu_utils.h b/src/ipu/ipu_utils.h index 9fd8a27..6cef057 100644 --- a/src/ipu/ipu_utils.h +++ b/src/ipu/ipu_utils.h @@ -1,7 +1,12 @@ #ifndef __IPU_UTILS__ #define __IPU_UTILS__ -// #define __SUPER__ __attribute__((target("supervisor"))) + +#ifdef __IPU__ +#define __SUPER__ __attribute__((target("supervisor"))) +#else +#define __SUPER__ +#endif extern int tileID; diff --git a/src/ipu/ipu_vertices.cpp b/src/ipu/ipu_vertices.cpp index e141647..81e3743 100644 --- a/src/ipu/ipu_vertices.cpp +++ b/src/ipu/ipu_vertices.cpp @@ -13,29 +13,28 @@ typedef uint8_t pixel_t; extern "C" { - void AM_LevelInit(void); - void AM_Drawer(pixel_t*); - void IPU_Setup_UnpackMarkNums(const unsigned char* buf); + __SUPER__ void AM_LevelInit(void); + __SUPER__ void AM_Drawer(pixel_t*); + __SUPER__ void IPU_Setup_UnpackMarkNums(const unsigned char* buf); }; -class AM_LevelInit_Vertex : public poplar::Vertex { +class AM_LevelInit_Vertex : public poplar::SupervisorVertex { public: - bool compute() { + __SUPER__ bool compute() { AM_LevelInit(); return true; } }; -class AM_Drawer_Vertex : public poplar::Vertex { +class AM_Drawer_Vertex : public poplar::SupervisorVertex { public: poplar::InOut> frame; - bool compute() { + __SUPER__ void compute() { assert(&frame[0] == I_VideoBuffer); AM_Drawer(&frame[0]); - return true; } }; @@ -44,8 +43,7 @@ class AM_Drawer_Vertex : public poplar::Vertex { struct IPU_Init_Vertex : public poplar::SupervisorVertex { - __attribute__((target("supervisor"))) - void compute() { + __SUPER__ void compute() { // Deduce logical tile ID int physical = __builtin_ipu_get_tile_id(); @@ -60,9 +58,6 @@ struct IPU_Init_Vertex : public poplar::SupervisorVertex { logical += 2 * row; tileID = logical; - - // IPU_R_InitColumnRequester(physical); - } }; @@ -72,18 +67,17 @@ struct IPU_Init_Vertex : public poplar::SupervisorVertex { struct IPU_MiscSetup_Vertex : public poplar::SupervisorVertex { poplar::InOut> frame; - __attribute__((target("supervisor"))) - void compute() { + __SUPER__ void compute() { I_VideoBuffer = &frame[0]; } }; -struct IPU_UnpackMarknumSprites_Vertex : public poplar::Vertex { +struct IPU_UnpackMarknumSprites_Vertex : public poplar::SupervisorVertex { poplar::Input> buf; - void compute() { + __SUPER__ void compute() { IPU_Setup_UnpackMarkNums(&buf[0]); return; } diff --git a/src/ipu/m_bbox.c b/src/ipu/m_bbox.c index 889b70c..7088a7c 100644 --- a/src/ipu/m_bbox.c +++ b/src/ipu/m_bbox.c @@ -26,7 +26,7 @@ #include - +__SUPER__ void M_ClearBox (fixed_t *box) { box[BOXTOP] = box[BOXRIGHT] = INT_MIN; @@ -34,6 +34,7 @@ void M_ClearBox (fixed_t *box) } +__SUPER__ void M_AddToBox ( fixed_t* box, diff --git a/src/ipu/m_bbox.h b/src/ipu/m_bbox.h index 958e21f..b1bbc65 100644 --- a/src/ipu/m_bbox.h +++ b/src/ipu/m_bbox.h @@ -33,13 +33,8 @@ enum }; // bbox coordinates // Bounding box functions. -void M_ClearBox (fixed_t* box); - -void -M_AddToBox -( fixed_t* box, - fixed_t x, - fixed_t y ); +__SUPER__ void M_ClearBox (fixed_t* box); +__SUPER__ void M_AddToBox(fixed_t* box, fixed_t x, fixed_t y); #endif diff --git a/src/ipu/m_fixed.c b/src/ipu/m_fixed.cpp similarity index 50% rename from src/ipu/m_fixed.c rename to src/ipu/m_fixed.cpp index 6d37d17..4ee799d 100644 --- a/src/ipu/m_fixed.c +++ b/src/ipu/m_fixed.cpp @@ -18,23 +18,28 @@ +extern "C" { #include #include #include "m_fixed.h" +} +#include + +#include "print.h" - +extern "C" +__SUPER__ int abs(int x) { return (x < 0) ? -x : x; } // Fixme. __USE_C_FIXED__ or something. -fixed_t -FixedMul -( fixed_t a, - fixed_t b ) +extern "C" +__SUPER__ +fixed_t FixedMul(fixed_t a, fixed_t b) { return ((int64_t) a * (int64_t) b) >> FRACBITS; // JOSEF: What about this? fewer inst. @@ -47,23 +52,43 @@ FixedMul +struct DivWorker : public poplar::Vertex { + fixed_t a, b; + void compute() { + // Using int64_ caused some weird errors. So use double instead...? + // a = (((int64_t) a) << FRACBITS) / b; + a = ((double) a * FRACUNIT) / (double) b; + } +}; + // // FixedDiv, C version. // - +extern "C" +__SUPER__ fixed_t FixedDiv(fixed_t a, fixed_t b) { - if ((abs(a) >> 14) >= abs(b)) - { - return (a^b) < 0 ? INT_MIN : INT_MAX; - } - else - { - int64_t result; + if ((abs(a) >> 14) >= abs(b)) { + return (a^b) < 0 ? INT_MIN : INT_MAX; + } else { + // int64_t result; // JOSEF + // result = ((int64_t) a << FRACBITS) / b; + // return (fixed_t) result; - result = ((int64_t) a << FRACBITS) / b; - - return (fixed_t) result; + DivWorker workerArgs; + unsigned workerArgsPtr = (unsigned)&workerArgs - TMEM_BASE_ADDR; + workerArgs.a = a; + workerArgs.b = b; + void* workerFn; + asm volatile("setzi %0, __runCodelet_DivWorker" : [workerFn] "+r"(workerFn)); + asm volatile( + "run %[workerFn], %[workerArgs], 0\n" + "sync %[zone]\n" + : [workerFn] "+r"(workerFn), + [workerArgs] "+r"(workerArgsPtr) + : [zone] "i"(TEXCH_SYNCZONE_LOCAL) + ); + return workerArgs.a; } } diff --git a/src/ipu/m_fixed.h b/src/ipu/m_fixed.h index 3a66c16..e152332 100644 --- a/src/ipu/m_fixed.h +++ b/src/ipu/m_fixed.h @@ -20,7 +20,7 @@ #ifndef __M_FIXED__ #define __M_FIXED__ - +#include "ipu_utils.h" // @@ -32,8 +32,8 @@ typedef int fixed_t; -fixed_t FixedMul (fixed_t a, fixed_t b); -fixed_t FixedDiv (fixed_t a, fixed_t b); +__SUPER__ fixed_t FixedMul (fixed_t a, fixed_t b); +__SUPER__ fixed_t FixedDiv (fixed_t a, fixed_t b); diff --git a/src/ipu/p_mobj.c b/src/ipu/p_mobj.c index dd92fc8..257f796 100644 --- a/src/ipu/p_mobj.c +++ b/src/ipu/p_mobj.c @@ -448,6 +448,7 @@ void P_MobjThinker(mobj_t *mobj) { // // P_SpawnMobj // +__SUPER__ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { mobj_t *mobj; state_t *st; @@ -598,6 +599,7 @@ void P_RespawnSpecials(void) { // Most of the player structure stays unchanged // between levels. // +__SUPER__ void P_SpawnPlayer(mapthing_t *mthing) { player_t *p; fixed_t x; @@ -668,6 +670,7 @@ void P_SpawnPlayer(mapthing_t *mthing) { // The fields of the mapthing should // already be in host byte order. // +__SUPER__ void P_SpawnMapThing(mapthing_t *mthing) { int i; int bit; diff --git a/src/ipu/p_setup.c b/src/ipu/p_setup.c index daf175b..a0c1f8f 100644 --- a/src/ipu/p_setup.c +++ b/src/ipu/p_setup.c @@ -12,7 +12,7 @@ #include "print.h" -void P_SpawnMapThing(mapthing_t *mthing); +__SUPER__ void P_SpawnMapThing(mapthing_t *mthing); // // MAP related Lookup tables. @@ -80,6 +80,7 @@ mapthing_t playerstarts[MAXPLAYERS]; // // P_LoadVertexes // +__SUPER__ void P_LoadVertexes(const unsigned char *buf) { byte *data; int i; @@ -130,6 +131,7 @@ sector_t *GetSectorAtNullAddress(void) { // // P_LoadSegs // +__SUPER__ void P_LoadSegs(const unsigned char *buf) { byte *data; int i; @@ -195,6 +197,7 @@ void P_LoadSegs(const unsigned char *buf) { // // P_LoadSectors // +__SUPER__ void P_LoadSectors(const unsigned char *buf) { byte *data; int i; @@ -224,6 +227,7 @@ void P_LoadSectors(const unsigned char *buf) { // // P_LoadNodes // +__SUPER__ __attribute__((optnone)) // Workaround for https://graphcore.atlassian.net/browse/LLVM-330 void P_LoadNodes(const unsigned char *buf) { int i; @@ -258,6 +262,7 @@ void P_LoadNodes(const unsigned char *buf) { // // P_LoadThings // +__SUPER__ void P_LoadThings(const unsigned char *buf) { byte *data; int i; @@ -308,6 +313,7 @@ void P_LoadThings(const unsigned char *buf) { // // P_LoadSideDefs // +__SUPER__ void P_LoadSideDefs(const unsigned char *buf) { byte *data; int i; @@ -335,6 +341,7 @@ void P_LoadSideDefs(const unsigned char *buf) { // P_LoadLineDefs // Also counts secret lines for intermissions. // +__SUPER__ void P_LoadLineDefs(const unsigned char *buf) { byte *data; int i; @@ -404,6 +411,7 @@ void P_LoadLineDefs(const unsigned char *buf) { // // P_LoadSubsectors // +__SUPER__ void P_LoadSubsectors(const unsigned char *buf) { byte *data; int i; @@ -428,6 +436,7 @@ void P_LoadSubsectors(const unsigned char *buf) { // // P_SetupLevel // +__SUPER__ void P_SetupLevel_pt0(const unsigned char unused) { int i; @@ -521,6 +530,7 @@ void P_SetupLevel_pt0(const unsigned char unused) { // // P_LoadBlockMap // +__SUPER__ void P_LoadBlockMap(const unsigned char *buf) { int i; int count; @@ -553,6 +563,7 @@ void P_LoadBlockMap(const unsigned char *buf) { // Builds sector line lists and subsector sector numbers. // Finds block bounding boxes for sectors. // +__SUPER__ void P_GroupLines(const unsigned char *buf) { (void) buf; diff --git a/src/ipu/p_setup.h b/src/ipu/p_setup.h index a30febc..7d61ecc 100644 --- a/src/ipu/p_setup.h +++ b/src/ipu/p_setup.h @@ -21,9 +21,9 @@ // NOT called by W_Ticker. Fixme. -void P_SetupLevel(); +__SUPER__ void P_SetupLevel(); // Called by startup code. -void P_Init(void); +__SUPER__ void P_Init(void); #endif diff --git a/src/ipu/p_setup_codelets.cpp b/src/ipu/p_setup_codelets.cpp index 5407d5f..82261b4 100644 --- a/src/ipu/p_setup_codelets.cpp +++ b/src/ipu/p_setup_codelets.cpp @@ -10,17 +10,17 @@ extern "C" { - void P_SetupLevel_pt0(const unsigned char *buf); - void P_LoadBlockMap(const unsigned char *buf); - void P_LoadVertexes(const unsigned char *buf); - void P_LoadSectors(const unsigned char *buf); - void P_LoadSideDefs(const unsigned char *buf); - void P_LoadLineDefs(const unsigned char *buf); - void P_LoadSubsectors(const unsigned char *buf); - void P_LoadNodes(const unsigned char *buf); - void P_LoadSegs(const unsigned char *buf); - void P_LoadThings(const unsigned char *buf); - void P_GroupLines(const unsigned char *buf); + __SUPER__ void P_SetupLevel_pt0(const unsigned char *buf); + __SUPER__ void P_LoadBlockMap(const unsigned char *buf); + __SUPER__ void P_LoadVertexes(const unsigned char *buf); + __SUPER__ void P_LoadSectors(const unsigned char *buf); + __SUPER__ void P_LoadSideDefs(const unsigned char *buf); + __SUPER__ void P_LoadLineDefs(const unsigned char *buf); + __SUPER__ void P_LoadSubsectors(const unsigned char *buf); + __SUPER__ void P_LoadNodes(const unsigned char *buf); + __SUPER__ void P_LoadSegs(const unsigned char *buf); + __SUPER__ void P_LoadThings(const unsigned char *buf); + __SUPER__ void P_GroupLines(const unsigned char *buf); }; @@ -28,11 +28,11 @@ extern "C" { // --------------- P_Setup ----------------- // -class P_SetupLevel_Vertex : public poplar::Vertex { +class P_SetupLevel_Vertex : public poplar::SupervisorVertex { poplar::Input> lumpBuf; poplar::Output lumpNum; public: - bool compute() { + __SUPER__ bool compute() { static int step = 0; int next; // Switch statements are bonkers diff --git a/src/ipu/p_tick.c b/src/ipu/p_tick.c index 18220b3..134be09 100644 --- a/src/ipu/p_tick.c +++ b/src/ipu/p_tick.c @@ -42,12 +42,13 @@ thinker_t thinkercap; // // P_InitThinkers // -void P_InitThinkers(void) { thinkercap.prev = thinkercap.next = &thinkercap; } +__SUPER__ void P_InitThinkers(void) { thinkercap.prev = thinkercap.next = &thinkercap; } // // P_AddThinker // Adds a new thinker at the end of the list. // +__SUPER__ void P_AddThinker(thinker_t *thinker) { thinkercap.prev->next = thinker; thinker->next = &thinkercap; @@ -60,6 +61,7 @@ void P_AddThinker(thinker_t *thinker) { // Deallocation is lazy -- it will not actually be freed // until its thinking turn comes up. // +__SUPER__ void P_RemoveThinker(thinker_t *thinker) { // FIXME: NOP. thinker->function.acv = (actionf_v)(-1); @@ -69,6 +71,7 @@ void P_RemoveThinker(thinker_t *thinker) { // P_AllocateThinker // Allocates memory and adds a new thinker at the end of the list. // +__SUPER__ void P_AllocateThinker(thinker_t *thinker) {} // diff --git a/src/ipu/p_tick.h b/src/ipu/p_tick.h index 804d86e..14e0b46 100644 --- a/src/ipu/p_tick.h +++ b/src/ipu/p_tick.h @@ -22,6 +22,6 @@ // Called by C_Ticker, // can call G_PlayerExited. // Carries out all thinking of monsters and players. -void P_Ticker(void); +__SUPER__ void P_Ticker(void); #endif diff --git a/src/ipu/r_bsp.c b/src/ipu/r_bsp.c index 001d6f6..67ec3db 100644 --- a/src/ipu/r_bsp.c +++ b/src/ipu/r_bsp.c @@ -47,11 +47,13 @@ sector_t *backsector; drawseg_t drawsegs[MAXDRAWSEGS]; drawseg_t *ds_p; +__SUPER__ void R_StoreWallRange(int start, int stop); // // R_ClearDrawSegs // +__SUPER__ void R_ClearDrawSegs(void) { ds_p = drawsegs; } // @@ -90,6 +92,7 @@ int bspnum; // e.g. single sided LineDefs (middle texture) // that entirely block the view. // +__SUPER__ void R_ClipSolidWallSegment(int first, int last) { cliprange_t *next; cliprange_t *start; @@ -169,6 +172,7 @@ crunch: // Does handle windows, // e.g. LineDefs with upper and lower texture. // +__SUPER__ void R_ClipPassWallSegment(int first, int last) { cliprange_t *start; @@ -209,6 +213,7 @@ void R_ClipPassWallSegment(int first, int last) { // // R_ClearClipSegs // +__SUPER__ void R_ClearClipSegs(void) { solidsegs[0].first = -0x7fffffff; // solidsegs[0].last = -1; // JOSEF @@ -224,6 +229,7 @@ void R_ClearClipSegs(void) { // Clips the given segment // and adds any visible pieces to the line list. // +__SUPER__ void R_AddLine(seg_t *line) { int x1; int x2; @@ -336,6 +342,7 @@ int checkcoord[12][4] = {{3, 0, 2, 1}, {3, 0, 2, 0}, {3, 1, 2, 0}, {0}, {2, 0, 2, 1}, {0, 0, 0, 0}, {3, 1, 3, 0}, {0}, {2, 0, 3, 1}, {2, 1, 3, 1}, {2, 1, 3, 0}}; +__SUPER__ boolean R_CheckBBox(fixed_t *bspcoord) { int boxx; int boxy; @@ -444,6 +451,7 @@ boolean R_CheckBBox(fixed_t *bspcoord) { // Add sprites of things in sector. // Draw one or more line segments. // +__SUPER__ void R_Subsector(int num) { int count; seg_t *line; @@ -526,6 +534,7 @@ void R_RenderBSPNode(int bspnum) { // // R_RenderBSPNodeNonRecursive // Non-recursive version is more suitable to IPU software stack +__SUPER__ void R_RenderBSPNodeNonRecursive() { node_t *bsp; int side; diff --git a/src/ipu/r_bsp.h b/src/ipu/r_bsp.h index 735d351..6259f00 100644 --- a/src/ipu/r_bsp.h +++ b/src/ipu/r_bsp.h @@ -48,10 +48,10 @@ extern lighttable_t **dscalelight; typedef void (*drawfunc_t)(int start, int stop); // BSP? -void R_ClearClipSegs(void); -void R_ClearDrawSegs(void); +__SUPER__ void R_ClearClipSegs(void); +__SUPER__ void R_ClearDrawSegs(void); -void R_RenderBSPNode(int bspnum); -void R_RenderBSPNodeNonRecursive(void); // Nonrecursive verion for IPU +__SUPER__ void R_RenderBSPNode(int bspnum); +__SUPER__ void R_RenderBSPNodeNonRecursive(void); // Nonrecursive verion for IPU #endif diff --git a/src/ipu/r_codelets.cpp b/src/ipu/r_codelets.cpp index f964936..18c4d80 100644 --- a/src/ipu/r_codelets.cpp +++ b/src/ipu/r_codelets.cpp @@ -12,18 +12,19 @@ extern "C" { - void R_InitTextures(int* maptex, R_Init_MiscValues_t* miscVals); - void R_RenderPlayerView(player_t *player); - void R_ExecuteSetViewSize(void); + __SUPER__ void R_InitTextures(int* maptex, R_Init_MiscValues_t* miscVals); + __SUPER__ void R_RenderPlayerView(player_t *player); + __SUPER__ void R_ExecuteSetViewSize(void); }; -struct R_Init_Vertex: public poplar::Vertex { +struct R_Init_Vertex: public poplar::SupervisorVertex { poplar::Input> miscValues; poplar::Input> lumpBuf; poplar::Output lumpNum; + __SUPER__ void compute() { static int step = 0; @@ -43,11 +44,11 @@ struct R_Init_Vertex: public poplar::Vertex { }; -struct R_RenderPlayerView_Vertex : public poplar::Vertex { +struct R_RenderPlayerView_Vertex : public poplar::SupervisorVertex { poplar::Input> miscValues; poplar::InOut> frame; - void compute() { + __SUPER__ void compute() { assert(&frame[0] == I_VideoBuffer); IPU_R_RenderPlayerView_UnpackMiscValues( @@ -60,14 +61,14 @@ struct R_RenderPlayerView_Vertex : public poplar::Vertex { }; -class R_ExecuteSetViewSize_Vertex : public poplar::Vertex { +class R_ExecuteSetViewSize_Vertex : public poplar::SupervisorVertex { public: poplar::Input> miscValues; - bool compute() { + __SUPER__ + void compute() { IPU_R_ExecuteSetViewSize_UnpackMiscValues( (R_ExecuteSetViewSize_MiscValues_t*) &miscValues[0] ); R_ExecuteSetViewSize(); - return true; } }; \ No newline at end of file diff --git a/src/ipu/r_data.c b/src/ipu/r_data.c index 984ea02..0e4a33c 100644 --- a/src/ipu/r_data.c +++ b/src/ipu/r_data.c @@ -373,6 +373,7 @@ byte *R_GetColumn(int tex, int col) { return texturecomposite[tex] + ofs; } */ +__SUPER__ static void GenerateTextureHashTable(void) { IPUpatchlesstexture_t **rover; int i; @@ -417,6 +418,7 @@ static void GenerateTextureHashTable(void) { // Initializes the texture list // with the textures from the world map. // +__SUPER__ void R_InitTextures(int* maptex, R_Init_MiscValues_t* miscVals) { maptexture_t *mtexture; IPUpatchlesstexture_t *texture; @@ -694,6 +696,7 @@ int R_FlatNumForName(char *name) { } */ +__SUPER__ int JOSEFstrsame(const char* restrict a, const char* restrict b) { for (int i = 0; i < 8; ++i) { char c_a = JOSEFtoupper(a[i]), c_b = JOSEFtoupper(b[i]); @@ -708,6 +711,7 @@ int JOSEFstrsame(const char* restrict a, const char* restrict b) { // Check whether texture is available. // Filter out NoTexture indicator. // +__SUPER__ int R_CheckTextureNumForName(char *name) { IPUpatchlesstexture_t *texture; int key; @@ -736,6 +740,7 @@ int R_CheckTextureNumForName(char *name) { // Calls R_CheckTextureNumForName, // aborts with error message. // +__SUPER__ int R_TextureNumForName(char *name) { int i; diff --git a/src/ipu/r_data.h b/src/ipu/r_data.h index cb9305d..7fd5498 100644 --- a/src/ipu/r_data.h +++ b/src/ipu/r_data.h @@ -21,22 +21,23 @@ #define __R_DATA__ #include "doomtype.h" +#include "ipu_utils.h" // Retrieve column data for span blitting. -byte *R_GetColumn(int tex, int col); +__SUPER__ byte *R_GetColumn(int tex, int col); // I/O, setting up the stuff. -void R_InitData(void); -void R_PrecacheLevel(void); +__SUPER__ void R_InitData(void); +__SUPER__ void R_PrecacheLevel(void); // Retrieval. // Floor/ceiling opaque texture tiles, // lookup by name. For animation? -int R_FlatNumForName(char *name); +__SUPER__ int R_FlatNumForName(char *name); // Called by P_Ticker for switches and animations, // returns the texture number for the texture name. -int R_TextureNumForName(char *name); -int R_CheckTextureNumForName(char *name); +__SUPER__ int R_TextureNumForName(char *name); +__SUPER__ int R_CheckTextureNumForName(char *name); #endif diff --git a/src/ipu/r_draw.c b/src/ipu/r_draw.c index 9cd9bd8..6405846 100644 --- a/src/ipu/r_draw.c +++ b/src/ipu/r_draw.c @@ -107,6 +107,7 @@ extern int lightnum; // Thus a special case loop for very fast rendering can // be used. It has also been used with Wolfenstein 3D. // +__SUPER__ void R_DrawColumn(void) { int count; pixel_t *dest; @@ -695,6 +696,7 @@ void R_DrawSpanLow(void) { // for getting the framebuffer address // of a pixel to draw. // +__SUPER__ void R_InitBuffer(int width, int height) { int i; diff --git a/src/ipu/r_draw.h b/src/ipu/r_draw.h index 35358e8..9dedb13 100644 --- a/src/ipu/r_draw.h +++ b/src/ipu/r_draw.h @@ -36,8 +36,8 @@ extern byte *dc_source; // The span blitting interface. // Hook in assembler or system specific BLT // here. -void R_DrawColumn(void); -void R_DrawColumnLow(void); +__SUPER__ void R_DrawColumn(void); +__SUPER__ void R_DrawColumnLow(void); // The Spectre/Invisibility effect. void R_DrawFuzzColumn(void); @@ -75,7 +75,7 @@ void R_DrawSpan(void); // Low resolution mode, 160x200? void R_DrawSpanLow(void); -void R_InitBuffer(int width, int height); +__SUPER__ void R_InitBuffer(int width, int height); // Initialize color translation tables, // for player rendering etc. diff --git a/src/ipu/r_main.c b/src/ipu/r_main.c index 334c6ea..45d9c0a 100644 --- a/src/ipu/r_main.c +++ b/src/ipu/r_main.c @@ -111,6 +111,7 @@ int extralight; // void (*colfunc)(void); // JOSEF +__SUPER__ void colfunc() { // JOSEF: Don't call through pointer, explicit call if (!detailshift) R_DrawColumn(); // else R_DrawColumnLow(); // LATER @@ -133,6 +134,7 @@ int abs(int); // Expand a given bbox // so that it encloses a given point. // +__SUPER__ void R_AddPointToBox(int x, int y, fixed_t *box) { if (x < box[BOXLEFT]) box[BOXLEFT] = x; @@ -150,6 +152,7 @@ void R_AddPointToBox(int x, int y, fixed_t *box) { // check point against partition plane. // Returns side 0 (front) or 1 (back). // +__SUPER__ int R_PointOnSide(fixed_t x, fixed_t y, node_t *node) { fixed_t dx; fixed_t dy; @@ -255,6 +258,7 @@ int R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) { // tangent (slope) value which is looked up in the // tantoangle[] table. // +__SUPER__ angle_t R_PointToAngle(fixed_t x, fixed_t y) { x -= viewx; y -= viewy; @@ -315,6 +319,7 @@ angle_t R_PointToAngle(fixed_t x, fixed_t y) { return 0; } +__SUPER__ angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) { viewx = x1; viewy = y1; @@ -322,6 +327,7 @@ angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) { return R_PointToAngle(x2, y2); } +__SUPER__ fixed_t R_PointToDist(fixed_t x, fixed_t y) { int angle; fixed_t dx; @@ -358,6 +364,7 @@ fixed_t R_PointToDist(fixed_t x, fixed_t y) { // // R_InitPointToAngle // +__SUPER__ void R_InitPointToAngle(void) { // UNUSED - now getting from tables.c #if 0 @@ -383,6 +390,7 @@ void R_InitPointToAngle(void) { // at the given angle. // rw_distance must be calculated first. // +__SUPER__ fixed_t R_ScaleFromGlobalAngle(angle_t visangle) { fixed_t scale; angle_t anglea; @@ -413,8 +421,8 @@ fixed_t R_ScaleFromGlobalAngle(angle_t visangle) { angleb = ANG90 + (visangle - rw_normalangle); // both sines are allways positive - sinea = IPU_finesine(anglea >> ANGLETOFINESHIFT); - sineb = IPU_finesine(angleb >> ANGLETOFINESHIFT); + sinea = finesine[anglea >> ANGLETOFINESHIFT]; + sineb = finesine[angleb >> ANGLETOFINESHIFT]; num = FixedMul(projection, sineb) << detailshift; den = FixedMul(rw_distance, sinea); @@ -468,6 +476,7 @@ void R_InitTables(void) { // // R_InitTextureMapping // +__SUPER__ void R_InitTextureMapping(void) { int i; int x; @@ -482,7 +491,6 @@ void R_InitTextureMapping(void) { // so FIELDOFVIEW angles covers SCREENWIDTH. focallength = FixedDiv(centerxfrac, finetangent[FINEANGLES / 4 + FIELDOFVIEW / 2]); - for (i = 0; i < FINEANGLES / 2; i++) { if (finetangent[i] > FRACUNIT * 2) t = -1; @@ -570,6 +578,7 @@ boolean setsizeneeded; int setblocks; int setdetail; +__SUPER__ void R_SetViewSize(int blocks, int detail) { setsizeneeded = true; setblocks = blocks; @@ -579,6 +588,7 @@ void R_SetViewSize(int blocks, int detail) { // // R_ExecuteSetViewSize // +__SUPER__ void R_ExecuteSetViewSize(void) { fixed_t cosadj; fixed_t dy; @@ -728,6 +738,7 @@ subsector_t *R_PointInSubsector(fixed_t x, fixed_t y) { // // R_SetupFrame // +__SUPER__ void R_SetupFrame(player_t *player) { int i; @@ -739,7 +750,7 @@ void R_SetupFrame(player_t *player) { viewz = player->viewz; - viewsin = IPU_finesine(viewangle >> ANGLETOFINESHIFT); + viewsin = finesine[viewangle >> ANGLETOFINESHIFT]; viewcos = finecosine[viewangle >> ANGLETOFINESHIFT]; // JOSEF TMP, some tests to about replacing sin LUTs! @@ -773,6 +784,7 @@ void R_SetupFrame(player_t *player) { // // R_RenderView // +__SUPER__ void R_RenderPlayerView(player_t *player) { R_SetupFrame(player); diff --git a/src/ipu/r_main.h b/src/ipu/r_main.h index 53c6824..8fdaf43 100644 --- a/src/ipu/r_main.h +++ b/src/ipu/r_main.h @@ -83,7 +83,7 @@ extern int detailshift; // // extern void (*colfunc)(void); // JOSEF -void colfunc(void); // Don't want to call via pointer on IPU +__SUPER__ void colfunc(void); // Don't want to call via pointer on IPU extern void (*transcolfunc)(void); extern void (*basecolfunc)(void); extern void (*fuzzcolfunc)(void); @@ -97,33 +97,33 @@ extern int tileRightClip; // // Utility functions. -int R_PointOnSide(fixed_t x, fixed_t y, node_t *node); +__SUPER__ int R_PointOnSide(fixed_t x, fixed_t y, node_t *node); -int R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line); +__SUPER__ int R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line); -angle_t R_PointToAngle(fixed_t x, fixed_t y); +__SUPER__ angle_t R_PointToAngle(fixed_t x, fixed_t y); -angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); +__SUPER__ angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); -fixed_t R_PointToDist(fixed_t x, fixed_t y); +__SUPER__ fixed_t R_PointToDist(fixed_t x, fixed_t y); -fixed_t R_ScaleFromGlobalAngle(angle_t visangle); +__SUPER__ fixed_t R_ScaleFromGlobalAngle(angle_t visangle); -subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); +__SUPER__ subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); -void R_AddPointToBox(int x, int y, fixed_t *box); +__SUPER__ void R_AddPointToBox(int x, int y, fixed_t *box); // // REFRESH - the actual rendering functions. // // Called by G_Drawer. -void R_RenderPlayerView(player_t *player); +__SUPER__ void R_RenderPlayerView(player_t *player); // Called by startup code. -void R_Init(void); +__SUPER__ void R_Init(void); // Called by M_Responder. -void R_SetViewSize(int blocks, int detail); +__SUPER__ void R_SetViewSize(int blocks, int detail); #endif diff --git a/src/ipu/r_plane.c b/src/ipu/r_plane.c index 330abb6..dbc657a 100644 --- a/src/ipu/r_plane.c +++ b/src/ipu/r_plane.c @@ -93,6 +93,7 @@ fixed_t cachedystep[SCREENHEIGHT]; // R_InitPlanes // Only at game startup. // +__SUPER__ void R_InitPlanes(void) { // Doh! } @@ -161,6 +162,7 @@ void R_MapPlane(int y, int x1, int x2) { // R_ClearPlanes // At begining of frame. // +__SUPER__ void R_ClearPlanes(void) { int i; angle_t angle; diff --git a/src/ipu/r_plane.h b/src/ipu/r_plane.h index 2f8ff90..d880513 100644 --- a/src/ipu/r_plane.h +++ b/src/ipu/r_plane.h @@ -37,17 +37,17 @@ extern short ceilingclip[SCREENWIDTH]; extern fixed_t yslope[SCREENHEIGHT]; extern fixed_t distscale[SCREENWIDTH]; -void R_InitPlanes(void); -void R_ClearPlanes(void); +__SUPER__ void R_InitPlanes(void); +__SUPER__ void R_ClearPlanes(void); -void R_MapPlane(int y, int x1, int x2); +__SUPER__ void R_MapPlane(int y, int x1, int x2); -void R_MakeSpans(int x, int t1, int b1, int t2, int b2); +__SUPER__ void R_MakeSpans(int x, int t1, int b1, int t2, int b2); -void R_DrawPlanes(void); +__SUPER__ void R_DrawPlanes(void); -visplane_t *R_FindPlane(fixed_t height, int picnum, int lightlevel); +__SUPER__ visplane_t *R_FindPlane(fixed_t height, int picnum, int lightlevel); -visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop); +__SUPER__ visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop); #endif diff --git a/src/ipu/r_segs.c b/src/ipu/r_segs.c index faa5a8f..1b1d9ed 100644 --- a/src/ipu/r_segs.c +++ b/src/ipu/r_segs.c @@ -38,6 +38,7 @@ #include "v_patch.h" #include +#include "ipu_utils.h" #include "ipu_texturetiles.h" @@ -93,6 +94,7 @@ lighttable_t **walllights; short *maskedtexturecol; +__SUPER__ int abs(int); // JOSEF /* @@ -190,7 +192,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2) { // #define HEIGHTBITS 12 #define HEIGHTUNIT (1 << HEIGHTBITS) - +__SUPER__ void R_RenderSegLoop(void) { angle_t angle; unsigned index; @@ -341,6 +343,7 @@ int lightnum; // JOSEF: Temprarily made this global for vis // A wall segment will be drawn // between start and stop pixels (inclusive). // +__SUPER__ void R_StoreWallRange(int start, int stop) { fixed_t hyp; fixed_t sineval; diff --git a/src/ipu/r_segs.h b/src/ipu/r_segs.h index b22e539..609d9ba 100644 --- a/src/ipu/r_segs.h +++ b/src/ipu/r_segs.h @@ -19,8 +19,9 @@ #ifndef __R_SEGS__ #define __R_SEGS__ +#include "ipu_texturetiles.h" #include "r_defs.h" -void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2); +__SUPER__ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2); #endif diff --git a/src/ipu/tables.c b/src/ipu/tables.c index 8803442..d62ff0e 100644 --- a/src/ipu/tables.c +++ b/src/ipu/tables.c @@ -32,13 +32,14 @@ #include "tables.h" #include // JOSEF +#include "ipu_texturetiles.h" // to get a global angle from cartesian coordinates, the coordinates are // flipped until they are in the first octant of the coordinate system, then // the y (<=x) is scaled and divided by x to get a tangent (slope) value // which is looked up in the tantoangle[] table. The +1 size is to handle // the case when x==y without additional checking. - +__SUPER__ int SlopeDiv(unsigned int num, unsigned int den) { unsigned ans; @@ -579,6 +580,7 @@ const fixed_t finetangent[4096] = }; // 40K lookup table is a bit dear for IPU, eventually calculate live instead +__SUPER__ fixed_t IPU_finesine(int i) { return finesine[i]; diff --git a/src/ipu/tables.h b/src/ipu/tables.h index 516f2b6..10fbc5b 100644 --- a/src/ipu/tables.h +++ b/src/ipu/tables.h @@ -47,7 +47,7 @@ // Effective size is 10240. extern const fixed_t finesine[5*FINEANGLES/4]; -fixed_t IPU_finesine(int i); // Replace big lookup on IPU +__SUPER__ fixed_t IPU_finesine(int i); // Replace big lookup on IPU // Re-use data, is just PI/2 pahse shift. extern const fixed_t *finecosine; @@ -90,7 +90,7 @@ extern const angle_t tantoangle[SLOPERANGE+1]; // Utility function, // called by R_PointToAngle. -int SlopeDiv(unsigned int num, unsigned int den); +__SUPER__ int SlopeDiv(unsigned int num, unsigned int den); #endif diff --git a/src/ipu/v_video.c b/src/ipu/v_video.c index 8e48fa8..bb0f29a 100644 --- a/src/ipu/v_video.c +++ b/src/ipu/v_video.c @@ -133,7 +133,7 @@ void V_SetPatchClipCallback(vpatchclipfunc_t func) // V_DrawPatch // Masks a column based masked pic to the screen. // - +__SUPER__ void V_DrawPatch(int x, int y, patch_t *patch) { int count; @@ -597,6 +597,7 @@ void V_DrawRawScreen(byte *raw) // // V_Init // +__SUPER__ void V_Init (void) { // no-op! @@ -606,6 +607,7 @@ void V_Init (void) // Set the buffer that the code draws to. +__SUPER__ void V_UseBuffer(pixel_t *buffer) { dest_screen = buffer; @@ -613,6 +615,7 @@ void V_UseBuffer(pixel_t *buffer) // Restore screen buffer to the i_video screen buffer. +__SUPER__ void V_RestoreBuffer(void) { dest_screen = I_VideoBuffer; diff --git a/src/ipu/v_video.h b/src/ipu/v_video.h index 7b98c35..624c371 100644 --- a/src/ipu/v_video.h +++ b/src/ipu/v_video.h @@ -27,6 +27,8 @@ // Needed because we are refering to patches. #include "v_patch.h" +#include "ipu_utils.h" + // // VIDEO // @@ -42,67 +44,67 @@ extern byte *tinttable; // haleyjd 08/28/10: Patch clipping callback, implemented to support Choco // Strife. typedef boolean (*vpatchclipfunc_t)(patch_t *, int, int); -void V_SetPatchClipCallback(vpatchclipfunc_t func); +__SUPER__ void V_SetPatchClipCallback(vpatchclipfunc_t func); // Allocates buffer screens, call before R_Init. -void V_Init (void); +__SUPER__ void V_Init (void); // Draw a block from the specified source screen to the screen. -void V_CopyRect(int srcx, int srcy, pixel_t *source, +__SUPER__ void V_CopyRect(int srcx, int srcy, pixel_t *source, int width, int height, int destx, int desty); -void V_DrawPatch(int x, int y, patch_t *patch); -void V_DrawPatchFlipped(int x, int y, patch_t *patch); -void V_DrawTLPatch(int x, int y, patch_t *patch); -void V_DrawAltTLPatch(int x, int y, patch_t * patch); -void V_DrawShadowedPatch(int x, int y, patch_t *patch); -void V_DrawXlaPatch(int x, int y, patch_t * patch); // villsa [STRIFE] -void V_DrawPatchDirect(int x, int y, patch_t *patch); +__SUPER__ void V_DrawPatch(int x, int y, patch_t *patch); +__SUPER__ void V_DrawPatchFlipped(int x, int y, patch_t *patch); +__SUPER__ void V_DrawTLPatch(int x, int y, patch_t *patch); +__SUPER__ void V_DrawAltTLPatch(int x, int y, patch_t * patch); +__SUPER__ void V_DrawShadowedPatch(int x, int y, patch_t *patch); +__SUPER__ void V_DrawXlaPatch(int x, int y, patch_t * patch); // villsa [STRIFE] +__SUPER__ void V_DrawPatchDirect(int x, int y, patch_t *patch); // Draw a linear block of pixels into the view buffer. -void V_DrawBlock(int x, int y, int width, int height, pixel_t *src); +__SUPER__ void V_DrawBlock(int x, int y, int width, int height, pixel_t *src); -void V_MarkRect(int x, int y, int width, int height); +__SUPER__ void V_MarkRect(int x, int y, int width, int height); -void V_DrawFilledBox(int x, int y, int w, int h, int c); -void V_DrawHorizLine(int x, int y, int w, int c); -void V_DrawVertLine(int x, int y, int h, int c); -void V_DrawBox(int x, int y, int w, int h, int c); +__SUPER__ void V_DrawFilledBox(int x, int y, int w, int h, int c); +__SUPER__ void V_DrawHorizLine(int x, int y, int w, int c); +__SUPER__ void V_DrawVertLine(int x, int y, int h, int c); +__SUPER__ void V_DrawBox(int x, int y, int w, int h, int c); // Draw a raw screen lump -void V_DrawRawScreen(byte *raw); +__SUPER__ void V_DrawRawScreen(byte *raw); // Temporarily switch to using a different buffer to draw graphics, etc. -void V_UseBuffer(pixel_t *buffer); +__SUPER__ void V_UseBuffer(pixel_t *buffer); // Return to using the normal screen buffer to draw graphics. -void V_RestoreBuffer(void); +__SUPER__ void V_RestoreBuffer(void); // Save a screenshot of the current screen to a file, named in the // format described in the string passed to the function, eg. // "DOOM%02i.pcx" -void V_ScreenShot(char *format); +__SUPER__ void V_ScreenShot(char *format); // Load the lookup table for translucency calculations from the TINTTAB // lump. -void V_LoadTintTable(void); +__SUPER__ void V_LoadTintTable(void); // villsa [STRIFE] // Load the lookup table for translucency calculations from the XLATAB // lump. -void V_LoadXlaTable(void); +__SUPER__ void V_LoadXlaTable(void); -void V_DrawMouseSpeedBox(int speed); +__SUPER__ void V_DrawMouseSpeedBox(int speed); #endif diff --git a/src/ipu/w_wad.c b/src/ipu/w_wad.c index ed90cb6..f977996 100644 --- a/src/ipu/w_wad.c +++ b/src/ipu/w_wad.c @@ -68,13 +68,14 @@ static lumpinfo_t *reloadlumps = NULL; static char *reloadname = NULL; static int reloadlump = -1; */ - +__SUPER__ char JOSEFtoupper(const char c) { if (c < 97 || c > 122) return c; return c ^ 0x20; } // Hash function used for lump names. +__SUPER__ unsigned int W_LumpNameHash(const char *s) { // This is the djb2 string hash function, modded to work on strings diff --git a/src/ipu/w_wad.h b/src/ipu/w_wad.h index ad860ca..b504421 100644 --- a/src/ipu/w_wad.h +++ b/src/ipu/w_wad.h @@ -52,25 +52,25 @@ struct lumpinfo_s extern lumpinfo_t **lumpinfo; extern unsigned int numlumps; -wad_file_t *W_AddFile(char *filename); -void W_Reload(void); +__SUPER__ wad_file_t *W_AddFile(char *filename); +__SUPER__ void W_Reload(void); -lumpindex_t W_CheckNumForName(char *name); -lumpindex_t W_GetNumForName(char *name); +__SUPER__ lumpindex_t W_CheckNumForName(char *name); +__SUPER__ lumpindex_t W_GetNumForName(char *name); -int W_LumpLength(lumpindex_t lump); -void W_ReadLump(lumpindex_t lump, void *dest); +__SUPER__ int W_LumpLength(lumpindex_t lump); +__SUPER__ void W_ReadLump(lumpindex_t lump, void *dest); -void *W_CacheLumpNum(lumpindex_t lump, int tag); -void *W_CacheLumpName(char *name, int tag); +__SUPER__ void *W_CacheLumpNum(lumpindex_t lump, int tag); +__SUPER__ void *W_CacheLumpName(char *name, int tag); -void W_GenerateHashTable(void); +__SUPER__ void W_GenerateHashTable(void); -extern unsigned int W_LumpNameHash(const char *s); +__SUPER__ extern unsigned int W_LumpNameHash(const char *s); -void W_ReleaseLumpNum(lumpindex_t lump); -void W_ReleaseLumpName(char *name); +__SUPER__ void W_ReleaseLumpNum(lumpindex_t lump); +__SUPER__ void W_ReleaseLumpName(char *name); -char JOSEFtoupper(const char c); +__SUPER__ char JOSEFtoupper(const char c); #endif