<?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=Childishbeat</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=Childishbeat"/>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/wiki/Special:Contributions/Childishbeat"/>
		<updated>2026-05-03T22:06:15Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.0</generator>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1151</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1151"/>
				<updated>2022-04-08T15:50:18Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Cleaned up with new article titles and better writing.&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.'''  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;
*'''[[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;
*'''[[Fantasy consoles]]''' - Dedicated to fantasy consoles.&lt;br /&gt;
*'''[[Bytebeat]]''' - Tiny music created from mathematical expressions.&lt;br /&gt;
*'''[[High-level programming languages]]''' - Basically anything that controls the hardware less directly than assembly languages.&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=1149</id>
		<title>Motorola 68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=1149"/>
				<updated>2022-04-08T15:43:56Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Motorola 68k based CPUs to Motorola 68000: Less verbose&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;
== Motorola M68K Platforms ==&lt;br /&gt;
*'''[[Atari ST]]''' - Atari ST Sizecoding information&lt;br /&gt;
*'''[[Atari Jaguar]]''' - Atari Jaguar Sizecoding information&lt;br /&gt;
*'''[[Commodore Amiga]]''' - Commodore Amiga Sizecoding information&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68k_based_CPUs&amp;diff=1150</id>
		<title>Motorola 68k based CPUs</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68k_based_CPUs&amp;diff=1150"/>
				<updated>2022-04-08T15:43:56Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Motorola 68k based CPUs to Motorola 68000: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Motorola 68000]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1147</id>
		<title>RISC-V</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V&amp;diff=1147"/>
				<updated>2022-04-08T15:42:21Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page RISC-V CPUs to RISC-V: Less verbose&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>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=RISC-V_CPUs&amp;diff=1148</id>
		<title>RISC-V CPUs</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=RISC-V_CPUs&amp;diff=1148"/>
				<updated>2022-04-08T15:42:21Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page RISC-V CPUs to RISC-V: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[RISC-V]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=PDP-11&amp;diff=1145</id>
		<title>PDP-11</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=PDP-11&amp;diff=1145"/>
				<updated>2022-04-08T15:42:06Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page PDP-11 CPUs to PDP-11: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Wanting to start sizecoding on a PDP-11 platforms like the BK-0010 and BK-0011m in this day and age can be tough, especially if&lt;br /&gt;
you have not grown up with such a machine. &lt;br /&gt;
&lt;br /&gt;
So here is a bit of help to get you started:&lt;br /&gt;
&lt;br /&gt;
=== Registers ===&lt;br /&gt;
The PDP-11's registers are ALL 16 bit.&lt;br /&gt;
&lt;br /&gt;
'''R0, R1, R2, R3, R4&lt;br /&gt;
R5 (Often Used to remember the return address during calls)&lt;br /&gt;
SP (R6), PC (R7)&lt;br /&gt;
'''&lt;br /&gt;
If an Even register number (R0,R2,R4) is used for certain commands (for example MUL)- the register and it's following will be used as a 32 bit pair when the result is returned&lt;br /&gt;
&lt;br /&gt;
Assignment direction is left (source) to right (dest). Default number mode for the PDP-11 is Octal mode (base-8), but there is possible to use other modes as well&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
mov #777,r0    ; octal =default&lt;br /&gt;
mov #^b101,r0  ; binary&lt;br /&gt;
mov #^x0aa,r0  ; hexadecimal&lt;br /&gt;
mov #'A,r0     ; ascii&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Instructions ===&lt;br /&gt;
Here is a rough translation for some of the PDP-11 instructions:&lt;br /&gt;
&lt;br /&gt;
* MOV src,dest - move source int dest register&lt;br /&gt;
* CLR, CLRB  - move zero into register&lt;br /&gt;
* INC/DEC , incb/decb - Increase/decrease register&lt;br /&gt;
* ADD/SUB - Add/Sub in 16 bits&lt;br /&gt;
* ADC/SBC - Add and Subtract in 32 bits&lt;br /&gt;
* MUL -  16 (odd register) or 32 bit (even register) multiplication&lt;br /&gt;
* DIV -  32 bit division&lt;br /&gt;
* ROL/ROR/ASR/ASL - Bit Rol and Shift instructions for 16 bit register&lt;br /&gt;
* ASH/ASHC - Shift 32bit register pair left and right (depending on argument)&lt;br /&gt;
* CALL/RETURN  - Call subroutine, return to PC&lt;br /&gt;
* JSR/RTS&amp;lt;reg&amp;gt; - Jump subroutine / Return to address in register&lt;br /&gt;
* BIT - Bit test (can be used for AND)&lt;br /&gt;
* SWAB - Swap bytes in a 16bit register&lt;br /&gt;
* SXT - Sign extend a 16bit register into a 32bit pari&lt;br /&gt;
* COM - Complement register (flip all bit)&lt;br /&gt;
* NEG - Flip all bits and add 1 (negative)&lt;br /&gt;
* XOR - Exclusive OR&lt;br /&gt;
* BIS - Logical OR&lt;br /&gt;
* BIC - Inverse Logical OR (can be used as an AND instruction if performing a COM (bitflip) command first)&lt;br /&gt;
&lt;br /&gt;
=== Testing and Branching ===&lt;br /&gt;
The PDP-11 has many branch conditions:&lt;br /&gt;
* TST - test register and update flags&lt;br /&gt;
* CMP - compare register&lt;br /&gt;
* BLT - branch if smaller (signed)&lt;br /&gt;
* BGT - branch if greater (signed)&lt;br /&gt;
* BLE - branch if smaller or equal (signed)&lt;br /&gt;
* BLO - branch if smaller (unsigned)&lt;br /&gt;
* BHI - branch if greater (unsigned)&lt;br /&gt;
* BLOS - branch if smaller or equal (unsigned)&lt;br /&gt;
* BHIS - branch if greater or equal (unsigned)&lt;br /&gt;
* BEQ - will branch if Z is set (Branch if EQual)&lt;br /&gt;
* BNE - will branch if Z is not set (Branch if Not Equal)&lt;br /&gt;
* BVS will branch if overflow is set&lt;br /&gt;
* BVC will branch if overflow is clear&lt;br /&gt;
* BMI will branch if the value is negative (minus - N set)&lt;br /&gt;
* BPL will branch if the value is positive (plus - N clear)&lt;br /&gt;
* BCS will Branch if Carry is Set&lt;br /&gt;
* BCC will Branch if Carry is Clear&lt;br /&gt;
* BR - this will ALWAYS branch &lt;br /&gt;
&lt;br /&gt;
=== Learning PDP-11 Assembler ===&lt;br /&gt;
There are a couple of PDP-11 tutorials available online, but most of them are in russian. Here is a basic one:&lt;br /&gt;
* https://www.chibiakumas.com/pdp11/&lt;br /&gt;
&lt;br /&gt;
== Electronika BK-0010  ==&lt;br /&gt;
The Electronika BK-0010 is a 16-bit PDP-11-compatible fanless Soviet home computers developed under the Electronika brand by NPO Scientific Center, the leading Soviet microcomputer design team at the time. It was also the predecessor of the more powerful UKNC and DVK micros.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
Setting up your development platform for the BK-0010/BK-0011m machine works as follows:&lt;br /&gt;
&lt;br /&gt;
* Assembler: https://github.com/imachug/PDPy11&lt;br /&gt;
* Emulator: http://sandro.pdp-11.ru&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
Video display&lt;br /&gt;
&lt;br /&gt;
=== Memory Map ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen ====&lt;br /&gt;
Now to get something on screen, lets fill our colorram with a simple AND pattern, like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
=== Small demos with documented source code ===&lt;br /&gt;
* Mona Lisa for the BK-0010/11m https://www.pouet.net/prod.php?which=86820&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
I found resources on BK-0010 sizecoding in english to be sparse.&lt;br /&gt;
* Good book to start BK-0010 programming http://www.translatetheweb.com/?from=&amp;amp;to=en&amp;amp;ref=TVert&amp;amp;dl=en&amp;amp;rr=DC&amp;amp;a=http%3a%2f%2fgid.pdp-11.ru%2fbooks%2fprogramming_BK10.html&lt;br /&gt;
* BK0010 ROM, system, etc http://www.translatetheweb.com/?from=&amp;amp;to=en&amp;amp;ref=TVert&amp;amp;dl=en&amp;amp;rr=DC&amp;amp;a=http%3a%2f%2fgid.pdp-11.ru%2fbooks%2f00001-01.32.03.html&lt;br /&gt;
* BK-0011M Information https://www.translatetheweb.com/?ref=TVert&amp;amp;from=&amp;amp;to=en&amp;amp;a=http%3A%2F%2Fgid.pdp-11.ru%2Fbooks%2F00015-01.32.01.html&lt;br /&gt;
* List of PDP-11 resources (Russian) http://gid.pdp-11.ru/doclist.html&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=PDP-11_CPUs&amp;diff=1146</id>
		<title>PDP-11 CPUs</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=PDP-11_CPUs&amp;diff=1146"/>
				<updated>2022-04-08T15:42:06Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page PDP-11 CPUs to PDP-11: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[PDP-11]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ARM&amp;diff=1143</id>
		<title>ARM</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ARM&amp;diff=1143"/>
				<updated>2022-04-08T15:41:45Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page ARM based CPUs to ARM: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
So here is a bit of help to get you started:&lt;br /&gt;
&lt;br /&gt;
=== The ARM processor  ===&lt;br /&gt;
The ARM Processor is a RISC based architecture and comes in many flavors.&lt;br /&gt;
&lt;br /&gt;
*'''[[RISC OS on ARM based CPUs]]''' - Create your tiny intro on ARM hardware on RISC OS.&lt;br /&gt;
*'''[[Gameboy Advance]]''' - Gameboy Advance Sizecoding Information&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ARM_based_CPUs&amp;diff=1144</id>
		<title>ARM based CPUs</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ARM_based_CPUs&amp;diff=1144"/>
				<updated>2022-04-08T15:41:45Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page ARM based CPUs to ARM: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[ARM]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Z80&amp;diff=1141</id>
		<title>Z80</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Z80&amp;diff=1141"/>
				<updated>2022-04-08T15:41:21Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Z80 based CPUs to Z80: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Wanting to start sizecoding on a Z80 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;
=== Registers ===&lt;br /&gt;
The Z80 can be seen as the little 8-bit brother of X86 chipsets, with many similarities.&lt;br /&gt;
If you are coming from a X86 background, this might help you get a bit more grip on the Z80.&lt;br /&gt;
These are the register pairs of the Z80, as seen from a X86 programmers perspective.&lt;br /&gt;
&lt;br /&gt;
* AF = AL + Flags&lt;br /&gt;
* HL = Can be seen as BX (H=BH,L=BL) or SI in a (HL) setting, like BX also used for addressing.&lt;br /&gt;
* BC = Can be seen as CX (B=CH,C=CL), often used for loops &lt;br /&gt;
* DE = Can be seen as DX (D=DH,E=DL) or DI in a (DE) setting&lt;br /&gt;
* IX = 16 bit Index Register X, can also be accessed with IXH,IXL &lt;br /&gt;
* IY = 16 bit Index Register Y, can also be accessed with IYH,IYL&lt;br /&gt;
&lt;br /&gt;
For each of the main registers there also exists a shadow register. These cannot be accessed directly, but must be swapped in and out with the main register set. The shadow registers are usually denoted by the ' symbol. They can be swapped with the following commands:&lt;br /&gt;
* EX AF,AF' = Swaps AF with AF'&lt;br /&gt;
* EXX = Swaps BC, DE and HL with BC', DE' and HL' &lt;br /&gt;
There are no shadow registers for the index registers.&lt;br /&gt;
&lt;br /&gt;
Note: For a lot of operations, you can only use the A(8bit) and HL(16bit) registers. &lt;br /&gt;
The Sjasmplus assembler has extra syntax and fake-instructions support which may produce unexpected results when source contains other than official Zilog syntax (but the parser can be configured to work in more relaxed way allowing more variations in syntax).&lt;br /&gt;
&lt;br /&gt;
=== Instructions ===&lt;br /&gt;
Here is a rough translation for some of the Z80 instructions:&lt;br /&gt;
&lt;br /&gt;
* BIT = TEST&lt;br /&gt;
* CP = CMP  (although the Z80 has many other handy compare functionality)&lt;br /&gt;
* DJNZ = LOOP (decreases B and checks not zero)&lt;br /&gt;
* EXE = Exchange all registers with Shadow registers, can be used a bit like PUSHA/POPA&lt;br /&gt;
* EX = XCHG&lt;br /&gt;
* HALT = HLT&lt;br /&gt;
* JP = JMP&lt;br /&gt;
* JR = JMP NEAR (Jump Relative)&lt;br /&gt;
* LD = MOV&lt;br /&gt;
* LDI = MOVSB   (tmp=(HL),(DE)=tmp, DE++, HL++)&lt;br /&gt;
* LDIR = REP MOVSB   (tmp=(HL),(DE)=tmp, DE++, HL++, BC--)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Learning Z80 Assembler ===&lt;br /&gt;
There are many Z80 tutorials available online, but one i found very simple and clear is at this 1996 styled webpage ;-)  &lt;br /&gt;
&lt;br /&gt;
* http://www.z80.info/lesson1.htm&lt;br /&gt;
* http://www.z80.info/lesson2.htm&lt;br /&gt;
* http://www.z80.info/lesson3.htm&lt;br /&gt;
* http://www.z80.info/lesson4.htm&lt;br /&gt;
* http://www.z80.info/lesson5.htm&lt;br /&gt;
&lt;br /&gt;
There is no proper index-page for this, which is why i linked all the lessons above, but you can continue to the next lesson by clicking at the next lesson at the bottom of the page.&lt;br /&gt;
&lt;br /&gt;
Also, here is a compact 'cheat sheet' with some basics for various Z80 systems:&lt;br /&gt;
https://www.chibiakumas.com/z80/CheatSheet.pdf&lt;br /&gt;
&lt;br /&gt;
== Z80 Plaforms ==&lt;br /&gt;
*'''[[ZX Spectrum]]''' - ZX Spectrum Sizecoding information&lt;br /&gt;
*'''[[Amstrad CPC]]''' - Amstrad CPC Sizecoding information&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Z80_based_CPUs&amp;diff=1142</id>
		<title>Z80 based CPUs</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Z80_based_CPUs&amp;diff=1142"/>
				<updated>2022-04-08T15:41:21Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Z80 based CPUs to Z80: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Z80]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=6502&amp;diff=1139</id>
		<title>6502</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=6502&amp;diff=1139"/>
				<updated>2022-04-08T15:41:01Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page 6502 based CPUs to 6502: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Wanting to start sizecoding on a 6502 platform in this day and age can be tough. &lt;br /&gt;
