Skip to content

Commit

Permalink
Auto inspection cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jul 7, 2024
1 parent f91d2d0 commit cbddbc0
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 200 deletions.
2 changes: 1 addition & 1 deletion Emulator/Components/Agnus/Agnus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ Agnus::executeUntil(Cycle cycle) {
amiga.serviceAlarmEvent();
}
if (isDue<SLOT_INS>(cycle)) {
agnus.serviceINSEvent(id[SLOT_INS]);
agnus.serviceINSEvent();
}

// Determine the next trigger cycle for all tertiary slots
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Components/Agnus/Agnus.h
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ class Agnus : public SubComponent, public Inspectable<AgnusInfo, AgnusStats> {
void serviceDASEvent(EventID id);

// Services an inspection event
void serviceINSEvent(EventID id);
void serviceINSEvent();
};

}
84 changes: 10 additions & 74 deletions Emulator/Components/Agnus/AgnusEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,90 +760,26 @@ Agnus::serviceDASEvent(EventID id)
}

void
Agnus::serviceINSEvent(EventID id)
Agnus::serviceINSEvent()
{
u64 mask = data[SLOT_INS];

if (mask & 1LL << COMP_AMIGA) amiga.record();
if (mask & 1LL << COMP_CPU) cpu.record();
if (mask & 1LL << COMP_MEM) mem.record();
if (mask & 1LL << COMP_CIA) ciaa.record(); ciab.record();
// Analyze bit mask
if (mask & 1LL << COMP_AGNUS) agnus.record();
if (mask & 1LL << COMP_AMIGA) amiga.record();
if (mask & 1LL << COMP_BLITTER) blitter.record();
if (mask & 1LL << COMP_COPPER) copper.record();
if (mask & 1LL << COMP_CIA) ciaa.record(); ciab.record();
if (mask & 1LL << COMP_CPU) cpu.record();
if (mask & 1LL << COMP_DENISE) denise.record();
if (mask & 1LL << COMP_MEM) mem.record();
if (mask & 1LL << COMP_PAULA) paula.record();
if (mask & 1LL << COMP_UART) uart.record();
if (mask & 1LL << COMP_CONTROL_PORT) controlPort1.record(); controlPort2.record();
if (mask & 1LL << COMP_SERIAL_PORT) serialPort.record();
if (mask & 1LL << COMP_UART) uart.record();

/*
switch (id) {
case INS_AMIGA:
amiga.record();
break;
case INS_CPU:
cpu.record();
break;
case INS_MEM:
break;
case INS_CIA:
ciaa.record();
ciab.record();
break;
case INS_AGNUS:
record();
break;
case INS_BLITTER:
blitter.record();
break;
case INS_COPPER:
copper.record();
break;
case INS_PAULA:
paula.record();
break;
case INS_DENISE:
denise.record();
break;
case INS_PORTS:
serialPort.record();
paula.uart.record();
controlPort1.record();
controlPort2.record();
break;
case INS_EVENTS:
agnus.record();
break;
default:
fatalError;
}
*/

// Reschedule event
rescheduleRel<SLOT_INS>((Cycle)(inspectionInterval * 28000000));
// Reschedule the event
rescheduleRel<SLOT_INS>((Cycle)(inspectionInterval * 28000007));
}

}
12 changes: 1 addition & 11 deletions Emulator/Components/Agnus/AgnusInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,17 +455,7 @@ Agnus::eventName(EventSlot slot, EventID id)
switch (id) {

case EVENT_NONE: return "none";
case INS_AMIGA: return "INS_AMIGA";
case INS_CPU: return "INS_CPU";
case INS_MEM: return "INS_MEM";
case INS_CIA: return "INS_CIA";
case INS_AGNUS: return "INS_AGNUS";
case INS_BLITTER: return "INS_BLITTER";
case INS_COPPER: return "INS_COPPER";
case INS_PAULA: return "INS_PAULA";
case INS_DENISE: return "INS_DENISE";
case INS_PORTS: return "INS_PORTS";
case INS_EVENTS: return "INS_EVENTS";
case INS_RECORD: return "INS_RECORD";
default: return "*** INVALID ***";
}
break;
Expand Down
12 changes: 1 addition & 11 deletions Emulator/Components/Agnus/AgnusTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,17 +393,7 @@ enum_i8(EventID)
ALA_EVENT_COUNT,

// Inspector slot
INS_AMIGA = 1,
INS_CPU,
INS_MEM,
INS_CIA,
INS_AGNUS,
INS_BLITTER,
INS_COPPER,
INS_PAULA,
INS_DENISE,
INS_PORTS,
INS_EVENTS,
INS_RECORD = 1,
INS_EVENT_COUNT
};

Expand Down
59 changes: 2 additions & 57 deletions Emulator/Components/Amiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ Amiga::setAutoInspectionMask(u64 mask)
if (mask) {

agnus.data[SLOT_INS] = mask;
agnus.serviceINSEvent(INS_AMIGA);
agnus.serviceINSEvent();

} else {

Expand All @@ -350,62 +350,7 @@ Amiga::setAutoInspectionMask(u64 mask)
}
}

CType
Amiga::getInspectionTarget() const
{
switch(agnus.id[SLOT_INS]) {

case EVENT_NONE: return COMP_UNKNOWN;
case INS_AMIGA: return COMP_AMIGA;
case INS_CPU: return COMP_CPU;
case INS_MEM: return COMP_MEM;
case INS_CIA: return COMP_CIA;
case INS_AGNUS: return COMP_AGNUS;
case INS_BLITTER: return COMP_BLITTER;
case INS_COPPER: return COMP_COPPER;
case INS_PAULA: return COMP_PAULA;
case INS_DENISE: return COMP_DENISE;
case INS_PORTS: return COMP_CONTROL_PORT;
case INS_EVENTS: return COMP_AGNUS;

default:
fatalError;
}
}

