how can you set the tiles to 16 bit?

All aspects of programming on the Commander X16.
Post Reply
funkheld
Posts: 259
Joined: Mon Feb 26, 2024 11:11 am

how can you set the tiles to 16 bit?

Post by funkheld »

Hi good afternoon.
how can you set the tiles to 16 bit please?

can you also print the tiles on layer0 with 2 byte?

Thanks.
greeting
User avatar
ahenry3068
Posts: 969
Joined: Tue Apr 04, 2023 9:57 pm

Re: how can you set the tiles to 16 bit?

Post by ahenry3068 »

funkheld wrote: Fri Mar 29, 2024 9:35 am Hi good afternoon.
how can you set the tiles to 16 bit please?

can you also print the tiles on layer0 with 2 byte?

Thanks.
greeting
This is getting outside my experience as I've been concentrating on 8 bit graphics. I suspect you mean 16 COLOR which is actually 4 bit tiles. You have to know the numbers to get it correct 1 bit --> 2 color, 2 bit --> 4 colors , 4 bit --> 16 colors, 8 bit --> 256 colors.
funkheld
Posts: 259
Joined: Mon Feb 26, 2024 11:11 am

Re: how can you set the tiles to 16 bit?

Post by funkheld »

I meant can you set the tiles to 16 bit width?

Thanks.
greeting
hstubbs3
Posts: 72
Joined: Thu Oct 26, 2023 12:14 pm

Re: how can you set the tiles to 16 bit?

Post by hstubbs3 »

Funkheld,

Tiles can only be set to 8x8, 8x16, 16x8 or 16x16 ..
The height and width are set in the tilebase register for the layer ->

$9F2F L0_TILEBASE Tile Base Address (16:11) | Tile Height | Tile Width
$9F36 L1_TILEBASE Tile Base Address (16:11) | Tile Height | Tile Width

IE -
set $9F36 equal to ((TILEBASE_ADDRESSS >> 9) & $FC) + (TILE_HEIGHT_IS_16 < 1) + TILE_WIDTH_IS_16

or something like -
POKE $9F36,((TILEBASE_ADDRESS/2048) AND $FC) + (TILE_HEIGHT_IS_16*1) + ( TILE_WIDTH_IS_16)

in the emulator ...
?PEEK($9F36)
gave me 248 ... so +1 to make it use tiles 16 wide..
POKE $9F36,249

corrupts the basic screen but hopefully it is clear that it is corrupted by incorrectly interpreting the tiles as 16x8 now.
One would have to load tiles of the correct size for this to work cleanly.
funkheld
Posts: 259
Joined: Mon Feb 26, 2024 11:11 am

Re: how can you set the tiles to 16 bit?

Post by funkheld »

thanks a lot.
249 works with tile-x 16.

value do you take for tile-y 16 please = 248+1+?

I can't figure out how to do the math for this.

Thanks.
greeting
hstubbs3
Posts: 72
Joined: Thu Oct 26, 2023 12:14 pm

Re: how can you set the tiles to 16 bit?

Post by hstubbs3 »

Funkheld,

Oops.. I made a mistake in my earlier maths..
set $9F36 equal to ((TILEBASE_ADDRESSS >> 9) & $FC) + (TILE_HEIGHT_IS_16 < 1) + TILE_WIDTH_IS_16
^ this part was correct, where TILE_HEIGHT_IS_16 and TILE_WIDTH_IS_16 are 1 if true and 0 if false..

The POKE was wrong... because to set Y for the tiles to 16, you have to add 2 ( VAR < 1 is same as VAR *2 )

which gives this for that tilebase -
248 => 8x8
249 => 16x8
250 => 8x16
251 => 16x16

this is of course using that tilebase that is already set for layer1 in BASIC mode - using the 8x8 character set copied from ROM to $1:F000 - which is pretty much cramped in there ! ->

$1:F000-$1:F7FF Charset
$1:F800-$1:F9BF unused (448 bytes)
$1:F9C0-$1:F9FF VERA PSG Registers (16 x 4 bytes)

if you are going to use tiles that are 16x8 or 8x16, those are 2x the size of 8x8, and if using 16x16, that is 4x the size!
So if you plan on using these larger tile sizes, you should set the tilebase to a different location in VRAM!
(You'll know when you overwrite out of the available space because the sound chip will start doing stuff, colors will corrupt, and finally sprites may appear or do weird things as you write further into reserved VRAM )


for quick reference, 1Bpp tiles -
8x8 - each is 8 bytes, 256 tiles in a set => 2K
8x16 or 16x8 - each is 16 bytes => 4K
16x16 - each is 32 bytes => 8K

and are stored line by line - say a letter F maybe ?
01111111 11111000 01111111 11111000 01111111 00000000 01111111 11100000 01111111 11100000 01111111 00000000 01111111 00000000 00000000 00000000 And would appear in memory like 7F F8 7F F8 7F 00 7F E0 7F E0 7F 00 7F 00 00
funkheld
Posts: 259
Joined: Mon Feb 26, 2024 11:11 am

Re: how can you set the tiles to 16 bit?

Post by funkheld »

hello , thanks for the mathe.

thanks
greeting.
Post Reply