8x16 and whatever else unreg wants to know

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
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

unregistered wrote:What assembler did Nintendo use?
I don't know if anyone here has this information, but I assure you that whatever it was, it was worse than the options we have today. These kinds of applications do not age well. And even if you found a copy of it and really wanted to use it for some reason, you'd probably have to emulate it, since Nintendo didn't use PCs for development (I'm not even sure if there is an emulator for whatever computer they used).
unregistered wrote:and thank you Dwedit for mentioning ASM6... tokumaru like that one the best in 2009...
I still do! =) I usually recommend it because it's easy as hell to start using (meaning it's newbie-friendly enough), just like NESASM, but doesn't have the annoying bugs, limitations, and inconsistencies of NESASM.

Check this thread for some discussion about assemblers. It has a poll where people voted for their favorite assemblers.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

! have chosen asm6

2 quick questons. 1) In the Processor Status register could we store a 4 bit binary number for a short time in bits 6 through 3? Well, "Assembly In One Step" shows the bits of the Processor Status register... the 6th bit is set when an overflow of an addition or subtraction occurs, the 5th bit is never set/reset, the 4th bit is "...set if an interrupt caused by a BRK [and] reset if caused by an external interupt...", and the 3rd bit doesn't matter cause it is only changed by two instructions and it's a flag for decimal mode which is missing on the nes, i think. So, is bit 4 the most changed-at random-times bit 'cause it is affected by interrupts? I dont understand "interrupts" much; what are they (and does bit 2 of the Processor Status register kindof disable the random-change-ness of bit 4?)? I'm floored and so excited that we can probably access the Processor Status register with PLP+PHA and PHP+PLA!!!!(just reread the kim1-6502 Appendixes and noticed that it says "Push Processor Status on Stack" and "Pull Accumulator from Stack" and PLP and PHA AND "Assembly In One Step" calls the fourth register "Processor Status")!!!!!21 !!!!!!!!!!!!!!!!!!!!!!!!!!!!! :shock:
2) Um.. i dont remember my second question ...sorry :oops: (i'll respond to yalls previous posts, maybe later... good night. : )
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Bits 5 and 4 do not exist inside the CPU. Bit 4 exists only in the byte pushed out to the stack. Bit 3 (decimal mode) exists even though it doesn't affect the adder, and it can be used to store one bit, but it's not practical. Bit 6 (overflow) will be wiped out after the next ADC, SBC, or BIT instruction.

The most reliable source of randomness on the NES is the time since power on, mixed up with some sort of hashing function.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tepples wrote:Bits 5 and 4 do not exist inside the CPU. Bit 4 exists only in the byte pushed out to the stack. Bit 3 (decimal mode) exists even though it doesn't affect the adder, and it can be used to store one bit, but it's not practical. Bit 6 (overflow) will be wiped out after the next ADC, SBC, or BIT instruction.

The most reliable source of randomness on the NES is the time since power on, mixed up with some sort of hashing function.
woah ok, tepples, thanks for that info! :) And how do you access the time since power on? That's interesting.

tokumaru wrote:
unregistered wrote: wrote:
What assembler did Nintendo use?
I don't know if anyone here has this information, but I assure you that whatever it was, it was worse than the options we have today. These kinds of applications do not age well. And even if you found a copy of it and really wanted to use it for some reason, you'd probably have to emulate it, since Nintendo didn't use PCs for development (I'm not even sure if there is an emulator for whatever computer they used).
I didn't ever think about that Nintendo might not use PCs for development. The only other choice i can guess is maybe they used macs?
tokumaru wrote:Check this thread for some discussion about assemblers. It has a poll where people voted for their favorite assemblers.
Thank you. :)

3gengames wrote: I don't know if any other assemblers offer this, but NESASM also can include other files.
ASM6 has INCLUDE and INCBIN. :) There is more explanation of the entire ASM6 in README.TXT... it's a really good explanation. :)
3gengames wrote:If you want more help feel free to mail me, I'd be interested in learning a new assembler, too.
You are so kind - thank you, but the included README.TXT help is really excellent! And there's a whole strong ASM6 user group here. :) And, asking basic questions in this forum can also help others. Do you agree?
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

unregistered wrote:I dont understand "interrupts" much; what are they
They interrupt (hence their name) the program in order to run some other piece of code. Important events generate interrupts because such events need to be handled right away. For example, if NMIs are enabled, this interrupt will fire when VBlank starts. The start of VBlank is an important event, so it makes sense to interrupt whatever the PPU is doing so that the full duration of VBlank can be used for VRAM updates. Scanline interrupts are also important, because they fire at the exact moment that a certain scanline is being rendered, so if you want to do some kind of raster effect at that location you have to immediately respond to the event.

