2011-09-15 12:41:49 +00:00
|
|
|
void ICD2::lcdScanline() {
|
2014-01-28 10:04:58 +00:00
|
|
|
if(GameBoy::ppu.status.ly > 143) return; //Vblank
|
2012-04-26 10:51:13 +00:00
|
|
|
if((GameBoy::ppu.status.ly & 7) == 0) {
|
2014-01-28 10:04:58 +00:00
|
|
|
write_bank = (write_bank + 1) & 3;
|
|
|
|
write_addr = 0;
|
2011-05-08 13:46:37 +00:00
|
|
|
}
|
2014-01-28 10:04:58 +00:00
|
|
|
}
|
2011-05-08 13:46:37 +00:00
|
|
|
|
2014-01-28 10:04:58 +00:00
|
|
|
void ICD2::lcdOutput(uint2 color) {
|
|
|
|
unsigned y = write_addr / 160;
|
|
|
|
unsigned x = write_addr % 160;
|
|
|
|
unsigned addr = write_bank * 512 + y * 2 + x / 8 * 16;
|
|
|
|
output[addr + 0] = (output[addr + 0] << 1) | (bool)(color & 1);
|
|
|
|
output[addr + 1] = (output[addr + 1] << 1) | (bool)(color & 2);
|
|
|
|
write_addr = (write_addr + 1) % 1280;
|
2011-05-08 13:46:37 +00:00
|
|
|
}
|
|
|
|
|
2011-09-15 12:41:49 +00:00
|
|
|
void ICD2::joypWrite(bool p15, bool p14) {
|
2011-01-08 09:58:41 +00:00
|
|
|
//joypad handling
|
|
|
|
if(p15 == 1 && p14 == 1) {
|
|
|
|
if(joyp15lock == 0 && joyp14lock == 0) {
|
|
|
|
joyp15lock = 1;
|
|
|
|
joyp14lock = 1;
|
|
|
|
joyp_id = (joyp_id + 1) & 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(p15 == 0 && p14 == 1) joyp15lock = 0;
|
|
|
|
if(p15 == 1 && p14 == 0) joyp14lock = 0;
|
|
|
|
|
|
|
|
//packet handling
|
|
|
|
if(p15 == 0 && p14 == 0) { //pulse
|
|
|
|
pulselock = false;
|
|
|
|
packetoffset = 0;
|
|
|
|
bitoffset = 0;
|
|
|
|
strobelock = true;
|
|
|
|
packetlock = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pulselock) return;
|
|
|
|
|
|
|
|
if(p15 == 1 && p14 == 1) {
|
|
|
|
strobelock = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strobelock) {
|
|
|
|
if(p15 == 1 || p14 == 1) { //malformed packet
|
|
|
|
packetlock = false;
|
|
|
|
pulselock = true;
|
|
|
|
bitoffset = 0;
|
|
|
|
packetoffset = 0;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//p15:1, p14:0 = 0
|
|
|
|
//p15:0, p14:1 = 1
|
|
|
|
bool bit = (p15 == 0);
|
|
|
|
strobelock = true;
|
|
|
|
|
|
|
|
if(packetlock) {
|
|
|
|
if(p15 == 1 && p14 == 0) {
|
|
|
|
if((joyp_packet[0] >> 3) == 0x11) {
|
|
|
|
mlt_req = joyp_packet[1] & 3;
|
|
|
|
if(mlt_req == 2) mlt_req = 3;
|
|
|
|
joyp_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(packetsize < 64) packet[packetsize++] = joyp_packet;
|
|
|
|
packetlock = false;
|
|
|
|
pulselock = true;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bitdata = (bit << 7) | (bitdata >> 1);
|
|
|
|
if(++bitoffset < 8) return;
|
|
|
|
|
|
|
|
bitoffset = 0;
|
|
|
|
joyp_packet[packetoffset] = bitdata;
|
|
|
|
if(++packetoffset < 16) return;
|
|
|
|
packetlock = true;
|
|
|
|
}
|
|
|
|
|
Update to v088r08 release.
byuu says:
From this WIP, I'm starting on the impossible task of
a declarative-based GUI, which I'm calling Ethos.
base/ becomes emulator/, and we add emulator/interface.hpp, which is
a base API that all emulation cores must implement in full.
(Right now, it's kind of a hybrid to work with the old GUI and the new
GUI at the same time, of course.)
Unlike the old interfaces, the new base class also provides all general
usability hooks: loading and saving files and states, cheat codes, etc.
The new interface also contains information and vector structs to
describe all possible loading methods, controller bindings, etc; and
gives names for them all.
The actual GUI in fact should not include eg <gba/gba.hpp> anymore.
Should speed up GUI compilation.
So the idea going forward is that ethos will build a list of emulators
right when the application starts up.
Once you've appended an emulator to that list, you're done. No more GUI
changes are needed to support that system.
The GUI will have code to parse the emulator interfaces list, and build
all the requisite GUI options dynamically, declarative style.
Ultimately, once the project is finished, the new GUI should look ~99%
identical to the current GUI. But it'll probably be a whole lot smaller.
2012-04-29 06:29:54 +00:00
|
|
|
uint32_t ICD2::videoColor(unsigned source, uint16_t red, uint16_t green, uint16_t blue) {
|
Update to v088r03 release.
byuu says:
static vector<uint8_t> file::read(const string &filename); replaces:
static bool file::read(const string &filename, uint8_t *&data, unsigned
&size); This allows automatic deletion of the underlying data.
Added vectorstream, which is obviously a vector<uint8_t> wrapper for
a data stream. Plan is for all data accesses inside my emulation cores
to take stream objects, especially MSU1. This lets you feed the core
anything: memorystream, filestream, zipstream, gzipstream, httpstream,
etc. There will still be exceptions for link and serial, those need
actual library files on disk. But those aren't official hardware devices
anyway.
So to help with speed a bit, I'm rethinking the video rendering path.
Previous system:
- core outputs system-native samples (SNES = 19-bit LRGB, NES = 9-bit
emphasis+palette, DMG = 2-bit grayscale, etc.)
- interfaceSystem transforms samples to 30-bit via lookup table inside
the emulation core
- interfaceSystem masks off overscan areas, if enabled
- interfaceUI runs filter to produce new target buffer, if enabled
- interfaceUI transforms 30-bit video to native display depth (24-bit or
30-bit), and applies color-adjustments (gamma, etc) at the same time
New system:
- all cores now generate an internal palette, and call
Interface::videoColor(uint32_t source, uint16_t red, uint16_t green,
uint16_t blue) to get native display color post-adjusted (gamma, etc
applied already.)
- all cores output to uint32_t* buffer now (output video.palette[color]
instead of just color)
- interfaceUI runs filter to produce new target buffer, if enabled
- interfaceUI memcpy()'s buffer to the video card
videoColor() is pretty neat. source is the raw pixel (as per the
old-format, 19-bit SNES, 9-bit NES, etc), and you can create a color
from that if you really want to. Or return that value to get a buffer
just like v088 and below. red, green, blue are 16-bits per channel,
because why the hell not, right? Just lop off all the bits you don't
want. If you have more bits on your display than that, fuck you :P
The last step is extremely difficult to avoid. Video cards can and do
have pitches that differ from the width of the texture. Trying to make
the core account for this would be really awful. And even if we did
that, the emulation routine would need to write directly to a video card
RAM buffer. Some APIs require you to lock the video buffer while
writing, so this would leave the video buffer locked for a long time.
Probably not catastrophic, but still awful. And lastly, if the
emulation core tried writing directly to the display texture, software
filters would no longer be possible (unless you -really- jump through
hooks and divert to a memory buffer when a filter is enabled, but ...
fuck.)
Anyway, the point of all that work was to eliminate an extra video copy,
and the need for a really painful 30-bit to 24-bit conversion (three
shifts, three masks, three array indexes.) So this basically reverts us,
performance-wise, to where we were pre-30 bit support.
[...]
The downside to this is that we're going to need a filter for each
output depth. Since the array type is uint32_t*, and I don't intend to
support higher or lower depths, we really only need 24+30-bit versions
of each filter. Kinda shitty, but oh well.
2012-04-27 12:12:53 +00:00
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
void ICD2::videoRefresh(const uint32_t* data, unsigned pitch, unsigned width, unsigned height) {
|
2011-01-08 09:58:41 +00:00
|
|
|
}
|
|
|
|
|
Update to v088r08 release.
byuu says:
From this WIP, I'm starting on the impossible task of
a declarative-based GUI, which I'm calling Ethos.
base/ becomes emulator/, and we add emulator/interface.hpp, which is
a base API that all emulation cores must implement in full.
(Right now, it's kind of a hybrid to work with the old GUI and the new
GUI at the same time, of course.)
Unlike the old interfaces, the new base class also provides all general
usability hooks: loading and saving files and states, cheat codes, etc.
The new interface also contains information and vector structs to
describe all possible loading methods, controller bindings, etc; and
gives names for them all.
The actual GUI in fact should not include eg <gba/gba.hpp> anymore.
Should speed up GUI compilation.
So the idea going forward is that ethos will build a list of emulators
right when the application starts up.
Once you've appended an emulator to that list, you're done. No more GUI
changes are needed to support that system.
The GUI will have code to parse the emulator interfaces list, and build
all the requisite GUI options dynamically, declarative style.
Ultimately, once the project is finished, the new GUI should look ~99%
identical to the current GUI. But it'll probably be a whole lot smaller.
2012-04-29 06:29:54 +00:00
|
|
|
void ICD2::audioSample(int16_t left, int16_t right) {
|
2011-02-02 10:37:31 +00:00
|
|
|
audio.coprocessor_sample(left, right);
|
2011-01-08 09:58:41 +00:00
|
|
|
}
|
|
|
|
|
Update to v088r08 release.
byuu says:
From this WIP, I'm starting on the impossible task of
a declarative-based GUI, which I'm calling Ethos.
base/ becomes emulator/, and we add emulator/interface.hpp, which is
a base API that all emulation cores must implement in full.
(Right now, it's kind of a hybrid to work with the old GUI and the new
GUI at the same time, of course.)
Unlike the old interfaces, the new base class also provides all general
usability hooks: loading and saving files and states, cheat codes, etc.
The new interface also contains information and vector structs to
describe all possible loading methods, controller bindings, etc; and
gives names for them all.
The actual GUI in fact should not include eg <gba/gba.hpp> anymore.
Should speed up GUI compilation.
So the idea going forward is that ethos will build a list of emulators
right when the application starts up.
Once you've appended an emulator to that list, you're done. No more GUI
changes are needed to support that system.
The GUI will have code to parse the emulator interfaces list, and build
all the requisite GUI options dynamically, declarative style.
Ultimately, once the project is finished, the new GUI should look ~99%
identical to the current GUI. But it'll probably be a whole lot smaller.
2012-04-29 06:29:54 +00:00
|
|
|
int16_t ICD2::inputPoll(unsigned port, unsigned device, unsigned id) {
|
2012-04-26 10:51:13 +00:00
|
|
|
GameBoy::cpu.status.mlt_req = joyp_id & mlt_req;
|
2011-01-08 09:58:41 +00:00
|
|
|
|
|
|
|
unsigned data = 0x00;
|
|
|
|
switch(joyp_id & mlt_req) {
|
2012-05-06 06:34:46 +00:00
|
|
|
case 0: data = ~r6004; break;
|
|
|
|
case 1: data = ~r6005; break;
|
|
|
|
case 2: data = ~r6006; break;
|
|
|
|
case 3: data = ~r6007; break;
|
2011-01-08 09:58:41 +00:00
|
|
|
}
|
|
|
|
|
2012-04-26 10:51:13 +00:00
|
|
|
switch((GameBoy::Input)id) {
|
2012-05-06 06:34:46 +00:00
|
|
|
case GameBoy::Input::Start: return (bool)(data & 0x80);
|
|
|
|
case GameBoy::Input::Select: return (bool)(data & 0x40);
|
|
|
|
case GameBoy::Input::B: return (bool)(data & 0x20);
|
|
|
|
case GameBoy::Input::A: return (bool)(data & 0x10);
|
|
|
|
case GameBoy::Input::Down: return (bool)(data & 0x08);
|
|
|
|
case GameBoy::Input::Up: return (bool)(data & 0x04);
|
|
|
|
case GameBoy::Input::Left: return (bool)(data & 0x02);
|
|
|
|
case GameBoy::Input::Right: return (bool)(data & 0x01);
|
2011-01-08 09:58:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|