Skip navigation
Welcome, Guest! Please Login or Join

Loading...

Nerdy Nights week 3 6502 ASM, first app

Jul 8, 2008 at 4:47:14 PM
albailey (55)
avatar
(Al Bailey) < Lolo Lord >
Posts: 1522 - Joined: 04/10/2007
Ontario
Profile
Unzip the background.zip file.
Open a DOS window.
change into that background folder

type the following:
dir


There should be 3 files
background.asm
background.bat
mario.chr

type:
background.bat

It should complain: 'NESASM3' is not recognized as an internal or external command

Update background.bat to include the entire path to nesasm (be aware that you may need quotes if there are spaces in the path).

Alternativly, add nesasm to your sytem "PATH" variable.
to do this:
Open your "Control Panel" and click on "System". to open "System Properties"
In "System Properties" find the "Advanced" tab. and click on the "Environment Variables" button.
Find an item entitled "PATH" and edit it to add the path to your nesasm (you probably should add this at the end, and remember to add a semi colon before you enter the path)

If this all works, and nesasm is working, you should see your background.nes file being created.
Double click the NES file and your emulator should load it.
Al



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

My Gameboy collection  97% complete.          My N64 collection   88% complete



 My Gamecube collection  99% complete        My NES collection   97% complete


Jul 13, 2008 at 10:03:46 AM
dutch (0)
This user has been banned -- click for more information.
(bert n) < Meka Chicken >
Posts: 589 - Joined: 10/02/2007
Netherlands
Profile
Finaly made nesasm work with the controller.zip file

thanks al.

it was great to see asm make controller.nes and when the fceuxd showed mario i jumped sky high!
i can finally test all my codes and work on them.

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

LOOKING FOR GARAGE CART,pm me with buy or trading offer


Oct 20, 2009 at 12:03:55 AM
ddribin (0)

(Dave Dribin) < Cherub >
Posts: 11 - Joined: 10/19/2009
United States
Profile
Hi all,

I'm interested in getting started on some NES programming just for kicks, and I've been reading the Nerdy Nights series, along with some other docs.  I'm on a Mac, so I want to try translating these tutorials into ca65 and test on Nestopia, since that works better than NESASM3 + FCEUXD SP.

This first tutorial doesn't seem to work, however.  The screen shows up as all black.  I have to add in code like this to setup the palette before storing %10000000 into $2001:


 lda #$3f ; Set PPU address to BG palette RAM ($3F00)
 sta $2006
 lda #$00
 sta $2006

 lda #$00
 sta $2007
 sta $2007
 
@vblankwait3:
 bit $2002
 bpl @vblankwait3


Any help on why this is needed on Nestopia?  Does it make sense that the palette needs to be setup like this?  Is there a more proper way to initialize the PPU to get a light blue background by setting bit 7 of $2001? Is Nestopia just broken?

Thanks,

-Dave

P.S. Sorry for not formatting the code properly. I don't see how to choose a fixed width font.

Oct 20, 2009 at 12:24:20 AM
udisi (88)
avatar
< King Solomon >
Posts: 3263 - Joined: 11/15/2006
United States
Profile
well you may have copied it wrong here, but it should be #%10000000 , not %10000000. # signs can screw a lot of things up lol.

you're palette initialization looks right to me, but you shouldn't even need a palette loaded to intensify color.

Oct 20, 2009 at 12:37:54 AM
ddribin (0)

(Dave Dribin) < Cherub >
Posts: 11 - Joined: 10/19/2009
United States
Profile
I am indeed using #%10000000.  Here's the code just following the previous snippet:

 lda #%10000000 ; intensify blues
 sta $2001

@forever:
 jmp @forever

And here's the whole file: http://gist.github.com/213995...


Oct 21, 2009 at 12:23:07 AM
ddribin (0)

(Dave Dribin) < Cherub >
Posts: 11 - Joined: 10/19/2009
United States
Profile
This is definitely a difference between FCEUXDSP and Nestopia.  I compiled FCEUX on OS X, and it did not need the palette initialized.  I'll leave it in is it doesn't change anything on FCEU*.

