From b0c0fabf3e7a284d2713e11b30015818f91097e4 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Wed, 29 Mar 2017 16:44:54 -0500 Subject: [PATCH] [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]older zcroll renamed to xcroll[zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM] --- src/lib/16_ca.c | 8 +++++--- src/lib/16_ca.h | 2 +- src/lib/16_enti.c | 2 +- src/lib/16_spri.c | 10 +++++----- src/lib/16_tail.h | 4 ++-- src/lib/16_tdef.h | 22 ++++++++++++---------- src/lib/16_vl.c | 12 ++++++------ src/lib/scroll16.c | 14 +++++++------- src/lib/scroll16.h | 8 +++----- 9 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/lib/16_ca.c b/src/lib/16_ca.c index 0358a505..ca0ad837 100755 --- a/src/lib/16_ca.c +++ b/src/lib/16_ca.c @@ -1123,8 +1123,10 @@ dinorm: void CAL_SetupMapFile (global_game_variables_t *gvar) { +#ifndef MAPHEADERLINKED int handle; long length; +#endif // // load maphead.ext (offsets and tileinfo for map file) @@ -1137,9 +1139,9 @@ void CAL_SetupMapFile (global_game_variables_t *gvar) MM_GetPtr (MEMPTR gvar->ca.tinf,length,gvar); CA_FarRead(handle, gvar->ca.tinf, length,gvar); close(handle); -#else +//#else - tinf = (byte _seg *)FP_SEG(&maphead); + gvar->ca.tinf = (byte _seg *)FP_SEG(&maphead); #endif @@ -1805,7 +1807,7 @@ void CA_CacheGrChunk (int chunk) byte far *source; int next; - gvar->video.grneeded[chunk] |= ca_levelbit; // make sure it doesn't get removed + gvar->ca.grneeded[chunk] |= ca_levelbit; // make sure it doesn't get removed if (grsegs[chunk]) { MM_SetPurge (&grsegs[chunk],0); diff --git a/src/lib/16_ca.h b/src/lib/16_ca.h index bda68182..29b6c627 100755 --- a/src/lib/16_ca.h +++ b/src/lib/16_ca.h @@ -31,7 +31,7 @@ #define NOGRAPHICS #define NOAUDIO -//#define MAPHEADERLINKED +#define MAPHEADERLINKED //#define GRHEADERLINKED //#define AUDIOHEADERLINKED diff --git a/src/lib/16_enti.c b/src/lib/16_enti.c index c66eead0..7210e6d3 100755 --- a/src/lib/16_enti.c +++ b/src/lib/16_enti.c @@ -46,7 +46,7 @@ void EN_initentity(entity_t *enti, video_t *video) // modexClearRegion(&video->page[0], enti->x, enti->y, 16, 16, 2); // modexClearRegion(&video->page[2], 0, 0, video->page[2].sw, video->page[2].sh, 45); // modexClearRegion(&video->page[3], 0, 0, video->page[3].sw, video->page[3].sh, 47); - if(!video->bgps){ + if(!video->vga_state.bgps){ //video->ofs.pattern_ofs=(uint16_t)video->page[0].data; //video->ofs.offscreen_ofs=(uint16_t)video->page[3].data; w = (enti->x + 24) & (~3); diff --git a/src/lib/16_spri.c b/src/lib/16_spri.c index f2c58ff3..251bad5b 100755 --- a/src/lib/16_spri.c +++ b/src/lib/16_spri.c @@ -156,7 +156,7 @@ void animate_spri(entity_t *enti, video_t *video) } // render box bounds. y does not need modification, but x and width must be multiple of 4 - if(!video->rss) + if(!video->vga_state.rss) { if (x >= enti->overdraww) rx = (x - enti->overdraww) & (~3); else rx = -(video->page[0].dx); @@ -167,7 +167,7 @@ void animate_spri(entity_t *enti, video_t *video) if ((rx+w) > video->page[0].width) w = video->page[0].width-rx; if ((ry+h) > video->page[0].height) h = video->page[0].height-ry; - if(!video->bgps){ + if(!video->vga_state.bgps){ // block copy pattern to where we will draw the sprite vga_setup_wm1_block_copy(); o2 = video->ofs.offscreen_ofs; @@ -199,12 +199,12 @@ void animate_spri(entity_t *enti, video_t *video) #ifdef __DEBUG_SPRI__ if(dbg_delayanimation) delay(250);//{ while(!IN_KeyDown(sc_Space)/* && !IN_KeyDown(sc_Escape)*/){} delay(250); } #endif - if(!video->rss) + if(!video->vga_state.rss) { // restore ptr vga_state.vga_graphics_ram = omemptr; - if(!video->bgps){ + if(!video->vga_state.bgps){ // block copy to visible RAM from offscreen vga_setup_wm1_block_copy(); o = video->ofs.offscreen_ofs; // source offscreen @@ -217,6 +217,6 @@ void animate_spri(entity_t *enti, video_t *video) // restore stride vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = video->page[0].stridew; - vga_state.vga_graphics_ram = video->omemptr; + vga_state.vga_graphics_ram = video->vga_state.omemptr; video->dorender=1; } diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h index d31cac10..4de636c6 100755 --- a/src/lib/16_tail.h +++ b/src/lib/16_tail.h @@ -56,10 +56,10 @@ #define TAIL_FUNCTIONKEYFUNCTIONS0EXE \ if(gvar.in.inst->Keyboard[sc_F4]){ turboXT(12); IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[68/*sc_F10*/]){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1, &gvar); } \ - if(gvar.in.inst->Keyboard[sc_F8]){ gvar.video.bgps=!gvar.video.bgps; IN_UserInput(1, &gvar); } \ + if(gvar.in.inst->Keyboard[sc_F8]){ gvar.video.vga_state.bgps=!gvar.video.vga_state.bgps; IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[sc_F7]){ ZC_ShowMV(&gvar.mv, 0, 1); IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[sc_F6]){ ZC_ShowMV(&gvar.mv, 0, 0); IN_UserInput(1, &gvar); } \ - if(gvar.in.inst->Keyboard[sc_T]){ gvar.video.rss=!gvar.video.rss; IN_UserInput(1, &gvar); } \ + if(gvar.in.inst->Keyboard[sc_T]){ gvar.video.vga_state.rss=!gvar.video.vga_state.rss; IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[sc_P]){ modexpdump(&gvar.video.page[0]); IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[sc_Y]){ dbg_delayanimation=!dbg_delayanimation; IN_UserInput(1, &gvar); } \ RFDEBUGFUNCTIONS diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 871cf69e..2c2d0f72 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -365,18 +365,23 @@ typedef struct typedef struct { - char old_mode; //old video mode before game! - byte palette[PALSIZE], dpal[PALSIZE]; //palette array - page_t page[MAXPAGE]; //can be used as a pointer to root page[0] - word vmem_remain; //remaining video memory - byte num_of_pages; //number of actual pages - //doslib origi vars +//doslib origi vars byte far * omemptr; byte vga_draw_stride; byte vga_draw_stride_limit; // further X clipping - //end of doslib origi vars +//end of doslib origi vars boolean __near rss; //render sprite switch boolean __near bgps; //bg preservation render switch between old and new +} vga_state_t; + +typedef struct +{ + char old_mode; //old video mode before game! + byte palette[PALSIZE], dpal[PALSIZE]; //palette array + page_t page[MAXPAGE]; //can be used as a pointer to root page[0] + word vmem_remain; //remaining video memory + byte num_of_pages; //number of actual pages + vga_state_t vga_state; sword __near sprifilei; //player file's i nibble __near p; //render page number nibble __near sp; //show page number(for showpage) @@ -387,9 +392,6 @@ typedef struct ofs_t ofs; //offset vars used for doslib word vh; //video combined height //0000word startclk; float clk, tickclk; //timer -//newer vars -//TODO: find out how they are used -// byte grneeded[NUMCHUNKS]; } video_t; //from scroll16 diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 7e67b012..82e81375 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -274,7 +274,7 @@ void modexCalcVmemRemain(video_t *video) void VL_Initofs(video_t *video) { - if(!video->bgps) + if(!video->vga_state.bgps) { video->ofs.offscreen_ofs = video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height); video->ofs.pattern_ofs = (uint16_t)video->page[2].data; @@ -304,12 +304,12 @@ void modexHiganbanaPageSetup(video_t *video) VL_Initofs(video); //doslib origi var - video->omemptr= vga_state.vga_graphics_ram; - video->vga_draw_stride= vga_state.vga_draw_stride; - video->vga_draw_stride_limit= vga_state.vga_draw_stride_limit; + video->vga_state.omemptr= vga_state.vga_graphics_ram; + video->vga_state.vga_draw_stride= vga_state.vga_draw_stride; + video->vga_state.vga_draw_stride_limit= vga_state.vga_draw_stride_limit; //sprite render switch and bgpreservation switch - video->rss= 1; - video->bgps= 1; + video->vga_state.rss= 1; + video->vga_state.bgps= 1; //setup the buffersize video->page[0].dx=video->page[0].dy= diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 9e69713c..0cbb7397 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -347,7 +347,7 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) // if(id==0) mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM); // else -// if(mv[0].video->bgps) +// if(mv[0].video->vga_state.bgps) // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height); //mv[0].video->dorender=1;//ScrollRight } @@ -370,7 +370,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) // if(id==0) mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM); // else -// if(mv[0].video->bgps) +// if(mv[0].video->vga_state.bgps) // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height); //mv[0].video->dorender=1;//ScrollLeft } @@ -393,7 +393,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) // if(id==0) mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWROWNUM); // else -// if(mv[0].video->bgps) +// if(mv[0].video->vga_state.bgps) // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight); //mv[0].video->dorender=1;//ScrollUp } @@ -416,14 +416,14 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) // if(id==0) mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWROWNUM); // else -// if(mv[0].video->bgps) +// if(mv[0].video->vga_state.bgps) // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight); //mv[0].video->dorender=1;//ScrollDown } void ZC_mapScroll(map_view_t *mv, player_t *player, word pn) { - word b = mv[0].video->bgps; + word b = mv[0].video->vga_state.bgps; switch(player[pn].enti.d) { case 2://none @@ -534,7 +534,7 @@ void mapGoTo(map_view_t *mv, int tx, int ty) modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0); ZC_mapredraw(mv, tx, ty); - //if(mv[0].video->bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); + //if(mv[0].video->vga_state.bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); } void ZC_mapinitMV(map_view_t *mv, int tx, int ty) @@ -825,7 +825,7 @@ void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn) } } - if(pip[0].video->bgps && dd)//if moving wwww + if(pip[0].video->vga_state.bgps && dd)//if moving wwww { modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40); diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index 8f367bf7..f7887686 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -88,7 +88,7 @@ printf("\n\n");\ \ printf("gvar.video:\n");\ printf(" r=%u ", gvar.video.dorender);\ - printf("bgps=%u ", gvar.video.bgps);\ + printf("bgps=%u ", gvar.video.vga_state.bgps);\ printf("dbg_delayanimation=%u ", dbg_delayanimation);\ printf("\n\n"); @@ -96,12 +96,10 @@ printf("\n\n"); if(IN_KeyDown(sc_F11)){ pagedelayrendermap=!pagedelayrendermap; IN_UserInput(1, &gvar); } if(IN_KeyDown(sc_F10)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1, &gvar); } if(IN_KeyDown(sc_F9)){ pagenorendermap=!pagenorendermap; IN_UserInput(1, &gvar); } - if(IN_KeyDown(sc_F8)){ gvar.video.bgps=!gvar.video.bgps; IN_UserInput(1, &gvar); } - if(IN_KeyDown(sc_T)){ gvar.video.rss=!gvar.video.rss; IN_UserInput(1, &gvar); } + if(IN_KeyDown(sc_F8)){ gvar.video.vga_state.bgps=!gvar.video.vga_state.bgps; IN_UserInput(1, &gvar); } + if(IN_KeyDown(sc_T)){ gvar.video.vga_state.rss=!gvar.video.vga_state.rss; IN_UserInput(1, &gvar); } */ -extern boolean pagenorendermap, pagedelayrendermap; - extern char global_temp_status_text[512]; extern char global_temp_status_text2[512]; -- 2.39.5