PICO-8 Wiki
No edit summary
Tag: Source edit
No edit summary
Tag: Source edit
(One intermediate revision by one other user not shown)
Line 42: Line 42:
 
|13 || <code>\r</code> || Carriage return ||
 
|13 || <code>\r</code> || Carriage return ||
 
|-
 
|-
|14 || <code>\014</code> || Switch font defined at 0x5600 ||
+
|14 || <code>\14</code> || Switch font defined at 0x5600 ||
 
|-
 
|-
|15 || <code>\015</code> || Switch font to default ||
+
|15 || <code>\15</code> || Switch font to default ||
 
|-
 
|-
 
|}
 
|}
Line 201: Line 201:
   
 
When printed, characters 128-255 are eight pixels wide. Characters 32-127 print as four pixels wide.
 
When printed, characters 128-255 are eight pixels wide. Characters 32-127 print as four pixels wide.
  +
  +
'''Note:''' PICO-8 uses [https://emojipedia.org/variation-selector-16/ variation selector 16] (U+FE0F) with the Unicode emoji symbols for Down key (⬇️), Left key (⬅️), O key (🅾️), Right key (➡️), and Up key (⬆️). Not all emoji-capable displays show an emoji variant glyph for [https://unicode-table.com/en/27A1/ Black Rightwards Arrow] (U+27A1), but PICO-8 uses the variation selector anyway. The variation selector is ''not'' used with X key (U+274E).
   
 
{| class="article-table"
 
{| class="article-table"
Line 213: Line 215:
 
|130 || 🐱 || Jelpi || U+1F431 || Shift-C
 
|130 || 🐱 || Jelpi || U+1F431 || Shift-C
 
|-
 
|-
|131 || ⬇️ || Down key || U+2B07 || Shift-D
+
|131 || ⬇️ || Down key || U+2B07 U+FE0F || Shift-D
 
|-
 
|-
 
|132 || ░ || Dot pattern || U+2591 || Shift-E
 
|132 || ░ || Dot pattern || U+2591 || Shift-E
Line 229: Line 231:
 
|138 || ⌂ || House || U+2302 || Shift-K
 
|138 || ⌂ || House || U+2302 || Shift-K
 
|-
 
|-
|139 || ⬅️ || Left key || U+2B05 || Shift-L
+
|139 || ⬅️ || Left key || U+2B05 U+FE0F || Shift-L
 
|-
 
|-
 
|140 || 😐 || Face || U+1F610 || Shift-M
 
|140 || 😐 || Face || U+1F610 || Shift-M
Line 235: Line 237:
 
|141 || ♪ || Musical note || U+266A || Shift-N
 
|141 || ♪ || Musical note || U+266A || Shift-N
 
|-
 
|-
|142 || 🅾️ || O key || U+1F17E || Shift-O
+
|142 || 🅾️ || O key || U+1F17E U+FE0F || Shift-O
 
|-
 
|-
 
|143 || ◆ || Diamond || U+25C6 || Shift-P
 
|143 || ◆ || Diamond || U+25C6 || Shift-P
Line 241: Line 243:
 
|144 || … || Ellipsis || U+2026 || Shift-Q
 
|144 || … || Ellipsis || U+2026 || Shift-Q
 
|-
 
|-
|145 || ➡️ || Right key || U+27A1 || Shift-R
+
|145 || ➡️ || Right key || U+27A1 U+FE0F || Shift-R
 
|-
 
|-
 
|146 || ★ || Five-pointed star || U+2605 || Shift-S
 
|146 || ★ || Five-pointed star || U+2605 || Shift-S
Line 247: Line 249:
 
|147 || ⧗ || Hourglass || U+29D7 || Shift-T
 
|147 || ⧗ || Hourglass || U+29D7 || Shift-T
 
|-
 
|-
|148 || ⬆️ || Up key || U+2B06 || Shift-U
+
|148 || ⬆️ || Up key || U+2B06 U+FE0F || Shift-U
 
|-
 
|-
 
|149 || ˇ || Birds || U+2C7 || Shift-V
 
|149 || ˇ || Birds || U+2C7 || Shift-V

Revision as of 22:15, 9 September 2021

P8SCII is PICO-8's character set. It has 256 codes, consisting of 16 control codes and 240 printable characters (letters, numbers, symbols).

For detailed information about control codes, see P8SCII Control Codes.

P8SCII reference

Control codes

Control codes describe effects that occur during printing of strings via the print() function. Typically, you specify a control code in a string literal with an escape sequence. Code strings can also be calculated by number with chr(). Except for cursor position, foreground color, and audio in progress, effects are reset at the end of the print() function call.

Some codes accept parameters as characters after the control code. See P8SCII Control Codes for more details.

Number Character Name Parameters
0 \0 Terminate printing
1 \* Repeat next character P0: number of times to repeat
2 \# Draw solid background P0: color
3 \- Move cursor horizontally P0: num of pixels minus 16
4 \| Move cursor vertically P0: num of pixels minus 16
5 \+ Move cursor P0: horiz offset minus 16; P1: vert offset minus 16
6 \^ Special command See P8SCII Control Codes
7 \a Audio command See P8SCII Control Codes
8 \b Backspace
9 \t Tab
10 \n Newline
11 \v Decorate previous character See P8SCII Control Codes
12 \f Set foreground color P0: color
13 \r Carriage return
14 \14 Switch font defined at 0x5600
15 \15 Switch font to default

Symbols and Japanese punctuation

Symbols and punc

PICO-8 rendering of the symbols and Japanese punctuation character range

Characters 16-31 are symbols useful as icons or Japanese punctuation.

Number Character Name Unicode Number Character Name Unicode
16 Vertical rectangle U+25AE 24 Japanese starting quote U+300C
17 Filled square U+25A0 25 Japanese ending quote U+300D
18 Hollow square U+25A1 26 ¥ Yen sign U+A5
19 Five dot U+2059 27 Interpunct U+2022
20 Four dot U+2058 28 Japanese comma U+3001
21 Pause U+2016 29 Japanese full stop U+3002
22 Back U+25C0 30 Japanese dakuten U+309B
23 Forward U+25B6 31 Japanese handakuten U+309C

ASCII characters

Ascii

PICO-8 rendering of the ASCII character range

Printable characters 32-127 match the ASCII standard.

Within PICO-8, English letters in the range 65-90 print in lowercase (small caps), while letters in the range 97-122 print in uppercase.

Number Character Name Number Character Name
32 space space 80 P P
33 ! ! 81 Q Q
34 " Double quote 82 R R
35 # # 83 S S
36 $ $ 84 T T
37 % % 85 U U
38 & & 86 V V
39 ' Single quote 87 W W
40 ( ( 88 X X
41 ) ) 89 Y Y
42 * * 90 Z Z
43 + + 91 [ [
44 , , 92 \ \
45 - - 93 ] ]
46 . . 94 ^ ^
47 / / 95 _ Underscore
48 0 0 96 ` Backtick
49 1 1 97 a a
50 2 2 98 b b
51 3 3 99 c c
52 4 4 100 d d
53 5 5 101 e e
54 6 6 102 f f
55 7 7 103 g g
56 8 8 104 h h
57 9 9 105 i i
58 : : 106 j j
59 ; ; 107 k k
60 < < 108 l l
61 = = 109 m m
62 > > 110 n n
63 ? ? 111 o o
64 @ @ 112 p p
65 A A 113 q q
66 B B 114 r r
67 C C 115 s s
68 D D 116 t t
69 E E 117 u u
70 F F 118 v v
71 G G 119 w w
72 H H 120 x x
73 I I 121 y y
74 J J 122 z z
75 K K 123 { {
76 L L 124 | Vertical bar
77 M M 125 } }
78 N N 126 ~ Tilde
79 O O

Typeable symbols

Symbols

PICO-8 rendering of the typeable symbols character range

Characters 127-153 and 254-255 are graphical symbols proprietary to PICO-8.

Symbols in the range 128-153 can be entered in the PICO-8 editor by holding the Shift key and pressing a letter key, assigned in alphabetical order. Many symbols have intuitive assignments. For example, the Up, Down, Right, Left, X, and O keypad symbols are assigned to Shift-U, Shift-D, Shift-R, Shift-L, Shift-X, and Shift-O, respectively.

Tip: The btn() and btnp() functions accept the keypad symbols as an argument, as an alternative to the key code. Use the corresponding symbol as if it were a variable name, without string quotes:

if btn() then
  jump()
end

When printed, characters 128-255 are eight pixels wide. Characters 32-127 print as four pixels wide.

Note: PICO-8 uses variation selector 16 (U+FE0F) with the Unicode emoji symbols for Down key (⬇️), Left key (⬅️), O key (🅾️), Right key (➡️), and Up key (⬆️). Not all emoji-capable displays show an emoji variant glyph for Black Rightwards Arrow (U+27A1), but PICO-8 uses the variation selector anyway. The variation selector is not used with X key (U+274E).

Number Character Name Unicode Entry
127 Hollow circle U+25CB
128 Rectangle U+2588 Shift-A
129 Checkerboard U+2592 Shift-B
130 🐱 Jelpi U+1F431 Shift-C
131 ⬇️ Down key U+2B07 U+FE0F Shift-D
132 Dot pattern U+2591 Shift-E
133 Throwing star U+273D Shift-F
134 Ball U+25CF Shift-G
135 Heart U+2665 Shift-H
136 Eye U+2609 Shift-I
137 Man U+C6C3 Shift-J
138 House U+2302 Shift-K
139 ⬅️ Left key U+2B05 U+FE0F Shift-L
140 😐 Face U+1F610 Shift-M
141 Musical note U+266A Shift-N
142 🅾️ O key U+1F17E U+FE0F Shift-O
143 Diamond U+25C6 Shift-P
144 Ellipsis U+2026 Shift-Q
145 ➡️ Right key U+27A1 U+FE0F Shift-R
146 Five-pointed star U+2605 Shift-S
147 Hourglass U+29D7 Shift-T
148 ⬆️ Up key U+2B06 U+FE0F Shift-U
149 ˇ Birds U+2C7 Shift-V
150 Sawtooth U+2227 Shift-W
151 X key U+274E Shift-X
152 Horiz lines U+25A4 Shift-Y
153 Vert lines U+25A5 Shift-Z

Hiragana

Hiragana

PICO-8 rendering of the Japanese Hiragana character range

Characters 154-203 are the Japanese Hiragana alphabet, and characters 204-253 are the Japanese Katakana alphabet. Japanese characters appear in order, followed by the four digraph indicators.

Japanese diacritics and punctuation can be found in characters 24-31.

Number Character Name Unicode Number Character Name Unicode
154 a U+3042 179 ha U+306F
155 i U+3044 180 hi U+3072
156 u U+3046 181 fu U+3075
157 e U+3048 182 he U+3078
158 o U+304A 183 ho U+307B
159 ka U+304B 184 ma U+307E
160 ki U+304D 185 mi U+307F
161 ku U+304F 186 mu U+3080
162 ke U+3051 187 me U+3081
163 ko U+3053 188 mo U+3082
164 sa U+3055 189 ya U+3084
165 shi U+3057 190 yu U+3086
166 su U+3059 191 yo U+3088
167 se U+305B 192 ra U+3089
168 so U+305D 193 ri U+308A
169 ta U+305F 194 ru U+308B
170 chi U+3061 195 re U+308C
171 tsu U+3064 196 ro U+308D
172 te U+3066 197 wa U+308F
173 to U+3068 198 wo U+3092
174 na U+306A 199 n U+3093
175 ni U+306B 200 Sokuon U+3063
176 nu U+306C 201 Digraph: ya U+3083
177 ne U+306D 202 Digraph: yu U+3085
178 no U+306E 203 Digraph: yo U+3087

Katakana

Katakana

PICO-8 rendering of the Japanese Katakana character range

Characters 204-253 are the Japanese Katakana alphabet. Japanese characters appear in order, followed by the four digraph indicators.

Japanese diacritics and punctuation can be found in characters 24-31.

Number Character Name Unicode Number Character Name Unicode
204 a U+30A2 229 ha U+30CF
205 i U+30A4 230 hi U+30D2
206 u U+30A6 231 fu U+30D5
207 e U+30A8 232 he U+30D8
208 o U+30AA 233 ho U+30DB
209 ka U+30AB 234 ma U+30DE
210 ki U+30AD 235 mi U+30DF
211 ku U+30AF 236 mu U+30E0
212 ke U+30B1 237 me U+30E1
213 ko U+30B3 238 mo U+30E2
214 sa U+30B5 239 ya U+30E4
215 shi U+30B7 240 yu U+30E6
216 su U+30B9 241 yo U+30E8
217 se U+30BB 242 ra U+30E9
218 so U+30BD 243 ri U+30EA
219 ta U+30BF 244 ru U+30EB
220 chi U+30C1 245 re U+30EC
221 tsu U+30C4 246 ro U+30ED
222 te U+30C6 247 wa U+30EF
223 to U+30C8 248 wo U+30F2
224 na U+30CA 249 n U+30F3
225 ni U+30CB 250 Sokuon U+30C3
226 nu U+30CC 251 Digraph: ya U+30E3
227 ne U+30CD 252 Digraph: yu U+30E5
228 no U+30CE 253 Digraph: yo U+30E7

Remaining symbols

Remaining

PICO-8 rendering of the final two symbols of the P8SCII character set

The final two characters in the P8SCII set offer two more symbols.

Number Character Name Unicode
254 Left arc U+25DC
255 Right arc U+25DD

Using PS8SCII codes

All characters and codes can appear in string literals using either typed characters or escape sequences. Some codes have special escape sequences, such as \n for a newline code. All codes can be entered via their number using an escape sequence such as \0xxx, where xxx is the number in decimal.

print("press ❎ to jump\npress 🅾️ to use an item")

price = 729
print("cost: " .. chr(26) .. tostr(price))

The chr() function takes a number and returns a one-character string with the corresponding P8SCII character. The ord() function takes a one-character string and returns the P8SCII code for that character as a number.

All printable characters have an equivalent symbol in the Unicode character set. You can type a printable character in the PICO-8 editor by entering the corresponding symbol or by pasting it from the clipboard. PICO-8 uses the Unicode equivalent when saving to a .p8 file, printing to the console via printh(), or copying to the clipboard.

Note: The P8SCII value is not the same as the Unicode value! The character sets overlap in the ASCII range (32-126), with uppercase and lowercase swapped. Otherwise, a P8SCII printable character maps to a Unicode character with the same meaning (as for Japanese letters) or a pictographic equivalent (as for symbols).