]> 4ch.mooo.com Git - 16.git/commitdiff
p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I...
authorsparky4 <sparky4@cock.li>
Fri, 7 Apr 2017 19:44:03 +0000 (14:44 -0500)
committersparky4 <sparky4@cock.li>
Fri, 7 Apr 2017 19:44:03 +0000 (14:44 -0500)
data/02.imf [new file with mode: 0755]
data/searchin.imf [new file with mode: 0755]
makefile
src/exmmtest.c
src/imfplay.c [new file with mode: 0755]
src/lib/16_map.c
src/lib/16_tdef.h
src/lib/vgmsnd/vgmSnd.c
src/lib/vgmsnd/vgmSnd.h
src/vgmtest.c

diff --git a/data/02.imf b/data/02.imf
new file mode 100755 (executable)
index 0000000..364012d
Binary files /dev/null and b/data/02.imf differ
diff --git a/data/searchin.imf b/data/searchin.imf
new file mode 100755 (executable)
index 0000000..da8f72a
Binary files /dev/null and b/data/searchin.imf differ
index 31a56d0d3ae4be384da81b686dc1ab6453747ae9..9de0c726b553483b26b56a0a6acdeb9ec921c351 100755 (executable)
--- a/makefile
+++ b/makefile
@@ -89,6 +89,7 @@ DOSLIB_DOS=$(DOSLIBDIR)/hw/dos
 DOSLIB_VGA=$(DOSLIBDIR)/hw/vga
 DOSLIB_8250=$(DOSLIBDIR)/hw/8250
 DOSLIB_8254=$(DOSLIBDIR)/hw/8254
+DOSLIB_8259=$(DOSLIBDIR)/hw/8259
 DOSLIB_ADLIB=$(DOSLIBDIR)/hw/adlib
 DOSLIB_JOYSTICK=$(DOSLIBDIR)/hw/joystick
 DOSLIB_MEMMODE=dos86$(MEMORYMODE)
@@ -146,7 +147,7 @@ DOSLIBOBJ += 8250.$(OBJ)
 #
 # libraries
 #
-DOSLIBLIBS = $(DOSLIB_CPU)/$(DOSLIB_MEMMODE)/cpu.lib $(DOSLIB_DOS)/$(DOSLIB_MEMMODE)/dos.lib $(DOSLIB_VGA)/$(DOSLIB_MEMMODE)/vga.lib $(DOSLIB_8254)/$(DOSLIB_MEMMODE)/8254.lib $(DOSLIB_ADLIB)/$(DOSLIB_MEMMODE)/adlib.lib
+DOSLIBLIBS = $(DOSLIB_CPU)/$(DOSLIB_MEMMODE)/cpu.lib $(DOSLIB_DOS)/$(DOSLIB_MEMMODE)/dos.lib $(DOSLIB_VGA)/$(DOSLIB_MEMMODE)/vga.lib $(DOSLIB_8254)/$(DOSLIB_MEMMODE)/8254.lib $(DOSLIB_8259)/$(DOSLIB_MEMMODE)/8259.lib $(DOSLIB_ADLIB)/$(DOSLIB_MEMMODE)/adlib.lib
 !ifeq DEBUGSERIAL 1
 DOSLIBLIBS += $(DOSLIB_8250)/$(DOSLIB_MEMMODE)/8250.lib
 !endif
@@ -198,7 +199,8 @@ TESTEXEC = &
        vrstest.exe &
        tesuto.exe &
        0.exe &
-       maptest.exe
+       maptest.exe &
+       imfplay.exe
 #zcroll.exe &
 TESTEXEC2 = &
        pcxtest.exe &
@@ -229,7 +231,6 @@ EXEC = &
        bakapi.exe &
        $(TESTEXEC) &
        $(UTILEXEC) &
-       imfplay.exe &
        opltest.exe
 
 #!ifdef __LINUX__
