bsnes/higan/pce/vdc/sprite.cpp

103 lines
2.8 KiB
C++
Raw Normal View History

auto VDC::Sprite::scanline(uint y) -> void {
y += 64;
objects.reset();
static const uint widths[] = {15, 31};
static const uint heights[] = {15, 31, 63, 63};
uint count = 0;
for(uint index : range(64)) {
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
uint16 d0 = vdc->satb.read(index << 2 | 0);
uint16 d1 = vdc->satb.read(index << 2 | 1);
uint16 d2 = vdc->satb.read(index << 2 | 2);
uint16 d3 = vdc->satb.read(index << 2 | 3);
Object object;
object.y = d0.bits(0,9);
object.height = heights[d3.bits(12,13)];
if(y < object.y) continue;
if(y > object.y + object.height) continue;
object.x = d1.bits(0,9);
object.mode = d2.bit(0);
object.pattern = d2.bits(1,10);
object.palette = d3.bits(0,3);
object.priority = d3.bit(7);
object.width = widths[d3.bit(8)];
object.hflip = d3.bit(11);
object.vflip = d3.bit(15);
object.first = index == 0;
if(object.width == 31) object.pattern.bit(0) = 0;
if(object.height == 31) object.pattern.bit(1) = 0;
if(object.height == 63) object.pattern.bits(1,2) = 0;
if(object.width == 15) {
objects.append(object);
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
if(++count >= 16) return vdc->irq.raise(VDC::IRQ::Line::Overflow);
} else {
//32-width sprites count as two 16-width sprite slots
object.pattern ^= object.hflip;
object.width = 15;
objects.append(object);
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
if(++count >= 16) return vdc->irq.raise(VDC::IRQ::Line::Overflow);
object.x += 16;
object.pattern ^= 1;
objects.append(object);
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
if(++count >= 16) return vdc->irq.raise(VDC::IRQ::Line::Overflow);
}
}
}
auto VDC::Sprite::run(uint x, uint y) -> void {
x += 32;
y += 64;
Update to v102 release. byuu says (in the public announcement): This release adds very preliminary emulation of the Sega Master System (Mark III), Sega Game Gear, Sega Mega Drive (Genesis), and NEC PC Engine (Turbografx-16). These cores do not yet offer sound emulation, save states or cheat codes. I'm always very hesitant to release a new emulation core in its alpha stages, as in the past this has resulted in lasting bad impressions of cores that have since improved greatly. For instance, the Game Boy Advance emulation offered today is easily the second most accurate around, yet it is still widely judged by its much older alpha implementation. However, it's always been tradition with higan to not hold onto code in secret. Rather than delay future releases for another year or two, I'll put my faith in you all to understand that the emulation of these systems will improve over time. I hope that by releasing things as they are now, I might be able to receive some much needed assistance in improving these cores, as the documentation for these new systems is very much less than ideal. byuu says (in the WIP forum): Changelog: - PCE: latch background scroll registers (fixes Neutopia scrolling) - PCE: clip background attribute table scrolling (fixes Blazing Lazers scrolling) - PCE: support background/sprite enable/disable bits - PCE: fix large sprite indexing (fixes Blazing Lazers title screen sprites) - HuC6280: wrap zeropage accesses to never go beyond $20xx - HuC6280: fix alternating addresses for block move instructions (fixes Neutopia II) - HuC6280: block move instructions save and restore A,X,Y registers - HuC6280: emulate BCD mode (may not be 100% correct, based on SNES BCD) (fixes Blazing Lazers scoring)
2017-01-19 21:01:15 +00:00
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
color = 0;
palette = 0;
priority = 0;
Update to v102 release. byuu says (in the public announcement): This release adds very preliminary emulation of the Sega Master System (Mark III), Sega Game Gear, Sega Mega Drive (Genesis), and NEC PC Engine (Turbografx-16). These cores do not yet offer sound emulation, save states or cheat codes. I'm always very hesitant to release a new emulation core in its alpha stages, as in the past this has resulted in lasting bad impressions of cores that have since improved greatly. For instance, the Game Boy Advance emulation offered today is easily the second most accurate around, yet it is still widely judged by its much older alpha implementation. However, it's always been tradition with higan to not hold onto code in secret. Rather than delay future releases for another year or two, I'll put my faith in you all to understand that the emulation of these systems will improve over time. I hope that by releasing things as they are now, I might be able to receive some much needed assistance in improving these cores, as the documentation for these new systems is very much less than ideal. byuu says (in the WIP forum): Changelog: - PCE: latch background scroll registers (fixes Neutopia scrolling) - PCE: clip background attribute table scrolling (fixes Blazing Lazers scrolling) - PCE: support background/sprite enable/disable bits - PCE: fix large sprite indexing (fixes Blazing Lazers title screen sprites) - HuC6280: wrap zeropage accesses to never go beyond $20xx - HuC6280: fix alternating addresses for block move instructions (fixes Neutopia II) - HuC6280: block move instructions save and restore A,X,Y registers - HuC6280: emulate BCD mode (may not be 100% correct, based on SNES BCD) (fixes Blazing Lazers scoring)
2017-01-19 21:01:15 +00:00
if(!enable) return;
bool first = false;
for(auto& object : objects) {
if(x < object.x) continue;
if(x > object.x + object.width) continue;
uint10 hoffset = x - object.x;
uint10 voffset = y - object.y;
if(object.hflip) hoffset ^= object.width;
if(object.vflip) voffset ^= object.height;
uint16 patternAddress = object.pattern;
Update to v102 release. byuu says (in the public announcement): This release adds very preliminary emulation of the Sega Master System (Mark III), Sega Game Gear, Sega Mega Drive (Genesis), and NEC PC Engine (Turbografx-16). These cores do not yet offer sound emulation, save states or cheat codes. I'm always very hesitant to release a new emulation core in its alpha stages, as in the past this has resulted in lasting bad impressions of cores that have since improved greatly. For instance, the Game Boy Advance emulation offered today is easily the second most accurate around, yet it is still widely judged by its much older alpha implementation. However, it's always been tradition with higan to not hold onto code in secret. Rather than delay future releases for another year or two, I'll put my faith in you all to understand that the emulation of these systems will improve over time. I hope that by releasing things as they are now, I might be able to receive some much needed assistance in improving these cores, as the documentation for these new systems is very much less than ideal. byuu says (in the WIP forum): Changelog: - PCE: latch background scroll registers (fixes Neutopia scrolling) - PCE: clip background attribute table scrolling (fixes Blazing Lazers scrolling) - PCE: support background/sprite enable/disable bits - PCE: fix large sprite indexing (fixes Blazing Lazers title screen sprites) - HuC6280: wrap zeropage accesses to never go beyond $20xx - HuC6280: fix alternating addresses for block move instructions (fixes Neutopia II) - HuC6280: block move instructions save and restore A,X,Y registers - HuC6280: emulate BCD mode (may not be 100% correct, based on SNES BCD) (fixes Blazing Lazers scoring)
2017-01-19 21:01:15 +00:00
patternAddress += (voffset >> 4) << 1;
patternAddress += (hoffset >> 4);
patternAddress <<= 6;
patternAddress += (voffset & 15);
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
uint16 d0 = vdc->vram.read(patternAddress + 0);
uint16 d1 = vdc->vram.read(patternAddress + 16);
uint16 d2 = vdc->vram.read(patternAddress + 32);
uint16 d3 = vdc->vram.read(patternAddress + 48);
uint4 index = 15 - (hoffset & 15);
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
uint4 color;
color.bit(0) = d0.bit(index);
color.bit(1) = d1.bit(index);
color.bit(2) = d2.bit(index);
color.bit(3) = d3.bit(index);
if(color == 0) continue;
if(this->color) {
if(first) return vdc->irq.raise(VDC::IRQ::Line::Collision);
return;
}
Update to v102r03 release. byuu says: Changelog: - PCE: split VCE from VDC - HuC6280: changed bus from (uint21 addr) to (uint8 bank, uint13 addr) - added SuperGrafx emulation (adds secondary VDC, plus new VPC) The VDC now has no concept of the actual display raster timing, and instead is driven by Vpulse (start of frame) and Hpulse (start of scanline) signals from the VCE. One still can't render the start of the next scanline onto the current scanline through overly aggressive timings, but it shouldn't be too much more difficult to allow that to occur now. This process incurs quite a major speed hit, so low-end systems with Atom CPUs can't run things at 60fps anymore. The timing needs a lot of work. The pixels end up very jagged if the VCE doesn't output batches of 2-4 pixels at a time. But this should not be a requirement at all, so I'm not sure what's going wrong there. Yo, Bro and the 512-width mode of TV Sports Basketball is now broken as a result of these changes, and I'm not sure why. To load SuperGrafx games, you're going to have to change the .pce extensions to .sg or .sgx. Or you can manually move the games from the PC Engine folder to the SuperGrafx folder and change the game folder extensions. I have no way to tell the games apart. Mednafen uses CRC32 comparisons, and I may consider that since there's only five games, but I'm not sure yet. The only SuperGrafx game that's playable right now is Aldynes. And the priorities are all screwed up. I don't understand how the windows or the priorities work at all from sgxtech.txt, so ... yeah. It's pretty broken, but it's a start. I could really use some help with this, as I'm very lost right now with rendering :/ ----- Note that the SuperGrafx is technically its own system, it's not an add-on. As such, I'm giving it a separate .sys folder, and a separate library. There's debate over how to name this thing. "SuperGrafx" appears more popular than "Super Grafx". And you might also call it the "PC Engine SuperGrafx", but I decided to leave off the prefix so it appears more distinct.
2017-01-23 21:18:54 +00:00
this->color = color;
this->palette = object.palette;
this->priority = object.priority;
if(object.first) first = true;
}
}