When an interrupt occurs, the program counter and the status flags are pushed to the stack, so that when the interrupt handler is over the CPU can resume whatever it was doing, without even realizing it was interrupted. If you need to modify any registers inside the interrupt handlers, you have to back them up to the stack and restore them after returning, or else the code that was interrupted will most likely crash.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

unregistered wrote:
tepples wrote:Bits 5 and 4 do not exist inside the CPU. Bit 4 exists only in the byte pushed out to the stack. Bit 3 (decimal mode) exists even though it doesn't affect the adder, and it can be used to store one bit, but it's not practical. Bit 6 (overflow) will be wiped out after the next ADC, SBC, or BIT instruction.

The most reliable source of randomness on the NES is the time since power on, mixed up with some sort of hashing function.
woah ok, tepples, thanks for that info! :)
Had you tried searching wiki.nesdev.com?
And how do you access the time since power on?
Make a variable, clear it to 0 at reset, and add 1 to it in your NMI handler. Then 60 times a second (or perhaps 50 times a second depending on the particular console's TV system), the variable's value will increase by 1.
tokumaru wrote:Nintendo didn't use PCs for development (I'm not even sure if there is an emulator for whatever computer they used).
I didn't ever think about that Nintendo might not use PCs for development. The only other choice i can guess is maybe they used macs?
In the 1980s, there were more platforms than just PC and Mac. I seem to remember that Nintendo used Apple IIGS computers for first-gen Super NES development because native 65816 assemblers were available and programmers could run unit tests on the same architecture. But after that generation, the next generation devkit (Mirage) appears to have run on a Mac, and this other article appears to agree.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

Thank you tokumaru! :D
tepples wrote:
unregistered wrote:
tepples wrote:Bits 5 and 4 do not exist inside the CPU. Bit 4 exists only in the byte pushed out to the stack. Bit 3 (decimal mode) exists even though it doesn't affect the adder, and it can be used to store one bit, but it's not practical. Bit 6 (overflow) will be wiped out after the next ADC, SBC, or BIT instruction.

The most reliable source of randomness on the NES is the time since power on, mixed up with some sort of hashing function.
woah ok, tepples, thanks for that info! :)
Had you tried searching wiki.nesdev.com?
No, not really, since it can be changed by anyone... a friend had a bad experience with the wikipedia. But, that one says not everyone can change it?! :shock: Thank you for mentioning it! :) Now I'm learning from this page http://wiki.nesdev.com/w/index.php/PPU_OAM

Also, maybe yall could add this... it's my sketch of the memory and it should print out on one page (uncheck the "Enable Shrink-to-Fit" box, i think) Hope it helps someone, yall can read it, and maybe use it on the wiki. It's old... and i misspelled Pallets "Paletts" sorry. :oops:
tepples wrote:
And how do you access the time since power on?
Make a variable, clear it to 0 at reset, and add 1 to it in your NMI handler. Then 60 times a second (or perhaps 50 times a second depending on the particular console's TV system), the variable's value will increase by 1.
Thanks :D, it's always fun to find out how to do nes programming for me.
tepples wrote:
tokumaru wrote:Nintendo didn't use PCs for development (I'm not even sure if there is an emulator for whatever computer they used).
I didn't ever think about that Nintendo might not use PCs for development. The only other choice i can guess is maybe they used macs?
In the 1980s, there were more platforms than just PC and Mac. I seem to remember that Nintendo used Apple IIGS computers for first-gen Super NES development because native 65816 assemblers were available and programmers could run unit tests on the same architecture. But after that generation, the next generation devkit (Mirage) appears to have run on a Mac, and this other article appears to agree.
WOW cool! 8)
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

unregistered wrote:[usually a wiki] can be changed by anyone... a friend had a bad experience with the wikipedia. But, that one says not everyone can change it?! :shock: Thank you for mentioning it! :)
The trusted group is given to anyone with a couple dozen on-topic posts on the BBS who has PM'd me requesting access. But even if it were as open as it used to be, I still check recent changes daily to revert vandalism.
Also, maybe yall could add this... it's my sketch of the memory
Great minds think alike; someone else had the same idea. See CPU memory map and PPU memory map.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tepples wrote:
unregistered wrote:[usually a wiki] can be changed by anyone... a friend had a bad experience with the wikipedia. But, that one says not everyone can change it?! :shock: Thank you for mentioning it! :)
The trusted group is given to anyone with a couple dozen on-topic posts on the BBS who has PM'd me requesting access. But even if it were as open as it used to be, I still check recent changes daily to revert vandalism.
Also, maybe yall could add this... it's my sketch of the memory
Great minds think alike; someone else had the same idea. See CPU memory map and PPU memory map.
Ah ok, thanks tepples :)
yesyesyall
Posts: 28
Joined: Sat Mar 05, 2011 3:17 pm
Location: Houston, Texas

