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

Author Topic: [SNES] Easy way to clear VRAM?  (Read 3047 times)

lytron

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • pantalytron.com
[SNES] Easy way to clear VRAM?
« on: March 27, 2014, 05:01:46 am »
Hello, hello,

I take a small peek into the code of Asterix for the SNES. The whole boot/register clear stuff seems to be written quite dilettantish (double-clearing registers, unnecessary lines and stuff).

But all of a sudden, I saw this:

Code: [Select]
LDA #$C0
STA $211A

If I understand this document right, this clears the whole VRAM at once? Is that right? Does that actually work even if the screen setting was changed to Mode 1 before? I would be astonished if something that nifty would be there, after all this weird stuff I saw...

... does anyone know more about it?

Bregalad

  • Hero Member
  • *****
  • Posts: 2751
    • View Profile
Re: [SNES] Easy way to clear VRAM?
« Reply #1 on: March 27, 2014, 05:54:04 am »
Clearing VRAM is something very very different from showing a blank screen.

mopoz

  • Jr. Member
  • **
  • Posts: 69
  • Russia, Vodka and Bears
    • View Profile
Re: [SNES] Easy way to clear VRAM?
« Reply #2 on: March 27, 2014, 05:57:40 am »
Code: [Select]
lda #$0000
 ldx #$0000
-
 sta $7F8000,x
 inx
 inx
 beq -

  lda #$0000
  sta $2116
  lda #$8000
  sta $4302
  lda #$8000
  sta $4305
  sep #$20
  lda #$80
  sta $2115
  lda #$01
  sta $4300
  lda #$18
  sta $4301
  lda #$7f
  sta $4334
  lda #$01
  sta $420b

  lda #$4000
  sta $2116
  lda #$8000
  sta $4312
  lda #$8000
  sta $4315
  sep #$20
  lda #$80
  sta $2115
  lda #$01
  sta $4300
  lda #$18
  sta $4311
  lda #$7f
  sta $4314
  lda #$02
  sta $420b
 

Or have an empty space in the ROM.
« Last Edit: March 29, 2014, 07:01:04 pm by mopoz »
Skate-punk rulezzzz

lytron

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • pantalytron.com
Re: [SNES] Easy way to clear VRAM?
« Reply #3 on: March 27, 2014, 06:34:05 am »
Ah, sorry, my mistake. I misunderstood this:

Quote
211a  wb++?-
        rc----yx
c       = Empty space fill, when bit 7 is set:
                   0 = Transparent.
                   1 = Fill with character 0. Note that the fill is matrix transformed like all other Mode 7 tiles.

I misinterpreted "Empty space fill" and "Fill with character 0".

magno

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Traducciones Magno
Re: [SNES] Easy way to clear VRAM?
« Reply #4 on: March 27, 2014, 09:31:29 am »
In fact, erasing VRAM is easier and faster than mopoz posted:
Code: [Select]
  ; set a '0' value in RAM
  lda #$0000
  sta $0000
  ; VRAM destination address $0000
  sta $2116
  ; RAM source address $7E:0000
  sta $4302
  ; bytes to transfer $10000
  sta $4305
  sep #$20
  ; VRAM address increment after writing to $2119
  lda #$80
  sta $2115
  ; DMA transfer writes 2 bytes, 1 to $2118 and 1 to $2119, without incrementing RAM address (fixed transfer)
  lda #$09
  sta $4300
  ; PPU destination register $2118
  lda #$18
  sta $4301
  ; RAM source address bank $7E
  lda #$7E
  sta $4334
  ; run the DMA!
  lda #$01
  sta $420b