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

Post Reply
lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

NES Screen Tool question

Post by lillapojkenpåön » Sat Jul 04, 2020 9:44 pm

Hello, I'm following the nesdoug tutorial, but I can't seem to get a working background from nesst,
the palette is pretty easy, palettes>Put to clipboard>C data, and paste it..
but nesst seems to have changed since every tutorial or video I can find when it comes to saving the nametable..

“Nametable/Save Nametable and Attributes/RLE packed as C header .h”
That option is not available so I tried this
Nametable>
checked include nametable, include attributes, RLE compression
save as C header

but I just get a black screen, any ideas what I'm doing wrong?
I just drew the bg in nesst so I didn't import a picture or anything.

Code: Select all

#include "LIB/neslib.h"
#include "LIB/nesdoug.h" 
#include "nesst/testproject.h" 


#define BLACK 0x0f
#define DK_GY 0x00
#define LT_GY 0x10
#define WHITE 0x30
// there's some oddities in the palette code, black must be 0x0f, white must be 0x30
 
 
#pragma bss-name(push, "ZEROPAGE")

// GLOBAL VARIABLES
// all variables should be global for speed
// zeropage global is even faster


static unsigned char bright;


/*{pal:"nes",layout:"nes"}*/
const unsigned char palette[16]={ 0x0f,0x00,0x10,0x30,0x0f,0x01,0x21,0x31,0x0f,0x06,0x16,0x26,0x0f,0x09,0x19,0x29 };



// setup PPU and tables
void setup_graphics() 
{
  // set palette colors
  pal_bg(palette);
  // turn on PPU
  ppu_on_all();
}


void fade_to(unsigned to)
{
  while(bright != to)
  {
    delay(4);
    if (bright < to) ++bright; else --bright;
    pal_bright(bright);
  }
}
	

void main (void) {
   // vram_adr and vram_put only work with screen off
    ppu_off(); // screen off
    pal_bright(0);	// can be a value 0 (black) to 8 (white), 4 = normal
	
	
  // unpack nametable into the VRAM

    vram_adr(NAMETABLE_A);		// set address (x,y)
    vram_unrle(testproject);	// write bytes to video RAM

	
    // initialize PPU
    setup_graphics();
	
	
    fade_to(4);   //fade in to normal
	
	
	while (1){
		// infinite loop
		
		
		// game code can go here later.
		
		
    // wait for next frame
    ppu_wait_frame();	
	}
}

lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

Re: NES Screen Tool question

Post by lillapojkenpåön » Sat Jul 04, 2020 11:59 pm

I downloaded nesst 2.4 so I could get that option but still just a black screen.
I got it working on 8bitworkshop but it had the wrong tile, but in the right places.
that's why I downloaded cc65 and everything, but several hours of just a black screen :cry:

User avatar
dougeff
Posts: 2707
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: NES Screen Tool question

Post by dougeff » Sun Jul 05, 2020 6:25 am

On the newest NES screen tool, you need checkmarks next to "include nametable" and/or "include attributes" when you save a nametable.

Version 2.4 leaves these unchecked by default, which produces a zero byte output file.

(I think this is true, but I don't seem to have a copy of 2.4 on my system anymore)

Version 2.5 has them both checked by default. Try version 2.5. Or, make sure you have something checked in 2.4.
nesdoug.com -- blog/tutorial on programming for the NES

lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

Re: NES Screen Tool question

Post by lillapojkenpåön » Sun Jul 05, 2020 4:32 pm

In the newest version I put checkmarks next to "include nametable" "include attributes" and "RLE compression"

In 2.4 there is no checkmarks, It works completely different, that's why I downloaded it

lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

Re: NES Screen Tool question

Post by lillapojkenpåön » Sun Jul 05, 2020 4:49 pm

I don't think there's any tiles to draw with, the palette is the colors, the nametable the shape right? where is the code that puts the tiles where they should be in the rom?

User avatar
dougeff
Posts: 2707
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: NES Screen Tool question

Post by dougeff » Sun Jul 05, 2020 7:13 pm

Usually I use an .incbin at the bottom of crt0.s to include tiles. I put them in a special segment that is mapped to go after the code.

I can't remember how to do it in 8bitworkshop, but it doesn't look like you are using that anymore.
nesdoug.com -- blog/tutorial on programming for the NES

lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

Re: NES Screen Tool question

Post by lillapojkenpåön » Sun Jul 05, 2020 8:38 pm

Thanks!! I got it now, I opened the existing Alpha.chr and added the tile to that and saved, now it works.
How many different .chr tilesets can a game have?

lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

Re: NES Screen Tool question

Post by lillapojkenpåön » Tue Jul 07, 2020 1:46 pm

Another quick question, what does attributes mean, specificly when it comes to sprites

void __fastcall__ oam_spr(unsigned char x,unsigned char y,unsigned char chrnum,unsigned char attr)

changing the number changes the color, and priority, sometimes it's above the background sometimes behind, but what am I doing exactly?

lidnariq
Posts: 9491
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: NES Screen Tool question

Post by lidnariq » Tue Jul 07, 2020 1:50 pm


lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

Re: NES Screen Tool question

Post by lillapojkenpåön » Tue Jul 07, 2020 11:46 pm

Thanks!
What about this
// there's some oddities in the palette code, black must be 0x0f, white must be 0x30

Is that specific to Doug's code, or just in general?

And I'm trying to figure out why a bg palette is 16 values, but when used in a 32 byte palette table needs to be 17 values, you have to add the last black,
and how come you can skip it otherwise? Can it not be anything other than black?

User avatar
dougeff
Posts: 2707
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: NES Screen Tool question

Post by dougeff » Wed Jul 08, 2020 5:14 am

It's about neslib. If you look at the bottom of neslib.s
palBrightTable0:

I think my comment about black is that neslib uses 0x0f to replace 0x0d and 0x0e. 0x0e is fine, but 0x0d is a different black... (the D column is affected by color emphasis, but E and F aren't) which is odd to me, that Shiru is forcing you to use 0x0f... except that some TVs have issues with the 0x0d color, especially of all the color emphasis bits are set (like the title screen of The Immortal), the screen is warped and glitchy because the "blacker than black" signal confuses the TV timing signals.

But also, 0x1f and 0x2f, and 0x3f are black on NES hardware, but with this code they will fade to white * faster than 0x0f. Which is probably not what you expect.

So, I recommend using 0x0e or 0x0f for black.

Also, 0x20 white is treated differently than 0x30 white. It fades to black * faster than the 0x31-0x3c colors, which is probably not what you expect. So, I recommend just using 0x30 for white.


* (Where I say fade, I'm referring to neslib color brightness. pal_spr_bright(), pal_bg_bright(), and pal_bright() functions). They select a different starting point in the palette table based on the brightness value. 0 for all black, 4 for normal, 8 for all white. You see the first 4 rows filled with 0x0f black and the last 4 rows filled with 0x30 white.
nesdoug.com -- blog/tutorial on programming for the NES

lillapojkenpåön
Posts: 20
Joined: Sat Jul 04, 2020 5:27 pm

Re: NES Screen Tool question

Post by lillapojkenpåön » Sat Jul 11, 2020 2:48 am

Ok, thanks!
I tried to get the bg collision code to work with my 8x8 tile bg,
(*objectX + objectWidth >> 3) + (*objectY / 8 * 32)

but didn't get it working correctly, so I tried drawing each tile with four tiles,
I have saved and re-saved everything numerous times, but when compiling and running it still shows the old bg and tiles,
what am I doing wrong??
EDIT:
Got it to work.

Post Reply