News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: What causes this in games?  (Read 5085 times)

justin3009

  • Hero Member
  • *****
  • Posts: 1614
  • Welp
    • View Profile
What causes this in games?
« on: September 09, 2012, 06:42:20 pm »
I'm modding Lufia II right now, but this isn't an issue strictly in this game.  I've seen it in Tales of Phantasia and Chrono Trigger.  I don't recall ever really fixing them, I just worked 'around' them.  But in this case.. I can't work around it, I have to figure out how to fix it.



Essentially, what would cause this behavior with the text?
'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.'

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6893
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: What causes this in games?
« Reply #1 on: September 10, 2012, 12:16:17 am »
Taking a look at the original menu window, I can only guess it's using HDMA to adjust the scroll registers mid-frame so that the original Japanese game could print dakuten lines using only 4 pixel tall tiles instead of using up the tile space for all 8 lines of the tiles (which it doesn't need).

(edit: Taking another look, Estpolis I used full-height dakuten tiles.)

EDIT: Yep, that's what it looks like.
« Last Edit: September 10, 2012, 12:27:54 am by KingMike »
"My watch says 30 chickens" Google, 2018

LostTemplar

  • Hero Member
  • *****
  • Posts: 906
    • View Profile
    • au-ro-ra.net
Re: What causes this in games?
« Reply #2 on: September 10, 2012, 04:33:51 am »
Yeah, a lot of the newer games do that in their menus. You will have to find where the HDMA transfer is initiated and either disable it or change the table it uses to your liking. The DMA logger in Geiger's Snes9x debugger is pretty helpful for doing this; if the table resides in the ROM area you can just change it without touching the code.

justin3009

  • Hero Member
  • *****
  • Posts: 1614
  • Welp
    • View Profile
Re: What causes this in games?
« Reply #3 on: September 10, 2012, 07:28:46 am »
Huh, that's interesting to know.  Didn't realize it still did that.  Good to know more in-depth about and thank you about the DMA logger there.  Totally forgot about that!

Edit: Lol, well, found the table.  The fun part.  The X/Y coordinates of it can be adjusted.. but not the width or anything.  It literally spams across the entire screen ~_~  So if I do go with this menu form I have right now, I have to completely drop the HDMA. (Which isn't too bad but I was hoping to apply it to the text so it'd save a lot more screen room).
« Last Edit: September 10, 2012, 08:11:39 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.'

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: What causes this in games?
« Reply #4 on: September 10, 2012, 07:30:08 am »
I guess I have another example of the kinds of fun people have with hblank effects.

Lenophis

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 959
  • The return of the sombrero!
    • View Profile
    • Slick Productions
Re: What causes this in games?
« Reply #5 on: September 10, 2012, 09:11:05 am »
It literally spams across the entire screen ~_~
DMA and HDMA apply their effects to scanlines, and with the right table settings, it can apply only to the scanlines you wish.

Quote
So if I do go with this menu form I have right now, I have to completely drop the HDMA. (Which isn't too bad but I was hoping to apply it to the text so it'd save a lot more screen room).
Wrong. The HDMA is only going to be tweaking the layer for the text, everything else won't be touched.


https://ff6randomizer.codeplex.com/ - Randomize your FF6 experience!

justin3009

  • Hero Member
  • *****
  • Posts: 1614
  • Welp
    • View Profile
Re: What causes this in games?
« Reply #6 on: September 10, 2012, 09:24:42 am »
I'd have to figure out how to make it apply only to certain scanlines then.  Cause right now, it's covering up the entire screen and once moved, screws up the ENTIRETY of the menu text.  All PC stats are completely.. well demolished and squished as saw in that previous image. 
'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.'

Lenophis

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 959
  • The return of the sombrero!
    • View Profile
    • Slick Productions
Re: What causes this in games?
« Reply #7 on: September 10, 2012, 09:38:08 am »
Here's an example for you, taken from the main menu in Final Fantasy 6.

