This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Problem with Load second NameTable

Problem with Load second NameTable
by on (#38484)
I load one name table. I use $2005 and i get simple scroll effect (dubled first NT). But i cannot load second name table. First NT i load to VRAM address $2000, how, and where i must load second NT? (to $2400? and how do it?)

Code:
   JSR LoadNT1

----subrutines----


LoadNT1:

   LDX #$20
   STX $2006
   LDX #$00
   STX $2006
   STY $2006
   LDX #$04
   LDA #low(NameTable1)
   STA <$0000
   LDA #high(NameTable1)
   STA <$0001

LoadMap1:

   LDA [$0000], y
   STA $2007
   INY
   BNE LoadMap1
   INC <$0001
   DEX
   BNE LoadMap1

   RTS

---------------------

NameTable1:

   .incbin "test.map1"
Re: Problem with Load second NameTable
by on (#38487)
sdm wrote:
First NT i load to VRAM address $2000, how, and where i must load second NT? (to $2400? and how do it?)

The address of the second NT depends on the kind of mirroring you're using. It can be either at $2400 (vertical mirroring), or at $2800 (horizontal mirroring) but it is always mirrored at $2C00 as well, regardless of the mirroting type.

To update it you must wait for VBlank, turn rendering off, update the NT, wait for VBlank again and turn rendering on. There is no time to update a whole NT without turning rendering off. If you want to do it without disabling rendering, you have to break the updating process down into smaller pieces, updating smaller parts of it during VBlank. A safe number of bytes to write during VBlank (of course, depending on the performance of the code you are using to do it) is about 128 bytes, so a full NT update would take around 8 frames.

by on (#44167)
thanks ,i see , MAX bytes is 128 :P
Re: Problem with Load second NameTable
by on (#92114)
sdm wrote:
I load one name table. I use $2005 and i get simple scroll effect (dubled first NT). But i cannot load second name table. First NT i load to VRAM address $2000, how, and where i must load second NT? (to $2400? and how do it?)

Code:
   JSR LoadNT1

----subrutines----


LoadNT1:

   LDX #$20
   STX $2006
   LDX #$00
   STX $2006
   STY $2006
   LDX #$04
   LDA #low(NameTable1)
   STA <$0000
   LDA #high(NameTable1)
   STA <$0001

LoadMap1:

   LDA [$0000], y
   STA $2007
   INY
   BNE LoadMap1
   INC <$0001
   DEX
   BNE LoadMap1

   RTS

---------------------

NameTable1:

   .incbin "test.map1"


Old, but may be useful for someone, solution is simple:

http://siudym.webd.pl/nesasm/2nt.nes

Code:

   .inesmir 1

   JSR LoadNT1

----subrutines----


LoadNT1:

   LDX #$20
   STX $2006
   LDX #$00
   STX $2006
   STY $2006
   LDX #$08                       ;change
   LDA #low(NameTable1)
   STA <$0000
   LDA #high(NameTable1)
   STA <$0001

LoadMap1:

   LDA [$0000], y
   STA $2007
   INY
   BNE LoadMap1
   INC <$0001
   DEX
   BNE LoadMap1

   RTS

---------------------

NameTable1:

   .incbin "test.map1"     ;nametable0
   .incbin "test.map2"     ;nametable1