see if this fixes zapper movies

This commit is contained in:
zeromus 2008-06-19 03:26:37 +00:00
parent 85b5214f40
commit 0d6820d922
5 changed files with 115 additions and 114 deletions

View File

@ -503,10 +503,14 @@ void FCEUI_SetInputFourscore(bool attachFourscore)
FSAttached = attachFourscore; FSAttached = attachFourscore;
} }
//mbg 6/18/08 HACK
extern ZAPPER ZD[2];
SFORMAT FCEUCTRL_STATEINFO[]={ SFORMAT FCEUCTRL_STATEINFO[]={
{ joy_readbit, 2, "JYRB"}, { joy_readbit, 2, "JYRB"},
{ joy, 4, "JOYS"}, { joy, 4, "JOYS"},
{ &LastStrobe, 1, "LSTS"}, { &LastStrobe, 1, "LSTS"},
{ &ZD[0].bogo, 1, "ZBG0"},
{ &ZD[1].bogo, 1, "ZBG1"},
{ 0 } { 0 }
}; };

View File

@ -1,22 +1,22 @@
/* FCE Ultra - NES/Famicom Emulator /* FCE Ultra - NES/Famicom Emulator
* *
* Copyright notice for this file: * Copyright notice for this file:
* Copyright (C) 2002 Xodnizel * Copyright (C) 2002 Xodnizel
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -25,123 +25,122 @@
#include "zapper.h" #include "zapper.h"
#include "../movie.h" #include "../movie.h"
static ZAPPER ZD[2]; ZAPPER ZD[2];
static void ZapperFrapper(int w, uint8 *bg, uint8 *spr, uint32 linets, int final) static void ZapperFrapper(int w, uint8 *bg, uint8 *spr, uint32 linets, int final)
{ {
int xs,xe; int xs,xe;
int zx,zy; int zx,zy;
if(!bg) // New line, so reset stuff. if(!bg) // New line, so reset stuff.
{ {
ZD[w].zappo=0; ZD[w].zappo=0;
return; return;
} }
xs=ZD[w].zappo; xs=ZD[w].zappo;
xe=final; xe=final;
zx=ZD[w].mzx; zx=ZD[w].mzx;
zy=ZD[w].mzy; zy=ZD[w].mzy;
if(xe>256) xe=256; if(xe>256) xe=256;
if(scanline>=(zy-4) && scanline<=(zy+4)) if(scanline>=(zy-4) && scanline<=(zy+4))
{ {
while(xs<xe) while(xs<xe)
{ {
uint8 a1,a2; uint8 a1,a2;
uint32 sum; uint32 sum;
if(xs<=(zx+4) && xs>=(zx-4)) if(xs<=(zx+4) && xs>=(zx-4))
{ {
a1=bg[xs]; a1=bg[xs];
if(spr) if(spr)
{ {
a2=spr[xs]; a2=spr[xs];
if(!(a2&0x80))
if(!(a2&0x40) || (a1&64))
a1=a2;
}
a1&=63;
sum=palo[a1].r+palo[a1].g+palo[a1].b; if(!(a2&0x80))
if(sum>=100*3) if(!(a2&0x40) || (a1&64))
{ a1=a2;
ZD[w].zaphit=((uint64)linets+(xs+16)*(PAL?15:16))/48+timestampbase; }
goto endo; a1&=63;
}
} sum=palo[a1].r+palo[a1].g+palo[a1].b;
xs++; if(sum>=100*3)
} {
} ZD[w].zaphit=((uint64)linets+(xs+16)*(PAL?15:16))/48+timestampbase;
endo: goto endo;
ZD[w].zappo=final; }
}
xs++;
}
}
endo:
ZD[w].zappo=final;
} }
static INLINE int CheckColor(int w) static INLINE int CheckColor(int w)
{ {
FCEUPPU_LineUpdate(); FCEUPPU_LineUpdate();
if((ZD[w].zaphit+100)>=(timestampbase+timestamp) if((ZD[w].zaphit+100)>=(timestampbase+timestamp)
&& !(ZD[w].mzb&2)) return(0); && !(ZD[w].mzb&2)) return(0);
return(1); return(1);
} }
static uint8 ReadZapperVS(int w) static uint8 ReadZapperVS(int w)
{ {
uint8 ret=0; uint8 ret=0;
if(ZD[w].zap_readbit==4) ret=1;
if(ZD[w].zap_readbit==7) if(ZD[w].zap_readbit==4) ret=1;
{
if(ZD[w].bogo) if(ZD[w].zap_readbit==7)
ret|=0x1; {
} if(ZD[w].bogo)
if(ZD[w].zap_readbit==6) ret|=0x1;
{ }
if(!CheckColor(w)) if(ZD[w].zap_readbit==6)
ret|=0x1; {
} if(!CheckColor(w))
if(!fceuindbg) ret|=0x1;
ZD[w].zap_readbit++; }
return ret; if(!fceuindbg)
ZD[w].zap_readbit++;
return ret;
} }
static void StrobeZapperVS(int w) static void StrobeZapperVS(int w)
{ {
ZD[w].zap_readbit=0; ZD[w].zap_readbit=0;
} }
static uint8 ReadZapper(int w) static uint8 ReadZapper(int w)
{ {
uint8 ret=0; uint8 ret=0;
if(ZD[w].bogo) if(ZD[w].bogo)
ret|=0x10; ret|=0x10;
if(CheckColor(w)) if(CheckColor(w))
ret|=0x8; ret|=0x8;
return ret; return ret;
} }
static void DrawZapper(int w, uint8 *buf, int arg) static void DrawZapper(int w, uint8 *buf, int arg)
{ {
FCEU_DrawGunSight(buf, ZD[w].mzx,ZD[w].mzy); FCEU_DrawGunSight(buf, ZD[w].mzx,ZD[w].mzy);
} }
static void UpdateZapper(int w, void *data, int arg) static void UpdateZapper(int w, void *data, int arg)
{ {
uint32 *ptr=(uint32 *)data; uint32 *ptr=(uint32 *)data;
//FCEU_DispMessage("%3d:%3d",ZD[w].mzx,ZD[w].mzy); if(ZD[w].bogo)
if(ZD[w].bogo) ZD[w].bogo--;
ZD[w].bogo--; if(ptr[2]&3 && (!(ZD[w].mzb&3)))
if(ptr[2]&3 && (!(ZD[w].mzb&3))) ZD[w].bogo=5;
ZD[w].bogo=5;
ZD[w].mzx=ptr[0]; ZD[w].mzx=ptr[0];
ZD[w].mzy=ptr[1]; ZD[w].mzy=ptr[1];
ZD[w].mzb=ptr[2]; ZD[w].mzb=ptr[2];
} }
static void LogZapper(int w, MovieRecord* mr) static void LogZapper(int w, MovieRecord* mr)
@ -149,18 +148,15 @@ static void LogZapper(int w, MovieRecord* mr)
mr->zappers[w].x = ZD[w].mzx; mr->zappers[w].x = ZD[w].mzx;
mr->zappers[w].y = ZD[w].mzy; mr->zappers[w].y = ZD[w].mzy;
mr->zappers[w].b = ZD[w].mzb; mr->zappers[w].b = ZD[w].mzb;
mr->zappers[w].bogo = ZD[w].bogo;
} }
static void LoadZapper(int w, MovieRecord* mr) static void LoadZapper(int w, MovieRecord* mr)
{ {
if(ZD[w].bogo)
ZD[w].bogo--;
if(mr->zappers[w].b&3 && (!(ZD[w].mzb&3)))
ZD[w].bogo=5;
ZD[w].mzx = mr->zappers[w].x; ZD[w].mzx = mr->zappers[w].x;
ZD[w].mzy = mr->zappers[w].y; ZD[w].mzy = mr->zappers[w].y;
ZD[w].mzb = mr->zappers[w].b; ZD[w].mzb = mr->zappers[w].b;
ZD[w].bogo = mr->zappers[w].bogo;
} }
@ -169,11 +165,11 @@ static INPUTC ZAPVSC={ReadZapperVS,0,StrobeZapperVS,UpdateZapper,ZapperFrapper,D
INPUTC *FCEU_InitZapper(int w) INPUTC *FCEU_InitZapper(int w)
{ {
memset(&ZD[w],0,sizeof(ZAPPER)); memset(&ZD[w],0,sizeof(ZAPPER));
if(GameInfo->type == GIT_VSUNI) if(GameInfo->type == GIT_VSUNI)
return(&ZAPVSC); return(&ZAPVSC);
else else
return(&ZAPC); return(&ZAPC);
} }

View File

@ -5,7 +5,7 @@ struct ZAPPER
{ {
uint32 mzx,mzy,mzb; uint32 mzx,mzy,mzb;
int zap_readbit; int zap_readbit;
int bogo; uint8 bogo;
int zappo; int zappo;
uint64 zaphit; uint64 zaphit;
}; };

View File

@ -163,12 +163,13 @@ void MovieRecord::parse(MovieData* md, std::istream* is)
parseJoy(is, joysticks[port]); parseJoy(is, joysticks[port]);
else if(md->ports[port] == SI_ZAPPER) else if(md->ports[port] == SI_ZAPPER)
{ {
int x,y,b; int x,y,b,bogo;
*is >> x >> y >> b; *is >> x >> y >> b >> bogo;
//todo: test uintDecFromIstream //todo: test uintDecFromIstream
zappers[port].x = x; zappers[port].x = x;
zappers[port].y = y; zappers[port].y = y;
zappers[port].b = b; zappers[port].b = b;
zappers[port].bogo = bogo;
} }
is->get(); //eat the pipe is->get(); //eat the pipe
@ -208,7 +209,7 @@ void MovieRecord::dump(MovieData* md, std::ostream* os, int index)
if(md->ports[port] == SI_GAMEPAD) if(md->ports[port] == SI_GAMEPAD)
dumpJoy(os, joysticks[port]); dumpJoy(os, joysticks[port]);
else if(md->ports[port] == SI_ZAPPER) else if(md->ports[port] == SI_ZAPPER)
*os << setw(3) << setfill('0') << (int)zappers[port].x << ' ' << setw(3) << setfill('0') << (int)zappers[port].y << setw(1) << ' ' << (int)zappers[port].b; *os << setw(3) << setfill('0') << (int)zappers[port].x << ' ' << setw(3) << setfill('0') << (int)zappers[port].y << setw(1) << ' ' << (int)zappers[port].b << ' ' << (int)zappers[port].bogo;
} }
os->put('|'); os->put('|');
} }
@ -345,7 +346,7 @@ static void LoadFM2(MovieData& movieData, std::istream* fp, int size=INT_MAX, bo
bool bail = false; bool bail = false;
for(;;) for(;;)
{ {
bool iswhitespace, isrecchar, isnewline; bool iswhitespace, isrecchar, isnewline;
int c; int c;
if(size--<=0) goto bail; if(size--<=0) goto bail;
c = fp->get(); c = fp->get();

View File

@ -49,7 +49,7 @@ public:
ValueArray<uint8,4> joysticks; ValueArray<uint8,4> joysticks;
struct { struct {
uint8 x,y,b; uint8 x,y,b,bogo;
} zappers[2]; } zappers[2];
//misc commands like reset, etc. //misc commands like reset, etc.