Welcome to the Shining Force Central Forums!
SFC Forums Index Shining Forums Shining Force II
Register for your free forum account now or Login to remove this advert.

Was working on a minor compilation hack

and ran into a snag...

Discussion about this classic Genesis/Mega Drive game.

Was working on a minor compilation hack

Postby Stordarth » Tue Oct 15 2019 6:31pm

So for the first time in years, I dusted off the caravan and SF2 Edit to work on a small-scale bug fix/QoL hack, compiling various fix patches, minor graphical adjustments, dialogue fixes etc. So far everything was running smoothly, until I went to see Evil Spirit.

When I watched the scene, and it came time for Zeon to take over Evil Spirit, he just... disappeared. No sprite. Thinking I'd broken it with my graphics changes, I followed it all the way back, and found that in fact, none of my changes were the culprit. The very act of making a 4MB rom with the caravan breaks something with the large sprites. I know BNC never finished the large sprite stuff, and they can't be edited, so I wonder if that has something to do with it.

I'm posting this wondering if this was a commonly known issue, or if this is the first time it's been picked up. It wouldn't have shown up in the various SURVIVOR based hacks due to the story bypass, but there are plenty of 4MB rom hacks that don't skip the story/exploration. Also hoping that maybe Wiz might know some stuff about the large sprites.

I mean, literally any hack the caravan has touched has this issue. Yeah, it's extremely minor. But when you're trying to make a bug fix hack, having a new bug introduced just feels counter to my aim, you know?

Code: Select all
Dice Codes
Attack/Marked Target: /roll 8d100
Damage Variance (Rebels): /roll d18 [Blake with Blade], /roll d26 [Other cases.]
Damage Variance (Emissaries): /roll d16 [Zuberi with Blade], /roll d21 [Rain with Katana, Thrald with Blade], /roll d26 [Other cases.]
Magic: /roll d26
Status Effects: /roll d100
Level-Ups (No/Fixed MP): /roll 4d11
Level-Ups (Has MP): /roll 5d11

---
SFCW-A: Durandar, Sedor Silverwing
Sunken Castle: Fintan Kahn

Code: Select all
Dice Codes
Attack/Marked Target: /roll 8d100
Damage Variance (Rebels): /roll d18 [Blake with Blade], /roll d26 [Other cases.]
Damage Variance (Emissaries): /roll d16 [Zuberi with Blade], /roll d21 [Rain with Katana, Thrald with Blade], /roll d26 [Other cases.]
Magic: /roll d26
Status Effects: /roll d100
Level-Ups (No/Fixed MP): /roll 4d11
Level-Ups (Has MP): /roll 5d11

---
SFCW-A: Durandar, Sedor Silverwing
Sunken Castle: Fintan Kahn
Stordarth

User avatar
The L-Block Anomaly
Administrator
 
Posts: 17750
Joined: Thu Sep 16 2004 3:30pm
Location: The Midlands, Staffordshire, England

Re: Was working on a minor compilation hack

Postby Wiz » Wed Oct 16 2019 7:01pm

Hey Stor,

I was not aware of this regression, so I just gave it a look and ... I couldn't find any proper explanation. :(

Here are my observations if anybody wants to contribute to this research :
- In the Caravan-expanded ROM, the moved Zeon special sprite data is absolutely identical to the original ROM's content
- Both pointers from the Special Sprite pointer table to the Zeon entry are correct
- During this Evil Spirit cutscene, Zeon's sprite doesn't appear in the VDP RAM, so something wrong happens before it's properly loaded, but not necessarily when loading it.
- It seems to have an impact on the game's timing on a frame level, as playing a recorded Tool-Assisted Speedrun crashes precisely at this moment, controller input data getting out of synch with what happens in-game.
- And still, no other Special Sprite seems to have any problem : Kraken, Taros, Evil Spirit are totally fine while using the same Special Sprite loading routines ...

To my knowledge this is not the only regression, as I noticed that the intro cutscene doesn't display the castle's map properly.

Could these cutscenes have something in common ? :shifty:
Don't they both use palette alterations ?
Darker colors for the intro night, and sepia-like colors for the Evil Spirit ...
Maybe it's the same thing being responsible for both bugs, but maybe not, I don't want to set a wrong track here.

(wrong track indeed)

Having said that ... :shifty: SF2DISASM ROM builds don't generate such issues, so that's a possible workaround solution. You're welcome to ask for support in the sf2hack Discord. ;)

Side note :
However, I just noticed that TAS-records didn't play properly in most recent SF2DISASM 4MB builds ...
Nothing game-breaking for a normal game, and no visual difference either, but something subtly different enough to generate different RNG and/or different frame-level timing, which immediately breaks a recorded TAS.
I'll have to investigate that to make sure vanilla 4MB builds still provide a frame-perfect, exact same game experience as the original 2MB ROM.


... HAH ! Found it !
Ok, here's the explanation eventually :
The cutscene calls specific subroutines to make the Evil Spirit sprite alternate between the base graphics and the ones where it seems to have something like radio-spiritual interference :shifty: :
Code: Select all
                nextSingleText $0,130   ; "Hi...s...pow...er...{W1}"
                executeSubroutine sub_5BFDA
                csWait 10
                executeSubroutine csub_5BFD0
                csWait 10
                executeSubroutine sub_5BFDA
                flashScreenWhite $28
                executeSubroutine sub_5BFE4
                setActscript ALLY_IAN,eas_Jump
                setActscript ALLY_RUBURAN,eas_Jump
                setActscript FOLLOWER_B,eas_Jump
                setActscript 128,eas_Jump
                setActscriptWait 129,eas_Jump
                setActscript ALLY_IAN,eas_Jump
                setActscript ALLY_RUBURAN,eas_Jump
                setActscript FOLLOWER_B,eas_Jump
                setActscript 128,eas_Jump
                setActscriptWait 129,eas_Jump
                nextSingleText $0,131   ; "I'm Zeon!  I'm the King of{N}the Devils!{W1}"


