A couple of little notes, one cautious and one helpful, about screen_set_charset...:
You're going to want to only use ISO charsets (1 and 6) when in ISO mode, and only use PETSCII charsets (2 through 5) in PETSCII mode. Otherwise, the screen-code-to-character translation matrix that's used when displaying text to the screen gets... out of sync. The helpful thing is that if you're in PETSCII mode and set the charset to thin PETSCII, and switch to ISO mode, you'll get thin ISO. And vice versa.
I haven't tested the shifted/unshifted settings in PETSCII mode yet. Maybe CHR$(14) and CHR$(142) work differently if you set the wrong version of the charset.
Text mode after tilemaps?
Re: Text mode after tilemaps?
I was actually already doing this. I had $FF81 #defined as IOINIT, but can't remember where I found it.Calling CINT ($FF81) will completely reset the VERA back to a Kernal-friendly text mode, including initializing VRAM and uploading the character set. This is probably the most forward-compatible thing to do.
Edit:
I've never been very good at understanding a system from its documentation. It's always been easier for me to learn by example. The problem with the X16 is that almost no one uses C so there's not a lot of examples to look at.
Sometimes I'll end up trying to understand a feature from the cc65 implementation.
Last edited by Dacobi on Sun Sep 10, 2023 7:06 am, edited 1 time in total.
-
- Posts: 292
- Joined: Wed Jun 03, 2020 11:33 am
- Location: Kalmar, Sweden
Re: Text mode after tilemaps?
Do you use both layers for rendering graphics for gameplay? Otherwise, this is what I do:Dacobi wrote: ↑Fri Sep 08, 2023 2:33 pm The problem is that my game uses both layers and almost all the VRAM.
I didn't know text mode was just a tilemap.
I guess I could make a 32x32 1 bpp tilemap with only 2 tiles, one with all pixels set and one with all off, and then use them to spell "LOADING". That should be a little over 2KB of VRAM.
I switch to resolution 320x256, this is what my games use.
I keep layer 1 (the text layer) exactly as it is. Then I can print text with the kernal routine BSOUT or in C you can use printf().
If I disable layer 0 I can have a solid background, if layer 1 is enabled I can easily print text like "GAME OVER" above game graphics.
I have my own charset that I have made in CharPad (https://subchristsoftware.itch.io/charpad-c64-pro).
I have both 8x8 characters and 16x16 characters that consist of four 8x8 characters.
I load my charset directly to VRAM by using KERNAL routines.
When the user quits the game, I restore the original charset by simply printing $8E with BSOUT. This triggers the upload of the original charset from ROM to VRAM.
If you use both layers for game graphics you can switch layer 1 between text mode and the other mode you are using. After all, you were mainly interested in printing text on a black background (?).
An alternative is to use sprites. I do this in Rally Speedway when displaying huge 64x32 characters. I found this to be the best solution because at the same time, I display game graphics and regular 8x8 text on the screen.
Re: Text mode after tilemaps?
I do use both layers. I have one layer for the track and one for the background. This is both for simplicity but also allows me to reuse backgrounds.If you use both layers for game graphics you can switch layer 1 between text mode and the other mode you are using. After all, you were mainly interested in printing text on a black background (?).
I just uploaded an SD image with something that works quite well,
including an animated progress bar : )
I ended up with a 32x32 1bpp 256 colors tilemap with 6 simple tiles that I use to print "LOADING" in large letters plus the progress bar.
When I start to load a menu screen or a track I first load the palette and then the loading screen. Then while I load the files from SD card to VRAM the VBLANK interrupt updates the progress bar.
After all files have been loaded I disable the progress bar and set DC_VIDEO = 1 and then set up the layers and enable them.