]> 4ch.mooo.com Git - 16.git/commitdiff
fix bizarre near/far sprintf problem when gv->pee not initialized by just replacing the
authorJonathan Campbell <jonathan@castus.tv>
Sun, 30 Oct 2016 16:38:35 +0000 (09:38 -0700)
committerJonathan Campbell <jonathan@castus.tv>
Sun, 30 Oct 2016 16:38:35 +0000 (09:38 -0700)
gv->pee status text buffer with a global char[] buffer everyone can use for status messages.
that way Watcom C can resolve the far pointer properly to sprintf(). This fixes ZCROLL.EXE
printing *** Null pointer assignment detected on shutdown.

data/g.pal
src/lib/16_timer.c
src/lib/scroll16.c
src/lib/scroll16.h
src/lib/typdefst.h

index d11fb0fce8180eac9c62887cec19e7232d8b6412..6b992816b96b9fbbd2d936eaf6dec3a107ef4b6e 100755 (executable)
Binary files a/data/g.pal and b/data/g.pal differ
index 9b73b887f22f5db05b65a39efcdd121e05ad9092..4ce497099cebb25424d5e575c92120a89313299f 100755 (executable)
@@ -29,8 +29,8 @@ clock_t start_timer(global_game_variables_t *gv)
        gv->kurokku.clock_start = *clockw;\r
        gv->kurokku.clock = clockw;\r
        //gv->kurokku.frames_per_second = 60;\r
-       gv->pee = _nmalloc(sizeof(byte)*16);\r
-       //turn this off if XT\r
+\r
+    //turn this off if XT\r
        switch(detectcpu())\r
        {\r
                case 0:\r
@@ -63,6 +63,9 @@ double time_in_seconds(global_game_variables_t *gv)
        return (gv->kurokku.t) / CLOCKS_PER_SEC;\r
 }\r
 \r
+// big global status text buffer\r
+char global_temp_status_text[512];\r
+\r
 /*double time_in_seconds(time_t in_t)\r
 {\r
        return (in_t) / CLOCKS_PER_SEC;\r
@@ -75,8 +78,8 @@ void shinkutxt(global_game_variables_t *gv)
        if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))\r
        {\r
                //t=(((*(gv->clock))-gv->clock_start) /18.2);\r
-               sprintf(gv->pee, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));\r
-               fprintf(stderr, "%s\n", gv->pee);\r
+               sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));\r
+               fprintf(stderr, "%s\n", global_temp_status_text);\r
                //(gv->clock_start)=*(gv->clock);\r
                gv->kurokku.tiku=0;\r
        }\r
index b94e768a77c1a8d4813111caa3e2bdae39c36cf3..6f1c450ed0e1d2fd89473cd755ddaca0cdd06d7b 100755 (executable)
@@ -774,9 +774,16 @@ void shinku(global_game_variables_t *gv)
 //     vga_restore_rm0wm0();\r
        if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))\r
        {\r
-               sprintf(gv->pee, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));\r
+        // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even\r
+        //      though it should be. Instead it's NULL as a near pointer but contains a non-null\r
+        //      segment value, so testing against NULL doesn't work. It is initialized properly if\r
+        //      you call start_timer() though which uses near malloc. Rather than fight with that,\r
+        //      I decided it would be better to declare a temp buffer statically and sprintf to that.\r
+        //\r
+        //      This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.\r
+               sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));\r
                //modexClearRegion(&(gv->video.page[shinku_fps_indicator_page]), x, y, w, h, 45);\r
-               modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, gv->pee);\r
+               modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);\r
                gv->kurokku.tiku=0;\r
                /* block copy to visible RAM from offscreen */\r
 //             vga_setup_wm1_block_copy();\r
index 1f60967087e3bcb74d3a56b1aa192096f835868a..84b3eab063fafcdb6a2ea37161a9b98924662065 100755 (executable)
@@ -70,6 +70,8 @@ typedef struct
 extern boolean pageflipflop, pageploop;\r
 extern unsigned char shinku_fps_indicator_page;\r
 \r
+extern char global_temp_status_text[512];\r
+\r
 //map_t allocMap(int w, int h);\r
 //void initMap(map_t *map);\r
 void walk(map_view_t *pip, player_t *player, word pn);\r
index 32aaed26247dff50ca141cc0ad730a5930ceb65f..d6cc2b9a635d4de6a3b6b03bef390828b577a2be 100755 (executable)
@@ -334,10 +334,11 @@ typedef struct
        video_t video;  // video settings variable\r
        ca_t            ca;     // ca stuff\r
        pm_t            pm;     // pm stuff\r
-       byte *pee;              // message for fps\r
        loghandle_t handle;     //handles for file logging\r
        kurokku_t kurokku;      //clock struct\r
        mminfo_t mm; mminfotype mmi;\r
 } global_game_variables_t;\r
 \r
+extern char global_temp_status_text[512];\r
+\r
 #endif /* _TYPEDEFSTRUCT_H_ */\r