Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloMK7 committed May 12, 2024
0 parents commit 19a46a8
Show file tree
Hide file tree
Showing 86 changed files with 12,592 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
images/logo.pdn
.vscode/
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
VERSION_MAJOR := 1
VERSION_MINOR := 0
VERSION_REVISION := 0

all:
mkdir -p plugin/build
sed -e 's/VERSION_MAJOR/$(VERSION_MAJOR)/' -e 's/VERSION_MINOR/$(VERSION_MINOR)/' -e 's/VERSION_REVISION/$(VERSION_REVISION)/' plugin/ArticBase.plgInfo > plugin/build/ArticBase.plgInfo
$(MAKE) -C plugin VERSION_MAJOR=$(VERSION_MAJOR) VERSION_MINOR=$(VERSION_MINOR) VERSION_REVISION=$(VERSION_REVISION)
bin2c -d app/includes/plugin.h -o app/sources/plugin.c plugin/ArticBase.3gx
$(MAKE) -C app VERSION_MAJOR=$(VERSION_MAJOR) VERSION_MINOR=$(VERSION_MINOR) VERSION_REVISION=$(VERSION_REVISION)

clean:
$(MAKE) -C plugin clean
rm -f app/sources/plugin.c
rm -f app/includes/plugin.h
$(MAKE) -C app clean

re: clean all
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Artic Base Server
<p align="center">
<img width="180" height="180" src="https://github.com/PabloMK7/ArticBaseServer/blob/main/images/logo.png?raw=true">
</p>

Artic Base is a tool for broadcasting games from your 3DS to a compatible emulator. This allows playing your physical or digital games on an emulator without having to dump them. You can find a demo [here](https://www.youtube.com/watch?v=noDz-FnOd2M).

## Description
Artic Base Server is a Luma3DS 3GX plugin that allows using the Artic Base protocol to broadcast your games to a compaible emulator (for example: [PabloMK7/citra](https://github.com/PabloMK7/citra)). This works by forwarding the filesystem requests from the emulator to the console.

### Features
- Play games from your console without having to dump them.
- Sync the savedata/extdata of the broadcasted game during the play session.
- Load shared ext data and NCCH archives from your console.
- Remove the need to dump AES keys, as the decryption is done by the console's OS.

### Advantages over playing on real console
- Play your games at higher resolutions.
- Use external controllers that may better fit your playstyle.
- Switch between playing on your PC at home and your console on the go.
- Reduce e-waste by reusing partially broken consoles to broadcast your games to your PC.
- Allow museums or non-profit game preservation organizations to have a centralised database of preserved games, while using an Artic Base Server + a compatible emulator to do research as needed.

### Disadvantages over game dumps
- Slower loading times, ranging from 2x to 5x depending on how much data is needed by the game. Thanks to the use of a cache in memory, loading times get better if game resources that were already loaded are requested again.
- Constant and stable connection is needed with the console running the server so that it's able to provide the game resources on demand.

## Usage instructions
1) Download the `.cia` or `.3dsx` file from the [releases page](https://github.com/PabloMK7/ArticBaseServer/releases) and install it.
2) Run the Artic Base Server application. Press A to confirm you want to start Artic Base.
3) Select the application you want to broadcast from the Home Menu.
4) On a compatible emulator, select the Artic Base option and enter the IP address displayed on your console.

