2016-03-02 11:19:33 +00:00
|
|
|
auto CPU::keypadRead() -> uint4 {
|
|
|
|
uint4 data = 0;
|
|
|
|
|
|
|
|
if(r.ypadEnable) {
|
Update to v097r24 release.
byuu says:
Changelog:
- WS: fixed bug when IRQs triggered during a rep string instruction
- WS: added sprite attribute caching (per-scanline); absolutely massive
speed-up
- WS: emulated limit of 32 sprites per scanline
- WS: emulated the extended PPU register bit behavior based on the
DISP_CTRL tile bit-depth setting
- WS: added "Rotate" key binding; can be used to flip the WS display
between horizontal and vertical in real-time
The prefix emulation may not be 100% hardware-accurate, but the edge
cases should be extreme enough to not come up in the WS library. No way
to get the emulation 100% down without intensive hardware testing.
trap15 pointed me at a workflow diagram for it, but that diagram is
impossible without a magic internal stack frame that grows with every
IRQ, and can thus grow infinitely large.
The rotation thing isn't exactly the most friendly set-up, but oh well.
I'll see about adding a default rotation setting to manifests, so that
games like GunPey can start in the correct orientation. After that, if
the LCD orientation icon turns out to be reliable, then I'll start using
that. But if there are cases where it's not reliable, then I'll leave it
to manual button presses.
Speaking of icons, I'll need a set of icons to render on the screen.
Going to put them to the top right on vertical orientation, and on the
bottom left for horizontal orientation. Just outside of the video
output, of course.
Overall, WS is getting pretty far along, but still some major bugs in
various games. I really need sound emulation, though. Nobody's going to
use this at all without that.
2016-03-12 13:27:41 +00:00
|
|
|
data |= system.keypad.y1 << 0;
|
|
|
|
data |= system.keypad.y2 << 1;
|
|
|
|
data |= system.keypad.y3 << 2;
|
|
|
|
data |= system.keypad.y4 << 3;
|
2016-03-02 11:19:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(r.xpadEnable) {
|
Update to v097r24 release.
byuu says:
Changelog:
- WS: fixed bug when IRQs triggered during a rep string instruction
- WS: added sprite attribute caching (per-scanline); absolutely massive
speed-up
- WS: emulated limit of 32 sprites per scanline
- WS: emulated the extended PPU register bit behavior based on the
DISP_CTRL tile bit-depth setting
- WS: added "Rotate" key binding; can be used to flip the WS display
between horizontal and vertical in real-time
The prefix emulation may not be 100% hardware-accurate, but the edge
cases should be extreme enough to not come up in the WS library. No way
to get the emulation 100% down without intensive hardware testing.
trap15 pointed me at a workflow diagram for it, but that diagram is
impossible without a magic internal stack frame that grows with every
IRQ, and can thus grow infinitely large.
The rotation thing isn't exactly the most friendly set-up, but oh well.
I'll see about adding a default rotation setting to manifests, so that
games like GunPey can start in the correct orientation. After that, if
the LCD orientation icon turns out to be reliable, then I'll start using
that. But if there are cases where it's not reliable, then I'll leave it
to manual button presses.
Speaking of icons, I'll need a set of icons to render on the screen.
Going to put them to the top right on vertical orientation, and on the
bottom left for horizontal orientation. Just outside of the video
output, of course.
Overall, WS is getting pretty far along, but still some major bugs in
various games. I really need sound emulation, though. Nobody's going to
use this at all without that.
2016-03-12 13:27:41 +00:00
|
|
|
data |= system.keypad.x1 << 0;
|
|
|
|
data |= system.keypad.x2 << 1;
|
|
|
|
data |= system.keypad.x3 << 2;
|
|
|
|
data |= system.keypad.x4 << 3;
|
2016-03-02 11:19:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(r.buttonEnable) {
|
Update to v097r24 release.
byuu says:
Changelog:
- WS: fixed bug when IRQs triggered during a rep string instruction
- WS: added sprite attribute caching (per-scanline); absolutely massive
speed-up
- WS: emulated limit of 32 sprites per scanline
- WS: emulated the extended PPU register bit behavior based on the
DISP_CTRL tile bit-depth setting
- WS: added "Rotate" key binding; can be used to flip the WS display
between horizontal and vertical in real-time
The prefix emulation may not be 100% hardware-accurate, but the edge
cases should be extreme enough to not come up in the WS library. No way
to get the emulation 100% down without intensive hardware testing.
trap15 pointed me at a workflow diagram for it, but that diagram is
impossible without a magic internal stack frame that grows with every
IRQ, and can thus grow infinitely large.
The rotation thing isn't exactly the most friendly set-up, but oh well.
I'll see about adding a default rotation setting to manifests, so that
games like GunPey can start in the correct orientation. After that, if
the LCD orientation icon turns out to be reliable, then I'll start using
that. But if there are cases where it's not reliable, then I'll leave it
to manual button presses.
Speaking of icons, I'll need a set of icons to render on the screen.
Going to put them to the top right on vertical orientation, and on the
bottom left for horizontal orientation. Just outside of the video
output, of course.
Overall, WS is getting pretty far along, but still some major bugs in
various games. I really need sound emulation, though. Nobody's going to
use this at all without that.
2016-03-12 13:27:41 +00:00
|
|
|
data |= system.keypad.start << 1;
|
|
|
|
data |= system.keypad.a << 2;
|
|
|
|
data |= system.keypad.b << 3;
|
2016-03-02 11:19:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2016-02-04 10:29:08 +00:00
|
|
|
auto CPU::portRead(uint16 addr) -> uint8 {
|
|
|
|
//DMA_SRC
|
2016-02-16 09:27:55 +00:00
|
|
|
if(addr == 0x0040) return r.dmaSource.byte(0);
|
|
|
|
if(addr == 0x0041) return r.dmaSource.byte(1);
|
|
|
|
if(addr == 0x0042) return r.dmaSource.byte(2);
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//DMA_DST
|
2016-02-16 09:27:55 +00:00
|
|
|
if(addr == 0x0044) return r.dmaTarget.byte(0);
|
|
|
|
if(addr == 0x0045) return r.dmaTarget.byte(1);
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//DMA_LEN
|
2016-02-16 09:27:55 +00:00
|
|
|
if(addr == 0x0046) return r.dmaLength.byte(0);
|
|
|
|
if(addr == 0x0047) return r.dmaLength.byte(1);
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//DMA_CTRL
|
2016-03-29 08:44:03 +00:00
|
|
|
if(addr == 0x0048) return r.dmaMode << 0 | r.dmaEnable << 7;
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//WSC_SYSTEM
|
2016-03-29 08:44:03 +00:00
|
|
|
if(addr == 0x0062) return (
|
Update to v104r06 release.
byuu says:
Changelog:
- gba,ws: removed Thread::step() override¹
- processor/m68k: move.b (a7)+ and move.b (a7)- adjust a7 by two, not
by one²
- tomoko: created new initialize(Video,Audio,Input)Driver() functions³
- ruby/audio: split Audio::information into
Audio::available(Devices,Frequencies,Latencies,Channels)³
- ws: added Model::(WonderSwan,WonderSwanColor,SwanCrystal)()
functions for consistency with other cores
¹: this should hopefully fix GBA Pokemon Pinball. Thanks to
SuperMikeMan for pointing out the underlying cause.
²: this fixes A Ressaha de Ikou, Mega Bomberman, and probably more
games.
³: this is the big change: so there was a problem with WASAPI where
you might change your device under the audio settings panel. And your
new device may not support the frequency that your old device used. This
would end up not updating the frequency, and the pitch would be
distorted.
The old Audio::information() couldn't tell you what frequencies,
latencies, or channels were available for all devices simultaneously, so
I had to split them up. The new initializeAudioDriver() function
validates you have a correct driver, or it defaults to none. Then it
validates a correct device name, or it defaults to the first entry in
the list. Then it validates a correct frequency, or defaults to the
first in the list. Then finally it validates a correct latency, or
defaults to the first in the list.
In this way ... we have a clear path now with no API changes required to
select default devices, frequencies, latencies, channel counts: they
need to be the first items in their respective lists.
So, what we need to do now is go through and for every audio driver that
enumerates devices, we need to make sure the default device gets added
to the top of the list. I'm ... not really sure how to do this with most
drivers, so this is definitely going to take some time.
Also, when you change a device, initializeAudioDriver() is called again,
so if it's a bad device, it will disable the audio driver instead of
continuing to send samples at it and hoping that the driver blocked
those API calls when it failed to initialize properly.
Now then ... since it was a decently-sized API change, it's possible
I've broken compilation of the Linux drivers, so please report any
compilation errors so that I can fix them.
2017-08-26 01:15:49 +00:00
|
|
|
Model::SwanCrystal() << 7
|
2016-03-29 08:44:03 +00:00
|
|
|
);
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//HW_FLAGS
|
|
|
|
if(addr == 0x00a0) {
|
2018-04-25 09:34:43 +00:00
|
|
|
bool color = Model::WonderSwanColor() || Model::SwanCrystal();
|
2016-02-04 21:18:06 +00:00
|
|
|
return (
|
2016-03-29 09:15:01 +00:00
|
|
|
1 << 0 //0 = BIOS mapped; 1 = cartridge mapped
|
2018-04-25 09:34:43 +00:00
|
|
|
| color << 1 //0 = WonderSwan or Pocket Challenge V2; 1 = WonderSwan Color or SwanCrystal
|
2016-03-29 09:15:01 +00:00
|
|
|
| 1 << 2 //0 = 8-bit bus width; 1 = 16-bit bus width
|
|
|
|
| 1 << 7 //1 = built-in self-test passed
|
2016-02-04 21:18:06 +00:00
|
|
|
);
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//INT_BASE
|
2016-03-29 09:15:01 +00:00
|
|
|
if(addr == 0x00b0) return (
|
2018-04-25 09:34:43 +00:00
|
|
|
r.interruptBase | (Model::WonderSwan() || Model::PocketChallengeV2() ? 3 : 0)
|
2016-03-29 09:15:01 +00:00
|
|
|
);
|
2016-02-04 21:18:06 +00:00
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
//SER_DATA
|
|
|
|
if(addr == 0x00b1) return r.serialData;
|
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//INT_ENABLE
|
|
|
|
if(addr == 0x00b2) return r.interruptEnable;
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
//SER_STATUS
|
|
|
|
if(addr == 0x00b3) return (
|
|
|
|
1 << 2 //hack: always report send buffer as empty
|
|
|
|
| r.serialBaudRate << 6
|
|
|
|
| r.serialEnable << 7
|
|
|
|
);
|
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//INT_STATUS
|
|
|
|
if(addr == 0x00b4) return r.interruptStatus;
|
|
|
|
|
2016-03-02 11:19:33 +00:00
|
|
|
//KEYPAD
|
|
|
|
if(addr == 0x00b5) return (
|
|
|
|
keypadRead() << 0
|
|
|
|
| r.ypadEnable << 4
|
|
|
|
| r.xpadEnable << 5
|
|
|
|
| r.buttonEnable << 6
|
|
|
|
);
|
|
|
|
|
2016-02-04 10:29:08 +00:00
|
|
|
return 0x00;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto CPU::portWrite(uint16 addr, uint8 data) -> void {
|
|
|
|
//DMA_SRC
|
2016-03-29 09:15:01 +00:00
|
|
|
if(addr == 0x0040) r.dmaSource.byte(0) = data & ~1;
|
|
|
|
if(addr == 0x0041) r.dmaSource.byte(1) = data;
|
|
|
|
if(addr == 0x0042) r.dmaSource.byte(2) = data;
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//DMA_DST
|
2016-03-29 09:15:01 +00:00
|
|
|
if(addr == 0x0044) r.dmaTarget.byte(0) = data & ~1;
|
|
|
|
if(addr == 0x0045) r.dmaTarget.byte(1) = data;
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//DMA_LEN
|
2016-03-29 09:15:01 +00:00
|
|
|
if(addr == 0x0046) r.dmaLength.byte(0) = data & ~1;
|
|
|
|
if(addr == 0x0047) r.dmaLength.byte(1) = data;
|
2016-02-04 10:29:08 +00:00
|
|
|
|
|
|
|
//DMA_CTRL
|
|
|
|
if(addr == 0x0048) {
|
2016-02-16 09:27:55 +00:00
|
|
|
r.dmaMode = data.bit(0);
|
2016-03-29 09:15:01 +00:00
|
|
|
r.dmaEnable = data.bit(7);
|
2016-02-04 21:18:06 +00:00
|
|
|
if(r.dmaEnable) dmaTransfer();
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//WSC_SYSTEM
|
|
|
|
if(addr == 0x0062) {
|
|
|
|
//todo: d0 = 1 powers off system
|
|
|
|
}
|
|
|
|
|
|
|
|
//HW_FLAGS
|
|
|
|
if(addr == 0x00a0) {
|
|
|
|
//todo: d2 (bus width) bit is writable; but ... it will do very bad things
|
2016-02-04 21:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//INT_BASE
|
|
|
|
if(addr == 0x00b0) {
|
2018-04-25 09:34:43 +00:00
|
|
|
r.interruptBase = Model::WonderSwan() || Model::PocketChallengeV2() ? data & ~7 : data & ~1;
|
2016-02-04 21:18:06 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
//SER_DATA
|
|
|
|
if(addr == 0x00b1) r.serialData = data;
|
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//INT_ENABLE
|
|
|
|
if(addr == 0x00b2) {
|
|
|
|
r.interruptEnable = data;
|
2016-03-29 09:15:01 +00:00
|
|
|
r.interruptStatus &= ~r.interruptEnable;
|
2016-02-04 21:18:06 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
//SER_STATUS
|
|
|
|
if(addr == 0x00b3) {
|
|
|
|
r.serialBaudRate = data.bit(6);
|
|
|
|
r.serialEnable = data.bit(7);
|
|
|
|
}
|
|
|
|
|
2016-03-02 11:19:33 +00:00
|
|
|
//KEYPAD
|
|
|
|
if(addr == 0x00b5) {
|
|
|
|
r.ypadEnable = data.bit(4);
|
|
|
|
r.xpadEnable = data.bit(5);
|
|
|
|
r.buttonEnable = data.bit(6);
|
|
|
|
}
|
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//INT_ACK
|
|
|
|
if(addr == 0x00b6) {
|
2016-03-26 01:56:15 +00:00
|
|
|
//acknowledge only edge-sensitive interrupts
|
|
|
|
r.interruptStatus &= ~(data & 0b11110010);
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
}
|