I've put the code up on Bit Bucket:


I hope to add all the tutorials, ported to ca65, as I work through them.

-Dave



Edited: 10/21/2009 at 12:43 AM by ddribin

Oct 21, 2009 at 12:37:49 AM
udisi (88)
avatar
< King Solomon >
Posts: 3263 - Joined: 11/15/2006
United States
Profile
cool, I use NESASM3 and FCEU so, I couldn't be much help. I looked at your source and I didn't see any reason it shouldn't run. I thought maybe there might have been a difference between ca65 and NESASM, but nice to know it was just the emulator.

Oct 25, 2009 at 12:18:18 PM
ddribin (0)

(Dave Dribin) < Cherub >
Posts: 11 - Joined: 10/19/2009
United States
Profile
I've verified that the initial palette on Nestopia is not all zeros.  Take a look at the Nestopia source code in NstPpu.cpp:

static const byte powerUpPalette[] =
{
    0x3F,0x01,0x00,0x01,0x00,0x02,0x02,0x0D,
    0x08,0x10,0x08,0x24,0x00,0x00,0x04,0x2C,
    0x09,0x01,0x34,0x03,0x00,0x04,0x00,0x14,
    0x08,0x3A,0x00,0x02,0x00,0x20,0x2C,0x08
};

So to make this example work properly, the palettes should be cleared to zero first.

-Dave


Nov 12, 2009 at 6:57:36 PM
JohnB544 (0)

(John B.) < Cherub >
Posts: 2 - Joined: 11/12/2009
United Kingdom
Profile
.bank 0
.org $C000
;some code here
Is there any reason, that bank 0 is at memory location $C000, instead of $8000, where the cartige ROM starts?
.bank 2
.org $0000
.incbin "mario.chr" ;includes 8KB graphics file from SMB1
$0000 is the internal RAM, but there is only 2KB of RAM, and bank 2 is 8KB. And what about the CHR RAM? The graphics shouldn't be there?

Nov 12, 2009 at 7:15:06 PM
Zzap (47)
avatar
(James ) < King Solomon >
Posts: 3298 - Joined: 05/01/2007
Australia
Profile
You can have 16k of ROM space starting at $C000 or 32k starting at $8000.

The bank 2 here is referring to CHR ROM starting at $0000 in the PPU (note that the PPU and CPU memory are in different address spaces).

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

Chunkout for iPhone, iPad and iTouch out now!
Chunkout Games: FaceBook | Web

Nov 13, 2009 at 11:14:37 AM
JohnB544 (0)

(John B.) < Cherub >
Posts: 2 - Joined: 11/12/2009
United Kingdom
Profile
Originally posted by: Zzap

You can have 16k of ROM space starting at $C000 or 32k starting at $8000.

The bank 2 here is referring to CHR ROM starting at $0000 in the PPU (note that the PPU and CPU memory are in different address spaces).
Thank you, now I understand it.

Feb 5, 2010 at 1:11:19 AM
fireseed (0)

(Jason S) < Cherub >
Posts: 2 - Joined: 02/05/2010
United States
Profile
Would anyone know the reason why, when I make a save state on fcgeux, that the colors turn from green, where I have it now;

LDA #%11000000 ;intensify blues
STA $2001

Back to a dull gray.
I don't yet know how to bring the new save state back into a format that I can analyze in a text document like the original asm to see what has changed either...

You guys rock the rocks, btw.
Cheers!

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

Feb 5, 2010 at 9:17:29 AM
KHAN Games (88)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 7785 - Joined: 06/21/2007
Florida
Profile
I'm not really sure how save states work. I assume it just picks up the code from wherever it left off when you saved it. Perhaps it's just waking up in the infinite loop and bypasses all the loading stuff? I have no idea.

Feb 5, 2010 at 12:35:26 PM
fireseed (0)

(Jason S) < Cherub >
Posts: 2 - Joined: 02/05/2010
United States
Profile
Would there be a way to open it into the rom and the decompile it reanalyze the code in the save state to try to see exactly what changed where? Wouldn't Fceuxdsp be able to do this somehow?

