Made collisions editable

This commit is contained in:
thrust26 2017-12-20 18:18:07 +01:00
parent f61e45829c
commit 0826ce6bd6
8 changed files with 246 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -417,25 +417,83 @@ bool TIADebug::priorityPF(int newVal)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIADebug::collision(CollisionBit id) const bool TIADebug::collision(CollisionBit id, bool toggle) const
{ {
switch(id) switch(id)
{ {
case Cx_M0P1: return myTIA.collCXM0P() & 0x80; case Cx_M0P1:
case Cx_M0P0: return myTIA.collCXM0P() & 0x40; if(toggle)
case Cx_M1P0: return myTIA.collCXM1P() & 0x80; myTIA.toggleCollP1M0();
case Cx_M1P1: return myTIA.collCXM1P() & 0x40; return myTIA.collCXM0P() & 0x80;
case Cx_P0PF: return myTIA.collCXP0FB() & 0x80;
case Cx_P0BL: return myTIA.collCXP0FB() & 0x40; case Cx_M0P0:
case Cx_P1PF: return myTIA.collCXP1FB() & 0x80; if(toggle)
case Cx_P1BL: return myTIA.collCXP1FB() & 0x40; myTIA.toggleCollP0M0();
case Cx_M0PF: return myTIA.collCXM0FB() & 0x80; return myTIA.collCXM0P() & 0x40;
case Cx_M0BL: return myTIA.collCXM0FB() & 0x40;
case Cx_M1PF: return myTIA.collCXM1FB() & 0x80; case Cx_M1P0:
case Cx_M1BL: return myTIA.collCXM1FB() & 0x40; if(toggle)
case Cx_BLPF: return myTIA.collCXBLPF() & 0x80; myTIA.toggleCollP0M1();
case Cx_P0P1: return myTIA.collCXPPMM() & 0x80; return myTIA.collCXM1P() & 0x80;
case Cx_M0M1: return myTIA.collCXPPMM() & 0x40;
case Cx_M1P1:
if(toggle)
myTIA.toggleCollP1M1();
return myTIA.collCXM1P() & 0x40;
case Cx_P0PF:
if(toggle)
myTIA.toggleCollP0PF();
return myTIA.collCXP0FB() & 0x80;
case Cx_P0BL:
if(toggle)
myTIA.toggleCollP0BL();
return myTIA.collCXP0FB() & 0x40;
case Cx_P1PF:
if(toggle)
myTIA.toggleCollP1PF();
return myTIA.collCXP1FB() & 0x80;
case Cx_P1BL:
if(toggle)
myTIA.toggleCollP1BL();
return myTIA.collCXP1FB() & 0x40;
case Cx_M0PF:
if(toggle)
myTIA.toggleCollM0PF();
return myTIA.collCXM0FB() & 0x80;
case Cx_M0BL:
if(toggle)
myTIA.toggleCollM0BL();
return myTIA.collCXM0FB() & 0x40;
case Cx_M1PF:
if(toggle)
myTIA.toggleCollM1PF();
return myTIA.collCXM1FB() & 0x80;
case Cx_M1BL:
if(toggle)
myTIA.toggleCollM1BL();
return myTIA.collCXM1FB() & 0x40;
case Cx_BLPF:
if(toggle)
myTIA.toggleCollBLPF();
return myTIA.collCXBLPF() & 0x80;
case Cx_P0P1:
if(toggle)
myTIA.toggleCollP0P1();
return myTIA.collCXPPMM() & 0x80;
case Cx_M0M1:
if(toggle)
myTIA.toggleCollM0M1();
return myTIA.collCXPPMM() & 0x40;
} }
return false; // make compiler happy return false; // make compiler happy
} }

View File

@ -130,6 +130,9 @@ class TIADebug : public DebuggerSystem
bool scorePF(int newVal = -1); bool scorePF(int newVal = -1);
bool priorityPF(int newVal = -1); bool priorityPF(int newVal = -1);
/** Get specific bits in the collision register (used by collXX_XX) */
bool collision(CollisionBit id, bool toggle = false) const;
// Collision registers // Collision registers
bool collM0_P1() const { return collision(Cx_M0P1); } bool collM0_P1() const { return collision(Cx_M0P1); }
bool collM0_P0() const { return collision(Cx_M0P0); } bool collM0_P0() const { return collision(Cx_M0P0); }
@ -179,9 +182,6 @@ class TIADebug : public DebuggerSystem
/** Display a color patch for color at given index in the palette */ /** Display a color patch for color at given index in the palette */
string colorSwatch(uInt8 c) const; string colorSwatch(uInt8 c) const;
/** Get specific bits in the collision register (used by collXX_XX) */
bool collision(CollisionBit id) const;
string audFreq(uInt8 div); string audFreq(uInt8 div);
string booleanWithLabel(string label, bool value); string booleanWithLabel(string label, bool value);

View File

