void CK6_GrabbiterCol(CK_object *a, CK_object *b) { if (!ck_gameState.ep.ck6.sandwich) { CA_CacheGrChunk(0x23); SD_PlaySound(SOUND_GRABBITER); US_CenterWindow(26, 8); VH_DrawBitmap(US_GetWindowX() + US_GetWindowW() - 0x30, US_GetWindowY(), 0x23); US_SetWindowW(US_GetWindowW() - 0x30); US_SetPrintY(US_GetPrintY() + 5); US_CPrint("Oh no!\n" "It's a slavering\n" "Grabbiter! He says,\n" "\"Get me lunch and\n" "I'll tell ya a secret!\""); VL_Present(); VL_DelayTics(30); // VW_WaitVBL(30); IN_ClearKeysDown(); IN_WaitButton(); RF_ForceRefresh(); ck_nextX = -b->deltaPosX; ck_nextY = -b->deltaPosY; b->xDirection = b->yDirection = IN_motion_None; CK_PhysUpdateNormalObj(b); } else { ck_gameState.ep.ck6.sandwich++; CA_CacheGrChunk(0x23); US_CenterWindow(26, 8); VH_DrawBitmap(US_GetWindowX() + US_GetWindowW() - 0x30, US_GetWindowY(), 0x23); US_SetWindowW(US_GetWindowW() - 0x30); US_SetPrintY(US_GetPrintY() + 2); US_CPrint("The Grabbiter grabs\n" "the gigantic sandwich,\n" "downs it in one bite,\n" "and says,\"Here's your\n" "secret. Big meals\n" "make me sleepy!\n"); VL_Present(); VL_DelayTics(30); // VW_WaitVBL(30); IN_ClearKeysDown(); IN_WaitButton(); CK_SetAction2(a, CK_GetActionByName("CK6_ACT_GrabbiterNapping0")); RF_ForceRefresh(); } }
void StatusWindow (void) { id0_word_t x; // DEBUG - make this look better US_CenterWindow(22,7); US_CPrint("Status Window"); WindowX += 8; WindowW -= 8; WindowY += 20; WindowH -= 20; PrintX = WindowX; PrintY = WindowY; VWB_DrawTile8(PrintX,PrintY,26); VWB_DrawTile8(PrintX + 8,PrintY,27); PrintX += 24; US_PrintUnsigned(gamestate.lives); US_Print("\n"); VWB_DrawTile8(PrintX,PrintY,32); VWB_DrawTile8(PrintX + 8,PrintY,33); VWB_DrawTile8(PrintX,PrintY + 8,34); VWB_DrawTile8(PrintX + 8,PrintY + 8,35); PrintX += 24; US_PrintUnsigned(gamestate.boobusbombs); US_Print("\n"); WindowX += 50; WindowW -= 50; PrintX = WindowX; PrintY = WindowY; fontcolor = F_FIRSTCOLOR; US_Print("Next "); fontcolor = F_BLACK; x = PrintX; VWB_DrawTile8(PrintX,PrintY,26); VWB_DrawTile8(PrintX + 8,PrintY,27); PrintX += 24; US_PrintUnsigned(gamestate.nextextra); US_Print("\n"); PrintX = x; VWB_DrawTile8(PrintX,PrintY,24); VWB_DrawTile8(PrintX + 8,PrintY,25); PrintX += 24; US_PrintUnsigned(gamestate.keys); US_Print("\n"); // DEBUG - add flower powers (#36) VW_UpdateScreen(); IN_Ack(); }
void CK6_MapCliffCol(CK_object *a, CK_object *b) { if (b->type == CT_Player) { if (ck_gameState.ep.ck6.rope == 0) { CA_CacheGrChunk(0x23); US_CenterWindow(26, 8); VH_DrawBitmap(US_GetWindowX() + US_GetWindowW() - 0x30, US_GetWindowY(), 0x23); US_SetWindowW(US_GetWindowW() - 0x30); US_SetPrintY(US_GetPrintY() + 15); US_CPrint("What a tall cliff!\n" "Wish I had a rope\n" "and grappling hook.\n"); VL_Present(); SD_PlaySound(SOUND_NEEDKEYCARD); VL_DelayTics(30); // VW_WaitVBL(30); IN_ClearKeysDown(); IN_WaitButton(); RF_ForceRefresh(); ck_nextX = -b->deltaPosX; ck_nextY = -b->deltaPosY; b->xDirection = b->yDirection = IN_motion_None; CK_PhysUpdateNormalObj(b); } else if (ck_gameState.ep.ck6.rope == 1) { ck_gameState.ep.ck6.rope++; SD_PlaySound(SOUND_KEENTHROWROPE); CK_SetAction2(b, CK_GetActionByName("CK6_ACT_MapKeenThrowRope0")); b->type = CT_Friendly; } else if (ck_gameState.ep.ck6.rope == 2) { if (a->user1) { b->posY += 0x40; b->user4 = 6; b->yDirection = IN_motion_Down; } else { b->posY -= 0x40; b->user4 = 6; b->yDirection = IN_motion_Up; } CK_SetAction(b, CK_GetActionByName("CK6_ACT_MapKeenClimbRope0")); b->type = CT_Friendly; } } }
void GameOver (void) { VW_InitDoubleBuffer (); US_CenterWindow (16,3); US_PrintCentered("Game Over!"); VW_UpdateScreen (); IN_ClearKeysDown (); IN_Ack (); }
void DebugMemory (void) { VW_FixRefreshBuffer (); US_CenterWindow (16,7); US_CPrint ("Memory Usage"); US_CPrint ("------------"); US_Print ("Total :"); US_PrintUnsigned (mminfo.mainmem/1024); US_Print ("k\nFree :"); US_PrintUnsigned (MM_UnusedMemory()/1024); US_Print ("k\nWith purge:"); US_PrintUnsigned (MM_TotalFree()/1024); US_Print ("k\n"); VW_UpdateScreen(); IN_Ack (); #if GRMODE == EGAGR MM_ShowMemory (); #endif }
void CK6_RocketCol(CK_object *a, CK_object *b) { if (ck_gameState.ep.ck6.passcard == 0) { CA_CacheGrChunk(0x23); US_CenterWindow(26, 8); VH_DrawBitmap(US_GetWindowX() + US_GetWindowW() - 0x30, US_GetWindowY(), 0x23); US_SetWindowW(US_GetWindowW() - 0x30); US_SetPrintY(US_GetPrintY() + 5); US_CPrint("The door makes a loud\n" "blooping noise.\n" "It says,\n" "\"Passcard required\n" "for entry.\""); VL_Present(); SD_PlaySound(SOUND_NEEDKEYCARD); VL_DelayTics(30); // VW_WaitVBL(30); IN_ClearKeysDown(); IN_WaitButton(); RF_ForceRefresh(); ck_nextX = -b->deltaPosX; ck_nextY = -b->deltaPosY; b->xDirection = b->yDirection = IN_motion_None; CK_PhysUpdateNormalObj(b); } else if (ck_gameState.ep.ck6.passcard == 1) { a->user1 = 0; a->user2 = 0x100; CK_SetAction2(a, CK_GetActionByName("CK6_ACT_RocketFly0")); b->posX = a->posX; b->posY = a->posY + 0x100; b->clipped = CLIP_not; CK_SetAction2(b, CK_GetActionByName("CK6_ACT_MapKeenRocketSit0")); SD_PlaySound(SOUND_ROCKETLAUNCH); SD_WaitSoundDone(); } }
void CK6_ShowGetRope() { SD_WaitSoundDone(); SD_PlaySound(SOUND_STORYITEM); CA_UpLevel(); CA_CacheGrChunk(0x23); US_CenterWindow(26, 8); VH_DrawBitmap(US_GetWindowX() + US_GetWindowW() - 0x30, US_GetWindowY(), 0x23); US_SetWindowW(US_GetWindowW() - 0x30); US_SetPrintY(US_GetPrintY() + 12); US_CPrint("Wow! A rope and\n" "grappling hook!\n" "They look useful!\n"); VL_Present(); VL_DelayTics(30); // VW_WaitVBL(30); IN_ClearKeysDown(); IN_WaitButton(); CA_DownLevel(); ck_gameState.ep.ck6.rope = true; }
void CK6_ShowGetSandwich() { SD_WaitSoundDone(); SD_PlaySound(SOUND_STORYITEM); CA_UpLevel(); CA_CacheGrChunk(0x23); US_CenterWindow(26, 8); VH_DrawBitmap(US_GetWindowX() + US_GetWindowW() - 0x30, US_GetWindowY(), 0x23); US_SetWindowW(US_GetWindowW() - 0x30); US_SetPrintY(US_GetPrintY() + 12); US_CPrint("This is the second\n" "biggest sandwich\n" "I ever saw!\n"); VL_Present(); VL_DelayTics(30); // VW_WaitVBL(30); IN_ClearKeysDown(); IN_WaitButton(); CA_DownLevel(); ck_gameState.ep.ck6.sandwich = true; }
void DebugMemory (void) { //id0_int_t i; //id0_char_t scratch[80],str[10]; //id0_long_t mem; //spritetype id0_seg *block; VW_FixRefreshBuffer (); US_CenterWindow (16,7); #if 0 CA_OpenDebug (); for (i=0;i<NUMCHUNKS;i++) { if (grsegs[i]) { strcpy (scratch,"Chunk:"); itoa (i,str,10); strcat (scratch,str); strcat (scratch,"\n"); write (debughandle,scratch,strlen(scratch)); } } CA_CloseDebug (); #endif US_CPrint ("Memory Usage"); US_CPrint ("------------"); US_Print ("Total :"); US_PrintUnsigned (mminfo.mainmem/1024); US_Print ("k\nFree :"); US_PrintUnsigned (MM_UnusedMemory()/1024); US_Print ("k\nWith purge:"); US_PrintUnsigned (MM_TotalFree()/1024); US_Print ("k\n"); VW_UpdateScreen(); IN_Ack (); }
void CK6_ShowGetPasscard() { SD_WaitSoundDone(); SD_PlaySound(SOUND_STORYITEM); CA_UpLevel(); CA_CacheGrChunk(0x23); US_CenterWindow(26, 8); VH_DrawBitmap(US_GetWindowX() + US_GetWindowW() - 0x30, US_GetWindowY(), 0x23); US_SetWindowW(US_GetWindowW() - 0x30); US_SetPrintY(US_GetPrintY() + 4); US_CPrint("What's this? Cool!\n" "A passcard for\n" "the Bloogstar Rocket!\n" "(It can fly though\n" "their force field.)"); VL_Present(); VL_DelayTics(30); // VW_WaitVBL(30); IN_ClearKeysDown(); IN_WaitButton(); CA_DownLevel(); ck_gameState.ep.ck6.passcard = true; }
int USL_HardError(word errval,int ax,int bp,int si) { #define IGNORE 0 #define RETRY 1 #define ABORT 2 extern void ShutdownId(void); static char buf[32]; static WindowRec wr; int di; char c,*s,*t; di = _DI; if (ax < 0) s = "DEVICE ERROR"; else { if ((di & 0x00ff) == 0) s = "DRIVE ~ IS WRITE PROTECTED"; else s = "ERROR ON DRIVE ~"; for (t = buf;*s;s++,t++) // Can't use sprintf() if ((*t = *s) == '~') *t = (ax & 0x00ff) + 'A'; *t = '\0'; s = buf; } c = peekb(0x40,0x49); // Get the current screen mode if ((c < 4) || (c == 7)) goto oh_kill_me; // DEBUG - handle screen cleanup fontnumber = 4; US_SaveWindow(&wr); US_CenterWindow(30,3); US_CPrint(s); US_CPrint("(R)ETRY or (A)BORT?"); VW_UpdateScreen(); IN_ClearKeysDown(); asm sti // Let the keyboard interrupts come through while (true) { switch (IN_WaitForASCII()) { case key_Escape: case 'a': case 'A': goto oh_kill_me; break; case key_Return: case key_Space: case 'r': case 'R': US_ClearWindow(); VW_UpdateScreen(); US_RestoreWindow(&wr); return(RETRY); break; } } oh_kill_me: abortprogram = s; ShutdownId(); fprintf(stderr,"TERMINAL ERROR: %s\n",s); return(ABORT); #undef IGNORE #undef RETRY #undef ABORT }
/* ================ = = DebugKeys = ================ */ id0_int_t DebugKeys (void) { id0_boolean_t esc; id0_int_t level; #if FRILLS if (Keyboard[0x12] && ingame) // DEBUG: end + 'E' to quit level { if (tedlevel) TEDDeath(); playstate = levelcomplete; } #endif if (Keyboard[0x22] && ingame) // G = god mode { VW_FixRefreshBuffer (); US_CenterWindow (12,2); if (godmode) US_PrintCentered ("God mode OFF"); else US_PrintCentered ("God mode ON"); VW_UpdateScreen(); IN_Ack(); godmode ^= 1; return 1; } else if (Keyboard[0x17]) // I = item cheat { VW_FixRefreshBuffer (); US_CenterWindow (12,3); US_PrintCentered ("Free items!"); gamestate.boobusbombs=99; gamestate.flowerpowers=99; gamestate.keys=99; VW_UpdateScreen(); IN_Ack (); return 1; } else if (Keyboard[0x24]) // J = jump cheat { jumpcheat^=1; VW_FixRefreshBuffer (); US_CenterWindow (18,3); if (jumpcheat) US_PrintCentered ("Jump cheat ON"); else US_PrintCentered ("Jump cheat OFF"); VW_UpdateScreen(); IN_Ack (); return 1; } #if FRILLS else if (Keyboard[0x32]) // M = memory info { DebugMemory(); return 1; } #endif else if (Keyboard[0x19]) // P = pause with no screen disruptioon { IN_Ack(); } else if (Keyboard[0x1f] && ingame) // S = slow motion { singlestep^=1; VW_FixRefreshBuffer (); US_CenterWindow (18,3); if (singlestep) US_PrintCentered ("Slow motion ON"); else US_PrintCentered ("Slow motion OFF"); VW_UpdateScreen(); IN_Ack (); return 1; } #if FRILLS else if (Keyboard[0x14]) // T = sprite test { TestSprites(); return 1; } #endif else if (Keyboard[0x11] && ingame) // W = warp to level { VW_FixRefreshBuffer (); US_CenterWindow(26,3); PrintY+=6; US_Print(" Warp to which level(0-16):"); VW_UpdateScreen(); esc = !US_LineInput (px,py,str,NULL,true,2,0); if (!esc) { level = atoi (str); if (level>=0 && level<=16) { gamestate.mapon = level; playstate = warptolevel; } } return 1; } return 0; }
void TestSprites(void) { id0_int_t hx,hy,sprite,oldsprite,bottomy,topx,shift; spritetabletype id0_far *spr; spritetype id0_seg *block; id0_unsigned_t mem,scan; VW_FixRefreshBuffer (); US_CenterWindow (30,17); US_CPrint ("Sprite Test"); US_CPrint ("-----------"); hy=PrintY; hx=(PrintX+56)&(~7); topx = hx+TEXTWIDTH; US_Print ("Chunk:\nWidth:\nHeight:\nOrgx:\nOrgy:\nXl:\nYl:\nXh:\nYh:\n" "Shifts:\nMem:\n"); bottomy = PrintY; sprite = STARTSPRITES; shift = 0; do { if (sprite>=STARTTILE8) sprite = STARTTILE8-1; else if (sprite<STARTSPRITES) sprite = STARTSPRITES; spr = &spritetable[sprite-STARTSPRITES]; block = (spritetype id0_seg *)grsegs[sprite]; VWB_Bar (hx,hy,TEXTWIDTH,bottomy-hy,WHITE); PrintX=hx; PrintY=hy; US_PrintUnsigned (sprite);US_Print ("\n");PrintX=hx; US_PrintUnsigned (spr->width);US_Print ("\n");PrintX=hx; US_PrintUnsigned (spr->height);US_Print ("\n");PrintX=hx; US_PrintSigned (spr->orgx);US_Print ("\n");PrintX=hx; US_PrintSigned (spr->orgy);US_Print ("\n");PrintX=hx; US_PrintSigned (spr->xl);US_Print ("\n");PrintX=hx; US_PrintSigned (spr->yl);US_Print ("\n");PrintX=hx; US_PrintSigned (spr->xh);US_Print ("\n");PrintX=hx; US_PrintSigned (spr->yh);US_Print ("\n");PrintX=hx; US_PrintSigned (spr->shifts);US_Print ("\n");PrintX=hx; if (!block) { US_Print ("-----"); } else { mem = block->sourceoffset[3]+5*block->planesize[3]; mem = (mem+15)&(~15); // round to paragraphs US_PrintUnsigned (mem); } oldsprite = sprite; do { // // draw the current shift, then wait for key // VWB_Bar(topx,hy,DISPWIDTH,bottomy-hy,WHITE); if (block) { PrintX = topx; PrintY = hy; US_Print ("Shift:"); US_PrintUnsigned (shift); US_Print ("\n"); VWB_DrawSprite (topx+16+shift*2,PrintY,sprite); } VW_UpdateScreen(); scan = IN_WaitForKey (); switch (scan) { case sc_UpArrow: sprite++; break; case sc_DownArrow: sprite--; break; case sc_LeftArrow: if (--shift == -1) shift = 3; break; case sc_RightArrow: if (++shift == 4) shift = 0; break; case sc_Escape: return; } } while (sprite == oldsprite); } while (1); }
int USL_HardError(word errval,int ax,int bp,int si) { #define IGNORE 0 #define RETRY 1 #define ABORT 2 extern void ShutdownId(void); static char buf[32]; static WindowRec wr; int di; char c,*s,*t; di = _DI; if (ax < 0) s = "Device Error"; else { if ((di & 0x00ff) == 0) s = "Drive ~ is Write Protected"; else s = "Error on Drive ~"; for (t = buf;*s;s++,t++) // Can't use sprintf() if ((*t = *s) == '~') *t = (ax & 0x00ff) + 'A'; *t = '\0'; s = buf; } c = peekb(0x40,0x49); // Get the current screen mode if ((c < 4) || (c == 7)) goto oh_kill_me; // DEBUG - handle screen cleanup US_SaveWindow(&wr); US_CenterWindow(30,3); US_CPrint(s); US_CPrint("(R)etry or (A)bort?"); VW_UpdateScreen(); IN_ClearKeysDown(); asm sti // Let the keyboard interrupts come through while (true) { switch (IN_WaitForASCII()) { case key_Escape: case 'a': case 'A': goto oh_kill_me; break; case key_Return: case key_Space: case 'r': case 'R': US_ClearWindow(); VW_UpdateScreen(); US_RestoreWindow(&wr); return(RETRY); break; } } oh_kill_me: abortprogram = s; ShutdownId(); fprintf(stderr,"Terminal Error: %s\n",s); if (tedlevel) fprintf(stderr,"You launched from TED. I suggest that you reboot...\n"); return(ABORT); #undef IGNORE #undef RETRY #undef ABORT }
void CheckKeys (void) { if (screenfaded) // don't do anything with a faded screen return; // // pause key wierdness can't be checked as a scan code // if (Paused) { CenterWindow (8,3); US_PrintCentered ("PAUSED"); VW_UpdateScreen (); SD_MusicOff(); IN_Ack(); SD_MusicOn(); Paused = false; if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } // // F1-F7/ESC to enter control panel // if ( (LastScan >= sc_F1 && LastScan <= sc_F7) || LastScan == sc_Escape) { StopMusic (); NormalScreen (); FreeUpMemory (); US_CenterWindow (20,8); US_CPrint ("Loading"); VW_UpdateScreen (); US_ControlPanel(); // REFKEEN - Alternative controllers support (maybe user has changed some keys which may currently have an effect) void PrepareGamePlayControllerMapping(void); PrepareGamePlayControllerMapping(); // if (abortgame) { playstate = ex_abort; return; } StartMusic (); IN_ClearKeysDown(); if (restartgame) playstate = ex_resetgame; if (loadedgame) playstate = ex_loadedgame; DrawPlayScreen (); CacheScaleds (); lasttimecount = SD_GetTimeCount(); if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } // // F10-? debug keys // if (Keyboard[sc_F10]) { DebugKeys(); if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse // if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement lasttimecount = SD_GetTimeCount(); } }