X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_tail.c;h=4d6040cb640fcbb51a9907bf805aeb7998b76c3d;hb=adefd71cb8a3e70da10523e4eb97e442a655a6cd;hp=638e71102de4da83b93694a0479d6c85da9f4a25;hpb=5d9205e1e89bb330c1930f0260039edb846091eb;p=16.git diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index 638e7110..4d6040cb 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -26,8 +26,6 @@ #include "src/lib/16_tail.h" #include "src/lib/16text.h" -static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ - /* ========================== = @@ -38,25 +36,19 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ ========================== */ -void Startup16(global_game_variables_t *gvar) +void Startup16 (global_game_variables_t *gvar) { gvar->video.VL_Started=0; TL_VidInit(gvar); gvar->mm.mmstarted=0; gvar->pm.PMStarted=0; - MM_Startup(gvar); + StartupCAMMPM(gvar); #ifdef __WATCOMC__ #ifdef __DEBUG_InputMgr__ if(!dbg_nointest) #endif IN_Startup(gvar); #endif -#ifdef __16_PM__ - PM_Startup(gvar); - PM_CheckMainMem(gvar); - PM_UnlockMainMem(gvar); -#endif - CA_Startup(gvar); } //=========================================================================== @@ -71,23 +63,81 @@ void Startup16(global_game_variables_t *gvar) ========================== */ -void Shutdown16(global_game_variables_t *gvar) +void Shutdown16 (global_game_variables_t *gvar) { -#ifdef __16_PM__ - PM_Shutdown(gvar); -#endif #ifdef __WATCOMC__ #ifdef __DEBUG_InputMgr__ if(!dbg_nointest) #endif IN_Shutdown(gvar); #endif - CA_Shutdown(gvar); - MM_Shutdown(gvar); + ShutdownCAMMPM(gvar); #ifdef __WATCOMC__ if(gvar->video.VL_Started) - VGAmodeX(0, 1, gvar); + VL_Shutdown (gvar);//VGAmodeX(0, 1, gvar); +#endif +} + +//=========================================================================== + +/* +========================== += += StartupCAMMPM += +========================== +*/ + +void StartupCAMMPM (global_game_variables_t *gvar) +{ +/* + MM_Startup (); // so the signon screen can be freed + + SignonScreen (); + + VW_Startup (); + IN_Startup (); + PM_Startup (); + PM_UnlockMainMem (); + SD_Startup (); + CA_Startup (); + US_Startup (); +*/ + MM_Startup(gvar); +#ifdef __16_PM__ + PM_Startup(gvar); +//???? PM_CheckMainMem(gvar); + PM_UnlockMainMem(gvar); +#endif + CA_Startup(gvar); +} + +//=========================================================================== + +/* +========================== += += ShutdownCAMMPM += +========================== +*/ + +void ShutdownCAMMPM (global_game_variables_t *gvar) +{ +/* + US_Shutdown (); + SD_Shutdown (); + PM_Shutdown (); + IN_Shutdown (); + VW_Shutdown (); + CA_Shutdown (); + MM_Shutdown () +*/ +#ifdef __16_PM__ + PM_Shutdown(gvar); #endif + CA_Shutdown(gvar); + MM_Shutdown(gvar); } //=========================================================================== @@ -99,25 +149,25 @@ void Shutdown16(global_game_variables_t *gvar) = ==================== */ - -/*void ReadConfig(void) +#if 0 +void ReadConfig(void) { int file; - SDMode sd; - SMMode sm; - SDSMode sds; +// SDMode sd; +// SMMode sm; +// SDSMode sds; - if ( (file = open(configname,O_BINARY | O_RDONLY)) != -1) + if ( (file = open(CONFIGNAME,O_BINARY | O_RDONLY)) != -1) { // // valid config file // - read(file,Scores,sizeof(HighScore) * MaxScores); +// read(file,Scores,sizeof(HighScore) * MaxScores); - read(file,&sd,sizeof(sd)); - read(file,&sm,sizeof(sm)); - read(file,&sds,sizeof(sds)); +// read(file,&sd,sizeof(sd)); +// read(file,&sm,sizeof(sm)); +// read(file,&sds,sizeof(sds)); read(file,&mouseenabled,sizeof(mouseenabled)); read(file,&joystickenabled,sizeof(joystickenabled)); @@ -135,7 +185,7 @@ void Shutdown16(global_game_variables_t *gvar) close(file); - if (sd == sdm_AdLib && !AdLibPresent && !SoundBlasterPresent) + /*if (sd == sdm_AdLib && !AdLibPresent && !SoundBlasterPresent) { sd = sdm_PC; sd = smm_Off; @@ -143,7 +193,7 @@ void Shutdown16(global_game_variables_t *gvar) if ((sds == sds_SoundBlaster && !SoundBlasterPresent) || (sds == sds_SoundSource && !SoundSourcePresent)) - sds = sds_Off; + sds = sds_Off;*/ if (!MousePresent) mouseenabled = false; @@ -158,7 +208,7 @@ void Shutdown16(global_game_variables_t *gvar) // // no config file, so select by hardware // - if (SoundBlasterPresent || AdLibPresent) +/* if (SoundBlasterPresent || AdLibPresent) { sd = sdm_AdLib; sm = smm_AdLib; @@ -174,7 +224,7 @@ void Shutdown16(global_game_variables_t *gvar) else if (SoundSourcePresent) sds = sds_SoundSource; else - sds = sds_Off; + sds = sds_Off;*/ if (MousePresent) mouseenabled = true; @@ -191,7 +241,7 @@ void Shutdown16(global_game_variables_t *gvar) SD_SetMusicMode (sm); SD_SetSoundMode (sd); SD_SetDigiDevice (sds); -}*/ +} /* @@ -202,20 +252,20 @@ void Shutdown16(global_game_variables_t *gvar) ==================== */ -/*void WriteConfig(void) +void WriteConfig(void) { int file; - file = open(configname,O_CREAT | O_BINARY | O_WRONLY, + file = open(CONFIGNAME,O_CREAT | O_BINARY | O_WRONLY, S_IREAD | S_IWRITE | S_IFREG); if (file != -1) { - write(file,Scores,sizeof(HighScore) * MaxScores); +// write(file,Scores,sizeof(HighScore) * MaxScores); - write(file,&SoundMode,sizeof(SoundMode)); - write(file,&MusicMode,sizeof(MusicMode)); - write(file,&DigiMode,sizeof(DigiMode)); +// write(file,&SoundMode,sizeof(SoundMode)); +// write(file,&MusicMode,sizeof(MusicMode)); +// write(file,&DigiMode,sizeof(DigiMode)); write(file,&mouseenabled,sizeof(mouseenabled)); write(file,&joystickenabled,sizeof(joystickenabled)); @@ -228,13 +278,13 @@ void Shutdown16(global_game_variables_t *gvar) write(file,&buttonmouse,sizeof(buttonmouse)); write(file,&buttonjoy,sizeof(buttonjoy)); - write(file,&viewsize,sizeof(viewsize)); +// write(file,&viewsize,sizeof(viewsize)); write(file,&mouseadjustment,sizeof(mouseadjustment)); close(file); } -}*/ - +} +#endif //=========================================================================== /* @@ -245,70 +295,66 @@ void Shutdown16(global_game_variables_t *gvar) =================== */ -#define PIXPERFRAME 1600 - -void FizzleFade (unsigned source, unsigned dest, - unsigned width,unsigned height, boolean abortable, global_game_variables_t *gv) +boolean FizzleFade (unsigned source, unsigned dest, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar) { - unsigned drawofs,pagedelta; - unsigned char maskb[8] = {1,2,4,8,16,32,64,128}; - unsigned x,y,p,frame; - long rndval; - word TimeCount = *clockw; - word screenseg = SCREENSEG; + word p,pixperframe; + unsigned drawofs,pagedelta; + byte mask,maskb[8] = {1,2,4,8}; + unsigned x,y,frame; + long rndval; + word screenseg; +#ifdef __WATCOMC__ + unsigned esorig;//,q; +#endif pagedelta = dest-source; -//++++ VL_SetScreen (dest,0); rndval = 1; +#ifdef __WATCOMC__ + esorig = 0;// q = 16; +#endif x = y = 0; + pixperframe = (dword)(gvar->video.page[0].width*gvar->video.page[0].height)/frames; + screenseg = SCREENSEG; + + IN_StartAck (gvar); +// modexClearRegion(&(gvar->video.page[0]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 0); +// modexClearRegion(&(gvar->video.page[1]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 15); + +#ifdef __WATCOMC__ __asm { - mov es,[screenseg] - mov dx,SC_INDEX - mov al,SC_MAPMASK - out dx,al + mov [esorig],es } - - TimeCount=frame=0; - do // while (1) +#endif +// TimeCount= + frame=0; + do // while (1) { - if (abortable) - { - IN_ReadControl(0,gv); - if (gv->player[0].info.button0 || gv->player[0].info.button1 || gv->in.inst->Keyboard[sc_Space] - || gv->in.inst->Keyboard[sc_Enter]) - { -//++++ VW_ScreenToScreen (source,dest,width/8,height); - return; - } + if (abortable && IN_CheckAck (gvar) ) + return true; + + __asm { + mov es,[screenseg] } - for (p=0;pwidth || y>height) +// if ((x>width || y>height) && (xvideo.ofs.ylookup[y]; +// drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2); + drawofs = source+(y*gvar->video.page[0].stridew) + (x>>2); + + // + // copy one pixel + // + mask = x&3; + VGAREADMAP(mask); + mask = maskb[mask]; + VGAMAPMASK(mask); __asm { - mov cx,[x] - mov si,cx - and si,7 - mov dx,GC_INDEX - mov al,GC_BITMASK - mov ah,BYTE PTR [maskb+si] - out dx,ax - - mov si,[drawofs] - shr cx,1 - shr cx,1 - shr cx,1 - add si,cx - mov di,si + mov di,[drawofs] + mov al,[es:di] add di,[pagedelta] - - mov dx,GC_INDEX - mov al,GC_READMAP // leave GC_INDEX set to READMAP - out dx,al - - mov dx,SC_INDEX+1 - mov al,1 - out dx,al - mov dx,GC_INDEX+1 - mov al,0 - out dx,al - - mov bl,[es:si] - xchg [es:di],bl - - mov dx,SC_INDEX+1 - mov al,2 - out dx,al - mov dx,GC_INDEX+1 - mov al,1 - out dx,al - - mov bl,[es:si] - xchg [es:di],bl - - mov dx,SC_INDEX+1 - mov al,4 - out dx,al - mov dx,GC_INDEX+1 - mov al,2 - out dx,al - - mov bl,[es:si] - xchg [es:di],bl - - mov dx,SC_INDEX+1 - mov al,8 - out dx,al - mov dx,GC_INDEX+1 - mov al,3 - out dx,al - - mov bl,[es:si] - xchg [es:di],bl + mov [es:di],al } if (rndval == 1) // entire sequence has been completed - { -//++++ VGABITMASK(255); -//++++ VGAMAPMASK(15); - return; - } + return false; } frame++; -//++++ while (TimeCountca.audiosegs[STARTMUSIC + i]) + { + MM_SetPurge(MEMPTRCONV gvar->ca.audiosegs[STARTMUSIC + i],3, gvar); + MM_SetLock(MEMPTRCONV gvar->ca.audiosegs[STARTMUSIC + i],false, gvar); + } } -//=========================================================================== +//========================================================================== + + +/* +================= += += StartMusic += +================= +*/ + +void TL_StartMusic(global_game_variables_t *gvar) +{ + musicnames chunk; + + SD_MusicOff(); + chunk = 0;//++++songs[gamestate.mapon+gamestate.episode*10]; + +// if ((chunk == -1) || (MusicMode != smm_AdLib)) +//DEBUG control panel return; + +//++++ MM_BombOnError (false,gvar); +//++++ CA_CacheAudioChunk(STARTMUSIC + chunk, gvar); +//++++ MM_BombOnError (true,gvar); +//++++ if (gvar->mm.mmerror) +//++++ gvar->mm.mmerror = false; +//++++ else +//++++ { + MM_SetLock(MEMPTRCONV gvar->ca.audiosegs[STARTMUSIC + chunk],true, gvar); + SD_StartMusic((MusicGroup far *)gvar->ca.audiosegs[STARTMUSIC + chunk]); +//++++ } +} /* ================== @@ -448,6 +513,128 @@ void DebugMemory_(global_game_variables_t *gvar, boolean q) // if(q) MM_ShowMemory (gvar); } +/* +=================== += += TestSprites += +=================== +*/ + +#if 0 +#define DISPWIDTH 110 +#define TEXTWIDTH 40 +void TestSprites(void) +{ + int hx,hy,sprite,oldsprite,bottomy,topx,shift; + spritetabletype far *spr; + spritetype _seg *block; + unsigned mem,scan; + + + VW_FixRefreshBuffer (); + US_CenterWindow (30,17); + + US_CPrint ("Sprite Test"); + US_CPrint ("-----------"); + + hy=PrintY; + hx=(PrintX+56)&(~7); + topx = hx+TEXTWIDTH; + + US_Print ("Chunk:\nWidth:\nHeight:\nOrgx:\nOrgy:\nXl:\nYl:\nXh:\nYh:\n" + "Shifts:\nMem:\n"); + + bottomy = PrintY; + + sprite = STARTSPRITES; + shift = 0; + + do + { + if (sprite>=STARTTILE8) + sprite = STARTTILE8-1; + else if (spritewidth);US_Print ("\n");PrintX=hx; + US_PrintUnsigned (spr->height);US_Print ("\n");PrintX=hx; + US_PrintSigned (spr->orgx);US_Print ("\n");PrintX=hx; + US_PrintSigned (spr->orgy);US_Print ("\n");PrintX=hx; + US_PrintSigned (spr->xl);US_Print ("\n");PrintX=hx; + US_PrintSigned (spr->yl);US_Print ("\n");PrintX=hx; + US_PrintSigned (spr->xh);US_Print ("\n");PrintX=hx; + US_PrintSigned (spr->yh);US_Print ("\n");PrintX=hx; + US_PrintSigned (spr->shifts);US_Print ("\n");PrintX=hx; + if (!block) + { + US_Print ("-----"); + } + else + { + mem = block->sourceoffset[3]+5*block->planesize[3]; + mem = (mem+15)&(~15); // round to paragraphs + US_PrintUnsigned (mem); + } + + oldsprite = sprite; + do + { + // + // draw the current shift, then wait for key + // + VWB_Bar(topx,hy,DISPWIDTH,bottomy-hy,WHITE); + if (block) + { + PrintX = topx; + PrintY = hy; + US_Print ("Shift:"); + US_PrintUnsigned (shift); + US_Print ("\n"); + VWB_DrawSprite (topx+16+shift*2,PrintY,sprite); + } + + VW_UpdateScreen(); + + scan = IN_WaitForKey (); + + switch (scan) + { + case sc_UpArrow: + sprite++; + break; + case sc_DownArrow: + sprite--; + break; + case sc_LeftArrow: + if (--shift == -1) + shift = 3; + break; + case sc_RightArrow: + if (++shift == 4) + shift = 0; + break; + case sc_Escape: + return; + } + + } while (sprite == oldsprite); + + } while (1); + + +} + +#endif + /* ========================== = @@ -522,10 +709,7 @@ void Quit (global_game_variables_t *gvar, char *error) //=========================================================================== -#ifndef __WATCOMC__ -char global_temp_status_text[512]; -char global_temp_status_text2[512]; -#else +#ifdef __WATCOMC__ // // for mary4 (XT) // this is from my XT's BIOS