@@ -273,6 +274,7 @@ fontgfx.exe:        fontgfx.$(OBJ) gfx.lib $(DOSLIB)
 inputest.exe:   inputest.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib
 #inntest.exe:          inntest.$(OBJ)  $(16LIBNOINOBJS) 16_in_1.$(OBJ) $(DOSLIB) gfx.lib
 sountest.exe:  sountest.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib
+imfplay.exe:           imfplay.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib
 pcxtest.exe:   pcxtest.$(OBJ) gfx.lib $(DOSLIB) $(16LIB)
 vrstest.exe:   vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
 #vgacamm.exe:  vgacamm.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
@@ -317,6 +319,7 @@ fontgfx.$(OBJ):$(SRC)/fontgfx.c
 inputest.$(OBJ):$(SRC)/inputest.c
 #inntest.$(OBJ):$(SRC)/inntest.c
 sountest.$(OBJ): $(SRC)/sountest.c
+imfplay.$(OBJ): $(SRC)/imfplay.c
 #miditest.$(OBJ): $(SRC)/miditest.c
 #testemm.$(OBJ):$(SRC)/testemm.c
 #testemm0.$(OBJ): $(SRC)/testemm0.c
@@ -352,6 +355,8 @@ $(DOSLIB_8250)/$(DOSLIB_MEMMODE)/8250.lib:
        cd $(DOSLIB_8250:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
 $(DOSLIB_8254)/$(DOSLIB_MEMMODE)/8254.lib:
        cd $(DOSLIB_8254:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
+$(DOSLIB_8259)/$(DOSLIB_MEMMODE)/8259.lib:
+       cd $(DOSLIB_8259:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
 $(DOSLIB_ADLIB)/$(DOSLIB_MEMMODE)/adlib.lib:
        cd $(DOSLIB_ADLIB:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
 
@@ -359,9 +364,9 @@ joytest.exe:
        cd $(DOSLIB_JOYSTICK:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
        $(COPYCOMMAND) $(DOSLIB_JOYSTICK:$(to_os_path))$(DIRSEP)$(DOSLIB_MEMMODE)$(DIRSEP)test.exe joytest.exe
 
-imfplay.exe:
-       cd $(DOSLIB_ADLIB:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
-       $(COPYCOMMAND) $(DOSLIB_ADLIB:$(to_os_path))$(DIRSEP)$(DOSLIB_MEMMODE)$(DIRSEP)imfplay.exe imfplay.exe
+#imfplay.exe:
+#      cd $(DOSLIB_ADLIB:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
+#      $(COPYCOMMAND) $(DOSLIB_ADLIB:$(to_os_path))$(DIRSEP)$(DOSLIB_MEMMODE)$(DIRSEP)imfplay.exe imfplay.exe
 
 opltest.exe:
        cd $(DOSLIB_ADLIB:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
index fe5f0ad24a980c508e985104d324ad79a9a0efa7..7e9ba334f0148644f052939c7086d18f2e68c621 100755 (executable)
@@ -109,18 +109,6 @@ void segatesuto()
 }\r
 #endif\r
 \r
-#ifdef __16_PM__\r
-#ifdef __DEBUG_PM__\r
-       dbg_debugpm=1;  //debug pm\r
-#endif\r
-#endif\r
-#ifdef __DEBUG_CA__\r
-       dbg_debugca=1;\r
-#endif\r
-#ifdef __DEBUG_MM__\r
-       dbg_debugmm=1;\r
-#endif\r
-\r
 //===========================================================================//\r
 \r
 //=======================================//\r
@@ -155,6 +143,17 @@ main(int argc, char *argv[])
                                                                #ifdef PRINTBBDUMP\r
                                                                //0000PRINTBB; KEYP\r
                                                                #endif\r
+#ifdef __16_PM__\r
+#ifdef __DEBUG_PM__\r
+       dbg_debugpm=1;  //debug pm\r
+#endif\r
+#endif\r
+#ifdef __DEBUG_CA__\r
+       dbg_debugca=1;\r
+#endif\r
+#ifdef __DEBUG_MM__\r
+       dbg_debugmm=1;\r
+#endif\r
 \r
        if(argv[1]){ strcpy(bakapee1, argv[1]);//bakapee1[] = *argv[1];\r
        if(argv[2]) strcpy(bakapee2, argv[2]); }//bakapee2[] = argv[2]; }\r
diff --git a/src/imfplay.c b/src/imfplay.c
new file mode 100755 (executable)
index 0000000..7fb6753
--- /dev/null
@@ -0,0 +1,270 @@
+/* midi.c
+ *
+ * Adlib OPL2/OPL3 FM synthesizer chipset test program.
+ * Play MIDI file using the OPLx synthesizer (well, poorly anyway)
+ * (C) 2010-2012 Jonathan Campbell.
+ * Hackipedia DOS library.
+ *
+ * This code is licensed under the LGPL.
+ * <insert LGPL legal text here>
+ *
+ * Compiles for intended target environments:
+ *   - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box]
+ */
+
+#include "src/lib/16_head.h"
+#include "src/lib/16_tail.h"
+#include "src/lib/16_pm.h"
+#include "src/lib/16_ca.h"
+#include "src/lib/16_mm.h"
+#include "src/lib/16_hc.h"
+#include "src/lib/16_dbg.h"
+// #include <stdio.h>
+// #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
+// #include <stdlib.h>
+// #include <string.h>
+// #include <unistd.h>
+// #include <malloc.h>
+// #include <ctype.h>
+// #include <fcntl.h>
+// #include <math.h>
+// #include <dos.h>
+
+#include <hw/vga/vga.h>
+#include <hw/dos/dos.h>
+#include <hw/8254/8254.h>              /* 8254 timer */
+#include <hw/8259/8259.h>
+#include <hw/adlib/adlib.h>
+
+static void (interrupt *old_irq0)();
+static volatile unsigned long irq0_ticks=0;
+static volatile unsigned int irq0_cnt=0,irq0_add=0,irq0_max=0;
+
+#pragma pack(push,1)
+struct imf_entry {
+       uint8_t         reg,data;
+       uint16_t        delay;
+};
+#pragma pack(pop)
+
+static struct imf_entry*       imf_music=NULL;
+static struct imf_entry*       imf_play_ptr=NULL;
+static struct imf_entry*       imf_music_end=NULL;
+static uint16_t                        imf_delay_countdown=0;
+
+#define PRINTBB {\
+       printf("-------------------------------------------------------------------------------\n");\
+       printf("buffer:\n");\
+       printf("bigbuffer       %Fp\t", gvar->ca.audiosegs[0]);\
+       printf("&%Fp\n", MEMPTR gvar->ca.audiosegs[0]);\
+       printf("imf_music       %Fp\t", imf_music);\
+       printf("&%Fp\n", imf_music);\
+       printf("imf_play_ptr    %Fp\t", imf_play_ptr);\
+       printf("&%Fp\n", imf_play_ptr);\
+       printf("imf_music_end   %Fp\t", imf_music_end);\
+       printf("&%Fp\n", imf_music_end);\
+       printf("-------------------------------------------------------------------------------\n");\
+}
+
+void imf_free_music(global_game_variables_t *gvar) {
+       if (imf_music) free(imf_music);
+       MM_FreePtr(MEMPTR gvar->ca.audiosegs[0], gvar);
+       imf_music = imf_play_ptr = imf_music_end = NULL;
+       imf_delay_countdown = 0;
+}
+
+int imf_load_music(const char *path, global_game_variables_t *gvar) {
+       unsigned long len;
+       unsigned char buf[8];
+       int fd;
+
+       imf_free_music(gvar);
+
+       fd = open(path,O_RDONLY|O_BINARY);
+       if (fd < 0) return 0;
+
+       len = lseek(fd,0,SEEK_END);
+       lseek(fd,0,SEEK_SET);
+       read(fd,buf,2);
+       if (buf[0] != 0 || buf[1] != 0) // type 1 IMF
+               len = *((uint16_t*)buf);
+       else
+               lseek(fd,0,SEEK_SET);
+
+       if (len == 0 || len > 65535UL) {
+               close(fd);
+               return 0;
+       }
+       len -= len & 3;
+
+//     imf_music = malloc(len);
+       MM_GetPtr(MEMPTR gvar->ca.audiosegs[0],len, gvar);
+       imf_music = (struct imf_entry *)gvar->ca.audiosegs[0];
+       if (imf_music == NULL) {
+               close(fd);
+               return 0;
+       }
+       read(fd,imf_music,len);
+       close(fd);
+
+       imf_play_ptr = imf_music;
+       imf_music_end = imf_music + (len >> 2UL);
+       PRINTBB;
+       return 1;
+}
+
+/* WARNING: subroutine call in interrupt handler. make sure you compile with -zu flag for large/compact memory models */
+void interrupt irq0() {
+       irq0_ticks++;
+       if ((irq0_cnt += irq0_add) >= irq0_max) {
+               irq0_cnt -= irq0_max;
+               old_irq0();
+       }
+       else {
+               p8259_OCW2(0,P8259_OCW2_NON_SPECIFIC_EOI);
+       }
+}
+
+void imf_tick() {
+       if (imf_delay_countdown == 0) {
+               do {
+                       adlib_write(imf_play_ptr->reg,imf_play_ptr->data);
+                       imf_delay_countdown = imf_play_ptr->delay;
+                       imf_play_ptr++;
+                       if (imf_play_ptr == imf_music_end)
+                       {
+                               printf("replay\n");
+                               imf_play_ptr = imf_music;
+                       }
+               } while (imf_delay_countdown == 0);
+       }
+       else {
+               imf_delay_countdown--;
+       }
+}
+
+void adlib_shut_up() {
+       int i;
+
+       memset(adlib_fm,0,sizeof(adlib_fm));
+       memset(&adlib_reg_bd,0,sizeof(adlib_reg_bd));
+       for (i=0;i < adlib_fm_voices;i++) {
+               struct adlib_fm_operator *f;
+               f = &adlib_fm[i].mod;
+               f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;
+               f = &adlib_fm[i].car;
+               f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;
+       }
+
+       for (i=0;i < adlib_fm_voices;i++) {
+               struct adlib_fm_operator *f;
+
+               f = &adlib_fm[i].mod;
+               f->mod_multiple = 1;
+               f->total_level = 63 - 16;
+               f->attack_rate = 15;
+               f->decay_rate = 4;
+               f->sustain_level = 0;
+               f->release_rate = 8;
+               f->f_number = 400;
+               f->sustain = 1;
+               f->octave = 4;
+               f->key_on = 0;
+
+               f = &adlib_fm[i].car;
+               f->mod_multiple = 1;
+               f->total_level = 63 - 16;
+               f->attack_rate = 15;
+               f->decay_rate = 4;
+               f->sustain_level = 0;
+               f->release_rate = 8;
+               f->f_number = 0;
+               f->sustain = 1;
+               f->octave = 0;
+               f->key_on = 0;
+       }
+
+       adlib_apply_all();
+}
+
+void main(int argc,char **argv) {
+       static global_game_variables_t gvar;
+       unsigned long tickrate = 700;
+       unsigned long ptick;
+       int c;
+#ifdef __DEBUG_CA__
+       dbg_debugca=1;
+#endif
+#ifdef __DEBUG_MM_
+       dbg_debugmm=1;
+#endif
+       MM_Startup(&gvar);
+       PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar);
+       CA_Startup(&gvar);
+       printf("ADLIB FM test program IMFPLAY\n");
+       if (argc < 2) {
+               printf("You must specify an IMF file to play\n");
+               return;
+       }
+
+       if (!init_adlib()) {
+               printf("Cannot init library\n");
+               return;
+       }
+       if (!probe_8254()) { /* we need the timer to keep time with the music */
+               printf("8254 timer not found\n");
+               return;
+       }
+
+       if (!imf_load_music(argv[1], &gvar)) {
+               printf("Failed to load IMF Music\n");
+               return;
+       }
+
+       write_8254_system_timer(T8254_REF_CLOCK_HZ / tickrate);
+       irq0_cnt = 0;
+       irq0_add = 182;
+       irq0_max = 1000; /* about 18.2Hz */
+       old_irq0 = _dos_getvect(8);/*IRQ0*/
+       _dos_setvect(8,irq0);
+
+       adlib_shut_up();
+       shutdown_adlib_opl3(); // NTS: Apparently the music won't play otherwise
+       _cli();
+       irq0_ticks = ptick = 0;
+       _sti();
+
+       while (1) {
+               unsigned long adv;
+
+               _cli();
+               adv = irq0_ticks - ptick;
+               if (adv >= 100UL) adv = 100UL;
+               ptick = irq0_ticks;
+               _sti();
+
+               while (adv != 0) {
+                       imf_tick();
+                       adv--;
+               }
+
+               if (kbhit()) {
+                       c = getch();
+                       if (c == 0) c = getch() << 8;
+
+                       if (c == 27) {
+                               break;
+                       }
+               }
+       }
+//     printf("contents of the imf_music\n[\n%s\n]\n", imf_music);
+
+       imf_free_music(&gvar);
+       adlib_shut_up();
+       shutdown_adlib();
+       _dos_setvect(8,old_irq0);
+       write_8254_system_timer(0);/* back to normal 18.2Hz */
+       PM_Shutdown(&gvar);
+       CA_Shutdown(&gvar);
+       MM_Shutdown(&gvar);
+}
index bcda288f794fd9e5943179d6f008653d99398629..e598d36b8541acc6b0f9eb84500585fac512c848 100755 (executable)
@@ -20,6 +20,8 @@
  *\r
  */\r
 \r
+//TODO USE CA AND THIS FILE FORMAT\r
+\r
 #include "src/lib/16_map.h"\r
 #include <malloc.h>\r
 \r
index c57753875ecfbcb88264be8f60fef0fb41948aa6..c87b272ec44e6a8c392d4121960d2270f6057ba6 100755 (executable)
@@ -594,6 +594,17 @@ typedef struct
 \r
 //==========================================================================\r
 \r
+/*\r
+#pragma pack(push,1)\r
+typedef struct imf_entry {\r
+       uint8_t         reg,data;\r
+       uint16_t        delay;\r
+} imf_entry_t;\r
+#pragma pack(pop)\r
+*/\r
+\r
+//==========================================================================\r
+\r
 //from 16_ca\r
 //==========================================================================\r
 \r
index 1bd719f8c0a26f470d4379c6766816a206623748..d41f2abea3a0a9381e4f4e34c5e75d00b2a4e4ce 100755 (executable)
@@ -137,7 +137,7 @@ static const UINT8 CHN_OPMASK_REV[0x20] =
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
 \r
 \r
-UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile)\r
+UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile, global_game_variables_t *gvar)\r
 {\r
        size_t hdrSize;\r
        size_t readEl;  // 'elements' read from file\r
@@ -171,7 +171,9 @@ UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile)
        }\r
 \r
        vgmFile->dataLen = vgmBaseHdr.lngEOFOffset + 0x04;\r
-       vgmFile->data = (UINT8*)malloc(vgmFile->dataLen);\r
+       //vgmFile->data = (UINT8*)malloc(vgmFile->dataLen);\r
+       MM_GetPtr(MEMPTR gvar->ca.audiosegs[0], vgmFile->dataLen, gvar);\r
+       vgmFile->data = (UINT8*)gvar->ca.audiosegs[0];\r
        if (vgmFile->data == NULL)\r
        {\r
                fclose(hFile);\r
@@ -212,9 +214,11 @@ UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile)
        return 0x00;\r
 }\r
 \r