&lt;br /&gt;
[[File:6502.jpg|thumb]]&lt;br /&gt;
&lt;br /&gt;
So here is a bit of help to get you started:&lt;br /&gt;
&lt;br /&gt;
=== The 6502 processor  ===&lt;br /&gt;
The 6502 processor can be seen as the 8-bit micro ARM chip. &lt;br /&gt;
It has only has 3 registers (Accumulator, X and Y registers) and a handful of instructions to work with.&lt;br /&gt;
&lt;br /&gt;
=== Adressing modes ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
=== Zero page ===&lt;br /&gt;
When using the 6502 for sizecoding, you'll mostly be working from zeropage&lt;br /&gt;
&lt;br /&gt;
=== General 6502 Resources ===&lt;br /&gt;
* 6502.org http://www.6502.org/&lt;br /&gt;
* 6502 instruction reference http://www.6502.org/tutorials/6502opcodes.html&lt;br /&gt;
* 6502 books http://retro.hansotten.nl/6502-sbc/&lt;br /&gt;
* 6502 Assembler tutorial https://dwheeler.com/6502/oneelkruns/asm1step.html&lt;br /&gt;
* Easy 6502 code tester https://skilldrick.github.io/easy6502/&lt;br /&gt;
* Synthetic instructions https://wiki.nesdev.com/w/index.php/Synthetic_instructions#8-bit_rotate&lt;br /&gt;
&lt;br /&gt;
== 6502 Based Platforms ==&lt;br /&gt;
*'''[[Atari 8Bit]]''' - Atari 8-Bit Family (Atari XL/XE, etc.)&lt;br /&gt;
*'''[[Apple II]]''' - Apple II(e)&lt;br /&gt;
*'''[[Commodore 64]]''' - Commodore 64&lt;br /&gt;
*'''[[BBC Micro]]''' - Acorn BBC Micro/Master/Electron.&lt;br /&gt;
*'''[[Atari Lynx]]''' - Atari Lynx Handheld&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=6502_based_CPUs&amp;diff=1140</id>
		<title>6502 based CPUs</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=6502_based_CPUs&amp;diff=1140"/>
				<updated>2022-04-08T15:41:01Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page 6502 based CPUs to 6502: Less verbose&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[6502]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=1137</id>
		<title>Motorola 68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=1137"/>
				<updated>2022-04-08T15:31:55Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Motorola 68k based CPUS to Motorola 68k based CPUs: Misspelling&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;
