Update to v103r24 release.

byuu says:

Changelog:

  - gb/mbc6: mapper is now functional, but Net de Get has some text
    corruption¹
  - gb/mbc7: mapper is now functional²
  - gb/cpu: HDMA syncs other components after each byte transfer now
  - gb/ppu: LY,LX forced to zero when LCDC.d7 is lowered (eg disabled),
    not when it's raised (eg enabled)
  - gb/ppu: the LCD does not run at all when LCDC.d7 is clear³
      - fixes graphical corruption between scene transitions in Legend
        of Zelda - Oracle of Ages
      - thanks to Cydrak, Shonumi, gekkio for their input on the cause
        of this issue
  - md/controller: renamed "Gamepad" to "Control Pad" per official
    terminology
  - md/controller: added "Fighting Pad" (6-button controller) emulation
    [hex\_usr]
  - processor/m68k: fixed TAS to set data.d7 when
    EA.mode==DataRegisterDirect; fixes Asterix
  - hiro/windows: removed carriage returns from mouse.cpp and
    desktop.cpp
  - ruby/audio/alsa: added device driver selection [SuperMikeMan]
  - ruby/audio/ao: set format.matrix=nullptr to prevent a crash on some
    systems [SuperMikeMan]
  - ruby/video/cgl: rename term() to terminate() to fix a crash on macOS
    [Sintendo]

¹: The observation that this mapper split $4000-7fff into two banks
came from MAME's implementation. But their implementation was quite
broken and incomplete, so I didn't actually use any of it. The
observation that this mapper split $a000-bfff into two banks came from
Tauwasser, and I did directly use that information, plus the knowledge
that $0400/$0800 are the RAM bank select registers.

The text corruption is due to a race condition with timing. The game is
transferring font letters via HDMA, but the game code ends up setting
the bank# with the font a bit too late after the HDMA has already
occurred. I'm not sure how to fix this ... as a whole, I assumed my Game
Boy timing was pretty good, but apparently it's not that good.

²: The entire design of this mapper comes from endrift's notes.
endrift gets full credit for higan being able to emulate this mapper.
Note that the accelerometer implementation is still not tested, and
probably won't work right until I tweak the sensitivity a lot.

³: So the fun part of this is ... it breaks the strict 60fps rate of
the Game Boy. This was always inevitable: certain timing conditions can
stretch frames, too. But this is pretty much an absolute deal breaker
for something like Vsync timing. This pretty much requires adaptive sync
to run well without audio stuttering during the transition.

There's currently one very important detail missing: when the LCD is
turned off, presumably the image on the screen fades to white. I do not
know how long this process takes, or how to really go about emulating
it. Right now as an incomplete patch, I'm simply leaving the last
displayed image on the screen until the LCD is turned on again. But I
will have to output white, as well as add code to break out of the
emulation loop periodically when the LCD is left off eg indefinitely, or
bad things would happen. I'll work something out and then implement.

Another detail is I'm not sure how long it takes for the LCD to start
rendering again once enabled. Right now, it's immediate. I've heard it's
as long as 1/60th of a second, but that really seems incredibly
excessive? I'd like to know at least a reasonably well-supported
estimate before I implement that.
This commit is contained in:
Tim Allen 2017-08-01 21:41:27 +10:00
parent 7022d1aa51
commit 571760c747
27 changed files with 333 additions and 139 deletions

View File

