mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 07:02:27 +01:00
byuu says: Changelog: - importing a game won't show message box on success - importing a game will select the game that was imported in the list - caveat: GTK+ port doesn't seem to be removing focus from item 0 even though the selection is on item 2 - Game Boy audio reduced in volume by 50% - Game Boy Advance audio reduced in volume by 50% - Game Boy internally mixes audio at 2MHz now - Game Boy Advance's Game Boy audio hardware internally mixes audio at 2MHz now - Game Boy Color doesn't sort sprites by X-coordinate - Game Boy Color allows transparency on BGpriority pixels - caveat: this seems to allow sprites to appear on top of windows - Game Boy Color VRAM DMA transfers 16 bytes in 8 clocks (or 16 clocks in double speed mode) - Game Boy Color VRAM DMA masks low 4-bits of source and destination address - Game Boy Color VRAM DMA only allows reads from ROM or RAM - Game Boy Color VRAM DMA only allows writes to VRAM - fixed a bug in dereferencing a nullptr from pObject::find(), should fix crash when pressing enter key on blank windows - fixed Windows RadioItem selection - Game Boy Advance color emulation code added
109 lines
2.3 KiB
C++
109 lines
2.3 KiB
C++
#ifdef APU_CPP
|
|
|
|
bool APU::Square2::dac_enable() {
|
|
return (envelope_volume || envelope_direction);
|
|
}
|
|
|
|
void APU::Square2::run() {
|
|
if(period && --period == 0) {
|
|
period = 2 * (2048 - frequency);
|
|
phase++;
|
|
switch(duty) {
|
|
case 0: duty_output = (phase == 6); break; //______-_
|
|
case 1: duty_output = (phase >= 6); break; //______--
|
|
case 2: duty_output = (phase >= 4); break; //____----
|
|
case 3: duty_output = (phase <= 5); break; //------__
|
|
}
|
|
}
|
|
|
|
uint4 sample = (duty_output ? volume : (uint4)0);
|
|
if(enable == false) sample = 0;
|
|
|
|
output = sample;
|
|
}
|
|
|
|
void APU::Square2::clock_length() {
|
|
if(counter && enable) {
|
|
if(++length == 0) enable = false;
|
|
}
|
|
}
|
|
|
|
void APU::Square2::clock_envelope() {
|
|
if(enable && envelope_frequency && --envelope_period == 0) {
|
|
envelope_period = envelope_frequency;
|
|
if(envelope_direction == 0 && volume > 0) volume--;
|
|
if(envelope_direction == 1 && volume < 15) volume++;
|
|
}
|
|
}
|
|
|
|
void APU::Square2::write(unsigned r, uint8 data) {
|
|
if(r == 1) { //$ff16 NR21
|
|
duty = data >> 6;
|
|
length = (data & 0x3f);
|
|
}
|
|
|
|
if(r == 2) { //$ff17 NR22
|
|
envelope_volume = data >> 4;
|
|
envelope_direction = data & 0x08;
|
|
envelope_frequency = data & 0x07;
|
|
if(dac_enable() == false) enable = false;
|
|
}
|
|
|
|
if(r == 3) { //$ff18 NR23
|
|
frequency = (frequency & 0x0700) | data;
|
|
}
|
|
|
|
if(r == 4) { //$ff19 NR24
|
|
bool initialize = data & 0x80;
|
|
counter = data & 0x40;
|
|
frequency = ((data & 7) << 8) | (frequency & 0x00ff);
|
|
|
|
if(initialize) {
|
|
enable = dac_enable();
|
|
period = 2 * (2048 - frequency);
|
|
envelope_period = envelope_frequency;
|
|
volume = envelope_volume;
|
|
}
|
|
}
|
|
}
|
|
|
|
void APU::Square2::power() {
|
|
enable = 0;
|
|
|
|
duty = 0;
|
|
length = 0;
|
|
envelope_volume = 0;
|
|
envelope_direction = 0;
|
|
envelope_frequency = 0;
|
|
frequency = 0;
|
|
counter = 0;
|
|
|
|
output = 0;
|
|
duty_output = 0;
|
|
phase = 0;
|
|
period = 0;
|
|
envelope_period = 0;
|
|
volume = 0;
|
|
}
|
|
|
|
void APU::Square2::serialize(serializer& s) {
|
|
s.integer(enable);
|
|
|
|
s.integer(duty);
|
|
s.integer(length);
|
|
s.integer(envelope_volume);
|
|
s.integer(envelope_direction);
|
|
s.integer(envelope_frequency);
|
|
s.integer(frequency);
|
|
s.integer(counter);
|
|
|
|
s.integer(output);
|
|
s.integer(duty_output);
|
|
s.integer(phase);
|
|
s.integer(period);
|
|
s.integer(envelope_period);
|
|
s.integer(volume);
|
|
}
|
|
|
|
#endif
|