Page 1 of 1

Is there a tool to tell how many tiles I'm using?

Posted: Sat Feb 20, 2016 8:58 pm
by POLYGAMe
I seem to remember seeing screenshots in one of the threads of an app that gives detailed VDP data but I can't find it. Anyone know where I could get it? Want to keep an eye on my tile count.

Re: Is there a tool to tell how many tiles I'm using?

Posted: Sun Feb 21, 2016 3:09 pm
by BigEvilCorporation
It depends what qualifies as "using" - all tiles are "in use" at all times I guess. Do you want to keep a counter of how many tiles you've uploaded to VRAM, or determine if a specific art asset is going to fit at compile time?

I'm from an assembler background so mileage may vary, but my game has a static VRAM layout map and a quick n' dirty calculation to show me the size of each of my banks at assembly time:

Code: Select all

;---------------------------------------------------------
; Bank 0
;---------------------------------------------------------
Tile_Bank0_Size_t:     equ vdp_max_tiles
Tile_Bank0_Size_b:     equ (Tile_Bank0_Size_t*size_tile_b)
Tile_Bank0_Start:    equ (vram_addr_tiles)
;---------------------------------------------------------

	rsset Tile_Bank0_Start
Tiles_PixelFontVRAM: rs.b (Tiles_PixelFontSizeB)
Tiles_Player1VRAM:   rs.b (tiles_nymn_size_b)
Tiles_MonsterVRAM:   rs.b (tiles_monster_size_b)
LevelMapVRAM:        rs.b (tiles_lvl1_size_b)

;---------------------------------------------------------
Tiles_Bank0_End:     rs.b 0
Tiles_Bank0_Count    equ (Tiles_Bank0_End/size_tile_b)
;---------------------------------------------------------


;---------------------------------------------------------
; Bank 1
;---------------------------------------------------------
Tile_Bank1_Size_b:   equ 0x1000
Tile_Bank1_Size_t:   equ (0x1000/size_tile_b)
Tile_Bank1_Start:    equ (vram_addr_plane_a+Tile_Bank1_Size_b)	; Spare space at VDP 0xD000-0xE000
;---------------------------------------------------------

	rsset Tile_Bank1_Start
Tiles_Fuzzl1VRAM:    rs.b (tiles_fuzzl_size_b)
Tiles_Fuzzl2VRAM:    rs.b (tiles_fuzzl_size_b)
Tiles_Leaf1VRAM:     rs.b (tiles_leaf_size_b)
Tiles_Leaf2VRAM:     rs.b (tiles_leaf_size_b)
Tiles_Leaf3VRAM:     rs.b (tiles_leaf_size_b)
Tiles_VinesVRAM:     rs.b (tiles_vines_size_b)
Tiles_BoulderVRAM:   rs.b (tiles_boulder_size_b*Boulder_MaxEntities)
Tiles_FireflyVRAM:   rs.b (tiles_firefly_size_b*Firefly_MaxEntities)

;---------------------------------------------------------
Tiles_Bank1_End:     rs.b 0
Tiles_Bank1_Count    equ ((Tiles_Bank1_End-Tile_Bank1_Start)/size_tile_b)
;---------------------------------------------------------

	inform 0,"-----------------------------------"
	inform 0,"VDP tile count (bank 0): %d / %d", Tiles_Bank0_Count,Tile_Bank0_Size_t
	inform 0,"VDP tile count (bank 1): %d / %d", Tiles_Bank1_Count,Tile_Bank1_Size_t
	inform 0,"-----------------------------------"

	if (Tiles_Bank0_Count>Tile_Bank0_Size_t)
	inform 2,'VDP tile bank 0 count overflow (count: %d, max: %d)',Tiles_Bank0_Count,Tile_Bank0_Size_t
	endif

	if (Tiles_Bank1_Count>Tile_Bank1_Size_t)
	inform 2,'VDP tile bank 1 count overflow (count: %d, max: %d)',Tiles_Bank1_Count,Tile_Bank1_Size_t
	endif
In C you have the luxury of a better static array syntax and sizeof(), so it should be considerably easier.

As for runtime usage, I guess you could just keep a counter of how many tiles you've copied to VRAM?

Re: Is there a tool to tell how many tiles I'm using?

Posted: Sun Feb 21, 2016 11:03 pm
by POLYGAMe
BigEvilCorporation wrote:It depends what qualifies as "using" - all tiles are "in use" at all times I guess. Do you want to keep a counter of how many tiles you've uploaded to VRAM, or determine if a specific art asset is going to fit at compile time?

I'm from an assembler background so mileage may vary, but my game has a static VRAM layout map and a quick n' dirty calculation to show me the size of each of my banks at assembly time:

Code: Select all

