mirror of
https://github.com/XorTroll/3dJS.git
synced 2024-11-27 04:00:21 +00:00
Remake repos
This commit is contained in:
parent
b7f094dd3d
commit
a9929bd659
BIN
Banner.png
Normal file
BIN
Banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
36
Makefile
Normal file
36
Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
TARGET := 3DS
|
||||
LIBRARY := 0
|
||||
|
||||
ifeq ($(TARGET),3DS)
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
endif
|
||||
|
||||
BUILD_DIR := build
|
||||
OUTPUT_DIR := output
|
||||
INCLUDE_DIRS := include
|
||||
SOURCE_DIRS := source
|
||||
LIBRARY_DIRS := $(DEVKITPRO)/libctru
|
||||
LIBRARIES := ctru m
|
||||
|
||||
NAME := 3dJS
|
||||
|
||||
TITLE := 3dJS - beta 2
|
||||
DESCRIPTION := 3dJS - JavaScript interpreter for 3DS
|
||||
AUTHOR := XorTroll
|
||||
PRODUCT_CODE := CTR-P-AJSP
|
||||
UNIQUE_ID := 0xABFF
|
||||
|
||||
SYSTEM_MODE := 64MB
|
||||
SYSTEM_MODE_EXT := Legacy
|
||||
|
||||
BANNER_AUDIO := Sfx.wav
|
||||
BANNER_IMAGE := Banner.png
|
||||
ICON := Icon.png
|
||||
|
||||
include buildtools/make_base
|
BIN
buildtools/3ds/bannertool-linux32
Normal file
BIN
buildtools/3ds/bannertool-linux32
Normal file
Binary file not shown.
BIN
buildtools/3ds/bannertool-linux64
Normal file
BIN
buildtools/3ds/bannertool-linux64
Normal file
Binary file not shown.
BIN
buildtools/3ds/bannertool-mac32
Normal file
BIN
buildtools/3ds/bannertool-mac32
Normal file
Binary file not shown.
BIN
buildtools/3ds/bannertool-mac64
Normal file
BIN
buildtools/3ds/bannertool-mac64
Normal file
Binary file not shown.
BIN
buildtools/3ds/bannertool32.exe
Normal file
BIN
buildtools/3ds/bannertool32.exe
Normal file
Binary file not shown.
BIN
buildtools/3ds/bannertool64.exe
Normal file
BIN
buildtools/3ds/bannertool64.exe
Normal file
Binary file not shown.
37
buildtools/3ds/citra/README.md
Normal file
37
buildtools/3ds/citra/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
**BEFORE FILING AN ISSUE, READ THE RELEVANT SECTION IN THE [CONTRIBUTING](https://github.com/citra-emu/citra/blob/master/CONTRIBUTING.md#reporting-issues) FILE!!!**
|
||||
|
||||
Citra Emulator
|
||||
==============
|
||||
[![Travis CI Build Status](https://travis-ci.org/citra-emu/citra.svg?branch=master)](https://travis-ci.org/citra-emu/citra)
|
||||
[![AppVeyor CI Build Status](https://ci.appveyor.com/api/projects/status/sdf1o4kh3g1e68m9?svg=true)](https://ci.appveyor.com/project/bunnei/citra)
|
||||
|
||||
Citra is an experimental open-source Nintendo 3DS emulator/debugger written in C++. It is written with portability in mind, with builds actively maintained for Windows, Linux and macOS. Citra only emulates a subset of 3DS hardware, and therefore is generally only useful for running/debugging homebrew applications. At this time, Citra is even able to boot several commercial games! Most of these do not run to a playable state, but we are working every day to advance the project forward.
|
||||
|
||||
Citra is licensed under the GPLv2 (or any later version). Refer to the license.txt file included. Please read the [FAQ](https://github.com/citra-emu/citra/wiki/FAQ) before getting started with the project.
|
||||
|
||||
Check out our [website](https://citra-emu.org/)!
|
||||
|
||||
For development discussion, please join us @ #citra on freenode.
|
||||
|
||||
### Development
|
||||
|
||||
Most of the development happens on GitHub. It's also where [our central repository](https://github.com/citra-emu/citra) is hosted.
|
||||
|
||||
If you want to contribute please take a look at the [Contributor's Guide](CONTRIBUTING.md), [TODO list](https://docs.google.com/document/d/1SWIop0uBI9IW8VGg97TAtoT_CHNoP42FzYmvG1F4QDA) and [Developer Information](https://github.com/citra-emu/citra/wiki/Developer-Information). You should as well contact any of the developers in the forum in order to know about the current state of the emulator.
|
||||
|
||||
### Building
|
||||
|
||||
* __Windows__: [Windows Build](https://github.com/citra-emu/citra/wiki/Building-For-Windows)
|
||||
* __Linux__: [Linux Build](https://github.com/citra-emu/citra/wiki/Building-For-Linux)
|
||||
* __macOS__: [macOS Build](https://github.com/citra-emu/citra/wiki/Building-for-macOS)
|
||||
|
||||
|
||||
### Support
|
||||
We happily accept monetary donations, or donated games and hardware. Please see our [donations page](https://citra-emu.org/page/donate) for more information on how you can contribute to Citra. Any donations received will go towards things like:
|
||||
* 3DS consoles for developers to explore the hardware
|
||||
* 3DS games for testing
|
||||
* Any equipment required for homebrew
|
||||
* Infrastructure setup
|
||||
* Eventually 3D displays to get proper 3D output working
|
||||
|
||||
We also more than gladly accept used 3DS consoles, preferably ones with firmware 4.5 or lower! If you would like to give yours away, don't hesitate to join our IRC channel #citra on [Freenode](http://webchat.freenode.net/?channels=citra) and talk to neobrain or bunnei. Mind you, IRC is slow-paced, so it might be a while until people reply. If you're in a hurry you can just leave contact details in the channel or via private message and we'll get back to you.
|
BIN
buildtools/3ds/citra/SDL2.dll
Normal file
BIN
buildtools/3ds/citra/SDL2.dll
Normal file
Binary file not shown.
BIN
buildtools/3ds/citra/citra-linux64
Normal file
BIN
buildtools/3ds/citra/citra-linux64
Normal file
Binary file not shown.
BIN
buildtools/3ds/citra/citra-mac64
Normal file
BIN
buildtools/3ds/citra/citra-mac64
Normal file
Binary file not shown.
BIN
buildtools/3ds/citra/citra64.exe
Normal file
BIN
buildtools/3ds/citra/citra64.exe
Normal file
Binary file not shown.
BIN
buildtools/3ds/citra/libs/libSDL2-2.0.0.dylib
Normal file
BIN
buildtools/3ds/citra/libs/libSDL2-2.0.0.dylib
Normal file
Binary file not shown.
BIN
buildtools/3ds/citra/libs/libpng16.16.dylib
Normal file
BIN
buildtools/3ds/citra/libs/libpng16.16.dylib
Normal file
Binary file not shown.
339
buildtools/3ds/citra/license.txt
Normal file
339
buildtools/3ds/citra/license.txt
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
BIN
buildtools/3ds/logo.bcma.lz
Normal file
BIN
buildtools/3ds/logo.bcma.lz
Normal file
Binary file not shown.
BIN
buildtools/3ds/makerom-linux32
Normal file
BIN
buildtools/3ds/makerom-linux32
Normal file
Binary file not shown.
BIN
buildtools/3ds/makerom-linux64
Normal file
BIN
buildtools/3ds/makerom-linux64
Normal file
Binary file not shown.
BIN
buildtools/3ds/makerom-mac32
Normal file
BIN
buildtools/3ds/makerom-mac32
Normal file
Binary file not shown.
BIN
buildtools/3ds/makerom-mac64
Normal file
BIN
buildtools/3ds/makerom-mac64
Normal file
Binary file not shown.
BIN
buildtools/3ds/makerom32.exe
Normal file
BIN
buildtools/3ds/makerom32.exe
Normal file
Binary file not shown.
BIN
buildtools/3ds/makerom64.exe
Normal file
BIN
buildtools/3ds/makerom64.exe
Normal file
Binary file not shown.
92
buildtools/3ds/servefiles.py
Normal file
92
buildtools/3ds/servefiles.py
Normal file
@ -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()
|
285
buildtools/3ds/template.rsf
Normal file
285
buildtools/3ds/template.rsf
Normal file
@ -0,0 +1,285 @@
|
||||
BasicInfo:
|
||||
Title : $(APP_TITLE)
|
||||
ProductCode : $(APP_PRODUCT_CODE)
|
||||
Logo : Homebrew
|
||||
|
||||
RomFs:
|
||||
RootPath: $(APP_ROMFS)
|
||||
|
||||
TitleInfo:
|
||||
Category : $(APP_CATEGORY)
|
||||
UniqueId : $(APP_UNIQUE_ID)
|
||||
|
||||
Option:
|
||||
UseOnSD : $(APP_USE_ON_SD) # true if App is to be installed to SD
|
||||
FreeProductCode : true # Removes limitations on ProductCode
|
||||
MediaFootPadding : false # If true CCI files are created with padding
|
||||
EnableCrypt : $(APP_ENCRYPTED) # Enables encryption for NCCH and CIA
|
||||
EnableCompress : true # Compresses where applicable (currently only exefs:/.code)
|
||||
|
||||
AccessControlInfo:
|
||||
CoreVersion : 2
|
||||
|
||||
# Exheader Format Version
|
||||
DescVersion : 2
|
||||
|
||||
# Minimum Required Kernel Version (below is for 4.5.0)
|
||||
ReleaseKernelMajor : "02"
|
||||
ReleaseKernelMinor : "33"
|
||||
|
||||
# ExtData
|
||||
UseExtSaveData : false # enables ExtData
|
||||
#ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId
|
||||
|
||||
# FS:USER Archive Access Permissions
|
||||
# Uncomment as required
|
||||
FileSystemAccess:
|
||||
- CategorySystemApplication
|
||||
- CategoryHardwareCheck
|
||||
- CategoryFileSystemTool
|
||||
- Debug
|
||||
- TwlCardBackup
|
||||
- TwlNandData
|
||||
- Boss
|
||||
- DirectSdmc
|
||||
- Core
|
||||
- CtrNandRo
|
||||
- CtrNandRw
|
||||
- CtrNandRoWrite
|
||||
- CategorySystemSettings
|
||||
- CardBoard
|
||||
- ExportImportIvs
|
||||
- DirectSdmcWrite
|
||||
- SwitchCleanup
|
||||
- SaveDataMove
|
||||
- Shop
|
||||
- Shell
|
||||
- CategoryHomeMenu
|
||||
- SeedDB
|
||||
IoAccessControl:
|
||||
- FsMountNand
|
||||
- FsMountNandRoWrite
|
||||
- FsMountTwln
|
||||
- FsMountWnand
|
||||
- FsMountCardSpi
|
||||
- UseSdif3
|
||||
- CreateSeed
|
||||
- UseCardSpi
|
||||
|
||||
# Process Settings
|
||||
MemoryType : $(APP_MEMORY_TYPE) # Application/System/Base
|
||||
SystemMode : $(APP_SYSTEM_MODE) # 64MB(Default)/96MB/80MB/72MB/32MB
|
||||
IdealProcessor : 0
|
||||
AffinityMask : 1
|
||||
Priority : 16
|
||||
MaxCpu : 0x9E # Default
|
||||
HandleTableSize : 0x200
|
||||
DisableDebug : false
|
||||
EnableForceDebug : false
|
||||
CanWriteSharedPage : true
|
||||
CanUsePrivilegedPriority : false
|
||||
CanUseNonAlphabetAndNumber : true
|
||||
PermitMainFunctionArgument : true
|
||||
CanShareDeviceMemory : true
|
||||
RunnableOnSleep : false
|
||||
SpecialMemoryArrange : true
|
||||
|
||||
# New3DS Exclusive Process Settings
|
||||
SystemModeExt : $(APP_SYSTEM_MODE_EXT) # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
|
||||
CpuSpeed : $(APP_CPU_SPEED) # 268MHz(Default)/804MHz
|
||||
EnableL2Cache : $(APP_ENABLE_L2_CACHE) # false(default)/true
|
||||
CanAccessCore2 : true
|
||||
|
||||
# Virtual Address Mappings
|
||||
IORegisterMapping:
|
||||
- 1ff00000-1ff7ffff # DSP memory
|
||||
MemoryMapping:
|
||||
- 1f000000-1f5fffff:r # VRAM
|
||||
|
||||
# Accessible SVCs, <Name>:<ID>
|
||||
SystemCallAccess:
|
||||
ControlMemory: 1
|
||||
QueryMemory: 2
|
||||
ExitProcess: 3
|
||||
GetProcessAffinityMask: 4
|
||||
SetProcessAffinityMask: 5
|
||||
GetProcessIdealProcessor: 6
|
||||
SetProcessIdealProcessor: 7
|
||||
CreateThread: 8
|
||||
ExitThread: 9
|
||||
SleepThread: 10
|
||||
GetThreadPriority: 11
|
||||
SetThreadPriority: 12
|
||||
GetThreadAffinityMask: 13
|
||||
SetThreadAffinityMask: 14
|
||||
GetThreadIdealProcessor: 15
|
||||
SetThreadIdealProcessor: 16
|
||||
GetCurrentProcessorNumber: 17
|
||||
Run: 18
|
||||
CreateMutex: 19
|
||||
ReleaseMutex: 20
|
||||
CreateSemaphore: 21
|
||||
ReleaseSemaphore: 22
|
||||
CreateEvent: 23
|
||||
SignalEvent: 24
|
||||
ClearEvent: 25
|
||||
CreateTimer: 26
|
||||
SetTimer: 27
|
||||
CancelTimer: 28
|
||||
ClearTimer: 29
|
||||
CreateMemoryBlock: 30
|
||||
MapMemoryBlock: 31
|
||||
UnmapMemoryBlock: 32
|
||||
CreateAddressArbiter: 33
|
||||
ArbitrateAddress: 34
|
||||
CloseHandle: 35
|
||||
WaitSynchronization1: 36
|
||||
WaitSynchronizationN: 37
|
||||
SignalAndWait: 38
|
||||
DuplicateHandle: 39
|
||||
GetSystemTick: 40
|
||||
GetHandleInfo: 41
|
||||
GetSystemInfo: 42
|
||||
GetProcessInfo: 43
|
||||
GetThreadInfo: 44
|
||||
ConnectToPort: 45
|
||||
SendSyncRequest1: 46
|
||||
SendSyncRequest2: 47
|
||||
SendSyncRequest3: 48
|
||||
SendSyncRequest4: 49
|
||||
SendSyncRequest: 50
|
||||
OpenProcess: 51
|
||||
OpenThread: 52
|
||||
GetProcessId: 53
|
||||
GetProcessIdOfThread: 54
|
||||
GetThreadId: 55
|
||||
GetResourceLimit: 56
|
||||
GetResourceLimitLimitValues: 57
|
||||
GetResourceLimitCurrentValues: 58
|
||||
GetThreadContext: 59
|
||||
Break: 60
|
||||
OutputDebugString: 61
|
||||
ControlPerformanceCounter: 62
|
||||
CreatePort: 71
|
||||
CreateSessionToPort: 72
|
||||
CreateSession: 73
|
||||
AcceptSession: 74
|
||||
ReplyAndReceive1: 75
|
||||
ReplyAndReceive2: 76
|
||||
ReplyAndReceive3: 77
|
||||
ReplyAndReceive4: 78
|
||||
ReplyAndReceive: 79
|
||||
BindInterrupt: 80
|
||||
UnbindInterrupt: 81
|
||||
InvalidateProcessDataCache: 82
|
||||
StoreProcessDataCache: 83
|
||||
FlushProcessDataCache: 84
|
||||
StartInterProcessDma: 85
|
||||
StopDma: 86
|
||||
GetDmaState: 87
|
||||
RestartDma: 88
|
||||
DebugActiveProcess: 96
|
||||
BreakDebugProcess: 97
|
||||
TerminateDebugProcess: 98
|
||||
GetProcessDebugEvent: 99
|
||||
ContinueDebugEvent: 100
|
||||
GetProcessList: 101
|
||||
GetThreadList: 102
|
||||
GetDebugThreadContext: 103
|
||||
SetDebugThreadContext: 104
|
||||
QueryDebugProcessMemory: 105
|
||||
ReadProcessMemory: 106
|
||||
WriteProcessMemory: 107
|
||||
SetHardwareBreakPoint: 108
|
||||
GetDebugThreadParam: 109
|
||||
ControlProcessMemory: 112
|
||||
MapProcessMemory: 113
|
||||
UnmapProcessMemory: 114
|
||||
CreateCodeSet: 115
|
||||
CreateProcess: 117
|
||||
TerminateProcess: 118
|
||||
SetProcessResourceLimits: 119
|
||||
CreateResourceLimit: 120
|
||||
SetResourceLimitValues: 121
|
||||
AddCodeSegment: 122
|
||||
Backdoor: 123
|
||||
KernelSetState: 124
|
||||
QueryProcessMemory: 125
|
||||
|
||||
# Service List
|
||||
# Maximum 34 services (32 if firmware is prior to 9.6.0)
|
||||
ServiceAccessControl:
|
||||
- APT:U
|
||||
- ac:u
|
||||
- am:net
|
||||
- boss:U
|
||||
- cam:u
|
||||
- cecd:u
|
||||
- cfg:nor
|
||||
- cfg:u
|
||||
- csnd:SND
|
||||
- dsp::DSP
|
||||
- frd:u
|
||||
- fs:USER
|
||||
- gsp::Gpu
|
||||
- gsp::Lcd
|
||||
- hid:USER
|
||||
- http:C
|
||||
- ir:rst
|
||||
- ir:u
|
||||
- ir:USER
|
||||
- mic:u
|
||||
- ndm:u
|
||||
- news:s
|
||||
- nwm::EXT
|
||||
- nwm::UDS
|
||||
- ptm:sysm
|
||||
- ptm:u
|
||||
- pxi:dev
|
||||
- soc:U
|
||||
- ssl:C
|
||||
- y2r:u
|
||||
|
||||
|
||||
SystemControlInfo:
|
||||
SaveDataSize: 0KB # Change if the app uses savedata
|
||||
RemasterVersion: $(APP_VERSION_MAJOR)
|
||||
StackSize: 0x40000
|
||||
|
||||
# Modules that run services listed above should be included below
|
||||
# Maximum 48 dependencies
|
||||
# <module name>:<module titleid>
|
||||
Dependency:
|
||||
ac: 0x0004013000002402
|
||||
#act: 0x0004013000003802
|
||||
am: 0x0004013000001502
|
||||
boss: 0x0004013000003402
|
||||
camera: 0x0004013000001602
|
||||
cecd: 0x0004013000002602
|
||||
cfg: 0x0004013000001702
|
||||
codec: 0x0004013000001802
|
||||
csnd: 0x0004013000002702
|
||||
dlp: 0x0004013000002802
|
||||
dsp: 0x0004013000001a02
|
||||
friends: 0x0004013000003202
|
||||
gpio: 0x0004013000001b02
|
||||
gsp: 0x0004013000001c02
|
||||
hid: 0x0004013000001d02
|
||||
http: 0x0004013000002902
|
||||
i2c: 0x0004013000001e02
|
||||
ir: 0x0004013000003302
|
||||
mcu: 0x0004013000001f02
|
||||
mic: 0x0004013000002002
|
||||
ndm: 0x0004013000002b02
|
||||
news: 0x0004013000003502
|
||||
#nfc: 0x0004013000004002
|
||||
nim: 0x0004013000002c02
|
||||
nwm: 0x0004013000002d02
|
||||
pdn: 0x0004013000002102
|
||||
ps: 0x0004013000003102
|
||||
ptm: 0x0004013000002202
|
||||
#qtm: 0x0004013020004202
|
||||
ro: 0x0004013000003702
|
||||
socket: 0x0004013000002e02
|
||||
spi: 0x0004013000002302
|
||||
ssl: 0x0004013000002f02
|
642
buildtools/make_base
Normal file
642
buildtools/make_base
Normal file
@ -0,0 +1,642 @@
|
||||
# PROLOGUE #
|
||||
|
||||
ALL_PC_TARGETS := WIN32 WIN64 MAC32 MAC64 LINUX32 LINUX64
|
||||
ALL_SPECIFIC_TARGETS := $(ALL_PC_TARGETS) 3DS WIIU
|
||||
ALL_TARGETS := NATIVE NATIVE32 NATIVE64 $(ALL_SPECIFIC_TARGETS)
|
||||
|
||||
TARGET ?= NATIVE
|
||||
TARGETS :=
|
||||
|
||||
ifneq (1,$(words $(TARGET)))
|
||||
TARGETS := $(TARGET)
|
||||
else ifeq ($(TARGET),ALL)
|
||||
TARGETS := $(ALL_SPECIFIC_TARGETS)
|
||||
else ifeq ($(TARGET),PC)
|
||||
TARGETS := $(ALL_PC_TARGETS)
|
||||
endif
|
||||
|
||||
ifneq ($(TARGETS),)
|
||||
|
||||
.PHONY: all clean
|
||||
all:
|
||||
@$(foreach target,$(TARGETS),make --no-print-directory TARGET=$(target);)
|
||||
|
||||
else
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
$(info Building for $(TARGET)...)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),$(filter $(TARGET),3DS WIIU))
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),3DS)
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),WIIU)
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
endif
|
||||
|
||||
# TOOLS #
|
||||
|
||||
BUILDTOOLS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
|
||||
define createdirrule
|
||||
$(1): | $(dir $(1))
|
||||
|
||||
ifndef $(dir $(1))_DIRECTORY_RULE_IS_DEFINED
|
||||
$(dir $(1)):
|
||||
@mkdir -p $$@
|
||||
|
||||
$(dir $(1))_DIRECTORY_RULE_IS_DEFINED := 1
|
||||
endif
|
||||
endef
|
||||
|
||||
rwildcard=$(wildcard $1/$2) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2))
|
||||
|
||||
# INITIAL COMMON SETUP #
|
||||
|
||||
EMPTY :=
|
||||
SPACE := $(EMPTY) $(EMPTY)
|
||||
STRIPPED_NAME := $(subst $(SPACE),,$(NAME))
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
HOST_OS := windows
|
||||
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
|
||||
HOST_ARCH := x86_64
|
||||
else
|
||||
HOST_ARCH := i686
|
||||
endif
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
HOST_OS := mac
|
||||
else ifeq ($(UNAME_S),Linux)
|
||||
HOST_OS := linux
|
||||
else
|
||||
$(error "Unsupported host OS.")
|
||||
endif
|
||||
|
||||
UNAME_M := $(shell uname -m)
|
||||
ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 amd64))
|
||||
HOST_ARCH := x86_64
|
||||
else ifeq ($(UNAME_M),$(filter $(UNAME_M),i386 i686))
|
||||
HOST_ARCH := i686
|
||||
else
|
||||
$(error "Unsupported host architecture.")
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),NATIVE)
|
||||
TARGET_OS := $(HOST_OS)
|
||||
TARGET_ARCH := $(HOST_ARCH)
|
||||
else ifeq ($(TARGET),NATIVE32)
|
||||
TARGET_OS := $(HOST_OS)
|
||||
TARGET_ARCH := i686
|
||||
else ifeq ($(TARGET),NATIVE64)
|
||||
TARGET_OS := $(HOST_OS)
|
||||
TARGET_ARCH := x86_64
|
||||
else ifeq ($(TARGET),WIN32)
|
||||
TARGET_OS := windows
|
||||
TARGET_ARCH := i686
|
||||
else ifeq ($(TARGET),WIN64)
|
||||
TARGET_OS := windows
|
||||
TARGET_ARCH := x86_64
|
||||
else ifeq ($(TARGET),LINUX32)
|
||||
TARGET_OS := linux
|
||||
TARGET_ARCH := i686
|
||||
else ifeq ($(TARGET),LINUX64)
|
||||
TARGET_OS := linux
|
||||
TARGET_ARCH := x86_64
|
||||
else ifeq ($(TARGET),MAC32)
|
||||
TARGET_OS := mac
|
||||
TARGET_ARCH := i686
|
||||
else ifeq ($(TARGET),MAC64)
|
||||
TARGET_OS := mac
|
||||
TARGET_ARCH := x86_64
|
||||
else ifeq ($(TARGET),3DS)
|
||||
TARGET_OS := 3ds
|
||||
TARGET_ARCH := arm
|
||||
else ifeq ($(TARGET),WIIU)
|
||||
TARGET_OS := wiiu
|
||||
TARGET_ARCH := ppc
|
||||
else
|
||||
$(error "Unknown target. Supported targets: $(ALL_TARGETS)")
|
||||
endif
|
||||
|
||||
TARGET_BUILD_DIR := $(BUILD_DIR)
|
||||
TARGET_OUTPUT_DIR := $(OUTPUT_DIR)
|
||||
|
||||
BUILT_FILTER := $(patsubst %.bin,$(TARGET_BUILD_DIR)/%.bin.o,$(BUILD_FILTER)) \
|
||||
$(patsubst %.c,$(TARGET_BUILD_DIR)/%.o,$(BUILD_FILTER)) \
|
||||
$(patsubst %.cpp,$(TARGET_BUILD_DIR)/%.o,$(BUILD_FILTER)) \
|
||||
$(patsubst %.s,$(TARGET_BUILD_DIR)/%.o,$(BUILD_FILTER))
|
||||
|
||||
OBJECT_FILES := $(foreach dir,$(SOURCE_DIRS), \
|
||||
$(patsubst %.bin,$(TARGET_BUILD_DIR)/%.bin.o,$(call rwildcard,$(dir),*.bin)) \
|
||||
$(patsubst %.c,$(TARGET_BUILD_DIR)/%.o,$(call rwildcard,$(dir),*.c)) \
|
||||
$(patsubst %.cpp,$(TARGET_BUILD_DIR)/%.o,$(call rwildcard,$(dir),*.cpp)) \
|
||||
$(patsubst %.s,$(TARGET_BUILD_DIR)/%.o,$(call rwildcard,$(dir),*.s)) \
|
||||
)
|
||||
|
||||
OBJECT_FILES := $(filter-out $(BUILT_FILTER),$(OBJECT_FILES))
|
||||
|
||||
OUTPUT_ZIP_FILE ?= $(OUTPUT_DIR)/$(STRIPPED_NAME).zip
|
||||
|
||||
ifeq ($(strip $(VERSION_MAJOR)),)
|
||||
VERSION_MAJOR := 0
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(VERSION_MINOR)),)
|
||||
VERSION_MINOR := 0
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(VERSION_MICRO)),)
|
||||
VERSION_MICRO := 0
|
||||
endif
|
||||
|
||||
LD_FLAGS := $(patsubst %,-L%/lib,$(LIBRARY_DIRS)) $(patsubst %,-l%,$(LIBRARIES))
|
||||
COMMON_CC_FLAGS := $(sort $(foreach dir,$(SOURCE_DIRS),$(patsubst %,-I$(TARGET_BUILD_DIR)/%,$(dir $(call rwildcard,$(dir),*))))) $(patsubst %,-I%,$(INCLUDE_DIRS)) $(patsubst %,-I%/include,$(LIBRARY_DIRS)) -g -Wall -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) $(BUILD_FLAGS)
|
||||
|
||||
ifeq ($(findstring -O,$(BUILD_FLAGS)),)
|
||||
COMMON_CC_FLAGS += -O2
|
||||
endif
|
||||
|
||||
# COMMON LIBRARY SETUP #
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
STRIPPED_NAME := lib$(STRIPPED_NAME)
|
||||
EXTRA_OUTPUT_FILES += $(INCLUDE_DIRS)
|
||||
endif
|
||||
|
||||
# TARGET SETUP #
|
||||
|
||||
ifeq ($(TARGET_OS),windows)
|
||||
ifeq ($(HOST_OS),windows)
|
||||
AR := ar
|
||||
AS := as
|
||||
CC := gcc
|
||||
CXX := g++
|
||||
else ifeq ($(TARGET_ARCH),i686)
|
||||
AR := i686-w64-mingw32-ar
|
||||
AS := i686-w64-mingw32-as
|
||||
CC := i686-w64-mingw32-gcc
|
||||
CXX := i686-w64-mingw32-g++
|
||||
else ifeq ($(TARGET_ARCH),x86_64)
|
||||
AR := x86_64-w64-mingw32-ar
|
||||
AS := x86_64-w64-mingw32-as
|
||||
CC := x86_64-w64-mingw32-gcc
|
||||
CXX := x86_64-w64-mingw32-g++
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),i686)
|
||||
COMMON_CC_FLAGS += -m32
|
||||
else ifeq ($(TARGET_ARCH),x86_64)
|
||||
COMMON_CC_FLAGS += -m64
|
||||
endif
|
||||
|
||||
LD_FLAGS += -static-libstdc++ -static-libgcc -static
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).a $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).dll
|
||||
COMMON_CC_FLAGS += -fPIC
|
||||
else
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).exe
|
||||
endif
|
||||
else ifeq ($(TARGET_OS),mac)
|
||||
ifeq ($(HOST_OS),mac)
|
||||
AR := ar
|
||||
AS := as
|
||||
CC := gcc
|
||||
CXX := g++
|
||||
else ifeq ($(TARGET_ARCH),i686)
|
||||
AR := i386-apple-darwin15-ar
|
||||
AS := i386-apple-darwin15-as
|
||||
CC := i386-apple-darwin15-gcc
|
||||
CXX := i386-apple-darwin15-g++
|
||||
else ifeq ($(TARGET_ARCH),x86_64)
|
||||
AR := x86_64-apple-darwin15-ar
|
||||
AS := x86_64-apple-darwin15-as
|
||||
CC := x86_64-apple-darwin15-gcc
|
||||
CXX := x86_64-apple-darwin15-g++
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),i686)
|
||||
COMMON_CC_FLAGS += -m32
|
||||
else ifeq ($(TARGET_ARCH),x86_64)
|
||||
COMMON_CC_FLAGS += -m64
|
||||
endif
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).a $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).so $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).dylib
|
||||
COMMON_CC_FLAGS += -fPIC
|
||||
else
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME)
|
||||
endif
|
||||
else ifeq ($(TARGET_OS),linux)
|
||||
ifeq ($(HOST_OS),linux)
|
||||
AR := ar
|
||||
AS := as
|
||||
CC := gcc
|
||||
CXX := g++
|
||||
else ifeq ($(TARGET_ARCH),i686)
|
||||
AR := i686-pc-linux-gnu-ar
|
||||
AS := i686-pc-linux-gnu-as
|
||||
CC := i686-pc-linux-gnu-gcc
|
||||
CXX := i686-pc-linux-gnu-g++
|
||||
else ifeq ($(TARGET_ARCH),x86_64)
|
||||
AR := x86_64-pc-linux-gnu-ar
|
||||
AS := x86_64-pc-linux-gnu-as
|
||||
CC := x86_64-pc-linux-gnu-gcc
|
||||
CXX := x86_64-pc-linux-gnu-g++
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),i686)
|
||||
COMMON_CC_FLAGS += -m32
|
||||
else ifeq ($(TARGET_ARCH),x86_64)
|
||||
COMMON_CC_FLAGS += -m64
|
||||
endif
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).a $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).so
|
||||
COMMON_CC_FLAGS += -fPIC
|
||||
else
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME)
|
||||
endif
|
||||
else ifeq ($(TARGET_OS),3ds)
|
||||
BUILT_FILTER := $(patsubst %.v.pica,$(TARGET_BUILD_DIR)/%.shbin.o,$(BUILD_FILTER)) \
|
||||
$(patsubst %.shlist,$(TARGET_BUILD_DIR)/%.shbin.o,$(BUILD_FILTER)) \
|
||||
|
||||
OBJECT_FILES := $(foreach dir,$(SOURCE_DIRS), \
|
||||
$(patsubst %.v.pica,$(TARGET_BUILD_DIR)/%.shbin.o,$(call rwildcard,$(dir),*.v.pica)) \
|
||||
$(patsubst %.shlist,$(TARGET_BUILD_DIR)/%.shbin.o,$(call rwildcard,$(dir),*.shlist)) \
|
||||
) $(OBJECT_FILES)
|
||||
|
||||
OBJECT_FILES := $(filter-out $(BUILT_FILTER),$(OBJECT_FILES))
|
||||
|
||||
REMOTE_IP ?= 127.0.0.1 # User-defined
|
||||
|
||||
TITLE ?= $(NAME)
|
||||
|
||||
CATEGORY ?= Application
|
||||
USE_ON_SD ?= true
|
||||
MEMORY_TYPE ?= Application
|
||||
CPU_SPEED ?= 268MHz
|
||||
ENABLE_L2_CACHE ?= true
|
||||
|
||||
AR := $(DEVKITARM)/bin/arm-none-eabi-ar
|
||||
AS := $(DEVKITARM)/bin/arm-none-eabi-as
|
||||
CC := $(DEVKITARM)/bin/arm-none-eabi-gcc
|
||||
CXX := $(DEVKITARM)/bin/arm-none-eabi-g++
|
||||
|
||||
PICASSO := $(DEVKITARM)/bin/picasso
|
||||
SMDHTOOL := $(DEVKITARM)/bin/smdhtool
|
||||
_3DSXTOOL := $(DEVKITARM)/bin/3dsxtool
|
||||
_3DSLINK := $(DEVKITARM)/bin/3dslink
|
||||
|
||||
SERVEFILES := python $(BUILDTOOLS_DIR)/3ds/servefiles.py
|
||||
|
||||
ifeq ($(HOST_OS),windows)
|
||||
ifeq ($(HOST_ARCH),x86_64)
|
||||
MAKEROM := $(BUILDTOOLS_DIR)/3ds/makerom64.exe
|
||||
BANNERTOOL := $(BUILDTOOLS_DIR)/3ds/bannertool64.exe
|
||||
CITRA := $(BUILDTOOLS_DIR)/3ds/citra/citra64.exe
|
||||
else
|
||||
MAKEROM := $(BUILDTOOLS_DIR)/3ds/makerom32.exe
|
||||
BANNERTOOL := $(BUILDTOOLS_DIR)/3ds/bannertool32.exe
|
||||
CITRA := $(BUILDTOOLS_DIR)/3ds/citra/citra32.exe
|
||||
endif
|
||||
else ifeq ($(HOST_OS),mac)
|
||||
ifeq ($(HOST_ARCH),x86_64)
|
||||
MAKEROM := $(BUILDTOOLS_DIR)/3ds/makerom-mac64
|
||||
BANNERTOOL := $(BUILDTOOLS_DIR)/3ds/bannertool-mac64
|
||||
CITRA := $(BUILDTOOLS_DIR)/3ds/citra/citra-mac64
|
||||
else
|
||||
MAKEROM := $(BUILDTOOLS_DIR)/3ds/makerom-mac32
|
||||
BANNERTOOL := $(BUILDTOOLS_DIR)/3ds/bannertool-mac32
|
||||
CITRA := $(BUILDTOOLS_DIR)/3ds/citra/citra-mac32
|
||||
endif
|
||||
else ifeq ($(HOST_OS),linux)
|
||||
ifeq ($(HOST_ARCH),x86_64)
|
||||
MAKEROM := $(BUILDTOOLS_DIR)/3ds/makerom-linux64
|
||||
BANNERTOOL := $(BUILDTOOLS_DIR)/3ds/bannertool-linux64
|
||||
CITRA := $(BUILDTOOLS_DIR)/3ds/citra/citra-linux64
|
||||
else
|
||||
MAKEROM := $(BUILDTOOLS_DIR)/3ds/makerom-linux32
|
||||
BANNERTOOL := $(BUILDTOOLS_DIR)/3ds/bannertool-linux32
|
||||
CITRA := $(BUILDTOOLS_DIR)/3ds/citra/citra-linux32
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).a
|
||||
else
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).elf $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).3dsx $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).3ds $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).cia
|
||||
endif
|
||||
|
||||
LD_FLAGS += -specs=3dsx.specs
|
||||
COMMON_CC_FLAGS += -mword-relocations -fomit-frame-pointer -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -DARM11 -D_3DS
|
||||
|
||||
_3DSXTOOL_FLAGS :=
|
||||
COMMON_MAKEROM_FLAGS := -rsf $(BUILDTOOLS_DIR)/3ds/template.rsf -target t -exefslogo -icon $(TARGET_BUILD_DIR)/icon.icn -banner $(TARGET_BUILD_DIR)/banner.bnr -major $(VERSION_MAJOR) -minor $(VERSION_MINOR) -micro $(VERSION_MICRO) -DAPP_TITLE="$(TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)" -DAPP_SYSTEM_MODE="$(SYSTEM_MODE)" -DAPP_SYSTEM_MODE_EXT="$(SYSTEM_MODE_EXT)" -DAPP_CATEGORY="$(CATEGORY)" -DAPP_USE_ON_SD="$(USE_ON_SD)" -DAPP_MEMORY_TYPE="$(MEMORY_TYPE)" -DAPP_CPU_SPEED="$(CPU_SPEED)" -DAPP_ENABLE_L2_CACHE="$(ENABLE_L2_CACHE)" -DAPP_VERSION_MAJOR="$(VERSION_MAJOR)"
|
||||
|
||||
ifneq ("$(wildcard $(ROMFS_DIR))","")
|
||||
_3DSXTOOL_FLAGS += --romfs=$(ROMFS_DIR)
|
||||
COMMON_MAKEROM_FLAGS += -DAPP_ROMFS="$(ROMFS_DIR)"
|
||||
endif
|
||||
|
||||
ifneq ("$(wildcard $(LOGO))","")
|
||||
COMMON_MAKEROM_FLAGS += -logo "$(LOGO)"
|
||||
else ifneq ($(LOGO),plain)
|
||||
COMMON_MAKEROM_FLAGS += -logo "$(BUILDTOOLS_DIR)/3ds/logo.bcma.lz"
|
||||
endif
|
||||
|
||||
ifeq ($(suffix $(BANNER_IMAGE)),.cgfx)
|
||||
BANNER_IMAGE_ARG := -ci
|
||||
else
|
||||
BANNER_IMAGE_ARG := -i
|
||||
endif
|
||||
|
||||
ifeq ($(suffix $(BANNER_AUDIO)),.cwav)
|
||||
BANNER_AUDIO_ARG := -ca
|
||||
else
|
||||
BANNER_AUDIO_ARG := -a
|
||||
endif
|
||||
else ifeq ($(TARGET_OS),wiiu)
|
||||
REMOTE_IP ?= 127.0.0.1 # User-defined
|
||||
|
||||
AR := $(DEVKITPPC)/bin/powerpc-eabi-ar
|
||||
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
|
||||
CC := $(DEVKITPPC)/bin/powerpc-eabi-gcc
|
||||
CXX := $(DEVKITPPC)/bin/powerpc-eabi-g++
|
||||
|
||||
WIILOAD_BIN := $(DEVKITPPC)/bin/wiiload
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/lib/$(STRIPPED_NAME).a
|
||||
else
|
||||
OUTPUT_FILES := $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/$(STRIPPED_NAME).elf $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/icon.png
|
||||
endif
|
||||
|
||||
LD_FLAGS += -Wl,-d,--gc-sections
|
||||
COMMON_CC_FLAGS += -mwup -mcpu=750 -meabi -mhard-float -ffast-math -DESPRESSO -DWIIU
|
||||
endif
|
||||
|
||||
# FINAL COMMON SETUP #
|
||||
|
||||
CC_FLAGS := $(COMMON_CC_FLAGS) $(BUILD_FLAGS_CC)
|
||||
CXX_FLAGS := $(COMMON_CC_FLAGS) $(BUILD_FLAGS_CXX)
|
||||
|
||||
ifeq ($(findstring -std,$(BUILD_FLAGS_CC)),)
|
||||
CC_FLAGS += -std=gnu99
|
||||
endif
|
||||
|
||||
ifeq ($(findstring -std,$(BUILD_FLAGS_CXX)),)
|
||||
CXX_FLAGS += -std=gnu++11
|
||||
endif
|
||||
|
||||
ifneq ($(EXTRA_OUTPUT_FILES),)
|
||||
EXTRA_OUTPUT_COPY_CMD := cp -r $(EXTRA_OUTPUT_FILES) $(OUTPUT_DIR)
|
||||
endif
|
||||
|
||||
# MAIN RULES #
|
||||
|
||||
.PHONY: all run install clean
|
||||
|
||||
all: $(OUTPUT_ZIP_FILE)
|
||||
|
||||
# TARGET RULES #
|
||||
|
||||
ifeq ($(TARGET_OS),3ds)
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
|
||||
install: $(OUTPUT_ZIP_FILE)
|
||||
@mkdir -p $(DEVKITPRO)/$(STRIPPED_NAME)
|
||||
@cp -r $(TARGET_OUTPUT_DIR)/* $(DEVKITPRO)/$(STRIPPED_NAME)
|
||||
@echo "Installed."
|
||||
|
||||
else
|
||||
|
||||
run: $(OUTPUT_ZIP_FILE)
|
||||
@echo "Running..."
|
||||
@$(CITRA) $(RUN_FLAGS) $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).3dsx
|
||||
|
||||
runhw: $(OUTPUT_ZIP_FILE)
|
||||
@echo "Running..."
|
||||
@$(_3DSLINK) --address $(REMOTE_IP) $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).3dsx
|
||||
|
||||
install: $(OUTPUT_ZIP_FILE)
|
||||
@echo "Installing..."
|
||||
@$(SERVEFILES) $(REMOTE_IP) $(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME).cia
|
||||
@echo "Installed."
|
||||
|
||||
endif
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.shbin.o: $(TARGET_BUILD_DIR)/%.shbin.c
|
||||
@echo $@
|
||||
@$(CC) -c $(CC_FLAGS) -MMD -MP -MF $(TARGET_BUILD_DIR)/$*.d $< -o $@
|
||||
|
||||
define shader-as
|
||||
$(eval CURBIN := $(patsubst %.shbin.c,%.shbin,$@))
|
||||
$(PICASSO) -o $(CURBIN) $1
|
||||
@cd $(dir $(CURBIN)); \
|
||||
xxd -i $(notdir $(CURBIN)) "$(CURDIR)/$@"
|
||||
echo "extern const u8" `(echo $(notdir $(CURBIN)) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
echo "extern const u32" `(echo $(notdir $(CURBIN)) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_len";" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
endef
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.shbin.c: %.v.pica %.g.pica
|
||||
@echo $@
|
||||
@$(call shader-as,$^)
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.shbin.c: %.v.pica
|
||||
@echo $@
|
||||
@$(call shader-as,$<)
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.shbin.c: %.shlist
|
||||
@echo $@
|
||||
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
|
||||
|
||||
%.bnr: $(BANNER_IMAGE) $(BANNER_AUDIO)
|
||||
@echo $@
|
||||
@$(BANNERTOOL) makebanner $(BANNER_IMAGE_ARG) $(BANNER_IMAGE) $(BANNER_AUDIO_ARG) $(BANNER_AUDIO) -o $@ > /dev/null
|
||||
|
||||
%.icn: $(ICON)
|
||||
@echo $@
|
||||
@$(BANNERTOOL) makesmdh -s "$(TITLE)" -l "$(DESCRIPTION)" -p "$(AUTHOR)" -i $(ICON) $(ICON_FLAGS) -o $@ > /dev/null
|
||||
|
||||
%.smdh: $(ICON)
|
||||
@echo $@
|
||||
@$(SMDHTOOL) --create "$(TITLE)" "$(DESCRIPTION)" "$(AUTHOR)" $(ICON) $@
|
||||
|
||||
$(TARGET_OUTPUT_DIR)/%.3dsx: $(TARGET_OUTPUT_DIR)/%.elf $(TARGET_BUILD_DIR)/meta.smdh
|
||||
@echo $@
|
||||
@$(_3DSXTOOL) $< $@ --smdh=$(word 2,$^) $(_3DSXTOOL_FLAGS)
|
||||
|
||||
%.3ds: %.elf $(TARGET_BUILD_DIR)/banner.bnr $(TARGET_BUILD_DIR)/icon.icn
|
||||
@echo $@
|
||||
@$(MAKEROM) -f cci -o $@ -elf $< -DAPP_ENCRYPTED=true $(COMMON_MAKEROM_FLAGS)
|
||||
|
||||
%.cia: %.elf $(TARGET_BUILD_DIR)/banner.bnr $(TARGET_BUILD_DIR)/icon.icn
|
||||
@echo $@
|
||||
@$(MAKEROM) -f cia -o $@ -elf $< -DAPP_ENCRYPTED=false $(COMMON_MAKEROM_FLAGS)
|
||||
|
||||
else ifeq ($(TARGET_OS),wiiu)
|
||||
|
||||
ifeq ($(LIBRARY),1)
|
||||
|
||||
install: $(OUTPUT_ZIP_FILE)
|
||||
@mkdir -p $(DEVKITPRO)/$(STRIPPED_NAME)
|
||||
@cp -r $(TARGET_OUTPUT_DIR)/* $(DEVKITPRO)/$(STRIPPED_NAME)
|
||||
@echo "Installed."
|
||||
|
||||
else
|
||||
|
||||
runhw: $(OUTPUT_ZIP_FILE)
|
||||
@echo "Running..."
|
||||
@WIILOAD=tcp:$(REMOTE_IP) $(WIILOAD_BIN) $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/$(STRIPPED_NAME).elf $(RUN_FLAGS)
|
||||
|
||||
endif
|
||||
|
||||
$(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml:
|
||||
@echo $@
|
||||
@cp $(BUILDTOOLS_DIR)/wiiu/meta_template.xml $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml
|
||||
@sed -i -- 's/$$(TITLE)/$(subst /,\/,$(TITLE))/g' $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml
|
||||
@sed -i -- 's/$$(AUTHOR)/$(subst /,\/,$(AUTHOR))/g' $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml
|
||||
@sed -i -- 's/$$(VERSION)/$(subst /,\/,$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO))/g' $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml
|
||||
@sed -i -- 's/$$(RELEASE_DATE)/$(subst /,\/,$(shell date +'%Y%m%d%H%M%S'))/g' $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml
|
||||
@sed -i -- 's/$$(SHORT_DESCRIPTION)/$(subst /,\/,$(DESCRIPTION))/g' $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml
|
||||
@sed -i -- 's/$$(LONG_DESCRIPTION)/$(subst /,\/,$(LONG_DESCRIPTION))/g' $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/meta.xml
|
||||
|
||||
$(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/icon.png:
|
||||
@echo $@
|
||||
@cp $(ICON) $(TARGET_OUTPUT_DIR)/wiiu/apps/$(STRIPPED_NAME)/icon.png
|
||||
|
||||
else ifeq ($(TARGET_OS),windows)
|
||||
ifeq ($(HOST_OS),$(filter $(HOST_OS),linux mac))
|
||||
ifneq ($(LIBRARY),1)
|
||||
|
||||
run: $(OUTPUT_FILES) $(OUTPUT_ZIP_FILE)
|
||||
@echo "Running..."
|
||||
@wine ./$< $(RUN_FLAGS)
|
||||
|
||||
endif
|
||||
else ifeq ($(HOST_OS),windows)
|
||||
ifneq ($(LIBRARY),1)
|
||||
|
||||
run: $(OUTPUT_FILES) $(OUTPUT_ZIP_FILE)
|
||||
@echo "Running..."
|
||||
@./$< $(RUN_FLAGS)
|
||||
|
||||
endif
|
||||
endif
|
||||
else ifeq ($(TARGET_OS),$(filter $(TARGET_OS),mac linux))
|
||||
ifeq ($(HOST_OS),$(TARGET_OS))
|
||||
ifeq ($(LIBRARY),1)
|
||||
|
||||
install: $(OUTPUT_ZIP_FILE)
|
||||
@install -m 0755 $(OUTPUT_FILES) /usr/local/lib
|
||||
@install -m 0644 $(foreach dir,$(INCLUDE_DIRS),$(wildcard $(dir)/*)) /usr/local/include
|
||||
@echo "Installed."
|
||||
|
||||
else
|
||||
|
||||
run: $(OUTPUT_FILES) $(OUTPUT_ZIP_FILE)
|
||||
@echo "Running..."
|
||||
@./$< $(RUN_FLAGS)
|
||||
|
||||
install: $(OUTPUT_ZIP_FILE)
|
||||
@install -m 0755 $(OUTPUT_FILES) /usr/local/bin
|
||||
@echo "Installed."
|
||||
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# COMMON RULES #
|
||||
|
||||
$(OUTPUT_ZIP_FILE): $(OUTPUT_FILES) $(EXTRA_OUTPUT_FILES)
|
||||
@echo $@
|
||||
@$(EXTRA_OUTPUT_COPY_CMD)
|
||||
@cd $(OUTPUT_DIR); \
|
||||
zip -r $(patsubst $(OUTPUT_DIR)/%,%,$@ * -x $(OUTPUT_ZIP_FILE)) > /dev/null
|
||||
|
||||
$(TARGET_OUTPUT_DIR)/$(STRIPPED_NAME): $(OBJECT_FILES)
|
||||
@echo $@
|
||||
@$(CXX) $(CXX_FLAGS) $^ -o $@ $(LD_FLAGS)
|
||||
|
||||
%.elf: $(OBJECT_FILES)
|
||||
@echo $@
|
||||
@$(CXX) $(CXX_FLAGS) $^ -o $@ $(LD_FLAGS)
|
||||
|
||||
%.a: $(OBJECT_FILES)
|
||||
@echo $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
%.so: $(OBJECT_FILES)
|
||||
@echo $@
|
||||
@$(CXX) $(CXX_FLAGS) -shared $^ -o $@ $(LD_FLAGS)
|
||||
|
||||
%.exe: $(OBJECT_FILES)
|
||||
@echo $@
|
||||
@$(CXX) $(CXX_FLAGS) $^ -o $@ $(LD_FLAGS)
|
||||
|
||||
%.dll: $(OBJECT_FILES)
|
||||
@echo $@
|
||||
@$(CXX) $(CXX_FLAGS) -shared $^ -o $@ $(LD_FLAGS)
|
||||
|
||||
%.dylib: $(OBJECT_FILES)
|
||||
@echo $@
|
||||
@$(CXX) $(CXX_FLAGS) -dynamiclib -undefined suppress -flat_namespace $^ -o $@ $(LD_FLAGS)
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.o: %.c
|
||||
@echo $@
|
||||
@$(CC) -c $(CC_FLAGS) -MMD -MP -MF $(TARGET_BUILD_DIR)/$*.d $< -o $@
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.o: %.cpp
|
||||
@echo $@
|
||||
@$(CXX) -c $(CXX_FLAGS) -MMD -MP -MF $(TARGET_BUILD_DIR)/$*.d $< -o $@
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.o: %.s
|
||||
@echo $@
|
||||
@$(CC) -c $(CC_FLAGS) -MMD -MP -MF $(TARGET_BUILD_DIR)/$*.d -x assembler-with-cpp $< -o $@
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.o: %.S
|
||||
@echo $@
|
||||
@$(CC) -c $(CC_FLAGS) -MMD -MP -MF $(TARGET_BUILD_DIR)/$*.d -x assembler-with-cpp $< -o $@
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.bin.o: $(TARGET_BUILD_DIR)/%.bin.c
|
||||
@echo $@
|
||||
@$(CC) -c $(CC_FLAGS) -MMD -MP -MF $(TARGET_BUILD_DIR)/$*.d $< -o $@
|
||||
|
||||
$(TARGET_BUILD_DIR)/%.bin.c: %.bin
|
||||
@echo $@
|
||||
@cd $(<D); \
|
||||
xxd -i $(<F) "$(CURDIR)/$@"
|
||||
@echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(TARGET_BUILD_DIR)/$< | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_len";" >> `(echo $(TARGET_BUILD_DIR)/$< | tr . _)`.h
|
||||
|
||||
$(foreach file,$(OBJECT_FILES),$(eval $(call createdirrule,$(file))))
|
||||
$(foreach file,$(OUTPUT_FILES),$(eval $(call createdirrule,$(file))))
|
||||
|
||||
# DEPENDS #
|
||||
|
||||
DEPENDS := $(OBJECT_FILES:.o=.d)
|
||||
-include $(DEPENDS)
|
||||
|
||||
endif
|
||||
|
||||
# CLEAN #
|
||||
|
||||
clean:
|
||||
@rm -rf $(BUILD_DIR) $(OUTPUT_DIR)
|
||||
@echo "Cleaned."
|
12
compile.bat
Normal file
12
compile.bat
Normal file
@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
title Compiling...
|
||||
cls
|
||||
make
|
||||
pause
|
||||
cls
|
||||
title Executing 3DSX...
|
||||
output\3dJS.3dsx
|
||||
copy output\3dJS.3dsx D:\3ds\3dJS.3dsx
|
||||
copy output\3dJS.cia D:\_\3dJS.cia
|
||||
pause
|
||||
exit
|
3672
source/duk_config.h
Normal file
3672
source/duk_config.h
Normal file
File diff suppressed because it is too large
Load Diff
94984
source/duktape.c
Normal file
94984
source/duktape.c
Normal file
File diff suppressed because it is too large
Load Diff
1349
source/duktape.h
Normal file
1349
source/duktape.h
Normal file
File diff suppressed because it is too large
Load Diff
29
source/includes.h
Normal file
29
source/includes.h
Normal file
@ -0,0 +1,29 @@
|
||||
#include <iostream>
|
||||
#include <3ds.h>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <cstdio>
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <stdio.h>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <dirent.h>
|
||||
#include <random>
|
||||
using namespace std;
|
346
source/jscore.h
Normal file
346
source/jscore.h
Normal file
@ -0,0 +1,346 @@
|
||||
#include "includes.h"
|
||||
#include "duktape.h"
|
||||
|
||||
static PrintConsole top, sub;
|
||||
|
||||
inline string JS()
|
||||
{
|
||||
string js;
|
||||
js += "var system=[];";
|
||||
js += "var console=[];";
|
||||
js += "var screen=[];";
|
||||
js += "var input=[];";
|
||||
js += "var applet=[];";
|
||||
js += "system.exitApp=function(){__exit();};";
|
||||
js += "system.isNew3DS=function(){return __isnew();};";
|
||||
js += "system.getTime=function(){var tme=[];tme.Seconds=__tmsc();tme.Minutes=__tmmn();tme.Hour=__tmhr();tme.dayName=__tmdys();tme.dayNumber=__tmdyn();tme.monthName=__tmmns();tme.monthNumber=__tmmnn();tme.Year=__tmyr();return tme;};";
|
||||
js += "system.reboot=function(){__reboot();};";
|
||||
js += "system.powerOff=function(){__pwroff();};";
|
||||
js += "system.getBattery=function(){return __curbat();};";
|
||||
js += "system.isCharging=function(){return __batchg();};";
|
||||
js += "system.launchApplet=function(Applet){__applt(Applet);};";
|
||||
js += "console.log=function(){for(var i=0;i!=arguments.length;i++){__print(arguments[i]);}__prln();};";
|
||||
js += "console.read=function(){return __read();};";
|
||||
js += "console.setScreen=function(Screen){__setscr(Screen);};";
|
||||
js += "console.clear=function(){__clear();};";
|
||||
js += "screen.Top=1;";
|
||||
js += "screen.Bottom=0;";
|
||||
js += "input.None=0;";
|
||||
js += "input.A=1;";
|
||||
js += "input.B=2;";
|
||||
js += "input.Select=4;";
|
||||
js += "input.Start=8;";
|
||||
js += "input.DRight=16;";
|
||||
js += "input.DLeft=32;";
|
||||
js += "input.DUp=64;";
|
||||
js += "input.DDown=128;";
|
||||
js += "input.R=256;";
|
||||
js += "input.L=512;";
|
||||
js += "input.X=1024;";
|
||||
js += "input.Y=2048;";
|
||||
js += "input.ZL=16384;";
|
||||
js += "input.ZR=32768;";
|
||||
js += "input.Touch=1048576;";
|
||||
js += "input.CSRight=16777216;";
|
||||
js += "input.CSLeft=33554432;";
|
||||
js += "input.CSUp=67108864;";
|
||||
js += "input.CSDown=134217728;";
|
||||
js += "input.CPRight=268435456;";
|
||||
js += "input.CPLeft=536870912;";
|
||||
js += "input.CPUp=1073741824;";
|
||||
js += "input.CPDown=2147483648;";
|
||||
js += "input.checkUp=function(){return __ipup();};";
|
||||
js += "input.checkDown=function(){return __ipdown();};";
|
||||
js += "input.checkHeld=function(){return __ipheld();};";
|
||||
js += "input.isPressed=function(){return input.checkHeld()!=input.None;};";
|
||||
js += "input.getTouch=function(){var tch=[];tch.X=__tchsx();tch.Y=__tchsy();return tch;};";
|
||||
js += "applet.HomeMenu = 0x101;";
|
||||
js += "applet.AlternateMenu = 0x103;";
|
||||
js += "applet.Camera = 0x110;";
|
||||
js += "applet.FriendsList = 0x112;";
|
||||
js += "applet.GameNotes = 0x113;";
|
||||
js += "applet.WebBrowser = 0x114;";
|
||||
js += "applet.InstructionManual = 0x115;";
|
||||
js += "applet.Notifications = 0x116;";
|
||||
js += "applet.Miiverse = 0x117;";
|
||||
js += "applet.MiiversePosting = 0x118;";
|
||||
js += "applet.AmiiboSettings = 0x119;";
|
||||
js += "applet.Application = 0x300;";
|
||||
js += "applet.eShop = 0x301;";
|
||||
js += "applet.SoftwareKeyboard = 0x401;";
|
||||
js += "applet.MiiSelector = 0x402;";
|
||||
js += "applet.PhotoSelector = 0x404;";
|
||||
js += "applet.SoundSelector = 0x405;";
|
||||
js += "applet.ErrorDisplay = 0x406;";
|
||||
js += "applet.eShopMint = 0x407;";
|
||||
js += "applet.CirclePadCalibrator = 0x408;";
|
||||
js += "applet.Notepad = 0x409;";
|
||||
js += "undefined;";
|
||||
return js;
|
||||
}
|
||||
|
||||
inline duk_ret_t Duk_eval(duk_context *ctx, void *udata)
|
||||
{
|
||||
(void) udata;
|
||||
duk_eval(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t Duk_str(duk_context *ctx, void *udata)
|
||||
{
|
||||
(void) udata;
|
||||
duk_to_string(ctx, -1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline gfxScreen_t detscreen(int scr)
|
||||
{
|
||||
return (scr == 0) ? GFX_BOTTOM : GFX_TOP;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___exit(duk_context *ctx)
|
||||
{
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___clear(duk_context *ctx)
|
||||
{
|
||||
cout << "\x1b[2J";
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___setscr(duk_context *ctx)
|
||||
{
|
||||
int scr = duk_to_number(ctx, 0);
|
||||
(scr == 0) ? consoleSelect(&top) : consoleSelect(&sub);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___prln(duk_context *ctx)
|
||||
{
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___print(duk_context *ctx)
|
||||
{
|
||||
int argv = duk_get_top(ctx);
|
||||
for(int i = 0; i < argv; i++)
|
||||
{
|
||||
cout << duk_to_string(ctx, i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___read(duk_context *ctx)
|
||||
{
|
||||
SwkbdState swkbd;
|
||||
char readed[256];
|
||||
swkbdInit(&swkbd, SWKBD_TYPE_NORMAL, 1, -1);
|
||||
swkbdInputText(&swkbd, readed, sizeof(readed));
|
||||
duk_push_string(ctx, readed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___ipheld(duk_context *ctx)
|
||||
{
|
||||
hidScanInput();
|
||||
int inp = hidKeysHeld();
|
||||
duk_push_number(ctx, inp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___ipup(duk_context *ctx)
|
||||
{
|
||||
hidScanInput();
|
||||
int inp = hidKeysUp();
|
||||
duk_push_number(ctx, inp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___ipdown(duk_context *ctx)
|
||||
{
|
||||
hidScanInput();
|
||||
int inp = hidKeysDown();
|
||||
duk_push_number(ctx, inp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___isnew(duk_context *ctx)
|
||||
{
|
||||
bool res;
|
||||
APT_CheckNew3DS(&res);
|
||||
duk_push_boolean(ctx, res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
|
||||
|
||||
const char* weekDays[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
|
||||
|
||||
const int daysAtStartOfMonthLUT[12] = {0 % 7, 31 % 7, 59 % 7, 90 % 7, 120 % 7, 151 % 7, 181 % 7, 212 % 7, 243 % 7, 273 % 7, 304 % 7, 334 % 7 };
|
||||
|
||||
static inline bool isLeapYear(int year)
|
||||
{
|
||||
return (year%4) == 0 && !((year%100) == 0 && (year%400) != 0);
|
||||
}
|
||||
|
||||
static inline int getDayOfWeek(int day, int month, int year)
|
||||
{
|
||||
day += 2*(3-((year/100)%4));
|
||||
year %= 100;
|
||||
day += year + (year/4);
|
||||
day += daysAtStartOfMonthLUT[month] - (isLeapYear(year) && (month <= 1));
|
||||
return day % 7;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmhr(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int hr = tmst->tm_hour;
|
||||
duk_push_number(ctx, hr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmmn(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int mn = tmst->tm_min;
|
||||
duk_push_number(ctx, mn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmsc(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int sc = tmst->tm_sec;
|
||||
duk_push_number(ctx, sc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmdys(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int idy = tmst->tm_mday;
|
||||
int imt = tmst->tm_mon;
|
||||
int iyr = tmst->tm_year + 1900;
|
||||
const char* daystr = weekDays[getDayOfWeek(idy, imt, iyr)];
|
||||
duk_push_string(ctx, daystr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmdyn(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int day = tmst->tm_mday;
|
||||
duk_push_number(ctx, day);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmmns(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int mon = tmst->tm_mon;
|
||||
const char* monstr = months[mon];
|
||||
duk_push_string(ctx, monstr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmmnn(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int mon = tmst->tm_mon;
|
||||
duk_push_number(ctx, mon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tmyr(duk_context *ctx)
|
||||
{
|
||||
time_t tms = time(NULL);
|
||||
struct tm* tmst = gmtime((const time_t*)&tms);
|
||||
int yr = tmst->tm_year + 1900;
|
||||
duk_push_number(ctx, yr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tchsx(duk_context *ctx)
|
||||
{
|
||||
touchPosition touch;
|
||||
hidTouchRead(&touch);
|
||||
duk_push_number(ctx, touch.px);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___tchsy(duk_context *ctx)
|
||||
{
|
||||
touchPosition touch;
|
||||
hidTouchRead(&touch);
|
||||
duk_push_number(ctx, touch.py);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___reboot(duk_context *ctx)
|
||||
{
|
||||
Handle serviceHandle = 0;
|
||||
srvGetServiceHandle(&serviceHandle, "ptm:sysm");
|
||||
u32 *commandBuffer = getThreadCommandBuffer();
|
||||
commandBuffer[0] = 0x040700C0;
|
||||
commandBuffer[1] = 0x00000000;
|
||||
commandBuffer[2] = 0x00000000;
|
||||
commandBuffer[3] = 0x00000000;
|
||||
svcSendSyncRequest(serviceHandle);
|
||||
svcCloseHandle(serviceHandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___pwroff(duk_context *ctx)
|
||||
{
|
||||
Handle serviceHandle = 0;
|
||||
srvGetServiceHandle(&serviceHandle, "ptm:sysm");
|
||||
u32 *commandBuffer = getThreadCommandBuffer();
|
||||
commandBuffer[0] = 0x040700C0;
|
||||
commandBuffer[1] = 0x00000000;
|
||||
commandBuffer[2] = 0x00000000;
|
||||
commandBuffer[3] = 0x00000000;
|
||||
svcSendSyncRequest(serviceHandle);
|
||||
svcCloseHandle(serviceHandle);
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___curbat(duk_context *ctx)
|
||||
{
|
||||
u8 data = 0;
|
||||
PTMU_GetBatteryLevel(&data);
|
||||
duk_push_number(ctx, (int)data * 20);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___batchg(duk_context *ctx)
|
||||
{
|
||||
u8 data = 0;
|
||||
PTMU_GetBatteryChargeState(&data);
|
||||
bool chg = (data == 1) ? true : false;
|
||||
duk_push_boolean(ctx, chg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline duk_ret_t JS___applt(duk_context *ctx)
|
||||
{
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
gspWaitForVBlank();
|
||||
int id = duk_to_number(ctx, 0);
|
||||
u32 buff[0x400 / 4];
|
||||
memset(buff, 0, sizeof(buff));
|
||||
if(!aptLaunchLibraryApplet((NS_APPID)id, buff, sizeof(buff), 0)) exit(0);
|
||||
return 0;
|
||||
}
|
259
source/main.cpp
Normal file
259
source/main.cpp
Normal file
@ -0,0 +1,259 @@
|
||||
#include "includes.h"
|
||||
#include "duktape.h"
|
||||
#include "jscore.h"
|
||||
|
||||
static string Version = "Beta 2";
|
||||
static bool menu;
|
||||
static duk_context *ctx;
|
||||
static const char *tmptext = "";
|
||||
|
||||
SwkbdState jskbd(const char* init, const char *hint)
|
||||
{
|
||||
SwkbdState swkbd;
|
||||
swkbdInit(&swkbd, SWKBD_TYPE_NORMAL, 2, -1);
|
||||
swkbdSetHintText(&swkbd, hint);
|
||||
swkbdSetInitialText(&swkbd, init);
|
||||
return swkbd;
|
||||
}
|
||||
|
||||
string StringReplace(string str, string from, string to)
|
||||
{
|
||||
string ret = str;
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = str.find(from, start_pos)) != std::string::npos)
|
||||
{
|
||||
ret = str.replace(start_pos, from.length(), to);
|
||||
start_pos += to.length();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char* optioncolor(int selected, int required)
|
||||
{
|
||||
return (selected == required) ? CONSOLE_RED : CONSOLE_RESET;
|
||||
}
|
||||
|
||||
void clearformat()
|
||||
{
|
||||
cout << CONSOLE_RESET << "\x1b[40m";
|
||||
}
|
||||
|
||||
void clearall()
|
||||
{
|
||||
consoleSelect(&sub);
|
||||
clearformat();
|
||||
consoleClear();
|
||||
consoleSelect(&top);
|
||||
clearformat();
|
||||
consoleClear();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Rows and columns in screens: (colums, rows)
|
||||
|
||||
Top: 50, 30
|
||||
Bottom: 40, 30
|
||||
|
||||
*/
|
||||
|
||||
void MainMenu(int selected)
|
||||
{
|
||||
menu = true;
|
||||
duk_destroy_heap(ctx);
|
||||
clearall();
|
||||
cout << endl << endl << CONSOLE_YELLOW << "---------------------|" << CONSOLE_GREEN << " 3dJS " << CONSOLE_YELLOW << "|---------------------" << CONSOLE_YELLOW << endl << "----------|" << CONSOLE_CYAN << " 3DS JavaScript interpreter " << CONSOLE_YELLOW << "|----------" << CONSOLE_RESET << endl << endl << endl << endl << optioncolor(selected, 0) << " - " << CONSOLE_RESET << "Type and execute JavaScript code" << endl << endl << optioncolor(selected, 1) << " - " << CONSOLE_RESET << "Load JavaScript code from a file" << endl << endl << optioncolor(selected, 2) << " - " << CONSOLE_RESET << "About this interpreter" << endl << endl << endl << endl << endl << " Move between options using " << CONSOLE_CYAN << "D-pad" << CONSOLE_RESET << " control." << endl << " Open selected option with " << CONSOLE_CYAN << "A" << CONSOLE_RESET << " button." << endl << endl << endl << " Developed by " << CONSOLE_BLUE << "X" << CONSOLE_CYAN << "or" << CONSOLE_BLUE << "T" << CONSOLE_CYAN << "roll" << CONSOLE_RESET << "." << endl << endl << endl << CONSOLE_RESET << " \x1b[42m " << endl << "\x1b[40m " << "\x1b[42m" << " " << Version << " " << endl << "\x1b[40m " << "\x1b[42m" << " \x1b[40m";
|
||||
ctx = duk_create_heap_default();
|
||||
duk_push_c_function(ctx, JS___print, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__print");
|
||||
duk_push_c_function(ctx, JS___prln, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__prln");
|
||||
duk_push_c_function(ctx, JS___read, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__read");
|
||||
duk_push_c_function(ctx, JS___clear, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__clear");
|
||||
duk_push_c_function(ctx, JS___setscr, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__setscr");
|
||||
duk_push_c_function(ctx, JS___ipheld, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__ipheld");
|
||||
duk_push_c_function(ctx, JS___ipup, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__ipup");
|
||||
duk_push_c_function(ctx, JS___ipdown, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__ipdown");
|
||||
duk_push_c_function(ctx, JS___exit, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__exit");
|
||||
duk_push_c_function(ctx, JS___isnew, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__isnew");
|
||||
duk_push_c_function(ctx, JS___tmhr, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmhr");
|
||||
duk_push_c_function(ctx, JS___tmmn, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmmn");
|
||||
duk_push_c_function(ctx, JS___tmsc, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmsc");
|
||||
duk_push_c_function(ctx, JS___tmdys, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmdys");
|
||||
duk_push_c_function(ctx, JS___tmdyn, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmdyn");
|
||||
duk_push_c_function(ctx, JS___tmmns, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmmns");
|
||||
duk_push_c_function(ctx, JS___tmmnn, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmmnn");
|
||||
duk_push_c_function(ctx, JS___tmyr, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tmyr");
|
||||
duk_push_c_function(ctx, JS___tchsx, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tchsx");
|
||||
duk_push_c_function(ctx, JS___tchsy, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__tchsy");
|
||||
duk_push_c_function(ctx, JS___reboot, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__reboot");
|
||||
duk_push_c_function(ctx, JS___pwroff, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__pwroff");
|
||||
duk_push_c_function(ctx, JS___batchg, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__batchg");
|
||||
duk_push_c_function(ctx, JS___curbat, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__curbat");
|
||||
duk_push_c_function(ctx, JS___applt, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "__applt");
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
int sl = 0;
|
||||
srand(time(NULL));
|
||||
nsInit();
|
||||
ptmSysmInit();
|
||||
ptmuInit();
|
||||
aptInit();
|
||||
newsInit();
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_TOP, &top);
|
||||
consoleInit(GFX_BOTTOM, &sub);
|
||||
consoleSelect(&top);
|
||||
MainMenu(sl);
|
||||
string jsfile, jscode;
|
||||
while(aptMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
int k = hidKeysDown();
|
||||
if(k & KEY_DOWN)
|
||||
{
|
||||
if(sl == 2) sl = 0;
|
||||
else sl++;
|
||||
MainMenu(sl);
|
||||
}
|
||||
else if(k & KEY_UP)
|
||||
{
|
||||
if(sl == 0) sl = 2;
|
||||
else sl--;
|
||||
MainMenu(sl);
|
||||
}
|
||||
else if(k & KEY_A)
|
||||
{
|
||||
if(sl == 0)
|
||||
{
|
||||
clearall();
|
||||
cout << CONSOLE_CYAN << " Type the JS code to execute it." << CONSOLE_RESET;
|
||||
SwkbdState kbd = jskbd(tmptext, "JavaScript code to be interpreted");
|
||||
char cjscode[512];
|
||||
swkbdInputText(&kbd, cjscode, sizeof(cjscode));
|
||||
tmptext = cjscode;
|
||||
jscode = JS() + string(cjscode);
|
||||
consoleClear();
|
||||
if(!jscode.empty())
|
||||
{
|
||||
consoleSelect(&top);
|
||||
const char* code = jscode.c_str();
|
||||
duk_push_string(ctx, code);
|
||||
duk_safe_call(ctx, Duk_eval, NULL, 1, 1);
|
||||
duk_safe_call(ctx, Duk_str, NULL, 1, 1);
|
||||
string res = string(duk_get_string(ctx, -1));
|
||||
cout << endl << res << endl << endl << CONSOLE_MAGENTA << "-------------------------" << CONSOLE_RESET << endl << endl << "Code execution has finished." << endl << "Press" << CONSOLE_CYAN << " Start " << CONSOLE_RESET << "to return to" << CONSOLE_CYAN << " 3dJS" << CONSOLE_RESET << "\'s menu.";
|
||||
duk_pop(ctx);
|
||||
}
|
||||
else MainMenu(sl);
|
||||
}
|
||||
else if(sl == 1)
|
||||
{
|
||||
clearall();
|
||||
cout << CONSOLE_CYAN << " Type the name of the file at SD card." << CONSOLE_RESET;
|
||||
string sjscode = JS();
|
||||
SwkbdState kbd = jskbd(tmptext, "JavaScript source file to load");
|
||||
char cjsfile[512];
|
||||
swkbdInputText(&kbd, cjsfile, sizeof(cjsfile));
|
||||
tmptext = cjsfile;
|
||||
jsfile = StringReplace(string(cjsfile), "/", "\\");
|
||||
if(!jsfile.empty())
|
||||
{
|
||||
int chr;
|
||||
FILE * jsf;
|
||||
jsf = fopen(("sdmc://" + jsfile).c_str(), "r");
|
||||
if(jsf)
|
||||
{
|
||||
consoleClear();
|
||||
string line;
|
||||
while((chr = getc(jsf)) != EOF)
|
||||
{
|
||||
sjscode += (char)chr;
|
||||
}
|
||||
consoleSelect(&top);
|
||||
const char* code = sjscode.c_str();
|
||||
duk_push_string(ctx, code);
|
||||
duk_safe_call(ctx, Duk_eval, NULL, 1, 1);
|
||||
duk_safe_call(ctx, Duk_str, NULL, 1, 1);
|
||||
string res = string(duk_get_string(ctx, -1));
|
||||
cout << endl << res << endl << endl << CONSOLE_MAGENTA << "-------------------------" << CONSOLE_RESET << endl << endl << "Code execution has finished." << endl << "Press" << CONSOLE_CYAN << " Start " << CONSOLE_RESET << "to return to" << CONSOLE_CYAN << " 3dJS" << CONSOLE_RESET << "\'s menu.";
|
||||
duk_pop(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
consoleSelect(&sub);
|
||||
consoleClear();
|
||||
consoleSelect(&top);
|
||||
consoleClear();
|
||||
cout << endl << endl << "Given file does not exist." << endl << "Press" << CONSOLE_CYAN << " Start " << CONSOLE_RESET << "to return to" << CONSOLE_CYAN << " 3dJS" << CONSOLE_RESET << "\'s menu.";
|
||||
}
|
||||
fclose(jsf);
|
||||
}
|
||||
else MainMenu(sl);
|
||||
}
|
||||
else if(sl == 2)
|
||||
{
|
||||
clearall();
|
||||
consoleSelect(&top);
|
||||
cout << endl << endl << CONSOLE_YELLOW << "-----------------| " << CONSOLE_GREEN << "Generic info" << CONSOLE_YELLOW << " |-----------------" << CONSOLE_RESET << endl << endl;
|
||||
cout << " This 3DS program uses " << CONSOLE_CYAN << "duktape" << CONSOLE_RESET << ", a JavaScript" << endl << endl;
|
||||
cout << " engine for C/C++, to handle and interpretate JS" << endl << endl;
|
||||
cout << " code on a 3DS system. I have added some" << endl << endl;
|
||||
cout << " constants and elements which make us able to use" << endl << endl;
|
||||
cout << " 3DS controls, screen printing, and which make" << endl << endl;
|
||||
cout << " us able to make full homebrew apps only using" << endl << endl;
|
||||
cout << " JavaScript and this app. Hope you enjoy it!" << endl << endl;
|
||||
cout << endl << CONSOLE_MAGENTA << "--------------------------------------------------" << CONSOLE_RESET << endl << endl << endl << " Press" << CONSOLE_CYAN << " Start " << CONSOLE_RESET << "to return to" << CONSOLE_CYAN << " 3dJS" << CONSOLE_RESET << "\'s menu. ";
|
||||
consoleSelect(&sub);
|
||||
cout << endl << endl << CONSOLE_YELLOW << "------------| " << CONSOLE_GREEN << "Future plans" << CONSOLE_YELLOW << " |------------" << CONSOLE_RESET << endl << endl;
|
||||
cout << " One of my objectives with this program" << endl << endl;
|
||||
cout << " is to extend the ability of making" << endl << endl;
|
||||
cout << " Nintendo homebrew apps for people who" << endl << endl;
|
||||
cout << " don't want to use C, C++ or Lua." << endl << endl;
|
||||
cout << " I'm planning to remake this idea into" << endl << endl;
|
||||
cout << " other platforms, such as Nintendo DS" << endl << endl;
|
||||
cout << " or even Nintendo Switch." << endl << endl;
|
||||
cout << endl << CONSOLE_MAGENTA << "----------------------------------------" << CONSOLE_RESET << endl << endl << endl << " Press" << CONSOLE_CYAN << " Start " << CONSOLE_RESET << "to return to" << CONSOLE_CYAN << " 3dJS" << CONSOLE_RESET << "\'s menu.";
|
||||
}
|
||||
}
|
||||
else if(k & KEY_START)
|
||||
{
|
||||
MainMenu(sl);
|
||||
}
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
nsExit();
|
||||
ptmSysmExit();
|
||||
ptmuExit();
|
||||
aptExit();
|
||||
newsExit();
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user