2015-11-16 08:38:05 +00:00
|
|
|
auto PPU::vram_read(uint mode, uint32 addr) -> uint32 {
|
2012-04-09 06:41:27 +00:00
|
|
|
addr &= (addr & 0x10000) ? 0x17fff : 0x0ffff;
|
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) {
|
2012-04-09 06:41:27 +00:00
|
|
|
addr &= ~3;
|
|
|
|
return vram[addr + 0] << 0 | vram[addr + 1] << 8 | vram[addr + 2] << 16 | vram[addr + 3] << 24;
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Half) {
|
2012-04-09 06:41:27 +00:00
|
|
|
addr &= ~1;
|
|
|
|
return vram[addr + 0] << 0 | vram[addr + 1] << 8;
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Byte) {
|
2012-04-09 06:41:27 +00:00
|
|
|
return vram[addr];
|
|
|
|
}
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
|
|
|
|
return 0; //should never occur
|
2012-04-09 06:41:27 +00:00
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto PPU::vram_write(uint mode, uint32 addr, uint32 word) -> void {
|
2012-04-09 06:41:27 +00:00
|
|
|
addr &= (addr & 0x10000) ? 0x17fff : 0x0ffff;
|
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) {
|
2012-04-09 06:41:27 +00:00
|
|
|
addr &= ~3;
|
|
|
|
vram[addr + 0] = word >> 0;
|
|
|
|
vram[addr + 1] = word >> 8;
|
|
|
|
vram[addr + 2] = word >> 16;
|
|
|
|
vram[addr + 3] = word >> 24;
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Half) {
|
2012-04-09 06:41:27 +00:00
|
|
|
addr &= ~1;
|
|
|
|
vram[addr + 0] = word >> 0;
|
|
|
|
vram[addr + 1] = word >> 8;
|
2015-07-01 10:58:42 +00:00
|
|
|
} else if(mode & Byte) {
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
//8-bit writes to OBJ section of VRAM are ignored
|
|
|
|
if(regs.control.bgmode <= 2 && addr >= 0x10000) return;
|
|
|
|
if(regs.control.bgmode <= 5 && addr >= 0x14000) return;
|
|
|
|
|
2012-04-09 06:41:27 +00:00
|
|
|
addr &= ~1;
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
vram[addr + 0] = (uint8)word;
|
|
|
|
vram[addr + 1] = (uint8)word;
|
2012-04-09 06:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto PPU::pram_read(uint mode, uint32 addr) -> uint32 {
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) return pram_read(Half, addr & ~2) << 0 | pram_read(Half, addr | 2) << 16;
|
|
|
|
if(mode & Byte) return pram_read(Half, addr) >> ((addr & 1) * 8);
|
2012-04-09 06:41:27 +00:00
|
|
|
return pram[addr >> 1 & 511];
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto PPU::pram_write(uint mode, uint32 addr, uint32 word) -> void {
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) {
|
|
|
|
pram_write(Half, addr & ~2, word >> 0);
|
|
|
|
pram_write(Half, addr | 2, word >> 16);
|
2012-04-09 06:41:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Byte) {
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
word = (uint8)word;
|
2015-07-01 10:58:42 +00:00
|
|
|
return pram_write(Half, addr, word << 8 | word << 0);
|
2012-04-09 06:41:27 +00:00
|
|
|
}
|
|
|
|
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
pram[addr >> 1 & 511] = (uint16)word;
|
2012-04-09 06:41:27 +00:00
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto PPU::oam_read(uint mode, uint32 addr) -> uint32 {
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) return oam_read(Half, addr & ~2) << 0 | oam_read(Half, addr | 2) << 16;
|
|
|
|
if(mode & Byte) return oam_read(Half, addr) >> ((addr & 1) * 8);
|
2012-04-09 06:41:27 +00:00
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
auto& obj = object[addr >> 3 & 127];
|
|
|
|
auto& par = objectparam[addr >> 5 & 31];
|
2012-04-09 06:41:27 +00:00
|
|
|
|
|
|
|
switch(addr & 6) {
|
|
|
|
|
|
|
|
case 0: return (
|
|
|
|
(obj.y << 0)
|
|
|
|
| (obj.affine << 8)
|
|
|
|
| (obj.affinesize << 9)
|
|
|
|
| (obj.mode << 10)
|
|
|
|
| (obj.mosaic << 12)
|
|
|
|
| (obj.colors << 13)
|
|
|
|
| (obj.shape << 14)
|
|
|
|
);
|
|
|
|
|
|
|
|
case 2: return (
|
|
|
|
(obj.x << 0)
|
|
|
|
| (obj.affineparam << 9)
|
|
|
|
| (obj.hflip << 12)
|
|
|
|
| (obj.vflip << 13)
|
|
|
|
| (obj.size << 14)
|
|
|
|
);
|
|
|
|
|
|
|
|
case 4: return (
|
|
|
|
(obj.character << 0)
|
|
|
|
| (obj.priority << 10)
|
|
|
|
| (obj.palette << 12)
|
|
|
|
);
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
switch(addr >> 3 & 3) {
|
|
|
|
case 0: return par.pa;
|
|
|
|
case 1: return par.pb;
|
|
|
|
case 2: return par.pc;
|
|
|
|
case 3: return par.pd;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto PPU::oam_write(uint mode, uint32 addr, uint32 word) -> void {
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) {
|
|
|
|
oam_write(Half, addr & ~2, word >> 0);
|
|
|
|
oam_write(Half, addr | 2, word >> 16);
|
2012-04-09 06:41:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
if(mode & Byte) return; //8-bit writes to OAM are ignored
|
2012-04-09 06:41:27 +00:00
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
auto& obj = object[addr >> 3 & 127];
|
|
|
|
auto& par = objectparam[addr >> 5 & 31];
|
2012-04-09 06:41:27 +00:00
|
|
|
switch(addr & 6) {
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
obj.y = word >> 0;
|
|
|
|
obj.affine = word >> 8;
|
|
|
|
obj.affinesize = word >> 9;
|
|
|
|
obj.mode = word >> 10;
|
|
|
|
obj.mosaic = word >> 12;
|
|
|
|
obj.colors = word >> 13;
|
|
|
|
obj.shape = word >> 14;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
obj.x = word >> 0;
|
|
|
|
obj.affineparam = word >> 9;
|
|
|
|
obj.hflip = word >> 12;
|
|
|
|
obj.vflip = word >> 13;
|
|
|
|
obj.size = word >> 14;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
obj.character = word >> 0;
|
|
|
|
obj.priority = word >> 10;
|
|
|
|
obj.palette = word >> 12;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
switch(addr >> 3 & 3) {
|
|
|
|
case 0: par.pa = word; break;
|
|
|
|
case 1: par.pb = word; break;
|
|
|
|
case 2: par.pc = word; break;
|
|
|
|
case 3: par.pd = word; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
static uint widths[] = {
|
2012-04-09 06:41:27 +00:00
|
|
|
8, 16, 32, 64,
|
|
|
|
16, 32, 32, 64,
|
|
|
|
8, 8, 16, 32,
|
|
|
|
8, 8, 8, 8, //invalid modes
|
|
|
|
};
|
|
|
|
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
static uint heights[] = {
|
2012-04-09 06:41:27 +00:00
|
|
|
8, 16, 32, 64,
|
|
|
|
8, 8, 16, 32,
|
|
|
|
16, 32, 32, 64,
|
|
|
|
8, 8, 8, 8, //invalid modes
|
|
|
|
};
|
|
|
|
|
|
|
|
obj.width = widths [obj.shape * 4 + obj.size];
|
|
|
|
obj.height = heights[obj.shape * 4 + obj.size];
|
|
|
|
}
|