BSNESv115+: pull upstream
43e42b2dcaf84c41d09c49745d82f8515e4f7771: simplify SA1 division c0c60c83a84a49d4a2b822a0491cb258a3c5b98a: fix justifier controller
This commit is contained in:
parent
27f6800d45
commit
b0af99a68a
Binary file not shown.
|
@ -90,9 +90,7 @@ auto Justifier::latch(bool data) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Justifier::latch() -> void {
|
auto Justifier::latch() -> void {
|
||||||
/* active value is inverted here ... */
|
if(!active) {
|
||||||
|
|
||||||
if(active != 0) {
|
|
||||||
int nx = platform->inputPoll(port, device, 0 + X);
|
int nx = platform->inputPoll(port, device, 0 + X);
|
||||||
int ny = platform->inputPoll(port, device, 0 + Y);
|
int ny = platform->inputPoll(port, device, 0 + Y);
|
||||||
player1.x = max(-16, min(256 + 16, nx + player1.x));
|
player1.x = max(-16, min(256 + 16, nx + player1.x));
|
||||||
|
@ -100,8 +98,7 @@ auto Justifier::latch() -> void {
|
||||||
bool offscreen = (player1.x < 0 || player1.y < 0 || player1.x >= 256 || player1.y >= (int)ppu.vdisp());
|
bool offscreen = (player1.x < 0 || player1.y < 0 || player1.x >= 256 || player1.y >= (int)ppu.vdisp());
|
||||||
if(!offscreen) ppu.latchCounters(player1.x, player1.y);
|
if(!offscreen) ppu.latchCounters(player1.x, player1.y);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if(active != 1) {
|
|
||||||
int nx = platform->inputPoll(port, device, 4 + X);
|
int nx = platform->inputPoll(port, device, 4 + X);
|
||||||
int ny = platform->inputPoll(port, device, 4 + Y);
|
int ny = platform->inputPoll(port, device, 4 + Y);
|
||||||
player2.x = max(-16, min(256 + 16, nx + player2.x));
|
player2.x = max(-16, min(256 + 16, nx + player2.x));
|
||||||
|
|
|
@ -431,14 +431,17 @@ auto SA1::writeIOSA1(uint address, uint8 data) -> void {
|
||||||
mmio.mr = (uint32)((int16)mmio.ma * (int16)mmio.mb);
|
mmio.mr = (uint32)((int16)mmio.ma * (int16)mmio.mb);
|
||||||
mmio.mb = 0;
|
mmio.mb = 0;
|
||||||
} else {
|
} else {
|
||||||
//unsigned division
|
//signed division
|
||||||
if(mmio.mb == 0) {
|
if(mmio.mb == 0) {
|
||||||
mmio.mr = 0;
|
mmio.mr = 0;
|
||||||
} else {
|
} else {
|
||||||
int16 dividend = mmio.ma;
|
int16 dividend = mmio.ma;
|
||||||
uint16 divisor = mmio.mb;
|
uint16 divisor = mmio.mb;
|
||||||
uint16 remainder = dividend >= 0 ? uint16(dividend % divisor) : uint16((dividend % divisor + divisor) % divisor);
|
//sa1 division rounds toward negative infinity, but C division rounds toward zero
|
||||||
uint16 quotient = (dividend - remainder) / divisor;
|
//adding divisor*65536 ensures it rounds down
|
||||||
|
uint32 dividend_ext = dividend + (uint32)divisor*65536;
|
||||||
|
uint16 remainder = dividend_ext % divisor;
|
||||||
|
uint16 quotient = dividend_ext / divisor - 65536;
|
||||||
mmio.mr = remainder << 16 | quotient;
|
mmio.mr = remainder << 16 | quotient;
|
||||||
}
|
}
|
||||||
mmio.ma = 0;
|
mmio.ma = 0;
|
||||||
|
|
Loading…
Reference in New Issue