Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,697 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
TARGET := scummvm | ||
|
||
APP_TITLE := ScummVM | ||
APP_DESCRIPTION := Point-and-click adventure game engines | ||
APP_AUTHOR := ScummVM Team | ||
APP_ICON := backends/platform/3ds/icon.png | ||
|
||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft | ||
CXXFLAGS += -std=gnu++11 | ||
ASFLAGS += -mfloat-abi=hard | ||
LDFLAGS += -specs=3dsx.specs $(ARCH) -L$(DEVKITPRO)/libctru/lib -L$(DEVKITPRO)/portlibs/3ds/lib | ||
|
||
.PHONY: clean_3ds | ||
|
||
all: $(TARGET).3dsx | ||
|
||
clean: clean_3ds | ||
|
||
clean_3ds: | ||
$(RM) $(TARGET).3dsx | ||
|
||
$(TARGET).smdh: $(APP_ICON) $(MAKEFILE_LIST) | ||
@smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@ | ||
@echo built ... $(notdir $@) | ||
|
||
$(TARGET).3dsx: $(EXECUTABLE) $(TARGET).smdh | ||
@3dsxtool $< $@ --smdh=$(TARGET).smdh | ||
@echo built ... $(notdir $@) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# rules for assembling GPU shaders | ||
#--------------------------------------------------------------------------------- | ||
define shader-as | ||
$(eval FILEPATH := $(patsubst %.shbin.o,%.shbin,$@)) | ||
$(eval FILE := $(patsubst %.shbin.o,%.shbin,$(notdir $@))) | ||
picasso -o $(FILEPATH) $1 | ||
bin2s $(FILEPATH) | $(AS) -o $@ | ||
echo "extern const u8" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(FILEPATH) | tr . _)`.h | ||
echo "extern const u8" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(FILEPATH) | tr . _)`.h | ||
echo "extern const u32" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(FILEPATH) | tr . _)`.h | ||
endef | ||
|
||
%.shbin.o : %.v.pica %.g.pica | ||
@echo $(notdir $^) | ||
@$(call shader-as,$^) | ||
|
||
%.shbin.o : %.v.pica | ||
@echo $(notdir $<) | ||
@$(call shader-as,$<) | ||
|
||
%.shbin.o : %.shlist | ||
@echo $(notdir $<) | ||
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* ScummVM - Graphic Adventure Engine | ||
* | ||
* ScummVM is the legal property of its developers, whose names | ||
* are too numerous to list here. Please refer to the COPYRIGHT | ||
* file distributed with this source distribution. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
|
||
#include "backends/platform/3ds/gui.h" | ||
#include "common/system.h" | ||
|
||
StatusMessageDialog* StatusMessageDialog::_opened = 0; | ||
|
||
StatusMessageDialog::StatusMessageDialog(const Common::String &message, uint32 duration) | ||
: MessageDialog(message, 0, 0) { | ||
_timer = g_system->getMillis() + duration; | ||
if (_opened) | ||
_opened->close(); | ||
_opened = this; | ||
} | ||
|
||
void StatusMessageDialog::handleTickle() { | ||
MessageDialog::handleTickle(); | ||
if (g_system->getMillis() > _timer) | ||
close(); | ||
} | ||
|
||
void StatusMessageDialog::close() { | ||
GUI::Dialog::close(); | ||
if (_opened) | ||
_opened = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* ScummVM - Graphic Adventure Engine | ||
* | ||
* ScummVM is the legal property of its developers, whose names | ||
* are too numerous to list here. Please refer to the COPYRIGHT | ||
* file distributed with this source distribution. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
|
||
#ifndef GUI_3DS_H | ||
#define GUI_3DS_H | ||
|
||
#include "gui/message.h" | ||
|
||
class StatusMessageDialog : public GUI::MessageDialog { | ||
public: | ||
StatusMessageDialog(const Common::String &message, uint32 duration); | ||
|
||
void handleTickle(); | ||
|
||
protected: | ||
virtual void close(); | ||
|
||
uint32 _timer; | ||
static StatusMessageDialog* _opened; | ||
}; | ||
|
||
#endif // GUI_3DS_H |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* ScummVM - Graphic Adventure Engine | ||
* | ||
* ScummVM is the legal property of its developers, whose names | ||
* are too numerous to list here. Please refer to the COPYRIGHT | ||
* file distributed with this source distribution. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
|
||
#define FORBIDDEN_SYMBOL_ALLOW_ALL | ||
|
||
#include "osystem.h" | ||
#include <3ds.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
// Initialize basic libctru stuff | ||
gfxInitDefault(); | ||
cfguInit(); | ||
osSetSpeedupEnable(true); | ||
// consoleInit(GFX_TOP, NULL); | ||
|
||
g_system = new OSystem_3DS(); | ||
assert(g_system); | ||
|
||
// Invoke the actual ScummVM main entry point | ||
// if (argc > 2) | ||
// res = scummvm_main(argc-2, &argv[2]); | ||
// else | ||
// res = scummvm_main(argc, argv); | ||
scummvm_main(0, nullptr); | ||
|
||
delete dynamic_cast<OSystem_3DS*>(g_system); | ||
|
||
cfguExit(); | ||
gfxExit(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
MODULE := backends/platform/3ds | ||
|
||
MODULE_OBJS := \ | ||
main.o \ | ||
shader.shbin.o \ | ||
sprite.o \ | ||
gui.o \ | ||
osystem.o \ | ||
osystem-graphics.o \ | ||
osystem-audio.o \ | ||
osystem-events.o | ||
|
||
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS. | ||
MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) | ||
OBJS := $(MODULE_OBJS) $(OBJS) | ||
MODULE_DIRS += $(sort $(dir $(MODULE_OBJS))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* ScummVM - Graphic Adventure Engine | ||
* | ||
* ScummVM is the legal property of its developers, whose names | ||
* are too numerous to list here. Please refer to the COPYRIGHT | ||
* file distributed with this source distribution. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
|
||
#include "osystem.h" | ||
|
||
static bool exitAudioThread = false; | ||
static bool hasAudio = false; | ||
|
||
static void audioThreadFunc(void* arg) { | ||
Audio::MixerImpl *mixer = (Audio::MixerImpl *) arg; | ||
OSystem_3DS *osys = (OSystem_3DS*)g_system; | ||
|
||
int i; | ||
const int channel = 0; | ||
int bufferIndex = 0; | ||
const int bufferCount = 3; | ||
const int bufferSize = 80000; // Can't be too small, based on delayMillis duration | ||
const int sampleRate = 22050; | ||
int sampleLen = 0; | ||
uint32 lastTime = osys->getMillis(true); | ||
uint32 time = lastTime; | ||
ndspWaveBuf buffers[bufferCount]; | ||
|
||
for(i = 0; i < bufferCount; ++i) { | ||
memset(&buffers[i], 0, sizeof(ndspWaveBuf)); | ||
buffers[i].data_vaddr = linearAlloc(bufferSize); | ||
buffers[i].looping = false; | ||
buffers[i].status = NDSP_WBUF_FREE; | ||
} | ||
|
||
ndspChnReset(channel); | ||
ndspChnSetInterp(channel, NDSP_INTERP_LINEAR); | ||
ndspChnSetRate(channel, sampleRate); | ||
ndspChnSetFormat(channel, NDSP_FORMAT_STEREO_PCM16); | ||
|
||
while(!exitAudioThread) { | ||
bufferIndex++; | ||
bufferIndex %= bufferCount; | ||
ndspWaveBuf* buf = &buffers[bufferIndex]; | ||
|
||
osys->delayMillis(100); // Note: Increasing the delay requires a bigger buffer | ||
|
||
time = osys->getMillis(true); | ||
sampleLen = (time - lastTime) * 22 * 4; // sampleRate / 1000 * channelCount * sizeof(int16); | ||
lastTime = time; | ||
|
||
if (sampleLen > 0) { | ||
buf->nsamples = mixer->mixCallback(buf->data_adpcm, sampleLen); | ||
if (buf->nsamples > 0) { | ||
DSP_FlushDataCache(buf->data_vaddr, bufferSize); | ||
ndspChnWaveBufAdd(channel, buf); | ||
} | ||
} | ||
} | ||
|
||
for(i = 0; i < bufferCount; ++i) | ||
linearFree(buffers[i].data_pcm8); | ||
} | ||
|
||
void OSystem_3DS::initAudio() { | ||
_mixer = new Audio::MixerImpl(this, 22050); | ||
|
||
hasAudio = R_SUCCEEDED(ndspInit()); | ||
_mixer->setReady(false); | ||
|
||
if (hasAudio) { | ||
s32 prio = 0; | ||
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE); | ||
audioThread = threadCreate(&audioThreadFunc, _mixer, 32*1048, prio-1, -2, false); | ||
} | ||
} | ||
|
||
void OSystem_3DS::destroyAudio() { | ||
if (hasAudio) { | ||
exitAudioThread = true; | ||
threadJoin(audioThread, U64_MAX); | ||
threadFree(audioThread); | ||
ndspExit(); | ||
} | ||
|
||
delete _mixer; | ||
_mixer = 0; | ||
} | ||
|
||
Audio::Mixer *OSystem_3DS::getMixer() { | ||
assert(_mixer); | ||
return _mixer; | ||
} |
Oops, something went wrong.