P.S. I hope there's a tutorial coming up here on changing the palette more, cause I want to make my rom- yellow!

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

Feb 5, 2010 at 1:09:36 PM
udisi (88)
avatar
< King Solomon >
Posts: 3263 - Joined: 11/15/2006
United States
Profile
oh, the tutorials will do a lot more than that. I think week 4 does palettes, you'll probably never use the intensify line again. It's the most basic of things. Palettes are much more fun

Apr 3, 2010 at 4:33:51 AM
Farid (0)
avatar
(Farid Abbasi) < Cherub >
Posts: 15 - Joined: 04/03/2010
Iran (Islamic Republic of)
Profile
How can I make a NES ROM to support right to left language?
I don't have any problem for translating fixed text on the screen but texts which gradually appear from left to right, are really hard to translate.
Captain Tsubasa Arabic translation is a good example for this matter.
I guess I have to do it in assembly 6502 but I don't have any idea how to do it?
I appreciate anyone who can help me.

Also some other nice people guide me but I really need some more help :

http://www.romhacking.net/forum/i...

Jun 28, 2010 at 1:27:13 AM
nullending (5)
avatar
(Ethan Ferrell) < Eggplant Wizard >
Posts: 375 - Joined: 01/17/2010
Texas
Profile
Anyone know what the label NMI means for the vBlank section? Why NMI? Why not vBlank0 or something?

-------------------------
I am on a hiatus until further notice. Work and my loved one's health require my attention.

Jun 28, 2010 at 2:08:25 AM
NESHomebrew (20)
avatar
(Brad Bateman - Strange Brew Games) < King Solomon >
Posts: 4209 - Joined: 04/28/2008
Saskatchewan
Profile
Originally posted by: nullending

Anyone know what the label NMI means for the vBlank section? Why NMI? Why not vBlank0 or something?
http://wiki.nesdev.com/w/index.php/NMI

Aug 30, 2010 at 12:04:42 PM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
i have a question to the BNE/BEQ command. How can i figure out which adress the code passages have?

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!

Jul 9, 2011 at 7:06:11 AM
CMR (4)
avatar
< Meka Chicken >
Posts: 878 - Joined: 04/26/2008
United States
Profile
Sorry for the necropost, but I'm having trouble understanding why the banks begin where they do. In the sample code from the download link .bank0 starts at .org $C000, .bank1 starts at .org $FFFA, and .bank2 starts at .org $0000. Is .org specifying where to put the code in reference to the system's memory map or the cart rom's? $FFFA is too big a number for the 32KB cart, so I have to assume we're dealing with the CPU's memory map. And why does .bank0 start at $C000? Does it need to go there or did you just put it there because you wanted to? Also, the 32KB cart rom on the memory map from week 2 doesn't include the 16KB chr rom, correct? I'm thinking the chr rom is outside the CPU's memory map and can only be accessed by the PPU. Is that why the chr rom can start at $0000, because it isn't really a part of the CPU's memory map?

Thanks for the tutorials. Anymore help you or anyone else can give is greatly appreciated.

Jul 9, 2011 at 7:31:59 AM
thefox (0)
avatar
(Kalle Immonen) < Meka Chicken >
Posts: 533 - Joined: 07/08/2008
Finland
Profile
Originally posted by: CMR

Is .org specifying where to put the code in reference to the system's memory map or the cart rom's? $FFFA is too big a number for the 32KB cart, so I have to assume we're dealing with the CPU's memory map

What .org really is doing is hinting the assembler where the code will be placed when it is run, so that it can build the instructions correctly. So .org doesn't actually "place" the code anywhere.

Originally posted by: CMR

And why does .bank0 start at $C000? Does it need to go there or did you just put it there because you wanted to?

Since the ROM has 16KB PRG-ROM, and the PRG-ROM area is at 8000-FFFF, we know the ROM will be mapped both at 8000-BFFF and C000-FFFF (because of mirroring) when the code is executed. So really we're just telling the assembler where the code will appear, like said earlier.
It would be fine to use .org $8000 as well (and .org $A000 for the 2nd 8K bank), but it's somewhat easier to use $C000 (and $E000), because then the vectors will be placed correctly when using .org $FFFA.

