X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_tail.c;h=c0d6d89fdee243505a3ce0ed990b0d2d39117771;hb=0d61e6c7f0e9fbb2838962ef7452c2f6c8a5455b;hp=b2acec13763597edfd912d1461b82f605965490e;hpb=fb900d77df687bfa549995e15a762017c381e552;p=16.git diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index b2acec13..c0d6d89f 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * This file is part of Project 16. * @@ -20,10 +20,13 @@ * */ /* - * 16 library + * 16 tail library */ #include "src/lib/16_tail.h" +#include "src/lib/16text.h" + +static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ /* ========================== @@ -37,15 +40,70 @@ void Startup16(global_game_variables_t *gvar) { +#ifdef __WATCOMC__ + start_timer(gvar); +#endif + gvar->video.VL_Started=0; + TL_VidInit(gvar); + gvar->mm.mmstarted=0; + gvar->pm.PMStarted=0; + MM_Startup(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); +} + +//=========================================================================== + +/* +========================== += += Shutdown16 += += Shuts down all ID_?? managers += +========================== +*/ + +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); +#ifdef __WATCOMC__ + if(gvar->video.VL_Started) + VGAmodeX(0, 1, gvar); +#endif +} + +void TL_VidInit(global_game_variables_t *gvar) +{ #ifdef __WATCOMC__ // DOSLIB: check our environment probe_dos(); // DOSLIB: what CPU are we using? // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS. - // So this code by itself shouldn't care too much what CPU it's running on. Except that other - // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for - // the CPU to carry out tasks. --J.C. + // So this code by itself shouldn't care too much what CPU it's running on. Except that other + // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for + // the CPU to carry out tasks. --J.C. cpu_probe(); // DOSLIB: check for VGA @@ -61,46 +119,338 @@ void Startup16(global_game_variables_t *gvar) if (_DEBUG_INIT() == 0) { #ifdef DEBUGSERIAL - printf("WARNING: Failed to initialize DEBUG output\n"); + //printf("WARNING: Failed to initialize DEBUG output\n"); #endif } _DEBUG("Serial debug output started\n"); // NTS: All serial output must end messages with newline, or DOSBox-X will not emit text to log _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); -#endif - gvar->mm.mmstarted=0; - gvar->pm.PMStarted=0; - MM_Startup(gvar); - IN_Startup(gvar); - PM_Startup(gvar); - PM_UnlockMainMem(gvar); - CA_Startup(gvar); -#ifdef __WATCOMC__ - start_timer(gvar); -#endif + textInit(); + // get old video mode + //in.h.ah = 0xf; + //int86(0x10, &in, &out); + if(!gvar->video.old_mode) gvar->video.old_mode = vgaGetMode();//out.h.al; +#else + gvar->video.old_mode = 3; +#endif } + //=========================================================================== /* -========================== +==================== = -= Shutdown16 += ReadConfig = -= Shuts down all ID_?? managers +==================== +*/ + +/*void ReadConfig(void) +{ + int file; + SDMode sd; + SMMode sm; + SDSMode sds; + + + if ( (file = open(configname,O_BINARY | O_RDONLY)) != -1) + { + // + // valid config file + // + read(file,Scores,sizeof(HighScore) * MaxScores); + + 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)); + read(file,&joypadenabled,sizeof(joypadenabled)); + read(file,&joystickprogressive,sizeof(joystickprogressive)); + read(file,&joystickport,sizeof(joystickport)); + + read(file,&dirscan,sizeof(dirscan)); + read(file,&buttonscan,sizeof(buttonscan)); + read(file,&buttonmouse,sizeof(buttonmouse)); + read(file,&buttonjoy,sizeof(buttonjoy)); + + read(file,&viewsize,sizeof(viewsize)); + read(file,&mouseadjustment,sizeof(mouseadjustment)); + + close(file); + + if (sd == sdm_AdLib && !AdLibPresent && !SoundBlasterPresent) + { + sd = sdm_PC; + sd = smm_Off; + } + + if ((sds == sds_SoundBlaster && !SoundBlasterPresent) || + (sds == sds_SoundSource && !SoundSourcePresent)) + sds = sds_Off; + + if (!MousePresent) + mouseenabled = false; + if (!JoysPresent[joystickport]) + joystickenabled = false; + + MainMenu[6].active=1; + MainItems.curpos=0; + } + else + { + // + // no config file, so select by hardware + // + if (SoundBlasterPresent || AdLibPresent) + { + sd = sdm_AdLib; + sm = smm_AdLib; + } + else + { + sd = sdm_PC; + sm = smm_Off; + } + + if (SoundBlasterPresent) + sds = sds_SoundBlaster; + else if (SoundSourcePresent) + sds = sds_SoundSource; + else + sds = sds_Off; + + if (MousePresent) + mouseenabled = true; + + joystickenabled = false; + joypadenabled = false; + joystickport = 0; + joystickprogressive = false; + + viewsize = 15; + mouseadjustment=5; + } + + SD_SetMusicMode (sm); + SD_SetSoundMode (sd); + SD_SetDigiDevice (sds); +}*/ + + +/* +==================== = -========================== += WriteConfig += +==================== */ -void Shutdown16(global_game_variables_t *gvar) +/*void WriteConfig(void) { - PM_Shutdown(gvar); - IN_Shutdown(gvar); - CA_Shutdown(gvar); - MM_Shutdown(gvar); -} + int file; + 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,&SoundMode,sizeof(SoundMode)); + write(file,&MusicMode,sizeof(MusicMode)); + write(file,&DigiMode,sizeof(DigiMode)); + + write(file,&mouseenabled,sizeof(mouseenabled)); + write(file,&joystickenabled,sizeof(joystickenabled)); + write(file,&joypadenabled,sizeof(joypadenabled)); + write(file,&joystickprogressive,sizeof(joystickprogressive)); + write(file,&joystickport,sizeof(joystickport)); + + write(file,&dirscan,sizeof(dirscan)); + write(file,&buttonscan,sizeof(buttonscan)); + write(file,&buttonmouse,sizeof(buttonmouse)); + write(file,&buttonjoy,sizeof(buttonjoy)); + + write(file,&viewsize,sizeof(viewsize)); + write(file,&mouseadjustment,sizeof(mouseadjustment)); + + close(file); + } +}*/ + +//=========================================================================== + +/* +=================== += += FizzleFade += +=================== +*/ + +#define PIXPERFRAME 1600 + +void FizzleFade (unsigned source, unsigned dest, + unsigned width,unsigned height, boolean abortable, global_game_variables_t *gv) +{ + 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; + + pagedelta = dest-source; +//++++ VL_SetScreen (dest,0); + rndval = 1; + x = y = 0; + + __asm { + mov es,[screenseg] + mov dx,SC_INDEX + mov al,SC_MAPMASK + out dx,al + } + + 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; + } + } + + for (p=0;pwidth || y>height) + continue; + drawofs = source+gv->video.ofs.ylookup[y]; + + __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 + 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 + } + + if (rndval == 1) // entire sequence has been completed + { +//++++ VGABITMASK(255); +//++++ VGAMAPMASK(15); + return; + } + } + frame++; +//++++ while (TimeCount 0; z >>= 1) + { + strcat(b, ((x & z) == z) ? "1" : "0"); + } + return b; +} + +const char *nibble_to_binary(nibble x) +{ + static char b[9]; + int z; + + b[0] = '\0'; + for (z = 8; z > 0; z >>= 1) + { + strcat(b, ((x & z) == z) ? "1" : "0"); + } + return b; +} + +const char *boolean_to_binary(boolean x) +{ + static char b[9]; + int z; + + b[0] = '\0'; + for (z = 1; z > 0; z >>= 1) + { + strcat(b, ((x & z) == z) ? "1" : "0"); + } + return b; +} + +void nibbletest() +{ + nibble pee; + printf("nibbletest\n"); + /* nibble to binary string */ + for(pee=0;pee<18;pee++) + printf(" %u %s\n", pee, nibble_to_binary(pee)); + printf(" sizeof(nibble)=%s\n", nibble_to_binary(sizeof(nibble))); + printf("end of nibble test\n"); +} + +void booleantest() +{ + boolean pee; + printf("booleantest\n"); + /* boolean to binary string */ + for(pee=0;pee<4;pee++) + printf(" %u %s\n", pee, boolean_to_binary(pee)); + printf(" sizeof(boolean)=%s\n", boolean_to_binary(sizeof(boolean))); + printf("end of boolean test\n"); +} + +#ifdef __BORLANDC__ +word modexPalOverscan(word col) +{ + //modexWaitBorder(); + outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */ + outp(PAL_DATA_REG, col); + return col; +} +#endif