see if this fixes zapper movies
This commit is contained in:
parent
85b5214f40
commit
0d6820d922
|
@ -503,10 +503,14 @@ void FCEUI_SetInputFourscore(bool attachFourscore)
|
|||
FSAttached = attachFourscore;
|
||||
}
|
||||
|
||||
//mbg 6/18/08 HACK
|
||||
extern ZAPPER ZD[2];
|
||||
SFORMAT FCEUCTRL_STATEINFO[]={
|
||||
{ joy_readbit, 2, "JYRB"},
|
||||
{ joy, 4, "JOYS"},
|
||||
{ &LastStrobe, 1, "LSTS"},
|
||||
{ &ZD[0].bogo, 1, "ZBG0"},
|
||||
{ &ZD[1].bogo, 1, "ZBG1"},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -25,123 +25,122 @@
|
|||
#include "zapper.h"
|
||||
#include "../movie.h"
|
||||
|
||||
static ZAPPER ZD[2];
|
||||
ZAPPER ZD[2];
|
||||
|
||||
static void ZapperFrapper(int w, uint8 *bg, uint8 *spr, uint32 linets, int final)
|
||||
{
|
||||
int xs,xe;
|
||||
int zx,zy;
|
||||
int xs,xe;
|
||||
int zx,zy;
|
||||
|
||||
if(!bg) // New line, so reset stuff.
|
||||
{
|
||||
ZD[w].zappo=0;
|
||||
return;
|
||||
}
|
||||
xs=ZD[w].zappo;
|
||||
xe=final;
|
||||
if(!bg) // New line, so reset stuff.
|
||||
{
|
||||
ZD[w].zappo=0;
|
||||
return;
|
||||
}
|
||||
xs=ZD[w].zappo;
|
||||
xe=final;
|
||||
|
||||
zx=ZD[w].mzx;
|
||||
zy=ZD[w].mzy;
|
||||
zx=ZD[w].mzx;
|
||||
zy=ZD[w].mzy;
|
||||
|
||||
if(xe>256) xe=256;
|
||||
if(xe>256) xe=256;
|
||||
|
||||
if(scanline>=(zy-4) && scanline<=(zy+4))
|
||||
{
|
||||
while(xs<xe)
|
||||
{
|
||||
uint8 a1,a2;
|
||||
uint32 sum;
|
||||
if(xs<=(zx+4) && xs>=(zx-4))
|
||||
{
|
||||
a1=bg[xs];
|
||||
if(spr)
|
||||
{
|
||||
a2=spr[xs];
|
||||
|
||||
if(!(a2&0x80))
|
||||
if(!(a2&0x40) || (a1&64))
|
||||
a1=a2;
|
||||
}
|
||||
a1&=63;
|
||||
if(scanline>=(zy-4) && scanline<=(zy+4))
|
||||
{
|
||||
while(xs<xe)
|
||||
{
|
||||
uint8 a1,a2;
|
||||
uint32 sum;
|
||||
if(xs<=(zx+4) && xs>=(zx-4))
|
||||
{
|
||||
a1=bg[xs];
|
||||
if(spr)
|
||||
{
|
||||
a2=spr[xs];
|
||||
|
||||
sum=palo[a1].r+palo[a1].g+palo[a1].b;
|
||||
if(sum>=100*3)
|
||||
{
|
||||
ZD[w].zaphit=((uint64)linets+(xs+16)*(PAL?15:16))/48+timestampbase;
|
||||
goto endo;
|
||||
}
|
||||
}
|
||||
xs++;
|
||||
}
|
||||
}
|
||||
endo:
|
||||
ZD[w].zappo=final;
|
||||
if(!(a2&0x80))
|
||||
if(!(a2&0x40) || (a1&64))
|
||||
a1=a2;
|
||||
}
|
||||
a1&=63;
|
||||
|
||||
sum=palo[a1].r+palo[a1].g+palo[a1].b;
|
||||
if(sum>=100*3)
|
||||
{
|
||||
ZD[w].zaphit=((uint64)linets+(xs+16)*(PAL?15:16))/48+timestampbase;
|
||||
goto endo;
|
||||
}
|
||||
}
|
||||
xs++;
|
||||
}
|
||||
}
|
||||
endo:
|
||||
ZD[w].zappo=final;
|
||||
}
|
||||
|
||||
static INLINE int CheckColor(int w)
|
||||
{
|
||||
FCEUPPU_LineUpdate();
|
||||
FCEUPPU_LineUpdate();
|
||||
|
||||
if((ZD[w].zaphit+100)>=(timestampbase+timestamp)
|
||||
&& !(ZD[w].mzb&2)) return(0);
|
||||
if((ZD[w].zaphit+100)>=(timestampbase+timestamp)
|
||||
&& !(ZD[w].mzb&2)) return(0);
|
||||
|
||||
return(1);
|
||||
return(1);
|
||||
}
|
||||
|
||||
static uint8 ReadZapperVS(int w)
|
||||
{
|
||||
uint8 ret=0;
|
||||
|
||||
if(ZD[w].zap_readbit==4) ret=1;
|
||||
uint8 ret=0;
|
||||
|
||||
if(ZD[w].zap_readbit==7)
|
||||
{
|
||||
if(ZD[w].bogo)
|
||||
ret|=0x1;
|
||||
}
|
||||
if(ZD[w].zap_readbit==6)
|
||||
{
|
||||
if(!CheckColor(w))
|
||||
ret|=0x1;
|
||||
}
|
||||
if(!fceuindbg)
|
||||
ZD[w].zap_readbit++;
|
||||
return ret;
|
||||
if(ZD[w].zap_readbit==4) ret=1;
|
||||
|
||||
if(ZD[w].zap_readbit==7)
|
||||
{
|
||||
if(ZD[w].bogo)
|
||||
ret|=0x1;
|
||||
}
|
||||
if(ZD[w].zap_readbit==6)
|
||||
{
|
||||
if(!CheckColor(w))
|
||||
ret|=0x1;
|
||||
}
|
||||
if(!fceuindbg)
|
||||
ZD[w].zap_readbit++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void StrobeZapperVS(int w)
|
||||
{
|
||||
ZD[w].zap_readbit=0;
|
||||
ZD[w].zap_readbit=0;
|
||||
}
|
||||
|
||||
static uint8 ReadZapper(int w)
|
||||
{
|
||||
uint8 ret=0;
|
||||
if(ZD[w].bogo)
|
||||
ret|=0x10;
|
||||
if(CheckColor(w))
|
||||
ret|=0x8;
|
||||
return ret;
|
||||
uint8 ret=0;
|
||||
if(ZD[w].bogo)
|
||||
ret|=0x10;
|
||||
if(CheckColor(w))
|
||||
ret|=0x8;
|
||||
return ret;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
uint32 *ptr=(uint32 *)data;
|
||||
uint32 *ptr=(uint32 *)data;
|
||||
|
||||
//FCEU_DispMessage("%3d:%3d",ZD[w].mzx,ZD[w].mzy);
|
||||
if(ZD[w].bogo)
|
||||
ZD[w].bogo--;
|
||||
if(ptr[2]&3 && (!(ZD[w].mzb&3)))
|
||||
ZD[w].bogo=5;
|
||||
if(ZD[w].bogo)
|
||||
ZD[w].bogo--;
|
||||
if(ptr[2]&3 && (!(ZD[w].mzb&3)))
|
||||
ZD[w].bogo=5;
|
||||
|
||||
ZD[w].mzx=ptr[0];
|
||||
ZD[w].mzy=ptr[1];
|
||||
ZD[w].mzb=ptr[2];
|
||||
ZD[w].mzx=ptr[0];
|
||||
ZD[w].mzy=ptr[1];
|
||||
ZD[w].mzb=ptr[2];
|
||||
}
|
||||
|
||||
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].y = ZD[w].mzy;
|
||||
mr->zappers[w].b = ZD[w].mzb;
|
||||
mr->zappers[w].bogo = ZD[w].bogo;
|
||||
}
|
||||
|
||||
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].mzy = mr->zappers[w].y;
|
||||
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)
|
||||
{
|
||||
memset(&ZD[w],0,sizeof(ZAPPER));
|
||||
if(GameInfo->type == GIT_VSUNI)
|
||||
return(&ZAPVSC);
|
||||
else
|
||||
return(&ZAPC);
|
||||
memset(&ZD[w],0,sizeof(ZAPPER));
|
||||
if(GameInfo->type == GIT_VSUNI)
|
||||
return(&ZAPVSC);
|
||||
else
|
||||
return(&ZAPC);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ struct ZAPPER
|
|||
{
|
||||
uint32 mzx,mzy,mzb;
|
||||
int zap_readbit;
|
||||
int bogo;
|
||||
uint8 bogo;
|
||||
int zappo;
|
||||
uint64 zaphit;
|
||||
};
|
||||
|
|
|
@ -163,12 +163,13 @@ void MovieRecord::parse(MovieData* md, std::istream* is)
|
|||
parseJoy(is, joysticks[port]);
|
||||
else if(md->ports[port] == SI_ZAPPER)
|
||||
{
|
||||
int x,y,b;
|
||||
*is >> x >> y >> b;
|
||||
int x,y,b,bogo;
|
||||
*is >> x >> y >> b >> bogo;
|
||||
//todo: test uintDecFromIstream
|
||||
zappers[port].x = x;
|
||||
zappers[port].y = y;
|
||||
zappers[port].b = b;
|
||||
zappers[port].bogo = bogo;
|
||||
}
|
||||
|
||||
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)
|
||||
dumpJoy(os, joysticks[port]);
|
||||
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('|');
|
||||
}
|
||||
|
@ -345,7 +346,7 @@ static void LoadFM2(MovieData& movieData, std::istream* fp, int size=INT_MAX, bo
|
|||
bool bail = false;
|
||||
for(;;)
|
||||
{
|
||||
bool iswhitespace, isrecchar, isnewline;
|
||||
bool iswhitespace, isrecchar, isnewline;
|
||||
int c;
|
||||
if(size--<=0) goto bail;
|
||||
c = fp->get();
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
ValueArray<uint8,4> joysticks;
|
||||
|
||||
struct {
|
||||
uint8 x,y,b;
|
||||
uint8 x,y,b,bogo;
|
||||
} zappers[2];
|
||||
|
||||
//misc commands like reset, etc.
|
||||
|
|
Loading…
Reference in New Issue