Problem with Load second NameTable

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
sdm
Posts: 315
Joined: Tue Apr 11, 2006 4:08 am
Location: Poland

Problem with Load second NameTable

Post by sdm »

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: Select all

	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"
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Problem with Load second NameTable

Post by tokumaru »

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.
User avatar
yefeng
Posts: 6
Joined: Thu Mar 12, 2009 4:09 am
Location: China

Post by yefeng »

thanks ,i see , MAX bytes is 128 :P
sdm
Posts: 315
Joined: Tue Apr 11, 2006 4:08 am
Location: Poland

Re: Problem with Load second NameTable

Post by sdm »

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: Select all

	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: Select all


	.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

Post Reply