mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
byuu says: Changelog: - added Cocoa target: higan can now be compiled for OS X Lion [Cydrak, byuu] - SNES/accuracy profile hires color blending improvements - fixes Marvelous text [AWJ] - fixed a slight bug in SNES/SA-1 VBR support caused by a typo - added support for multi-pass shaders that can load external textures (requires OpenGL 3.2+) - added game library path (used by ananke->Import Game) to Settings->Advanced - system profiles, shaders and cheats database can be stored in "all users" shared folders now (eg /usr/share on Linux) - all configuration files are in BML format now, instead of XML (much easier to read and edit this way) - main window supports drag-and-drop of game folders (but not game files / ZIP archives) - audio buffer clears when entering a modal loop on Windows (prevents audio repetition with DirectSound driver) - a substantial amount of code clean-up (probably the biggest refactoring to date) One highly desired target for this release was to default to the optimal drivers instead of the safest drivers, but because AMD drivers don't seem to like my OpenGL 3.2 driver, I've decided to postpone that. AMD has too big a market share. Hopefully with v093 officially released, we can get some public input on what AMD doesn't like.
80 lines
2.7 KiB
C++
80 lines
2.7 KiB
C++
void PPU::render_objects() {
|
|
if(regs.control.enable[OBJ] == false) return;
|
|
for(unsigned n = 0; n < 128; n++) render_object(object[n]);
|
|
}
|
|
|
|
//px,py = pixel coordinates within sprite [0,0 - width,height)
|
|
//fx,fy = affine pixel coordinates
|
|
//pa,pb,pc,pd = affine pixel adjustments
|
|
//x,y = adjusted coordinates within sprite (linear = vflip/hflip, affine = rotation/zoom)
|
|
void PPU::render_object(Object& obj) {
|
|
uint8 py = regs.vcounter - obj.y;
|
|
if(obj.affine == 0 && obj.affinesize == 1) return; //hidden
|
|
if(py >= obj.height << obj.affinesize) return; //offscreen
|
|
|
|
auto& output = layer[OBJ];
|
|
unsigned rowsize = regs.control.objmapping == 0 ? 32 >> obj.colors : obj.width / 8;
|
|
unsigned baseaddr = obj.character * 32;
|
|
|
|
if(obj.mosaic && regs.mosaic.objvsize) {
|
|
signed mosaicy = (regs.vcounter / (1 + regs.mosaic.objvsize)) * (1 + regs.mosaic.objvsize);
|
|
py = obj.y >= 160 || mosaicy - obj.y >= 0 ? mosaicy - obj.y : 0;
|
|
}
|
|
|
|
int16 pa = objectparam[obj.affineparam].pa;
|
|
int16 pb = objectparam[obj.affineparam].pb;
|
|
int16 pc = objectparam[obj.affineparam].pc;
|
|
int16 pd = objectparam[obj.affineparam].pd;
|
|
|
|
//center-of-sprite coordinates
|
|
int16 centerx = obj.width / 2;
|
|
int16 centery = obj.height / 2;
|
|
|
|
//origin coordinates (top-left of sprite)
|
|
int28 originx = -(centerx << obj.affinesize);
|
|
int28 originy = -(centery << obj.affinesize) + py;
|
|
|
|
//fractional pixel coordinates
|
|
int28 fx = originx * pa + originy * pb;
|
|
int28 fy = originx * pc + originy * pd;
|
|
|
|
for(unsigned px = 0; px < (obj.width << obj.affinesize); px++) {
|
|
unsigned x, y;
|
|
if(obj.affine == 0) {
|
|
x = px;
|
|
y = py;
|
|
if(obj.hflip) x ^= obj.width - 1;
|
|
if(obj.vflip) y ^= obj.height - 1;
|
|
} else {
|
|
x = (fx >> 8) + centerx;
|
|
y = (fy >> 8) + centery;
|
|
}
|
|
|
|
uint9 ox = obj.x + px;
|
|
if(ox < 240 && x < obj.width && y < obj.height) {
|
|
unsigned offset = (y / 8) * rowsize + (x / 8);
|
|
offset = offset * 64 + (y & 7) * 8 + (x & 7);
|
|
|
|
uint8 color = object_vram_read(baseaddr + (offset >> !obj.colors));
|
|
if(obj.colors == 0) color = (x & 1) ? color >> 4 : color & 15;
|
|
if(color) {
|
|
if(obj.mode & 2) {
|
|
windowmask[Obj][ox] = true;
|
|
} else if(output[ox].enable == false || obj.priority < output[ox].priority) {
|
|
if(obj.colors == 0) color = obj.palette * 16 + color;
|
|
output[ox].write(true, obj.priority, pram[256 + color], obj.mode == 1, obj.mosaic);
|
|
}
|
|
}
|
|
}
|
|
|
|
fx += pa;
|
|
fy += pc;
|
|
}
|
|
}
|
|
|
|
uint8 PPU::object_vram_read(unsigned addr) const {
|
|
if(regs.control.bgmode == 3 || regs.control.bgmode == 4 || regs.control.bgmode == 5) {
|
|
if(addr <= 0x3fff) return 0u;
|
|
}
|
|
return vram[0x10000 + (addr & 0x7fff)];
|
|
}
|