commit 558a387b6e5c4879021082ea9c2ccb99afa6139c
Author: Rekushi <170186554+RekuNote@users.noreply.github.com>
Date: Thu Oct 29 03:55:40 2026 +0000
Add files via upload
diff --git a/FORMAT.md b/FORMAT.md
new file mode 100644
index 0000000..451f3e7
--- /dev/null
+++ b/FORMAT.md
@@ -0,0 +1,188 @@
+# Switchnote `.sppm` format
+
+`.sppm` is Switchnote Studio's own offline animation format. It is not a Nintendo `.ppm`
+file. All integers are unsigned little-endian unless stated otherwise. Readers
+must check every length before allocating or advancing. `include/sppm.hpp` and
+`source/sppm.cpp` are the reference implementation.
+
+The Fakenote Studio repository supplies 1280×720 UI mockups and 640×360 sample
+artwork, with editor buttons for layers A through D. It does **not** specify a
+binary format or an exact ink palette. The payload uses a 640×360
+canvas, four indexed layers, and 256 editable RGBA palette entries. Entry 0 is
+transparent. The four layers composite D, C, B, A from back to front; pattern
+brushes write ordinary palette indices in their chosen pattern.
+
+## Header
+
+| Offset | Size | Value |
+| ---: | ---: | --- |
+| 0 | 4 | ASCII `SPPM` |
+| 4 | 2 | Payload version `2` (`1` remains readable) |
+| 6 | 2 | Header size `36` |
+| 8 | 8 | Total file byte length |
+| 16 | 4 | CRC-32/IEEE of bytes from offset 36 to end |
+| 20 | 2 | Canvas width `640` |
+| 22 | 2 | Canvas height `360` |
+| 24 | 1 | Layer count `4` |
+| 25 | 2 | Palette count `256` |
+| 27 | 1 | Playback FPS, 1–30 |
+| 28 | 1 | Flags: bit 0 locked, bit 1 allows spin-offs, bit 2 BGM follows animation speed, bit 3 stops after the final frame (clear = loop) |
+| 29 | 4 | Frame count, 1–9999 |
+| 33 | 1 | Audio track count, 0–4 |
+| 34 | 2 | Reserved zero |
+
+Maximum file size is 512 MiB. The CRC protects against accidental damage;
+it is not an authentication tag.
+
+## Legacy signed v2 envelope
+
+Legacy files may use the binary/RLE payload with the header version set to `2`,
+followed by the four-byte ASCII marker `SPPS` and a 32-byte HMAC-SHA-256 tag.
+The tag covers the complete v2 payload, including its header, metadata, frames
+and audio. Readers verify the tag in constant time before decoding the payload.
+The HMAC key is retained in an encrypted, console-bound `identity-v2-*.bin`
+record. This is a legacy local-file integrity scheme; current app saves use the
+publicly verifiable Ed25519-signed v3 envelope below. Neither scheme is
+Nintendo's signature system or proof of a real-world creator identity.
+Readers accept both old v1 and current v2 payloads inside an authenticated
+envelope.
+`.sppm` is a compact binary encoding with RLE layers, not plaintext and not an
+encrypted format.
+
+## Public v3 signatures
+
+Gallery files use the same SPPM payload with its marker set to version `3`,
+followed by `SPP3`, public author/original-author/editor identities, and a
+64-byte Ed25519 signature. The signed digest covers the complete payload and
+all three identities. The server validates the signature and checks each
+available FSID against its included public identity. This is self-certifying:
+it proves that the included editor key signed those bytes, not that the key
+belongs to a Nintendo account or a verified human.
+
+The Ed25519 secret is encrypted at rest with XSalsa20-Poly1305 and a wrapping
+key derived from system-specific console material. On CFW, this material is
+available to homebrew and is not a hardware-backed, non-exportable secret; a
+compromised console can still expose its signing key. The protection is
+intended to make a copied SD identity file unusable on an ordinary different
+console, not to resist a compromised device.
+
+## Palette and metadata
+
+Immediately after the header are 256 RGBA entries, each four bytes in R, G,
+B, A order. The next five fields are UTF-8 strings with `u16 byte length` then
+that many bytes: title (at most 256 bytes), description (4096), author name
+(128), original author name (128), and last editor name (128). NUL bytes are
+forbidden. The reader rejects malformed UTF-8 and preserves valid bytes;
+the frontend is responsible for display and editing.
+
+The default drawing palette uses pink at index 6 and purple at index 10.
+When reading older SPPMs, the exact opaque legacy colors `(92,224,36)` and
+`(26,40,72)` are remapped to `(239,68,133)` and `(132,66,183)`. Palette indices
+are unchanged; saving writes the migrated colors back into the SPPM.
+
+Six IDs follow, each exactly 16 uppercase hexadecimal ASCII characters:
+
+1. Author FSID, the current Switchnote creator.
+2. Original author FSID, retained through all spin-offs.
+3. Last editor FSID.
+4. Current note ID, newly allocated for a spin-off.
+5. Root note ID, retained through all spin-offs.
+6. Parent note ID, the immediate source Switchnote. Sixteen ASCII zeroes encode
+ an absent parent on an original note. Zeroes are never a valid allocated ID.
+
+The metadata ends with creation time (`u64` Unix seconds UTC), modification
+time (`u64` Unix seconds UTC), and cover frame index (`u32`, zero-based).
+Original notes have `currentId == rootId`, no parent, and author FSID equal to
+original author FSID. A spin-off must have a new current ID different from its
+parent and root IDs. Editing changes the last editor and modification time;
+the original author and root ID do not change.
+
+## Frames
+
+Frames appear sequentially. Each frame contains four layer records in A–D
+order. A layer record has a codec byte (`1` for RLE), a `u32` compressed byte
+length, a `u32` CRC-32/IEEE of the compressed bytes, then the compressed data.
+Decoded data is exactly 230,400 row-major `u8` palette indices. The decoder
+rejects output beyond that size, truncated packets, unknown codecs, and excess
+data. A compressed layer may contain at most 460,800 bytes.
+
+RLE packets have a one-byte command. Bit 7 set means repeat the following
+single palette index `(command & 0x7F) + 1` times. Bit 7 clear means copy that
+many literal palette indices from the following bytes. Both packet types allow
+lengths 1–128. The writer uses repeat packets for runs of at least three.
+
+## Audio
+
+Audio track 0 is background music, starting at frame 0. Tracks 1–3 are sound
+effects with frame cues. Tracks are stored in order and each record contains:
+
+| Field | Encoding |
+| --- | --- |
+| Track index | `u8`, zero-based |
+| Channels | `u8`, mono `1` or stereo `2` |
+| BGM reference FPS | `u8`, 1–30 for BGM (or 0 to use note speed); zero for SE. Added in payload v2. |
+| Sample rate | `u32`, 8000–48000 Hz |
+| Name | `u16` byte length + up to 64 UTF-8 bytes |
+| Trigger count | `u16` |
+| Trigger frames | That many `u16` zero-based frame indices, strictly increasing |
+| PCM sample count | `u32`, counts interleaved samples, not stereo pairs |
+| PCM CRC | `u32` CRC-32/IEEE of sample bytes |
+| PCM | Signed 16-bit little-endian interleaved samples |
+
+BGM has no triggers. A sound effect may be cued multiple times. Every cue must
+refer to an existing frame. Total decoded PCM is limited to 32 Mi samples.
+To store SE without music, make track 0 an empty BGM entry with a valid rate
+and channel count.
+
+With the BGM speed flag set, playback rate is `current FPS / reference FPS`:
+changing animation speed changes music tempo and pitch together. With the flag
+clear, BGM keeps its imported timing. SE tracks always play at their recorded
+speed. The v1 payload defaults to speed-linked BGM.
+The playback-loop flag defaults to looping for older files. When set, playback
+stops all Switchnote tracks at the end of the final frame; when clear, frame zero
+and its BGM/SE cues start together on each loop.
+
+## IDs and spin-offs
+
+Lineage IDs are **64-bit pseudonymous identifiers**, generated as the first
+eight HMAC-SHA-256 digest bytes rendered in uppercase hex. The HMAC key is a
+32-byte per-install secret generated with the platform cryptographic random
+generator and kept in the encrypted console-local identity record. The
+message is:
+
+```
+ASCII("FlipnoteNX-FSID-v1") || 00 || ASCII(domain) || 00 || 16-byte nonce
+```
+
+This historical domain string is retained to keep existing Switchnote identities, signatures, and saved files compatible.
+
+The portable core exposes `deriveFsid(secret, nonce, domain)` so the Switch
+frontend can provide randomness through libnx. It uses a fresh random nonce
+for each new note ID. Creator FSIDs are the first eight SHA-256 bytes of a
+domain-separated Ed25519 public key and a 16-byte one-way device tag. These
+values are still 16 hexadecimal characters (64 bits): an FSID is a public
+identifier, not a password or proof of authorship.
+
+Gallery coin and comment writes require a random, single-use, 30-second server
+challenge signed with the console's Ed25519 key. The server verifies the
+signature, FSID/key binding, request method/path/body, and requesting IP. Coin
+limits and poster ownership use the full 256-bit signing-key fingerprint,
+independent of the shortened FSID and public device tag. Gallery HTTP is LAN-only and does not encrypt public data in
+transit; do not expose the development service to the public internet.
+
+Creating a spin-off is an explicit operation. It requires the source to allow
+spin-offs and not be locked. It copies frames, palette, and audio; keeps the
+root note ID and original author credit; sets parent ID to the source current
+ID; allocates a new current ID; sets the new author and last editor; resets
+creation/modification time; and makes the child editable. The child may be
+saved independently without modifying the parent.
+
+## Safe writing
+
+Signed saves serialize and validate the complete document, write a sibling
+temporary file, then replace the target. If the SD filesystem refuses to
+replace an existing file by rename, the old file is moved to a unique sibling
+backup, the new file is installed, and the old file is restored if installation
+fails. Signed loads authenticate the envelope before replacing the caller's
+document; legacy loads still validate all bounds, IDs, frame data, CRCs, and
+metadata.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..be3f7b2
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,661 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ 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
+them 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.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero 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 that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ 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.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ 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
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1a1c4f7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,89 @@
+# Switch homebrew build, based on the devkitPro/switchbrew application template.
+.SUFFIXES:
+
+ifeq ($(strip $(DEVKITPRO)),)
+$(error DEVKITPRO is not set; open a devkitPro shell or run build.ps1 on Windows)
+endif
+
+TOPDIR ?= $(CURDIR)
+
+ifeq ($(wildcard $(DEVKITPRO)/libnx/switch_rules),)
+$(error libnx is missing from $(DEVKITPRO); install the switch-dev group)
+endif
+include $(DEVKITPRO)/libnx/switch_rules
+
+TARGET := switchnote
+BUILD := build
+SOURCES := source third_party
+INCLUDES := include third_party
+ROMFS := romfs
+
+export APP_TITLE := Switchnote Studio
+export APP_AUTHOR := RexiMemo!
+export APP_VERSION := 0.1.51
+
+ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
+PKG_CONFIG := $(PORTLIBS)/bin/aarch64-none-elf-pkg-config
+SDL_PACKAGES := SDL2_image SDL2_ttf SDL2_mixer sdl2
+
+CFLAGS := -g -Wall -Wextra -O2 -ffunction-sections $(ARCH) $(DEFINES)
+CFLAGS += -D__SWITCH__ $(INCLUDE) $(shell $(PKG_CONFIG) --cflags $(SDL_PACKAGES))
+CXXFLAGS := $(CFLAGS) -std=gnu++17 -fno-rtti -fno-exceptions
+ASFLAGS := -g $(ARCH)
+LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LIBS := $(shell $(PKG_CONFIG) --static --libs $(SDL_PACKAGES)) -lnx
+LIBDIRS := $(PORTLIBS) $(LIBNX)
+
+ifneq ($(BUILD),$(notdir $(CURDIR)))
+
+export OUTPUT := $(CURDIR)/$(TARGET)
+export TOPDIR := $(CURDIR)
+export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
+export DEPSDIR := $(CURDIR)/$(BUILD)
+
+CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
+CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
+SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+
+export LD := $(CXX)
+export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
+export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ -I$(CURDIR)/$(BUILD)
+export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
+
+# libnx's NRO icon is JPEG. build.ps1 converts a root icon.png if supplied.
+ifneq ($(wildcard $(TOPDIR)/icon.jpg),)
+export APP_ICON := $(TOPDIR)/icon.jpg
+else
+export APP_ICON := $(LIBNX)/default_icon.jpg
+endif
+
+export NROFLAGS += --icon=$(APP_ICON) --nacp=$(CURDIR)/$(TARGET).nacp
+export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
+
+.PHONY: all clean $(BUILD)
+all: $(BUILD)
+
+$(BUILD):
+ @mkdir -p $@
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+clean:
+ @rm -rf -- $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf $(TARGET).map
+
+else
+
+DEPENDS := $(OFILES:.o=.d)
+ROMFS_FILES := $(shell find $(TOPDIR)/$(ROMFS) -type f)
+
+.PHONY: all
+all: $(OUTPUT).nro
+
+$(OUTPUT).nro: $(OUTPUT).elf $(OUTPUT).nacp $(ROMFS_FILES)
+
+$(OUTPUT).elf: $(OFILES)
+
+-include $(DEPENDS)
+
+endif
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5f4728d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,25 @@
+# Switchnote Studio
+
+Switchnote Studio is a Nintendo Switch homebrew app for making frame-by-frame drawings and animations. It began with the artwork and interface assets from Jaames's 2020 Fakenote Studio April Fools' project, then grew into a working editor.
+
+This is the source snapshot for **Ver 0.1.51**. The included `switchnote.nro` is the original build from the project, with SHA-256 `B0B56FDC81766C8740622AC81BA5E72E90293099CBDB96B5BBF0372AC0C10CCA`.
+
+## What it does
+
+- Draw on a 640 × 360 canvas with four layers, pen and brush tools, an eraser, fill, undo and redo.
+- Make and play animations at eight speeds, with onion skin and frame controls.
+- Add music and frame sound effects. Images can be imported from the Switch album, an IR camera or another device.
+- Save signed `.sppm` Switchnotes locally, make spin-offs, and export animations.
+- Browse and post through Switchnote Gallery at `https://reximemo.net/nswitch/`.
+
+The app needs full Homebrew Menu memory. Launch it through App Override; it cannot run in Applet Mode. Put the NRO at `switch/Switchnote/switchnote.nro` on the SD card. User data is stored under `sdmc:/switch/Switchnote/`.
+
+## Building
+
+Install devkitPro's Switch toolchain, libnx, `switch-pkg-config`, `switch-sdl2`, `switch-sdl2_image`, `switch-sdl2_ttf` and `switch-sdl2_mixer`. On Windows, run `./build.ps1` from PowerShell. The script expects devkitPro at `C:\devkitPro`, or you can pass `-DevkitProPath`. On Linux or macOS, set up the devkitPro environment and run `make` from a path without spaces.
+
+The build writes `switchnote.nro` to the project root. `source/` and `include/` contain the app, `romfs/` contains its bundled assets, and `FORMAT.md` describes the `.sppm` format. `server/` contains a local Gallery test server; it is not the production service. The JavaScript and Python readers and converters are in `tools/`.
+
+## Licences and assets
+
+The app code is released under the [GNU AGPL version 3](LICENSE). The standalone tools have their own MIT licence in `tools/LICENSE`. Fakenote Studio assets and Bitstream Vera fonts have notices in `licenses/`.
diff --git a/SHA256SUMS b/SHA256SUMS
new file mode 100644
index 0000000..17cde7f
--- /dev/null
+++ b/SHA256SUMS
@@ -0,0 +1 @@
+B0B56FDC81766C8740622AC81BA5E72E90293099CBDB96B5BBF0372AC0C10CCA switchnote.nro
diff --git a/build.ps1 b/build.ps1
new file mode 100644
index 0000000..db446ae
--- /dev/null
+++ b/build.ps1
@@ -0,0 +1,112 @@
+# Build the Switch NRO from Windows using devkitPro's MSYS2 toolchain.
+param(
+ [string]$DevkitProPath = '',
+ [switch]$KeepBuild
+)
+
+$ErrorActionPreference = 'Stop'
+
+function Quote-Bash([string]$Value) {
+ return "'" + $Value.Replace("'", "'\''") + "'"
+}
+
+$projectRoot = [IO.Path]::GetFullPath($PSScriptRoot)
+if (-not $DevkitProPath) {
+ if ($env:DEVKITPRO -and (Test-Path -LiteralPath $env:DEVKITPRO)) {
+ $DevkitProPath = $env:DEVKITPRO
+ } else {
+ $DevkitProPath = 'C:\devkitPro'
+ }
+}
+$devkitRoot = [IO.Path]::GetFullPath($DevkitProPath)
+
+$bash = Join-Path $devkitRoot 'msys2\usr\bin\bash.exe'
+$cygpath = Join-Path $devkitRoot 'msys2\usr\bin\cygpath.exe'
+$rules = Join-Path $devkitRoot 'libnx\switch_rules'
+$compiler = Join-Path $devkitRoot 'devkitA64\bin\aarch64-none-elf-g++.exe'
+$pkgConfig = Join-Path $devkitRoot 'portlibs\switch\bin\aarch64-none-elf-pkg-config'
+
+foreach ($required in @($bash, $cygpath, $rules, $compiler, $pkgConfig)) {
+ if (-not (Test-Path -LiteralPath $required)) {
+ throw "Missing Switch build dependency: $required`nInstall devkitPro's Switch toolchain and switch-pkg-config packages; see README.md."
+ }
+}
+
+if ($devkitRoot -match '\s') {
+ throw 'The devkitPro installation path contains spaces; install it at C:\devkitPro or choose a path without spaces.'
+}
+
+$tempRoot = [IO.Path]::GetFullPath([IO.Path]::GetTempPath())
+if ($tempRoot -match '\s') {
+ throw 'The temporary path contains spaces. Set TEMP to a writable directory without spaces before building.'
+}
+
+# The upstream devkitPro Makefile pattern requires a path without spaces, so
+# compile a fresh copy in the temp folder.
+$stage = Join-Path $tempRoot ('switchnote-build-' + [Guid]::NewGuid().ToString('N'))
+$resolvedStage = [IO.Path]::GetFullPath($stage)
+$tempPrefix = $tempRoot.TrimEnd('\', '/') + [IO.Path]::DirectorySeparatorChar
+if (-not $resolvedStage.StartsWith($tempPrefix, [StringComparison]::OrdinalIgnoreCase) -or
+ -not ([IO.Path]::GetFileName($resolvedStage) -match '^switchnote-build-[0-9a-f]{32}$')) {
+ throw "Unexpected temporary build path: $resolvedStage"
+}
+
+New-Item -ItemType Directory -Path $stage | Out-Null
+try {
+ foreach ($entry in @('Makefile', 'source', 'include', 'third_party', 'romfs')) {
+ $source = Join-Path $projectRoot $entry
+ if (-not (Test-Path -LiteralPath $source)) {
+ throw "Project file or directory is missing: $source"
+ }
+ Copy-Item -LiteralPath $source -Destination (Join-Path $stage $entry) -Recurse
+ }
+
+ $rootJpeg = Join-Path $projectRoot 'icon.jpg'
+ $rootPng = Join-Path $projectRoot 'icon.png'
+ if (Test-Path -LiteralPath $rootPng) {
+ try {
+ Add-Type -AssemblyName System.Drawing
+ $inputImage = [Drawing.Image]::FromFile($rootPng)
+ $bitmap = [Drawing.Bitmap]::new(256, 256)
+ $graphics = [Drawing.Graphics]::FromImage($bitmap)
+ try {
+ $graphics.Clear([Drawing.Color]::White)
+ $graphics.InterpolationMode = [Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
+ $graphics.DrawImage($inputImage, 0, 0, 256, 256)
+ $bitmap.Save((Join-Path $stage 'icon.jpg'), [Drawing.Imaging.ImageFormat]::Jpeg)
+ } finally {
+ $graphics.Dispose()
+ $bitmap.Dispose()
+ $inputImage.Dispose()
+ }
+ } catch {
+ Write-Warning "Could not convert icon.png to JPEG; the default libnx icon will be used. $($_.Exception.Message)"
+ }
+ } elseif (Test-Path -LiteralPath $rootJpeg) {
+ Copy-Item -LiteralPath $rootJpeg -Destination (Join-Path $stage 'icon.jpg')
+ }
+
+ $devkitUnix = (& $cygpath -u $devkitRoot).Trim()
+ if ($LASTEXITCODE -ne 0 -or -not $devkitUnix) { throw 'cygpath could not translate the devkitPro path.' }
+ $stageUnix = (& $cygpath -u $stage).Trim()
+ if ($LASTEXITCODE -ne 0 -or -not $stageUnix) { throw 'cygpath could not translate the build path.' }
+
+ $devkitQuoted = Quote-Bash $devkitUnix
+ $stageQuoted = Quote-Bash $stageUnix
+ $command = 'export DEVKITPRO={0}; export DEVKITA64="$DEVKITPRO/devkitA64"; export PATH="$DEVKITA64/bin:$DEVKITPRO/tools/bin:$DEVKITPRO/portlibs/switch/bin:$PATH"; cd {1}; make -j2' -f $devkitQuoted, $stageQuoted
+ & $bash -lc $command
+ if ($LASTEXITCODE -ne 0) { throw "Switch build failed with exit code $LASTEXITCODE." }
+
+ $builtNro = Join-Path $stage 'switchnote.nro'
+ if (-not (Test-Path -LiteralPath $builtNro)) { throw "Build reported success but no NRO exists at $builtNro" }
+ $destination = Join-Path $projectRoot 'switchnote.nro'
+ Copy-Item -LiteralPath $builtNro -Destination $destination -Force
+ Write-Host "Built $destination"
+} finally {
+ if ($KeepBuild) {
+ Write-Host "Temporary build retained at $stage"
+ } elseif (Test-Path -LiteralPath $stage) {
+ # This directory was created above and its full path was checked against TEMP.
+ Remove-Item -LiteralPath $stage -Recurse -Force
+ }
+}
diff --git a/icon.png b/icon.png
new file mode 100644
index 0000000..1319abe
Binary files /dev/null and b/icon.png differ
diff --git a/include/audio_upload_server.hpp b/include/audio_upload_server.hpp
new file mode 100644
index 0000000..cc3eb92
--- /dev/null
+++ b/include/audio_upload_server.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include
+
+class AudioUploadServer {
+public:
+ AudioUploadServer();
+ ~AudioUploadServer();
+ AudioUploadServer(const AudioUploadServer&) = delete;
+ AudioUploadServer& operator=(const AudioUploadServer&) = delete;
+
+ bool start(const std::string& bindAddress, const std::string& uploadDirectory,
+ const std::string& assetsRoot, const std::string& sessionCode,
+ std::string& error, bool photoTransfer = false,
+ const std::string& noteSingular = "Switchnote");
+ void stop();
+ bool isRunning() const;
+ bool isConnected() const;
+ bool takeCompletedUpload(int& track);
+ void finishCompletedUpload(bool success);
+
+private:
+ void* impl_ = nullptr;
+};
diff --git a/include/branding_bundle.hpp b/include/branding_bundle.hpp
new file mode 100644
index 0000000..24f76e5
--- /dev/null
+++ b/include/branding_bundle.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include
+#include
+
+namespace branding {
+
+struct Bundle {
+ std::string app;
+ std::string singular;
+ std::string plural;
+ std::vector logo;
+};
+
+bool writeConfig(const std::string& path, const Bundle& bundle, std::string& error);
+bool readConfig(const std::string& path, Bundle& bundle, std::string& error);
+
+} // namespace branding
diff --git a/include/branding_config_server.hpp b/include/branding_config_server.hpp
new file mode 100644
index 0000000..12f45d4
--- /dev/null
+++ b/include/branding_config_server.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include
+
+class BrandingConfigServer {
+public:
+ BrandingConfigServer();
+ ~BrandingConfigServer();
+ BrandingConfigServer(const BrandingConfigServer&) = delete;
+ BrandingConfigServer& operator=(const BrandingConfigServer&) = delete;
+
+ bool start(const std::string& bindAddress, const std::string& dataDirectory,
+ const std::string& assetsRoot, const std::string& sessionCode,
+ std::string& error, const std::string& appName,
+ const std::string& noteSingular, const std::string& notePlural);
+ void stop();
+ bool isRunning() const;
+ bool isConnected() const;
+ bool takeConfigUpdate();
+
+private:
+ void* impl_ = nullptr;
+};
diff --git a/include/export.hpp b/include/export.hpp
new file mode 100644
index 0000000..70b41ec
--- /dev/null
+++ b/include/export.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "sppm.hpp"
+
+#include
+
+namespace sppm {
+
+// Exports a looping GIF89a animation. The GIF uses the document palette and
+// composites layers A through D for each frame. GIF has no audio channel.
+bool exportGif(const Document& document, const std::string& path,
+ std::string& error);
+
+// Exports the selected cover frame as a lossless RGBA PNG.
+bool exportPngCover(const Document& document, const std::string& path,
+ std::string& error);
+
+// Exports a Motion-JPEG MP4 animation. Frames are composited over white at
+// native Switchnote resolution; audio tracks are not muxed.
+bool exportMp4(const Document& document, const std::string& path,
+ std::string& error);
+
+} // namespace sppm
diff --git a/include/sppm.hpp b/include/sppm.hpp
new file mode 100644
index 0000000..0b5d5a6
--- /dev/null
+++ b/include/sppm.hpp
@@ -0,0 +1,162 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace sppm {
+
+constexpr std::uint16_t kWidth = 640;
+constexpr std::uint16_t kHeight = 360;
+constexpr std::size_t kPixelsPerLayer = static_cast(kWidth) * kHeight;
+constexpr std::size_t kLayerCount = 4;
+constexpr std::size_t kPaletteSize = 256;
+constexpr std::size_t kMaxFrames = 9999;
+constexpr std::size_t kMaxAudioTracks = 4;
+
+struct Color {
+ std::uint8_t r = 0;
+ std::uint8_t g = 0;
+ std::uint8_t b = 0;
+ std::uint8_t a = 255;
+};
+
+using Palette = std::array;
+
+// Palette index 0 is transparent. Other entries can be changed by the editor.
+Palette defaultPalette();
+
+struct Frame {
+ // A, B, C, D from front to back; one palette index per 640x360 pixel.
+ std::array, kLayerCount> layers;
+ Frame();
+};
+
+struct AudioTrack {
+ std::string name; // e.g. BGM, SE1, SE2, SE3
+ std::uint32_t sampleRate = 0; // 8000..48000 Hz
+ std::uint8_t channels = 1; // 1 or 2
+ std::uint8_t referenceFps = 0; // BGM's native animation speed; 0 means use the note's speed
+ std::uint8_t referenceSpeed = 0; // SPPM v3 BGM speed index (1..8); 0 means legacy fps
+ std::vector frameTriggers; // SE cues; BGM always starts at frame 0
+ std::vector pcm; // interleaved signed 16-bit samples
+};
+
+// A public identity is safe to put in an .sppm file. It contains an Ed25519
+// verification key and a one-way, app-specific device tag; neither field
+// exposes a raw console identifier.
+struct PublicIdentity {
+ std::array key{};
+ std::array deviceTag{};
+};
+
+struct SigningIdentity {
+ PublicIdentity publicIdentity;
+ std::array secretKey{};
+ // Present only to keep validating pre-v3 console-HMAC files after migration.
+ std::array legacyHmacKey{};
+};
+
+struct Metadata {
+ std::string title;
+ std::string description;
+ std::string authorName;
+ std::string originalAuthorName;
+ std::string lastEditorName;
+
+ // Creator identities, not file IDs. Exactly 16 uppercase hexadecimal chars.
+ std::string authorFsid;
+ std::string originalAuthorFsid;
+ std::string lastEditorFsid;
+
+ // Present for v3 public-key-signed files. Zero values indicate a legacy
+ // author record which cannot be retrospectively cryptographically bound.
+ PublicIdentity authorIdentity;
+ PublicIdentity originalAuthorIdentity;
+ PublicIdentity lastEditorIdentity;
+
+ // File lineage IDs. parentId is empty only for an original Switchnote.
+ std::string currentId;
+ std::string rootId;
+ std::string parentId;
+
+ std::uint64_t createdUnixSeconds = 0;
+ std::uint64_t modifiedUnixSeconds = 0;
+ std::uint32_t coverFrame = 0;
+ std::uint8_t fps = 12;
+ std::uint8_t speed = 0; // SPPM v3 DSi speed index (1..8); 0 means legacy fps
+ bool locked = false;
+ bool allowSpinoffs = true;
+ bool bgmFollowsSpeed = true;
+ bool loopPlayback = true;
+};
+
+struct Document {
+ Metadata metadata;
+ Palette palette = defaultPalette();
+ std::vector frames;
+ std::vector audioTracks;
+};
+
+bool isValidFsid(std::string_view fsid);
+bool hasPublicIdentity(const PublicIdentity& identity);
+std::string deriveFsid(const PublicIdentity& identity);
+std::string identityFingerprint(const PublicIdentity& identity);
+std::array deriveDeviceTag(const std::vector& deviceMaterial);
+std::array deriveDeviceWrapKey(const std::vector& deviceMaterial,
+ const std::array& salt);
+bool createSigningIdentity(const std::array& deviceTag,
+ SigningIdentity& identity, std::string& error);
+bool sealSigningSecret(const SigningIdentity& identity,
+ const std::array& wrapKey,
+ const std::array& nonce,
+ std::array& sealed, std::string& error);
+bool unsealSigningSecret(const std::array& sealed,
+ const std::array& wrapKey,
+ const std::array& nonce,
+ SigningIdentity& identity, std::string& error);
+
+// Domain-separated 64-bit ID helper used for non-identity note and lineage IDs.
+// Creator FSIDs are instead derived from PublicIdentity.
+std::string deriveFsid(const std::array& secret,
+ const std::array& nonce,
+ std::string_view domain);
+
+bool validate(const Document& document, std::string& error);
+double frameRate(const Metadata& metadata);
+bool serialize(const Document& document, std::vector& bytes,
+ std::string& error);
+bool deserialize(const std::vector& bytes, Document& document,
+ std::string& error);
+bool loadFile(const std::string& path, Document& document, std::string& error);
+bool saveFile(const std::string& path, const Document& document, std::string& error);
+// Console-local authenticated .sppm envelopes. Legacy v1 notes remain readable;
+// new saves include a 256-bit HMAC-SHA-256 footer verified with the local key.
+bool deserializeSigned(const std::vector& bytes, Document& document,
+ const std::array& signingKey,
+ std::string& error);
+bool loadSignedFile(const std::string& path, Document& document,
+ const std::array& signingKey,
+ std::string& error);
+bool saveSignedFile(const std::string& path, const Document& document,
+ const std::array& signingKey,
+ std::string& error);
+// v3 is publicly verifiable: no console-local secret is needed to validate a
+// received file. It signs a domain-separated SHA-256 digest with Ed25519.
+bool savePublicSignedFile(const std::string& path, const Document& document,
+ const SigningIdentity& identity, std::string& error);
+bool signMessage(const SigningIdentity& identity, const std::uint8_t* message,
+ std::size_t messageSize, std::array& signature,
+ std::string& error);
+
+// Preserves the original author and root ID, while giving the fork a new
+// current ID, parent ID, author, creation time and editable state.
+bool createSpinoff(const Document& parent, std::string_view newAuthorName,
+ std::string_view newAuthorFsid, std::string_view newCurrentId,
+ std::uint64_t nowUnixSeconds, Document& child,
+ std::string& error);
+
+} // namespace sppm
diff --git a/licenses/THIRD_PARTY_NOTICES.md b/licenses/THIRD_PARTY_NOTICES.md
new file mode 100644
index 0000000..e287a6e
--- /dev/null
+++ b/licenses/THIRD_PARTY_NOTICES.md
@@ -0,0 +1,5 @@
+# Third-party assets
+
+The Fakenote Studio assets are covered by the MIT licence in `fakenote-studio.txt`. The Bitstream Vera fonts are covered by `bitstream-vera.txt`.
+
+The original Nintendo DSi Flipnote Studio WAV files are omitted from this source release. The FOT Seurat fonts in `romfs/fonts/` have no redistribution permission documented here. They are not covered by the Fakenote Studio MIT licence.
diff --git a/licenses/bitstream-vera.txt b/licenses/bitstream-vera.txt
new file mode 100644
index 0000000..e651be1
--- /dev/null
+++ b/licenses/bitstream-vera.txt
@@ -0,0 +1,124 @@
+Bitstream Vera Fonts Copyright
+
+The fonts have a generous copyright, allowing derivative works (as
+long as "Bitstream" or "Vera" are not in the names), and full
+redistribution (so long as they are not *sold* by themselves). They
+can be be bundled, redistributed and sold with any software.
+
+The fonts are distributed under the following copyright:
+
+Copyright
+=========
+
+Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream
+Vera is a trademark of Bitstream, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the fonts accompanying this license ("Fonts") and associated
+documentation files (the "Font Software"), to reproduce and distribute
+the Font Software, including without limitation the rights to use,
+copy, merge, publish, distribute, and/or sell copies of the Font
+Software, and to permit persons to whom the Font Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright and trademark notices and this permission notice
+shall be included in all copies of one or more of the Font Software
+typefaces.
+
+The Font Software may be modified, altered, or added to, and in
+particular the designs of glyphs or characters in the Fonts may be
+modified and additional glyphs or characters may be added to the
+Fonts, only if the fonts are renamed to names not containing either
+the words "Bitstream" or the word "Vera".
+
+This License becomes null and void to the extent applicable to Fonts
+or Font Software that has been modified and is distributed under the
+"Bitstream Vera" names.
+
+The Font Software may be sold as part of a larger software package but
+no copy of one or more of the Font Software typefaces may be sold by
+itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
+BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL,
+OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT
+SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
+
+Except as contained in this notice, the names of Gnome, the Gnome
+Foundation, and Bitstream Inc., shall not be used in advertising or
+otherwise to promote the sale, use or other dealings in this Font
+Software without prior written authorization from the Gnome Foundation
+or Bitstream Inc., respectively. For further information, contact:
+fonts at gnome dot org.
+
+Copyright FAQ
+=============
+
+ 1. I don't understand the resale restriction... What gives?
+
+ Bitstream is giving away these fonts, but wishes to ensure its
+ competitors can't just drop the fonts as is into a font sale system
+ and sell them as is. It seems fair that if Bitstream can't make money
+ from the Bitstream Vera fonts, their competitors should not be able to
+ do so either. You can sell the fonts as part of any software package,
+ however.
+
+ 2. I want to package these fonts separately for distribution and
+ sale as part of a larger software package or system. Can I do so?
+
+ Yes. A RPM or Debian package is a "larger software package" to begin
+ with, and you aren't selling them independently by themselves.
+ See 1. above.
+
+ 3. Are derivative works allowed?
+ Yes!
+
+ 4. Can I change or add to the font(s)?
+ Yes, but you must change the name(s) of the font(s).
+
+ 5. Under what terms are derivative works allowed?
+
+ You must change the name(s) of the fonts. This is to ensure the
+ quality of the fonts, both to protect Bitstream and Gnome. We want to
+ ensure that if an application has opened a font specifically of these
+ names, it gets what it expects (though of course, using fontconfig,
+ substitutions could still could have occurred during font
+ opening). You must include the Bitstream copyright. Additional
+ copyrights can be added, as per copyright law. Happy Font Hacking!
+
+ 6. If I have improvements for Bitstream Vera, is it possible they might get
+ adopted in future versions?
+
+ Yes. The contract between the Gnome Foundation and Bitstream has
+ provisions for working with Bitstream to ensure quality additions to
+ the Bitstream Vera font family. Please contact us if you have such
+ additions. Note, that in general, we will want such additions for the
+ entire family, not just a single font, and that you'll have to keep
+ both Gnome and Jim Lyles, Vera's designer, happy! To make sense to add
+ glyphs to the font, they must be stylistically in keeping with Vera's
+ design. Vera cannot become a "ransom note" font. Jim Lyles will be
+ providing a document describing the design elements used in Vera, as a
+ guide and aid for people interested in contributing to Vera.
+
+ 7. I want to sell a software package that uses these fonts: Can I do so?
+
+ Sure. Bundle the fonts with your software and sell your software
+ with the fonts. That is the intent of the copyright.
+
+ 8. If applications have built the names "Bitstream Vera" into them,
+ can I override this somehow to use fonts of my choosing?
+
+ This depends on exact details of the software. Most open source
+ systems and software (e.g., Gnome, KDE, etc.) are now converting to
+ use fontconfig (see www.fontconfig.org) to handle font configuration,
+ selection and substitution; it has provisions for overriding font
+ names and subsituting alternatives. An example is provided by the
+ supplied local.conf file, which chooses the family Bitstream Vera for
+ "sans", "serif" and "monospace". Other software (e.g., the XFree86
+ core server) has other mechanisms for font substitution.
+
diff --git a/licenses/fakenote-studio.txt b/licenses/fakenote-studio.txt
new file mode 100644
index 0000000..7eb59f0
--- /dev/null
+++ b/licenses/fakenote-studio.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 jaames
+
+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.
diff --git a/licenses/sound-manifest.json b/licenses/sound-manifest.json
new file mode 100644
index 0000000..4fbd86d
--- /dev/null
+++ b/licenses/sound-manifest.json
@@ -0,0 +1,33 @@
+{
+ "sourceArchive": "SEQARC_SYSTEM_SE 2.zip",
+ "sourceDirectory": "SEQARC_SYSTEM_SE/",
+ "conversion": "RIFF PCM stereo 16-bit 65456 Hz to RIFF PCM stereo 16-bit 48000 Hz using FFmpeg; original duration preserved",
+ "cataloguedWavCount": 143,
+ "selectionPolicy": "The archive was reviewed by filename and decoded duration. Short interaction cues are mapped by action; long pen/eraser, recording, waiting, and tutorial/music clips are not used as button sounds.",
+ "effects": {
+ "button_on": "SE_SY_BUTTON_ON.wav",
+ "button_off": "SE_SY_BUTTON_OFF.wav",
+ "cursor_cancel": "SE_SY_CURSOR_CANCEL.wav",
+ "undo": "SE_SY_UNDO.wav",
+ "redo": "SE_SY_REDO.wav",
+ "page_new": "SE_SY_EDIT_PAGE_INSERT.wav",
+ "movie_play": "SE_SY_MOVIE_PLAY.wav",
+ "movie_stop": "SE_SY_MOVIE_STOP.wav",
+ "draw_tool_btn_on": "SE_SY_DRAW_TOOL_BTN_ON.wav",
+ "folder_open": "SE_SY_FOLDER_OPEN.wav",
+ "pic_stamp": "SE_SY_PIC_STAMP.wav",
+ "paint": "SE_SY_PAINT.wav",
+ "page_backward": "SE_SY_PAGE_BACKWARD.wav",
+ "page_forward": "SE_SY_PAGE_FORWARD.wav",
+ "page_first": "SE_SY_PAGE_FIRST.wav",
+ "page_end": "SE_SY_PAGE_END.wav",
+ "edit_page_copy": "SE_SY_EDIT_PAGE_COPY.wav",
+ "edit_page_paste": "SE_SY_EDIT_PAGE_PASTE.wav",
+ "edit_page_remove": "SE_SY_EDIT_PAGE_REMOVE.wav",
+ "screen_swap": "SE_SY_SCREEN_SWAP.wav",
+ "popup": "SE_SY_POPUP.wav",
+ "popup_select": "SE_SY_POPUP_SELECT.wav",
+ "save_ok": "SE_SY_SAVE_OK.wav",
+ "delete_complete": "SE_SY_DELETE_COMPLETE.wav"
+ }
+}
diff --git a/paper-stack-transparent.png b/paper-stack-transparent.png
new file mode 100644
index 0000000..693fb15
Binary files /dev/null and b/paper-stack-transparent.png differ
diff --git a/source/audio_upload_server.cpp b/source/audio_upload_server.cpp
new file mode 100644
index 0000000..c43ebb1
--- /dev/null
+++ b/source/audio_upload_server.cpp
@@ -0,0 +1,701 @@
+#include "audio_upload_server.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include