-void FreeVGMFile(VGM_FILE* vgmFile)\r
+void FreeVGMFile(VGM_FILE* vgmFile, global_game_variables_t *gvar)\r
 {\r
-       free(vgmFile->data);    vgmFile->data = NULL;\r
+       //if(vgmFile->data){ free(vgmFile->data);       vgmFile->data = NULL; }\r
+//     if(vgmFile->data) free(vgmFile->data);\r
+       MM_FreePtr(MEMPTR gvar->ca.audiosegs[0], gvar);\r
        vgmFile->dataLen = 0;\r
 \r
        return;\r
index 373d73ddc6fe0d31c102fa0df619663f6444e276..9bfdbc30fcb7da7896792f3e212cced18f66081e 100755 (executable)
@@ -56,8 +56,8 @@ typedef struct _vgm_file
 } VGM_FILE;\r
 \r
 \r
-UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile);\r
-void FreeVGMFile(VGM_FILE* vgmFile);\r
+UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile, global_game_variables_t *gvar);\r
+void FreeVGMFile(VGM_FILE* vgmFile, global_game_variables_t *gvar);\r
 \r
 void InitEngine(void);\r
 void DeinitEngine(void);\r
index ee9e09fe39edde17b021577ec6dff375cbb93699..ef8d242d743a8d57acc747286da42f38a2dd28d1 100755 (executable)
 #include "src/lib/16_sd.h"\r
 //#include "src/lib/doslib/adlib.h"\r
 #include "src/lib/16_in.h"\r
