Merge remote-tracking branch 'upstream/master'

This commit is contained in:
radius 2018-01-07 19:54:22 -05:00
commit bebb94738c
8 changed files with 41 additions and 48 deletions

View File

@ -1,32 +0,0 @@
language: generic
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
env:
global:
- CORE=sameboy
- COMPILER_NAME=gcc CXX=g++-7 CC=gcc-7
matrix:
- PLATFORM=linux_x64
before_script:
- pwd
- mkdir -p ~/bin
- ln -s /usr/bin/gcc-7 ~/bin/gcc
- ln -s /usr/bin/g++-7 ~/bin/g++
- ln -s /usr/bin/cpp-7 ~/bin/cpp
- export PATH=~/bin:$PATH
- ls -l ~/bin
- echo $PATH
- g++-7 --version
- g++ --version
script:
- cd ~/
- git clone --depth=50 https://github.com/libretro/libretro-super
- cd libretro-super/travis
- ./build.sh

View File

@ -80,14 +80,14 @@ Start:
; Play first sound
ld a, $83
call PlaySound
ld b, 15
ld b, 5
call WaitBFrames
; Play second sound
ld a, $c1
call PlaySound
; Wait ~2.5 seconds
ld b, 150
; Wait ~1.15 seconds
ld b, 70
call WaitBFrames
; Set registers to match the original DMG boot
@ -123,9 +123,13 @@ DoubleBitsAndWriteRow:
ret
WaitFrame:
ldh a, [$44]
cp $90
jr nz, WaitFrame
push hl
ld hl, $FF0F
res 0, [hl]
.wait
bit 0, [hl]
jr z, .wait
pop hl
ret
WaitBFrames:

Binary file not shown.

Binary file not shown.

View File

@ -27,11 +27,11 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, uint8_t value, unsig
if (gb->apu_output.sample_rate) {
unsigned left_volume = 0;
if (gb->io_registers[GB_IO_NR51] & (1 << index)) {
left_volume = gb->io_registers[GB_IO_NR50] & 7;
left_volume = (gb->io_registers[GB_IO_NR50] & 7) + 1;
}
unsigned right_volume = 0;
if (gb->io_registers[GB_IO_NR51] & (0x10 << index)) {
right_volume = (gb->io_registers[GB_IO_NR50] >> 4) & 7;
right_volume = ((gb->io_registers[GB_IO_NR50] >> 4) & 7) + 1;
}
GB_sample_t output = {(0xf - value) * left_volume, (0xf - value) * right_volume};
if (*(uint32_t *)&(gb->apu_output.current_sample[index]) != *(uint32_t *)&output) {
@ -575,6 +575,14 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
gb->apu.square_channels[index].sample_countdown = (gb->apu.square_channels[index].sample_length ^ 0x7FF) * 2 + 4 - gb->apu.lf_div;
}
gb->apu.square_channels[index].current_volume = gb->io_registers[index == GB_SQUARE_1 ? GB_IO_NR12 : GB_IO_NR22] >> 4;
/* The volume changes caused by NRX4 sound start take effect instantly (i.e. the effect the previously
started sound). The playback itself is not instant which is why we don't update the sample for other
cases. */
if (gb->apu.is_active[index]) {
update_square_sample(gb, index);
}
gb->apu.square_channels[index].volume_countdown = gb->io_registers[index == GB_SQUARE_1 ? GB_IO_NR12 : GB_IO_NR22] & 7;
if ((gb->io_registers[index == GB_SQUARE_1 ? GB_IO_NR12 : GB_IO_NR22] & 0xF8) != 0) {
@ -599,7 +607,6 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
if (!gb->apu.square_sweep_countdown) gb->apu.square_sweep_countdown = 8;
}
/* Note that we don't change the sample just yet! This was verified on hardware. */
}
/* APU glitch - if length is enabled while the DIV-divider's LSB is 1, tick the length once. */
@ -718,7 +725,10 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
}
else if (gb->apu.is_active[GB_NOISE]){
nrx2_glitch(&gb->apu.noise_channel.current_volume, value, gb->io_registers[reg]);
update_square_sample(gb, GB_NOISE);
update_sample(gb, GB_NOISE,
(gb->apu.noise_channel.lfsr & 1) ?
gb->apu.noise_channel.current_volume : 0,
0);
}
break;
}
@ -757,6 +767,17 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
}
gb->apu.noise_channel.current_volume = gb->io_registers[GB_IO_NR42] >> 4;
/* The volume changes caused by NRX4 sound start take effect instantly (i.e. the effect the previously
started sound). The playback itself is not instant which is why we don't update the sample for other
cases. */
if (gb->apu.is_active[GB_NOISE]) {
update_sample(gb, GB_NOISE,
(gb->apu.noise_channel.lfsr & 1) ?
gb->apu.noise_channel.current_volume : 0,
0);
}
gb->apu.noise_channel.volume_countdown = gb->io_registers[GB_IO_NR42] & 7;
if ((gb->io_registers[GB_IO_NR42] & 0xF8) != 0) {
@ -767,8 +788,6 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
gb->apu.noise_channel.pulse_length = 0x40;
gb->apu.noise_channel.length_enabled = false;
}
/* Note that we don't change the sample just yet! This was verified on hardware. */
}
/* APU glitch - if length is enabled while the DIV-divider's LSB is 1, tick the length once. */

View File

@ -6,9 +6,9 @@
#ifdef GB_INTERNAL
/* Divides nicely and never overflows with 4 channels and 8 volume levels */
#define MAX_CH_AMP 0x1FFE
#define CH_STEP (MAX_CH_AMP/0xF/7)
/* Divides nicely and never overflows with 4 channels and 8 (1-8) volume levels */
#define MAX_CH_AMP 0x1FE0
#define CH_STEP (MAX_CH_AMP/0xF/8)
#endif
/* APU ticks are 2MHz, triggered by an internal APU clock. */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

View File

@ -6,6 +6,8 @@ ifneq ($(GIT_VERSION)," unknown")
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
CFLAGS += -DSAMEBOY_CORE_VERSION=\"$(VERSION)\"
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
@ -139,7 +141,7 @@ CFLAGS += -Wall -D__LIBRETRO__ $(fpic) $(INCFLAGS) -std=gnu11 -D_GNU_SOURCE -D
all: $(TARGET)
$(CORE_DIR)/libretro/%_boot.c: $(CORE_DIR)/BootROMs/prebuilt/%_boot.bin
$(CORE_DIR)/libretro/%_boot.c: $(CORE_DIR)/build/bin/BootROMs/%_boot.bin
echo "/* AUTO-GENERATED */" > $@
echo "const unsigned char $(notdir $(@:%.c=%))[] = {" >> $@
hexdump -v -e '/1 "0x%02x, "' $< >> $@