Basic NES Screen Tool question

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Basic NES Screen Tool question

Post by sempressimo »

When I draw screen (just 1 screen size) and export name table I get a 960 bytes and its not hex numbers as I expected.

I load my screens as .db $03, $06 etc. and just 1 screen size I have no scrolling.

My goal is just to draw 1 screen for now with the tool, instead of by hand on the .db(s) as I do now.

What I am missing?
Last edited by sempressimo on Sun Nov 29, 2015 8:54 am, edited 1 time in total.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Basic NES Screen Tool question

Post by tepples »

A 960-byte file out of a nametable editor is most likely an uncompressed nametable without an attribute table. You can include it in your file with the .incbin command that an assembler is likely to support. But if different parts of the nametable use different 3-color subpalettes, I'd encourage you to include the attribute table so that the NES knows what colors to apply to each 16x16 pixel area. This will make your file 1024 bytes.
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Re: Basic NES Screen Tool question

Post by sempressimo »

I got the name table working as an .incbin of 1024, but there is something off with the attributes or the pallete:

Image

Image

My pallete section matches the program as I copied the pal ASM here to be sure:

palette:

.db $0f,$00,$10,$30 ,$0f,$01,$21,$31 ,$0f,$06,$16,$05, $0f,$09,$19,$29
.db $0f,$00,$10,$30 ,$0f,$01,$21,$31 ,$0f,$06,$16,$05, $0f,$09,$19,$29
lidnariq
Posts: 10677
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Basic NES Screen Tool question

Post by lidnariq »

How are you uploading the palette?
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Re: Basic NES Screen Tool question

Post by sempressimo »

lidnariq wrote:How are you uploading the palette?
LoadGamePalettes:

LoadPalettes:
LDA $2002 ; read PPU status to reset the high/low latch
LDA #$3F
STA $2006 ; write the high byte of $3F00 address
LDA #$00
STA $2006 ; write the low byte of $3F00 address
LDX #$00 ; start out at 0
LoadPalettesLoop:

LDA roomindex
CMP #$00
BNE .next

LDA palette_dark, x ; load data from address (palette + the value in x)
JMP ResumePaletteLoading

.next

LDA palette, x ; load data from address (palette + the value in x)

ResumePaletteLoading:

STA $2007 ; write to PPU
INX ; X = X + 1
CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
; if compare was equal to 32, keep going down

RTS

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

First 16 are for the background, last 16 for the sprites. Want to mention this was all working when I was doing this by hand (i.e. editing the .db(s) for all things.

This is the "old way" and the "new way" for nametable data:

; New way shown on pictures..
Room0:
.incbin "demo.nam"

; Old way, no problem with this
Room1:
.db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
.db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
.db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
.db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
.db $99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99
.db $99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$99,$99
.db $99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$26,$27,$26,$27,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99
.db $99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$36,$37,$36,$37,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99,$99

attributes_1: ;8 x 8 = 64 bytes
.db %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111
.db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
.db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
.db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
.db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
.db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
.db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
.db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
User avatar
dougeff
Posts: 2876
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Basic NES Screen Tool question

Post by dougeff »

You're attribute table looks wrong. How was it generated? By hand?

Looks to me like it should be...
0, 0, 0, 0, 0, 0, 0, 0
(11110101=)$f5, $f5, $f5, $f5, $f5, $f5, $f5, $f5
$ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
Then zero to the end.

Although your output doesn't match your attribute table either, according to your data, the "Lv 1" would be green and the rest of the screen gray. It's not being loaded right. Are you sure it's going to 23c0?
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Re: Basic NES Screen Tool question

Post by sempressimo »

Atribute table for Room 1 was generated by hand but so far seems to be working fine. The problem I present is with Room 0 where the attribute table is included in the .nam file created by the NES Screen Tool.
User avatar
dougeff
Posts: 2876
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Basic NES Screen Tool question

Post by dougeff »

In FCEUX, open hex editor, set view = PPU, and scroll down to 23c0. What numbers are you getting?
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Re: Basic NES Screen Tool question

Post by sempressimo »

dougeff wrote:In FCEUX, open hex editor, set view = PPU, and scroll down to 23c0. What numbers are you getting?
Image
User avatar
dougeff
Posts: 2876
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Basic NES Screen Tool question

Post by dougeff »

That matches the data.

So, I was misunderstanding at first. The above pictures are unrelated to current problem?
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Re: Basic NES Screen Tool question

Post by sempressimo »

dougeff wrote:That matches the data.

So, I was misunderstanding at first. The above pictures are unrelated to current problem?
I will summarize, the problem is seen here:

Image

Image

My code to load the name table is:

Code: Select all

Room0:
  .incbin "demo.nam" ; This is a 1024 bytes file created with Screen Tool, it should contain the attribute table
My palette loading routine is:

Code: Select all

;----------------------
; LoadGamePalettes()
;----------------------  
LoadGamePalettes:

  LoadPalettes:
  LDA $2002             ; read PPU status to reset the high/low latch
  LDA #$3F
  STA $2006             ; write the high byte of $3F00 address
  LDA #$00
  STA $2006             ; write the low byte of $3F00 address
  LDX #$00              ; start out at 0
LoadPalettesLoop:
  
  LDA roomindex
  CMP #$00
  BNE .next
  
  LDA palette_dark, x     ; load data from address (palette + the value in x)
  JMP ResumePaletteLoading
  
.next

  LDA palette, x     ; load data from address (palette + the value in x)
  
ResumePaletteLoading:

  STA $2007             ; write to PPU
  INX                   ; X = X + 1
  CPX #$20              ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
  BNE LoadPalettesLoop  ; Branch to LoadPalettesLoop if compare was Not Equal to zero
                        ; if compare was equal to 32, keep going down
  RTS
User avatar
dougeff
Posts: 2876
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Basic NES Screen Tool question

Post by dougeff »

Oh, then my original statement holds true.

Your attribute table data is wrong. It doesn't match the picture you're showing us.

To quote myself...
Looks to me like it should be...
0, 0, 0, 0, 0, 0, 0, 0
(11110101=)$f5, $f5, $f5, $f5, $f5, $f5, $f5, $f5
$ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
Then zero to the end.
Last edited by dougeff on Sun Nov 29, 2015 7:04 pm, edited 2 times in total.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Basic NES Screen Tool question

Post by thefox »

You can look at the palette in FCEUX, you know. Nametables also. (I'm not sure if FCEUX can display attribute table values, but Nintendulator can show those ones as well.)
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Re: Basic NES Screen Tool question

Post by sempressimo »

thefox wrote:You can look at the palette in FCEUX, you know. Nametables also. (I'm not sure if FCEUX can display attribute table values, but Nintendulator can show those ones as well.)
I keep forgetting about these tools. I did point me to my issue, I was loading a diff palette based on the room and I was pointing to the incorrect one.

Thanks all!
User avatar
dougeff
Posts: 2876
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Basic NES Screen Tool question

Post by dougeff »

At some point, you will have to consider compressing your data. The Nes Screen Tool (i think) has a RLE compression tool...and a bit of code to insert to uncompress it. (I've never used it personally).
nesdoug.com -- blog/tutorial on programming for the NES
Post Reply