@ -12,7 +12,7 @@ using namespace nall;
namespace Emulator {
static const string Name = "higan";
static const string Version = "103.23";
static const string Version = "103.24";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "http://byuu.org/";

View File

@ -3,18 +3,62 @@ auto Cartridge::MBC6::read(uint16 address) -> uint8 {
return cartridge.rom.read(address.bits(0,13));
}
if((address & 0xc000) == 0x4000) { //$4000-7fff
return cartridge.rom.read(io.rom.bank << 14 | address.bits(0,13));
if((address & 0xe000) == 0x4000) { //$4000-5fff
return cartridge.rom.read(io.rom.bank[0] << 13 | address.bits(0,12));
}
if((address & 0xe000) == 0x6000) { //$6000-7fff
return cartridge.rom.read(io.rom.bank[1] << 13 | address.bits(0,12));
}
if((address & 0xf000) == 0xa000) { //$a000-afff
if(!io.ram.enable) return 0xff;
return cartridge.ram.read(io.ram.bank[0] << 12 | address.bits(0,11));
}
if((address & 0xf000) == 0xb000) { //$b000-bfff
if(!io.ram.enable) return 0xff;
return cartridge.ram.read(io.ram.bank[1] << 12 | address.bits(0,11));
}
return 0xff;
}
auto Cartridge::MBC6::write(uint16 address, uint8 data) -> void {
if((address & 0xf000) == 0x2000) { //$2000-2fff
io.rom.bank = data;
if((address & 0xfc00) == 0x0000) {
io.ram.enable = data.bits(0,3) == 0xa;
return;
}
if((address & 0xfc00) == 0x0400) {
io.ram.bank[0] = data;
return;
}
if((address & 0xfc00) == 0x0800) {
io.ram.bank[1] = data;
return;
}
if((address & 0xf800) == 0x2000) {
io.rom.bank[0] = data;
return;
}
if((address & 0xf800) == 0x3000) {
io.rom.bank[1] = data;
return;
}
if((address & 0xf000) == 0xa000) { //$a000-afff
if(!io.ram.enable) return;
return cartridge.ram.write(io.ram.bank[0] << 12 | address.bits(0,11), data);
}
if((address & 0xf000) == 0xb000) { //$b000-bfff
if(!io.ram.enable) return;
return cartridge.ram.write(io.ram.bank[1] << 12 | address.bits(0,11), data);
}
}
auto Cartridge::MBC6::power() -> void {
@ -22,4 +66,9 @@ auto Cartridge::MBC6::power() -> void {
}
auto Cartridge::MBC6::serialize(serializer& s) -> void {
s.integer(io.rom.bank[0]);
s.integer(io.rom.bank[1]);
s.integer(io.ram.enable);
s.integer(io.ram.bank[0]);
s.integer(io.ram.bank[1]);
}

View File

@ -6,7 +6,11 @@ struct MBC6 : Mapper {
struct IO {
struct ROM {
uint8 bank = 0x01;
uint8 bank[2];
} rom;
struct RAM {
uint1 enable;
uint8 bank[2];
} ram;
} io;
} mbc6;

View File

@ -3,7 +3,7 @@ auto Cartridge::MBC7::read(uint16 address) -> uint8 {
return cartridge.rom.read(address.bits(0,13));
}
if((address & 0xc000) == 0x0000) { //$4000-7fff
if((address & 0xc000) == 0x4000) { //$4000-7fff
return cartridge.rom.read(io.rom.bank << 14 | address.bits(0,13));
}
@ -15,8 +15,8 @@ auto Cartridge::MBC7::read(uint16 address) -> uint8 {
case 3: return io.accelerometer.x.bits(8,15);
case 4: return io.accelerometer.y.bits(0, 7);
case 5: return io.accelerometer.y.bits(8,15);
case 6: return io.accelerometer.z.bits(0, 7);
case 7: return io.accelerometer.z.bits(8,15);
case 6: return 0x00; //z?
case 7: return 0xff; //z?
case 8: return 0xff;
}
@ -78,4 +78,9 @@ auto Cartridge::MBC7::power() -> void {
}
auto Cartridge::MBC7::serialize(serializer& s) -> void {
s.integer(io.rom.bank);
s.integer(io.ram.enable[0]);
s.integer(io.ram.enable[1]);
s.integer(io.accelerometer.x);
s.integer(io.accelerometer.y);
}

View File

@ -14,7 +14,6 @@ struct MBC7 : Mapper {
struct Accelerometer {
uint16 x = 0x8000;
uint16 y = 0x8000;
uint16 z = 0xff00; //unused
} accelerometer;
} io;
} mbc7;

View File

@ -76,8 +76,8 @@ auto CPU::hblank() -> void {
if(status.dmaMode == 1 && status.dmaLength && ppu.status.ly < 144) {
for(auto n : range(16)) {
writeDMA(status.dmaTarget++, readDMA(status.dmaSource++));
status.dmaLength--;
if(n & 1) step(1 << status.speedDouble);
}
step(8 << status.speedDouble);
status.dmaLength -= 16;
}
}

View File

@ -37,7 +37,6 @@ auto PPU::readTileCGB(bool select, uint x, uint y, uint& attr, uint& data) -> vo
auto PPU::scanlineCGB() -> void {
px = 0;
if(!enabled()) return;
const uint Height = (status.obSize == 0 ? 8 : 16);
sprites = 0;
@ -69,24 +68,22 @@ auto PPU::runCGB() -> void {
ob.priority = 0;
uint color = 0x7fff;
if(enabled()) {
runBackgroundCGB();
if(status.windowDisplayEnable) runWindowCGB();
if(status.obEnable) runObjectsCGB();
runBackgroundCGB();
if(status.windowDisplayEnable) runWindowCGB();
if(status.obEnable) runObjectsCGB();
if(ob.palette == 0) {
color = bg.color;
} else if(bg.palette == 0) {
color = ob.color;
} else if(status.bgEnable == 0) {
color = ob.color;
} else if(bg.priority) {
color = bg.color;
} else if(ob.priority) {
color = ob.color;
} else {
color = bg.color;
}
if(ob.palette == 0) {
color = bg.color;
} else if(bg.palette == 0) {
color = ob.color;
} else if(status.bgEnable == 0) {
color = ob.color;
} else if(bg.priority) {
color = bg.color;
} else if(ob.priority) {
color = ob.color;
} else {
color = bg.color;
}
uint32* output = screen + status.ly * 160 + px++;

View File

@ -19,7 +19,6 @@ auto PPU::readTileDMG(bool select, uint x, uint y, uint& data) -> void {
auto PPU::scanlineDMG() -> void {
px = 0;
if(!enabled()) return;
const uint Height = (status.obSize == 0 ? 8 : 16);
sprites = 0;
@ -60,20 +59,18 @@ auto PPU::runDMG() -> void {
ob.palette = 0;
uint color = 0;
if(enabled()) {
if(status.bgEnable) runBackgroundDMG();
if(status.windowDisplayEnable) runWindowDMG();
if(status.obEnable) runObjectsDMG();
if(status.bgEnable) runBackgroundDMG();
if(status.windowDisplayEnable) runWindowDMG();
if(status.obEnable) runObjectsDMG();
if(ob.palette == 0) {
color = bg.color;
} else if(bg.palette == 0) {
color = ob.color;
} else if(ob.priority) {
color = ob.color;
} else {
color = bg.color;
}
if(ob.palette == 0) {
color = bg.color;
} else if(bg.palette == 0) {
color = ob.color;
} else if(ob.priority) {
color = ob.color;
} else {
color = bg.color;
}
uint32* output = screen + status.ly * 160 + px++;

View File

@ -113,7 +113,7 @@ auto PPU::writeIO(uint16 addr, uint8 data) -> void {
}
if(addr == 0xff40) { //LCDC
if(!status.displayEnable && (data & 0x80)) {
if(status.displayEnable && !data.bit(7)) {
status.ly = 0;
status.lx = 0;

View File

@ -8,13 +8,13 @@ PPU ppu;
#include "cgb.cpp"
#include "serialization.cpp"
auto PPU::enabled() const -> bool { return status.displayEnable; }
auto PPU::Enter() -> void {
while(true) scheduler.synchronize(), ppu.main();
}
auto PPU::main() -> void {
if(!status.displayEnable) return step(456);
status.lx = 0;
if(Model::SuperGameBoy()) superGameBoy->lcdScanline();
@ -30,7 +30,7 @@ auto PPU::main() -> void {
}
mode(0);
if(enabled()) cpu.hblank();
cpu.hblank();
step(204);
} else {
mode(1);
@ -40,7 +40,7 @@ auto PPU::main() -> void {
status.ly++;
if(status.ly == 144) {
if(enabled()) cpu.raise(CPU::Interrupt::Vblank);
cpu.raise(CPU::Interrupt::Vblank);
scheduler.exit(Scheduler::Event::Frame);
}

View File

@ -1,6 +1,4 @@
struct PPU : Thread, MMIO {
auto enabled() const -> bool;
static auto Enter() -> void;
auto main() -> void;
auto mode(uint) -> void;

View File

@ -0,0 +1,29 @@
ControlPad::ControlPad(uint port) : Controller(port) {
}
auto ControlPad::readData() -> uint8 {
uint6 data;
if(select == 0) {
data.bit(0) = platform->inputPoll(port, ID::Device::ControlPad, Up);
data.bit(1) = platform->inputPoll(port, ID::Device::ControlPad, Down);
data.bits(2,3) = ~0;
data.bit(4) = platform->inputPoll(port, ID::Device::ControlPad, A);
data.bit(5) = platform->inputPoll(port, ID::Device::ControlPad, Start);
} else {
data.bit(0) = platform->inputPoll(port, ID::Device::ControlPad, Up);
data.bit(1) = platform->inputPoll(port, ID::Device::ControlPad, Down);
data.bit(2) = platform->inputPoll(port, ID::Device::ControlPad, Left);
data.bit(3) = platform->inputPoll(port, ID::Device::ControlPad, Right);
data.bit(4) = platform->inputPoll(port, ID::Device::ControlPad, B);
data.bit(5) = platform->inputPoll(port, ID::Device::ControlPad, C);
}
data = ~data;
return latch << 7 | select << 6 | data;
}
auto ControlPad::writeData(uint8 data) -> void {
select = data.bit(6);
latch = data.bit(7);
}

View File

@ -1,13 +1,13 @@
struct Gamepad : Controller {
struct ControlPad : Controller {
enum : uint {
Up, Down, Left, Right, A, B, C, Start,
};
Gamepad(uint port);
ControlPad(uint port);
auto readData() -> uint8 override;
auto writeData(uint8 data) -> void override;
boolean select;
boolean latch;
uint1 select = 1;
uint1 latch;
};

View File

@ -5,7 +5,8 @@ namespace MegaDrive {
ControllerPort controllerPort1;
ControllerPort controllerPort2;
ControllerPort extensionPort;
#include "gamepad/gamepad.cpp"
#include "control-pad/control-pad.cpp"
#include "fighting-pad/fighting-pad.cpp"
Controller::Controller(uint port) : port(port) {
if(!handle()) create(Controller::Enter, 1);
@ -37,7 +38,8 @@ auto ControllerPort::connect(uint deviceID) -> void {
switch(deviceID) { default:
case ID::Device::None: device = new Controller(port); break;
case ID::Device::Gamepad: device = new Gamepad(port); break;
case ID::Device::ControlPad: device = new ControlPad(port); break;
case ID::Device::FightingPad: device = new FightingPad(port); break;
}
cpu.peripherals.reset();

View File

@ -3,7 +3,7 @@ struct Controller : Thread {
virtual ~Controller();
static auto Enter() -> void;
auto main() -> void;
virtual auto main() -> void;
virtual auto readData() -> uint8 { return 0xff; }
virtual auto writeData(uint8 data) -> void {}
@ -30,4 +30,5 @@ extern ControllerPort controllerPort1;
extern ControllerPort controllerPort2;
extern ControllerPort extensionPort;
#include "gamepad/gamepad.hpp"
#include "control-pad/control-pad.hpp"
#include "fighting-pad/fighting-pad.hpp"

View File

@ -0,0 +1,66 @@
FightingPad::FightingPad(uint port) : Controller(port) {
create(Controller::Enter, 1'000'000);
}
auto FightingPad::main() -> void {
if(timeout) {
timeout--;
} else {
counter = 0;
}
step(1);
synchronize(cpu);
}
auto FightingPad::readData() -> uint8 {
uint6 data;
if(select == 0) {
if(counter == 0 || counter == 1 || counter == 4) {
data.bit(0) = platform->inputPoll(port, ID::Device::FightingPad, Up);
data.bit(1) = platform->inputPoll(port, ID::Device::FightingPad, Down);
data.bits(2,3) = ~0;
}
if(counter == 2) {
data.bits(0,3) = ~0; //controller type detection
}
if(counter == 3) {
data.bits(0,3) = 0;
}
data.bit(4) = platform->inputPoll(port, ID::Device::FightingPad, A);
data.bit(5) = platform->inputPoll(port, ID::Device::FightingPad, Start);
} else {
if(counter == 0 || counter == 1 || counter == 2 || counter == 4) {
data.bit(0) = platform->inputPoll(port, ID::Device::FightingPad, Up);
data.bit(1) = platform->inputPoll(port, ID::Device::FightingPad, Down);
data.bit(2) = platform->inputPoll(port, ID::Device::FightingPad, Left);
data.bit(3) = platform->inputPoll(port, ID::Device::FightingPad, Right);
data.bit(4) = platform->inputPoll(port, ID::Device::FightingPad, B);
data.bit(5) = platform->inputPoll(port, ID::Device::FightingPad, C);
}
if(counter == 3) {
data.bit(0) = platform->inputPoll(port, ID::Device::FightingPad, Z);
data.bit(1) = platform->inputPoll(port, ID::Device::FightingPad, Y);
data.bit(2) = platform->inputPoll(port, ID::Device::FightingPad, X);
data.bit(3) = platform->inputPoll(port, ID::Device::FightingPad, Mode);
data.bits(4,5) = 0;
}
}
data = ~data;
return latch << 7 | select << 6 | data;
}
auto FightingPad::writeData(uint8 data) -> void {
if(!select && data.bit(6)) { //0->1 transition
if(++counter == 5) counter = 0;
}
select = data.bit(6);
latch = data.bit(7);
timeout = 1600; //~1.6ms
}

View File

@ -0,0 +1,16 @@
struct FightingPad : Controller {
enum : uint {
Up, Down, Left, Right, A, B, C, X, Y, Z, Mode, Start,
};
FightingPad(uint port);
auto main() -> void override;
auto readData() -> uint8 override;
auto writeData(uint8 data) -> void override;
uint1 select = 1;
uint1 latch;
uint3 counter;
uint32 timeout;
};

View File

@ -1,30 +0,0 @@
Gamepad::Gamepad(uint port) : Controller(port) {
}
auto Gamepad::readData() -> uint8 {
uint6 data;
if(select == 0) {
data.bit(0) = platform->inputPoll(port, ID::Device::Gamepad, Up);
data.bit(1) = platform->inputPoll(port, ID::Device::Gamepad, Down);
data.bit(2) = 1;
data.bit(3) = 1;
data.bit(4) = platform->inputPoll(port, ID::Device::Gamepad, A);
data.bit(5) = platform->inputPoll(port, ID::Device::Gamepad, Start);
} else {
data.bit(0) = platform->inputPoll(port, ID::Device::Gamepad, Up);
data.bit(1) = platform->inputPoll(port, ID::Device::Gamepad, Down);
data.bit(2) = platform->inputPoll(port, ID::Device::Gamepad, Left);
data.bit(3) = platform->inputPoll(port, ID::Device::Gamepad, Right);
data.bit(4) = platform->inputPoll(port, ID::Device::Gamepad, B);
data.bit(5) = platform->inputPoll(port, ID::Device::Gamepad, C);
}
data = ~data;
return latch << 7 | select << 6 | data;
}
auto Gamepad::writeData(uint8 data) -> void {
select = data.bit(6);
latch = data.bit(7);
}

View File

@ -26,7 +26,7 @@ Interface::Interface() {
extensionPort.devices.append(device);
}
{ Device device{ID::Device::Gamepad, "Gamepad"};
{ Device device{ID::Device::ControlPad, "Control Pad"};
device.inputs.append({0, "Up" });
device.inputs.append({0, "Down" });
device.inputs.append({0, "Left" });
@ -39,6 +39,23 @@ Interface::Interface() {
controllerPort2.devices.append(device);
}
{ Device device{ID::Device::FightingPad, "Fighting Pad"};
device.inputs.append({0, "Up" });
device.inputs.append({0, "Down" });
device.inputs.append({0, "Left" });
device.inputs.append({0, "Right"});
device.inputs.append({0, "A" });
device.inputs.append({0, "B" });
device.inputs.append({0, "C" });
device.inputs.append({0, "X" });
device.inputs.append({0, "Y" });
device.inputs.append({0, "Z" });
device.inputs.append({0, "Mode" });
device.inputs.append({0, "Start"});
controllerPort1.devices.append(device);
controllerPort2.devices.append(device);
}
ports.append(move(controllerPort1));
ports.append(move(controllerPort2));
ports.append(move(extensionPort));

View File

@ -14,7 +14,8 @@ struct ID {
struct Device { enum : uint {
None,
Gamepad,
ControlPad,
FightingPad,
};};
};

View File

@ -1131,12 +1131,17 @@ auto M68K::instructionSWAP(DataRegister with) -> void {
}
auto M68K::instructionTAS(EffectiveAddress with) -> void {
//auto data = read<Byte, Hold>(with);
//write<Byte>(with, data | 0x80);
uint32 data;
//Mega Drive models 1&2 have a bug that prevents TAS write cycle from completing
//this bugged behavior is required for certain software to function correctly
auto data = read<Byte>(with);
if(with.mode == DataRegisterDirect) {
data = read<Byte, Hold>(with);
write<Byte>(with, data | 0x80);
} else {
//Mega Drive models 1&2 have a bug that prevents TAS write from taking effect
//this bugged behavior is required for certain software to function correctly
data = read<Byte>(with);
step(4);
}
r.c = 0;
r.v = 0;

View File

@ -1,17 +1,17 @@
#if defined(Hiro_Desktop)
namespace hiro {
auto pDesktop::size() -> Size {
return {GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)};
}
auto pDesktop::workspace() -> Geometry {
RECT rc;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
return {rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top};
}
}
#endif
#if defined(Hiro_Desktop)
namespace hiro {
auto pDesktop::size() -> Size {
return {GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)};
}
auto pDesktop::workspace() -> Geometry {
RECT rc;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
return {rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top};
}
}
#endif

View File

@ -1,22 +1,22 @@
#if defined(Hiro_Mouse)
namespace hiro {
auto pMouse::position() -> Position {
POINT point{0};
GetCursorPos(&point);
return {point.x, point.y};
}
auto pMouse::pressed(Mouse::Button button) -> bool {
switch(button) {
case Mouse::Button::Left: return GetAsyncKeyState(VK_LBUTTON) & 0x8000;
case Mouse::Button::Middle: return GetAsyncKeyState(VK_MBUTTON) & 0x8000;
case Mouse::Button::Right: return GetAsyncKeyState(VK_RBUTTON) & 0x8000;
}
return false;
}
}
#endif
#if defined(Hiro_Mouse)
namespace hiro {
auto pMouse::position() -> Position {
POINT point{};
GetCursorPos(&point);
return {point.x, point.y};
}
auto pMouse::pressed(Mouse::Button button) -> bool {
switch(button) {
case Mouse::Button::Left: return GetAsyncKeyState(VK_LBUTTON) & 0x8000;
case Mouse::Button::Middle: return GetAsyncKeyState(VK_MBUTTON) & 0x8000;
case Mouse::Button::Right: return GetAsyncKeyState(VK_RBUTTON) & 0x8000;
}
return false;
}
}
#endif

View File

@ -6,11 +6,27 @@ struct AudioALSA : Audio {
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = queryDevices();
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {20, 40, 60, 80, 100};
information.channels = {2};
return information;
}
auto device() -> string { return _device; }
auto blocking() -> bool { return _blocking; }
auto channels() -> uint { return 2; }
auto frequency() -> double { return _frequency; }
auto latency() -> uint { return _latency; }
auto setDevice(string device) -> bool {
if(_device == device) return true;
_device = device;
return initialize();
}
auto setBlocking(bool blocking) -> bool {
if(_blocking == blocking) return true;
_blocking = blocking;
@ -76,7 +92,9 @@ private:
auto initialize() -> bool {
terminate();
if(snd_pcm_open(&_interface, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) return terminate(), false;
string device = "default";
if(queryDevices().find(_device)) device = _device;
if(snd_pcm_open(&_interface, device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) return terminate(), false;
uint rate = (uint)_frequency;
uint bufferTime = _latency * 1000;
@ -122,10 +140,29 @@ private:
if(_buffer) {
delete[] _buffer;
_buffer = nullptr;
}
}
}
auto queryDevices() -> string_vector {
string_vector devices;
const char** list;
if(snd_device_name_hint(-1, "pcm", (void***)&list) == 0) {
uint index = 0;
while(list[index]) {
const char* deviceName = snd_device_name_get_hint(list[index], "NAME");
if(deviceName) devices.append(deviceName);
free(deviceName);
index++;
}
}
snd_device_name_free_hint((void**)list);
return devices;
}
bool _ready = false;
string _device;
bool _blocking = true;
double _frequency = 48000.0;
uint _latency = 40;

View File

@ -44,6 +44,7 @@ struct AudioAO : Audio {
format.channels = 2;
format.rate = (uint)_frequency;
format.byte_format = AO_FMT_LITTLE;
format.matrix = nullptr;
ao_info* information = ao_driver_info(driverID);
if(!information) return false;

View File

@ -63,7 +63,7 @@ struct Audio {
virtual ~Audio() = default;
virtual auto ready() -> bool { return true; }
virtual auto information() -> Information { return {{"None"}, {48000.0}, {0}, {2}}; }
virtual auto information() -> Information { return {{"Default"}, {48000.0}, {0}, {2}}; }
virtual auto exclusive() -> bool { return false; }
virtual auto context() -> uintptr { return 0; }

View File

@ -127,7 +127,7 @@ private:
return _ready = true;
}
auto term() -> void {
auto terminate() -> void {
_ready = false;
OpenGL::terminate();