diff --git a/genius/GNUmakefile b/genius/GNUmakefile index c9a14577..908e0990 100644 --- a/genius/GNUmakefile +++ b/genius/GNUmakefile @@ -1,22 +1,21 @@ name := genius build := stable +flags += -I.. nall.path := ../nall include $(nall.path)/GNUmakefile -object.path := obj -flags += -I.. - hiro.path := ../hiro hiro.resource := data/$(name).rc include $(hiro.path)/GNUmakefile -objects := obj/hiro.o $(if $(call streq,$(platform),windows),obj/hiro-resource.o) -objects += obj/genius.o +objects := obj/genius.o -all: $(objects) +obj/genius.o: genius.cpp + +all: $(hiro.objects) $(objects) $(info Linking out/$(name) ...) - +@$(strip $(compiler) -o out/$(name) $(objects) $(options) $(hiro.options)) + +@$(compiler) -o out/$(name) $(hiro.objects) $(objects) $(hiro.options) $(options) ifeq ($(platform),macos) rm -rf out/$(name).app mkdir -p out/$(name).app/Contents/MacOS/ @@ -26,16 +25,14 @@ ifeq ($(platform),macos) sips -s format icns data/$(name).png --out out/$(name).app/Contents/Resources/$(name).icns endif -obj/genius.o: genius.cpp genius.hpp - $(info Compiling $< ...) - @$(compiler) $(flags.cpp) $(flags) -o obj/genius.o -c genius.cpp +verbose: hiro.verbose nall.verbose all; clean: ifeq ($(platform),macos) rm -rf out/$(name).app endif - $(call rm,obj/*) - $(call rm,out/*) + $(call delete,obj/*) + $(call delete,out/*) install: ifeq ($(platform),macos) diff --git a/higan/GNUmakefile b/higan/GNUmakefile index 36accab4..2463cf03 100644 --- a/higan/GNUmakefile +++ b/higan/GNUmakefile @@ -1,15 +1,12 @@ +target := bsnes +binary := application build := performance openmp := true +flags += -I. -I.. nall.path := ../nall include $(nall.path)/GNUmakefile -binary := application -target := bsnes -objects := libco emulator audio video resource -object.path := obj -flags += -I. -I.. - ifeq ($(platform),windows) ifeq ($(binary),application) link += -luuid -lkernel32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32 @@ -37,18 +34,7 @@ else $(error "unsupported platform") endif -compile = \ - $(strip \ - $(if $(filter %.c,$<), \ - $(compiler) $(flags.c) $(flags) $1 -c $< -o $@ -MMD -MP -MF $(@:.o=.d), \ - $(if $(filter %.cpp,$<), \ - $(compiler) $(flags.cpp) $(flags) $1 -c $< -o $@ -MMD -MP -MF $(@:.o=.d) \ - )) \ - ) - -%.o: $< - $(info Compiling $< ...) - @$(call compile) +objects := libco emulator audio video resource obj/libco.o: ../libco/libco.c obj/emulator.o: emulator/emulator.cpp @@ -61,5 +47,5 @@ include $(ui)/GNUmakefile -include obj/*.d clean: - $(call rm,out/*) - $(call rm,obj/*) + $(call delete,out/*) + $(call delete,obj/*) diff --git a/higan/emulator/emulator.hpp b/higan/emulator/emulator.hpp index 6ba1a263..7bbdf444 100644 --- a/higan/emulator/emulator.hpp +++ b/higan/emulator/emulator.hpp @@ -13,7 +13,7 @@ using namespace nall; namespace Emulator { static const string Name = "higan"; - static const string Version = "106.47"; + static const string Version = "106.48"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "https://byuu.org/"; diff --git a/higan/gb/cpu/cpu.hpp b/higan/gb/cpu/cpu.hpp index 05a6736e..8c0e499e 100644 --- a/higan/gb/cpu/cpu.hpp +++ b/higan/gb/cpu/cpu.hpp @@ -41,7 +41,6 @@ struct CPU : Processor::LR35902, Thread, MMIO { bool p15 = 0; bool p14 = 0; uint8 joyp; - uint8 mltReq; //$ff01 SB uint8 serialData; diff --git a/higan/gb/cpu/io.cpp b/higan/gb/cpu/io.cpp index 72770e87..a3319975 100644 --- a/higan/gb/cpu/io.cpp +++ b/higan/gb/cpu/io.cpp @@ -29,7 +29,9 @@ auto CPU::joypPoll() -> void { } status.joyp = 0x0f; - if(status.p15 == 1 && status.p14 == 1) status.joyp -= status.mltReq; + if(status.p15 == 1 && status.p14 == 1 && Model::SuperGameBoy()) { + status.joyp = superGameBoy->joypRead(); + } if(status.p15 == 0) status.joyp &= button ^ 0x0f; if(status.p14 == 0) status.joyp &= dpad ^ 0x0f; if(status.joyp != 0x0f) raise(Interrupt::Joypad); diff --git a/higan/gb/cpu/serialization.cpp b/higan/gb/cpu/serialization.cpp index 017cd1f3..c15bd527 100644 --- a/higan/gb/cpu/serialization.cpp +++ b/higan/gb/cpu/serialization.cpp @@ -10,7 +10,6 @@ auto CPU::serialize(serializer& s) -> void { s.integer(status.p15); s.integer(status.p14); s.integer(status.joyp); - s.integer(status.mltReq); s.integer(status.serialData); s.integer(status.serialBits); diff --git a/higan/gb/interface/interface.hpp b/higan/gb/interface/interface.hpp index e229aebb..d07104b4 100644 --- a/higan/gb/interface/interface.hpp +++ b/higan/gb/interface/interface.hpp @@ -72,6 +72,7 @@ struct SuperGameBoyInterface { virtual auto lcdScanline() -> void = 0; virtual auto lcdOutput(uint2 color) -> void = 0; + virtual auto joypRead() -> uint4 = 0; virtual auto joypWrite(bool p15, bool p14) -> void = 0; }; diff --git a/higan/sfc/coprocessor/icd/icd.cpp b/higan/sfc/coprocessor/icd/icd.cpp index e3e0de3c..69d3d23f 100644 --- a/higan/sfc/coprocessor/icd/icd.cpp +++ b/higan/sfc/coprocessor/icd/icd.cpp @@ -91,7 +91,7 @@ auto ICD::reset() -> void { writeAddress = 0; packetSize = 0; - joypID = 3; + joypID = 0; joyp15Lock = 0; joyp14Lock = 0; pulseLock = true; diff --git a/higan/sfc/coprocessor/icd/icd.hpp b/higan/sfc/coprocessor/icd/icd.hpp index 3124a01b..a407787c 100644 --- a/higan/sfc/coprocessor/icd/icd.hpp +++ b/higan/sfc/coprocessor/icd/icd.hpp @@ -18,6 +18,7 @@ struct ICD : Emulator::Platform, GameBoy::SuperGameBoyInterface, Thread { //interface.cpp auto lcdScanline() -> void override; auto lcdOutput(uint2 color) -> void override; + auto joypRead() -> uint4 override; auto joypWrite(bool p15, bool p14) -> void override; //io.cpp diff --git a/higan/sfc/coprocessor/icd/interface.cpp b/higan/sfc/coprocessor/icd/interface.cpp index b05d8881..33121900 100644 --- a/higan/sfc/coprocessor/icd/interface.cpp +++ b/higan/sfc/coprocessor/icd/interface.cpp @@ -10,18 +10,26 @@ auto ICD::lcdOutput(uint2 color) -> void { uint y = writeAddress / 160; uint x = writeAddress % 160; uint addr = writeBank * 512 + y * 2 + x / 8 * 16; - output[addr + 0] = (output[addr + 0] << 1) | (bool)(color & 1); - output[addr + 1] = (output[addr + 1] << 1) | (bool)(color & 2); + output[addr + 0] = (output[addr + 0] << 1) | color.bit(0); + output[addr + 1] = (output[addr + 1] << 1) | color.bit(1); writeAddress = (writeAddress + 1) % 1280; } +auto ICD::joypRead() -> uint4 { + return 0xf - joypID; +} + auto ICD::joypWrite(bool p15, bool p14) -> void { //joypad handling if(p15 == 1 && p14 == 1) { if(joyp15Lock == 0 && joyp14Lock == 0) { joyp15Lock = 1; joyp14Lock = 1; - joypID = (joypID + 1) & 3; + joypID++; + if(mltReq == 0) joypID &= 0; //1-player mode + if(mltReq == 1) joypID &= 1; //2-player mode + if(mltReq == 2) joypID &= 3; //4-player mode (unverified; but the most likely behavior) + if(mltReq == 3) joypID &= 3; //4-player mode } } @@ -65,8 +73,7 @@ auto ICD::joypWrite(bool p15, bool p14) -> void { if(p15 == 1 && p14 == 0) { if((joypPacket[0] >> 3) == 0x11) { mltReq = joypPacket[1] & 3; - if(mltReq == 2) mltReq = 3; - joypID = 0; + joypID = 3; //required: the next time P14==1 && P15==1; increment and start from ID=0 (Joypad 1) } if(packetSize < 64) packet[packetSize++] = joypPacket; diff --git a/higan/sfc/coprocessor/icd/platform.cpp b/higan/sfc/coprocessor/icd/platform.cpp index d07f8021..6094a680 100644 --- a/higan/sfc/coprocessor/icd/platform.cpp +++ b/higan/sfc/coprocessor/icd/platform.cpp @@ -3,10 +3,8 @@ auto ICD::audioSample(const double* samples, uint channels) -> void { } auto ICD::inputPoll(uint port, uint device, uint id) -> int16 { - GameBoy::cpu.status.mltReq = joypID & mltReq; - - uint data = 0x00; - switch(joypID & mltReq) { + uint8 data = 0x00; + switch(joypID) { case 0: data = ~r6004; break; case 1: data = ~r6005; break; case 2: data = ~r6006; break; @@ -14,14 +12,14 @@ auto ICD::inputPoll(uint port, uint device, uint id) -> int16 { } switch((GameBoy::Input)id) { - case GameBoy::Input::Start: return (bool)(data & 0x80); - case GameBoy::Input::Select: return (bool)(data & 0x40); - case GameBoy::Input::B: return (bool)(data & 0x20); - case GameBoy::Input::A: return (bool)(data & 0x10); - case GameBoy::Input::Down: return (bool)(data & 0x08); - case GameBoy::Input::Up: return (bool)(data & 0x04); - case GameBoy::Input::Left: return (bool)(data & 0x02); - case GameBoy::Input::Right: return (bool)(data & 0x01); + case GameBoy::Input::Right: return data.bit(0); + case GameBoy::Input::Left: return data.bit(1); + case GameBoy::Input::Up: return data.bit(2); + case GameBoy::Input::Down: return data.bit(3); + case GameBoy::Input::A: return data.bit(4); + case GameBoy::Input::B: return data.bit(5); + case GameBoy::Input::Select: return data.bit(6); + case GameBoy::Input::Start: return data.bit(7); } return 0; diff --git a/higan/target-bsnes/GNUmakefile b/higan/target-bsnes/GNUmakefile index 0176ce2c..64b45cb0 100644 --- a/higan/target-bsnes/GNUmakefile +++ b/higan/target-bsnes/GNUmakefile @@ -5,35 +5,16 @@ include sfc/GNUmakefile include gb/GNUmakefile include processor/GNUmakefile -objects := ruby hiro $(if $(call streq,$(platform),windows),hiro-resource) $(objects) -objects += ui-bsnes ui-program ui-input ui-presentation -objects += ui-settings ui-tools ui-resource -objects := $(objects:%=obj/%.o) - -ifeq ($(platform),windows) - ruby += video.wgl video.direct3d video.directdraw video.gdi - ruby += audio.asio audio.wasapi audio.xaudio2 audio.directsound - ruby += input.windows -else ifeq ($(platform),macos) - ruby += video.cgl - ruby += audio.openal - ruby += input.quartz input.carbon -else ifeq ($(platform),linux) - ruby += video.glx video.xvideo video.xshm - ruby += audio.oss audio.alsa audio.openal audio.pulseaudio audio.pulseaudiosimple audio.ao - ruby += input.sdl input.xlib input.udev -else ifeq ($(platform),bsd) - ruby += video.glx video.xvideo video.xshm - ruby += audio.oss audio.openal - ruby += input.sdl input.xlib -endif +hiro.path := ../hiro +hiro.resource := $(ui)/resource/bsnes.rc +include $(hiro.path)/GNUmakefile ruby.path := ../ruby include $(ruby.path)/GNUmakefile -hiro.path := ../hiro -hiro.resource := $(ui)/resource/bsnes.rc -include $(hiro.path)/GNUmakefile +objects += ui-bsnes ui-program ui-input ui-presentation +objects += ui-settings ui-tools ui-resource +objects := $(objects:%=obj/%.o) obj/ui-bsnes.o: $(ui)/bsnes.cpp obj/ui-program.o: $(ui)/program/program.cpp @@ -43,10 +24,9 @@ obj/ui-settings.o: $(ui)/settings/settings.cpp obj/ui-tools.o: $(ui)/tools/tools.cpp obj/ui-resource.o: $(ui)/resource/resource.cpp -# targets -all: $(objects) +all: $(hiro.objects) $(ruby.objects) $(objects) $(info Linking out/$(name) ...) - +@$(strip $(compiler) -o out/$(name) $(objects) $(options) $(ruby.options) $(hiro.options)) + +@$(compiler) -o out/$(name) $(hiro.objects) $(ruby.objects) $(objects) $(hiro.options) $(ruby.options) $(options) ifeq ($(platform),macos) rm -rf out/$(name).app mkdir -p out/$(name).app/Contents/MacOS/ @@ -56,6 +36,8 @@ ifeq ($(platform),macos) sips -s format icns $(ui)/resource/$(name).png --out out/$(name).app/Contents/Resources/$(name).icns endif +verbose: hiro.verbose ruby.verbose nall.verbose all; + install: ifeq ($(shell id -un),root) $(error "make install should not be run as root") diff --git a/higan/target-bsnes/bsnes.cpp b/higan/target-bsnes/bsnes.cpp index c09a3892..64f371d2 100644 --- a/higan/target-bsnes/bsnes.cpp +++ b/higan/target-bsnes/bsnes.cpp @@ -4,7 +4,6 @@ unique_pointer