Post by yesyesyall »

hey, unregistered (OP), i am from houston. http://www.reddit.com/r/nesdevhouston/
check it out. it's empty right now. join up! i'm trying to find out who all is into nesdev in houston and the surrounding areas. maybe we can get a meetup going?

edit: i realize this is a sort of strange first post. i have been lurking for a little bit, though.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

^ yesyesyall, sorry, I'm uncomfortable to meet with you. :oops:
---------------------------------------------------------------------------

And so my question (edit: wait for it:)) to all of the asm6 user people: I'm trying to quote
tokumaru wrote:It may seem strange if you are doing it in a hardcoded way (manually setting up all the sprites of a particular object), but usually programmers implement a sprite system. For each possible frame of a character there is a list of the necessary sprites to draw it. It's just a series of .db or .dw statements that represent things like "this frame needs 4 sprites; the first one is at coordinates (4, 5) and uses tile $78; the second is at coordinates (12, and 8) uses tile $79 (...)". The coordinates are usually relative to the position of the object/character being drawn. This means that the sprite system can draw any frame of any character if you point it to the correct list.
from this thread. btw, thread starts at 0. Not 2.

I am worrying about not being able to set a variable inside the series of .db statements.... i want something like

Code: Select all

aY .byte 10
aX .byte 20
.db aY, $80, $00, aX, aY, $81, $00, aX +1
Do you all think that will work? im getting excited now... thinking it may be possible!
Last edited by unregistered on Mon Mar 28, 2011 3:37 pm, edited 2 times in total.
User avatar
qbradq
Posts: 972
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

That almost works. What you are looking for is the "EQU" assembler directive. From the ASM6 documentation:

Code: Select all

EQU

        For literal string replacement, similar to #define in C.

                one EQU 1
                plus EQU +
                DB one plus one ;DB 1 + 1
So your example above becomes:

Code: Select all

aY EQU 10 
aX EQU 20 
.db aY, $80, $00, aX, aY, $81, $00, aX +1

Remember, the .byte and .db directives emit a byte of data into the output ROM file. The EQU directive (and it's cousin, the = operator) create symbols within the assembler that you can use latter on.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

qbradq wrote:That almost works. What you are looking for is the "EQU" assembler directive. From the ASM6 documentation:

Code: Select all

EQU

        For literal string replacement, similar to #define in C.

                one EQU 1
                plus EQU +
                DB one plus one ;DB 1 + 1
So your example above becomes:

Code: Select all

aY EQU 10 
aX EQU 20 
.db aY, $80, $00, aX, aY, $81, $00, aX +1

Remember, the .byte and .db directives emit a byte of data into the output ROM file. The EQU directive (and it's cousin, the = operator) create symbols within the assembler that you can use latter on.
Thank you qbradq! :D
What are symbols? :? :) Does that mean that symbols are variables that dont exist in the ROM? :)
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Symbols are just "nicknames" for numbers. These numbers can represent memory locations (which is the case of labels and variables) or numeric constants (values you commonly use throughout the program).

They exist only in the source code to make programming easier (just imagine if you had to remember the addresses of everything!), they do not exist in the assembled program.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

Thank you tokumaru! :D That, symbols, si awesome! :)

edit: I've started with asm6... and the NES 101 tutorial by... Michael Martin. There is a file i made for the ... vblank part; and am trying to transfer all the vblank code to it. Started with just the three lines:

Code: Select all

jsr scroll_screen
jsr update_sprite
jsr react_to_input
rti
anddd, it worked!!! :D The ... links seem to work through different files! Amazing! And... don't remember what i was thinking, sorry
...[/code]

OH! I don't know if the code for the sound file thing should be copied over to the vblank part cause even though there is a link from the react_to_input code to it, it is still not vblank ppu code... is it? No, i dont think it is, because that's part of the CPU... it is also a pAPU pseudo-Audio Processing Unit! So even though it seems to .... not "link"... link to the Audio code it's not part of vblank, right? :?
Post Reply