<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.sizecoding.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Popolon</id>
		<title>SizeCoding - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.sizecoding.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Popolon"/>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/wiki/Special:Contributions/Popolon"/>
		<updated>2026-04-22T23:20:46Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.0</generator>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ReGIS&amp;diff=1834</id>
		<title>ReGIS</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ReGIS&amp;diff=1834"/>
				<updated>2025-11-16T09:29:29Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: link to a backup of the official manual available on line on a VT museum like website, add instruction on more recent distro (argument +u8 with xterm fail now).&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''ReGIS''' is a vector graphics markup language made by DEC for it's VT125, VT230, VT240/241 and above terminals. commands can be sent to it by serial or any other text/tty connexion.&lt;br /&gt;
: official manual &amp;quot;VT330/VT340 Programmer Reference Manual - Volume 2: Graphics Programming&amp;quot; by Digital, is available online in HTML format here: https://vt100.net/docs/vt3xx-gp/  and pdf https://raw.githubusercontent.com/hackerb9/vt340test/main/docs/EK-VT3XX-HR-002_VT330_VT340_Programmer_Pocket_Guide_May88.pdf&lt;br /&gt;
&lt;br /&gt;
== Overview of the features ==&lt;br /&gt;
Depending on terminal resolution and features changes&lt;br /&gt;
* VT125 768×240 pixels, 2 bitplans&lt;br /&gt;
* VT230 800×480 pixels, 2 bitplans&lt;br /&gt;
* VT240/VT241 768×480 pixels, 4 bitplans&lt;br /&gt;
&lt;br /&gt;
There is &amp;quot;shading&amp;quot; management allowing to mix simple patterns for fill or border, &lt;br /&gt;
&lt;br /&gt;
It supports curves with polynomial interpolation, by default with only one point + a value, it builds a circle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use it on Linux distros ==&lt;br /&gt;
Xterm supports it. Arch Linux and derivative support it from scratch. It must be recompiled on Debian and derivatives, with the --enable-regis-graphics option. Display will change depending on used VT emulation.&lt;br /&gt;
&lt;br /&gt;
Launch xterm like this to have more capabilities:&lt;br /&gt;
 xterm +u8 -geometry 132x50 -ti vt340 -tn vt340 /bin/bash&lt;br /&gt;
&lt;br /&gt;
On some recent distribution, &amp;lt;code&amp;gt;+u8&amp;lt;/code&amp;gt; could fail and the command just return with return code 0. In this case, just start with:&lt;br /&gt;
 xterm -geometry 132x50 -ti vt340 -tn vt340 /bin/bash&lt;br /&gt;
&lt;br /&gt;
then launch the script or connect by one of the available serial tools (screen, minicom, etc...) to the hw producing the markup.&lt;br /&gt;
&lt;br /&gt;
The markup is send to terminal prefixed, after the documentation by 0x1b 0x50 0x32 x70 (ESC + 'P2p', but on xterm implementation at least, any single digit decimal number instead of 2 works). It is also suffixed by 0x1b 0x5c (ESC + '\', standard VT endline sequence).&lt;br /&gt;
&lt;br /&gt;
Implementation in Bash:&lt;br /&gt;
 echo -e &amp;quot;\x1bP2p${command}\x1b\\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
in Lua:&lt;br /&gt;
 io.stream(string.char(0x1b)..&amp;quot;P2p&amp;quot;..command..string.char(0x1b,0x5c))&lt;br /&gt;
&lt;br /&gt;
'''Don't forget to flush the stream in tests with system based languages, to avoid a buffer filling few seconds wait''' :).&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1578</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1578"/>
				<updated>2024-04-18T21:10:42Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Introduction */ add link to RISC-V Code Size Reduction Group and explain what means ISA here&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA (Instruction Set Architecture). It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
: [https://github.com/riscvarchive/riscv-code-size-reduction The RISC-V Code Size Reduction Group] worked on code reduction in RISC-V ISA&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option &amp;lt;code&amp;gt;-x&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;objdump&amp;lt;/code&amp;gt; allow to see all the most segments of the ELF binary, but due to its usage to libBDF decoding, it only contains some part. The &amp;lt;code&amp;gt;readelf&amp;lt;/code&amp;gt; tool (also part of GNU binutils) display all real segments with &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; option. There is probably still some byte to gain there :).&lt;br /&gt;
 riscv64-elf-readelf -S tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
In compressed mnemonics, only 8 registers are available, due to 3bits limit of the register field in this case. Theses registers are for integer, x8-x15 or s0,s1,a0-a5 (in ABI), and for floats f8-f15 or in ABI fs0,fs1,fa0-fa5. An assembler error will occur if you try to use other registers with c. mnemonics, or a pseudo-instruction will be translated in non c. mnemonic.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones see below for various methods for running RISC-V code.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools. &amp;quot;&amp;lt;code&amp;gt;user static binfmt&amp;lt;/code&amp;gt;&amp;quot; allow to runs risc-v binaries transparently in non-risc-v systems.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ReGIS&amp;diff=1324</id>
		<title>ReGIS</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ReGIS&amp;diff=1324"/>
				<updated>2024-02-15T08:15:23Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''ReGIS''' is a vector graphics markup language made by DEC for it's VT125, VT230, VT240/241 and above terminals. commands can be sent to it by serial or any other text/tty connexion.&lt;br /&gt;
&lt;br /&gt;
== Overview of the features ==&lt;br /&gt;
Depending on terminal resolution and features changes&lt;br /&gt;
* VT125 768×240 pixels, 2 bitplans&lt;br /&gt;
* VT230 800×480 pixels, 2 bitplans&lt;br /&gt;
* VT240/VT241 768×480 pixels, 4 bitplans&lt;br /&gt;
&lt;br /&gt;
There is &amp;quot;shading&amp;quot; management allowing to mix simple patterns for fill or border, &lt;br /&gt;
&lt;br /&gt;
It supports curves with polynomial interpolation, by default with only one point + a value, it builds a circle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use it on Linux distros ==&lt;br /&gt;
Xterm supports it. Arch Linux and derivative support it from scratch. It must be recompiled on Debian and derivatives, with the --enable-regis-graphics option. Display will change depending on used VT emulation.&lt;br /&gt;
&lt;br /&gt;
Launch xterm like this to have more capabilities:&lt;br /&gt;
 xterm +u8 -geometry 132x50 -ti vt340 -tn vt340 /bin/bash&lt;br /&gt;
&lt;br /&gt;
then launch the script or connect by one of the available serial tools (screen, minicom, etc...) to the hw producing the markup.&lt;br /&gt;
&lt;br /&gt;
The markup is send to terminal prefixed, after the documentation by 0x1b 0x50 0x32 x70 (ESC + 'P2p', but on xterm implementation at least, any single digit decimal number instead of 2 works). It is also suffixed by 0x1b 0x5c (ESC + '\', standard VT endline sequence).&lt;br /&gt;
&lt;br /&gt;
Implementation in Bash:&lt;br /&gt;
 echo -e &amp;quot;\x1bP2p${command}\x1b\\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
in Lua:&lt;br /&gt;
 io.stream(string.char(0x1b)..&amp;quot;P2p&amp;quot;..command..string.char(0x1b,0x5c))&lt;br /&gt;
&lt;br /&gt;
'''Don't forget to flush the stream in tests with system based languages, to avoid a buffer filling few seconds wait''' :).&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ReGIS&amp;diff=1323</id>
		<title>ReGIS</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ReGIS&amp;diff=1323"/>
				<updated>2024-02-15T08:07:27Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: Created page with &amp;quot;'''ReGIS''' is a vector graphics markup language made by DEC for it's VT125, VT230, VT240/241 and above terminals. commands can be sent to it by serial or any other text/tty c...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''ReGIS''' is a vector graphics markup language made by DEC for it's VT125, VT230, VT240/241 and above terminals. commands can be sent to it by serial or any other text/tty connexion.&lt;br /&gt;
Depending on terminal resolution and features changes&lt;br /&gt;
* VT125&lt;br /&gt;
&lt;br /&gt;
== Use it on Linux distros ==&lt;br /&gt;
Xterm supports it. Arch Linux and derivative support it from scratch. It must be recompiled on Debian and derivatives, with the --enable-regis-graphics option. Display will change depending on used VT emulation.&lt;br /&gt;
&lt;br /&gt;
Launch xterm like this to have more capabilities:&lt;br /&gt;
 xterm +u8 -geometry 132x50 -ti vt340 -tn vt340 /bin/bash&lt;br /&gt;
&lt;br /&gt;
then launch the script or connect by one of the available serial tools (screen, minicom, etc...) to the hw producing the markup.&lt;br /&gt;
&lt;br /&gt;
The markup is send to terminal prefixed, after the documentation by 0x1b 0x50 0x32 x70 (ESC + 'P2p', but on xterm implementation at least, any single digit decimal number instead of 2 works). It is also suffixed by 0x1b 0x5c (ESC + '\', standard VT endline sequence).&lt;br /&gt;
&lt;br /&gt;
Implementation in Bash:&lt;br /&gt;
 echo -e &amp;quot;\x1bP2p${command}\x1b\\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
in Lua:&lt;br /&gt;
 io.stream(string.char(0x1b)..&amp;quot;P2p&amp;quot;..command..string.char(0x1b,0x5c))&lt;br /&gt;
&lt;br /&gt;
'''Don't forget to flush the stream in tests with system based languages, to avoid a buffer filling few seconds wait''' :).&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1322</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1322"/>
				<updated>2024-02-15T07:54:55Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Welcome to SizeCoding.org! ==&lt;br /&gt;
