Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "common.h"
- #include "event.h"
- void CheckAlloc(void *n)
- /* Check if an allocation completed successfully */
- {
- if(n == NULL)
- /* Failed! */
- {
- exit(1);
- /* Exit with err num 1 */
- }
- }
- void DoNothing(void *n)
- /* Just an ugly wordaround to remove some warnings */
- {
- State *s;
- s = (State *)n;
- s -> nothing = 0;
- }
- /*int returnmode()
- {
- return 3;
- }*/
- void InitGraph(void *n)
- /* Function to init graphics driver */
- {
- int gd = VGA, gm = VGAMED;
- /* Use VGAMED for setvisualpage & setactivepage */
- //installuserdriver("svga256", returnmode);
- initgraph(&gd, &gm, "");
- cleardevice();
- DoNothing(n);
- }
- void ClearGraph(void *n)
- /* Function to clear screen */
- {
- DoNothing(n);
- cleardevice();
- }
- void FREEMEMRow(Row *row)
- /* Release all the memory that used by a row */
- {
- Row *next;
- next = row;
- while(next != NULL)
- /* While not completed */
- {
- next = row -> next;
- /* Save the next node first */
- FREEMEMChar(row -> ch);
- /* Then free Chars of the Row */
- FREEMEM(row);
- /* Then free the Row node itself */
- row = next;
- /* Move to next row */
- }
- }
- void FREEMEMChar(Char *ch)
- /* Free link table struct Char */
- {
- Char *next;
- next = ch;
- while(next != NULL)
- /* While not completed */
- {
- next = ch -> next;
- /* Save the next node first */
- FREEMEM(ch);
- /* Then free this node */
- ch = next;
- /* Move to next node */
- }
- }
- void Exit(void *n)
- /* Flag an exit event */
- {
- State *s;
- s = (State *)n;
- if(s -> ischildwindow)
- /* Only exit the child window */
- CloseChildWindow(n);
- else
- /* Change the whole exit flag */
- s -> isexit = 1;
- }
- void CalcDelay(void *n)
- /* Use biostime to adjust delay() */
- {
- long bios_time, bios_time_start;
- long i;
- State *s;
- s = (State *)n;
- bios_time_start = biostime(0, 0);
- /* Save the current time */
- delay(200);
- /* Do a 200ms delay */
- bios_time = biostime(0, 0);
- /* Get current time after the 200ms delay */
- s -> delaytime = bios_time - bios_time_start;
- /* Then save the true timestamp for adjusting */
- }
- void Delay(void *n, long t)
- /* The fixed delay function */
- {
- State *s;
- int i;
- s = (State *)n;
- delay((int)(200 * t / s -> delaytime / CLK_TCK));
- /* Use the true timestamp to adjust the buggy delay */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement