Did not mean to revert these.

This commit is contained in:
Pachira 2024-12-11 02:28:31 +00:00
parent 99294e7c19
commit af294074aa

View file

@ -28,11 +28,11 @@ class Cpu {
}
public function popU8(): int {
return $this->io->read($this->state->sPage | $this->state->s--);
return $this->io->read($this->state->sPage | $this->state->s++);
}
public function pushU8(int $value): void {
$this->io->write($this->state->sPage | $this->state->s++, $value);
$this->io->write($this->state->sPage | $this->state->s--, $value);
}
public function popU16(): int {
@ -64,13 +64,19 @@ class Cpu {
return;
}
$pc = $this->state->pc;
if($irq === CpuInterruptRequest::Break) {
$vector = self::IV_IRQ;
++$pc;
} else
$vector = match($irq) {
CpuInterruptRequest::Maskable => self::IV_IRQ,
CpuInterruptRequest::NonMaskable => self::IV_NMI,
default => throw new RuntimeException('unexpected irq value')
};
$this->pushU16($this->state->pc);
$this->pushU16($pc);
$this->pushU8($this->state->p);
$this->state->pc = $this->readIoU16($vector);
}