void
Amiga::setInspectionTarget(CType target, Cycle trigger)
{
EventID id;

{ SUSPENDED

switch(target) {

case COMP_UNKNOWN: agnus.cancel<SLOT_INS>(); return;

case COMP_AMIGA: id = INS_AMIGA; break;
case COMP_CPU: id = INS_CPU; break;
case COMP_MEM: id = INS_MEM; break;
case COMP_CIA: id = INS_CIA; break;
case COMP_AGNUS: id = INS_AGNUS; break;
case COMP_BLITTER: id = INS_BLITTER; break;
case COMP_COPPER: id = INS_COPPER; break;
case COMP_PAULA: id = INS_PAULA; break;
case COMP_DENISE: id = INS_DENISE; break;
case COMP_CONTROL_PORT: id = INS_PORTS; break;
// case COMP_EVENTS: id = INS_EVENTS; break;

default:
fatalError;
}

agnus.scheduleRel<SLOT_INS>(trigger, id);
if (trigger == 0) agnus.serviceINSEvent(id);
}
}

double
double
Amiga::nativeRefreshRate() const
{
switch (config.type) {
Expand Down
3 changes: 2 additions & 1 deletion Emulator/Components/Amiga.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,11 @@ class Amiga final : public CoreComponent, public Inspectable<AmigaInfo> {
u64 getAutoInspectionMask() const;
void setAutoInspectionMask(u64 mask);

/*
[[deprecated]] CType getInspectionTarget() const;
[[deprecated]] void setInspectionTarget(CType target, Cycle trigger = 0);
[[deprecated]] void removeInspectionTarget() { setInspectionTarget(0); }

*/

//
// Methods from Configurable
Expand Down
13 changes: 13 additions & 0 deletions Emulator/VAmiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,4 +1053,17 @@ AmigaAPI::loadSnapshot(const Snapshot &snapshot)
amiga->loadSnapshot(snapshot);
}

u64
AmigaAPI::getAutoInspectionMask()
{
return amiga->getAutoInspectionMask();
}

void
AmigaAPI::setAutoInspectionMask(u64 mask)
{
amiga->setAutoInspectionMask(mask);
}


}
26 changes: 26 additions & 0 deletions Emulator/VAmiga.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@ struct AmigaAPI : API {
* @param snapshot Reference to a snapshot.
*/
void loadSnapshot(const Snapshot &snapshot);

/// @}
/// @name Auto-inspecting components
/// @{

/** @brief Gets the current auto-inspection mask
* The GUI utilizes Auto-Inspection to display life updates of the internal
* emulator state in the Inspector panel. As soon as an auto-inspection
* mask is set, the emulator caches the internal states of the inspected
* components at periodic intervals. The inspected components are
* specified as a bit mask.
*
* @return A bit mask indicating the components under inspection
*/
u64 getAutoInspectionMask();

/** @brief Sets the current auto-inspection mask
*
* @example The following call enables auto-inspections for the CIA chips
* and Paula: setAutoInspectionMask(1 << COMP_CIA | 1 << COMP_PAULA);
*
* @param mask A bit mask indicating the components under inspection
*/
void setAutoInspectionMask(u64 mask);

/// @}
};

struct AgnusAPI : API {
Expand Down
8 changes: 2 additions & 6 deletions Proxy/EmulatorProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
@property (readonly) EmulatorInfo cachedInfo;
@property (readonly) EmulatorStats stats;

@property NSInteger autoInspectionMask;

@property (readonly) BOOL poweredOn;
@property (readonly) BOOL poweredOff;
@property (readonly) BOOL paused;
Expand Down Expand Up @@ -255,12 +257,6 @@
- (BOOL)set:(Option)opt drive:(NSInteger)id enable:(BOOL)val;


/*
@property CType inspectionTarget;
- (void) removeInspectionTarget;
*/
@property NSInteger autoInspectionMask;




Expand Down
48 changes: 10 additions & 38 deletions Proxy/EmulatorProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2686,6 +2686,16 @@ - (EmulatorStats)stats
return [self emu]->getStats();
}

- (NSInteger)autoInspectionMask
{
return [self emu]->emu->main.getAutoInspectionMask();
}

- (void)setAutoInspectionMask:(NSInteger)mask
{
[self emu]->emu->main.setAutoInspectionMask(mask);
}

- (BOOL)poweredOn
{
return [self emu]->isPoweredOn();
Expand Down Expand Up @@ -2726,8 +2736,6 @@ - (BOOL)tracking
return [self emu]->isTracking();
}



- (void)setTrackMode:(BOOL)value
{
if (value) {
Expand All @@ -2737,42 +2745,6 @@ - (void)setTrackMode:(BOOL)value
}
}

/*
- (NSInteger)cpuLoad
{
double load = [self emu]->emu->getStats().cpuLoad;
return (NSInteger)(100 * load);
}
*/

/*
- (CType)inspectionTarget
{
return [self emu]->emu->main.getInspectionTarget();
}
- (void)setInspectionTarget:(CType)target
{
[self emu]->emu->main.setInspectionTarget(target);
}
- (void) removeInspectionTarget
{
[self emu]->emu->main.removeInspectionTarget();
}
*/

- (NSInteger)autoInspectionMask
{
return [self emu]->emu->main.getAutoInspectionMask();
}

- (void)setAutoInspectionMask:(NSInteger)mask
{
[self emu]->emu->main.setAutoInspectionMask(mask);
}


- (SnapshotProxy *)takeSnapshot
{
Amiga *amiga = (Amiga *)[self amiga]->obj;
Expand Down

0 comments on commit cbddbc0

Please sign in to comment.