+#include "src/lib/16_tail.h"\r
+#include "src/lib/16_pm.h"\r
+#include "src/lib/16_ca.h"\r
+#include "src/lib/16_mm.h"\r
+#include "src/lib/16_hc.h"\r
+#include "src/lib/16_dbg.h"\r
 \r
 void OPL2_Write(UINT8 reg, UINT8 data);\r
 UINT8 OPL2_ReadStatus(void);\r
@@ -48,14 +54,16 @@ UINT8 OPL2_ReadStatus(void)
 void\r
 main(int argc, char *argv[])\r
 {\r
-//     static global_game_variables_t gvar;\r
+       static global_game_variables_t gvar;\r
        VGM_FILE pee[9];\r
-       char *bakapee;\r
+       char bakapee[64] = "data/adlib.vgm";\r
 \r
-       bakapee = malloc(64);\r
-       if(argv[1]) bakapee = argv[1];\r
-       else bakapee = "data/adlib.vgm";\r
-       printf("%x\n", OpenVGMFile(bakapee, &pee[0]));\r
+       if(argv[1]) strcpy(bakapee, argv[1]);\r
+\r
+       MM_Startup(&gvar);\r
+//     PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar);\r
+//     CA_Startup(&gvar);\r
+       printf("%x\n", OpenVGMFile(bakapee, &pee[0], &gvar));\r
 //     IN_Startup(); IN_Default(0,&gvar.player[0],ctrl_Keyboard1);\r
        InitEngine();\r
        PlayMusic(&pee[0]);\r
@@ -66,7 +74,10 @@ main(int argc, char *argv[])
                UpdateSoundEngine();\r
        }\r
        StopMusic();\r
-       FreeVGMFile(&pee[0]);\r
+       FreeVGMFile(&pee[0], &gvar);\r
        DeinitEngine();\r
        //IN_Shutdown();\r
+//     PM_Shutdown(&gvar);\r
+//     CA_Shutdown(&gvar);\r
+       MM_Shutdown(&gvar);\r
 }\r