;---------------------------------------------------------
; Bank 0
;---------------------------------------------------------
Tile_Bank0_Size_t:     equ vdp_max_tiles
Tile_Bank0_Size_b:     equ (Tile_Bank0_Size_t*size_tile_b)
Tile_Bank0_Start:    equ (vram_addr_tiles)
;---------------------------------------------------------

	rsset Tile_Bank0_Start
Tiles_PixelFontVRAM: rs.b (Tiles_PixelFontSizeB)
Tiles_Player1VRAM:   rs.b (tiles_nymn_size_b)
Tiles_MonsterVRAM:   rs.b (tiles_monster_size_b)
LevelMapVRAM:        rs.b (tiles_lvl1_size_b)

;---------------------------------------------------------
Tiles_Bank0_End:     rs.b 0
Tiles_Bank0_Count    equ (Tiles_Bank0_End/size_tile_b)
;---------------------------------------------------------


;---------------------------------------------------------
; Bank 1
;---------------------------------------------------------
Tile_Bank1_Size_b:   equ 0x1000
Tile_Bank1_Size_t:   equ (0x1000/size_tile_b)
Tile_Bank1_Start:    equ (vram_addr_plane_a+Tile_Bank1_Size_b)	; Spare space at VDP 0xD000-0xE000
;---------------------------------------------------------

	rsset Tile_Bank1_Start
Tiles_Fuzzl1VRAM:    rs.b (tiles_fuzzl_size_b)
Tiles_Fuzzl2VRAM:    rs.b (tiles_fuzzl_size_b)
Tiles_Leaf1VRAM:     rs.b (tiles_leaf_size_b)
Tiles_Leaf2VRAM:     rs.b (tiles_leaf_size_b)
Tiles_Leaf3VRAM:     rs.b (tiles_leaf_size_b)
Tiles_VinesVRAM:     rs.b (tiles_vines_size_b)
Tiles_BoulderVRAM:   rs.b (tiles_boulder_size_b*Boulder_MaxEntities)
Tiles_FireflyVRAM:   rs.b (tiles_firefly_size_b*Firefly_MaxEntities)

;---------------------------------------------------------
Tiles_Bank1_End:     rs.b 0
Tiles_Bank1_Count    equ ((Tiles_Bank1_End-Tile_Bank1_Start)/size_tile_b)
;---------------------------------------------------------

	inform 0,"-----------------------------------"
	inform 0,"VDP tile count (bank 0): %d / %d", Tiles_Bank0_Count,Tile_Bank0_Size_t
	inform 0,"VDP tile count (bank 1): %d / %d", Tiles_Bank1_Count,Tile_Bank1_Size_t
	inform 0,"-----------------------------------"

	if (Tiles_Bank0_Count>Tile_Bank0_Size_t)
	inform 2,'VDP tile bank 0 count overflow (count: %d, max: %d)',Tiles_Bank0_Count,Tile_Bank0_Size_t
	endif

	if (Tiles_Bank1_Count>Tile_Bank1_Size_t)
	inform 2,'VDP tile bank 1 count overflow (count: %d, max: %d)',Tiles_Bank1_Count,Tile_Bank1_Size_t
	endif
In C you have the luxury of a better static array syntax and sizeof(), so it should be considerably easier.

As for runtime usage, I guess you could just keep a counter of how many tiles you've copied to VRAM?
LOL I didn't even think of that. Easy peasy. I was more thinking of an app I can load my images into to check each image's tile size but really as long as it all fits I'm fine. Haha.

Re: Is there a tool to tell how many tiles I'm using?

Posted: Mon Feb 22, 2016 11:09 am
by BigEvilCorporation
Retro Graphics Toolkit can tell you the number of unique tiles in a given image, remove duplicates and even dither to reduce: viewtopic.php?f=7&t=1392

It won't work for sprites though since sprite tiles not mapped by ID (unless you keep one sprite per tile).

There's also my own map editing tool which can import images, remove duplicates and show you the resulting size. It's nowhere near RGT with regards to features but hopefully a little more user friendly: viewtopic.php?f=7&t=2259

Re: Is there a tool to tell how many tiles I'm using?

Posted: Mon Feb 22, 2016 5:46 pm
by POLYGAMe
BigEvilCorporation wrote:Retro Graphics Toolkit can tell you the number of unique tiles in a given image, remove duplicates and even dither to reduce: viewtopic.php?f=7&t=1392

It won't work for sprites though since sprite tiles not mapped by ID (unless you keep one sprite per tile).

There's also my own map editing tool which can import images, remove duplicates and show you the resulting size. It's nowhere near RGT with regards to features but hopefully a little more user friendly: viewtopic.php?f=7&t=2259
Awesome, thanks!