From: sparky4 Date: Wed, 29 Mar 2017 17:47:52 +0000 (-0500) Subject: [16_ca needs huge amounts of work and I should remember what needs to be done soon... X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=commitdiff_plain;h=2a225a70d77b2323a29bc78539cd50c5997bca1e [16_ca needs huge amounts of work and I should remember what needs to be done soon][OpenVGMFile needs to be ported to 16_snd.c]going to port rest of code to borland c some time so we can use the core components of id engine here [going to add 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority now] added animation delay test back wwww [older zcroll renamed to xcroll][zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM] --- diff --git a/16/wf3d8086/.id_ca.c.kate-swp b/16/wf3d8086/.id_ca.c.kate-swp deleted file mode 100755 index ed0e0fcc..00000000 Binary files a/16/wf3d8086/.id_ca.c.kate-swp and /dev/null differ diff --git a/_rf_use.txt b/_rf_use.txt index a103cbae..0d903a96 100755 --- a/_rf_use.txt +++ b/_rf_use.txt @@ -31,3 +31,213 @@ kd_play.c: RF_RemoveSprite (&obj->sprite); kd_play.c: RF_Refresh(); kd_play.c: RF_SetRefreshHook (&FadeAndUnhook); kd_play.c: RF_NewPosition (orgx,orgy); +------------------------------------------------------------------------------- + ./qcata.sh start +------------------------------------------------------------------------------- +==== 16/Catacomb3D ==== +16/Catacomb3D/C3_MAIN.C:void RF_FixOfs (void) +16/Catacomb3D/ID_RF.C:// RF_Startup +16/Catacomb3D/ID_RF.C:= RF_Startup +16/Catacomb3D/ID_RF.C:void RF_Startup (void) +16/Catacomb3D/ID_RF.C:= RF_Shutdown +16/Catacomb3D/ID_RF.C:void RF_Shutdown (void) +16/Catacomb3D/ID_RF.C:= RF_FixOfs +16/Catacomb3D/ID_RF.C:void RF_FixOfs (void) +16/Catacomb3D/ID_RF.C:= RF_NewMap +16/Catacomb3D/ID_RF.C:void RF_NewMap (void) +16/Catacomb3D/ID_RF.C: Quit ("RF_NewMap: Map too tall!"); +16/Catacomb3D/ID_RF.C: RF_SetScrollBlock (0,MAPBORDER-1,true); +16/Catacomb3D/ID_RF.C: RF_SetScrollBlock (0,mapheight-MAPBORDER,true); +16/Catacomb3D/ID_RF.C: RF_SetScrollBlock (MAPBORDER-1,0,false); +16/Catacomb3D/ID_RF.C: RF_SetScrollBlock (mapwidth-MAPBORDER,0,false); +16/Catacomb3D/ID_RF.C:= RF_MarkTileGraphics +16/Catacomb3D/ID_RF.C:void RF_MarkTileGraphics (void) +16/Catacomb3D/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Background anim of 0:"); +16/Catacomb3D/ID_RF.C: Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); +16/Catacomb3D/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Unending background animation:"); +16/Catacomb3D/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Foreground anim of 0:"); +16/Catacomb3D/ID_RF.C: Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); +16/Catacomb3D/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Unending foreground animation:"); +16/Catacomb3D/ID_RF.C: Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); +16/Catacomb3D/ID_RF.C: Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); +16/Catacomb3D/ID_RF.C:= RF_SetScrollBlock +16/Catacomb3D/ID_RF.C:void RF_SetScrollBlock (int x, int y, boolean horizontal) +16/Catacomb3D/ID_RF.C: Quit ("RF_SetScrollBlock: Too many horizontal scroll blocks"); +16/Catacomb3D/ID_RF.C: Quit ("RF_SetScrollBlock: Too many vertical scroll blocks"); +16/Catacomb3D/ID_RF.C:= RF_SetRefreshHook +16/Catacomb3D/ID_RF.C:void RF_SetRefreshHook (void (*func) (void) ) +16/Catacomb3D/ID_RF.C:= RF_ForceRefresh +16/Catacomb3D/ID_RF.C:void RF_ForceRefresh (void) +16/Catacomb3D/ID_RF.C: RF_NewPosition (originxglobal,originyglobal); +16/Catacomb3D/ID_RF.C: RF_Refresh (); +16/Catacomb3D/ID_RF.C: RF_Refresh (); +16/Catacomb3D/ID_RF.C:= RF_MapToMap +16/Catacomb3D/ID_RF.C:void RF_MapToMap (unsigned srcx, unsigned srcy, +16/Catacomb3D/ID_RF.C:= RF_MemToMap +16/Catacomb3D/ID_RF.C:void RF_MemToMap (unsigned far *source, unsigned plane, +16/Catacomb3D/ID_RF.C:= RF_ClearBlock +16/Catacomb3D/ID_RF.C:void RF_ClearBlock (int x, int y, int width, int height) +16/Catacomb3D/ID_RF.C:= RF_RedrawBlock +16/Catacomb3D/ID_RF.C:void RF_RedrawBlock (int x, int y, int width, int height) +16/Catacomb3D/ID_RF.C:= RF_CalcTics +16/Catacomb3D/ID_RF.C:void RF_CalcTics (void) +16/Catacomb3D/ID_RF.C:= RF_FindFreeBuffer +16/Catacomb3D/ID_RF.C:unsigned RF_FindFreeBuffer (void) +16/Catacomb3D/ID_RF.C:= RF_NewPosition EGA +16/Catacomb3D/ID_RF.C:void RF_NewPosition (unsigned x, unsigned y) +16/Catacomb3D/ID_RF.C:= RF_Scroll EGA +16/Catacomb3D/ID_RF.C:void RF_Scroll (int x, int y) +16/Catacomb3D/ID_RF.C: RF_NewPosition(originxglobal,originyglobal); +16/Catacomb3D/ID_RF.C:= RF_PlaceSprite EGA +16/Catacomb3D/ID_RF.C:void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, +16/Catacomb3D/ID_RF.C: RF_RemoveSprite (user); +16/Catacomb3D/ID_RF.C: Quit ("RF_PlaceSprite: No free spots in spritearray!"); +16/Catacomb3D/ID_RF.C: strcpy (str,"RF_PlaceSprite: Placed an uncached sprite:"); +16/Catacomb3D/ID_RF.C:= RF_RemoveSprite EGA +16/Catacomb3D/ID_RF.C:void RF_RemoveSprite (void **user) +16/Catacomb3D/ID_RF.C:= RF_Refresh EGA +16/Catacomb3D/ID_RF.C:void RF_Refresh (void) +16/Catacomb3D/ID_RF.C: RF_CalcTics (); +16/Catacomb3D/ID_RF.C:= RF_NewPosition CGA +16/Catacomb3D/ID_RF.C:void RF_NewPosition (unsigned x, unsigned y) +16/Catacomb3D/ID_RF.C:= RF_Scroll CGA +16/Catacomb3D/ID_RF.C:void RF_Scroll (int x, int y) +16/Catacomb3D/ID_RF.C: RF_NewPosition(originxglobal,originyglobal); +16/Catacomb3D/ID_RF.C:= RF_PlaceSprite CGA +16/Catacomb3D/ID_RF.C:void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, +16/Catacomb3D/ID_RF.C: RF_RemoveSprite (user); +16/Catacomb3D/ID_RF.C: Quit ("RF_PlaceSprite: No free spots in spritearray!"); +16/Catacomb3D/ID_RF.C: strcpy (str,"RF_PlaceSprite: Placed an uncached sprite!"); +16/Catacomb3D/ID_RF.C:= RF_RemoveSprite CGA +16/Catacomb3D/ID_RF.C:void RF_RemoveSprite (void **user) +16/Catacomb3D/ID_RF.C:= RF_Refresh CGA +16/Catacomb3D/ID_RF.C:void RF_Refresh (void) +16/Catacomb3D/ID_US_2.C: RF_FixOfs(); +16/Catacomb3D/ID_RF.H:#define __ID_RF__ +16/Catacomb3D/ID_RF.H:void RF_Startup (void); +16/Catacomb3D/ID_RF.H:void RF_Shutdown (void); +16/Catacomb3D/ID_RF.H:void RF_FixOfs (void); +16/Catacomb3D/ID_RF.H:void RF_NewMap (void); +16/Catacomb3D/ID_RF.H:void RF_MarkTileGraphics (void); +16/Catacomb3D/ID_RF.H:void RF_SetScrollBlock (int x, int y, boolean horizontal); +16/Catacomb3D/ID_RF.H:void RF_NewPosition (unsigned x, unsigned y); +16/Catacomb3D/ID_RF.H:void RF_Scroll (int x, int y); +16/Catacomb3D/ID_RF.H:void RF_MapToMap (unsigned srcx, unsigned srcy, +16/Catacomb3D/ID_RF.H:void RF_MemToMap (unsigned far *source, unsigned plane, +16/Catacomb3D/ID_RF.H:void RF_ClearBlock (int x, int y, int width, int height); +16/Catacomb3D/ID_RF.H:void RF_RedrawBlock (int x, int y, int width, int height); +16/Catacomb3D/ID_RF.H:void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, +16/Catacomb3D/ID_RF.H:void RF_RemoveSprite (void **user); +16/Catacomb3D/ID_RF.H:void RF_CalcTics (void); +16/Catacomb3D/ID_RF.H:void RF_Refresh (void); +16/Catacomb3D/ID_RF.H:void RF_ForceRefresh (void); +16/Catacomb3D/ID_RF.H:void RF_SetRefreshHook (void (*func) (void) ); +16/Catacomb3D/ID_RF.H:unsigned RF_FindFreeBuffer (void); +==== 16/CatacombApocalypse ==== +16/CatacombApocalypse/C6_MAIN.C:void RF_FixOfs (void) +16/CatacombApocalypse/GELIB.C: RF_RemoveSprite(&CurBOBShape->sprite); +16/CatacombApocalypse/GELIB.C: RF_RemoveSprite (&CurBOBShape->sprite); +16/CatacombApocalypse/GELIB.C: RF_PlaceSprite(&Shape->sprite,obj->x+Shape->x_offset,obj->y+Shape->y_offset, Shape->shapenum, spritedraw,Shape->priority,Shape->sprflags); +16/CatacombApocalypse/GELIB.C: RF_NewPosition(0,0); +16/CatacombApocalypse/GELIB.C: RF_Refresh(); +16/CatacombApocalypse/GELIB.C: RF_ForceRefresh(); +16/CatacombApocalypse/GELIB.C: RF_ForceRefresh(); +16/CatacombApocalypse/GELIB.C: RF_Refresh(); +16/CatacombApocalypse/ID_RF.C:// RF_Startup +16/CatacombApocalypse/ID_RF.C:= RF_Startup +16/CatacombApocalypse/ID_RF.C:void RF_Startup (void) +16/CatacombApocalypse/ID_RF.C:= RF_Shutdown +16/CatacombApocalypse/ID_RF.C:void RF_Shutdown (void) +16/CatacombApocalypse/ID_RF.C:= RF_FixOfs +16/CatacombApocalypse/ID_RF.C:void RF_FixOfs (void) +16/CatacombApocalypse/ID_RF.C:= RF_NewMap +16/CatacombApocalypse/ID_RF.C:void RF_NewMap (void) +16/CatacombApocalypse/ID_RF.C: Quit ("RF_NewMap: Map too tall!"); +16/CatacombApocalypse/ID_RF.C: RF_SetScrollBlock (0,MAPBORDER-1,true); +16/CatacombApocalypse/ID_RF.C: RF_SetScrollBlock (0,mapheight-MAPBORDER,true); +16/CatacombApocalypse/ID_RF.C: RF_SetScrollBlock (MAPBORDER-1,0,false); +16/CatacombApocalypse/ID_RF.C: RF_SetScrollBlock (mapwidth-MAPBORDER,0,false); +16/CatacombApocalypse/ID_RF.C:= RF_MarkTileGraphics +16/CatacombApocalypse/ID_RF.C:void RF_MarkTileGraphics (void) +16/CatacombApocalypse/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Background anim of 0:"); +16/CatacombApocalypse/ID_RF.C: Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); +16/CatacombApocalypse/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Unending background animation:"); +16/CatacombApocalypse/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Foreground anim of 0:"); +16/CatacombApocalypse/ID_RF.C: Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); +16/CatacombApocalypse/ID_RF.C: strcpy (str,"RF_MarkTileGraphics: Unending foreground animation:"); +16/CatacombApocalypse/ID_RF.C: Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); +16/CatacombApocalypse/ID_RF.C: Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); +16/CatacombApocalypse/ID_RF.C:= RF_SetScrollBlock +16/CatacombApocalypse/ID_RF.C:void RF_SetScrollBlock (int x, int y, boolean horizontal) +16/CatacombApocalypse/ID_RF.C: Quit ("RF_SetScrollBlock: Too many horizontal scroll blocks"); +16/CatacombApocalypse/ID_RF.C: Quit ("RF_SetScrollBlock: Too many vertical scroll blocks"); +16/CatacombApocalypse/ID_RF.C:= RF_SetRefreshHook +16/CatacombApocalypse/ID_RF.C:void RF_SetRefreshHook (void (*func) (void) ) +16/CatacombApocalypse/ID_RF.C:= RF_ForceRefresh +16/CatacombApocalypse/ID_RF.C:void RF_ForceRefresh (void) +16/CatacombApocalypse/ID_RF.C: RF_NewPosition (originxglobal,originyglobal); +16/CatacombApocalypse/ID_RF.C: RF_Refresh (); +16/CatacombApocalypse/ID_RF.C: RF_Refresh (); +16/CatacombApocalypse/ID_RF.C:= RF_MapToMap +16/CatacombApocalypse/ID_RF.C:void RF_MapToMap (unsigned srcx, unsigned srcy, +16/CatacombApocalypse/ID_RF.C:= RF_MemToMap +16/CatacombApocalypse/ID_RF.C:void RF_MemToMap (unsigned far *source, unsigned plane, +16/CatacombApocalypse/ID_RF.C:= RF_ClearBlock +16/CatacombApocalypse/ID_RF.C:void RF_ClearBlock (int x, int y, int width, int height) +16/CatacombApocalypse/ID_RF.C:= RF_RedrawBlock +16/CatacombApocalypse/ID_RF.C:void RF_RedrawBlock (int x, int y, int width, int height) +16/CatacombApocalypse/ID_RF.C:= RF_CalcTics +16/CatacombApocalypse/ID_RF.C:void RF_CalcTics (void) +16/CatacombApocalypse/ID_RF.C:= RF_FindFreeBuffer +16/CatacombApocalypse/ID_RF.C:unsigned RF_FindFreeBuffer (void) +16/CatacombApocalypse/ID_RF.C:= RF_NewPosition EGA +16/CatacombApocalypse/ID_RF.C:void RF_NewPosition (unsigned x, unsigned y) +16/CatacombApocalypse/ID_RF.C:= RF_Scroll EGA +16/CatacombApocalypse/ID_RF.C:void RF_Scroll (int x, int y) +16/CatacombApocalypse/ID_RF.C: RF_NewPosition(originxglobal,originyglobal); +16/CatacombApocalypse/ID_RF.C:= RF_PlaceSprite EGA +16/CatacombApocalypse/ID_RF.C:void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, +16/CatacombApocalypse/ID_RF.C: RF_RemoveSprite (user); +16/CatacombApocalypse/ID_RF.C: Quit ("RF_PlaceSprite: No free spots in spritearray!"); +16/CatacombApocalypse/ID_RF.C: strcpy (str,"RF_PlaceSprite: Placed an uncached sprite:"); +16/CatacombApocalypse/ID_RF.C:= RF_RemoveSprite EGA +16/CatacombApocalypse/ID_RF.C:void RF_RemoveSprite (void **user) +16/CatacombApocalypse/ID_RF.C:= RF_Refresh EGA +16/CatacombApocalypse/ID_RF.C:void RF_Refresh (void) +16/CatacombApocalypse/ID_RF.C: RF_CalcTics (); +16/CatacombApocalypse/ID_RF.C:= RF_NewPosition CGA +16/CatacombApocalypse/ID_RF.C:void RF_NewPosition (unsigned x, unsigned y) +16/CatacombApocalypse/ID_RF.C:= RF_Scroll CGA +16/CatacombApocalypse/ID_RF.C:void RF_Scroll (int x, int y) +16/CatacombApocalypse/ID_RF.C: RF_NewPosition(originxglobal,originyglobal); +16/CatacombApocalypse/ID_RF.C:= RF_PlaceSprite CGA +16/CatacombApocalypse/ID_RF.C:void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, +16/CatacombApocalypse/ID_RF.C: RF_RemoveSprite (user); +16/CatacombApocalypse/ID_RF.C: Quit ("RF_PlaceSprite: No free spots in spritearray!"); +16/CatacombApocalypse/ID_RF.C: strcpy (str,"RF_PlaceSprite: Placed an uncached sprite!"); +16/CatacombApocalypse/ID_RF.C:= RF_RemoveSprite CGA +16/CatacombApocalypse/ID_RF.C:void RF_RemoveSprite (void **user) +16/CatacombApocalypse/ID_RF.C:= RF_Refresh CGA +16/CatacombApocalypse/ID_RF.C:void RF_Refresh (void) +16/CatacombApocalypse/ID_US_2.C: RF_FixOfs(); +16/CatacombApocalypse/ID_RF.H:#define __ID_RF__ +16/CatacombApocalypse/ID_RF.H:void RF_Startup (void); +16/CatacombApocalypse/ID_RF.H:void RF_Shutdown (void); +16/CatacombApocalypse/ID_RF.H:void RF_FixOfs (void); +16/CatacombApocalypse/ID_RF.H:void RF_NewMap (void); +16/CatacombApocalypse/ID_RF.H:void RF_MarkTileGraphics (void); +16/CatacombApocalypse/ID_RF.H:void RF_SetScrollBlock (int x, int y, boolean horizontal); +16/CatacombApocalypse/ID_RF.H:void RF_NewPosition (unsigned x, unsigned y); +16/CatacombApocalypse/ID_RF.H:void RF_Scroll (int x, int y); +16/CatacombApocalypse/ID_RF.H:void RF_MapToMap (unsigned srcx, unsigned srcy, +16/CatacombApocalypse/ID_RF.H:void RF_MemToMap (unsigned far *source, unsigned plane, +16/CatacombApocalypse/ID_RF.H:void RF_ClearBlock (int x, int y, int width, int height); +16/CatacombApocalypse/ID_RF.H:void RF_RedrawBlock (int x, int y, int width, int height); +16/CatacombApocalypse/ID_RF.H:void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, +16/CatacombApocalypse/ID_RF.H:void RF_RemoveSprite (void **user); +16/CatacombApocalypse/ID_RF.H:void RF_CalcTics (void); +16/CatacombApocalypse/ID_RF.H:void RF_Refresh (void); +16/CatacombApocalypse/ID_RF.H:void RF_ForceRefresh (void); +16/CatacombApocalypse/ID_RF.H:void RF_SetRefreshHook (void (*func) (void) ); +16/CatacombApocalypse/ID_RF.H:unsigned RF_FindFreeBuffer (void); +=============== ./qcata.sh end =============== diff --git a/src/lib/16_ca.c b/src/lib/16_ca.c index 58114c64..a41fb068 100755 --- a/src/lib/16_ca.c +++ b/src/lib/16_ca.c @@ -2024,7 +2024,7 @@ void CA_ClearMarks (global_game_variables_t *gvar) int i; for (i=0;ivideo.grneeded[i]&=~gvar->ca.ca_levelbit; + gvar->ca.grneeded[i]&=~gvar->ca.ca_levelbit; } //=========================================================================== @@ -2041,7 +2041,7 @@ void CA_ClearMarks (global_game_variables_t *gvar) void CA_ClearAllMarks (global_game_variables_t *gvar) { - _fmemset (gvar->video.grneeded,0,sizeof(gvar->video.grneeded)); + _fmemset (gvar->ca.grneeded,0,sizeof(gvar->ca.grneeded)); gvar->ca.ca_levelbit = 1; gvar->ca.ca_levelnum = 0; } diff --git a/src/lib/16_rf.c b/src/lib/16_rf.c index 05ea5ae5..46400385 100755 --- a/src/lib/16_rf.c +++ b/src/lib/16_rf.c @@ -76,6 +76,8 @@ unsigned SX_T_SHIFT; // screen x >> ?? = tile EGA = 1, CGA = 2; #define UPDATESPARESIZE (UPDATEWIDE*2+4) #define UPDATESIZE (UPDATESCREENSIZE+2*UPDATESPARESIZE) +#define MAXSCROLLEDGES 6 + /* ============================================================================= @@ -230,7 +232,9 @@ void RFL_NewTile (unsigned updateoffset); void RFL_MaskForegroundTiles (void); void RFL_UpdateTiles (void); +void RFL_BoundScroll (int x, int y);//++++?? void RFL_CalcOriginStuff (long x, long y); +void RFL_ClearScrollBlocks (void);//++++?? void RFL_InitSpriteList (void); void RFL_InitAnimList (void); void RFL_CheckForAnimTile (unsigned x, unsigned y); @@ -338,6 +342,40 @@ void RF_Shutdown (void) } +//=========================================================================== + + +/* +===================== += += RF_FixOfs += += Sets bufferofs,displayofs, and masterofs to regular values, for the += occasions when you have moved them around manually += +===================== +*/ + +void RF_FixOfs (void) +{ + if (grmode == EGAGR) + { + screenpage = 0; + otherpage = 1; + panx = pany = pansx = pansy = panadjust = 0; + displayofs = screenstart[screenpage]; + bufferofs = screenstart[otherpage]; + masterofs = screenstart[2]; + VW_SetScreen (displayofs,0); + } + else + { + bufferofs = 0; + masterofs = 0x8000; + } +} + + //=========================================================================== /* @@ -364,6 +402,8 @@ void RF_NewMap (void) // // make a lookup table for the maps left edge // + if (mapheight > MAXMAPHEIGHT) + Quit ("RF_NewMap: Map too tall!"); spot = 0; for (i=0;i=MAXANIMTYPES) - //Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); + Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); allanims[i].current = tile; allanims[i].count = tinf[SPEED+tile]; @@ -472,7 +516,7 @@ void RF_MarkTileGraphics (void) CA_MarkGrChunk(STARTTILE16+next); next += (signed char)(tinf[ANIM+next]); if (++anims > 20) - //Quit ("MarkTileGraphics: Unending animation!"); + Quit ("MarkTileGraphics: Unending animation!"); } } @@ -508,7 +552,7 @@ nextback: // new chain of animating tiles if (i>=MAXANIMTYPES) - //Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); + Quit ("RF_MarkTileGraphics: Too many unique animated tiles!"); allanims[i].current = tilehigh; allanims[i].count = tinf[MSPEED+tile]; @@ -522,7 +566,7 @@ nextback: CA_MarkGrChunk(STARTTILE16M+next); next += (signed char)(tinf[MANIM+next]); if (++anims > 20) - //Quit ("MarkTileGraphics: Unending animation!"); + Quit ("MarkTileGraphics: Unending animation!"); } } @@ -586,10 +630,10 @@ void RFL_CheckForAnimTile (unsigned x, unsigned y) // map = mapsegs[0]+offset; tile = *map; - if (tinf[ANIM+tile]) + if (tinf[ANIM+tile] && tinf[SPEED+tile]) { if (!animfreeptr) - //Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); + Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); anim = animfreeptr; animfreeptr = animfreeptr->nexttile; next = animhead; // stick it at the start of the list @@ -611,10 +655,10 @@ void RFL_CheckForAnimTile (unsigned x, unsigned y) // map = mapsegs[1]+offset; tile = *map; - if (tinf[MANIM+tile]) + if (tinf[MANIM+tile] && tinf[MSPEED+tile]) { if (!animfreeptr) - //Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); + Quit ("RF_CheckForAnimTile: No free spots in tilearray!"); anim = animfreeptr; animfreeptr = animfreeptr->nexttile; next = animhead; // stick it at the start of the list @@ -696,6 +740,37 @@ void RFL_RemoveAnimsOnY (unsigned y) } +/* +==================== += += RFL_RemoveAnimsInBlock += +==================== +*/ + +void RFL_RemoveAnimsInBlock (unsigned x, unsigned y, unsigned width, unsigned height) +{ + animtiletype *current,*next; + + current = animhead; + while (current) + { + if (current->x - x < width && current->y - y < height) + { + *(void **)current->prevptr = current->nexttile; + if (current->nexttile) + current->nexttile->prevptr = current->prevptr; + next = current->nexttile; + current->nexttile = animfreeptr; + animfreeptr = current; + current = next; + } + else + current = current->nexttile; + } +} + + /* ==================== = @@ -766,7 +841,7 @@ void RFL_AnimateTiles (void) y = current->y-originytile; if (x>=PORTTILESWIDE || y>=PORTTILESHIGH) - //Quit ("RFL_AnimateTiles: Out of bounds!"); + Quit ("RFL_AnimateTiles: Out of bounds!"); updateofs = uwidthtable[y] + x; RFL_NewTile(updateofs); // puts "1"s in both pages @@ -853,6 +928,115 @@ void RFL_CalcOriginStuff (long x, long y) } + +/* +================= += += RFL_ClearScrollBlocks += +================= +*/ + +void RFL_ClearScrollBlocks (void) +{ + hscrollblocks = vscrollblocks = 0; +} + + +/* +================= += += RF_SetScrollBlock += += Sets a horizontal or vertical scroll block += a horizontal block is ----, meaning it blocks up/down movement += +================= +*/ + +void RF_SetScrollBlock (int x, int y, boolean horizontal) +{ + if (horizontal) + { + hscrolledge[hscrollblocks] = y; + if (hscrollblocks++ == MAXSCROLLEDGES) + Quit ("RF_SetScrollBlock: Too many horizontal scroll blocks"); + } + else + { + vscrolledge[vscrollblocks] = x; + if (vscrollblocks++ == MAXSCROLLEDGES) + Quit ("RF_SetScrollBlock: Too many vertical scroll blocks"); + } +} + + +/* +================= += += RFL_BoundScroll += += Bound a given x/y movement to scroll blocks += +================= +*/ + +void RFL_BoundScroll (int x, int y) +{ + int check,newxtile,newytile; + + originxglobal += x; + originyglobal += y; + + newxtile= originxglobal >> G_T_SHIFT; + newytile = originyglobal >> G_T_SHIFT; + + if (x>0) + { + newxtile+=SCREENTILESWIDE; + for (check=0;check0) + { + newytile+=SCREENTILESHIGH; + for (check=0;checkoriginxmax) + orgx=originxmax; + + if (orgyoriginymax) + orgy=originymax; + + originxtile = orgx>>G_T_SHIFT; + originytile = orgy>>G_T_SHIFT; + + for (check=0;check=originxtile && edge <=originxtile+10) + { + orgx = (edge+1)*TILEGLOBAL; + break; + } + if (edge>=originxtile+11 && edge <=originxtile+20) + { + orgx = (edge-20)*TILEGLOBAL; + break; + } + } + + for (check=0;check=originytile && edge <=originytile+6) + { + orgy = (edge+1)*TILEGLOBAL; + break; + } + if (edge>=originytile+7 && edge <=originytile+13) + { + orgy = (edge-13)*TILEGLOBAL; + break; + } + } + + + RFL_CalcOriginStuff (orgx,orgy); +} + +//=========================================================================== + +/* +===================== += += RF_ClearBlock += += Posts erase blocks to clear a certain area of the screen to the master += screen, to erase text or something draw directly to the screen += += Parameters in pixels, but erasure is byte bounded += +===================== +*/ + +void RF_ClearBlock (int x, int y, int width, int height) +{ + eraseblocktype block; + +#if GRMODE == EGAGR + block.screenx = x/8+originxscreen; + block.screeny = y+originyscreen; + block.width = (width+(x&7)+7)/8; + block.height = height; + memcpy (eraselistptr[0]++,&block,sizeof(block)); + memcpy (eraselistptr[1]++,&block,sizeof(block)); +#endif + +#if GRMODE == CGAGR + block.screenx = x/4+originxscreen; + block.screeny = y+originyscreen; + block.width = (width+(x&3)+3)/4; + block.height = height; + memcpy (eraselistptr[0]++,&block,sizeof(block)); +#endif + +} + +//=========================================================================== + +/* +===================== += += RF_RedrawBlock += += Causes a number of tiles to be redrawn to the master screen and updated += += Parameters in pixels, but erasure is tile bounded += +===================== +*/ + +void RF_RedrawBlock (int x, int y, int width, int height) +{ + int xx,yy,xl,xh,yl,yh; + + xl=(x+panx)/16; + xh=(x+panx+width+15)/16; + yl=(y+pany)/16; + yh=(y+pany+height+15)/16; + for (yy=yl;yy<=yh;yy++) + for (xx=xl;xx<=xh;xx++) + RFL_NewTile (yy*UPDATEWIDE+xx); +} + + +//=========================================================================== + +/* +===================== += += RF_CalcTics += +===================== +*/ + +void RF_CalcTics (void) +{ + long newtime,oldtimecount; + +// +// calculate tics since last refresh for adaptive timing +// + if (lasttimecount > TimeCount) + TimeCount = lasttimecount; // if the game was paused a LONG time + + if (DemoMode) // demo recording and playback needs + { // to be constant +// +// take DEMOTICS or more tics, and modify Timecount to reflect time taken +// + oldtimecount = lasttimecount; + while (TimeCountMAXTICS) + { + TimeCount -= (tics-MAXTICS); + tics = MAXTICS; + } + } +} /* ============================================================================= @@ -969,6 +1483,39 @@ void RF_ForceRefresh (void) #if GRMODE == EGAGR +/* +===================== += += RF_FindFreeBuffer += += Finds the start of unused, non visable buffer space += +===================== +*/ + +unsigned RF_FindFreeBuffer (void) +{ + unsigned spot,i,j; + boolean ok; + + for (i=0;i<3;i++) + { + spot = screenstart[i]+SCREENSPACE; + ok = true; + for (j=0;j<3;j++) + if (spot == screenstart[j]) + { + ok = false; + break; + } + if (ok) + return spot; + } + + return 0; // never get here... +} + +//=========================================================================== /* ===================== @@ -984,10 +1531,11 @@ void RF_NewPosition (unsigned x, unsigned y) byte *page0ptr,*page1ptr; unsigned updatenum; -// + RFL_BoundNewOrigin (x,y); +/*?? // calculate new origin related globals // - RFL_CalcOriginStuff (x,y); + RFL_CalcOriginStuff (x,y);*/ // // clear out all animating tiles @@ -997,10 +1545,11 @@ void RF_NewPosition (unsigned x, unsigned y) // // set up the new update arrays at base position // - memset (tilecache,0,sizeof(tilecache)); // old cache is invalid +//?? memset (tilecache,0,sizeof(tilecache)); // old cache is invalid updatestart[0] = baseupdatestart[0]; updatestart[1] = baseupdatestart[1]; + updateptr = updatestart[otherpage]; page0ptr = updatestart[0]+PORTTILESWIDE; // used to stick "0"s after rows page1ptr = updatestart[1]+PORTTILESWIDE; @@ -1233,10 +1782,11 @@ void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, { spritelisttype register *sprite,*next; spritetabletype far *spr; - spritetype /*_seg*/ *block; + spritetype _seg *block; unsigned shift,pixx; + char str[80],str2[10]; - if (!spritenumber) + if (!spritenumber || spritenumber == (unsigned)-1) { RF_RemoveSprite (user); return; @@ -1276,7 +1826,7 @@ void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, // this is a brand new sprite, so allocate a block from the array if (!spritefreeptr) - //Quit ("RF_PlaceSprite: No free spots in spritearray!"); + Quit ("RF_PlaceSprite: No free spots in spritearray!"); sprite = spritefreeptr; spritefreeptr = spritefreeptr->nextsprite; @@ -1294,7 +1844,15 @@ linknewspot: // write the new info to the sprite // spr = &spritetable[spritenumber-STARTSPRITES]; - block = (spritetype /*_seg*/ *)grsegs[spritenumber]; + block = (spritetype _seg *)grsegs[spritenumber]; + + if (!block) + { + strcpy (str,"RF_PlaceSprite: Placed an uncached sprite:"); + itoa (spritenumber,str2,10); + strcat (str,str2); + Quit (str); + } globaly+=spr->orgy; globalx+=spr->orgx; @@ -1646,7 +2204,6 @@ redraw: void RF_Refresh (void) { byte *newupdate; - long newtime; updateptr = updatestart[otherpage]; @@ -1703,28 +2260,7 @@ asm mov [WORD PTR es:di],UPDATETERMINATE // // calculate tics since last refresh for adaptive timing // - if (lasttimecount > TimeCount) - lasttimecount = TimeCount; // if the game was paused a LONG time - do - { - newtime = TimeCount; - tics = newtime-lasttimecount; - } while (ticsMAXTICS) - { - TimeCount -= (tics-MAXTICS); - tics = MAXTICS; - } + RF_CalcTics (); } #endif // GRMODE == EGAGR @@ -1754,10 +2290,11 @@ void RF_NewPosition (unsigned x, unsigned y) byte *spotptr; unsigned updatenum; -// + RFL_BoundNewOrigin (x,y); +/*?? // calculate new origin related globals // - RFL_CalcOriginStuff (x,y); + RFL_CalcOriginStuff (x,y);*/ // // clear out all animating tiles @@ -1922,10 +2459,11 @@ void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, { spritelisttype register *sprite,*next; spritetabletype far *spr; - spritetype /*_seg*/ *block; + spritetype _seg *block; unsigned shift,pixx; + char str[80],str2[10]; - if (!spritenumber) + if (!spritenumber || spritenumber == (unsigned)-1) { RF_RemoveSprite (user); return; @@ -1961,7 +2499,7 @@ void RF_PlaceSprite (void **user,unsigned globalx,unsigned globaly, // this is a brand new sprite, so allocate a block from the array if (!spritefreeptr) - //Quit ("RF_PlaceSprite: No free spots in spritearray!"); + Quit ("RF_PlaceSprite: No free spots in spritearray!"); sprite = spritefreeptr; spritefreeptr = spritefreeptr->nextsprite; @@ -1979,7 +2517,16 @@ linknewspot: // write the new info to the sprite // spr = &spritetable[spritenumber-STARTSPRITES]; - block = (spritetype /*_seg*/ *)grsegs[spritenumber]; + block = (spritetype _seg *)grsegs[spritenumber]; + + if (!block) + { + strcpy (str,"RF_PlaceSprite: Placed an uncached sprite!"); + itoa (spritenumber,str2,10); + strcat (str,str2); + Quit (str); + } + globaly+=spr->orgy; globalx+=spr->orgx; @@ -2336,29 +2883,7 @@ void RF_Refresh (void) // // calculate tics since last refresh for adaptive timing // - if (lasttimecount > TimeCount) - lasttimecount = TimeCount; // if the game was paused a LONG time - do - { - newtime = TimeCount; - tics = newtime-lasttimecount; - } while (ticsMAXTICS) - tics = MAXTICS; - + RF_CalcTics (); } #endif // GRMODE == CGAGR diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index e9f19bbd..0b6de0bf 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -171,11 +171,11 @@ typedef struct { byte *data; //TODO: 16_mm and 16_ca must handle this } mapl_t; //map layer array type def -#define MAP_LAYERS 3 +#define MAPPLANES 3 typedef struct { //long planestart[3]; //unsigned planelength[3]; - mapl_t layerdata[MAP_LAYERS]; // mapdata for multilayer (map index values for rendering which image on the tile) + mapl_t layerdata[MAPPLANES]; // mapdata for multilayer (map index values for rendering which image on the tile) tiles_t *tiles; //TODO: 16_mm and 16_ca must handle this // tilesets for layers (currently ony 4 can be loaded wwww) int width, height; //this has to be signed! byte name[16]; @@ -390,7 +390,7 @@ typedef struct //0000word startclk; float clk, tickclk; //timer //newer vars //TODO: find out how they are used - byte grneeded[NUMCHUNKS]; +// byte grneeded[NUMCHUNKS]; } video_t; //from scroll16 @@ -581,7 +581,6 @@ typedef struct //========================================================================== #define NUMMAPS 4//39 -#define MAPPLANES 3 #define NUMSNDCHUNKS 84 typedef struct @@ -589,10 +588,18 @@ typedef struct word bit0,bit1; // 0-255 is a character, > is a pointer to a node } huffnode; +typedef struct +{ + long planestart[3]; + unsigned planelength[3]; + unsigned width,height; + char name[16]; +} maptype; + typedef struct { int mapon, mapnum; - //maptype _seg *mapheaderseg[NUMMAPS]; + maptype _seg *mapheaderseg[NUMMAPS]; } ca_mapinfo_t; typedef struct @@ -602,27 +609,22 @@ typedef struct int audiohandle[4]; // handle to AUDIOT / AUDIO } ca_handle_t; /* - 16/wf3d8086/id_ca.c:byte _seg *tinf; -16/wf3d8086/id_ca.c:unsigned _seg *mapsegs[MAPPLANES]; -16/wf3d8086/id_ca.c:maptype _seg *mapheaderseg[NUMMAPS]; -16/wf3d8086/id_ca.c:byte _seg *audiosegs[NUMSNDCHUNKS]; -16/wf3d8086/id_ca.c:void _seg *grsegs[NUMCHUNKS]; -16/wf3d8086/id_ca.c:long _seg *grstarts; // array of offsets in egagraph, -1 for sparse -16/wf3d8086/id_ca.c:long _seg *audiostarts; // array of offsets in audio / audiot 16/wf3d8086/id_ca.c: grstarts = (long _seg *)FP_SEG(&EGAhead); 16/wf3d8086/id_ca.c: tinf = (byte _seg *)FP_SEG(&maphead); 16/wf3d8086/id_ca.c: pos = ((mapfiletype _seg *)tinf)->headeroffsets[i]; 16/wf3d8086/id_ca.c: audiostarts = (long _seg *)FP_SEG(&audiohead); 16/wf3d8086/id_ca.c: ((mapfiletype _seg *)tinf)->RLEWtag); 16/wf3d8086/id_ca.c: ((mapfiletype _seg *)tinf)->RLEWtag); -16/wf3d8086/id_ca.c: source = (byte _seg *)bufferseg+(pos-bufferstart);*/ +16/wf3d8086/id_ca.c: source = (byte _seg *)bufferseg+(pos-bufferstart); +*/ typedef struct //TODO: USE THIS!!!! { byte ca_levelbit,ca_levelnum; ca_handle_t file; //files to open ca_mapinfo_t camap; - unsigned _seg *mapsegs[MAP_LAYERS]; + byte _seg *tinf[4];//?? where in the id engine is this used and what is it? --sparky4 + unsigned _seg *mapsegs[MAPPLANES]; void _seg *grsegs[NUMCHUNKS]; byte far grneeded[NUMCHUNKS]; word _seg *audiosegs[NUMSNDCHUNKS];//long @@ -630,9 +632,6 @@ typedef struct //TODO: USE THIS!!!! word _seg *grstarts; // array of offsets in egagraph, -1 for sparse//long word _seg *audiostarts; // array of offsets in audio / audiot//long - //misc memptr - byte _seg *tinf[4]; - huffnode huffnode; //TODO: extend! and learn from keen/wolf/catacomb's code wwww diff --git a/src/maptest.c b/src/maptest.c index 8a99276f..7b53667c 100755 --- a/src/maptest.c +++ b/src/maptest.c @@ -59,7 +59,7 @@ main(int argc, char *argv[]) getch(); #ifdef DUMP_MAP //if(map.width*map.height != 1200) - for(k=0;k