News: 11 March 2016 - Forum Rules

Author Topic: Tales of Phantasia - VRAM Problem **SOLVED**  (Read 3929 times)

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Tales of Phantasia - VRAM Problem **SOLVED**
« on: August 23, 2014, 06:34:09 pm »
I'm in the pretty close final stages of getting the characters swappable on the main menu.  I've got stats swapping perfectly only to find out the names do not swap.  Turns out since I'm using VWF names, their data is stored at 7E7969 instead of 7E6A92+.  I can set it to update both at once but it causes the screen to flicker heavily.. I've tried other methods like altering the Tilemap itself but that was causing consistent issues where it'd only update once then it wouldn't update properly again afterwards.

Is there anyway to update both areas of the VRAM WITHOUT having the screen flicker?  I swear I had this issue a couple years back originally but I have no clue how I got around it anymore.
« Last Edit: September 11, 2014, 02:47:42 pm by justin3009 »
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

magno

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Traducciones Magno
Re: Tales of Phantasia - VRAM Problem
« Reply #1 on: August 24, 2014, 11:41:20 am »
Is there anyway to update both areas of the VRAM WITHOUT having the screen flicker?  I swear I had this issue a couple years back originally but I have no clue how I got around it anymore.

Which VRAM areas do you want to update? You only talked about RAM addresses, not VRAM.
Do you have any clue of what's causing the flickering? Maybe is there any DMA transfer to VRAM on course after NMI ends?

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Tales of Phantasia - VRAM Problem
« Reply #2 on: August 24, 2014, 01:58:09 pm »
It takes data from 7E5180 (Tilemap) and then updates it at around B000.  But the names are stored at 7300 (E600) for VWF wise.  When it updates the names, it just rewrites the data at 7E7969 and stores it to E600.  I was trying a method to update the tilemap instead and just transfer that into VRAM but SOMETHING would always bug and have it transfer once, I couldn't figure out why it was happening.

I'm sure the way I had it coded was causing the flickering but I'm not absolutely sure how to get around it.  I was having it transfer the original data that DID transfer the names and then used another section of code to update the Tilemap at B000 RIGHT AWAY after the other code.  So it was probably just too much going on at once and interrupting something else that caused the flicker.  I'm just not sure how to get around it.
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5792
    • View Profile
    • Nightcrawler's Translation Corporation
Re: Tales of Phantasia - VRAM Problem
« Reply #3 on: August 25, 2014, 05:52:18 pm »
Flicker in the context that you've described is because you're writing to VRAM that is currently mapped to the screen. You need to either

a.) Write to VRAM not currently mapped to the screen, and then map those tiles after the data is loaded.

b.) You can map the screen area in question to blank tiles, update the VRAM that was previously mapped to the screen with the new data, and then map it back to the new data after the data is transferred.