Code: [Select]
C3/36A3: A902    LDA #$02       (from C3/1AC8, C3/1CA8, C3/1D0B)
C3/36A5: 8D5043  STA $4350      (set transfer method to...?)
C3/36A8: A912    LDA #$12
C3/36AA: 8D5143  STA $4351      (register address becomes $2112)
C3/36AD: A0C236  LDY #$36C2
C3/36B0: 8C5243  STY $4352      (set the address)
C3/36B3: A9C3    LDA #$C3
C3/36B5: 8D5443  STA $4354      (set the bank, C3/36C2)
C3/36B8: A9C3    LDA #$C3
C3/36BA: 8D5743  STA $4357
C3/36BD: A920    LDA #$20
C3/36BF: 0443    TSB $43        (eventually enable channel 5 of HDMA)
C3/36C1: 60      RTS
 
HDMA transfer table for main menu text on layer 3 (item, skills, equip, etc)
C3/36C2: 0F0000  (15 scanlines, 0 pixel shift)
C3/36C5: 0F0300  (15 scanlines, 3 pixel shift)
C3/36C8: 0F0400  (15 scanlines, 4 pixel shift)
C3/36CB: 0F0500  (15 scanlines, 5 pixel shift)
C3/36CE: 0F0600  (15 scanlines, 6 pixel shift)
C3/36D1: 0F0700  (15 scanlines, 7 pixel shift)
C3/36D4: 0F0800  (15 scanlines, 8 pixel shift)
C3/36D7: 0F0900  (15 scanlines, 9 pixel shift)
C3/36DA: 070800  (7 scanlines, 8 pixel shift)
C3/36DD: 080000  (8 scanlines, 0 pixel shift)
C3/36E0: 080000  (8 scanlines, 0 pixel shift)
C3/36E3: 180000  (24 scanlines, 0 pixel shift, 167 scanlines total)
C3/36E6: 00      (end)


https://ff6randomizer.codeplex.com/ - Randomize your FF6 experience!

justin3009

  • Hero Member
  • *****
  • Posts: 1614
  • Welp
    • View Profile
Re: What causes this in games?
« Reply #8 on: September 10, 2012, 07:38:59 pm »
Code: [Select]
$82/8DB0 A0 00 00    LDY #$0000              A:0001 X:FFFE Y:0000 P:envMxdIzC
$82/8DB3 B7 F4       LDA [$F4],y[$8E:E297]   A:0001 X:FFFE Y:0000 P:envMxdIZC - Table for HDMA
$82/8DB5 97 F7       STA [$F7],y[$7E:80C0]   A:0000 X:FFFE Y:0000 P:envMxdIZC - Storage in RAM
$82/8DB7 F0 0D       BEQ $0D    [$8DC6]      A:0000 X:FFFE Y:0000 P:envMxdIZC
$82/8DC6 C2 20       REP #$20                A:0000 X:FFFE Y:0000 P:envMxdIZC
$82/8DC8 A5 F3       LDA $F3    [$00:00F3]   A:0000 X:FFFE Y:0000 P:envmxdIZC
$82/8DCA 29 FF 00    AND #$00FF              A:9740 X:FFFE Y:0000 P:eNvmxdIzC
$82/8DCD A8          TAY                     A:0040 X:FFFE Y:0000 P:envmxdIzC
$82/8DCE 4A          LSR A                   A:0040 X:FFFE Y:0040 P:envmxdIzC
$82/8DCF 4A          LSR A                   A:0020 X:FFFE Y:0040 P:envmxdIzc
$82/8DD0 4A          LSR A                   A:0010 X:FFFE Y:0040 P:envmxdIzc
$82/8DD1 4A          LSR A                   A:0008 X:FFFE Y:0040 P:envmxdIzc
$82/8DD2 AA          TAX                     A:0004 X:FFFE Y:0040 P:envmxdIzc
$82/8DD3 A5 F7       LDA $F7    [$00:00F7]   A:0004 X:0004 Y:0040 P:envmxdIzc
$82/8DD5 99 02 43    STA $4302,y[$80:4342]   A:80C0 X:0004 Y:0040 P:eNvmxdIzc
$82/8DD8 E2 20       SEP #$20                A:80C0 X:0004 Y:0040 P:eNvmxdIzc
$82/8DDA A5 F9       LDA $F9    [$00:00F9]   A:80C0 X:0004 Y:0040 P:eNvMxdIzc
$82/8DDC 99 04 43    STA $4304,y[$80:4344]   A:807E X:0004 Y:0040 P:envMxdIzc
$82/8DDF A5 FA       LDA $FA    [$00:00FA]   A:807E X:0004 Y:0040 P:envMxdIzc
$82/8DE1 99 01 43    STA $4301,y[$80:4341]   A:8012 X:0004 Y:0040 P:envMxdIzc
$82/8DE4 A5 FB       LDA $FB    [$00:00FB]   A:8012 X:0004 Y:0040 P:envMxdIzc
$82/8DE6 99 00 43    STA $4300,y[$80:4340]   A:8002 X:0004 Y:0040 P:envMxdIzc
$82/8DE9 AD 65 15    LDA $1565  [$80:1565]   A:8002 X:0004 Y:0040 P:envMxdIzc
$82/8DEC 29 02       AND #$02                A:8002 X:0004 Y:0040 P:envMxdIzc
$82/8DEE F0 08       BEQ $08    [$8DF8]      A:8002 X:0004 Y:0040 P:envMxdIzc
$82/8DF0 1C 65 15    TRB $1565  [$80:1565]   A:8002 X:0004 Y:0040 P:envMxdIzc
$82/8DF3 A5 F2       LDA $F2    [$00:00F2]   A:8002 X:0004 Y:0040 P:envMxdIzc
$82/8DF5 8D 0C 42    STA $420C  [$80:420C]   A:8010 X:0004 Y:0040 P:envMxdIzc
$82/8DF8 AD 65 15    LDA $1565  [$80:1565]   A:8010 X:0004 Y:0040 P:envMxdIzc
$82/8DFB 29 04       AND #$04                A:8000 X:0004 Y:0040 P:envMxdIZc
$82/8DFD F0 12       BEQ $12    [$8E11]      A:8000 X:0004 Y:0040 P:envMxdIZc
$82/8E11 6B          RTL                     A:8000 X:0004 Y:0040 P:envMxdIZc

