X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=blobdiff_plain;f=src%2Flib%2F16_tail.c;h=7b5fdcb4de0c44ea65d8a5809290383c367d39d7;hp=02216ce65260276b2d13c08ca25f61a40d395936;hb=af2715fef8681d909afe82f7baaf5e13baabb76f;hpb=6556e86810e8560cb88a0c0042c7366240ab4e60 diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index 02216ce6..7b5fdcb4 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. * @@ -24,6 +24,7 @@ */ #include "src/lib/16_tail.h" +#include "src/lib/16text.h" /* ========================== @@ -45,9 +46,9 @@ void Startup16(global_game_variables_t *gvar) // 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 @@ -63,29 +64,29 @@ 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); + + textInit(); #endif gvar->mm.mmstarted=0; gvar->pm.PMStarted=0; -#ifdef __DEBUG__ - if(!dbg_nommpmca) -#endif MM_Startup(gvar); -if(!dbg_noplayerinpu) +#ifdef __WATCOMC__ +#ifdef __DEBUG_InputMgr__ + if(!dbg_nointest) +#endif IN_Startup(gvar); -#ifdef __DEBUG__ - if(!dbg_nommpmca){ #endif +#ifdef __16_PM__ PM_Startup(gvar); + PM_CheckMainMem(gvar); PM_UnlockMainMem(gvar); - CA_Startup(gvar); -#ifdef __DEBUG__ - } #endif + CA_Startup(gvar); } //=========================================================================== @@ -102,23 +103,168 @@ if(!dbg_noplayerinpu) void Shutdown16(global_game_variables_t *gvar) { -#ifdef __DEBUG__ - if(!dbg_nommpmca) -#endif +#ifdef __16_PM__ PM_Shutdown(gvar); -if(!dbg_noplayerinpu) +#endif +#ifdef __WATCOMC__ +#ifdef __DEBUG_InputMgr__ + if(!dbg_nointest) +#endif IN_Shutdown(gvar); -#ifdef __DEBUG__ - if(!dbg_nommpmca){ #endif CA_Shutdown(gvar); MM_Shutdown(gvar); -#ifdef __DEBUG__ - } +#ifdef __WATCOMC__ + VGAmodeX(0, 1, gvar); #endif } +//=========================================================================== + +/* +==================== += += ReadConfig += +==================== +*/ + +/*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 WriteConfig(void) +{ + 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); + } +}*/ + //=========================================================================== /* @@ -136,9 +282,9 @@ void DebugMemory_(global_game_variables_t *gvar, boolean q) US_CPrint ("Memory Usage"); US_CPrint ("------------"); - US_Print ("Total :"); + US_Print ("Total :"); US_PrintUnsigned (mminfo.mainmem/1024); - US_Print ("k\nFree :"); + US_Print ("k\nFree :"); US_PrintUnsigned (MM_UnusedMemory()/1024); US_Print ("k\nWith purge:"); US_PrintUnsigned (MM_TotalFree()/1024); @@ -157,11 +303,28 @@ void DebugMemory_(global_game_variables_t *gvar, boolean q) printf("With purge:"); if(q) printf(" "); printf("%uk\n", MM_TotalFree(gvar)/1024); if(q) printf("------------\n"); #ifdef __WATCOMC__ - IN_Ack (); + //IN_Ack (); #endif if(q) MM_ShowMemory (gvar); } -#ifdef __WATCOMC__ + +/* +========================== += += ClearMemory += +========================== +*/ + +void ClearMemory (global_game_variables_t *gvar) +{ +#ifdef __16_PM__ + PM_UnlockMainMem(gvar); +#endif + //snd + MM_SortMem (gvar); +} + /* ========================== = @@ -170,46 +333,43 @@ void DebugMemory_(global_game_variables_t *gvar, boolean q) ========================== */ -void Quit (char *error) +void Quit (global_game_variables_t *gvar, char *error) { - //unsigned finscreen; + //unsigned finscreen; memptr screen=0; - union REGS in, out; - //ClearMemory (); + ClearMemory (gvar); if (!*error) { - //WriteConfig (); +// #ifndef JAPAN +// CA_CacheGrChunk (ORDERSCREEN); +// screen = grsegs[ORDERSCREEN]; +// #endif +// WriteConfig (); } else { - //CA_CacheGrChunk (ERRORSCREEN); - //screen = grsegs[ERRORSCREEN]; +// CA_CacheGrChunk (ERRORSCREEN); +// screen = grsegs[ERRORSCREEN]; } - - //ShutdownId (); - IN_Shutdown(); - //modexLeave(); - in.h.ah = 0x00; - in.h.al = 0x3; - int86(0x10, &in, &out); + Shutdown16(gvar); if (error && *error) { - //movedata ((unsigned)screen,7,0xb800,0,7*160); - //gotoxy (10,4); - fprintf(stderr, "%s\n", error); - //gotoxy (1,8); - exit(1); + //movedata((unsigned)screen,7,0xb800,0,7*160); + gotoxy (10,4); + fprintf(stderr, "%s\n", error); + gotoxy (1,8); + exit(1); } else if (!error || !(*error)) { - //clrscr(); - //#ifndef JAPAN + clrscr(); +#ifndef JAPAN movedata ((unsigned)screen,7,0xb800,0,4000); - //gotoxy(1,24); - //#endif + gotoxy(1,24); +#endif //asm mov bh,0 //asm mov dh,23 // row //asm mov dl,0 // collumn @@ -219,10 +379,69 @@ void Quit (char *error) exit(0); } -#endif //=========================================================================== +#ifndef __WATCOMC__ +char global_temp_status_text[512]; +char global_temp_status_text2[512]; +#else +// +// for mary4 (XT) +// this is from my XT's BIOS +// http://www.phatcode.net/downloads.php?id=101 +// +void turboXT(byte bakapee) +{ + __asm { + push ax + push bx + push cx + in al, 61h //; Read equipment flags + xor al, bakapee //; toggle speed + out 61h, al //; Write new flags back + + mov bx, 0F89h //; low pitch blip + and al, 4 //; Is turbo mode set? + jz @@do_beep + mov bx, 52Eh //; high pitch blip + +@@do_beep: + mov al, 10110110b //; Timer IC 8253 square waves + out 43h, al //; channel 2, speaker + mov ax, bx + out 42h, al //; send low order + mov al, ah //; load high order + out 42h, al //; send high order + in al, 61h //; Read IC 8255 machine status + push ax + or al, 00000011b + out 61h, al //; Turn speaker on + mov cx, 2000h +@@delay: + loop @@delay + pop ax + out 61h, al //; Turn speaker off + pop cx + pop bx + pop ax + } +} +#endif + +const char *word_to_binary(word x) +{ + static char b[17]; + int z; + + b[0] = '\0'; + for (z = 16; z > 0; z >>= 1) + { + strcat(b, ((x & z) == z) ? "1" : "0"); + } + return b; +} + const char *nibble_to_binary(nibble x) { static char b[9];