pouët.net

Uncle's Sweater

UNCLE'S SWEATER

Author: rostok (@von_rostock / rostok.itch.io)
Category: Christmas Challenge
System:   PICO-8
Language: Lua 5.2 but PICO-8 does not include the Lua standard library.
Len source code: 115
Len exe file:    54
Len code only:   54
Instructions:
  1) Emulator (free)
     open source.txt in your favourite editor or just use this file
     copy the code into clipboard
     go to https://www.pico-8-edu.com/
     click on the triangle
     press Esc to enter editor
     press Ctrl+V to paste the code
     press Esc again to exit the edior
     type RUN(CLS()) to clear the screen and run the code
                     type this in lowercase
     press Enter
     wait COUPLE OF HOURS till the star is drawn

  2) Actual PICO-8 emulator (propertiary)
     follow steps above but instead of opening browser emulator run the app

  3) Actual PICO-8 emulator (propertiary), different approach
     start the emulator locally
     type LOAD VC-2023-14.ROM end press Enter (in lowercase)
     type RUN(CLS()) end press Enter
     behold

Description:
  The code is quite simple really, it loops endlessly generating random 
  coordinates which are pasted on screen using print shorthand 
  and with color being adjusted to draw sweater pattern
  Here's the code:

x=@24389+3y=@24388run(?"*",x*5.9,y*6.8,8<<(x*x-y*y)%6)

  And explanation for unpacked statements

                              -- assume that user has clear the screen
  x=@24389                    -- read pico-8 memory that corresponds to 
                              -- internal state of psedo-random number
                              -- generator. luckyli this is randomized
                              -- at each program start
                              -- x value is from 0 to 255
  +3                          -- add 3 to shift slightly to right
  y=@24388                    -- also set y to random value (same range)
  run(                        -- here's a bizarre way to loop the program
                              -- by executing statement in run parameters
  ?"*",x*5.9,y*6.8,           -- print asterisk at scaled coordinates
  8<<(x*x-y*y)%6              -- choose the color which is either red (8)
                              -- or black (2^4 an higher values)
  )                           -- loop ends here 
                              -- 
                              -- UNFORTUNATELY DUE TO LARGE RANDOM SPREAD 
                              -- AND DELAY WHEN RE-RUNNING CARTS THIS 
                              -- CODE WILL TAKE HOURS TO RENDER 
                              -- THE PATTERN

Comments:
  This archive and source length
  ------------------------------

  source.txt          - source without 3 line header
  vc-2023-14.p8       - source code with PICO8 header
  vc-2012-14.rom      - packed PICO-8 ROM
  vc-2023-14.png      - a screenshot
  vc-2023-14-mac.jpg  - a screenshot from mac gui
  source.png          - source screenshot as PICO doesn't wrap lines

  As there are 3 files with various length I would like to explain that in
  my personal opinion bare source code (54 bytes for this submission) 
  should be taken for PICO-8 ranking. 

  PICO-8
  ------

  PICO-8 is a virtual machine that has look and feel of 80s game consoles.
  It's screen has a resolution of 128x128 pixels and displays 16 colors.
  Memory is limited to 64kb however Lua variables & code are separate and 
  limited to 2MB. PICO-8 CPU is also limited with each instruction having 
  a specific number of cycles.  
  
  To see some interesting PICO-8 sizecoding creations follow #tweetcart tag 
  on Twitter. This tag is often associated with a single tweet long code 
  (280 chars) focused on making various demo effects.