NOTE: A recent version of Luma3DS (v13.1.1 or newer) is requires to use Artic Base Server. You can get it [here](https://github.com/LumaTeam/Luma3DS/releases/latest).

## Future Plans
This section lists features that Artic Base Server cannot currently provide. Some of these features may be added in the future.

### Things that might be implemented
- Play owned DLCs.
- Use the console as a controller itself.
- Broadcasting homebrew applications

### Things that will never be implemented
- Dump games, and any of its assets to persistent storage. This includes caching data between play sessions.
- Dump any kind of system data, such as keys, archives or console unique files. This includes caching data between play sessions.
- Using the Home Menu of the console that is running Artic Base Server and switching between games.

## License
MIT License

Copyright (c) 2024 PabloMK7

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## Credits
Artic Base uses icons from [flaticon](https://www.flaticon.com):
- <a href="https://www.flaticon.com/free-icons/igloo" title="igloo icons">Igloo icons created by smashingstocks - Flaticon</a>
- <a href="https://www.flaticon.com/free-icons/parabolic-dishes" title="parabolic dishes icons">Parabolic dishes icons created by Souayang - Flaticon</a>

Artic Base uses text renders from [cooltext](https://cooltext.com/).
8 changes: 8 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/build
*.3gx
.vscode/
output/
*.map

includes/plugin.h
sources/plugin.c
82 changes: 82 additions & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# TARGET #


TARGET := 3DS
LIBRARY := 0

ifeq ($(TARGET),$(filter $(TARGET),3DS WIIU))
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
endif
endif

# COMMON CONFIGURATION #

NAME := Artic Base

BUILD_DIR := build
OUTPUT_DIR := output
SOURCE_DIRS := sources
INCLUDE_DIRS := $(SOURCE_DIRS) includes

EXTRA_OUTPUT_FILES :=

LIBRARY_DIRS := $(PORTLIBS) $(CTRULIB) $(DEVKITPRO)/libcwav $(DEVKITPRO)/libncsnd
LIBRARIES := ctru

VERSION_MAJOR := 1
VERSION_MINOR := 0
VERSION_MICRO := 0

BUILD_FLAGS := -march=armv6k -mtune=mpcore -mfloat-abi=hard
BUILD_FLAGS_CC := -g -Wall -Wno-strict-aliasing -O3 -mword-relocations \
-fomit-frame-pointer -ffast-math $(ARCH) $(INCLUDE) -D__3DS__ $(BUILD_FLAGS) \
-DVERSION_MAJOR=${VERSION_MAJOR} \
-DVERSION_MINOR=${VERSION_MINOR} \
-DVERSION_REVISION=${VERSION_MICRO}

BUILD_FLAGS_CXX := $(BUILD_FLAGS_CC) $(COMMON_FLAGS) -fno-rtti -fno-exceptions -std=gnu++20
RUN_FLAGS :=

# 3DS/Wii U CONFIGURATION #

ifeq ($(TARGET),$(filter $(TARGET),3DS WIIU))
TITLE := Artic Base
DESCRIPTION := 3DS Game Broadcaster
AUTHOR := PabloMK7
endif

# 3DS CONFIGURATION #

ifeq ($(TARGET),3DS)
LIBRARY_DIRS += $(DEVKITPRO)/libctru $(DEVKITPRO)/portlibs/3ds/
LIBRARIES += ctru

PRODUCT_CODE := CTR-P-ARBS
UNIQUE_ID := 0xABA5E

CATEGORY := Application
USE_ON_SD := true

MEMORY_TYPE := Application
SYSTEM_MODE := 64MB
SYSTEM_MODE_EXT := Legacy
CPU_SPEED := 268MHz
ENABLE_L2_CACHE := true

ICON_FLAGS := --flags visible,recordusage

BANNER_AUDIO := resources/audio.cwav

BANNER_IMAGE := resources/banner.png

ICON := resources/icon.png

endif

# INTERNAL #

include buildtools/make_base

re : clean all
.PHONY: re
10 changes: 10 additions & 0 deletions app/buildtools/.buildconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[default]
name=Default
runtime=host
config-opts=
run-opts=
prefix=/home/steven/.cache/gnome-builder/install/buildtools/host
app-id=
postbuild=
prebuild=
default=true
Binary file added app/buildtools/3ds/logo.bcma.lz
Binary file not shown.
92 changes: 92 additions & 0 deletions app/buildtools/3ds/servefiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python
# coding: utf-8 -*-

import os
import socket
import struct
import sys
import threading
import time
import urllib

try:
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer
from urlparse import urljoin
from urllib import pathname2url, quote
except ImportError:
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer
from urllib.parse import urljoin, quote
from urllib.request import pathname2url

if len(sys.argv) < 3 or len(sys.argv) > 5:
print('Usage: ' + sys.argv[0] + ' <target ip> <file / directory> [host ip] [host port]')
sys.exit(1)

accepted_extension = ('.cia', '.tik', '.cetk')
target_ip = sys.argv[1]
target_path = sys.argv[2]
hostPort = 8080 # Default value

if not os.path.exists(target_path):
print(target_path + ': No such file or directory.')
sys.exit(1)

if len(sys.argv) >= 4:
hostIp = sys.argv[3]
if len(sys.argv) == 5:
hostPort = int(sys.argv[4])
else:
print('Detecting host IP...')
hostIp = [(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]

print('Preparing data...')
baseUrl = hostIp + ':' + str(hostPort) + '/'

if os.path.isfile(target_path):
if target_path.endswith(accepted_extension):
file_list_payload = baseUrl + quote(os.path.basename(target_path))
directory = os.path.dirname(target_path) # get file directory
else:
print('Unsupported file extension. Supported extensions are: ' + accepted_extension)
sys.exit(1)

else:
directory = target_path # it's a directory
file_list_payload = '' # init the payload before adding lines
for file in [file for file in next(os.walk(target_path))[2] if file.endswith(accepted_extension)]:
file_list_payload += baseUrl + quote(file) + '\n'

if len(file_list_payload) == 0:
print('No files to serve.')
sys.exit(1)

file_list_payloadBytes = file_list_payload.encode('ascii')

if directory and directory != '.': # doesn't need to move if it's already the current working directory
os.chdir(directory) # set working directory to the right folder to be able to serve files

print('\nURLs:')
print(file_list_payload + '\n')

print('Opening HTTP server on port ' + str(hostPort))
server = TCPServer(('', hostPort), SimpleHTTPRequestHandler)
thread = threading.Thread(target=server.serve_forever)
thread.start()

try:
print('Sending URL(s) to ' + target_ip + ' on port 5000...')
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((target_ip, 5000))
sock.sendall(struct.pack('!L', len(file_list_payloadBytes)) + file_list_payloadBytes)
while len(sock.recv(1)) < 1:
time.sleep(0.05)
sock.close()
except Exception as e:
print('An error occurred: ' + str(e))
server.shutdown()
sys.exit(1)

print('Shutting down HTTP server...')
server.shutdown()
Loading

0 comments on commit 19a46a8

Please sign in to comment.