JeremiahK Posted April 22, 2019 Share Posted April 22, 2019 Many times, I will be making graphics tables that need to be pre-shifted, or I will have multiple tables with the same graphics, some upside-down, some not, etc. If you want to make a change, you need to make sure you update all the tables correctly, and it becomes a real pain. I am sure some of you know what I am talking about... Over the holiday, I wrote a Python script that handles this for me. It inputs a single file for the graphics data and formatting options, and then generates each table to a separate file. It is very simple, with very little in terms of error checking, but it supports outputting tables forwards, backwards, inverted, upside-down, completely rearranged, you name it. GitHub: https://github.com/JeremiahK96/gen_gfx In order to use the script, create a file for the graphics table. I have included an example file on GitHub. The first character in the file is the character you want to use in the graphics tables to signify a bit that is set. After this is a number for the height of each block of graphics (sprite). So if the first line of the file is "X14", you would be using the X character in your graphics tables, and each block would be 14 bytes high. The next lines after the first one are for formatting the output files, and you can add as many as you need. Each line is 8 characters to define the layout of every byte within a table, and a '+' or '-' for standard/upside-down tables. Use 's' or 'c' to explicitly set or clear bits in the table. "sssscccc+" would output a table full of $F0 bytes. Use '7' through '0' to use data from D7 to D0 in the main graphics table. "76543210-" would output the graphics as-is in upside-down fashion, while "01234567-" would mirror it, as well. If you want to invert a bit from the graphics table, you can use the "uppercase" versions of 7-0 (%=5 inverted, &=7 inverted, etc). After the formatting options, you just need to add in the graphics data blocks, as such: __XXX___ _XX_XX__ XX___XX_ XX___XX_ XX___XX_ _XX_XX__ __XXX___ __XXX___ _XXXX___ ___XX___ ___XX___ ___XX___ ___XX___ _XXXXXX_ __XXX___ XXXXXXX_ XX___XX_ ___XXX__ __XXX___ _XXX____ XXXXXXX_ Run the script with the graphics file, and a prefix for the output files: python gen_gfx.py example.text table This outputs files as "table0.bin", "table1.bin", "table2.bin", etc. which contain the raw binary data. They can be included into an .asm file with dasm using "incbin table0.bin". Feel free to make any edits, redistribute, whatever you want! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.