&lt;br /&gt;
'''SizeCoding.org is a wiki dedicated to the art of creating very tiny programs for most popular types of CPUs. As sizecoding is also popular on other hardware, we recently opened the website for other platforms as well, check the links below.'''  &lt;br /&gt;
&lt;br /&gt;
By &amp;quot;very tiny programs&amp;quot;, we mean programs that are '''256 bytes or less in size''', typically created by members of the [https://en.wikipedia.org/wiki/Demoscene demoscene] as a show of programming skill. The size of these tiny programs is measured by their total size in opcode bytes, and are usually presented as an executable binary.  &lt;br /&gt;
&lt;br /&gt;
'''Despite their tiny size, these programs are able to produce amazing graphical displays, playable games, and sometimes music.'''  There are even some surprisingly effective programs in just '''16 bytes'''  [https://demozoo.org/productions/?platform=&amp;amp;production_type=55] or even '''8 bytes''' [https://demozoo.org/productions/?platform=&amp;amp;production_type=54]. &lt;br /&gt;
&lt;br /&gt;
'''The intent of this wiki is to teach assembler programmers the various techniques used to create tiny demoscene intros.''' &lt;br /&gt;
While these techniques can be used for other applications (boot sectors, ROM, BIOS and firmware code, etc.), the information presented here is firmly oriented towards the demoscene. Practicality and common sense are sometimes thrown out the window just to shave a single byte. Consider yourself warned.&lt;br /&gt;
&lt;br /&gt;
Here is the list of active platforms available on this wiki:&lt;br /&gt;
*'''[[DOS]]''' - Sizecoding for x86/DOS.&lt;br /&gt;
*'''[[Linux]]''' - Sizecoding for Linux.&lt;br /&gt;
*'''[[Fantasy consoles]]''' - Dedicated to Fantasy Consoles , Processing and other Virtual Machine languages (such as JavaScript).&lt;br /&gt;
*'''[[ARM]]''' - ARM-based platforms (RISC OS, Game oy Advance, etc.)&lt;br /&gt;
*'''[[Motorola 68000]]''' - Start sizecoding for the Atari ST or Amiga.&lt;br /&gt;
*'''[[6502]]''' - Commodore 64, Atari XE/XL, Apple II, Atari 2600, Atari Lynx, etc.&lt;br /&gt;
*'''[[Z80]]''' - For all your ZX Spectrum, Amstrad CPC, etc. sizecoding needs.&lt;br /&gt;
*'''[[PDP-11]]''' - Get your BK-0010 and BK-0011 kicks here.&lt;br /&gt;
*'''[[RISC-V]]''' - Mainly on cheap microcontrollers or QEMU for now, but first RISC−V micro-processors based board come since one year. &lt;br /&gt;
*'''[[Bytebeat]]''' - Tiny music created from mathematical expressions.&lt;br /&gt;
*'''[[ReGIS]]''' - VT125, VT230, VT240/241 and more terminal display vector graphics language.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1295</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1295"/>
				<updated>2024-02-08T20:46:21Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Registers */ space between general definition and compressed format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option &amp;lt;code&amp;gt;-x&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;objdump&amp;lt;/code&amp;gt; allow to see all the most segments of the ELF binary, but due to its usage to libBDF decoding, it only contains some part. The &amp;lt;code&amp;gt;readelf&amp;lt;/code&amp;gt; tool (also part of GNU binutils) display all real segments with &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; option. There is probably still some byte to gain there :).&lt;br /&gt;
 riscv64-elf-readelf -S tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
In compressed mnemonics, only 8 registers are available, due to 3bits limit of the register field in this case. Theses registers are for integer, x8-x15 or s0,s1,a0-a5 (in ABI), and for floats f8-f15 or in ABI fs0,fs1,fa0-fa5. An assembler error will occur if you try to use other registers with c. mnemonics, or a pseudo-instruction will be translated in non c. mnemonic.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones see below for various methods for running RISC-V code.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools. &amp;quot;&amp;lt;code&amp;gt;user static binfmt&amp;lt;/code&amp;gt;&amp;quot; allow to runs risc-v binaries transparently in non-risc-v systems.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1294</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1294"/>
				<updated>2024-02-08T20:45:34Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Registers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option &amp;lt;code&amp;gt;-x&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;objdump&amp;lt;/code&amp;gt; allow to see all the most segments of the ELF binary, but due to its usage to libBDF decoding, it only contains some part. The &amp;lt;code&amp;gt;readelf&amp;lt;/code&amp;gt; tool (also part of GNU binutils) display all real segments with &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; option. There is probably still some byte to gain there :).&lt;br /&gt;
 riscv64-elf-readelf -S tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed. In compressed mnemonics, only 8 registers are available, due to 3bits limit of the register field in this case. Theses registers are for integer, x8-x15 or s0,s1,a0-a5 (in ABI), and for floats f8-f15 or in ABI fs0,fs1,fa0-fa5. An assembler error will occur if you try to use other registers with c. mnemonics, or a pseudo-instruction will be translated in non c. mnemonic.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones see below for various methods for running RISC-V code.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools. &amp;quot;&amp;lt;code&amp;gt;user static binfmt&amp;lt;/code&amp;gt;&amp;quot; allow to runs risc-v binaries transparently in non-risc-v systems.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1293</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1293"/>
				<updated>2024-02-08T20:45:16Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Registers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option &amp;lt;code&amp;gt;-x&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;objdump&amp;lt;/code&amp;gt; allow to see all the most segments of the ELF binary, but due to its usage to libBDF decoding, it only contains some part. The &amp;lt;code&amp;gt;readelf&amp;lt;/code&amp;gt; tool (also part of GNU binutils) display all real segments with &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; option. There is probably still some byte to gain there :).&lt;br /&gt;
 riscv64-elf-readelf -S tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed. In compressed mnemonics, only 8 registers are available, due to 3bits limit of the register field in this case. Theses registers are for integer, x8-x15 or s0,s1,a0-a5 (in ABI), and for floating f8-f15 or in ABI fs0,fs1,fa0-fa5. An assembler error will occur if you try to use other registers with c. mnemonics, or a pseudo-instruction will be translated in non c. mnemonic.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones see below for various methods for running RISC-V code.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools. &amp;quot;&amp;lt;code&amp;gt;user static binfmt&amp;lt;/code&amp;gt;&amp;quot; allow to runs risc-v binaries transparently in non-risc-v systems.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1292</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1292"/>
				<updated>2024-02-04T17:47:46Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* General options and 16bits Compressed mnemonics extension */ readelf -S shows more segments than objdump -x&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option &amp;lt;code&amp;gt;-x&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;objdump&amp;lt;/code&amp;gt; allow to see all the most segments of the ELF binary, but due to its usage to libBDF decoding, it only contains some part. The &amp;lt;code&amp;gt;readelf&amp;lt;/code&amp;gt; tool (also part of GNU binutils) display all real segments with &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; option. There is probably still some byte to gain there :).&lt;br /&gt;
 riscv64-elf-readelf -S tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones see below for various methods for running RISC-V code.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools. &amp;quot;&amp;lt;code&amp;gt;user static binfmt&amp;lt;/code&amp;gt;&amp;quot; allow to runs risc-v binaries transparently in non-risc-v systems.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1291</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1291"/>
				<updated>2024-02-02T21:08:53Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Testing it */ +execute risc-v binary transparently on non-RISC−V systems&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option -x of objdump allow to see all the segments of the ELF binary. There is probably still some byte to gain there :):&lt;br /&gt;
 riscv64-elf-objdump -x tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones see below for various methods for running RISC-V code.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools. &amp;quot;&amp;lt;code&amp;gt;user static binfmt&amp;lt;/code&amp;gt;&amp;quot; allow to runs risc-v binaries transparently in non-risc-v systems.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1290</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1290"/>
				<updated>2024-02-02T20:59:44Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Assembler, compiler, linker */ send to bottom chapter to various method of runing risc-v code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option -x of objdump allow to see all the segments of the ELF binary. There is probably still some byte to gain there :):&lt;br /&gt;
 riscv64-elf-objdump -x tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones see below for various methods for running RISC-V code.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1289</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1289"/>
				<updated>2024-02-02T20:58:15Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Assembler, compiler, linker */ more information about available tools&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option -x of objdump allow to see all the segments of the ELF binary. There is probably still some byte to gain there :):&lt;br /&gt;
 riscv64-elf-objdump -x tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools  contains both RISC-V 32 and 64bits compiler (in [https://gcc.gnu.org/ GCC]), assembler (as), linker (ld), striper (strip), dumper/disassembler (objdump) contained in ([https://www.gnu.org/software/binutils/ gnu-binutils]) and debugger ([https://www.sourceware.org/gdb/ GDB], GNU Debugger), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://clang.llvm.org/ CLANG/LLVM] contains compiler/assembler (clang), linker that can strip (ld.lld)&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
* It exists various assembler, simulators, emulators (Qemu, TinyEMU, RVVM,… including WASM versions), various FPGA softcore implementations of RISC-V, and finally lot of cheap ASIC/boards hardware ones.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1288</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1288"/>
				<updated>2024-02-02T20:21:21Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* General options and 16bits Compressed mnemonics extension */ example of li&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo mnemonics (&amp;lt;code&amp;gt;li&amp;lt;/code&amp;gt;=load immediate, is one of them) and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option -x of objdump allow to see all the segments of the ELF binary. There is probably still some byte to gain there :):&lt;br /&gt;
 riscv64-elf-objdump -x tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler,linker,striper (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1287</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1287"/>
				<updated>2024-02-02T20:19:51Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Nomenclature and extensions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
==== General options and 16bits Compressed mnemonics extension ====&lt;br /&gt;
OS like Debian use RV64GC as default compiler extensions options. This mean General (IMAF) + Compressed instructions. Compressed mnemonics (assembly instructions) are a limited subset of mnemonics, that all fits on 16 bits. They are prefixed by &amp;lt;code&amp;gt;c.&amp;lt;/code&amp;gt;, and described in &amp;quot;Chapter 16 . “C” Standard Extension for Compressed Instructions, Version 2.0&amp;quot;, page 97, of  of the current specifications : &amp;quot;[https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf The RISC-V Instruction Set Manual - Volume I: Unprivileged ISA - Document Version 20191213]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
RISC-V Assembly language use pseudo-instructions, and assemblers like those of GCC or CLANG, convert them with their best efforts to more optimised ones, using compressed version, if the C flag is passed to --march argument:&lt;br /&gt;
&lt;br /&gt;
if f(loat) option is passed (as in imafc or gc), the final executable is a bit bigger than without it. So it can be interesting to limit extensions to really used one. However it can be useful to have access to floats numbers in demos.&lt;br /&gt;
&lt;br /&gt;
An example of building script with stripping if floats aren't used. You can decide to pass (tinydemo.s) or not the .s (tinydemo) to the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
riscv64-elf-as -march=rv64imac -o $file.o $file.s&lt;br /&gt;
riscv64-elf-ld -o $file $file.o&lt;br /&gt;
riscv64-elf-strip --strip-all $file&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A similar script with clang. &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; shorter version of &amp;lt;code&amp;gt;-strip-all&amp;lt;/code&amp;gt; can be used. It make slightly bigger elf executables.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
file=${1//.s}&lt;br /&gt;
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o&lt;br /&gt;
ld.lld -strip-all ${file}.o -o ${file}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disassemble the executable file, you can use gnu objdump with -d option:&lt;br /&gt;
 riscv64-elf-objdump -d tinydemo&lt;br /&gt;
However. This show pseudocode version of the software. To display mnemonics really used, add the option &amp;lt;code&amp;gt;-M no-aliases&amp;lt;/code&amp;gt; as is:&lt;br /&gt;
 riscv64-elf-objdump -d -M no-aliases tinydemo&lt;br /&gt;
&lt;br /&gt;
The option -x of objdump allow to see all the segments of the ELF binary. There is probably still some byte to gain there :):&lt;br /&gt;
 riscv64-elf-objdump -x tinydemo&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler,linker,striper (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=942</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=942"/>
				<updated>2021-10-02T09:30:25Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Online version: Metadata and Thumbnail image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the Lua Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so (respectively for JavaScript, MoonScript, Wren, Fennel, Squirrel):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- script: moon&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: wren&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fennel&amp;quot;&amp;gt;;; script: fennel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: squirrel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/nesbox/TIC-80/wiki/tic See here] to know how tic() is called in the different language supported by TIC-80.&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the &amp;lt;code&amp;gt;poke4&amp;lt;/code&amp;gt; instruction, that just change 4 bits. The address have to be multiplied by 2 when using poke4. access to 0x1000 for example is 0x02000 (high nibble) and 0x02001 (low nibble).&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for a playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this screenshot using the F7 key during the demo playback) and use this as you online version. The screenshot can also be imported from a 240×136 PNG (other size will throw an error) using inside TIC-80 console &amp;lt;code&amp;gt;import screen file[.png]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=941</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=941"/>
				<updated>2021-09-30T08:50:46Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* The RISC-V processor ISA */ +about Picorv32 and LUT sizecoding&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio. So there is also some [[LUT sizecoding]] tips, as used in the [https://github.com/kammoh/picorv32 PicoRV32 implementation] (ISC licensen similar to BSD one).  &lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler,linker,striper (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=940</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=940"/>
				<updated>2021-09-29T23:17:19Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Testing it */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler,linker,striper (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC-V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=939</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=939"/>
				<updated>2021-09-29T23:16:19Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Assembler, compiler, linker */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler,linker,striper (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=938</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=938"/>
				<updated>2021-09-29T23:15:36Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Assembler, compiler, linker */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler,linker (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=937</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=937"/>
				<updated>2021-09-29T23:12:31Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* The RISC-V processor ISA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-precision Floating-Point&lt;br /&gt;
* G: '''G'''eneral pupose (all of the above together)&lt;br /&gt;
* Q: '''Q'''uad-precision Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
* S: '''S'''upervisor-level Instruction-Set Extensions&lt;br /&gt;
* H: '''H'''ypervisor-level Instruction-Set Extensions&lt;br /&gt;
* X&amp;lt;name&amp;gt;: Non standard extension&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
Registers in assembly language can be called x0-x31 or by their specific functions. x0 is always 0 and can't be changed.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=936</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=936"/>
				<updated>2021-09-29T23:01:28Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Nomenclature and extensions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G: '''R'''isc'''V''', 32, 64 or 128 bits, base '''E'''mbedded/ '''I'''nteger/'''G'''eneral purpose instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-preicsion Floating-Point&lt;br /&gt;
* Q: '''Q'''uad-preicsion Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=935</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=935"/>
				<updated>2021-09-29T23:00:36Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* The RISC-V processor ISA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
==== Nomenclature and extensions ====&lt;br /&gt;
* RV|32/64/128|E/I/G '''R'''isc'''V''', 32, 64 or 128 bits, base '''I'''nteger instruction set&lt;br /&gt;
&lt;br /&gt;
So you will see generally RV32I for 32bits version + other letters corresponding to extensions as defined below. RV32E means (still) reduced, embedded systems version of integer instruction set. RV32I or (RV64G) means RV32 or RV64 + '''G'''eneral purpose (including IMAFD + Zicsr+ Zifenci extension) as described below:&lt;br /&gt;
&lt;br /&gt;
Basic '''standardized'' extension are:&lt;br /&gt;
* Zifencei: Instruction-Fetch Fence&lt;br /&gt;
* M: '''M'''ultiplication/division&lt;br /&gt;
* A: '''A'''tomic instructions&lt;br /&gt;
* Zicsr: Control and Status Register&lt;br /&gt;
* F: Single-precision '''F'''loating-Point &lt;br /&gt;
* D: '''D'''ouble-preicsion Floating-Point&lt;br /&gt;
* Q: '''Q'''uad-preicsion Floating-Point&lt;br /&gt;
* L: Decima'''l''' Floating-Point (IEEE 754-2008)&lt;br /&gt;
* C: '''C'''ompressed instructions&lt;br /&gt;
* B: '''B'''it manipulation&lt;br /&gt;
* J: '''J'''IT for dynamically translated languages&lt;br /&gt;
* T: '''T'''ransactional memory&lt;br /&gt;
* P: '''P'''acked SIMD instructions&lt;br /&gt;
* V: '''V'''ector instructions (as a vector processor, not as a packed SIMD)&lt;br /&gt;
* Zam: Misaligned Atomics&lt;br /&gt;
* Ztso: Total Store Ordering&lt;br /&gt;
&lt;br /&gt;
* Crypto extension is frozen, and should be available in October.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=934</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=934"/>
				<updated>2021-09-29T22:40:26Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* The RISC-V processor ISA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or LE (&amp;lt;=) hardware instructions, only LT (&amp;lt;) or GE (&amp;gt;=) instructions, but GT and LE can be synthesized by switching it to LT/GE, and the registers in test to keep the test as needed. The only immediate value possible is coded on 12 bits. If the value is signed, the sign will be extended to the higher bit, of the size of the register. Several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. &lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=933</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=933"/>
				<updated>2021-09-29T20:05:53Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* The RISC-V processor ISA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors, as one the goal is to hardly shrink number of transistors. For example, there is no GT (&amp;gt;) or GE (&amp;gt;=) hardware instructions, only LT (&amp;lt;) or LE (&amp;lt;=) instruction, but the RISC-V assembly language support GT and GE, and switch it to LT/LE by switching also registers to keep the test as needed. The same way, several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions. The only immediate value possible is coded on 12 bits.&lt;br /&gt;
&lt;br /&gt;
Generally less instruction in ISA (Instruction Set Architecture) as for RISC-V, means more instruction in machine code to have the same computation process, so RISC-V is not really competitive with other architectures for size-coding. It's advantage is more on transistors size-coding in its implementations, allowing more cores or more extensions than other architecture for the same die size, and a more efficient computation/power ratio.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=932</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=932"/>
				<updated>2021-09-29T19:53:21Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors. For example, there is no GT (&amp;gt;) or GE (&amp;gt;=) hardware instructions, only LT (&amp;lt;) or LE (&amp;lt;=) instruction, but the RISC-V assembly language support GT and GE, and switch it to LT/LE by switching also registers to keep the test as needed. The same way, several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
==== Assembler, compiler, linker ====&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs. It has been used mainly on Longan Nano a RV32 board generally sold with an LCD screen. There are few demo on this board. The initialisation of the screen on this platform has an important footprint that can't allow to go in 128B or 256B competitions. &lt;br /&gt;
&lt;br /&gt;
* Arduino has several RISC-V implementations.&lt;br /&gt;
&lt;br /&gt;
Most other languages are also available in RISC-V instruction set. Some Linux distribution have been ported and ISO are available (Debian, Ubuntu for example). Haiku OS also work on RISC-V platform, and there are plenty of embedded OS working on it (Arduino, FreeRTOS, HarmonyOS, LiteOS, RT-Thread, RustOS, Zephyr...).&lt;br /&gt;
&lt;br /&gt;
=== Testing it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=931</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=931"/>
				<updated>2021-09-29T19:46:20Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors. For example, there is no GT (&amp;gt;) or GE (&amp;gt;=) hardware instructions, only LT (&amp;lt;) or LE (&amp;lt;=) instruction, but the RISC-V assembly language support GT and GE, and switch it to LT/LE by switching also registers to keep the test as needed. The same way, several instructions are supported in RISC-V assembly language that doesn't actually exists as code machine instructions.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
* GNU tools contains both RISC-V 32 and 64bits compiler (GCC), assembler (gnu-binutils) and debugger (GDB), they are available for native or cross-compiling on most GNU/Linux distribution.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/theandrew168/bronzebeard Bronzebeard] is a standalone assembler for developing bare metal RISC-V programs.&lt;br /&gt;
&lt;br /&gt;
=== Test it ===&lt;br /&gt;
If you don't have one of those cheap boards, you can still test RISC-V assembly on an emulator.&lt;br /&gt;
Qemu allow to execute RISC-V application or systems on any kind of architectures. You can use the same tricks than used on x86 to reduce the binary size of the ELF binary format made with GNU tools.&lt;br /&gt;
&lt;br /&gt;
The main author of Qemu also made [https://bellard.org/tinyemu/ TinyEmu], a RISC−V only tiny emulator, it already has WASM ports, so you can play with it on the web.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=930</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=930"/>
				<updated>2021-09-29T19:28:58Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: +link to specifications&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors. For example, there is no GT (&amp;gt;) or GE (&amp;gt;=) hardware instructions, only LT (&amp;lt;) or LE (&amp;lt;=) instruction, but the RISC-V assembly language support GT and GE, and switch it to LT/LE by switching also registers to keep the test as needed.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;br /&gt;
&lt;br /&gt;
The specifications are all available on the risc-v.org site: https://riscv.org/technical/specifications/&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=929</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=929"/>
				<updated>2021-09-29T19:21:13Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and still in draft stage, 128 bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors. For example, there is no GT (&amp;gt;) or GE (&amp;gt;=) hardware instructions, only LT (&amp;lt;) or LE (&amp;lt;=) instruction, but the RISC-V assembly language support GT and GE, and switch it to LT/LE by switching also registers to keep the test as needed.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=928</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=928"/>
				<updated>2021-09-29T19:19:19Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* The RISC processor ISA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and 128 (still in draft stage) bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC-V processor ISA  ===&lt;br /&gt;
The RISC-V Processor is a RISC based architecture, with less instructions than most other RISC processors. For example, there is no GT (&amp;gt;) or GE (&amp;gt;=) hardware instructions, only LT (&amp;lt;) or LE (&amp;lt;=) instruction, but the RISC-V assembly language support GT and GE, and switch it to LT/LE by switching also registers to keep the test as needed.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=927</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=927"/>
				<updated>2021-09-29T19:18:47Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: introduction and few basics about specifications&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
RISC-V is an open and free standard or RISC ISA. It exists in 32,64 and 128 (still in draft stage) bits wide versions. There are lot of free or non free implementations. You can find software, FPGA, or ASIC implementations on most codeforges like Github, Gitlab, Gitea, etc... Several research institute around the world also opened their own versions.&lt;br /&gt;
&lt;br /&gt;
=== The RISC processor ISA  ===&lt;br /&gt;
The RISC Processor is a RISC based architecture, with less instructions than most other RISC processors. For example, there is no GT (&amp;gt;) or GE (&amp;gt;=) hardware instructions, only LT (&amp;lt;) or LE (&amp;lt;=) instruction, but the RISC-V assembly language support GT and GE, and switch it to LT/LE by switching also registers to keep the test as needed.&lt;br /&gt;
&lt;br /&gt;
One of the main goals of the specifications is to have modularity with high granularity. So bitwise operators, multiplications/divisions, vector instructions for example are on different optional extensions, that can be implemented or not by RISC-V processor makers, reducing the total number of transistors depending on processor usage. Each extension have its own letter added in the name of the processor.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=926</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=926"/>
				<updated>2021-09-29T19:03:22Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Welcome to SizeCoding.org! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Welcome to SizeCoding.org! ==&lt;br /&gt;
&lt;br /&gt;
'''SizeCoding.org is a wiki dedicated to the art of creating very tiny programs for most popular types of CPUs. As sizecoding is also popular on other hardware we recently opened the website for other plaforms as well, check the links below.'''  &lt;br /&gt;
&lt;br /&gt;
By &amp;quot;very tiny programs&amp;quot;, we mean programs that are '''256 bytes or less in size''', typically created by members of the [https://en.wikipedia.org/wiki/Demoscene demoscene] as a show of programming skill.  The size of these tiny programs is measured by their total size in opcode bytes, and are usually presented as executable binary.  &lt;br /&gt;
&lt;br /&gt;
'''Despite their tiny size, these programs are able to produce amazing graphical displays, playable games, and sometimes music.'''  There are even some surprisingly effective programs in under '''16 bytes''', such as [https://trixter.oldskool.org/2012/12/17/maze-generation-in-thirteen-bytes/ a maze generator in 10 bytes], a [[Paint16b|mouse-driven paint program in 16 bytes]], and an [[M8trix_8b|&amp;quot;Enter the Matrix&amp;quot; screensaver]] in only 8 bytes. &lt;br /&gt;
&lt;br /&gt;
'''The intent of this wiki is to teach assembler programmers the various techniques used to create tiny demoscene intros.'''  While these techniques can be used for other applications (boot sectors, ROM, BIOS and firmware code, etc.), the information presented here is firmly oriented towards the demoscene.  Practicality and common sense are sometimes thrown out the window just to shave a single byte -- consider yourself warned.&lt;br /&gt;
&lt;br /&gt;
This wiki is divided into the following major sections for x86:&lt;br /&gt;
&lt;br /&gt;
*'''[[Getting Started]]''' - What do you need to know before starting your first tinyprog?&lt;br /&gt;
&lt;br /&gt;
*'''[[Techniques|Tips, Tricks, and Techniques]]''' - The meat of the wiki.  Lists of small opcodes, default environment settings, size optimization basics, and a ton of random tips.&lt;br /&gt;
&lt;br /&gt;
*'''[[Case Studies]]''' - Analysis of existing award-winning tiny programs, with comments on what choices were made and why.&lt;br /&gt;
&lt;br /&gt;
*'''[[Resources|Additional Resources]]''' - Discussion threads, competitions, repositories, and other external references that can aid you in your quest.&lt;br /&gt;
&lt;br /&gt;
For other processors and platforms check out the sections here:&lt;br /&gt;
&lt;br /&gt;
*'''[[Linux]]''' - Sizecoding on linux platforms.&lt;br /&gt;
*'''[[RISC OS on ARM based CPUs]]''' - Create your tiny intro on ARM hardware on RISC OS.&lt;br /&gt;
*'''[[ARM based CPUs]]''' - Other ARM Based Plaforms (Gameboy Advance, etc.)&lt;br /&gt;
*'''[[Motorola 68k based CPUS]]''' - Start Sizecoding on your Atari ST or Amiga.&lt;br /&gt;
*'''[[6502 based CPUs]]''' - Commodore 64, Atari XE/XL, Apple II, Atari 2600, Atari Lynx, etc.&lt;br /&gt;
*'''[[Z80 based CPUs]]''' - For all your ZX Spectrum, Amstrad CPC, etc. sizecoding needs&lt;br /&gt;
*'''[[PDP-11 CPUs]]''' - Get your BK-0010 and BK-0011 kicks here&lt;br /&gt;
*'''[[RISC-V CPUs]]''' - Mainly on cheap micro-controllers or qemu for now, but first RISC−V micro-processors based board come since one year. &lt;br /&gt;
*'''[[Fantasy Consoles]]''' - Dedicated to Fantasy Consoles and VM's like TIC-80, PICO-8, Javascript/js1k, etc.&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=925</id>
		<title>Motorola 68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=925"/>
				<updated>2021-09-29T19:01:56Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* The Motorola 68k processor */ +about 68k instruction timing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Wanting to start sizecoding on a Motorola 68k platform in this day and age can be tough. &lt;br /&gt;
&lt;br /&gt;
So here is a bit of help to get you started:&lt;br /&gt;
&lt;br /&gt;
=== The Motorola 68k processor  ===&lt;br /&gt;
The Motorola 68k processor... &lt;br /&gt;
&lt;br /&gt;
Note:  Assigment direction is source,dest instead of dest,source !!!&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== Instructions timing ====&lt;br /&gt;
The number of cycles for each instruction is different depending of processor model in M68K family.&lt;br /&gt;
: http://oldwww.nvg.ntnu.no/amiga/MC680x0_Sections/mc68000timing.HTML&lt;br /&gt;
&lt;br /&gt;
== Atari ST ==&lt;br /&gt;
The Atari ST systems consists of the M68k system with custom hardware for graphics and sound.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
Setting up your development platform for the Atari ST systems is quite easy, first get the following tools:&lt;br /&gt;
&lt;br /&gt;
* Assembler: VASM - This assembler is able to assemble directly to a TOS executable&lt;br /&gt;
* Assembler: [http://rmac.is-slick.com RMAC] - Can assemble to TOS executable as well as a headerless absolute binary&lt;br /&gt;
* Emulator(s): -. Make sure to use the original TOS 1.62 Image for best compatibility.&lt;br /&gt;
&lt;br /&gt;
==== Compiling to a TOS image ====&lt;br /&gt;
Vasm -Ftos source.s -o source.tos&lt;br /&gt;
rmac -p -o source.tos source.s&lt;br /&gt;
&lt;br /&gt;
=== ST executable format, and why you should write relocatable code ===&lt;br /&gt;
&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The Atari ST uses an interleaved planar memory layout to represent its paletted display modes (we'll concentrate on 320x200x16 colours here). &lt;br /&gt;
&lt;br /&gt;
==== Paletted? ====&lt;br /&gt;
The Atari ST uses index values into a palette of colours. Index 0 is the background colour (that's also used for the border) and a maximum of 16 colours can be defined and indexed.&lt;br /&gt;
&lt;br /&gt;
==== Planes? ====&lt;br /&gt;
Every plane contains one bit of a pixel's colour index value. The bits of the binary representation of a colour index like %1010 (% Bit3,Bit2,Bit1,Bit0) will end up in 4 different planes (bits most significant to least significant aka left to right): Plane4 Plane3 Plane2 Plane1. &lt;br /&gt;
&lt;br /&gt;
So basicly Plane1 contains all of the Bit0s of all pixels, Plane2 all Bit1s, Plane3 all Bit2s and Plabe4 all Bit3s.&lt;br /&gt;
&lt;br /&gt;
The first pixel on a plane is described by the leftmost (aka most significant) bit in a word, the second one by the second-leftmost etc. - just like this %0123456789abcdef with 0-f=pixels 1-16. %1000000000000000=$8000=pixel 1 in a plane word set. The 16th pixel will use the leftmost bit of the next word in this plane. etc.&lt;br /&gt;
&lt;br /&gt;
==== Interleaved? ====&lt;br /&gt;
16 pixels worth of data are represented as a full graphicword, meaning all information to display 16 pixels are stored together, followed by the data to represent the next 16 pixels etc. One row worth of display data has 20 graphicwords (20*16 pixels=320 pixels).&lt;br /&gt;
&lt;br /&gt;
16 pixels are stored in 4 words - which contain 4 of the aforementioned planes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
So a 320x200x16 colour display is a contiuous memory buffer containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Pixels 0-15, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
Pixels 16-31, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
Pixels 32-47, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
......&lt;br /&gt;
Pixels 304-319, row 199:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To be refined soon.&lt;br /&gt;
&lt;br /&gt;
==== Setting a palette ====&lt;br /&gt;
Here is some code that will help you setup a palette&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
pea	palette(pc)&lt;br /&gt;
	move.w	#6,-(sp)&lt;br /&gt;
	trap	#14&lt;br /&gt;
&lt;br /&gt;
; Palette data&lt;br /&gt;
palette:	&lt;br /&gt;
	dc.w	$000,$100,$200,$311,$422,$533,$644,$755&lt;br /&gt;
	dc.w	$575,$464,$353,$242,$131,$020,$010,$000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
	;-----------------------&lt;br /&gt;
	; Line-A Initialization&lt;br /&gt;
	;-----------------------&lt;br /&gt;
; After calling this function, data register D0 and address register A0 point to a table ; with the starting address of the Line A variables. &lt;br /&gt;
; Address register A1 points to a table with the starting addresses for the three system ; font headers, &lt;br /&gt;
; and address register A2 points to a table that specifies the starting addresses of the; 15 Line A opcodes. There's no parameter required for this function, so all you have&lt;br /&gt;
; to do is call the word opcode label that you specified for the $A000 (Initialize)&lt;br /&gt;
; function.&lt;br /&gt;
	dc.w	$A000&lt;br /&gt;
	movem.l	(a0),a1-a4		; A3=INTIN, A4=PTSIN&lt;br /&gt;
&lt;br /&gt;
	;---------&lt;br /&gt;
	; For X&amp;amp;Y&lt;br /&gt;
	;---------&lt;br /&gt;
frameloop:&lt;br /&gt;
	move.w	#200-1,d7		; y&lt;br /&gt;
yLoop:	&lt;br /&gt;
	move.w	#320-1,d6		; x&lt;br /&gt;
xLoop:&lt;br /&gt;
&lt;br /&gt;
	; Putpixel&lt;br /&gt;
put_pixel:	&lt;br /&gt;
	move.b d6,d0		; d0=x&lt;br /&gt;
	eor d7,d0			; d0=x^y&lt;br /&gt;
	lsr.b #2,d0			; d0&amp;gt;&amp;gt;=4&lt;br /&gt;
	and #42,d0			; d0&amp;amp;42&lt;br /&gt;
	&lt;br /&gt;
	move.w	d0,(a3)		; a3=color(d0)&lt;br /&gt;
	movem.w	d6/d7,(a4)	; a4=x,y`&lt;br /&gt;
	&lt;br /&gt;
	dc.w	$A001		; put pixel command&lt;br /&gt;
&lt;br /&gt;
	dbra	d6,xLoop		; decrease and branch&lt;br /&gt;
    dbra	d7,yLoop&lt;br /&gt;
&lt;br /&gt;
; Wait loop&lt;br /&gt;
	bra frameloop ; .s	*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Atari ST systems use the YM2149 chip to generate sound.\&lt;br /&gt;
&lt;br /&gt;
For more information check out https://www.atarimagazines.com/v4n7/stsound.html&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
To be added soon.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the Atari ST is not very huge yet, so resources are sparse.&lt;br /&gt;
&lt;br /&gt;
[http://beyondbrown.mooo.com/post/mona/ Here is a writeup to porting of Mona to the Atari ST], containing many hints.&lt;br /&gt;
&lt;br /&gt;
Here are some bytetros with source code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prod name (Pouet link) !! Source code&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=64455 128b Palette Starfield by Gaston] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gaston/starfield_128b_src/STARFLD.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=64468 Fractal Landscape bootsector by Gaston] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gaston/fractal_boot_src/FRACTAL.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=22325 BIG scroller by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/bigscrol&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=16924 128byte drum machine by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/128drum&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=17041 128byte Theremin by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/theremin.128&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=17370 128byte virtual 303 by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/128b_303&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25051 88 Bytes by Sedma] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Sedma/SEDMA_ST&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25052 Realtime Competition by Mystic Bytes] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/OUT2K5/mikro&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=24965 The Bootshitctor by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/boot&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=50496 BOOT MY PIGGY GAME by Lineout &amp;amp; KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/piggy&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=53190 Keeping atari alive by D-Bug] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/D-Bug/OL09BOOT/OL09BOOT.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=53198 dla by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/dla/src&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=54952 quadratic splines by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/quad/QUAD.SRC&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=56279 TT-Noise by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/ttnoise&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=57063 Random Cell by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/Positivity/cell/CELL.SRC&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=57921 128 byte Choonage by Psycho Hacking Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/PHF/128choon&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=58123 ShowMem by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/showmem&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=65455 Benoît by Orb] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/RB/Benoit(ST)&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=65611 1 euro by Lineout &amp;amp; KÜA software productions &amp;amp; Psycho Hacking Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/BIER/source&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=67392 Έτη πολλα! by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/etipolla&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=68508 Sync128b by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/sync128b&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72891 128B Mandelbrot Set by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/128b-Mandelbrot_Set&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72893 64B Sierpinski Scroller by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/64b-Sierpinski_Scroller&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72894 32B Sierpinski Triangles by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/32b-Sierpinski_Triangle&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72895 32B Noise by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/32b-Noise&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=78762 Fractal 128 by Orion_] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Cedric%20Bourse%20(orion_)/fract128&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=81758 ImPerfect by Satantronic] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Satantronic/IMPERFCT&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84120 tunnelST by atariBDSM] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/atariBDSM/tunnelST&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84238 Blues by tr1x] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/tr1x/BLUES&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84239 Shades by tr1x] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/tr1x/SHADES&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86138 Wobble by Gash] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gash/wobble/wobble.s&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86127 MindBender by Defence Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Defence Force/MindBender&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86129 DER SPKR IMPERATIV by SMFX] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/SMFX/imperati/imperativ.s&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And some for the Atari Falcon&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prod name (pouet link) !! Source code&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25220 NoBrains Mandelbrot Zoomer 128 by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/mandel&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28781 128 bytes Plasma demo by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/plasma&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28783 128 bytes Pyro demo by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/pyro&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28784 128 bytes Sierspinksi by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/sierpins&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28856 128 TRON][ by T.O.Y.S.] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/T.O.Y.S/128TRON2/SOURCE/128TRON2.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28762 Strange Things Happends In Sweden by Mind Design] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Mind%20Design/Strange%20Things%20Happends%20InSweden&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25221 Mixed Dots 128 by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/mixdots/src&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25050 Realtime Competition Falcon by Sedma] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Sedma/SEDMA_F&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Commodore Amiga ==&lt;br /&gt;
The Commodore Amiga system consists of the M68k system with custom hardware for graphics and sound.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Assembler: -&lt;br /&gt;
* Emulator(s): Linux: fs-uae, Windows: WinUAE&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* Amucoders https://amycoders.org/&lt;br /&gt;
* [https://archive.org/details/Amiga_Hardware_Reference_Manual_1985_Commodore Amiga Harware Reference Manual from Commodore (scans on Archive.org)]&lt;br /&gt;
* [http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0000.html HTML version on elowar.com]&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=924</id>
		<title>Motorola 68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=924"/>
				<updated>2021-09-29T18:58:12Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Additional Resources */ +amiga hardware manual, the main reference about audio/graphics/video coprocessors&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Wanting to start sizecoding on a Motorola 68k platform in this day and age can be tough. &lt;br /&gt;
&lt;br /&gt;
So here is a bit of help to get you started:&lt;br /&gt;
&lt;br /&gt;
=== The Motorola 68k processor  ===&lt;br /&gt;
The Motorola 68k processor... &lt;br /&gt;
&lt;br /&gt;
Note:  Assigment direction is source,dest instead of dest,source !!!&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
== Atari ST ==&lt;br /&gt;
The Atari ST systems consists of the M68k system with custom hardware for graphics and sound.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
Setting up your development platform for the Atari ST systems is quite easy, first get the following tools:&lt;br /&gt;
&lt;br /&gt;
* Assembler: VASM - This assembler is able to assemble directly to a TOS executable&lt;br /&gt;
* Assembler: [http://rmac.is-slick.com RMAC] - Can assemble to TOS executable as well as a headerless absolute binary&lt;br /&gt;
* Emulator(s): -. Make sure to use the original TOS 1.62 Image for best compatibility.&lt;br /&gt;
&lt;br /&gt;
==== Compiling to a TOS image ====&lt;br /&gt;
Vasm -Ftos source.s -o source.tos&lt;br /&gt;
rmac -p -o source.tos source.s&lt;br /&gt;
&lt;br /&gt;
=== ST executable format, and why you should write relocatable code ===&lt;br /&gt;
&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The Atari ST uses an interleaved planar memory layout to represent its paletted display modes (we'll concentrate on 320x200x16 colours here). &lt;br /&gt;
&lt;br /&gt;
==== Paletted? ====&lt;br /&gt;
The Atari ST uses index values into a palette of colours. Index 0 is the background colour (that's also used for the border) and a maximum of 16 colours can be defined and indexed.&lt;br /&gt;
&lt;br /&gt;
==== Planes? ====&lt;br /&gt;
Every plane contains one bit of a pixel's colour index value. The bits of the binary representation of a colour index like %1010 (% Bit3,Bit2,Bit1,Bit0) will end up in 4 different planes (bits most significant to least significant aka left to right): Plane4 Plane3 Plane2 Plane1. &lt;br /&gt;
&lt;br /&gt;
So basicly Plane1 contains all of the Bit0s of all pixels, Plane2 all Bit1s, Plane3 all Bit2s and Plabe4 all Bit3s.&lt;br /&gt;
&lt;br /&gt;
The first pixel on a plane is described by the leftmost (aka most significant) bit in a word, the second one by the second-leftmost etc. - just like this %0123456789abcdef with 0-f=pixels 1-16. %1000000000000000=$8000=pixel 1 in a plane word set. The 16th pixel will use the leftmost bit of the next word in this plane. etc.&lt;br /&gt;
&lt;br /&gt;
==== Interleaved? ====&lt;br /&gt;
16 pixels worth of data are represented as a full graphicword, meaning all information to display 16 pixels are stored together, followed by the data to represent the next 16 pixels etc. One row worth of display data has 20 graphicwords (20*16 pixels=320 pixels).&lt;br /&gt;
&lt;br /&gt;
16 pixels are stored in 4 words - which contain 4 of the aforementioned planes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
So a 320x200x16 colour display is a contiuous memory buffer containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Pixels 0-15, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
Pixels 16-31, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
Pixels 32-47, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
......&lt;br /&gt;
Pixels 304-319, row 199:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To be refined soon.&lt;br /&gt;
&lt;br /&gt;
==== Setting a palette ====&lt;br /&gt;
Here is some code that will help you setup a palette&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
pea	palette(pc)&lt;br /&gt;
	move.w	#6,-(sp)&lt;br /&gt;
	trap	#14&lt;br /&gt;
&lt;br /&gt;
; Palette data&lt;br /&gt;
palette:	&lt;br /&gt;
	dc.w	$000,$100,$200,$311,$422,$533,$644,$755&lt;br /&gt;
	dc.w	$575,$464,$353,$242,$131,$020,$010,$000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
	;-----------------------&lt;br /&gt;
	; Line-A Initialization&lt;br /&gt;
	;-----------------------&lt;br /&gt;
; After calling this function, data register D0 and address register A0 point to a table ; with the starting address of the Line A variables. &lt;br /&gt;
; Address register A1 points to a table with the starting addresses for the three system ; font headers, &lt;br /&gt;
; and address register A2 points to a table that specifies the starting addresses of the; 15 Line A opcodes. There's no parameter required for this function, so all you have&lt;br /&gt;
; to do is call the word opcode label that you specified for the $A000 (Initialize)&lt;br /&gt;
; function.&lt;br /&gt;
	dc.w	$A000&lt;br /&gt;
	movem.l	(a0),a1-a4		; A3=INTIN, A4=PTSIN&lt;br /&gt;
&lt;br /&gt;
	;---------&lt;br /&gt;
	; For X&amp;amp;Y&lt;br /&gt;
	;---------&lt;br /&gt;
frameloop:&lt;br /&gt;
	move.w	#200-1,d7		; y&lt;br /&gt;
yLoop:	&lt;br /&gt;
	move.w	#320-1,d6		; x&lt;br /&gt;
xLoop:&lt;br /&gt;
&lt;br /&gt;
	; Putpixel&lt;br /&gt;
put_pixel:	&lt;br /&gt;
	move.b d6,d0		; d0=x&lt;br /&gt;
	eor d7,d0			; d0=x^y&lt;br /&gt;
	lsr.b #2,d0			; d0&amp;gt;&amp;gt;=4&lt;br /&gt;
	and #42,d0			; d0&amp;amp;42&lt;br /&gt;
	&lt;br /&gt;
	move.w	d0,(a3)		; a3=color(d0)&lt;br /&gt;
	movem.w	d6/d7,(a4)	; a4=x,y`&lt;br /&gt;
	&lt;br /&gt;
	dc.w	$A001		; put pixel command&lt;br /&gt;
&lt;br /&gt;
	dbra	d6,xLoop		; decrease and branch&lt;br /&gt;
    dbra	d7,yLoop&lt;br /&gt;
&lt;br /&gt;
; Wait loop&lt;br /&gt;
	bra frameloop ; .s	*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Atari ST systems use the YM2149 chip to generate sound.\&lt;br /&gt;
&lt;br /&gt;
For more information check out https://www.atarimagazines.com/v4n7/stsound.html&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
To be added soon.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the Atari ST is not very huge yet, so resources are sparse.&lt;br /&gt;
&lt;br /&gt;
[http://beyondbrown.mooo.com/post/mona/ Here is a writeup to porting of Mona to the Atari ST], containing many hints.&lt;br /&gt;
&lt;br /&gt;
Here are some bytetros with source code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prod name (Pouet link) !! Source code&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=64455 128b Palette Starfield by Gaston] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gaston/starfield_128b_src/STARFLD.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=64468 Fractal Landscape bootsector by Gaston] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gaston/fractal_boot_src/FRACTAL.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=22325 BIG scroller by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/bigscrol&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=16924 128byte drum machine by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/128drum&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=17041 128byte Theremin by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/theremin.128&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=17370 128byte virtual 303 by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/128b_303&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25051 88 Bytes by Sedma] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Sedma/SEDMA_ST&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25052 Realtime Competition by Mystic Bytes] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/OUT2K5/mikro&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=24965 The Bootshitctor by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/boot&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=50496 BOOT MY PIGGY GAME by Lineout &amp;amp; KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/piggy&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=53190 Keeping atari alive by D-Bug] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/D-Bug/OL09BOOT/OL09BOOT.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=53198 dla by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/dla/src&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=54952 quadratic splines by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/quad/QUAD.SRC&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=56279 TT-Noise by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/ttnoise&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=57063 Random Cell by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/Positivity/cell/CELL.SRC&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=57921 128 byte Choonage by Psycho Hacking Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/PHF/128choon&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=58123 ShowMem by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/showmem&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=65455 Benoît by Orb] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/RB/Benoit(ST)&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=65611 1 euro by Lineout &amp;amp; KÜA software productions &amp;amp; Psycho Hacking Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/BIER/source&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=67392 Έτη πολλα! by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/etipolla&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=68508 Sync128b by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/sync128b&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72891 128B Mandelbrot Set by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/128b-Mandelbrot_Set&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72893 64B Sierpinski Scroller by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/64b-Sierpinski_Scroller&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72894 32B Sierpinski Triangles by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/32b-Sierpinski_Triangle&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72895 32B Noise by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/32b-Noise&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=78762 Fractal 128 by Orion_] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Cedric%20Bourse%20(orion_)/fract128&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=81758 ImPerfect by Satantronic] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Satantronic/IMPERFCT&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84120 tunnelST by atariBDSM] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/atariBDSM/tunnelST&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84238 Blues by tr1x] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/tr1x/BLUES&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84239 Shades by tr1x] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/tr1x/SHADES&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86138 Wobble by Gash] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gash/wobble/wobble.s&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86127 MindBender by Defence Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Defence Force/MindBender&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86129 DER SPKR IMPERATIV by SMFX] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/SMFX/imperati/imperativ.s&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And some for the Atari Falcon&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prod name (pouet link) !! Source code&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25220 NoBrains Mandelbrot Zoomer 128 by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/mandel&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28781 128 bytes Plasma demo by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/plasma&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28783 128 bytes Pyro demo by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/pyro&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28784 128 bytes Sierspinksi by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/sierpins&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28856 128 TRON][ by T.O.Y.S.] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/T.O.Y.S/128TRON2/SOURCE/128TRON2.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28762 Strange Things Happends In Sweden by Mind Design] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Mind%20Design/Strange%20Things%20Happends%20InSweden&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25221 Mixed Dots 128 by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/mixdots/src&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25050 Realtime Competition Falcon by Sedma] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Sedma/SEDMA_F&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Commodore Amiga ==&lt;br /&gt;
The Commodore Amiga system consists of the M68k system with custom hardware for graphics and sound.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Assembler: -&lt;br /&gt;
* Emulator(s): Linux: fs-uae, Windows: WinUAE&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* Amucoders https://amycoders.org/&lt;br /&gt;
* [https://archive.org/details/Amiga_Hardware_Reference_Manual_1985_Commodore Amiga Harware Reference Manual from Commodore (scans on Archive.org)]&lt;br /&gt;
* [http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0000.html HTML version on elowar.com]&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=923</id>
		<title>Motorola 68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=923"/>
				<updated>2021-09-29T18:53:40Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Setting up */ +fs-uae for linux&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Wanting to start sizecoding on a Motorola 68k platform in this day and age can be tough. &lt;br /&gt;
&lt;br /&gt;
So here is a bit of help to get you started:&lt;br /&gt;
&lt;br /&gt;
=== The Motorola 68k processor  ===&lt;br /&gt;
The Motorola 68k processor... &lt;br /&gt;
&lt;br /&gt;
Note:  Assigment direction is source,dest instead of dest,source !!!&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
== Atari ST ==&lt;br /&gt;
The Atari ST systems consists of the M68k system with custom hardware for graphics and sound.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
Setting up your development platform for the Atari ST systems is quite easy, first get the following tools:&lt;br /&gt;
&lt;br /&gt;
* Assembler: VASM - This assembler is able to assemble directly to a TOS executable&lt;br /&gt;
* Assembler: [http://rmac.is-slick.com RMAC] - Can assemble to TOS executable as well as a headerless absolute binary&lt;br /&gt;
* Emulator(s): -. Make sure to use the original TOS 1.62 Image for best compatibility.&lt;br /&gt;
&lt;br /&gt;
==== Compiling to a TOS image ====&lt;br /&gt;
Vasm -Ftos source.s -o source.tos&lt;br /&gt;
rmac -p -o source.tos source.s&lt;br /&gt;
&lt;br /&gt;
=== ST executable format, and why you should write relocatable code ===&lt;br /&gt;
&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The Atari ST uses an interleaved planar memory layout to represent its paletted display modes (we'll concentrate on 320x200x16 colours here). &lt;br /&gt;
&lt;br /&gt;
==== Paletted? ====&lt;br /&gt;
The Atari ST uses index values into a palette of colours. Index 0 is the background colour (that's also used for the border) and a maximum of 16 colours can be defined and indexed.&lt;br /&gt;
&lt;br /&gt;
==== Planes? ====&lt;br /&gt;
Every plane contains one bit of a pixel's colour index value. The bits of the binary representation of a colour index like %1010 (% Bit3,Bit2,Bit1,Bit0) will end up in 4 different planes (bits most significant to least significant aka left to right): Plane4 Plane3 Plane2 Plane1. &lt;br /&gt;
&lt;br /&gt;
So basicly Plane1 contains all of the Bit0s of all pixels, Plane2 all Bit1s, Plane3 all Bit2s and Plabe4 all Bit3s.&lt;br /&gt;
&lt;br /&gt;
The first pixel on a plane is described by the leftmost (aka most significant) bit in a word, the second one by the second-leftmost etc. - just like this %0123456789abcdef with 0-f=pixels 1-16. %1000000000000000=$8000=pixel 1 in a plane word set. The 16th pixel will use the leftmost bit of the next word in this plane. etc.&lt;br /&gt;
&lt;br /&gt;
==== Interleaved? ====&lt;br /&gt;
16 pixels worth of data are represented as a full graphicword, meaning all information to display 16 pixels are stored together, followed by the data to represent the next 16 pixels etc. One row worth of display data has 20 graphicwords (20*16 pixels=320 pixels).&lt;br /&gt;
&lt;br /&gt;
16 pixels are stored in 4 words - which contain 4 of the aforementioned planes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
So a 320x200x16 colour display is a contiuous memory buffer containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Pixels 0-15, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
Pixels 16-31, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
Pixels 32-47, row 0:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
......&lt;br /&gt;
Pixels 304-319, row 199:(Plane1.w Plane2.w Plane3.w Plane4.w)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To be refined soon.&lt;br /&gt;
&lt;br /&gt;
==== Setting a palette ====&lt;br /&gt;
Here is some code that will help you setup a palette&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
pea	palette(pc)&lt;br /&gt;
	move.w	#6,-(sp)&lt;br /&gt;
	trap	#14&lt;br /&gt;
&lt;br /&gt;
; Palette data&lt;br /&gt;
palette:	&lt;br /&gt;
	dc.w	$000,$100,$200,$311,$422,$533,$644,$755&lt;br /&gt;
	dc.w	$575,$464,$353,$242,$131,$020,$010,$000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
	;-----------------------&lt;br /&gt;
	; Line-A Initialization&lt;br /&gt;
	;-----------------------&lt;br /&gt;
; After calling this function, data register D0 and address register A0 point to a table ; with the starting address of the Line A variables. &lt;br /&gt;
; Address register A1 points to a table with the starting addresses for the three system ; font headers, &lt;br /&gt;
; and address register A2 points to a table that specifies the starting addresses of the; 15 Line A opcodes. There's no parameter required for this function, so all you have&lt;br /&gt;
; to do is call the word opcode label that you specified for the $A000 (Initialize)&lt;br /&gt;
; function.&lt;br /&gt;
	dc.w	$A000&lt;br /&gt;
	movem.l	(a0),a1-a4		; A3=INTIN, A4=PTSIN&lt;br /&gt;
&lt;br /&gt;
	;---------&lt;br /&gt;
	; For X&amp;amp;Y&lt;br /&gt;
	;---------&lt;br /&gt;
frameloop:&lt;br /&gt;
	move.w	#200-1,d7		; y&lt;br /&gt;
yLoop:	&lt;br /&gt;
	move.w	#320-1,d6		; x&lt;br /&gt;
xLoop:&lt;br /&gt;
&lt;br /&gt;
	; Putpixel&lt;br /&gt;
put_pixel:	&lt;br /&gt;
	move.b d6,d0		; d0=x&lt;br /&gt;
	eor d7,d0			; d0=x^y&lt;br /&gt;
	lsr.b #2,d0			; d0&amp;gt;&amp;gt;=4&lt;br /&gt;
	and #42,d0			; d0&amp;amp;42&lt;br /&gt;
	&lt;br /&gt;
	move.w	d0,(a3)		; a3=color(d0)&lt;br /&gt;
	movem.w	d6/d7,(a4)	; a4=x,y`&lt;br /&gt;
	&lt;br /&gt;
	dc.w	$A001		; put pixel command&lt;br /&gt;
&lt;br /&gt;
	dbra	d6,xLoop		; decrease and branch&lt;br /&gt;
    dbra	d7,yLoop&lt;br /&gt;
&lt;br /&gt;
; Wait loop&lt;br /&gt;
	bra frameloop ; .s	*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Atari ST systems use the YM2149 chip to generate sound.\&lt;br /&gt;
&lt;br /&gt;
For more information check out https://www.atarimagazines.com/v4n7/stsound.html&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
To be added soon.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the Atari ST is not very huge yet, so resources are sparse.&lt;br /&gt;
&lt;br /&gt;
[http://beyondbrown.mooo.com/post/mona/ Here is a writeup to porting of Mona to the Atari ST], containing many hints.&lt;br /&gt;
&lt;br /&gt;
Here are some bytetros with source code:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prod name (Pouet link) !! Source code&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=64455 128b Palette Starfield by Gaston] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gaston/starfield_128b_src/STARFLD.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=64468 Fractal Landscape bootsector by Gaston] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gaston/fractal_boot_src/FRACTAL.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=22325 BIG scroller by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/bigscrol&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=16924 128byte drum machine by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/128drum&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=17041 128byte Theremin by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/theremin.128&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=17370 128byte virtual 303 by gwEm] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Preromanbritain/128b_303&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25051 88 Bytes by Sedma] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Sedma/SEDMA_ST&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25052 Realtime Competition by Mystic Bytes] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/OUT2K5/mikro&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=24965 The Bootshitctor by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/boot&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=50496 BOOT MY PIGGY GAME by Lineout &amp;amp; KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/piggy&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=53190 Keeping atari alive by D-Bug] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/D-Bug/OL09BOOT/OL09BOOT.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=53198 dla by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/dla/src&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=54952 quadratic splines by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/quad/QUAD.SRC&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=56279 TT-Noise by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/ttnoise&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=57063 Random Cell by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/Positivity/cell/CELL.SRC&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=57921 128 byte Choonage by Psycho Hacking Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/PHF/128choon&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=58123 ShowMem by Positivity] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Positivity/showmem&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=65455 Benoît by Orb] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/RB/Benoit(ST)&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=65611 1 euro by Lineout &amp;amp; KÜA software productions &amp;amp; Psycho Hacking Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/BIER/source&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=67392 Έτη πολλα! by KÜA software productions] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/KÜA%20software%20productions/etipolla&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=68508 Sync128b by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/sync128b&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72891 128B Mandelbrot Set by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/128b-Mandelbrot_Set&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72893 64B Sierpinski Scroller by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/64b-Sierpinski_Scroller&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72894 32B Sierpinski Triangles by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/32b-Sierpinski_Triangle&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=72895 32B Noise by Dyno] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Dyno/32b-Noise&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=78762 Fractal 128 by Orion_] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Cedric%20Bourse%20(orion_)/fract128&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=81758 ImPerfect by Satantronic] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Satantronic/IMPERFCT&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84120 tunnelST by atariBDSM] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/atariBDSM/tunnelST&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84238 Blues by tr1x] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/tr1x/BLUES&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=84239 Shades by tr1x] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/tr1x/SHADES&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86138 Wobble by Gash] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/Gash/wobble/wobble.s&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86127 MindBender by Defence Force] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Defence Force/MindBender&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=86129 DER SPKR IMPERATIV by SMFX] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/SMFX/imperati/imperativ.s&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And some for the Atari Falcon&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prod name (pouet link) !! Source code&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25220 NoBrains Mandelbrot Zoomer 128 by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/mandel&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28781 128 bytes Plasma demo by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/plasma&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28783 128 bytes Pyro demo by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/pyro&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28784 128 bytes Sierspinksi by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/sierpins&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28856 128 TRON][ by T.O.Y.S.] || https://github.com/ggnkua/Atari_ST_Sources/blob/master/ASM/T.O.Y.S/128TRON2/SOURCE/128TRON2.S&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=28762 Strange Things Happends In Sweden by Mind Design] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Mind%20Design/Strange%20Things%20Happends%20InSweden&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25221 Mixed Dots 128 by NoCrew] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/NoCrew/mixdots/src&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.pouet.net/prod.php?which=25050 Realtime Competition Falcon by Sedma] || https://github.com/ggnkua/Atari_ST_Sources/tree/master/ASM/Various/Sedma/SEDMA_F&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Commodore Amiga ==&lt;br /&gt;
The Commodore Amiga system consists of the M68k system with custom hardware for graphics and sound.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Assembler: -&lt;br /&gt;
* Emulator(s): Linux: fs-uae, Windows: WinUAE&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* Amucoders https://amycoders.org/&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=922</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=922"/>
				<updated>2021-09-26T19:58:27Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Video display */ more details about poke4.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the Lua Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so (respectively for JavaScript, MoonScript, Wren, Fennel, Squirrel):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- script: moon&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: wren&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fennel&amp;quot;&amp;gt;;; script: fennel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: squirrel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/nesbox/TIC-80/wiki/tic See here] to know how tic() is called in the different language supported by TIC-80.&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the &amp;lt;code&amp;gt;poke4&amp;lt;/code&amp;gt; instruction, that just change 4 bits. The address have to be multiplied by 2 when using poke4. access to 0x1000 for example is 0x02000 (high nibble) and 0x02001 (low nibble).&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for a playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this screenshot using the F7 key during the demo playback) and use this as you online version. The screenshot can also be imported from a 240×136 16 colors PNG (other size/format will throw an error) using inside TIC-80 console &amp;lt;code&amp;gt;import screen file[.png]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=921</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=921"/>
				<updated>2021-09-26T19:54:44Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Video display */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the Lua Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so (respectively for JavaScript, MoonScript, Wren, Fennel, Squirrel):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- script: moon&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: wren&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fennel&amp;quot;&amp;gt;;; script: fennel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: squirrel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/nesbox/TIC-80/wiki/tic See here] to know how tic() is called in the different language supported by TIC-80.&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the &amp;lt;code&amp;gt;poke4&amp;lt;/code&amp;gt; instruction.&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for a playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this screenshot using the F7 key during the demo playback) and use this as you online version. The screenshot can also be imported from a 240×136 16 colors PNG (other size/format will throw an error) using inside TIC-80 console &amp;lt;code&amp;gt;import screen file[.png]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=920</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=920"/>
				<updated>2021-09-26T19:50:15Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Getting started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the Lua Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so (respectively for JavaScript, MoonScript, Wren, Fennel, Squirrel):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- script: moon&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: wren&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fennel&amp;quot;&amp;gt;;; script: fennel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: squirrel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/nesbox/TIC-80/wiki/tic See here] to know how tic() is called in the different language supported by TIC-80.&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the poke4 instruction.&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for a playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this screenshot using the F7 key during the demo playback) and use this as you online version. The screenshot can also be imported from a 240×136 16 colors PNG (other size/format will throw an error) using inside TIC-80 console &amp;lt;code&amp;gt;import screen file[.png]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=919</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=919"/>
				<updated>2021-09-26T19:49:22Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Getting started */ +in how to sed different supported language, (external) link to the page that explain the tic() function in those languages&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the LUA Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so (respectively for JavaScript, MoonScript, Wren, Fennel, Squirrel):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- script: moon&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: wren&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fennel&amp;quot;&amp;gt;;; script: fennel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;// script: squirrel&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/nesbox/TIC-80/wiki/tic See here] to know how tic() is called in the different language supported by TIC-80.&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the poke4 instruction.&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for a playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this screenshot using the F7 key during the demo playback) and use this as you online version. The screenshot can also be imported from a 240×136 16 colors PNG (other size/format will throw an error) using inside TIC-80 console &amp;lt;code&amp;gt;import screen file[.png]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=918</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=918"/>
				<updated>2021-09-26T19:40:09Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Online version: Metadata and Thumbnail image */ +import screen(shot) from png file&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the LUA Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the poke4 instruction.&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for a playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this screenshot using the F7 key during the demo playback) and use this as you online version. The screenshot can also be imported from a 240×136 16 colors PNG (other size/format will throw an error) using inside TIC-80 console &amp;lt;code&amp;gt;import screen file[.png]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=917</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=917"/>
				<updated>2021-09-26T19:39:36Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Online version: Metadata and Thumbnail image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the LUA Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the poke4 instruction.&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for a playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this screenshot using the F7 key during the demo playback) and use this as you online version. The screenshot can also be imported from a 240×136 16 colors PNG (other size/format will throw an error) using inside TIC-80 console &amp;lt;code&amp;gt;import screen file&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=916</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=916"/>
				<updated>2021-09-26T19:32:03Z</updated>
		
		<summary type="html">&lt;p&gt;Popolon: /* Additional Resources */ +pactic fork de TIC-80 Packer)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Welcome to the virtual machine section of the website, where we will cover virtual machine (VM) languages and platforms like the TIC-80 and Javascript.&lt;br /&gt;
&lt;br /&gt;
== TIC-80 ==&lt;br /&gt;
TIC-80 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 240x136 pixels display, 16 color palette, 256 8x8 color sprites, 4 channel sound and etc.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the TIC-80 fantasy computer is an all-in-one creation and execution platform, setting up TIC-80 is very easy:&lt;br /&gt;
&lt;br /&gt;
Just go to the https://github.com/nesbox/TIC-80/releases page &lt;br /&gt;
&lt;br /&gt;
and download the package for your platform of choice (Windows, OSX, Linux and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
Or if you are just curious you can just start doodling online at http://tic80.com/&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
Most TIC-80 programs are coded using the LUA Scripting language. However it is possible to select different scripting language like javascript at the cost of a couple of bytes/characters like so: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;//script: js&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called 60 times a second) is the TIC() function, so this function is also a requirement for doing anything with graphics. Additionally you can also setup a sub=function SCN() that is called once per scanline at the costs of more bytes/characters. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()t=time()&lt;br /&gt;
-- your effect code&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC80 memory map and most common used function is available in this handy TIC80 cheatsheet, as well as the TIC80 wiki page.&lt;br /&gt;
&lt;br /&gt;
https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16colors which can be accessed via a wide range of graphics functions or by writing directly to VRAM at memory address 0x0000 using the poke4 instruction.&lt;br /&gt;
&lt;br /&gt;
==== Draw functions ====&lt;br /&gt;
There are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
cls(color=0)&lt;br /&gt;
pix(x,y[color]) [-&amp;gt; color]&lt;br /&gt;
circ(x,y,r,color) -- filled circle&lt;br /&gt;
circb(x,y,r,color) -- border circle&lt;br /&gt;
rect(x,y,w,h,color) -- filled rect&lt;br /&gt;
rectb(x,y,w,h,color) -- border rect&lt;br /&gt;
line(x0,y0,x1,y1,color)&lt;br /&gt;
tri(x1,y1,x2,y2,x3,y3,color)&lt;br /&gt;
textri(x1,y1,x2,y2,x3,y3,u1,v1,u2,v2,u3,v3,use_map=false,colorkey=-1)&lt;br /&gt;
print(text,x=0,y=0,color=15,fixed=false,scale=1,smallfont=false) -&amp;gt; width&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC() &lt;br /&gt;
t=time()/99&lt;br /&gt;
for y=0,136 do for x=0,240 do&lt;br /&gt;
pix(x,y,(x&amp;gt;&amp;gt;3~y&amp;gt;&amp;gt;3)+t)&lt;br /&gt;
end;end;end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
The best way to start is to use the default sweetie16 palette (https://lospec.com/palette-list/sweetie-16) as this palette&lt;br /&gt;
offers a nice selection of 16 colors arranged in such a way that they are easily accessable. From the verion 0.9b version and beyond you can initialise the new default sweetie16 palette at startup by adding a 0x11 Chunk to your TIC-80 cartridge. &lt;br /&gt;
&lt;br /&gt;
Normally a chunk would contain 4 bytes of header + data, but as this chunk has no data, it is possible to omit the extra 3 bytes of chunk-header if you place it at the end of your TIC cartridge. The new TIC-Packer linked below has the option to do this for you.&lt;br /&gt;
&lt;br /&gt;
==== Setting your own color palette ====&lt;br /&gt;
Alternatively you can setup your own palette by writing to the palette area located at 0x3fc0 like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i=0,47 do poke (0x3fc0+i,i*5)end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This produces a nice grayscale palette of 16 shades to work with.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
If you don't want to use the sweetie16 palette you can revert back to the pre 0.8 db16 palette by simply not including a 0x11 chunk in you cartridge. Although the arrangement of color-indices is not as ideal as sweetie16, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are&lt;br /&gt;
* (color)&amp;amp;10 - Some grey/blue shade&lt;br /&gt;
* ((color)&amp;amp;6)-3 - A Nice shade of Dark-cyan-white color&lt;br /&gt;
* (color)^2 - A shade of brown/yellowish colors&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The TIC-80 has soundregisters and 32 byte waveforms to access which are located at address 0FF9C in memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0FF9C SOUND REGS 72 18 byte x 4 ch&lt;br /&gt;
0FFE4 WAVEFORMS 256 16 wave/ 32x4b each&lt;br /&gt;
100E4 SFX 4224 64 sounds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make some noise ====&lt;br /&gt;
The easiest way to get 'some' sound going is to bitbang the sound-registers and hope for the best, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()for i=0,71 do poke(65436+i,(time()/7.2)%64)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more the &amp;quot;proper&amp;quot; way involves something like : define the waveform yourself (f.e. sawtooth), repeatedly (because for some reason one time is not enough), then write low part of the frequency to one byte, and the high nibble combined with the volume to another) &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=function()&lt;br /&gt;
for i=0,31 do poke4(2*65438+i,i/2) end -- setup waveforem&lt;br /&gt;
t=time()/10 &lt;br /&gt;
-- write frequencies&lt;br /&gt;
poke(65436+0,t%256) &lt;br /&gt;
poke(65437+0,(t/65536)%16+240)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But as you can see this costs considerably more bytes to setup.&lt;br /&gt;
&lt;br /&gt;
=== Final Optimisations ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
As a goal-post, you should always aim to have your uncompressed effect around the target size, and work from there.&lt;br /&gt;
&lt;br /&gt;
Final optimisation can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
A rule of thumb for this is that of the first or last character of a variable or function isn't a valid hex number (i.e. A-F) you can omit whitespace (so that: x=0 y=0 z=0 can become x=0y=0z=0)&lt;br /&gt;
&lt;br /&gt;
=== Release ===&lt;br /&gt;
For releasing an intro at a demoscene event, a raw TIC cartridge file without any additional graphics/sound/metadata is needed.&lt;br /&gt;
&lt;br /&gt;
Creating a http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;amp;action=edit&amp;amp;section=13 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk.&lt;br /&gt;
&lt;br /&gt;
Luckily there are various packers that help you convert your (LUA) Script to a empty TIC Cartridge with a single ZLIB compressed code block and optional 0x11 (sweetie16) palette chunk. See the additional links for links to these packers.&lt;br /&gt;
 &lt;br /&gt;
==== Exporting Video as Animated GIF ====&lt;br /&gt;
The TIC80 environment has a neat feature that lets you export your intro directly as an animated GIF file to converted to video later, by Pressing the F9 key to start and stop recording. However, there is a default recording limit capped to a fixed number of frames or seconds. You can change this in the tic80 config to a bigger number to match your recording-size. &lt;br /&gt;
&lt;br /&gt;
If your intro is taking up too many resources and starts chugging a bit on your machine, it can be wise to make a version that steps through time lineary by adding a number to your t variable yourself instead of using the time() function.&lt;br /&gt;
&lt;br /&gt;
==== Online version: Metadata and Thumbnail image ====&lt;br /&gt;
When uploading the intro to the TIC80 website for an playable online version, you will need to build a new TIC file with some added some meta-data and Thumbnail image (You can take this snapshot using the F7 key) and use this as you online version.&lt;br /&gt;
&lt;br /&gt;
The Meta data is added at the top of your intro as follows&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- title: My intro&lt;br /&gt;
-- author: scener&lt;br /&gt;
-- desc: my first sizecoded TIC-80 intro&lt;br /&gt;
-- script: lua (or moon/wren/js/fennel)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update: As of version 0.9b the TIC80.COM website now also allows you to upload a seperate TIC file with the metadata and keep the uploaded binary TIC file as code only.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the TIC-80 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* TIC-80 Wiki page https://github.com/nesbox/TIC-80/wiki&lt;br /&gt;
* TIC-80 One page cheat sheet (PDF) https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf&lt;br /&gt;
* TIC-80 Intros and demos on Pouet (Press F1 for code): https://www.pouet.net/prodlist.php?platform%5B%5D=TIC-80&lt;br /&gt;
* TIC-80 TIC Cartridge File Format (from TIC-80 Wiki) https://github.com/nesbox/TIC-80/wiki/tic-File-Format&lt;br /&gt;
* TIC-80 Packer https://bitbucket.org/WaterEnVuur/tic80-packer/src/master/&lt;br /&gt;
:* Pactic, fork de TIC-80 Packer https://github.com/phlubby/pactic&lt;br /&gt;
* TIC-Tool https://github.com/exoticorn/tic-tool&lt;br /&gt;
&lt;br /&gt;
== PICO-8 ==&lt;br /&gt;
The PICO-8 is a fantasy computer for making, playing and sharing tiny games and demos.&lt;br /&gt;
&lt;br /&gt;
There are built-in tools for development: code, sprites, maps, sound editors and the command line, which is enough to create a mini retro game. At the exit you will get a cartridge file, which can be stored and played on the website.&lt;br /&gt;
&lt;br /&gt;
Also, the game can be packed into a player that works on all popular platforms and distribute as you wish. To make a retro styled game the whole process of creation takes place under some technical limitations: 128x128 pixels display, 16  color palette, 256 8x8 color sprites and 4 channel sound &lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
As the PICO-8 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the PICO-8 is a commercial package and should be purchased before you can get started.&lt;br /&gt;
&lt;br /&gt;
You can go to https://lexaloffle.itch.io/pico-8 to purchase and then download the package for your platform of choice (Windows, OSX and even Raspberry Pi).&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
PICO-8 programs are coded using the LUA Scripting language. &lt;br /&gt;
&lt;br /&gt;
The main function used for updating the screen (and called either 30 or 60 times a second) is the _DRAW() function, so this function is also a requirement for doing anything with graphics. &lt;br /&gt;
&lt;br /&gt;
Most animated effects will also need to use some kind of a timer, so you are likely to also use the built-in time() function or keep track of your time (t) yourself as well..  So a minimal setup would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0 FUNCTION _DRAW()&lt;br /&gt;
-- your effect code&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a single-image PICO-8 Cheat sheet to get you started.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
PICO-8_Cheat_Sheet.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The PICO-8 has a 128x128 pixel display with 16 colors which can be accessed via a wide range of graphics functions.&lt;br /&gt;
&lt;br /&gt;
==== Built-in Draw functions ====&lt;br /&gt;
Here are a couple of built-in drawing functions you can use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
CLS(color=0)&lt;br /&gt;
PSET(x,y,color) &lt;br /&gt;
color=PGET(x,y)&lt;br /&gt;
CIRC(x,y,r,color)&lt;br /&gt;
CIRCFILL(x,y,r,color)&lt;br /&gt;
RECT(x,y,w,h,color)&lt;br /&gt;
RECTFILL(x,y,w,h,color)&lt;br /&gt;
LINE(x0,y0,x1,y1,color)&lt;br /&gt;
PRINT(text,[x,y,color])&lt;br /&gt;
&lt;br /&gt;
COLOR(color) - Set default color&lt;br /&gt;
PAL(destindex,sourceindex) - Replace dest colorindex with color from sourceindex&lt;br /&gt;
FILLP(mask) -- Set fill pattern for circ, circfill, rect, rectfill, pset, and line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Here is a bit of code to get you started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
T=0FUNCTION _DRAW() &lt;br /&gt;
FOR Y=0,128 DO FOR X=0,128 DO&lt;br /&gt;
PSET(X,Y,X~Y+T)&lt;br /&gt;
END END&lt;br /&gt;
T=T+1&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will display an animated XOR pattern.&lt;br /&gt;
&lt;br /&gt;
==== Color Palette ====&lt;br /&gt;
Unfortunately for us sizecoders, the PICO-8 comes with a fixed palette to 16 colors with size-unfriendely color indexing (https://lospec.com/palette-list/pico-8).&lt;br /&gt;
&lt;br /&gt;
Luckily, the PICO-8 provides a PAL(source,dest) function that lets you swap the color index of each color, but these are quite costly at 8-10 bytes per colorswap call.&lt;br /&gt;
&lt;br /&gt;
==== Colorindex table ====&lt;br /&gt;
One of the easier way to get a nice color-ramp without using the PAL function is to use a color indextable like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
c={0,5,6,7}&lt;br /&gt;
pset(x,y,c[i])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gives you the most freedom in terms of building your custom ramp of colors.&lt;br /&gt;
&lt;br /&gt;
==== Color index shuffling ====&lt;br /&gt;
Alternatively, you can shuffle your color indices a bit to get 'somewhat workable' colors.&lt;br /&gt;
&lt;br /&gt;
A couple of examples for this are:&lt;br /&gt;
* color+4 / pal(4,0) - Replaces color index 4 with 0(black) for a 4-shade Grayscale&lt;br /&gt;
* color&amp;amp;7*2 - Black, Purple, brown, white&lt;br /&gt;
* (color&amp;amp;7)^2 - Black, blue, brown yellow&lt;br /&gt;
&lt;br /&gt;
But feel free to experiment yourself as well and let us know on discord if you find something cool.&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The PICO-8 does not allow you to poke the soundregisters directly, but instead works with the SFX(effectindex) command to generate sounds. However we are allowed to poke the piece of memory that holds the soundeffect data, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
POKE(12869+offset,value)SFX(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PICO-8 vs TIC-80 Sizecoding ===&lt;br /&gt;
If you are familiar with TIC-80 sizecoding, but less with PICO-8. This chapter will help you point out the main differences between the 2 platforms:&lt;br /&gt;
&lt;br /&gt;
* Performance on PICO-8 is more limited. The use of instructions/tokens (inside and outside loops) will have a performance/token penalty.&lt;br /&gt;
* Less code to work with (for a typical 256byte intro 229 characters vs 300-400 characters of LZ compressed code on the TIC-80) &lt;br /&gt;
* Code-editor = Escape (prepare to have your desktop filled with screenshots by accidentally pressing F1 ;-)&lt;br /&gt;
* All alphabetic letters can be tugged against numeric chars (0..9) on PICO-8 &lt;br /&gt;
* Math functions don't need the MATH. prefix (SIN, COS, ATAN2, SQRT, SGN, RND, etc.) &lt;br /&gt;
* No integer divisions are needed anymore for logical operations&lt;br /&gt;
* The PICO-8 has custom characters available in the font (character numbers 128+).&lt;br /&gt;
* The PICO-8 LUA variant supports x+=value / x-=value&lt;br /&gt;
* The XOR operator is ^^ instead of ~ &lt;br /&gt;
* FUNCTION _DRAW() = FUNCTION TIC()&lt;br /&gt;
* Warning: The POKE4 function pokes 4 bytes intro memory instead of a nibble. Nibble poke is not available.&lt;br /&gt;
&lt;br /&gt;
=== Final optimisations and P8 Cartridge Release ===&lt;br /&gt;
When you are happy with your intro and want to get it ready for release, it becomes time to look at squeezing those last bytes.&lt;br /&gt;
&lt;br /&gt;
Final optimisations can be done by stringing as much code together on single lines and removing any extra spaces and whitelines.&lt;br /&gt;
&lt;br /&gt;
Here are a couple of other tips and tricks that help you squeeze those final bytes:&lt;br /&gt;
&lt;br /&gt;
* You can always directly stick a letter A..Z after a number 0..9 or a bracket.&lt;br /&gt;
* Make sure to reorder variable assigments and code around to make use of optimal letter/number squeezing.&lt;br /&gt;
* Unlike the TIC-80 , no integer divides (like //1) are usually necessary for doing logical operations.&lt;br /&gt;
* Using a GOTO loop construction like ::L:: &amp;lt;yourcode&amp;gt; FLIP()GOTO L will save you 1 character over FUNCTION _DRAW() &amp;lt;yourcode&amp;gt; END&lt;br /&gt;
* You can alias functions that you are going to use more frequently, e.g. S=SIN or R=RND&lt;br /&gt;
* Using decimal values instead of hexadecimal will save 1 character (32768 vs 0x8000)&lt;br /&gt;
* Did you know that the T() shorthand version of the TIME() function is also available?&lt;br /&gt;
* Remember that ?&amp;quot;text&amp;quot;,x,y is a shorthand for PRINT(&amp;quot;text&amp;quot;,x,y), however it does require its own newline (2x enter) to work&lt;br /&gt;
&lt;br /&gt;
When you are done, make sure that your raw LUA character count is around the target size minus 27 characters, as most demoparties will accept a loadable .P8 cartridge file as an intro, which adds a 27 byte header like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
pico-8 cartridge&lt;br /&gt;
&lt;br /&gt;
__lua__&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Followed by your raw LUA code, so this leaves:&lt;br /&gt;
* 101 characters for a 128 byte intro.&lt;br /&gt;
* 229 characters for a 256 byte intro.&lt;br /&gt;
* 485 characters for a 512 byte intro.&lt;br /&gt;
* 997 characters for a 1024 byte intro.&lt;br /&gt;
&lt;br /&gt;
The number of used characters can be made visible in the bottom right of the PICO-8 code editor, so that you can keep track.&lt;br /&gt;
&lt;br /&gt;
You can edit the cartridge with with above header in an external editor or find and strip them down from your internal PICO-9 cartridge folder (type FOLDER to jump directly to your cartridge folder and/or edit the PICO-8 config.txt to save your P8 cartridge files elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
Sizecoding on the PICO-8 is still in its infancy, but luckily there is already plenty of information to get you started!&lt;br /&gt;
&lt;br /&gt;
* PICO-8 Wiki page http://pico-8.wikia.com/wiki/Pico-8_Wikia&lt;br /&gt;
* PICO-8 One page cheat sheet (PNG) https://imgur.com/iGrP5bK&lt;br /&gt;
* PICO-8 API Reference https://neko250.github.io/pico8-api/&lt;br /&gt;
* PICO-8 guide https://nerdyteachers.com/PICO-8/Guide/&lt;br /&gt;
* PICO-8 List of sizecoded Fantasy Console intros (PICO-8/TIC-80) https://www.pouet.net/lists.php?which=199&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
The Javascript sizecoding community has been quite active for years now.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
&lt;br /&gt;
* Tools: [http://www.iteral.com/jscrush/ JSCrush online] [https://github.com/gre/jscrush JSCrush cli-tool] [https://siorki.github.io/regPack.html Reg Pack]&lt;br /&gt;
* Execution environment(s): Browser, [https://www.dwitter.net Dwitter]&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
No information yet&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
Something to get your journey started:&lt;br /&gt;
&lt;br /&gt;
* [https://marcgg.com/blog/2016/11/01/javascript-audio/ Generate Sounds Programmatically With Javascript]&lt;br /&gt;
&lt;br /&gt;
More information to follow&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://js1k.com JS1k]&lt;br /&gt;
&lt;br /&gt;
Tutorials / Postmortems&lt;br /&gt;
&lt;br /&gt;
* [https://frankforce.com/i-made-7-demos-in-2-weeks-for-js1k/ I made 7 demos in 2 weeks for js1k]&lt;br /&gt;
* [https://nikhilism.com/post/2012/demystifying-jscrush/ Demystifying JSCrush]&lt;br /&gt;
&lt;br /&gt;
More to follow&lt;/div&gt;</summary>
		<author><name>Popolon</name></author>	</entry>

	</feed>