Jump to content

Johan Kårlin

Members
  • Posts

    109
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Johan Kårlin

  1. Version 1.0.0

    13 downloads

    This is a console application for Windows that will convert png images to a format that the video controller (VERA) of the Commander X16 can read. Both indexed images (which contain a palette) and full-color images are supported. The original file can contain an image or a number of tiles or sprites. For conversion of images, the width of the image must be 320 or 640 pixels. Height has no restrictrions. For conversion to tiles or sprites, the width and height of each tile/sprite must be specified. COLORS Bits per pixel (BPP) in the generated file will depend on how many colors the conversion results in. The number of colors might be reduced because the color depth of VERA is limited to 12 bits. In other words several 32-bit colors in the original image might converted to the same 12-bit color. Semitransparent colors (0 < alpha < 255) will be treated as solid colors. For conversions of images with 16 colors or less, up to 13 colors will be displayed in the console window. Due to limitations of the console itself this is the maximum number that can be displayed correctly. TRANSPARENCY The first color of the palette might be transparent when rendered by VERA. This is for example the case when a sprite is rendered in front of a layer. Therefore it can be absolutely crucial which color in the original image that will receive index 0 in the generated palette. The selection is made in the following way: 1. If the original image is indexed (has a palette), the color with index 0 in the original will also receive index 0 in the converted image. 2. If the user has explicitly stated which color should be the first, this color will receive index 0. 3. If nothing above applies, the color of the top left pixel will receive index 0. OUTPUT At least two files will be generated: a binary file with image data and the palette in binary format or in the format of assembly source code or BASIC. As an extra bonus a BASIC program that displays the image/tiles/sprites can be generated. INSTALLATION The application is for Windows and depends on .NET 6.0. No installation is needed, there is just one executable file. SYNTAX X16PngConverter [-help] [FILENAME] {-image|-tiles|-sprites} [-height] [-width] [-palette] [-transparent] [-demo]. OPTIONS (No arguments) : Displays this text. -help/-h : Same as above if it is the first argument. FILENAME : If the name of the file is the only argument, the original image will be analyzed to see if conversion is possible and in that case which options that are possible. -image|-tiles|-sprites : Set conversion mode (mandatory). When image mode is used the original image must be either 320 or 640 pixels wide. -height/-h : Set height of tiles or sprites (not used when converting to a bitmap image). Valid values for tile mode are 8 and 16, for sprites 8, 16, 32 and 64. -width/-w : Set width of tiles or sprites, (not used when converting to a bitmap image). Valid values are the same as for height. -palette/-p : Set file format for the destination file that contains the palette. Valid values are: bin - a binary file asm - text file containing assembly source code) bas - text file containing BASIC DATA statements). If this option is omitted, all three files will be created. -transparent/-t : Set which color that will have index 0 in the generated palette. The value must be a 32-bit hexadecimal value in the following format: $aarrggbb where a = alpha, r = red, g = green and b = blue. -demo/-d : Generate a demo program in BASIC. This can be loaded to the emulator by using the -bas option. For example: x16emu -bas mysprites_demo.txt. To run it immediately add the option -run. Using this option will cause a binary palette file to be created. EXAMPLES X16PngConverter : Display help text. X16PngConverter image.png : Analyse image and see if it is possible to convert. X16PngConverter image.png -image : Convert to a bitmap image (width must be 320 or 640 pixels). X16PngConverter image.png -tiles -h 16 -w 16 : Convert to tiles with a widht and height of 16 pixels. X16PngConverter image.png -image -p asm : Convert to sprites and output palette only as a file with assembly source code. X16PngConverter image.png -image -t $ff88aacc : Convert image with the specified (potentially transparent) color as the first in the generated palette. X16PngConverter image.png -image -demo : Convert image and generate a BASIC demo program named image_demo.txt.
  2. X16PngConverter - convert png images to sprites, tiles or bitmap images View File This is a console application for Windows that will convert png images to a format that the video controller (VERA) of the Commander X16 can read. Both indexed images (which contain a palette) and full-color images are supported. The original file can contain an image or a number of tiles or sprites. For conversion of images, the width of the image must be 320 or 640 pixels. Height has no restrictrions. For conversion to tiles or sprites, the width and height of each tile/sprite must be specified. COLORS Bits per pixel (BPP) in the generated file will depend on how many colors the conversion results in. The number of colors might be reduced because the color depth of VERA is limited to 12 bits. In other words several 32-bit colors in the original image might converted to the same 12-bit color. Semitransparent colors (0 < alpha < 255) will be treated as solid colors. For conversions of images with 16 colors or less, up to 13 colors will be displayed in the console window. Due to limitations of the console itself this is the maximum number that can be displayed correctly. TRANSPARENCY The first color of the palette might be transparent when rendered by VERA. This is for example the case when a sprite is rendered in front of a layer. Therefore it can be absolutely crucial which color in the original image that will receive index 0 in the generated palette. The selection is made in the following way: 1. If the original image is indexed (has a palette), the color with index 0 in the original will also receive index 0 in the converted image. 2. If the user has explicitly stated which color should be the first, this color will receive index 0. 3. If nothing above applies, the color of the top left pixel will receive index 0. OUTPUT At least two files will be generated: a binary file with image data and the palette in binary format or in the format of assembly source code or BASIC. As an extra bonus a BASIC program that displays the image/tiles/sprites can be generated. INSTALLATION The application is for Windows and depends on .NET 6.0. No installation is needed, there is just one executable file. SYNTAX X16PngConverter [-help] [FILENAME] {-image|-tiles|-sprites} [-height] [-width] [-palette] [-transparent] [-demo]. OPTIONS (No arguments) : Displays this text. -help/-h : Same as above if it is the first argument. FILENAME : If the name of the file is the only argument, the original image will be analyzed to see if conversion is possible and in that case which options that are possible. -image|-tiles|-sprites : Set conversion mode (mandatory). When image mode is used the original image must be either 320 or 640 pixels wide. -height/-h : Set height of tiles or sprites (not used when converting to a bitmap image). Valid values for tile mode are 8 and 16, for sprites 8, 16, 32 and 64. -width/-w : Set width of tiles or sprites, (not used when converting to a bitmap image). Valid values are the same as for height. -palette/-p : Set file format for the destination file that contains the palette. Valid values are: bin - a binary file asm - text file containing assembly source code) bas - text file containing BASIC DATA statements). If this option is omitted, all three files will be created. -transparent/-t : Set which color that will have index 0 in the generated palette. The value must be a 32-bit hexadecimal value in the following format: $aarrggbb where a = alpha, r = red, g = green and b = blue. -demo/-d : Generate a demo program in BASIC. This can be loaded to the emulator by using the -bas option. For example: x16emu -bas mysprites_demo.txt. To run it immediately add the option -run. Using this option will cause a binary palette file to be created. EXAMPLES X16PngConverter : Display help text. X16PngConverter image.png : Analyse image and see if it is possible to convert. X16PngConverter image.png -image : Convert to a bitmap image (width must be 320 or 640 pixels). X16PngConverter image.png -tiles -h 16 -w 16 : Convert to tiles with a widht and height of 16 pixels. X16PngConverter image.png -image -p asm : Convert to sprites and output palette only as a file with assembly source code. X16PngConverter image.png -image -t $ff88aacc : Convert image with the specified (potentially transparent) color as the first in the generated palette. X16PngConverter image.png -image -demo : Convert image and generate a BASIC demo program named image_demo.txt. Submitter Johan Kårlin Submitted 12/01/21 Category Dev Tools  
  3. Version 1.0.0

    10 downloads

    Writing BASIC programs longer than 10 rows on the X16 is a tedious experience. The text editor is very limited, much is about struggling with row numbers. This is an extremely simple compiler (sort of at least) for Windows that lets you write your BASIC programs in your favourite text editor with labels. The compiler outputs a new text file with the extension ".bas". It adds row numbers and fills in the right row number after the commands "GOTO", "GOSUB" and "THEN". No installation is needed, just copy the only file to the directory of your choice. Usage: x16LabelCompiler <filename> [first row number] [step between row numbers] Labels must end with a colon (":"). Labels must not be reserved keywords in BASIC. Labels are preserved in the generated code by inserting "REM" before them. Empty rows are removed. All letters are converted to uppercase. A sample program called "guess_the_number.txt" is included. To compile the program: x16LabelCompiler guess_the_number.txt To start the emulator, load the generated file and run it immediately: x16emu -bas guess_the_number.bas -run
  4. Basic Label Compiler for Windows View File Writing BASIC programs longer than 10 rows on the X16 is a tedious experience. The text editor is very limited, much is about struggling with row numbers. This is an extremely simple compiler (sort of at least) for Windows that lets you write your BASIC programs in your favourite text editor with labels. The compiler adds row numbers and fills in the right row number after the commands "GOTO", "GOSUB" and "THEN". No installation is needed, just copy the only file to the directory of your choice. Usage: x16LabelCompiler <filename> [first row number] [step between row numbers] Labels must end with a colon (":"). Labels must not be reserved keywords in BASIC. Labels are preserved in the generated code by inserting "REM" before them. Empty rows are removed. All letters are converted to uppercase. A sample program called "guess_the_number.txt" is included. To compile the program: x16LabelCompiler guess_the_number.txt To start the emulator, load the generated file and run it immediately: x16emu -bas guess_the_number.bas -run Submitter Johan Kårlin Submitted 11/08/21 Category Dev Tools  
  5. I just found this thread when thinking about the exact question that started it almost a year ago. The FAQ still says that the YM2151 may not make it to the final product, but it is still there on he latest revision of the motherboard. I understand this as it is very unlikely that it will be removed. Or am I jumping to conclusions?
  6. Nice job! I am looking forward to see what will become of this!
  7. Easily done to miss things : ). Of course the other way is to just place the sprite outside screen boundaries, for example by setting the vertical position to 512. If you constantly calculate sprite positions it might feel more natural to only work with the position registers and never change the Z-depth, at least that is what I have found.
  8. You can actually disable sprites individually by setting the Z- depth to 0.
  9. I have found PyxelEdit very useful. You can draw you tiles and simultaneously arrange them in tilemaps to see how they work together. It have some bugs though. Tiled is the best program I know for drawing tilemaps. I have made an extension that exports the maps in the binary format that the X16 uses. I have made a small tool for converting tilemaps made with PyxelEdit as well but that is a separate program because PyxelEdit does not support extensions. You can find them under “Development Tools” in the download section.
  10. I have implemented this, but updating single columns and rows got unnecessary complicated. I ended up with a double buffered 32x32 tilemap (tiles 16x16). I scrolled 15 pixels and then updated the complete visible part of the tilemap. That made be spend about half of the available CPU cycles including all other code that was running each frame. A processor speed of 8 MHz makes a great difference compared to 1 MHz : ).
  11. I am happy to see an X16 version after all. It’s encouraging for all of us who are trying to develop programs for this platform as well. [emoji4]
  12. Oh, I just confused things, sorry.
  13. I do exactly this in my new game project where I use 64 Kb tilemaps. Just change the tilebase address for layer 0 in RAM address $9f2f and copy the character set to the new location.
  14. Really great that you are interested in contributing with some hardware expansions! Welcome!
  15. I remember starting out with VERA a long, long time ago (= more than a year). I tried to figure out what concepts like tiles and layers even meant. In those days there were no tutorials by Dusan, very few programs with source code to study, but luckily I had great help of Stephen’s legendary, unofficial documentation. This is the true story of how the West was won, or maybe not, but definitely a story of how a new interest in assembly programming was found. [emoji4]
  16. Whether sprite positions are signed or unsigned numbers is a matter of preference as I see it. A binary number does not know if it is negative or not, the interpretation is up to you. The problem with seeing it as a signed number is as you point out that after position 511 comes -512 but your sprite is still visible in the right part of the screen if your resolution is 640x480 which can be confusing. The advantage is that you can push the sprite over the top and left border by just setting the position to -1 which is more intuitive than setting it to 1023. When making scrolling games you constantly calculate sprite positions. I use 16 bits arithmetics. It works fine because the 6 most significant bits are just ignored by VERA. For example -1 = 65535 = %1111 1111 1111 1111 but it is also -1 if you just look at the 10 least significant bits. In the end I check if the calculated position is between -256 and 512 (requires only checking of the upper byte), if not I disable it. This is to avoid the risk of having sprites disappering to the right and suddenly turn up on the left and vice versa.
  17. There is actually nothing to wait for : ). Sprites can absolutely be displayed partially on the top or left edge of the screen. Positions are represented by 10 bits (= 0 - 1023) and wrap around which means that 1024 is the same as 0. Let's say you have a sprite that is 32 pixels wide. If you set the horizontal position to 1024 - 16 = 1008, the right half of it will be visible.
  18. Interesting, not least to see your VERA macros! But it still feels a bit awkward. I can end up having a numbers of flags for macros with several variables.
  19. It works but you must make sure all filenames are in capital letters. The file suffixes must also be whitelisted by the server. [mention]desertfish [/mention] ran into that problem when he tried to load image files with the suffix “KOA”. When he changed to “BIN” it worked.
  20. @lamb-duh That is an interesting solution. RPN brings memories to life, in high school, the coolest of my classmates had Texas Instrument calculators using this. I have to dive deeper into this. Interesting that you mention passing of parameters too. I have tested once to use inline parameters for and then use the ordinary stack to access them from the subroutine. Clever but adds extra code. But if you use your own stack, of course this is suddenly a lot easier. @paulscottrobson Well, right or wrong processor, I don't know. The only real experience of assembly language I have before this is from the Amiga and I can admit that I sometimes miss the 68000. I guess the discussion of how limited a retrocomputer should be will continue forever : ).
  21. I am still changing a color. I read somewhere that C64 game developers often just did inc $D020 to change the border color in the beginning and in the end of the interrupt handler. Very easy and useful. On the X16 it’s an easy solution too. Most of the times you don’t need an exact value, you just want to make sure that you have a lot more cycles to spend. [emoji846] But still it’s surely interesting that there is a counter at $9fb8, I had no idea.
  22. I just pasted it from VS Code. It looks great on my laptop but on Tapatalk linebreaks are missing. I don't know what the best way of sharing code snippets is?
  23. This is not the simplest byt quite useful. It is from my own library of text routines. _row, _col and _color are global variables that must be set. Text layer must start at $00000 which is the default. The string(s) to print must be in screen code not ascii/petscii. !macro Inc16 .addr { inc .addr bne + inc .addr+1 + } VPrintString: ;IN: ZP0, ZP1 = address of string terminated with 0. OUT: ZP0, ZP1 = address of string termination + 1 (to make printing of a string array easier) lda _col asl sta VERA_ADDR_L lda _row sta VERA_ADDR_M lda #$10 sta VERA_ADDR_H ldy _color - lda (ZP0) beq + sta VERA_DATA0 sty VERA_DATA0 +Inc16 ZP0 bra - + inc _row ;increase row and +Inc16 ZP0 ;increase pointer possibly to a string that follows directly after rts
  24. Thanks for the tip! I bought one too that I found on German Ebay. It was not the easiest to understand the German I can say but ”bieten” obviously meant what I was hoping for : ).
×
×
  • Create New...

Important Information

Please review our Terms of Use