I'm not honestly sure what all the rest does.  I'm still rather.. eh to HDMA/VRAM stuff.

Code: [Select]
$82/93F6 C2 20       REP #$20                A:0000 X:34FC Y:D445 P:envMxdIZC
$82/93F8 29 FF 00    AND #$00FF              A:0000 X:34FC Y:D445 P:envmxdIZC
$82/93FB 0A          ASL A                   A:0000 X:34FC Y:D445 P:envmxdIZC
$82/93FC AA          TAX                     A:0000 X:34FC Y:D445 P:envmxdIZc
$82/93FD BF 8A E5 8E LDA $8EE58A,x[$8E:E58A] A:0000 X:0000 Y:D445 P:envmxdIZc - ???
$82/9401 8D 96 05    STA $0596  [$83:0596]   A:FFFE X:0000 Y:D445 P:eNvmxdIzc
$82/9404 BF AC E5 8E LDA $8EE5AC,x[$8E:E5AC] A:FFFE X:0000 Y:D445 P:eNvmxdIzc - Pointer for HDMA
$82/9408 85 F4       STA $F4    [$00:00F4]   A:E297 X:0000 Y:D445 P:eNvmxdIzc
$82/940A E2 20       SEP #$20                A:E297 X:0000 Y:D445 P:eNvmxdIzc
$82/940C A9 8E       LDA #$8E                A:E297 X:0000 Y:D445 P:eNvMxdIzc - Set Bank
$82/940E 85 F6       STA $F6    [$00:00F6]   A:E28E X:0000 Y:D445 P:eNvMxdIzc
$82/9410 A9 10       LDA #$10                A:E28E X:0000 Y:D445 P:eNvMxdIzc
$82/9412 04 F2       TSB $F2    [$00:00F2]   A:E210 X:0000 Y:D445 P:envMxdIzc
$82/9414 A9 40       LDA #$40                A:E210 X:0000 Y:D445 P:envMxdIZc
$82/9416 85 F3       STA $F3    [$00:00F3]   A:E240 X:0000 Y:D445 P:envMxdIzc
$82/9418 A9 12       LDA #$12                A:E240 X:0000 Y:D445 P:envMxdIzc
$82/941A 85 FA       STA $FA    [$00:00FA]   A:E212 X:0000 Y:D445 P:envMxdIzc
$82/941C A9 02       LDA #$02                A:E212 X:0000 Y:D445 P:envMxdIzc
$82/941E 85 FB       STA $FB    [$00:00FB]   A:E202 X:0000 Y:D445 P:envMxdIzc
$82/9420 A2 C0 80    LDX #$80C0              A:E202 X:0000 Y:D445 P:envMxdIzc - RAM location to store HDMA
$82/9423 86 F7       STX $F7    [$00:00F7]   A:E202 X:80C0 Y:D445 P:eNvMxdIzc
$82/9425 A9 7E       LDA #$7E                A:E202 X:80C0 Y:D445 P:eNvMxdIzc
$82/9427 85 F9       STA $F9    [$00:00F9]   A:E27E X:80C0 Y:D445 P:envMxdIzc
$82/9429 A9 03       LDA #$03                A:E27E X:80C0 Y:D445 P:envMxdIzc
$82/942B 8D 65 15    STA $1565  [$83:1565]   A:E203 X:80C0 Y:D445 P:envMxdIzc
$82/942E 60          RTS                     A:E203 X:80C0 Y:D445 P:envMxdIzc