The other thing that cause flicker, (even  when you're doing it all right) is when you intermittently don't have enough vblank time to do what you're trying to do. Debugging and checking the H/V counters will tell you if that is the case.

I've come across some very difficult situations where the a game in question was consuming all available vblank time leaving me no additional time to do anything extra. That can be a true pain to work around.
TransCorp - Over 20 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Glory of Heracles IV SFC/SNES Translations

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Tales of Phantasia - VRAM Problem
« Reply #4 on: August 25, 2014, 06:25:41 pm »
I MIGHT have to go the 2nd route but first I'd like your view on this since I'm not quite sure I understand it.

Code: [Select]
$C2/6C8A A9 7E       LDA #$7E                A:AC00 X:FFFE Y:000F D:0000 DB:00 S:01F8 HC:0720 VC:225 FC:22 I:00 ;Load bank of transfer
$C2/6C8C 8D 04 43    STA $4304  [$00:4304]   A:AC7E X:FFFE Y:000F D:0000 DB:00 S:01F8 HC:0744 VC:225 FC:22 I:00
$C2/6C8F AE 43 14    LDX $1443  [$00:1443]   A:AC7E X:FFFE Y:000F D:0000 DB:00 S:01F8 HC:0780 VC:225 FC:22 I:00 ;Load pointer of transfer
$C2/6C92 8E 02 43    STX $4302  [$00:4302]   A:AC7E X:7969 Y:000F D:0000 DB:00 S:01F8 HC:0826 VC:225 FC:22 I:00
$C2/6C95 AE 4B 14    LDX $144B  [$00:144B]   A:AC7E X:7969 Y:000F D:0000 DB:00 S:01F8 HC:0868 VC:225 FC:22 I:00 ;Load where to store in VRAM
$C2/6C98 8E 16 21    STX $2116  [$00:2116]   A:AC7E X:7300 Y:000F D:0000 DB:00 S:01F8 HC:0914 VC:225 FC:22 I:00
$C2/6C9B A2 C0 04    LDX #$04C0              A:AC7E X:7300 Y:000F D:0000 DB:00 S:01F8 HC:0956 VC:225 FC:22 I:00 ;How much to transfer
$C2/6C9E 8E 05 43    STX $4305  [$00:4305]   A:AC7E X:04C0 Y:000F D:0000 DB:00 S:01F8 HC:0986 VC:225 FC:22 I:00
$C2/6CA1 A9 01       LDA #$01                A:AC7E X:04C0 Y:000F D:0000 DB:00 S:01F8 HC:1028 VC:225 FC:22 I:00 ;Begin transfer
$C2/6CA3 8D 0B 42    STA $420B  [$00:420B]   A:AC01 X:04C0 Y:000F D:0000 DB:00 S:01F8 HC:1052 VC:225 FC:22 I:00

Was it that there's 255 scanlines on screen?  So I would assume that VC has more than enough time but what is HC?  I haven't used those bits much so I'm confused on how it coincides.
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

magno

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Traducciones Magno
Re: Tales of Phantasia - VRAM Problem
« Reply #5 on: August 26, 2014, 09:08:34 am »
Was it that there's 255 scanlines on screen?  So I would assume that VC has more than enough time but what is HC?  I haven't used those bits much so I'm confused on how it coincides.

Yes, it looks like you have more than enought time to DMA tiles. "HC" is "Horizontal Counter", pretty much the same as the line counter (VC) but for each line. It counts master clocks in each line.

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Tales of Phantasia - VRAM Problem
« Reply #6 on: August 26, 2014, 04:39:28 pm »
Quote from: Nightcrawler
Flicker in the context that you've described is because you're writing to VRAM that is currently mapped to the screen.

Then it's most likely what Nightcrawler said.  I'll probably have to go with method #2 to fix it up.

Thank you both!  I'll edit and pop back later on this week if I'm able to get it to work properly.

Edit: GOT IT!  The reason it was updating the Tilemap only once is because of the VWF name code the routine used from the game originally!  It was because it REWROTE the names again which pretty much reverted the updated Layer 3 Tilemap causing issues.  I wrote a specific check to ONLY do that if 7E:1433 is =/= 08 (08 being the new value for PC swapping).  If it's not 08, update the names with new code.  If IS 08, load the original code to reload the PC names on the menu (Which is needed when you enter other menus and come back).  It's all working now :D  PC swapping is now pretty much done!  All that's left is to accommodate for the X/Y coordinates of the hand on PC's 5/6 with the screen scroll and add in a new byte to disable character swapping if it's activated on a PC or not, then PC swapping is 100% done :)

Thank you again!  It was something so simple but of course always evades me.  Seems the problem gets figured out every time AFTER I ask for help then see it's something ridiculously small.
« Last Edit: August 27, 2014, 09:12:28 am by justin3009 »
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

magno

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Traducciones Magno
Re: Tales of Phantasia - VRAM Problem
« Reply #7 on: August 27, 2014, 12:27:16 pm »
Congratulations, justin3009!! Looking forward to see your work completed!