== Motorola M68K Platforms ==&lt;br /&gt;
*'''[[Atari ST]]''' - Atari ST Sizecoding information&lt;br /&gt;
*'''[[Atari Jaguar]]''' - Atari Jaguar Sizecoding information&lt;br /&gt;
*'''[[Commodore Amiga]]''' - Commodore Amiga Sizecoding information&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68k_based_CPUS&amp;diff=1138</id>
		<title>Motorola 68k based CPUS</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68k_based_CPUS&amp;diff=1138"/>
				<updated>2022-04-08T15:31:55Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Motorola 68k based CPUS to Motorola 68k based CPUs: Misspelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Motorola 68k based CPUs]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=High-level_programming_languages&amp;diff=1136</id>
		<title>High-level programming languages</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=High-level_programming_languages&amp;diff=1136"/>
				<updated>2022-04-08T15:31:12Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: JavaScript has been readded after being removed from the fantasy consoles section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a list of high-level programming languages with articles on SizeCoding.org.&lt;br /&gt;
==Programming languages==&lt;br /&gt;
*'''[[JavaScript]]'''&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=1134</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=1134"/>
				<updated>2022-04-08T15:27:51Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Fantasy Consoles to Fantasy consoles: Consistency&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the fantasy consoles section of the website, where we will cover fantasy consoles, like TIC-80, PICO-8 and MicroW8.&lt;br /&gt;