The 3 different subroutines actually call ONE common subroutine which manages which sprite to display, and here's the code :
Code: Select all
ROM:00025CB6 ; =============== S U B R O U T I N E =======================================
ROM:00025CB6
ROM:00025CB6
ROM:00025CB6 sub_25CB6:                              ; CODE XREF: sub_20058j
ROM:00025CB6                 movem.l d0-d2/a0-a1,-(sp)
ROM:00025CBA                 lea     (SpecialSprites_EvilSpirit+$20),a0
ROM:00025CBE                 tst.w   d0
ROM:00025CC0                 beq.s   loc_25CD2
ROM:00025CC2                 cmpi.b  #1,d0
ROM:00025CC6                 bne.s   loc_25CCE
ROM:00025CC8                 lea     SpecialSprites_EvilSpiritAlt,a0
ROM:00025CCC                 bra.s   loc_25CD2
ROM:00025CCE ; ---------------------------------------------------------------------------
ROM:00025CCE
ROM:00025CCE loc_25CCE:                              ; CODE XREF: sub_25CB6+10j
ROM:00025CCE                 lea     (SpecialSprites_Zeon+$20),a0
ROM:00025CD2
ROM:00025CD2 loc_25CD2:                              ; CODE XREF: sub_25CB6+Aj
ROM:00025CD2                                         ; sub_25CB6+16j
ROM:00025CD2                 lea     (FF6802_LOADING_SPACE).l,a1
ROM:00025CD8                 move.l  a1,-(sp)
ROM:00025CDA                 jsr     (LoadCompressedData).w
ROM:00025CDE                 movea.l (sp)+,a0
ROM:00025CE0                 lea     ($AF00).l,a1
ROM:00025CE6                 move.w  #$480,d0
ROM:00025CEA                 moveq   #2,d1
ROM:00025CEC                 jsr     (ApplyVIntVramDMA).w
ROM:00025CF0                 jsr     (EnableDMAQueueProcessing).w
ROM:00025CF4                 movem.l (sp)+,d0-d2/a0-a1
ROM:00025CF8                 rts
ROM:00025CF8 ; End of function sub_25CB6


See those references to Special Sprite graphics ?
They should be updated to point to the expanded ROM's new Special Sprite locations.
However this is not as easy as updating a few pointer bytes here : those "lea" instructions only use 2 bytes for a relative offset, so the pointed data has to be less that 65kB near the current location, which isn't the case anymore.
SF2DISASM's solution is to change those instructions with 4-byte addressing instructions there, but it naturally shifts everything forward, so it's not a solution here.
A good ASM hacker could fix it by making this function branch to another place with more free space to use proper addressing, and this may be enough to fix the issue.

So there could be a non-SF2DISASM solution after all.

Well. You're still welcome at the sf2hack Discord when you feel ready to avoid messy hacks like that. :p
Wiz

User avatar
Shining Member
Shining Member
 
Posts: 169
Joined: Sun Mar 18 2007 2:43pm
Location: Blois, France


Re: Was working on a minor compilation hack

Postby Stordarth » Thu Oct 17 2019 2:27pm

I figured the spirit radio interference was part of it. The first flicker is when it vanished, and the original Evil Spirit sprite didn't come back.

I'll try and pop on at some point. If we can make an ips patch to fix the 4mb roms already produced, that'd be something. Would the disasm version still load and save properly in the Caravan with these minor differences?

Thanks for investigating this. I was never so hot with the disassembly stuff

Code: Select all
Dice Codes
Attack/Marked Target: /roll 8d100
Damage Variance (Rebels): /roll d18 [Blake with Blade], /roll d26 [Other cases.]
Damage Variance (Emissaries): /roll d16 [Zuberi with Blade], /roll d21 [Rain with Katana, Thrald with Blade], /roll d26 [Other cases.]
Magic: /roll d26
Status Effects: /roll d100
Level-Ups (No/Fixed MP): /roll 4d11
Level-Ups (Has MP): /roll 5d11

---
SFCW-A: Durandar, Sedor Silverwing
Sunken Castle: Fintan Kahn

Code: Select all
Dice Codes
Attack/Marked Target: /roll 8d100
Damage Variance (Rebels): /roll d18 [Blake with Blade], /roll d26 [Other cases.]
Damage Variance (Emissaries): /roll d16 [Zuberi with Blade], /roll d21 [Rain with Katana, Thrald with Blade], /roll d26 [Other cases.]
Magic: /roll d26
Status Effects: /roll d100
Level-Ups (No/Fixed MP): /roll 4d11
Level-Ups (Has MP): /roll 5d11

---
SFCW-A: Durandar, Sedor Silverwing
Sunken Castle: Fintan Kahn
Stordarth

User avatar
The L-Block Anomaly
Administrator
 
Posts: 17750
Joined: Thu Sep 16 2004 3:30pm
Location: The Midlands, Staffordshire, England


Return to Shining Force II

Who is online

Users viewing this topic: No registered users and 1 guest