{"id":25497405,"url":"https://github.com/pklito/ds-isometric-tiles","last_synced_at":"2025-09-13T10:39:44.735Z","repository":{"id":208261465,"uuid":"721194729","full_name":"pklito/DS-isometric-tiles","owner":"pklito","description":"Isometric graphics demo on the DSi using very limited memory","archived":false,"fork":false,"pushed_at":"2025-01-22T18:43:41.000Z","size":230,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T11:45:43.603Z","etag":null,"topics":["dsi","embedded-systems","isometric-graphics"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pklito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-20T14:49:51.000Z","updated_at":"2025-01-22T19:03:42.000Z","dependencies_parsed_at":"2025-01-22T19:31:43.808Z","dependency_job_id":"ba16e3bb-be7c-4bc1-9414-a7372a5e1b36","html_url":"https://github.com/pklito/DS-isometric-tiles","commit_stats":null,"previous_names":["pauloalbert/ds-isometric-tiles","pklito/ds-isometric-tiles"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pklito/DS-isometric-tiles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklito%2FDS-isometric-tiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklito%2FDS-isometric-tiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklito%2FDS-isometric-tiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklito%2FDS-isometric-tiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pklito","download_url":"https://codeload.github.com/pklito/DS-isometric-tiles/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklito%2FDS-isometric-tiles/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274950060,"owners_count":25379560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsi","embedded-systems","isometric-graphics"],"created_at":"2025-02-19T01:19:33.681Z","updated_at":"2025-09-13T10:39:44.714Z","avatar_url":"https://github.com/pklito.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DS-isometric-tiles\nThis project is a mock-up of typical isometric perspective games I worked on in my free time, using the tile mode on the nintendo DS, as part of course on micro-embedded programming EE-310 at EPFL, Lausanne.  \nThis project tries to push to it's limit what can be done using a very small number of tilemap tiles on the DSi software, to create isometric landscape with memory efficiency.\n\n![](readme_files/demo.png)\n## The project's main challenge\nIsometric view(technically Dimetric view in this case, but I will be calling it Isometric to fit the term used in gaming) looks something like this:\n\nThe difficulty is I intend to draw it using fixed predefined tiles of 8x8 pixels.\nThe first observation I made when starting this project is that we can draw the blocks in such a way where each tile is split up to three slices:  \n\u003cimg src=\"readme_files/tile_slices.png\" width=\"100\" /\u003e  \n\nIf we could paint each individual triangle, we can create the isometric look fairly easily.\n\n## How the code works\n### Turning the world into triangles\nWe start with a 3 dimentional cube world; in the code, it is called `WORLD_MAP`. a 0 in this array means air, a 1 means block 1, a 2, block 2.\nWe call the function `ISO_GenerateTiles` this function takes this 3D world and converts it into an array of 32x32 squares, from the screens perspective.\nThese aren't graphical tiles, they store the 3 colors of the triangles that will be in the tile in that location. represented as such:  \n|15|14-10|98765|43210|\n|---|---|---|---|\n|on bit|data top|data middle| data bottom|\n\nwhere data would look like this: `(01)(001)`  \nthe bottom 3 bits store the type of the block which had that face, and the top 2 bits store if it was the Top face of a block (FLOOR), the left wall (WALL_LEFT) or the right wall (WALL_RIGHT). (11) is undefined.  \n\n### Converting triangles into tiles\nThe following code exists inside `ISO_RenderTiles`.\nwe now have a `u16` array of the triangles in our screen which we need to convert to tiles.  \n**we can now observe an issue:** there are many combinations of triangle colors that can fit into one tile. we need to have a different tile for each combination  \nThe solution is to cleverly use Palettes to allow you to switch around colors.\n\n**observation:** there are some impossible combinations for triangles, such as  \nFloor 1 /  \n  /-- Wall 2  \nWall 1 \\\\--  \nIf a floor cuts above another block, it will have its own wall under it. so there is no way Wall 2 can be directly under floor 1.  \nWe can use this to map out the possible combinations and split them to an ordering that is logical.  \n\n#### Our division\nTiles are split into **which colors repeat themselves on the tile**: AAA, AAB, ABA, ABB, ABC  \nIn total, I have configured 25 different tiles:  \n - AAA: FULL\n - ABA: F1F2F1, F1W1F1, W1F1W1\n - AAB: F1F1F2, F1F1W1, W1W1X {W1W1F2, W1W1(W1b), W1W1W2, W1W1D, (W1b)(W1b)W1}\n - ABB: F1W1W1, XF2F2 {F1F2F2, DF2F2, WFF{_W1DD, _W2F2F2, _W1F2F2}\n - ABC: F1F2F3, F1F2W2, W1F2F3{_W2F2F3, _W3F2F3, _W1F2F3} ,DF2F3, DF2W2, W1DF3\n\n_note:_ where i wrote xyz{_1, _2, _3,...} this is one type of combination that had too many permutations to fit under one tile, so i split it into several sub cases.\n\n\n#### Our palette\n|colors\\\\Palettes| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |\n|---|---|---|---|---|---|---|---|---|\n| 0 |Water|Water|Water|Water|Water|Water|Water|Water|\n| 1 | F1 | F1 | F2 | F2 | Sand | Sand |_W1r_|_W2r_|\n| 2 | F2 | Sand | F1 | Sand |  F1 | F2 |_F2_|_Sand_|\n| 3 | Sand | F2 | Sand | F1 | F2 | F1 | _Sand_ | _F1 |\n| 4 | F1 | F1 | F2 | F2 | F2 | F1 | F1 | F2 |\n| 5 | W1 | W1 | W2 | W2 | W2b | W1b | W1b | W2b |\n| 6 | W2 | W2b| W1 | W1b | W1 | W2b | W2 | W1b |\n| 7 | D | F1 | F2 | Sand | W1 | W1b | W2 | W2b |\n\n- notice how with the rows 234, col 0-5, we can represent all permutations of (f1, f2, sand), which are all our floors.\n- row 7 is used for all 8 colors\n- row 0 is used exclusively for water\n- rows 4+5 combine floors with their own 2 walls, and row 6 gives walls of the opposite floor color.\n- The end of rows 234 is used for edge cases between walls and floors\n\n### technical limitations\nSince every combination has to be accounted for with the addition of more palettes or more tiles, the amount of different blocks you can implement is very limited.  \nAdditionally, Mapping the right palette for the combination of the tiles is a very arduous process, in some cases, requiring 8 if statements, for every palette outcome.  \nLastly, tile mode on the DS does not allow affine matrix transformations, so the only method to zoom is by doubling the size of each block.\n### conclusion\nFor the above reasons, I would suggest **not** to implement isometric or complex views in Tile mode, but rather use **Rotoscope** after the Triangle Generation step.  \nIt is worth noting however, that this implementation takes up a mere _800B_ for the tiles and _128B_ for the palette, as opposed to the _24KB_ of a rotoscope background.  also, consider that you may need to use two backgrounds in order to hide sprites behind some, effectively doubling the amount of memory*  \n*- in rotoscope, it is possible to \"mask\" a second layer only around sprites, however if there is more than one on screen, there is no choice but to use the whole 24KB\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpklito%2Fds-isometric-tiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpklito%2Fds-isometric-tiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpklito%2Fds-isometric-tiles/lists"}