But then the table is this.

Code: [Select]
70 00 00 0C 04 00 0C 08 00 0C 0C 00 0C 10 00 10 60 FF

That literally spams it across the WHOLE bottom of the screen or wherever you put it.  It's not a small area specific thing, so I'm not sure how it works.  I can't seem to figure out how to make it only apply to a certain area.  No matter what kind of data you put, it's literally just crossing the whole screen.
« Last Edit: September 11, 2012, 03:15:33 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.'

Disnesquick

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: What causes this in games?
« Reply #9 on: September 25, 2012, 12:46:55 pm »
Of course it is. HDMA is per scanline, as KingMike has said.

Firstly you've missed some code
Code: [Select]
$82/8DB0 A0 00 00    LDY #$0000              A:0001 X:FFFE Y:0000 P:envMxdIzC
$82/8DB3 B7 F4       LDA [$F4],y[$8E:E297]   A:0001 X:FFFE Y:0000 P:envMxdIZC - Table for HDMA
$82/8DB5 97 F7       STA [$F7],y[$7E:80C0]   A:0000 X:FFFE Y:0000 P:envMxdIZC - Storage in RAM
$82/8DB7 F0 0D       BEQ $0D    [$8DC6]      A:0000 X:FFFE Y:0000 P:envMxdIZC

MISSING CODE HERE

$82/8DC6 C2 20       REP #$20                A:0000 X:FFFE Y:0000 P:envMxdIZC

Code: [Select]
$82/8DE6 99 00 43    STA $4300,y[$80:4340]   A:8002 X:0004 Y:0040 P:envMxdIzc

sets you up for one register write twice mode. Two bytes to a single register

Code: [Select]
$82/8DE1 99 01 43    STA $4301,y[$80:4341]   A:8012 X:0004 Y:0040 P:envMxdIzc

Means that you are writing to register $2112 (BG3 Vertical Scroll)

Code: [Select]
$82/8DD5 99 02 43    STA $4302,y[$80:4342]   A:80C0 X:0004 Y:0040 P:eNvmxdIzc
$82/8DDC 99 04 43    STA $4304,y[$80:4344]   A:807E X:0004 Y:0040 P:envMxdIzc

means the HDMA table is at $7E80C0

this table is interpreted as

Code: [Select]
70 00 00    -    112 scanlines of scroll = zero
0C 04 00    -    12 scanlines of scroll = +4
0C 08 00    -    12 scanlines of scroll = +8
0C 0C 00    -    12 scanlines of scroll = +12
0C 10 00    -    12 scanlines of scroll = +14
10 60 FF    -    This makes no sense in context. It would be setting mode 7 bits of the scroll register...

