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

Author Topic: snes writing to VRAM  (Read 1776 times)

zhade

  • Full Member
  • ***
  • Posts: 193
    • View Profile
    • zhaDe's stuff
snes writing to VRAM
« on: July 24, 2015, 10:26:10 am »
Im trying to write some stuff to VRAM to change the gfx show on BG#3 in secret of mana, I have located the VRAM adress of a tile that I want to change and call a bit of code every frame to change it here is the code as it appears in the debugger:
Code: [Select]
$E0/F000 A9 80       LDA #$80                A:0001 X:0000 Y:0000 P:envMXdIZC
$E0/F002 8F 15 21 00 STA $002115[$00:2115]   A:0080 X:0000 Y:0000 P:eNvMXdIzC
$E0/F006 C2 20       REP #$20                A:0080 X:0000 Y:0000 P:eNvMXdIzC
$E0/F008 A9 55 5B    LDA #$5B55              A:0080 X:0000 Y:0000 P:eNvmXdIzC
$E0/F00B 8F 16 21 00 STA $002116[$00:2116]   A:5B55 X:0000 Y:0000 P:envmXdIzC
$E0/F00F E2 20       SEP #$20                A:5B55 X:0000 Y:0000 P:envmXdIzC
$E0/F011 A9 08       LDA #$08                A:5B55 X:0000 Y:0000 P:envMXdIzC
$E0/F013 8F 18 21 00 STA $002118[$00:2118]   A:5B08 X:0000 Y:0000 P:envMXdIzC
$E0/F017 A9 20       LDA #$20                A:5B08 X:0000 Y:0000 P:envMXdIzC
$E0/F019 8F 19 21 00 STA $002119[$00:2119]   A:5B20 X:0000 Y:0000 P:envMXdIzC
$E0/F01D E2 20       SEP #$20                A:5B20 X:0000 Y:0000 P:envMXdIzC
$E0/F01F 6B          RTL                     A:5B20 X:0000 Y:0000 P:envMXdIzC

the problem is that it doesnt always work... It only seem to change it when I transition from an area to the next and only in some areas. If I change the data directly with the debugger the tile changes immediatly as it should but it does not change back with when my routine is executed... What am I doing wrong ?

DougRPG

  • Full Member
  • ***
  • Posts: 146
    • View Profile
Re: snes writing to VRAM
« Reply #1 on: July 24, 2015, 11:41:01 am »
Are you writing this in Vblank? You cannot write to Vram outside Vblank/Hblank.

zhade

  • Full Member
  • ***
  • Posts: 193
    • View Profile
    • zhaDe's stuff
Re: snes writing to VRAM
« Reply #2 on: July 24, 2015, 12:22:55 pm »
Oops that what the problem indeed  :D

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6932
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: snes writing to VRAM
« Reply #3 on: July 24, 2015, 09:41:12 pm »
I'm guessing if you solved your problem, I don't need to mention on the SNES you always need to divide VRAM addresses by 2 (so as a result you can only write starting at even addresses). For technical reason.
"My watch says 30 chickens" Google, 2018