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

	<entry>
		<id>http://www.sizecoding.org/index.php?title=TIC-80&amp;diff=1191</id>
		<title>TIC-80</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=TIC-80&amp;diff=1191"/>
				<updated>2022-12-05T14:30:58Z</updated>
		
		<summary type="html">&lt;p&gt;Wojciech-graj: Fix typos. Re-write certain sections to improve clarity.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Setting up ===&lt;br /&gt;
The TIC-80 fantasy computer is an all-in-one creation and execution platform.&lt;br /&gt;
&lt;br /&gt;
Setup is easy, simply download an executable from the [https://github.com/nesbox/TIC-80/releases releases] page 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 [https://www.lua.org/ Lua] scripting language. However it is possible to use different scripting languages at the cost of a couple of bytes/characters as shown below (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 (called 60 times a second) is the TIC() function, and is a requirement for animated graphics. Additionally you can also create a SCN() function that is called once per scanline at the cost 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 yourself.  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 learn how TIC() is called in the different languages supported by TIC-80.&lt;br /&gt;
&lt;br /&gt;
A full overview of the TIC-80 memory map and most commonly used functions is available in this [https://zenithsal.com/assets/documents/tic-80_cheatsheet.pdf TIC-80 cheatsheet], as well as the [https://github.com/nesbox/TIC-80/wiki TIC-80 wiki page].&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
The TIC-80 has a 240x136 pixel display with 16 colors 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, setting four bits that represent a pixel's color. Note that the addresses have to be doubled when using poke4 because the memory is 4-bit addressable. Memory address 0x1000 would become 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 [https://lospec.com/palette-list/sweetie-16 sweetie16 palette] as this palette offers a nice selection of 16 colors arranged in such a way that they are easily accessible.&lt;br /&gt;
From version 0.9b onward you can initialize 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. Some packers linked below have the option to do this.&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 sound registers and 32 byte waveforms to access which are located at address 0x0FF9C 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, 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 waveform&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 Optimizations ===&lt;br /&gt;
==== Optimizing with a packer ====&lt;br /&gt;
Packers will shorten variable names, remove excess whitespace, and reorder operators and statements to make the code short and highly-compressible.&lt;br /&gt;
It is therefore more important to write code that a packer can compress effectively as opposed to simply aiming for the smallest uncompressed code.&lt;br /&gt;
&lt;br /&gt;
Repeating patterns within source code will typically be compressed very well.&lt;br /&gt;
Thus, it is best to use the same literals and reserved keywords as often as possible, while avoiding introducing new ones.&lt;br /&gt;
Additionally, if a variable or short function is used in multiple places, replacing each occurrence of the variable or function call with the calculation used to obtain their value will typically reduce cartridge size by a few bytes.&lt;br /&gt;
&lt;br /&gt;
==== Optimizing without a packer====&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 optimization can be done by stringing as much code together on single lines and removing any extra spaces and newlines.&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 TIC cartridge file adds a 4 byte header + 1 extra byte for a 0x11 sweetie16 chunk. &lt;br /&gt;
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 TIC-80 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 linearly 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 TIC-80 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 source code 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;
-- license: MIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As of version 0.9b the http://tic80.com website now also allows you to upload a separate 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;
* pakettic, https://github.com/vsariola/pakettic&lt;/div&gt;</summary>
		<author><name>Wojciech-graj</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Talk:Virtual_Machines&amp;diff=1190</id>
		<title>Talk:Virtual Machines</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Talk:Virtual_Machines&amp;diff=1190"/>
				<updated>2022-12-05T13:59:09Z</updated>
		
		<summary type="html">&lt;p&gt;Wojciech-graj: /* Proposition to delete article */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Proposition to delete article ==&lt;br /&gt;
&lt;br /&gt;
The scope of the article is too broad, as each virtual machine should stay on a separate page. Additionally, only 2 VMs are listed, so the article is very incomplete, and the contents of both sections are duplicates of their standalone pages (http://www.sizecoding.org/wiki/TIC-80 and http://www.sizecoding.org/wiki/JavaScript).&lt;/div&gt;</summary>
		<author><name>Wojciech-graj</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=TIC-80&amp;diff=1189</id>
		<title>TIC-80</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=TIC-80&amp;diff=1189"/>
				<updated>2022-12-05T13:51:22Z</updated>
		
		<summary type="html">&lt;p&gt;Wojciech-graj: Add 'Optimising with a packer' section.&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;
==== Optimising with a packer ====&lt;br /&gt;
Packers will shorten variable names, remove excess whitespace, and reorder operators and statements to make the code short and highly-compressible.&lt;br /&gt;
It is therefore more important to write code that a packer can compress effectively as opposed to simply aiming for the smallest uncompressed code.&lt;br /&gt;
&lt;br /&gt;
Repeating patterns within source code will typically be compressed very well.&lt;br /&gt;
Thus, it is best to use the same literals and reserved keywords as often as possible, while avoiding introducing new ones.&lt;br /&gt;
Additionally, if a variable or short function is used in multiple places, replacing each occurrence of the variable or function call with the calculation used to obtain their value will typically reduce cartridge size by a few bytes.&lt;br /&gt;
&lt;br /&gt;
==== Optimizing without a packer====&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;
* pakettic, https://github.com/vsariola/pakettic&lt;/div&gt;</summary>
		<author><name>Wojciech-graj</name></author>	</entry>

	</feed>