Originally posted by: CMR

I'm thinking the chr rom is outside the CPU's memory map and can only be accessed by the PPU. Is that why the chr rom can start at $0000, because it isn't really a part of the CPU's memory map? 

That is correct. The .org doesn't really matter for this bank.


-------------------------
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Edited: 07/09/2011 at 07:32 AM by thefox

Jul 9, 2011 at 2:11:25 PM
CMR (4)
avatar
< Meka Chicken >
Posts: 878 - Joined: 04/26/2008
United States
Profile
Thanks for the reply. Is 16KB the maximum the prg rom can be? I was under the impression it could be a maximum of 32KB with 4 8K banks. Also why are things arranged in 8K banks? Is this just how NESASM likes to do it, or does the hardware need it that way for some reason.

Sorry for all the questions, but I would like to get this down before I move on. Thanks again.

Jul 9, 2011 at 2:21:26 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
NESASM just puts them in 8KB banks. You can put more data in it, but then you'll have to use a mapper, probably first off a logic mapper, then maybe MMC1 then if you get really good, MMC3.

Jul 9, 2011 at 11:26:48 PM
thefox (0)
avatar
(Kalle Immonen) < Meka Chicken >
Posts: 533 - Joined: 07/08/2008
Finland
Profile
Originally posted by: CMR

Thanks for the reply. Is 16KB the maximum the prg rom can be? I was under the impression it could be a maximum of 32KB with 4 8K banks. Also why are things arranged in 8K banks? Is this just how NESASM likes to do it, or does the hardware need it that way for some reason.

Sorry for all the questions, but I would like to get this down before I move on. Thanks again.

Yes, 32KB is the maximum without mappers. Then the data will appear at $8000-FFFF, unmirrored, so you should use .org $8000 and put it in 4 NESASM banks.

The 8K bank system of NESASM is completely arbitrary, no hardware requirements behind it. AFAIK the reason is that NESASM is based on a PC Engine assembler, and PC Engine used 8K banking internally.


-------------------------
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi

Dec 29, 2011 at 5:45:22 PM
DoNotWant (1)

(Ham Sammich) < Eggplant Wizard >
Posts: 440 - Joined: 12/08/2011
Sweden
Profile
Hello, I'm trying to get into assembly programming through NES development,
but I have some trouble understanding some stuff from your attached code. Please help me,
I really want to understand this before moving on.



01. RESET:
02. SEI ; disable IRQs
03. CLD ; disable decimal mode
04. LDX #$40
05. STX $4017 ; disable APU frame IRQ
06. LDX #$FF
07. TXS ; Set up stack
08. INX ; now X = 0
09. STX $2000 ; disable NMI
10. STX $2001 ; disable rendering
11. STX $4010 ; disable DMC IRQs
12. vblankwait1: ; First wait for vblank to make sure PPU is ready
13. BIT $2002
14. BPL vblankwait1



Line 02 - IRQ's have to be disabled if not used, but why?
Line 03 - Decimal mode not supported by the 2A03
Line 04.05 - Aren't address $4017 controller 2? How is that connected to the APU? What is so special
about the number $40?

Line 06.07 - $FF last memory location in stack, initialize stack to this value.
Line 08 - Increment $FF so it overflows and becomes 0.
Line 09.10.11 - Set all bits in address $2000, $2001 and $4010 to 0. The first two I understand
but what is a DMC IRQ, and why does it need to be disabled?

Line 12.13.14 - I know the PPU have to warm up before using it, but what exactly do these lines of code do?



Please someone, look through this and correct me where I'm wrong,
and help me understand this code. I'm new to the field of computer science,
but I got a book coming in the mail any day now that will introduce me to
boolean algebra and stuff like that, which, if I understand it correctly,
is essential to NES dev and ASM programming in general.
Sorry for the long post.

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


Edited: 12/29/2011 at 05:45 PM by DoNotWant