This is doing exactly what KingMike and LostTemplar suggest: It's squashing 4 16pixel segments into 12 pixel segments.
The table looks a bit broken to be honest. HDMA tables are normally terminated with a 00 byte. The 10 60 FF does not look at all right.
« Last Edit: September 25, 2012, 07:15:02 pm by Disnesquick »

justin3009

  • Hero Member
  • *****
  • Posts: 1614
  • Welp
    • View Profile
Re: What causes this in games?
« Reply #10 on: September 25, 2012, 06:39:25 pm »
I honestly didn't know ANY of that aside from the actual table that was going on.  It makes a bit more sense now, and if I remember right, Chrono Trigger actually did the same thing with FF being the final byte.  If not, then maybe something is quite awry about the tables in general.
'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.'

Disnesquick

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: What causes this in games?
« Reply #11 on: September 25, 2012, 07:23:10 pm »
I honestly didn't know ANY of that aside from the actual table that was going on.  It makes a bit more sense now, and if I remember right, Chrono Trigger actually did the same thing with FF being the final byte.  If not, then maybe something is quite awry about the tables in general.

Well the BG3 scroll registers looks like:

Code: [Select]
-----aaa aaaaaaaa  a: Horizontal/Vertical offset

so the 10 60 FF would write FF 60 in and wait 16 scanlines, essentially plugging a massive scroll in and then a byte that wouldn't even make sense in mode 7, since only $210D/$210E are used in mode 7 (and use more bits than the aaaaaaaaaaa in $2112)

Its also clear from the screenshot that the other two lines with time and gold are also squashed. The table you posted is missing some data. Can you post the missing lines of code I mentioned and I can check how big the table actually is. Probably best to post the 10 lines before that too.


justin3009

  • Hero Member
  • *****
  • Posts: 1614
  • Welp
    • View Profile
Re: What causes this in games?
« Reply #12 on: September 29, 2012, 09:26:59 am »
Code: [Select]
$82/8DB9 C8          INY                     A:006F X:FFFE Y:0000 P:envMxdIzC
$82/8DBA C2 20       REP #$20                A:006F X:FFFE Y:0001 P:envMxdIzC
$82/8DBC B7 F4       LDA [$F4],y[$8E:E298]   A:006F X:FFFE Y:0001 P:envmxdIzC
$82/8DBE 97 F7       STA [$F7],y[$7E:80C1]   A:0000 X:FFFE Y:0001 P:envmxdIZC
$82/8DC0 E2 20       SEP #$20                A:0000 X:FFFE Y:0001 P:envmxdIZC
$82/8DC2 C8          INY                     A:0000 X:FFFE Y:0001 P:envMxdIZC
$82/8DC3 C8          INY                     A:0000 X:FFFE Y:0002 P:envMxdIzC
$82/8DC4 80 ED       BRA $ED    [$8DB3]      A:0000 X:FFFE Y:0003 P:envMxdIzC
$82/8DB3 B7 F4       LDA [$F4],y[$8E:E29A]   A:0000 X:FFFE Y:0003 P:envMxdIzC
- The missing lines.

6F 00 00 0C 04 00 0C 08 00 0C 0C 00 0C 10 00 10
60 FF 0C 04 00 0C 08 00 10 38 FF 10 28 FF 00

And I believe that's the full HDMA table right there.
'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.'

Disnesquick

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: What causes this in games?
« Reply #13 on: October 08, 2012, 12:08:44 pm »
Yup, these missing lines make a bit more sense. I guess the FF stuff is just them making completely sure that the scroll registers went off-screen to show blank space for those scanlines. Or possibly something weird

Code: [Select]

6F 00 00      112 "normal" lines
0C 04 00      12-pixel high character line
0C 08 00      12-pixel high character line
0C 0C 00      12-pixel high character line
0C 10 00      12-pixel high character line
10 60 FF      16 WTF lines
0C 04 00      12-pixel high character line
0C 08 00      12-pixel high character line
10 38 FF      16 WTF lines
10 28 FF      16 WTF lines
00            Finish HDMA