@ -129,10 +129,9 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
for(uInt32 col = 0; col < 5 - row; ++col) for(uInt32 col = 0; col < 5 - row; ++col)
{ {
myCollision[idx] = new CheckboxWidget(boss, lfont, collX, collY, ""); myCollision[idx] = new CheckboxWidget(boss, lfont, collX, collY, "", CheckboxWidget::kCheckActionCmd);
myCollision[idx]->setTarget(this); myCollision[idx]->setTarget(this);
myCollision[idx]->setID(idx); myCollision[idx]->setID(idx);
myCollision[idx]->setEditable(false); // TODO - enable this?
// We need to know where the PF_BL register is, to properly position // We need to know where the PF_BL register is, to properly position
// the CXCLR button // the CXCLR button
@ -827,6 +826,64 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case CheckboxWidget::kCheckActionCmd: case CheckboxWidget::kCheckActionCmd:
switch(id) switch(id)
{ {
case kP0_PFID:
tia.collision(Cx_P0PF, true);
break;
case kP0_BLID:
tia.collision(Cx_P0BL, true);
break;
case kP0_M1ID:
tia.collision(Cx_M1P0, true);
break;
case kP0_M0ID:
tia.collision(Cx_M0P0, true);
break;
case kP0_P1ID:
tia.collision(Cx_P0P1, true);
break;
case kP1_PFID:
tia.collision(Cx_P1PF, true);
break;
case kP1_BLID:
tia.collision(Cx_P1BL, true);
break;
case kP1_M1ID:
tia.collision(Cx_M1P1, true);
break;
case kP1_M0ID:
tia.collision(Cx_M0P1, true);
break;
case kM0_PFID:
tia.collision(Cx_M0PF, true);
break;
case kM0_BLID:
tia.collision(Cx_M0BL, true);
break;
case kM0_M1ID:
tia.collision(Cx_M0M1, true);
break;
case kM1_PFID:
tia.collision(Cx_M1PF, true);
break;
case kM1_BLID:
tia.collision(Cx_M1BL, true);
break;
case kBL_PFID:
tia.collision(Cx_BLPF, true);
break;
case kRefP0ID: case kRefP0ID:
tia.refP0(myRefP0->getState() ? 1 : 0); tia.refP0(myRefP0->getState() ? 1 : 0);
break; break;

View File

@ -136,6 +136,7 @@ class TiaWidget : public Widget, public CommandSender
kResBLCmd = 'Srbl', kResBLCmd = 'Srbl',
kHmoveCmd = 'Shmv', kHmoveCmd = 'Shmv',
kHmclrCmd = 'Shmc', kHmclrCmd = 'Shmc',
kCxChgCmd = 'Sccc',
kCxclrCmd = 'Scxl', kCxclrCmd = 'Scxl',
kDbgClCmd = 'DBGc', kDbgClCmd = 'DBGc',
}; };

View File

@ -1618,6 +1618,96 @@ uInt8 TIA::collCXBLPF() const
return (myCollisionMask & CollisionMask::ball & CollisionMask::playfield) ? 0x80 : 0; return (myCollisionMask & CollisionMask::ball & CollisionMask::playfield) ? 0x80 : 0;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP0PF()
{
myCollisionMask ^= (CollisionMask::player0 & CollisionMask::playfield);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP0BL()
{
myCollisionMask ^= (CollisionMask::player0 & CollisionMask::ball);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP0M1()
{
myCollisionMask ^= (CollisionMask::player0 & CollisionMask::missile1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP0M0()
{
myCollisionMask ^= (CollisionMask::player0 & CollisionMask::missile0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP0P1()
{
myCollisionMask ^= (CollisionMask::player0 & CollisionMask::player1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP1PF()
{
myCollisionMask ^= (CollisionMask::player1 & CollisionMask::playfield);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP1BL()
{
myCollisionMask ^= (CollisionMask::player1 & CollisionMask::ball);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP1M1()
{
myCollisionMask ^= (CollisionMask::player1 & CollisionMask::missile1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollP1M0()
{
myCollisionMask ^= (CollisionMask::player1 & CollisionMask::missile0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollM0PF()
{
myCollisionMask ^= (CollisionMask::missile0 & CollisionMask::playfield);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollM0BL()
{
myCollisionMask ^= (CollisionMask::missile0 & CollisionMask::ball);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollM0M1()
{
myCollisionMask ^= (CollisionMask::missile0 & CollisionMask::missile1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollM1PF()
{
myCollisionMask ^= (CollisionMask::missile1 & CollisionMask::playfield);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollM1BL()
{
myCollisionMask ^= (CollisionMask::missile1 & CollisionMask::ball);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::toggleCollBLPF()
{
myCollisionMask ^= (CollisionMask::ball & CollisionMask::playfield);
}
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::createAccessBase() void TIA::createAccessBase()

View File

@ -565,6 +565,25 @@ class TIA : public Device
uInt8 collCXPPMM() const; uInt8 collCXPPMM() const;
uInt8 collCXBLPF() const; uInt8 collCXBLPF() const;
/**
Toggle the specified collision bits
*/
void toggleCollP0PF();
void toggleCollP0BL();
void toggleCollP0M1();
void toggleCollP0M0();
void toggleCollP0P1();
void toggleCollP1PF();
void toggleCollP1BL();
void toggleCollP1M1();
void toggleCollP1M0();
void toggleCollM0PF();
void toggleCollM0BL();
void toggleCollM0M1();
void toggleCollM1PF();
void toggleCollM1BL();
void toggleCollBLPF();
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
void createAccessBase(); void createAccessBase();