void DoTunnel(struct Player *p, int w) { p->dir=DIR_STOP; p->nextdir=DIR_STOP; p->mcnt=0; p->mc=0; DrawBoardPart(p->lx,p->ly,ReadBoard(p->lx,p->ly)); DrawBoardPart(p->bx,p->by,ReadBoard(p->bx,p->by)); switch(w) { case LEFT_TUNNEL: p->zx=17*BITMAP_X; p->zy=5*BITMAP_Y; p->lx=17; p->ly=5; break; case RIGHT_TUNNEL: p->zx=1*BITMAP_X; p->zy=5*BITMAP_Y; p->lx=1; p->ly=5; break; default: debug_msg((char *)"ILLEGAL tunnel!\n"); break; } }
void DrawScreen(void) { int x,y,c; /* debug_msg((char *)"DEBUG- DrawScreen\n"); */ destw->setForeground(0xffffff); destw->setBackground(0); destw->clear(); NumDots=0; for(y=0;y<BoardY;y++) { for(x=0;x<BoardX;x++) { c=ReadBoard(x,y); DrawBoardPart(x,y,c); if(c==(int)'.') NumDots++; if(c==(int)'*') NumDots++; } } UpdateScore(); }
void ReadChunks() { Context context; while (!stream.Eof()) { dword id = stream.Read32(); const dword length = stream.Read32(); NST_VERIFY( length <= SIZE_1K * 4096UL ); switch (id) { case AsciiId<'N','A','M','E'>::V: id = (context( 0, id ) ? ReadName ( ) : 0); break; case AsciiId<'R','E','A','D'>::V: id = (context( 1, id ) ? ReadComment ( ) : 0); break; case AsciiId<'D','I','N','F'>::V: id = (context( 2, id ) ? ReadDumper ( ) : 0); break; case AsciiId<'T','V','C','I'>::V: id = (context( 3, id ) ? ReadSystem ( context ) : 0); break; case AsciiId<'B','A','T','R'>::V: id = (context( 4, id ) ? ReadBattery ( ) : 0); break; case AsciiId<'M','A','P','R'>::V: id = (context( 5, id ) ? ReadBoard ( ) : 0); break; case AsciiId<'M','I','R','R'>::V: id = (context( 6, id ) ? ReadMirroring ( ) : 0); break; case AsciiId<'C','T','R','L'>::V: id = (context( 7, id ) ? ReadController ( ) : 0); break; case AsciiId<'V','R','O','R'>::V: id = (context( 8, id ) ? ReadChrRam ( ) : 0); break; default: switch (id & 0x00FFFFFF) { case AsciiId<'P','C','K'>::V: case AsciiId<'C','C','K'>::V: case AsciiId<'P','R','G'>::V: case AsciiId<'C','H','R'>::V: { uint index = id >> 24 & 0xFF; if (index >= Ascii<'0'>::V && index <= Ascii<'9'>::V) { index -= Ascii<'0'>::V; } else if (index >= Ascii<'A'>::V && index <= Ascii<'F'>::V) { index = index - Ascii<'A'>::V + 10; } else { index = ~0U; } if (index < 16) { switch (dword part = (id & 0x00FFFFFF)) { case AsciiId<'P','C','K'>::V: case AsciiId<'C','C','K'>::V: part = (part == AsciiId<'C','C','K'>::V); id = (context( 9 + (part << 4) + index, id) ? ReadChecksum( part, index, context.roms[part][index] ) : 0); break; case AsciiId<'P','R','G'>::V: case AsciiId<'C','H','R'>::V: part = (part == AsciiId<'C','H','R'>::V); id = (context( 9 + 32 + (part << 4) + index, id ) ? ReadRom( part, index, length, context.roms[part] ) : 0); break; } break; } } default: id = ReadUnknown( id ); break; } } if (id < length) { for (id = length - id; id > 0x7FFFFFFF; id -= 0x7FFFFFFF) stream.Seek( 0x7FFFFFFF ); if (id) stream.Seek( id ); } else if (id > length) { throw RESULT_ERR_CORRUPT_FILE; } } for (uint i=0; i < 2; ++i) { uint count = 0; dword size = 0; for (uint j=0; j < 16; ++j) { if (const dword n=context.roms[i][j].data.Size()) { count++; size += n; } } if (count) { Profile::Board::Roms& rom = (i ? profile.board.chr : profile.board.prg); rom.resize( count ); Ram& dst = (i ? chr : prg); dst.Set( size ); if (!rom.empty()) { for (Profile::Board::Pins::const_iterator it(rom.front().pins.begin()), end(rom.front().pins.end()); it != end; ++it) dst.Pin(it->number) = it->function.c_str(); } size = 0; for (uint j=0, k=0; j < 16; ++j) { const Context::Rom& src = context.roms[i][j]; if (src.data.Size()) { rom[k].id = k; rom[k].size = src.data.Size(); rom[k].hash.Assign( NULL, src.crc ); k++; std::memcpy( dst.Mem(size), src.data.Mem(), src.data.Size() ); size += src.data.Size(); } } } } if (profileEx.nmt == ProfileEx::NMT_HORIZONTAL) { profile.board.solderPads = Profile::Board::SOLDERPAD_V; } else if (profileEx.nmt == ProfileEx::NMT_HORIZONTAL) { profile.board.solderPads = Profile::Board::SOLDERPAD_H; } switch (context.system) { case Context::SYSTEM_NTSC: if (favoredSystem == FAVORED_FAMICOM) { profile.system.type = Profile::System::FAMICOM; } if (favoredSystem == FAVORED_DENDY) { profile.system.type = Profile::System::DENDY; profile.system.cpu = Profile::System::CPU_DENDY; profile.system.ppu = Profile::System::PPU_DENDY; } else { profile.system.type = Profile::System::NES_NTSC; } break; default: profile.multiRegion = true; if (favoredSystem == FAVORED_FAMICOM) { profile.system.type = Profile::System::FAMICOM; break; } else if (favoredSystem != FAVORED_NES_PAL && favoredSystem != FAVORED_DENDY) { profile.system.type = Profile::System::NES_NTSC; break; } case Context::SYSTEM_PAL: if (favoredSystem == FAVORED_DENDY) { profile.system.type = Profile::System::DENDY; profile.system.cpu = Profile::System::CPU_DENDY; profile.system.ppu = Profile::System::PPU_DENDY; } else { profile.system.type = Profile::System::NES_PAL; profile.system.cpu = Profile::System::CPU_RP2A07; profile.system.ppu = Profile::System::PPU_RP2C07; } break; } }
/* NOTE: This function isn't finished yet... */ bool NewCheckSpace(int x, int y, int *dx, int *dy) { int foo; foo=ReadBoard(x,y); if(foo>'a') { return true; } else { return false; } }
bool CheckSpace(int x, int y, int *dx, int *dy) { int bx,by,foo; bx=(x/BITMAP_X)+(*dx); by=(y/BITMAP_Y)+(*dy); foo=ReadBoard(bx,by); if(foo>='a') { return true; } else { return false; } }
void MovePac(struct Player *P) { int nx,ny,goo=0,dx=0,dy=0,part; bool Check=false; P->mc++; if(WakaFlag) { WakaFlag=0; P->cur=P->old; } else { WakaFlag=1; P->old=P->cur; P->cur=SPR_PACNONE; //destw->draw(picts[SPR_PACNONE],P->zx,P->zy); destw->copyBlock(srcs,picts[SPR_PACNONE]->x,picts[SPR_PACNONE]->y,P->zx,P->zy,BITMAP_X,BITMAP_Y); } if(P->mc==P->speed) { if((P->bx==0)&&(P->by==5)) { DoTunnel(P,LEFT_TUNNEL); } else if((P->bx==18)&&(P->by==5)) { DoTunnel(P,RIGHT_TUNNEL); } P->mc=0; nx=P->zx; ny=P->zy; if(P->mcnt==CountMax) Check=true; if(P->mcnt<0) Check=true; if(Check) { P->mcnt=0; P->dir=P->nextdir; } switch(P->dir) { case DIR_UP: dy= -1; P->cur=SPR_PACUP; break; case DIR_DOWN: dy=1; P->cur=SPR_PACDOWN; break; case DIR_LEFT: dx= -1; P->cur=SPR_PACLEFT; break; case DIR_RIGHT: dx=1; P->cur=SPR_PACRIGHT; break; default: break; } dx=dx*AspectX; dy=dy*AspectY; //dy=DirY[P->dir]; dx=DirX[P->dir]; //P->cur=(*shapes)[P->dir]; if(Check) { P->lx=(nx+BITMAP_X/2)/BITMAP_X; P->ly=(ny+BITMAP_Y/2)/BITMAP_Y; part=ReadBoard(P->bx,P->by); if((part)==(int)'.') { WriteBoard(P->bx,P->by,(int)','); NumDots--; NumPoints+=1; UpdateScore(); } else if((part)==(int)'*') { WriteBoard(P->bx,P->by,(int)','); NumDots--; NumPoints+=10; UpdateScore(); DoMyBlue(); } /*P->lx=(nx+BITMAP_X/2)/BITMAP_X; P->ly=(ny+BITMAP_Y/2)/BITMAP_Y;*/ goo=CheckSpace(nx,ny,&dx,&dy); if(goo) { P->dir=DIR_STOP; P->nextdir=DIR_STOP; } } if(!goo) { if(FOOBAR_PACMOVE) DrawBoardPart(P->lx,P->ly,ReadBoard(P->lx,P->ly)); nx+=dx; ny+=dy; P->mcnt++; #ifdef CATCH_OUT if(ny<0) { ny=1; P->dir=DIR_DOWN; } if(ny>SCREEN_Y+BITMAP_X) { ny=SCREEN_Y-2; P->dir=DIR_UP; } if(nx<0) { nx=1; P->dir=DIR_RIGHT; } if(nx>SCREEN_X) { nx=SCREEN_X-2; P->dir=DIR_LEFT; } #endif if(WakaFlag) { //destw->draw(picts[P->cur],nx,ny); destw->copyBlock(srcs,picts[P->cur]->x,picts[P->cur]->y,nx,ny,BITMAP_X,BITMAP_Y); } else { //destw->draw(picts[SPR_PACNONE],nx,ny); destw->copyBlock(srcs,picts[SPR_PACNONE]->x,picts[SPR_PACNONE]->y,nx,ny,BITMAP_X,BITMAP_Y); } P->zx=nx; P->zy=ny; P->bx=(nx+BITMAP_X/2)/BITMAP_X; P->by=(ny+BITMAP_Y/2)/BITMAP_Y; } } }
void MoveGhost(struct Player *g) { int nx,ny,goo=0,dx=0,dy=0; bool Check=false; g->mc++; if(g->mc==g->speed) { g->mc=0; nx=g->zx; ny=g->zy; if(g->mcnt==CountMax) Check=true; if(g->mcnt<0) Check=true; if(Check) { g->mcnt=0; g->dir=g->nextdir; } if(g->lastint==G_SMART) { switch(g->dir) { case DIR_UP: dy= -1; g->cur=SPR_GUP; break; case DIR_DOWN: dy=1; g->cur=SPR_GDOWN; break; case DIR_LEFT: dx= -1; g->cur=SPR_GLEFT; break; case DIR_RIGHT: dx=1; g->cur=SPR_GRIGHT; break; default: break; } } if(g->lastint==G_SCARED) { switch(g->dir) { case DIR_UP: dy= -1; g->cur=SPR_BUP; break; case DIR_DOWN: dy=1; g->cur=SPR_BDOWN; break; case DIR_LEFT: dx= -1; g->cur=SPR_BLEFT; break; case DIR_RIGHT: dx=1; g->cur=SPR_BRIGHT; break; default: break; } } if(g->lastint==G_EYES) { switch(g->dir) { case DIR_UP: dy= -1; g->cur=SPR_EUP; break; case DIR_DOWN: dy=1; g->cur=SPR_EDOWN; break; case DIR_LEFT: dx= -1; g->cur=SPR_ELEFT; break; case DIR_RIGHT: dx=1; g->cur=SPR_ERIGHT; break; default: break; } } dx=dx*AspectX; dy=dy*AspectY; if(Check) { DrawBoardPart(g->lx,g->ly,ReadBoard(g->lx,g->ly)); g->lx=(nx+BITMAP_X/2)/BITMAP_X; g->ly=(ny+BITMAP_Y/2)/BITMAP_Y; goo=CheckSpace(nx,ny,&dx,&dy); if(goo) { GhostChoose(g); g->mcnt=CountMax; MoveGhost(g); } } if(!goo) { if(FOOBAR_PACMOVE) DrawBoardPart(g->lx,g->ly,ReadBoard(g->lx,g->ly)); nx+=dx; ny+=dy; g->mcnt++; #ifdef CATCH_OUT if(ny<0) { ny=1; g->dir=DIR_DOWN; } if(ny>SCREEN_Y) { ny=SCREEN_Y-2; g->dir=DIR_UP; } if(nx<0) { nx=1; g->dir=DIR_RIGHT; } if(nx>SCREEN_X) { nx=SCREEN_X-2; g->dir=DIR_LEFT; } #endif //destw->draw(picts[g->cur],nx,ny); destw->copyBlock(srcs,picts[g->cur]->x,picts[g->cur]->y,nx,ny,BITMAP_X,BITMAP_Y); g->zx=nx; g->zy=ny; g->bx=(nx+BITMAP_X/2)/BITMAP_X; g->by=(ny+BITMAP_Y/2)/BITMAP_Y; if(g->lastint==G_EYES) if((g->bx==HomeX)&&(g->by==HomeY)) { g->lastint=G_SMART; DoNormal(g); } } } }