Did not mean to revert these.
This commit is contained in:
parent
99294e7c19
commit
af294074aa
1 changed files with 14 additions and 8 deletions
12
src/Cpu.php
12
src/Cpu.php
|
@ -28,11 +28,11 @@ class Cpu {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function popU8(): int {
|
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 {
|
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 {
|
public function popU16(): int {
|
||||||
|
@ -64,13 +64,19 @@ class Cpu {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pc = $this->state->pc;
|
||||||
|
|
||||||
|
if($irq === CpuInterruptRequest::Break) {
|
||||||
|
$vector = self::IV_IRQ;
|
||||||
|
++$pc;
|
||||||
|
} else
|
||||||
$vector = match($irq) {
|
$vector = match($irq) {
|
||||||
CpuInterruptRequest::Maskable => self::IV_IRQ,
|
CpuInterruptRequest::Maskable => self::IV_IRQ,
|
||||||
CpuInterruptRequest::NonMaskable => self::IV_NMI,
|
CpuInterruptRequest::NonMaskable => self::IV_NMI,
|
||||||
default => throw new RuntimeException('unexpected irq value')
|
default => throw new RuntimeException('unexpected irq value')
|
||||||
};
|
};
|
||||||
|
|
||||||
$this->pushU16($this->state->pc);
|
$this->pushU16($pc);
|
||||||
$this->pushU8($this->state->p);
|
$this->pushU8($this->state->p);
|
||||||
$this->state->pc = $this->readIoU16($vector);
|
$this->state->pc = $this->readIoU16($vector);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue