Aslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=2315.msg26637e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index2df1-2.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=profile;area=showposts;sa=topics;u=262e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index2df1-2.html.zxh^|OKtext/htmlISO-8859-1gzip0||Tue, 10 Mar 2020 22:44:56 GMT0 0Ph^| VRAM updating (FF6 FWF font) **semi-solved**

Author Topic: VRAM updating (FF6 FWF font) **semi-solved**  (Read 422 times)

Madsiur

  • Tunnel Armor
  • *
  • Posts: 149
  • Gender: Male
  • FF6AE coder
    • View Profile
    • Madsiur's Lair
VRAM updating (FF6 FWF font) **semi-solved**
« on: December 08, 2016, 03:23:47 AM »
I'm having a font selector in config menu like this. However it only update the menu partially:



basically I'm doing this when selecting the option:

Code: [Select]
STA !SRAM      ; Set option
JSR $6B13         ; BG3 font GFX
JSR $6B37 ; BG1 font GFX
JSR $389E      ; Draw menu, etc.
JMP DrawFontOpt ; Draw "Default", "GBA" when changing option

$6B13 and $6B37 have been modified to take in account an offset from a table to pull the right font. I check the VRAM with bsnes+ and BG1 and BG3 fonts are only partially updated if not at all in the case of one of the two. Going back to main menu does not change anything. However, entering main menu from a map does show the right font everywhere and VRAM is also correct in this regard. I don't understand because the code go through the same $6B13 and $6B37 functions. I tried numerous thing I won't enumerate but it seems something is done when entering main after loading GFX that I can't replicate here.

Any idea of solution? Thanks!

 :edit: I got a working solution by forcing a V-Blank but would there be a smoother way of doing it without seeing the screen flashing (refreshing)?

Code: [Select]
REDRAW:
LDA #$8F       
STA $2100           ; Force V-Blank
JSR $6B13           ; BG3 font GFX
JSR $6B37           ; BG1 font GFX
JMP DrawFontOpt     ; Draw "Default", "GBA" when changing option
« Last Edit: December 08, 2016, 08:13:28 AM by Madsiur »

Novalia Spirit

  • Pandora's Masking Tape
  • *
  • Posts: 33
  • Gender: Male
    • View Profile
Re: VRAM updating (FF6 FWF font) **semi-solved**
« Reply #1 on: December 08, 2016, 02:07:10 PM »
If I recall correctly, VRAM writes are not allowed outside v-blank and force-blank. The way the game normally handles VRAM transfers beyond the menu initialization phase is to store the source, destination, and block size in $12-$18 or $19-$1F, and then let the DMA transfer occur on its own whenever an NMI is manually triggered at C3/1368. However, this only lets you update two VRAM blocks at once, so you'd need to set up the DMA transfers for both VRAM fonts, trigger an NMI by calling $1368 to handle this right away, and then set up the transfer for the tilemap update (to refresh the settings on screen), which the game would take care of on the next NMI.

A simple workaround would be to trigger a fade-in whenever the font is changed, which is what Pandora's Box does.

Madsiur

  • Tunnel Armor
  • *
  • Posts: 149
  • Gender: Male
  • FF6AE coder
    • View Profile
    • Madsiur's Lair
Re: VRAM updating (FF6 FWF font) **semi-solved**
« Reply #2 on: December 08, 2016, 09:05:48 PM »
A simple workaround would be to trigger a fade-in whenever the font is changed, which is what Pandora's Box does.

Right now the forced V-Blank does a quick black flickering which is ok also but I'll try your DMA solution for the learning aspect and check what it looks like. I spent a few hours asking myself what was wrong with my VRAM writing until I found out of V-Blank and H-Blank incidence. I'll remember from now on!

Novalia Spirit

  • Pandora's Masking Tape
  • *
  • Posts: 33
  • Gender: Male
    • View Profile
Re: VRAM updating (FF6 FWF font) **semi-solved**
« Reply #3 on: December 08, 2016, 11:32:02 PM »
My approach has an issue I completely overlooked until now. The font graphics are stored as 2bpp, which is all BG3 can handle. But they're manually converted to 4bpp for BG1, so you couldn't just upload them using the method I've mentioned, without first storing the converted graphics in a buffer. But if not for that, it would eliminate the blanking issue, as it's pretty much the same approach the game uses for uploading skin graphics after switching to a different wallpaper in the settings.