X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_tail.c;h=d8f18b9483fa429b79bab5705ae0e653e9b438af;hb=40badd0143ad830bd4d873acb9a836f191cc6d57;hp=742e113289140267c3ddb5d2562b46a02556d7bb;hpb=3e67fca24b59811ced65929a140f6c242b161d90;p=16.git diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index 742e1132..d8f18b94 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * Copyright (C) 2012-2018 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * This file is part of Project 16. * @@ -142,6 +142,112 @@ void ShutdownCAMMPM (global_game_variables_t *gvar) //=========================================================================== +//////////////////////////////////////////////////////////////////// +// +// HANDLE INTRO SCREEN (SYSTEM CONFIG) +// +//////////////////////////////////////////////////////////////////// +void MU_IntroScreen(global_game_variables_t *gvar) +{ +#define MAINCOLOR 0x6c +#define EMSCOLOR 0x6c +#define XMSCOLOR 0x6c + +#define FILLCOLOR 14 + + long memory,emshere,xmshere; + int i,num,ems[10]={100,200,300,400,500,600,700,800,900,1000}, + xms[10]={100,200,300,400,500,600,700,800,900,1000}, + main[10]={32,64,96,128,160,192,224,256,288,320}; + + gvar->video.print.t=1; + gvar->video.print.tlsw=1; + gvar->video.print.bgcolor=8; + gvar->video.print.color=5; + + // + // DRAW MAIN MEMORY + // + num=32; + gvar->video.print.x=49-32; + + memory=(1023l+gvar->mmi.nearheap+gvar->mmi.farheap)/1024l; + for (i=0;i<10;i++) + if (memory>=main[i]) + { + gvar->video.print.y=163-8*i; + sprintf(global_temp_status_text, "% 4u", num); VL_print(global_temp_status_text, 0, gvar); + VL_Bar(49,163-8*i,6,5,MAINCOLOR-i,gvar); + num+=32; + } + gvar->video.print.y=171; + VL_print("MAIN", 0, gvar); + + + // + // DRAW EMS MEMORY + // + if (gvar->pm.emm.EMSPresent) + { + num=100; + gvar->video.print.x=89-32; + + emshere=4l*gvar->pm.emm.EMSPagesAvail; + for (i=0;i<10;i++) + if (emshere>=ems[i]) + { + gvar->video.print.y=163-8*i; + sprintf(global_temp_status_text, "% 4u", num); VL_print(global_temp_status_text, 0, gvar); + VL_Bar(89,163-8*i,6,5,EMSCOLOR-i,gvar); + num+=100; + } + gvar->video.print.y=171; + VL_print(" EMS", 0, gvar); + } + + // + // DRAW XMS MEMORY + // + if (gvar->pm.xmm.XMSPresent) + { + num=100; + gvar->video.print.x=129-32; + + xmshere=4l*gvar->pm.xmm.XMSPagesAvail; + for (i=0;i<10;i++) + if (xmshere>=xms[i]) + { + gvar->video.print.y=163-8*i; + sprintf(global_temp_status_text, "% 4u", num); VL_print(global_temp_status_text, 0, gvar); + VL_Bar(129,163-8*i,6,5,XMSCOLOR-i,gvar); + num+=100; + } + gvar->video.print.y=171; + VL_print(" XMS", 0, gvar); + } + + // + // FILL BOXES + // + if (gvar->in.MousePresent) + VL_Bar(164,82,12,2,FILLCOLOR,gvar); + + if (gvar->in.JoysPresent[0] || gvar->in.JoysPresent[1]) + VL_Bar(164,105,12,2,FILLCOLOR,gvar); + +//++++ if (gvar->sd.AdLibPresent)//SB && !SoundBlasterPresent) +//++++ VL_Bar(164,128,12,2,FILLCOLOR,gvar); + +//SB if (SoundBlasterPresent) +//SB VL_Bar(164,151,12,2,FILLCOLOR,gvar); + +//SS if (SoundSourcePresent) +//SS VL_Bar(164,174,12,2,FILLCOLOR,gvar); + IN_Ack (gvar); +} + +//=========================================================================== + /* ==================== = @@ -149,29 +255,28 @@ void ShutdownCAMMPM (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)); - read(file,&joypadenabled,sizeof(joypadenabled)); read(file,&joystickprogressive,sizeof(joystickprogressive)); read(file,&joystickport,sizeof(joystickport)); @@ -185,7 +290,7 @@ void ShutdownCAMMPM (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; @@ -193,7 +298,7 @@ void ShutdownCAMMPM (global_game_variables_t *gvar) if ((sds == sds_SoundBlaster && !SoundBlasterPresent) || (sds == sds_SoundSource && !SoundSourcePresent)) - sds = sds_Off; + sds = sds_Off;*/ if (!MousePresent) mouseenabled = false; @@ -208,7 +313,7 @@ void ShutdownCAMMPM (global_game_variables_t *gvar) // // no config file, so select by hardware // - if (SoundBlasterPresent || AdLibPresent) +/* if (SoundBlasterPresent || AdLibPresent) { sd = sdm_AdLib; sm = smm_AdLib; @@ -224,13 +329,12 @@ void ShutdownCAMMPM (global_game_variables_t *gvar) else if (SoundSourcePresent) sds = sds_SoundSource; else - sds = sds_Off; + sds = sds_Off;*/ if (MousePresent) mouseenabled = true; joystickenabled = false; - joypadenabled = false; joystickport = 0; joystickprogressive = false; @@ -241,7 +345,7 @@ void ShutdownCAMMPM (global_game_variables_t *gvar) SD_SetMusicMode (sm); SD_SetSoundMode (sd); SD_SetDigiDevice (sds); -}*/ +} /* @@ -252,24 +356,23 @@ void ShutdownCAMMPM (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)); - write(file,&joypadenabled,sizeof(joypadenabled)); write(file,&joystickprogressive,sizeof(joystickprogressive)); write(file,&joystickport,sizeof(joystickport)); @@ -278,13 +381,13 @@ void ShutdownCAMMPM (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 //=========================================================================== /* @@ -450,6 +553,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 + // + VL_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 + /* ========================== = @@ -524,10 +749,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 @@ -571,37 +793,52 @@ void turboXT(byte bakapee) } #endif -const char *word_to_binary(word x) +//from https://stackoverflow.com/questions/18327439/printing-binary-representation-of-a-char-in-c +const char *word_to_binary(int x) { static char b[17]; int z; b[0] = '\0'; - for (z = 16; z > 0; z >>= 1) + for (z = 256; z > 0; z >>= 1) { +/// printf(" z=%u b=%u x=%u\n", z, b, x); strcat(b, ((x & z) == z) ? "1" : "0"); } return b; } -const char *nibble_to_binary(nibble x) +const char *byte_to_binary(int x) { static char b[9]; int z; b[0] = '\0'; - for (z = 8; z > 0; z >>= 1) + for (z = 128; z > 0; z >>= 1) { strcat(b, ((x & z) == z) ? "1" : "0"); } return b; } -const char *boolean_to_binary(boolean x) +const char *nibble_to_binary(int 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(int x) +{ + static char b[3]; + int z; + b[0] = '\0'; for (z = 1; z > 0; z >>= 1) { @@ -610,13 +847,35 @@ const char *boolean_to_binary(boolean x) return b; } +void wordtest() +{ + word pee; + printf("wordtest\n"); + /* word to binary string */ + for(pee=0;pee<280;pee++) + printf(" %u %s\n", pee, word_to_binary(pee)); + printf(" sizeof(word)=%s\n", word_to_binary(sizeof(word))); + printf("end of word test\n"); +} + +void bytetest() +{ + byte pee; + printf("bytetest\n"); + /* byte to binary string */ + for(pee=0;pee<18;pee++) + printf(" %u %s\n", pee, byte_to_binary(pee)); + printf(" sizeof(byte)=%s\n", byte_to_binary(sizeof(byte))); + printf("end of byte test\n"); +} + 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(" %u %s\n", pee, nibble_to_binary(pee)); printf(" sizeof(nibble)=%s\n", nibble_to_binary(sizeof(nibble))); printf("end of nibble test\n"); } @@ -627,7 +886,7 @@ void booleantest() printf("booleantest\n"); /* boolean to binary string */ for(pee=0;pee<4;pee++) - printf(" %u %s\n", pee, boolean_to_binary(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"); }