Simple CC65 NES ?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Simple CC65 NES ?
by on (#189722)
Code:
#include <nes.h>
 
void main()
{   
   waitvblank();
       
   *((unsigned char*)0x2006) = 0x3f;
   *((unsigned char*)0x2006) = 0x00;
        *((unsigned char*)0x2007) = 0x05; // put color 5 to address 0x3f00, which is the first in the above table
      
   *((unsigned char*)0x2006) = 0x3f;
        *((unsigned char*)0x2006) = 0x03;
   *((unsigned char*)0x2007) = 0x02; // put color 2 to address 0x3f0x, which is the third in the above table.
      
        *((unsigned char*)0x2006) = 0x20;
   *((unsigned char*)0x2006) = 0x41;
   *((unsigned char*)0x2007) = 'A'; // write letter.
      
   *((unsigned char*)0x2005) = 0x00;
   *((unsigned char*)0x2005) = 0x00;

   /* Enable the screen */
   /* By default, the screen and sprites were off */
   *((unsigned char*)0x2001) = 8;
   
   while(1);
}


Prints the letter 'A' on the screen.

Code:
#include <nes.h>
 
void main()
{   
   waitvblank();
       
   *((unsigned char*)0x2006) = 0x3f;
   *((unsigned char*)0x2006) = 0x00;
    *((unsigned char*)0x2007) = 0x05; // put color 5 to address 0x3f00, which is the first in the above table
      
   *((unsigned char*)0x2006) = 0x3f;
    *((unsigned char*)0x2006) = 0x03;
   *((unsigned char*)0x2007) = 0x02; // put color 2 to address 0x3f0x, which is the third in the above table.
      
    *((unsigned char*)0x2006) = 0x20;
   *((unsigned char*)0x2006) = 0x41;
   *((unsigned char*)0x2007) = 'A'; // write letter.
      
   *((unsigned char*)0x2006) = 0x25;
   *((unsigned char*)0x2006) = 0x44;
   *((unsigned char*)0x2007) = 'B'; // write letter.   
      
   *((unsigned char*)0x2005) = 0x00;
   *((unsigned char*)0x2005) = 0x00;

   /* Enable the screen */
   /* By default, the screen and sprites were off */
   *((unsigned char*)0x2001) = 8;
   
   while(1);
}


This code only prints the letter 'B' instead of 'A' and 'B'.

Just looking for why does this happen and how can I display both.
Re: Simple CC65 NES ?
by on (#189723)
$2041 and $2544 are on different nametables. How do you expect to see both of them at the same time? (You could check both nametables in a debugging emulator to verify.)

Your scroll position is set to 0,0 so I would expect you to only see A and not B, though.