==Platforms==&lt;br /&gt;
*'''[[TIC-80]]'''&lt;br /&gt;
*'''[[PICO-8]]'''&lt;br /&gt;
*'''[[MicroW8]]'''&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Byte Battle]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;diff=1135</id>
		<title>Fantasy Consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_Consoles&amp;diff=1135"/>
				<updated>2022-04-08T15:27:51Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Fantasy Consoles to Fantasy consoles: Consistency&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Fantasy consoles]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=1133</id>
		<title>Fantasy consoles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Fantasy_consoles&amp;diff=1133"/>
				<updated>2022-04-08T15:26:49Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Cleaned up. A new category will be used for high-level programming languages, hence JavaScript's removal, as it's one.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the fantasy consoles section of the website, where we will cover fantasy consoles, like TIC-80, PICO-8 and MicroW8.&lt;br /&gt;
==Platforms==&lt;br /&gt;
*'''[[TIC-80]]'''&lt;br /&gt;
*'''[[PICO-8]]'''&lt;br /&gt;
*'''[[MicroW8]]'''&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Byte Battle]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Bytebattles&amp;diff=1132</id>
		<title>Bytebattles</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Bytebattles&amp;diff=1132"/>
				<updated>2022-03-13T22:14:17Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Bytebattles to Byte Battle: This is the spelling LoveByte, its inventor, uses, and article titles should use singular forms.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Byte Battle]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Byte_Battle&amp;diff=1131</id>
		<title>Byte Battle</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Byte_Battle&amp;diff=1131"/>
				<updated>2022-03-13T22:14:16Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Bytebattles to Byte Battle: This is the spelling LoveByte, its inventor, uses, and article titles should use singular forms.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Bytebattles ==&lt;br /&gt;
