News: 11 March 2016 - Forum Rules

Author Topic: Question on Clearing VRAM?  (Read 5020 times)

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Question on Clearing VRAM?
« on: December 08, 2013, 02:51:22 pm »
Is there a way to clear VRAM just using a couple bytes to wipe a chunk of VRAM?

Instead of having like 7E:2000 to 7E:2800 being read to wipe VRAM, would it be possible to have it continuously load 7E:2000 and have it wipe out 800 bytes of VRAM with just those two?
'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.'

ARM9

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Question on Clearing VRAM?
« Reply #1 on: December 09, 2013, 07:04:53 am »
Yes, if you set the DMA transfer to fixed source.

Code: [Select]
rep #$10
sep #$20

lda #$80
sta $2115
ldx #$0000
stx $2116
stx $00 ; assumes direct page is $0000, this is the word that we're going to transfer.

lda #$7E
stx $4302 ; source address $0000
sta $4304 ; source bank

ldx #$0800
stx $4305

ldx #$1809 ; alternate byte writes to $2118/$2119 from fixed source
stx $4300

lda #$01
sta $420B
Alternatively you can use a zero word in rom but afaik DMA transfers are not affected by $420D so there's little to be gained from doing so. One scenario where that'd be useful however would be if you wanted to clear WRAM with DMA transfers without using SRAM.
« Last Edit: December 09, 2013, 07:11:13 am by ARM9 »

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Question on Clearing VRAM?
« Reply #2 on: December 09, 2013, 05:54:58 pm »
Code: [Select]
$C0/EB54 C2 10       REP #$10                A:0000 X:0E70 Y:0000 P:envmxdiZc
$C0/EB56 E2 20       SEP #$20                A:0000 X:0E70 Y:0000 P:envmxdiZc
$C0/EB58 A9 80       LDA #$80                A:0000 X:0E70 Y:0000 P:envMxdiZc
$C0/EB5A 8D 15 21    STA $2115  [$81:2115]   A:0080 X:0E70 Y:0000 P:eNvMxdizc
$C0/EB5D A2 00 00    LDX #$0000              A:0080 X:0E70 Y:0000 P:eNvMxdizc
$C0/EB60 8E 16 21    STX $2116  [$81:2116]   A:0080 X:0000 Y:0000 P:envMxdiZc
$C0/EB63 86 00       STX $00    [$00:0E70]   A:0080 X:0000 Y:0000 P:envMxdiZc
$C0/EB65 A9 7E       LDA #$7E                A:0080 X:0000 Y:0000 P:envMxdiZc
$C0/EB67 8E 02 43    STX $4302  [$81:4302]   A:007E X:0000 Y:0000 P:envMxdizc
$C0/EB6A 8D 04 43    STA $4304  [$81:4304]   A:007E X:0000 Y:0000 P:envMxdizc
$C0/EB6D A2 00 08    LDX #$0800              A:007E X:0000 Y:0000 P:envMxdizc
$C0/EB70 8E 05 43    STX $4305  [$81:4305]   A:007E X:0800 Y:0000 P:envMxdizc
$C0/EB73 A2 09 18    LDX #$1809              A:007E X:0800 Y:0000 P:envMxdizc
$C0/EB76 8E 00 43    STX $4300  [$81:4300]   A:007E X:1809 Y:0000 P:envMxdizc
$C0/EB79 A9 01       LDA #$01                A:007E X:1809 Y:0000 P:envMxdizc
$C0/EB7B 8D 0B 42    STA $420B  [$81:420B]   A:0001 X:1809 Y:0000 P:envMxdizc

Actually a little confused on this.  There's.. literally nothing happening to VRAM at all.  The location to write to even when set is 4300 (8600) which I tried setting it too, regardless, it's not doing a single thing.  Am I not enabling something to do so?
'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.'

ARM9

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Question on Clearing VRAM?
« Reply #3 on: December 10, 2013, 03:01:11 am »
That most likely means that you're trying to dma to vram during scanning which simply won't work in any accurate emulator. You'll want to run that piece of code during f-blank or v-blank.

Also this line looks rather suspicious: $C0/EB63 86 00       STX $00    [$00:0E70]   A:0080 X:0000 Y:0000 P:envMxdiZc
[$00:0E70] seems to imply that the direct page is set to $0E70, at least at the point where this code is executed. I assume this is a romhack so you may want to leave the direct page alone and use absolute addressing (stx $0000, stx.w 0 or whatever convention your assembler follows).
« Last Edit: December 10, 2013, 08:20:27 am by ARM9 »

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Question on Clearing VRAM?
« Reply #4 on: December 10, 2013, 10:11:38 am »
Ah okay, that makes more sense. And that's actually what the normal rom does with the 0E70. But I thought it was something like that. I'll take another whack when I get home.

December 10, 2013, 04:53:04 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Seems to work now!  The only problem now is it's..

- Doing that.  When it was set at 0000 for VRAM, it did blank graphics, but some reason down in the section I put it, it does lines like that instead.

Any idea why this would happen?
« Last Edit: December 10, 2013, 04:53:04 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.'

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5792
    • View Profile
    • Nightcrawler's Translation Corporation
Re: Question on Clearing VRAM?
« Reply #5 on: December 10, 2013, 05:44:48 pm »
Why are you clearing VRAM? In most cases, you never have to do that. Much more efficient clearing can be done via the tilemap. Most games even carry a copy in RAM of the tilemap that is sent to VRAM during NMI, so clearing is no more than writing to RAM at any time.
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: Question on Clearing VRAM?
« Reply #6 on: December 10, 2013, 05:55:38 pm »
If I'm seeing it right, it's more or less how Breath of Fire II handles it's system.  If what I'm seeing is correct, it loads the entire tilemap up at once and as the letters get written into VRAM, it just loads the tilemap directly instead of writing a new piece each time it's written.

So I try to clear a section where the dialogue WOULD be so it doesn't display left over graphics from the previous dialogue.
'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.'

ARM9

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Question on Clearing VRAM?
« Reply #7 on: December 11, 2013, 04:58:29 am »
- Doing that.  When it was set at 0000 for VRAM, it did blank graphics, but some reason down in the section I put it, it does lines like that instead.

Any idea why this would happen?
With the limited information at hand, I can only assume that your DMA source contains a non-zero value (hence the alternating pattern). I'll assume this is a vram dump.

Nightcrawler is right, if the map is stored in WRAM you can clear a layer by writing a word that maps to a "transparent" tile a couple times. This of course can also be accomplished with DMA (but not with WRAM as the source).
« Last Edit: December 11, 2013, 05:10:27 am by ARM9 »

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Question on Clearing VRAM?
« Reply #8 on: December 11, 2013, 06:10:32 am »
Ah duh, I see what you're saying. I'll try messing around a bit more with it all if possible tonight and see what I can come up with.
'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.'