It is currently Wed Aug 15, 2018 12:15 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Loading name tables
PostPosted: Tue Feb 07, 2006 11:36 am 
Offline

Joined: Sat Jan 21, 2006 9:04 am
Posts: 4
I'm following NES101 tutorial by Michael Martin. I come to part about background but can't get my name table to display. I'm not sure are they loaded correctly as whole screen is filled with tile #0. Code:

Code:
   .inesprg   1
   .ineschr   1
   .inesmir   1
   .inesmap   0

   .bank 0
   .org $8000

reset:
   sei
   cld

vb1:   lda $2002
   bne vb1
vb2:   lda $2002
   bne vb2

   lda #$00
   sta $2000
   sta $2001

   jsr load_palette
   jsr load_name_tables

   lda #%10001000
   sta $2000
   lda #%00001110   
   sta $2001

   cli

loop:
   jmp loop

load_palette:
   lda #$3F
   ldx #$00
   sta $2006
   stx $2006

lp:   lda palette_data, x
   sta $2007
   inx
   cpx #$20
   bne lp

   rts

load_name_tables:
   lda #LOW(name_tables_data)
   sta $10
   lda #HIGH(name_tables_data)
   sta $11

   lda #$20
   sta $2006
   lda #$00
   sta $2006

   ldx #$04
   ldy #$00

lnt1:   lda ($10), y
   sta $2007
   iny
   bne lnt1
   inc $11
   dex
   bne lnt1

   lda #$00
   ldx #$04
   ldy #$00

lnt2:   sta $2007
   iny
   bne lnt2
   dex
   bne lnt2

   rts


nmi:
irq:
   rti

palette_data:
   .db $0E, $15, $16, $17, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
   .db $0E, $11, $21, $31, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00

name_tables_data:
   .incbin "screen.nam"

   .bank 1
   .org $FFFA
   .dw nmi, reset, irq

   .bank 2
   .incbin "background.chr"
;   .incbin "sprites.chr"


I'd attach background and nametable files, but I don't know where to upload them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 11:41 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1421
Code:
   lda #$00
   ldx #$04
   ldy #$00

lnt2:   sta $2007
   iny
   bne lnt2
   dex
   bne lnt2


...is your problem. You have your ROM set to use horizontal mirroring, and that particular code is clearing PPU $2400-$27FF, which happens to be the same as $2000-$23FF (which contains the nametable you just entered). If you're following NES 101, you need to set the VRAM address to $2800 before that segment of code.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 12:58 pm 
Offline

Joined: Sat Jan 21, 2006 9:04 am
Posts: 4
I modified my code to use horizontal mirroring (.inesmir 0) and $2400 (instead of $2000) is written to $2006. Now it should be same as NES101. Still nothing on screen. When I look at nametables in FCE tile indexes are all $00 and $FF.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 1:53 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1421
spoofer wrote:
I modified my code to use horizontal mirroring (.inesmir 0) and $2400 (instead of $2000) is written to $2006.


Umm, that was the problem to begin with.

Set mirroring to Horizontal and then try this:

Code:
load_name_tables:
   lda #LOW(name_tables_data)
   sta $10
   lda #HIGH(name_tables_data)
   sta $11

   lda #$20              ;real nametable goes at $2000
   sta $2006
   lda #$00
   sta $2006

   ldx #$04
   ldy #$00

lnt1:   lda ($10), y
   sta $2007
   iny
   bne lnt1
   inc $11
   dex
   bne lnt1

   lda #$28              ;NEW - blank nametable goes at $2800
   sta $2006
   lda #$00
   sta $2006


   lda #$00
   ldx #$04
   ldy #$00

lnt2:   sta $2007
   iny
   bne lnt2
   dex
   bne lnt2

   rts


Chances are it'll work in most emulators.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject: im confuse
PostPosted: Wed Feb 08, 2006 6:03 am 
spoff says:

.inesprg 1
.ineschr 1
.inesmir 1
.inesmap 0

and then quietust says: "oh you are using horizontal mirroring.."

but .inesmir 0 is vertical and .ines 1 is horizontal?? i have reading it..

then spof says:

spoofer wrote:
I modified my code to use horizontal mirroring (.inesmir 0) and $2400 (instead of $2000) is written to $2006. Now it should be same as NES101. Still nothing on screen. When I look at nametables in FCE tile indexes are all $00 and $FF.


what..?? now .inesmir 0 is horizontal??

i dont understand... can someone explain it to me??.. im a newbie.


Top
  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 9:13 am 
Offline

Joined: Sat Jan 21, 2006 9:04 am
Posts: 4
Thanks Quietust, PPU address was wrong. Other problem was that NesASM use [ and ] for indirect indexed addressing and I was using ( and ).

lord: Just take a look at neshdr20.txt that comes with NesASM. All possible compinations are listed there (below mapper list).


Top
 Profile  
 
 Post subject: where
PostPosted: Wed Feb 08, 2006 9:20 am 
where can i download lastest version of NesASM??


Top
  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 9:22 am 
Offline

Joined: Sat Jan 21, 2006 9:04 am
Posts: 4
NESdev main page, search for "Nintendo Assembler".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group