From: sparky4 Date: Thu, 30 Jul 2015 15:43:03 +0000 (-0500) Subject: wwww added timer!! X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=1287746074527ec8af4c6ca515802e5a72d0ef05;p=16.git wwww added timer!! modified: 16.exe deleted: 16.hed modified: bakapi.exe modified: exmmtest.exe modified: fmemtest.exe modified: fontgfx.exe modified: fonttest.exe modified: inputest.exe modified: makefile modified: maptest.exe modified: palettec.exe modified: pcxtest.exe modified: scroll.exe modified: sountest.exe modified: src/lib/16_head.c modified: src/lib/16_head.h modified: src/lib/doslib/cpu.c modified: src/lib/mapread.c modified: src/lib/scroll16.c modified: src/lib/scroll16.h new file: src/lib/timer.c new file: src/lib/timer.h modified: src/scroll.c modified: test.exe modified: test2.exe modified: tsthimem.exe --- diff --git a/16.exe b/16.exe index f0f538fe..40978011 100644 Binary files a/16.exe and b/16.exe differ diff --git a/16.hed b/16.hed deleted file mode 100644 index 610bc56e..00000000 Binary files a/16.hed and /dev/null differ diff --git a/bakapi.exe b/bakapi.exe index 6eba4479..f9447403 100644 Binary files a/bakapi.exe and b/bakapi.exe differ diff --git a/exmmtest.exe b/exmmtest.exe index 680624bf..eaaf113a 100644 Binary files a/exmmtest.exe and b/exmmtest.exe differ diff --git a/fmemtest.exe b/fmemtest.exe index dd8b328a..fddfc4b5 100644 Binary files a/fmemtest.exe and b/fmemtest.exe differ diff --git a/fontgfx.exe b/fontgfx.exe index 364eb370..8da2cc7f 100644 Binary files a/fontgfx.exe and b/fontgfx.exe differ diff --git a/fonttest.exe b/fonttest.exe index 7f7af800..b8d8bd9a 100644 Binary files a/fonttest.exe and b/fonttest.exe differ diff --git a/inputest.exe b/inputest.exe index b23b7ecd..f655971d 100644 Binary files a/inputest.exe and b/inputest.exe differ diff --git a/makefile b/makefile index cbb1878f..ea0c9b84 100644 --- a/makefile +++ b/makefile @@ -19,15 +19,17 @@ JSMNLIB=$(SRCLIB)jsmn$(DIRSEP) DOSLIB=$(SRCLIB)doslib$(DIRSEP) WCPULIB=$(SRCLIB)wcpu$(DIRSEP) +16FLAGS=-fh=16.hed +BAKAPIFLAGS=-fh=bakapi.hed ZFLAGS=-zk0 -zu -zc# -zm# -zdp# -zp16 -zq -#DFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 -CFLAGS=-ei -wo -x -r -fh=16.hed -mc -k60000#16384# +DFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 +CFLAGS=-ei -wo -x -r -mc -k57344 OFLAGS=-ot -ox -ob -oh -or -om -ol# -ol+ FLAGS=-0 -d2 -lr $(OFLAGS) $(CFLAGS) $(DFLAGS) $(ZFLAGS) DOSLIBEXMMOBJ = himemsys.$(OBJ) emm.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) midi.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) -16LIBOBJS = bakapee.$(OBJ) 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) scroll16.$(OBJ) 16_ca.$(OBJ) +16LIBOBJS = bakapee.$(OBJ) 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) scroll16.$(OBJ) 16_ca.$(OBJ) timer.$(OBJ) GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16text.$(OBJ) TESTEXEC = exmmtest.exe test.exe pcxtest.exe test2.exe palettec.exe maptest.exe fmemtest.exe fonttest.exe fontgfx.exe sountest.exe tsthimem.exe inputest.exe scroll.exe @@ -40,10 +42,10 @@ all: $(EXEC) #game and bakapi executables # 16.exe: 16.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) 16.lib - wcl $(FLAGS) 16.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) 16.lib + wcl $(FLAGS) $(16FLAGS) 16.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) 16.lib bakapi.exe: bakapi.$(OBJ) 16.lib - wcl $(FLAGS) bakapi.$(OBJ) 16.lib + wcl $(FLAGS) $(BAKAPIFLAGS) bakapi.$(OBJ) 16.lib # #Test Executables! # @@ -219,6 +221,9 @@ mapread.$(OBJ): $(SRCLIB)mapread.h $(SRCLIB)mapread.c #fmapread.$(OBJ): $(SRCLIB)fmapread.h $(SRCLIB)fmapread.c 16.lib # wcl $(FLAGS) $(MFLAGS) -c $(SRCLIB)fmapread.c 16.lib +timer.$(OBJ): $(SRCLIB)timer.h $(SRCLIB)timer.c + wcl $(FLAGS) -c $(SRCLIB)timer.c + 16_in.$(OBJ): $(SRCLIB)16_in.h $(SRCLIB)16_in.c wcl $(FLAGS) -c $(SRCLIB)16_in.c @@ -287,4 +292,4 @@ clean: .symbolic # @$(REMOVECOMMAND) *.smp @$(REMOVECOMMAND) *.SMP @$(REMOVECOMMAND) 16.hed - + @$(REMOVECOMMAND) bakapi.hed diff --git a/maptest.exe b/maptest.exe index 68bb08b9..ba1abdf2 100644 Binary files a/maptest.exe and b/maptest.exe differ diff --git a/palettec.exe b/palettec.exe index 8d7c203a..948a90f7 100644 Binary files a/palettec.exe and b/palettec.exe differ diff --git a/pcxtest.exe b/pcxtest.exe index 95d0fbb9..ddd61350 100644 Binary files a/pcxtest.exe and b/pcxtest.exe differ diff --git a/scroll.exe b/scroll.exe index 4c505526..c4392e5e 100644 Binary files a/scroll.exe and b/scroll.exe differ diff --git a/sountest.exe b/sountest.exe index 845a26aa..970ccf12 100644 Binary files a/sountest.exe and b/sountest.exe differ diff --git a/src/lib/16_head.c b/src/lib/16_head.c index 008c6544..2aca4bb7 100644 --- a/src/lib/16_head.c +++ b/src/lib/16_head.c @@ -174,6 +174,70 @@ size_t GetFarFreeSize(void) return total; } +//near versions +void __near* AllocateLargestNearFreeBlock(size_t* Size) +{ + size_t s0, s1; + void __near* p; + + s0 = ~(size_t)0 ^ (~(size_t)0 >> 1); + while (s0 && (p = _nmalloc(s0)) == NULL) + s0 >>= 1; + + if (p) + _nfree(p); + + s1 = s0 >> 1; + while (s1) + { + if ((p = _nmalloc(s0 + s1)) != NULL) + { + s0 += s1; + _nfree(p); + } + s1 >>= 1; + } + while (s0 && (p = _nmalloc(s0)) == NULL) + s0 ^= s0 & -s0; + + *Size = s0; + return p; +} + +size_t GetNearFreeSize(void) +{ + size_t total = 0; + void __near* pFirst = NULL; + void __near* pLast = NULL; + for(;;) + { + size_t largest; + void __near* p = AllocateLargestNearFreeBlock(&largest); + if (largest < sizeof(void __near*)) + { + if (p != NULL) + _nfree(p); + break; + } + *(void __near* __near*)p = NULL; + total += largest; + if (pFirst == NULL) + pFirst = p; + + if (pLast != NULL) + *(void __near* __near*)pLast = p; + pLast = p; + } + + while (pFirst != NULL) + { + void __near* p = *(void __near* __near*)pFirst; + _nfree(pFirst); + pFirst = p; + } + return total; +} + long int filesize(FILE *fp) { diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 6f293147..6c5f9b0b 100644 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -42,7 +42,6 @@ #include #include #include -//#include #include "src/lib/types.h" /* Control codes for all keys on the keyboard */ @@ -160,10 +159,12 @@ typedef enum {false,true} boolean; typedef void __based(__self) * memptr; //typedef sregs.w.es * memptr //typedef __segment * memptr; -//typedef fenp.op_ptr_seg * memptr;//=fenv_t.; +//typedef fenp.op_ptr_seg * memptr; typedef struct { int old_mode; //old video mode before game! + word frames_per_second; + clock_t t; } global_game_variables_t; /* local function */ @@ -172,6 +173,8 @@ void* AllocateLargestFreeBlock(size_t* Size); size_t GetFreeSize(void); void far *AllocateLargestFarFreeBlock(size_t far* Size); size_t GetFarFreeSize(void); +void __near *AllocateLargestNearFreeBlock(size_t* Size); +size_t GetNearFreeSize(void); long int filesize(FILE *fp); int US_CheckParm(char *parm,char **strings); diff --git a/src/lib/doslib/cpu.c b/src/lib/doslib/cpu.c index 17bf1f83..8e111690 100644 --- a/src/lib/doslib/cpu.c +++ b/src/lib/doslib/cpu.c @@ -177,5 +177,5 @@ int cpu_basic_probe() pop bx //retnative } - return; + return 0; } diff --git a/src/lib/mapread.c b/src/lib/mapread.c index 777de7da..b6219969 100644 --- a/src/lib/mapread.c +++ b/src/lib/mapread.c @@ -69,18 +69,18 @@ word dump(const char *js, jsmntok_t *t, size_t count, word indent, char *js_sv, { // fprintf(stdout, "[[[[%d|%d]]]]\n", &(t+1)->size, (t+1)->size); // fprintf(stdout, "\n%.*s[xx[%d|%d]xx]\n", (t+1)->end - (t+1)->start, js+(t+1)->start, &(t+1)->size, (t+1)->size); - map->data = _nmalloc(sizeof(byte) * (t+1)->size); - map->tiles = _nmalloc(sizeof(tiles_t)); + map->data = malloc(sizeof(byte) * (t+1)->size); + map->tiles = malloc(sizeof(tiles_t)); //map->tiles->data = malloc(sizeof(bitmap_t)); //fix this to be far~ bp = bitmapLoadPcx("data/ed.pcx"); map->tiles->data = &bp; //map->tiles->data->data = malloc((16/**2*/)*16); - //map->tiles->data->width = (16/**2*/); - //map->tiles->data->height= 16; - map->tiles->tileHeight = 16; - map->tiles->tileWidth = 16; - map->tiles->rows = 1; + //map->tiles->data->width = (16/**2*/); + //map->tiles->data->height= 16; + map->tiles->tileHeight = 16; + map->tiles->tileWidth = 16; + map->tiles->rows = 1; map->tiles->cols = 1; strcpy(js_sv, "data");//strdup(js+t->start);//, t->end - t->start); } diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 9ddbe90b..854eaed0 100644 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -377,6 +377,29 @@ void mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) //} } +sword chkmap(map_t *map, word q) +{ + bitmap_t bp; + byte x[MAPW*MAPH] = {4};//{ 1, 2, 3, 4, 0, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 6, 7, 8, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10 }; + //check for failed to load map + if((map->width == map->height == 0) || (q>0)) + { + //initiate a null map! + map->width=MAPW; + map->height=MAPH; +// map->data = malloc((map->width*map->height)*sizeof(byte)); + map->data = &x; + map->tiles = malloc(sizeof(tiles_t)); + //fix this to be far~ + bp = bitmapLoadPcx("data/ed.pcx"); + map->tiles->data = &bp; + map->tiles->tileHeight = 16; + map->tiles->tileWidth = 16; + map->tiles->rows = 1; + map->tiles->cols = 1; + } + return 0; +} void mapGoTo(map_view_t *mv, int tx, int ty) { @@ -517,6 +540,25 @@ void pdump(page_t *pee) } } +//sync! +void shinku(page_t *page, global_game_variables_t *gv) +{ + byte *pee; + word x = (SCREEN_WIDTH/2); + word y = (SCREEN_HEIGHT/2); + word col = 33; + word bgcol = 0; + word type = 1; + if(elapsed_timer(gv) >= (1.0 / gv->frames_per_second)) + { + pee = malloc(sizeof(double)); + sprintf(pee, "%f", (((0x046C)-(gv->t)) /18.2)); + modexprint(page, x, y, type, col, bgcol, pee); + sprintf(pee, "%f", elapsed_timer(gv)); + modexprint(page, x, y+16, type, col, bgcol, pee); + } +} + void animatePlayer(map_view_t *pip, player_t *player, word playnum, sword scrollswitch) { sword dire=32; //direction diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index f4e0b9cb..46d1f184 100644 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -29,6 +29,7 @@ #include "src/lib/bitmap.h" #include "src/lib/planar.h" #include "src/lib/mapread.h" +#include "src/lib/timer.h" typedef struct { map_t *map; @@ -46,7 +47,9 @@ typedef struct #define TILEWH 16 #define QUADWH TILEWH/2 -//#define LOOPMAX (TILEWH/(player[0].speed)) +//for null map! +#define MAPW 40 +#define MAPH 30 //map_t allocMap(int w, int h); //void initMap(map_t *map); @@ -55,6 +58,7 @@ void mapScrollRight(map_view_t *mv, player_t *player, word id, word plid); void mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid); void mapScrollUp(map_view_t *mv, player_t *player, word id, word plid); void mapScrollDown(map_view_t *mv, player_t *player, word id, word plid); +sword chkmap(map_t *map, word q); void mapGoTo(map_view_t *mv, int tx, int ty); void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y); void mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset); @@ -63,6 +67,7 @@ void mapDrawWRow(map_view_t *mv, int tx, int ty, word y); void mapDrawWCol(map_view_t *mv, int tx, int ty, word x); void pdump(page_t *pee); void qclean(); +void shinku(page_t *page, global_game_variables_t *gv); void animatePlayer(map_view_t *pip, player_t *player, word playnum, sword scrollswitch); #endif /*__SCROLL16_H_*/ diff --git a/src/lib/timer.c b/src/lib/timer.c new file mode 100644 index 00000000..3adc37b0 --- /dev/null +++ b/src/lib/timer.c @@ -0,0 +1,45 @@ +/* Project 16 Source Code~ + * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "src/lib/timer.h" + +clock_t start_timer(global_game_variables_t *gv) +{ + //time(&(this->t)); + gv->t = clock(); + return gv->t; +} + +double elapsed_timer(global_game_variables_t *gv) +{ + return (clock() - gv->t) / CLOCKS_PER_SEC; +} + +/*double time_in_seconds(global_game_variables_t *gv) +{ + return (gv->t) / CLOCKS_PER_SEC; +}*/ + +double time_in_seconds(time_t in_t) +{ + return (in_t) / CLOCKS_PER_SEC; +} diff --git a/src/lib/timer.h b/src/lib/timer.h new file mode 100644 index 00000000..fae0ebe0 --- /dev/null +++ b/src/lib/timer.h @@ -0,0 +1,33 @@ +/* Project 16 Source Code~ + * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _TIMER_H_ +#define _TIMER_H_ +#include "src/lib/16_head.h" + +clock_t start_timer(global_game_variables_t *gv); +double elapsed_timer(global_game_variables_t *gv); +//double elapsed_timer(global_game_variables_t *gv) +double time_in_seconds(time_t in_t); +//clock_t _time(); + +#endif diff --git a/src/scroll.c b/src/scroll.c index c6316e56..6bd40c83 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -23,13 +23,14 @@ #include "src/lib/scroll16.h" #include "src/lib/mapread.h" #include "src/lib/wcpu/wcpu.h" -//====#include "src\lib\ems.c" //word far *clock= (word far*) 0x046C; /* 18.2hz clock */ void main() { + dword tiku = 0; // word panswitch=0, panq=1, pand=0; + global_game_variables_t gvar; word panpagenum=0; //for panning! int i; static word paloffset=0; @@ -44,48 +45,29 @@ void main() byte *dpal, *gpal; byte *ptr; byte *mappalptr; + byte *mesg=malloc(sizeof(dword)); player_t player[MaxPlayers]; player[0].persist_aniframe=0; player[0].speed=4; + + start_timer(&gvar); + gvar.frames_per_second = 60; //extern struct inconfig inpu; - - //player_t npc0; // atexit(qclean()); - /*if(!emmtest()) - { - printf("Expanded memory is not present\n"); - exit(0); - } - - if(!emmok()) - { - printf("Expanded memory manager is not present\n"); - exit(0); - } - - emsavail = emmavail(); - if(emsavail == -1) - { - printf("Expanded memory manager error\n"); - exit(0); - } - printf("There are %ld pages available\n",emsavail); - - if((emmhandle = emmalloc(emsavail)) < 0) - { - printf("Insufficient pages available\n"); - exit(0); - }*/ /* create the map */ //printf("Total used @ before map load: %zu\n", oldfreemem-GetFreeSize()); printf("Total free @ before map load: %zu\n", GetFreeSize()); + printf("Total near free @ before map load: %zu\n", GetNearFreeSize()); printf("Total far free @ before map load: %zu\n", GetFarFreeSize()); getch(); //0000 fprintf(stderr, "testing~\n"); // loadmap("data/test.map", &map); + map.width=0; + map.height=0; + chkmap(&map, 1); //0000 fprintf(stderr, "yay map loaded~~\n"); //---- map = allocMap(map.width,map.height); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly //if(isEMS()) printf("%d tesuto\n", coretotalEMS()); @@ -107,37 +89,6 @@ void main() p = planar_buf_from_bitmap(&player[0].data); //0000 printf("Total used @ after planar buffer creation: %zu\n", oldfreemem-GetFreeSize()); - /*if(isEMS()) - { - XMOVE mm; - mm.length=sizeof(map); - mm.sourceH=0; - mm.sourceOff=(long)↦ - mm.destH=emmhandle; - mm.destOff=1; - //halp! - ist = move_emem(&mm); - printf("%d\n", coretotalEMS()); - if(!ist){ dealloc_emem(emmhandle); exit(5); } - //printf("%d\n", emmhandle); - } - - if(isEMS()) - { - XMOVE mm; - mm.length=emmhandle; - mm.sourceH=0; - mm.sourceOff=(long)&ptmp; - mm.destH=emmhandle; - mm.destOff=0; - //halp! - ist = move_emem(&mm); - printf("%d\n", coretotalEMS()); - if(!ist){ dealloc_emem(emmhandle); exit(5); } - //printf("%d\n", emmhandle); - } -*/ - /* input! */ IN_Startup(); IN_Default(0,&player,ctrl_Joystick); @@ -147,6 +98,7 @@ void main() modexPalSave(dpal); modexFadeOff(4, dpal); + textInit(); VGAmodeX(1); modexPalBlack(); //reset the palette~ // printf("Total used @ before palette initiation: %zu\n", oldfreemem-GetFreeSize()); @@ -156,9 +108,9 @@ void main() //printf("1: %d\n", paloffset); map.tiles->data->offset=(paloffset/3); //XTmodexPalUpdate(map.tiles->data, &paloffset, 0, 0); - printf("\n====\n"); - printf("0 paloffset= %d\n", paloffset/3); - printf("====\n\n"); +// printf("\n====\n"); +// printf("0 paloffset= %d\n", paloffset/3); +// printf("====\n\n"); gpal = modexNewPal(); modexPalSave(gpal); modexSavePalFile("data/g.pal", gpal); @@ -212,8 +164,11 @@ void main() // printf("Total used @ before loop: %zu\n", oldfreemem-GetFreeSize()); modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 1); modexFadeOn(4, gpal); - while(!IN_KeyDown(sc_Escape) && player[0].hp>0) + while(!IN_KeyDown(sc_Escape) && player[0].hp>0) { + sprintf(mesg, "%lu", tiku); + modexprint(mv[1].page, 0, 0, 1, 15, 0, mesg); + shinku(mv[1].page, &gvar); IN_ReadControl(0,&player); //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction @@ -377,6 +332,7 @@ void main() if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break; //incase things go out of sync! + tiku++; } /* fade back to text mode */ diff --git a/test.exe b/test.exe index 03c18ca0..dd07d442 100644 Binary files a/test.exe and b/test.exe differ diff --git a/test2.exe b/test2.exe index 0680286f..56899e6f 100644 Binary files a/test2.exe and b/test2.exe differ diff --git a/tsthimem.exe b/tsthimem.exe index c581f9c9..e0b5545c 100644 Binary files a/tsthimem.exe and b/tsthimem.exe differ