Mode 72 development

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
Post Reply
rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: Mode 72 development

Post by rocifier » Sat Mar 17, 2018 7:46 am

Do the code tiles support X mirroring?

User avatar
Jubatian
Posts: 1365
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Mode 72 development

Post by Jubatian » Sat Mar 17, 2018 9:08 am

rocifier wrote:
Sat Mar 17, 2018 7:46 am
Do the code tiles support X mirroring?
No, I can't do that, as I said a tile (or more appropriately a tile row) is generated by code, which is sequential (pixels are output by a stream of code). That's not something which could be reversed. Obviously, you can have Y mirrored variants of tiles "for free" (since it is just a rearrangement of the tile rows).

I would suggest you to experiment with the generator, to see how your tileset translates, how large the resulting code will be (once you compile the generated assembly file).

rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: Mode 72 development

Post by rocifier » Sat Mar 17, 2018 10:57 am

Alright, that makes sense about the Y mirroring instead of X. Maybe I can design my game so that it plays horizontally instead and take advantage of that. How can I get started using the generator? Are there instructions anywhere?

User avatar
Jubatian
Posts: 1365
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Mode 72 development

Post by Jubatian » Sat Mar 17, 2018 2:16 pm

rocifier wrote:
Sat Mar 17, 2018 10:57 am
Alright, that makes sense about the Y mirroring instead of X. Maybe I can design my game so that it plays horizontally instead and take advantage of that. How can I get started using the generator? Are there instructions anywhere?
The generator is in the Mode 72 directory of the kernel. It has a short description on the top (below the GPL notice). You need Gimp, lay out your tileset as described there (as a 8 pixel tall image containing your tiles sequentially), convert it to indexed color if necessary (at most 16 colors, color 0 is background, color 15 is border), and save it as a header file (tileset.h), which you can copy alongside the generator. Then compile the generator, and run it, redirecting its output into an assembly file ("./a.out > tileset.s" in a Bash shell if you compiled as "gcc tilegen.c"). Not exactly user-friendly, but its a developer tool. You can then include the assembly file in your build, you can use the Mode 72 example there to start off.

rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: Mode 72 development

Post by rocifier » Sun Mar 18, 2018 8:21 am

Hi Jubation, seemed simple enough to generate the tileset assembly file. But I'm having difficulty compiling it in. I replaced tileset.s in the examples/videoMode72 directory, and tileset.h in the examples/videoMode72/assets directory. I get over 7000 lines of errors in the tileset.s file, most of which are null characters being ignored, but become more random and serious. Do you think it might be some kind of line ending compatibility with windows? I've attached my two files for you to try if you have time. Thanks for any help!
Attachments
tileset.s.txt
rename to .s
(167.83 KiB) Downloaded 97 times
tileset.h
put in /assets/
(105.53 KiB) Downloaded 96 times

User avatar
Jubatian
Posts: 1365
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Mode 72 development

Post by Jubatian » Sun Mar 18, 2018 9:17 am

rocifier wrote:
Sun Mar 18, 2018 8:21 am
Hi Jubation, seemed simple enough to generate the tileset assembly file. But I'm having difficulty compiling it in. I replaced tileset.s in the examples/videoMode72 directory, and tileset.h in the examples/videoMode72/assets directory. I get over 7000 lines of errors in the tileset.s file, most of which are null characters being ignored, but become more random and serious. Do you think it might be some kind of line ending compatibility with windows? I've attached my two files for you to try if you have time. Thanks for any help!
I dunno what your system did to it, but the file seems to be UTF-16, a quite unusual format which the compiler likely can not recognize. You can convert it to ASCII or UTF-8 with Notepad++ or possibly something else (I just mentioned Notepad++ since I know it has such a conversion feature). The file otherwise seems to be all right, you likely generated it proper, but somehow the output became UTF-16 which for me is very odd.

rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: Mode 72 development

Post by rocifier » Sun Mar 18, 2018 9:41 am

Jubatian wrote:
Sun Mar 18, 2018 9:17 am
rocifier wrote:
Sun Mar 18, 2018 8:21 am
Hi Jubation, seemed simple enough to generate the tileset assembly file. But I'm having difficulty compiling it in. I replaced tileset.s in the examples/videoMode72 directory, and tileset.h in the examples/videoMode72/assets directory. I get over 7000 lines of errors in the tileset.s file, most of which are null characters being ignored, but become more random and serious. Do you think it might be some kind of line ending compatibility with windows? I've attached my two files for you to try if you have time. Thanks for any help!
I dunno what your system did to it, but the file seems to be UTF-16, a quite unusual format which the compiler likely can not recognize. You can convert it to ASCII or UTF-8 with Notepad++ or possibly something else (I just mentioned Notepad++ since I know it has such a conversion feature). The file otherwise seems to be all right, you likely generated it proper, but somehow the output became UTF-16 which for me is very odd.
Wow that's weird, you're right. I changed the file and it seems much better now. Thanks for that! Hopefully this kind of stuff will help others venturing through this in windows. Just a handful of more legitimate errors which I don't understand. They all look like this... any ideas?

Code: Select all

_obj_/tileset.o: In function `tilerow_block_32':
tileset.s:1188: relocation truncated to fit: R_AVR_13_PCREL against `no symbol'

_obj_/tileset.o: In function `tilerow_block_34':
tileset.s:1201: relocation truncated to fit: R_AVR_13_PCREL against `no symbol'

User avatar
Jubatian
Posts: 1365
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Mode 72 development

Post by Jubatian » Sun Mar 18, 2018 10:51 am

rocifier wrote:
Sun Mar 18, 2018 9:41 am
(...) Just a handful of more legitimate errors which I don't understand. They all look like this... any ideas?
They were bugs in the generator which I fixed now (check out the Mode72 branch to have the fixes). Your tileset is currently smaller than that of the example, so the generator tries to use a different code generation method for it to pack it tighter. This had a few bugs.

By the way where the graphics came from? (I mean that of the game which you posted in the Tower Defense topic)

Just a note: If you compile the example with your tileset, the sprites may disappear. This is a deficiancy of the example: Sprites sourced from the Flash need to be in the 0x8000 - 0xEFFF range, and your tileset is too small to push them beyond 0x8000, so they become RAM sourced sprites.

rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: Mode 72 development

Post by rocifier » Sun Mar 18, 2018 9:19 pm

Oh nice work! I am pixelling all the graphics for the tower defense game. I gave it a good shot to convert it into a horizontal version but I just couldn't get it right. So I'm going to try and hack at the vertical version for now knowing I am sacrificing optimisation. A Y mirrored mock up is really difficult without making the perspective completely flat. But then you lose a lot of the charm that the vertical mockup has. I may need to end up doing a flat version if I want multiple levels though (which I do XD).

rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: Mode 72 development

Post by rocifier » Tue Mar 20, 2018 2:42 am

Jubatian, how does the m72_rowoff variable work in the sample code? The maths for it is relatively complex, but the main thing I don't understand is why it reads the values inside main_vram:

Code: Select all

m72_rowoff[i] = (u16)(&main_vram[((u16)(i) * 32U) + (j >> 3)]) + ((u16)(j & 7U) << 12);
EDIT: Also another question if you don't mind :) how can I build a mode72 example without the top and bottom text panels? I don't wish to use those in my game at this time. But it looks like there is a whole .s file dedicated to rendering them which I'd rather not include. Too difficult? Just set a null pointer to the text tables?

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests