Skip to content

Commit

Permalink
fix broken macro, create flags structure
Browse files Browse the repository at this point in the history
  • Loading branch information
noahw2021 committed Dec 27, 2023
1 parent 7ee8ef7 commit 95cf0cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion plasm2_emu/basetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef unsigned long WORD32;
typedef unsigned short WORD16;
typedef unsigned char BYTE, _bool;

#define InRange(x, min, max) (x > min && x < max)
#define InRange(x, min, max) (x >= min && x <= max)

#define TRUE 1
#define FALSE 0
8 changes: 8 additions & 0 deletions plasm2_emu/cpu/ops/cops_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,18 @@ void POP(void) {
void PSR(void) {
for (int c = 0; c < 16; c++)
MmuPush(ECtx->GPRs[c]);
if (ECtx->Security.SecurityLevel <= 1) {
for (int c = 0; c < 16; c++)
MmuPush(ECtx->SystemRs[c]);
}
return;
}

void POR(void) {
if (ECtx->Security.SecurityLevel <= 1) {
for (int c = 0; c < 16; c++)
ECtx->SystemRs[c] = MmuPop();
}
for (int c = 0; c < 16; c++)
ECtx->GPRs[c] = MmuPop();
return;
Expand Down
20 changes: 11 additions & 9 deletions plasm2_emu/devices/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ WORD64 DevicesiDevCount(void);
#define DEVSTATUS_RSN_INVCMD 0x00010000
#define DEVSTATUS_RSN_CLEAR 0x00FF0000

typedef union _CPU_DEVICE_FLAGS {
WORD32 FlagsRaw;
struct {
WORD32 Active : 1;
WORD32 On : 1;
WORD32 Sleep : 1;
WORD32 Hotswappable : 1;
};
}CPU_DEVICE_FLAGS, *PCPU_DEVICE_FLAGS;

typedef struct _DEVICES_CTX {
WORD64 DeviceCount;
struct {
Expand All @@ -49,15 +59,7 @@ typedef struct _DEVICES_CTX {
WORD64 DeviceModel;
WORD64 DeviceSerial;
WORD64(*Callbacks[7])(WORD32 DeviceId, WORD64 Argument);
union {
WORD32 FlagsRaw;
struct {
BYTE Active : 1;
BYTE On : 1;
BYTE Sleep : 1;
BYTE Hotswappable : 1;
};
}Flags;
CPU_DEVICE_FLAGS Flags;
}*Devices;
}DEVICES_CTX, *PDEVICES_CTX;
extern PDEVICES_CTX DevicesCtx;
Expand Down

0 comments on commit 95cf0cf

Please sign in to comment.