void DEMONPEGTOP::Move() { if (App->inter->enemies_movement) { CheckState(); PerformActions(); } }
void* ProcessActions (void* v) { int PacketSlot; DEBUGPATH; while (!Globals.Done) { PacketSlot = PopFromWaiting (); if (PacketSlot == PACKET_NONE) break; PerformActions (PacketSlot); RouteAndSend (PacketSlot); } return NULL; }
int main(){ TriggerFx(0,0,0); ClearVram(); InitMusicPlayer(patches); SetMasterVolume(0x40); StartSong(midisong); SetSpritesTileTable(mario_sprites_tileset); SetFontTilesIndex(SMB_TILESET_SIZE); SetTileTable(smb_tileset); Screen.scrollHeight = 23; Screen.overlayHeight=4; Screen.overlayTileTable=smb_tileset; DrawMap2(0,Screen.scrollHeight,map_hud); unsigned char c; for(int y=0;y<22;y++){ for(int x=0;x<30;x++){ c=pgm_read_byte(&(map_main[(y*MAP_MAIN_WIDTH)+x+2])); SetTile(x,y+1,c); } } dx=0; sx=50; sy=169-32+8; sprDir=1; goombaX[0]=17; //159; goombaDir[0]=-1; goombaAnim[0]=0; goombaSpr[0]=0; goombaSprIndex[0]=6; goombaX[1]=65 ;//201; goombaDir[1]=1; goombaAnim[1]=0; goombaSpr[1]=0; goombaSprIndex[1]=10; MapSprite2(0,map_rwalk1,0); MapSprite2(6,map_rgoomba1,SPRITE_FLIP_X); MapSprite2(10,map_rgoomba2,0); g=0; MoveSprite(0,sx,sy,2,3); Scroll(0,-1); MoveSprite(goombaSprIndex[0],goombaX[0],176,2,2); MoveSprite(goombaSprIndex[1],goombaX[1],176,2,2); Screen.scrollY=0; Screen.overlayHeight=4;//OVERLAY_LINES; while(1){ WaitVsync(1); processControls(); if((active&1)!=0){ PerformActions(); MoveSprite(0,sx,sy+dy,2,3); }else{ MoveSprite(0,sx,230,2,3); } //animate goombas for(g=0;g<2;g++){ if(goombaX[g]<=0 && goombaDir[g]==-1){ goombaDir[g]=1; } if(goombaX[g] >= (215+15) && goombaDir[g]==1){ goombaDir[g]=-1; } goombaX[g]+=goombaDir[g]; goombaAnim[g]++; if(goombaAnim[g]==8){ goombaSpr[g]^=1; goombaAnim[g]=0; } if(goombaSpr[g]==0){ MapSprite2(goombaSprIndex[g],map_rgoomba1,goombaDir[g]!=1?SPRITE_FLIP_X:0); }else{ MapSprite2(goombaSprIndex[g],map_rgoomba2,goombaDir[g]!=1?SPRITE_FLIP_X:0); } MoveSprite(goombaSprIndex[g],goombaX[g],176-32+8,2,2); } } }
static int PerformActions(int vb,int no) { static int disable_sysfunc=0; /* Recursion lock */ int d=BitFlags&(1<<DARKBIT); int ct=0; int fl; int doagain=0; if(vb==1 && no == -1 ) { Output("Give me a direction too."); return(0); } if(vb==1 && no>=1 && no<=6) { int nl; if(Items[LIGHT_SOURCE].Location==MyLoc || Items[LIGHT_SOURCE].Location==CARRIED) d=0; if(d) Output("Dangerous to move in the dark! "); nl=Rooms[MyLoc].Exits[no-1]; if(nl!=0) { MyLoc=nl; return(0); } if(d) { if(Options&YOUARE) Output("You fell down and broke your neck. "); else Output("I fell down and broke my neck. "); glk_exit(); } if(Options&YOUARE) Output("You can't go in that direction. "); else Output("I can't go in that direction. "); return(0); } fl= -1; while(ct<=GameHeader.NumActions) { int vv,nv; vv=Actions[ct].Vocab; /* Think this is now right. If a line we run has an action73 run all following lines with vocab of 0,0 */ if(vb!=0 && (doagain&&vv!=0)) break; /* Oops.. added this minor cockup fix 1.11 */ if(vb!=0 && !doagain && fl== 0) break; nv=vv%150; vv/=150; if((vv==vb)||(doagain&&Actions[ct].Vocab==0)) { if((vv==0 && RandomPercent(nv))||doagain|| (vv!=0 && (nv==no||nv==0))) { int f2; if(fl== -1) fl= -2; if((f2=PerformLine(ct))>0) { /* ahah finally figured it out ! */ fl=0; if(f2==2) doagain=1; if(vb!=0 && doagain==0) return(0); } } } ct++; /* Previously this did not check ct against * GameHeader.NumActions and would read past the end of * Actions. I don't know what should happen on the last * action, but doing nothing is better than reading one * past the end. * --Chris */ if(ct <= GameHeader.NumActions && Actions[ct].Vocab!=0) doagain=0; } if(fl!=0 && disable_sysfunc==0) { int item; if(Items[LIGHT_SOURCE].Location==MyLoc || Items[LIGHT_SOURCE].Location==CARRIED) d=0; if(vb==10 || vb==18) { /* Yes they really _are_ hardcoded values */ if(vb==10) { if(xstrcasecmp(NounText,"ALL")==0) { int i=0; int f=0; if(d) { Output("It is dark.\n"); return 0; } while(i<=GameHeader.NumItems) { if(Items[i].Location==MyLoc && Items[i].AutoGet!=NULL && Items[i].AutoGet[0]!='*') { no=WhichWord(Items[i].AutoGet,Nouns); disable_sysfunc=1; /* Don't recurse into auto get ! */ PerformActions(vb,no); /* Recursively check each items table code */ disable_sysfunc=0; if(CountCarried()==GameHeader.MaxCarry) { if(Options&YOUARE) Output("You are carrying too much. "); else Output("I've too much to carry. "); return(0); } Items[i].Location= CARRIED; Output(Items[i].Text); Output(": O.K.\n"); f=1; } i++; } if(f==0) Output("Nothing taken."); return(0); } if(no==-1) { Output("What ? "); return(0); } if(CountCarried()==GameHeader.MaxCarry) { if(Options&YOUARE) Output("You are carrying too much. "); else Output("I've too much to carry. "); return(0); } item=MatchUpItem(NounText,MyLoc); if(item==-1) { if(Options&YOUARE) Output("It is beyond your power to do that. "); else Output("It's beyond my power to do that. "); return(0); } Items[item].Location= CARRIED; Output("O.K. "); return(0); } if(vb==18) { if(xstrcasecmp(NounText,"ALL")==0) { int i=0; int f=0; while(i<=GameHeader.NumItems) { if(Items[i].Location==CARRIED && Items[i].AutoGet && Items[i].AutoGet[0]!='*') { no=WhichWord(Items[i].AutoGet,Nouns); disable_sysfunc=1; PerformActions(vb,no); disable_sysfunc=0; Items[i].Location=MyLoc; Output(Items[i].Text); Output(": O.K.\n"); f=1; } i++; } if(f==0) Output("Nothing dropped.\n"); return(0); } if(no==-1) { Output("What ? "); return(0); } item=MatchUpItem(NounText,CARRIED); if(item==-1) { if(Options&YOUARE) Output("It's beyond your power to do that.\n"); else Output("It's beyond my power to do that.\n"); return(0); } Items[item].Location=MyLoc; Output("O.K. "); return(0); } } } return(fl); }
void glk_main(void) { FILE *f; int vb,no; Bottom = glk_window_open(0, 0, 0, wintype_TextBuffer, 1); if(Bottom == NULL) glk_exit(); glk_set_window(Bottom); if(game_file == NULL) Fatal("No game provided"); f = fopen(game_file, "r"); if(f==NULL) Fatal("Cannot open game"); if (Options & TRS80_STYLE) { Width = 64; TopHeight = 11; } else { Width = 80; TopHeight = 10; } if(split_screen) { Top = glk_window_open(Bottom, winmethod_Above | winmethod_Fixed, TopHeight, wintype_TextGrid, 0); if(Top == NULL) { split_screen = 0; Top = Bottom; } } else { Top = Bottom; } Output("\ Scott Free, A Scott Adams game driver in C.\n\ Release 1.14, (c) 1993,1994,1995 Swansea University Computer Society.\n\ Distributed under the GNU software license\n\n"); LoadDatabase(f,(Options&DEBUGGING)?1:0); fclose(f); srand(time(NULL)); while(1) { glk_tick(); PerformActions(0,0); Look(); if(GetInput(&vb,&no) == -1) continue; switch(PerformActions(vb,no)) { case -1:Output("I don't understand your command. "); break; case -2:Output("I can't do that yet. "); break; } /* Brian Howarth games seem to use -1 for forever */ if(Items[LIGHT_SOURCE].Location/*==-1*/!=DESTROYED && GameHeader.LightTime!= -1) { GameHeader.LightTime--; if(GameHeader.LightTime<1) { BitFlags|=(1<<LIGHTOUTBIT); if(Items[LIGHT_SOURCE].Location==CARRIED || Items[LIGHT_SOURCE].Location==MyLoc) { if(Options&SCOTTLIGHT) Output("Light has run out! "); else Output("Your light has run out. "); } if(Options&PREHISTORIC_LAMP) Items[LIGHT_SOURCE].Location=DESTROYED; } else if(GameHeader.LightTime<25) { if(Items[LIGHT_SOURCE].Location==CARRIED || Items[LIGHT_SOURCE].Location==MyLoc) { if(Options&SCOTTLIGHT) { Output("Light runs out in "); OutputNumber(GameHeader.LightTime); Output(" turns. "); } else { if(GameHeader.LightTime%5==0) Output("Your light is growing dim. "); } } } } } }