Skip to content

Commit

Permalink
fix RSP semaphore register
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillonb committed Jun 12, 2022
1 parent dcc97e8 commit a8f6884
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/cpu/rsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ rsp_t n64rsp;

bool rsp_acquire_semaphore() {
if (N64RSP.semaphore_held) {
return false; // Semaphore is already held
return true; // Semaphore is already held
} else {
N64RSP.semaphore_held = true;
return true; // Acquired semaphore.
return false; // Acquired semaphore.
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/cpu/rsp_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ word read_word_spreg(word address) {
case ADDR_SP_DMA_BUSY_REG:
return 0; // DMA not busy, since it's instant.
case ADDR_SP_SEMAPHORE_REG:
return N64RSP.semaphore_held;
return rsp_acquire_semaphore();
default:
logfatal("Reading word from unknown/unsupported address 0x%08X in region: REGION_SP_REGS", address);
}
Expand Down Expand Up @@ -119,11 +119,7 @@ void write_word_spreg(word address, word value) {
case ADDR_SP_DMA_BUSY_REG:
logfatal("Write to unsupported SP reg: ADDR_SP_DMA_BUSY_REG");
case ADDR_SP_SEMAPHORE_REG:
if (value == 0) {
rsp_release_semaphore();
} else {
logfatal("Wrote non-zero value 0x%08X to SP reg ADDR_SP_SEMAPHORE_REG", value);
}
rsp_release_semaphore();
case ADDR_SP_PC_REG:
set_rsp_pc(value);
break;
Expand Down

0 comments on commit a8f6884

Please sign in to comment.