&lt;br /&gt;
Bytebattles are a form of live coding, similar to Shader Showdowns, where two contestants compete in writing a visual effect in 25 minutes. The coding environment is the [[Fantasy Consoles|TIC-80 fantasy console]]. However, unlike Shader Showdowns, there is an additional limit: the final code should be 256 characters or less. This requires the contestants to use efficient code (e.g. single letter variables) and to minimize the code (e.g. remove the whitespace), all within the time limit. Unlike in normal TIC-80 sizecoding, there is no compression, so every character counts.&lt;br /&gt;
&lt;br /&gt;
== General notation in this article ==&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
! Symbol || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; || Pixel index&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; || Alias for math.sin&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; || Pixel x-coordinate&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; || Pixel y-coordinate&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Basic optimizations ==&lt;br /&gt;
&lt;br /&gt;
* Functions, that are called three or more times should be aliased. For example, &amp;lt;code&amp;gt;e=elli&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;e()e()e()&amp;lt;/code&amp;gt; is 3 characters shorter than &amp;lt;code&amp;gt;elli()elli()elli()&amp;lt;/code&amp;gt;. Functions with 5-character-long names may already benefit from aliasing with two calls: &amp;lt;code&amp;gt;r=rectb&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;r()r()&amp;lt;/code&amp;gt; is 1 character shorter than &amp;lt;code&amp;gt;rectb()rectb()&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;t=0&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;t=t+.1&amp;lt;/code&amp;gt; is 3 characters shorter than &amp;lt;code&amp;gt;t=time()/399&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;for i=0,32639 do x=i%240y=i/240 end&amp;lt;/code&amp;gt; is 2-3 characters shorter than &amp;lt;code&amp;gt;for y=0,135 do for x=0,239 do end end&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;(x*x+y*y)^.5&amp;lt;/code&amp;gt; is 6 characters shorter than &amp;lt;code&amp;gt;math.sqrt(x*x+y*y)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;s(w-11)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;s(w+8)&amp;lt;/code&amp;gt; both approximate &amp;lt;code&amp;gt;math.cos(w)&amp;lt;/code&amp;gt;, so only &amp;lt;code&amp;gt;math.sin&amp;lt;/code&amp;gt; needs to be aliased. &amp;lt;code&amp;gt;s(w-11)&amp;lt;/code&amp;gt; is far more accurate, with the cost of one more character.&lt;br /&gt;
&lt;br /&gt;
== One-lining ==&lt;br /&gt;
&lt;br /&gt;
Most whitespace can be removed from LUA code. For example: &amp;lt;code&amp;gt;x=0y=0&amp;lt;/code&amp;gt; is valid. All new lines can be removed or replaced with space, making the whole code a single line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function TIC()for i=0,32639 do poke4(i,i)end end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Warning: Letters &amp;lt;code&amp;gt;a-f&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;A-F&amp;lt;/code&amp;gt; after a number cause problems.''' &amp;lt;code&amp;gt;a=0b=0&amp;lt;/code&amp;gt; is not valid code. It is advisable to only used one letter variables in the ranges &amp;lt;code&amp;gt;g-z&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;G-Z&amp;lt;/code&amp;gt; from the start; this will make eventual one-lining easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Load-function == &lt;br /&gt;
&lt;br /&gt;
Function &amp;lt;code&amp;gt;load&amp;lt;/code&amp;gt; takes a string of code and returns a function with no named arguments, with the code as its body. It's particularly useful for shortening the TIC function after one-lining:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TIC=load'for i=0,32639 do poke4(i,i)end'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a rule of thumb, one-lining and using the load trick can bring a ~ 275 character code down to 256.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;load&amp;lt;/code&amp;gt; can be even used to minimize a function with parameters: &amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt; returns the parameters. For example, the following example saves 3 bytes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
SCN=load'r=...poke(16320,r)'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Multiple parameters can be fetched with &amp;lt;code&amp;gt;x,y=...&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Warning: The backslash causes problems when using the load trick.''' In particular, if you have a string with escaped characters in the original code e.g. &amp;lt;code&amp;gt;print(&amp;quot;foo\nbar&amp;quot;)&amp;lt;/code&amp;gt;, then this needs to be double-escaped: &amp;lt;code&amp;gt;load'print(&amp;quot;foo\\nbar&amp;quot;)'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dithering ==&lt;br /&gt;
&lt;br /&gt;
If you have a floating point color value, TIC-80 &amp;lt;code&amp;gt;pix&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;poke4&amp;lt;/code&amp;gt; functions round it (toward zero). To add dithering, add a small value, between 0 and 1, to the color. The best technique depends whether you have &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; available or only &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; and how many bytes you can spare:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
! Expression                     || Length || Result                              || Notes                                                                                                                     &lt;br /&gt;
|-&lt;br /&gt;
|                                ||        || [[File:No dithering.png]]           || No dithering                              &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;s(i)*i%1&amp;lt;/code&amp;gt;          || 8      || [[File:Random dithering.png]]       || &amp;quot;random&amp;quot; dithering &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;i*481/960%1&amp;lt;/code&amp;gt;       || 11     || [[File:Chess dithering.png]]        ||  &amp;lt;code&amp;gt;(x/2+y/4)%1&amp;lt;/code&amp;gt; if you have x&amp;amp;y. &amp;lt;code&amp;gt;i*25/96%1&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;i*97/192&amp;lt;/code&amp;gt; if desperate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;(x*2-y%2)%4/4&amp;lt;/code&amp;gt;     || 13     || [[File:Block dithering.png]]        ||  2x2 block dithering                       &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;(i*2-i//80%2)%4/4&amp;lt;/code&amp;gt; || 17     || [[File:Block dithering from i.png]] ||  2x2 block dithering (almost), from i only &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A quick example demonstrating the 2x2 block dithering:&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;
 cls()&lt;br /&gt;
 for i=0,2399 do&lt;br /&gt;
  x=i%240&lt;br /&gt;
  y=i//240&lt;br /&gt;
  poke4(i,x/30+(x*2-y%2)%4/4)&lt;br /&gt;
 end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Palettes ==&lt;br /&gt;
&lt;br /&gt;
The following palettes assume that &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; goes from 0 to 47. Usually there's no need to make a new loop for this: just reuse another loop with &amp;lt;code&amp;gt;j=i%48&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
! Expression                                       || Length  || Result                               || Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,j*5)&amp;lt;/code&amp;gt;                   || 17      || [[File:Gray palette.png]]            ||&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,j%3*j*5)&amp;lt;/code&amp;gt;               || 21      || [[File:Blue-green-cyan palette.png]] || Good for objects &amp;amp; background&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,j%3*j/.4)&amp;lt;/code&amp;gt;              || 22      || [[File:Blue palette.png]]            || Use &amp;lt;code&amp;gt;(j+1)%3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(j+2)%3&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;2*j%3&amp;lt;/code&amp;gt; for different colors&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,s(j)^2*255)&amp;lt;/code&amp;gt;            || 24      || [[File:Rainbow palette.png]]         || Change the phase of the palette with s(j+p)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,s(j)^2*j*6)&amp;lt;/code&amp;gt;            || 24      || [[File:Rainbow faded palette.png]]   || Change the phase of the palette with s(j+p)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,s(j/15)*255)&amp;lt;/code&amp;gt;           || 25      || [[File:Blue-brown palette.png]]      || &amp;lt;code&amp;gt;s(j/15)^2&amp;lt;/code&amp;gt; is less bright&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,s(j-j%-3)^2*255)&amp;lt;/code&amp;gt;       || 29      || [[File:Green-beige palette.png]]     || &amp;lt;code&amp;gt;j%3*2&amp;lt;/code&amp;gt; for a more blue/beige variant, &amp;lt;code&amp;gt;-j%3*4&amp;lt;/code&amp;gt; for beige/blue variant&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,255/(1+2^(4+j%3-j/5)))&amp;lt;/code&amp;gt; || 35      || [[File:Bright beige palette.png]]    || &amp;lt;code&amp;gt;2*j%3&amp;lt;/code&amp;gt; for a pink variant&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,255/(1+2^(5-j%3-j/5)))&amp;lt;/code&amp;gt; || 35      || [[File:Bright blue palette.png]]     || &amp;lt;code&amp;gt;2*j%3&amp;lt;/code&amp;gt; for a green variant&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;poke(16320+j,s(j/15+s(j%3*3))^2*255)&amp;lt;/code&amp;gt;|| 37      || [[File:Green-purple palette.png]]    || Cyclic, based on [https://iquilezles.org/www/articles/palettes/palettes.htm]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The last one is an entire family of palettes. You can replace &amp;lt;code&amp;gt;s(j%3*3)&amp;lt;/code&amp;gt; with any function that depends on &amp;lt;code&amp;gt;j%3&amp;lt;/code&amp;gt;; this ensures the palette remains cyclic. Some ideas for tweaking the palettes:&lt;br /&gt;
* Invert the colors by adding a &amp;lt;code&amp;gt;-1-&amp;lt;/code&amp;gt; in the expression&lt;br /&gt;
* Flip the blue/red channels &amp;amp; have the entire palette running backwards by using &amp;lt;code&amp;gt;poke(16367-j,...)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Abuse the default Sweetie 16 palette, by only setting some of the RGB channels, while keeping others as they are. For example, setting all the blue channels to zero: &amp;lt;code&amp;gt;poke(16322+j*3,0)&amp;lt;/code&amp;gt;. Here &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; is between 0 and 15.&lt;br /&gt;
&lt;br /&gt;
Code for testing palettes:&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;
 cls()&lt;br /&gt;
 for j=0,47 do poke(16320+j,s(j/15)*255)end&lt;br /&gt;
 for c=0,15 do rect(c*5,0,5,5,c)end&lt;br /&gt;
end&lt;br /&gt;
s=math.sin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Motion blur == &lt;br /&gt;
&lt;br /&gt;
In TIC-80 API, the &amp;lt;code&amp;gt;pix&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;poke4&amp;lt;/code&amp;gt; functions round numbers towards zero. This can be abused for a motion blur: &amp;lt;code&amp;gt;poke4(i,peek4(i)-.9)&amp;lt;/code&amp;gt; maps colors 1 to 15 into one lower value, but value 0 stays at it is. Like so:&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()/9&lt;br /&gt;
 circ(t%240,t%136,9,15)&lt;br /&gt;
 for i=0,32639 do poke4(i,peek4(i)-.9)end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Updating only some pixels ==&lt;br /&gt;
&lt;br /&gt;
Pixel-based effects, especially raycasting and raymarching, can become excessively slow. A simple trick to update only ~ half of the pixels, giving a dithered/motion blur look and making the update smoother:&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()/499&lt;br /&gt;
 for i=t%2,32639,1.9 do poke4(i,i/4e3+t)end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples of effects ==&lt;br /&gt;
&lt;br /&gt;
The effects have not been crunched to keep them readable.&lt;br /&gt;
&lt;br /&gt;
=== Plasma ===&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()/499&lt;br /&gt;
 for i=0,32639 do&lt;br /&gt;
  x=i%240&lt;br /&gt;
  y=i/240&lt;br /&gt;
  v=s(x/50+t)+s(y/22+t)+s(x/32)&lt;br /&gt;
  poke4(i,v*2%8)&lt;br /&gt;
 end&lt;br /&gt;
end&lt;br /&gt;
s=math.sin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rotozoomer ===&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()/999 &lt;br /&gt;
 a=s(t-11)&lt;br /&gt;
 b=s(t)&lt;br /&gt;
 for i=0,32639 do&lt;br /&gt;
  x=i%240-120&lt;br /&gt;
  y=i/240-68&lt;br /&gt;
  u=a*x-b*y&lt;br /&gt;
  v=b*x+a*y&lt;br /&gt;
  poke4(i,(u//1~v//1)//16)&lt;br /&gt;
 end&lt;br /&gt;
end&lt;br /&gt;
s=math.sin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tunnel ===&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()/199&lt;br /&gt;
 for i=0,32639 do&lt;br /&gt;
  x=i%240-s(t/7)*99-120&lt;br /&gt;
  y=i/240-s(t/9)*49-68&lt;br /&gt;
  u=math.atan2(y,x)*6/6.29&lt;br /&gt;
  v=99/(x*x+y*y)^.5+t&lt;br /&gt;
  poke4(i,u//1~v//1)&lt;br /&gt;
 end&lt;br /&gt;
end&lt;br /&gt;
s=math.sin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Raymarcher ===&lt;br /&gt;
&lt;br /&gt;
The map is a bunch of repeated spheres here.&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;
 for i=0,32639 do&lt;br /&gt;
  -- ray (u,v,w), not normalized!&lt;br /&gt;
  u=i%240/120-1&lt;br /&gt;
  v=i/32639-.5&lt;br /&gt;
  w=1&lt;br /&gt;
  -- camera origo (x,y,z)&lt;br /&gt;
  x=3&lt;br /&gt;
  y=0&lt;br /&gt;
  z=time()/999 -- camera moves with time&lt;br /&gt;
  j=0&lt;br /&gt;
  repeat&lt;br /&gt;
   X=x%6-3 -- domain repetition&lt;br /&gt;
   Y=y%6-3&lt;br /&gt;
   Z=z%6-3&lt;br /&gt;
   -- ray not normalized=&amp;gt;reduce scale&lt;br /&gt;
   m=(X*X+Y*Y+Z*Z)^.5/2-1&lt;br /&gt;
   x=x+m*u&lt;br /&gt;
   y=y+m*v&lt;br /&gt;
   z=z+m*w&lt;br /&gt;
   j=j+1&lt;br /&gt;
  until j&amp;gt;15 or m&amp;lt;.1&lt;br /&gt;
  poke4(i,j)&lt;br /&gt;
 end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Code from past bytebattles https://livecode.demozoo.org/&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=JavaScript&amp;diff=1129</id>
		<title>JavaScript</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=JavaScript&amp;diff=1129"/>
				<updated>2022-03-13T21:57:01Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Javascript to JavaScript: To correct the spelling. Interestingly, the correct spelling sends you here without a redirect.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Javascript&amp;diff=1130</id>
		<title>Javascript</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Javascript&amp;diff=1130"/>
				<updated>2022-03-13T21:57:01Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Javascript to JavaScript: To correct the spelling. Interestingly, the correct spelling sends you here without a redirect.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[JavaScript]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Pico8&amp;diff=1128</id>
		<title>Pico8</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Pico8&amp;diff=1128"/>
				<updated>2022-03-13T21:24:50Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Pico8 to PICO-8: PICO-8's the right spelling, and the page is inconvenient or harder to find with no ability to use it.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[PICO-8]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=PICO-8&amp;diff=1127</id>
		<title>PICO-8</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=PICO-8&amp;diff=1127"/>
				<updated>2022-03-13T21:24:49Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Pico8 to PICO-8: PICO-8's the right spelling, and the page is inconvenient or harder to find with no ability to use it.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
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 of 16 colors with size-unfriendly 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 ways 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 sound registers 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 sound effect 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 the above header in an external editor or find and strip them down from your internal PICO-8 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;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Tic80&amp;diff=1126</id>
		<title>Tic80</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Tic80&amp;diff=1126"/>
				<updated>2022-03-13T21:21:12Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Tic80 to TIC-80: TIC-80's the correct spelling, and the page is inconvenient or harder to find.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[TIC-80]]&lt;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=TIC-80&amp;diff=1125</id>
		<title>TIC-80</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=TIC-80&amp;diff=1125"/>
				<updated>2022-03-13T21:21:11Z</updated>
		
		<summary type="html">&lt;p&gt;Childishbeat: Childishbeat moved page Tic80 to TIC-80: TIC-80's the correct spelling, and the page is inconvenient or harder to find.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;/div&gt;</summary>
		<author><name>Childishbeat</name></author>	</entry>

	</feed>