-
-
Notifications
You must be signed in to change notification settings - Fork 492
blit segment
poke4(2*0x03FFC, blit_segment)
The blit segment controls how sprite drawing functions will read sprites in memory. It can specify the amount of bits to read per pixel and the position of the spritesheet.
In TIC-80, sprite drawing functions use two different types of indexing:
- total indexing:
spr
indexes sprites counting 8x8 sprite positions from left to right and from top to bottom on the whole spritesheet - local indexing:
map
,ttri
withtexsrc=1
andfont
use 8 bit unsigned integer as indexes. This difference is the reason why those functions are limited to a portion of the spritesheet.
The blit segment modifies how indexes are interpreted.
val | bin | target memory segment
--------------------------
2 | 0010 | 4bpp // default value
4 | 0100 | 2bpp
8 | 1000 | 1bpp
4 bpp 2 bpp 1 bpp
<-------16 cols-------> <--------32 cols--------> <---------64 cols--------->
+------+---------+------+ +------+-----------+------+ +------+------+------+------+
| 0000 | | 0015 | | 0000 | | 0031 | | 0000 | | 0063 |
+------+-- --+------+ +------+-- --+------+ +------+-- --+------+
| | | | | |
: TILES (BG) : : TILES (BG) : : TILES (BG) :
| | | | | |
+ --+-- --+------+ + --+-- --+------+ + --+-- --+------+
| | 0255 | | | 0511 | | | 1023 |
+------+---------+------+ +------+-----------+------+ +------+-------------+------+
| 0256 | | 0271 | | 0512 | | 0527 | | 1024 | | 1087 |
+------+-- --+------+ +------+-- --+------+ +------+-- --+------+
| | | | | |
: SPRITES (FG) : : SPRITES (FG) : : SPRITES (FG) :
| | | | | |
+ --+-- --+------+ + --+-- --+------+ + --+-- --+------+
| | 0511 | | | 1023 | | | 2047 |
+------+---------+------+ +------+-----------+------+ +------+------+------+------+
The blit_segment
can be used to give functions using local indexing access to the full spritesheet using origin translation. blit_segment
values define actually define both the way to read pixels and a virtual window in memory.
Because local indexing considers a 16 columns grid, low bpp spritesheets are organized in pages of 16 columns, laid out horizontally. The blit segment defines which page will be read.
Also, because both indexing schemes should be usable for any value of blit_segment
, origin translation is also applicable to total indexing. The spritesheet wraps around on both vertical and horizontal axis, and the blit segment defines where the indexing starts.
val | bin | target memory segment
--------------------------
0 | 0000 | (reserved)
1 | 0001 | (reserved)
2 | 0010 | 4bpp BG page 0 // default value
3 | 0011 | " FG page 0
4 | 0100 | 2bpp BG page 0
5 | 0101 | " " page 1
6 | 0110 | " FG page 0
7 | 0111 | " " page 1
8 | 1000 | 1bpp BG page 0
9 | 1001 | " " page 1
10 | 1010 | " " page 2
11 | 1011 | " " page 3
12 | 1100 | " FG page 0
13 | 1101 | " " page 1
14 | 1110 | " " page 2
15 | 1111 | " " page 3
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
Platform
RAM & VRAM | Display | Palette | Bits per Pixel (BPP) |
.tic
Format | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
- BDR (0.90)
- BOOT (1.0)
- MENU
- OVR (deprecated)
- SCN (deprecated)
- TIC
- btn & btnp
- circ & circb
- clip
- cls
- elli & ellib (0.90)
- exit
- fget & fset (0.80)
- font
- key & keyp
- line
- map
- memcpy & memset
- mget & mset
- mouse
- music
- peek, peek4
- peek1, peek2 (1.0)
- pix
- pmem
- poke, poke4
- poke1, poke2 (1.0)
- rect & rectb
- reset
- sfx
- spr
- sync
- ttri (1.0)
- time
- trace
- tri & trib (0.90)
- tstamp (0.80)
- vbank (1.0)