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
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Sound, debugger, free: pick two

Post by cpow »

tepples wrote:NESICIDE for Linux runs at less than full speed on my machine and therefore also lacks sound

cpow is the developer of NESICIDE, an emulator containing such a debugger.
I won't hijack this thread I'll just mention that there have been some discoveries [thanks lidnariq, torrasque] regarding the poor performance on Linux. Having said that, the minimum system requirements are still pretty high yet.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tokumaru[color=green], on [url=http://nesdev.com/bbs/viewtopic.php?p=94670#94670]page 37[/url], [/color] wrote:Personally, I always use writes to $FF as breakpoint triggers, so all I have to do is "sta $ff" at the point I want to debug.
How could I do that too? ...with FCEUX. :)
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Post by Kasumi »

Put 00FF in the address box of the add breakpoint dialog, then check the "write" box.

In your code, add an sta $FF before the routine you want to check.

Edit: Forgot to say, that's a pretty great idea, Tokumaru. I always just used to use odd opcodes.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

Kasumi wrote: Put 00FF in the address box of the add breakpoint dialog, then check the "write" box.

In your code, add an sta $FF before the routine you want to check.
Kasumi, thank you! :D I'm really happy for the help, but im a little confused to... what do yall do next that helps you? I only know about pressing "Run" and nothing happens. :?
Last edited by unregistered on Thu Jun 07, 2012 9:55 am, edited 1 time in total.
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames »

You have to use the step into button to step 1 line of a code at a time. Pressing RUN will run the program until that break point is hit again, not allowing you to see anything that is wrong.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

3gengames wrote:You have to use the step into button to step 1 line of a code at a time. Pressing RUN will run the program until that break point is hit again, not allowing you to see anything that is wrong.
Ah, thank you 3gengames! :D This is becoming awesome! ...I didn't know what the step into button did. :oops: Thank you so much Kasumi and 3gengames! :D

edit: Step Into rocks! It's so helpful! :D hahaha I used to make breakpoints that ran to $FFFF so the Run button would keep working. :P (<-- me looking silly) :lol: :)
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

ok in my code there is

Code: Select all

	lda rc_upleft
	sta screenArray,x
	lda rc_upright 
	sta screenArray+1,x
and so there is another part where I would like to try something like

Code: Select all

lda (rhombusCollision_low+1), y
but there are many questions I have
1.)Does the +1 only work on one group stas or on both stas and ldas?
2.)Is (this)+1,y possible?
3.)Is (this+1),y possible?

ok, it fit all into 3 questions... :oops:
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Post by Shiru »

screenArray is a label that represents an address. Labels allow you to not care about actual physical addresses, assembler takes care on it. +1 etc is added to the address that is calculated by assembler for a label. So you can use it anywhere you could use an actual address, and it works exactly the same as for an address.

Like, sta $4000+1 is the same as sta $4001; if label=$4000, sta label+1 will be the same as sta $4001.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

Shiru wrote:screenArray is a label that represents an address. Labels allow you to not care about actual physical addresses, assembler takes care on it. +1 etc is added to the address that is calculated by assembler for a label. So you can use it anywhere you could use an actual address, and it works exactly the same as for an address.

Like, sta $4000+1 is the same as sta $4001; if label=$4000, sta label+1 will be the same as sta $4001.
Wow, Shiru, great explanation! I really understand the +1 etc thing now; thank you so much! :D

just added
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

unregistered wrote:2.)Is (this)+1,y possible?
3.)Is (this+1),y possible?
These will probably assemble, but they will not work like you think. LDA (this)+1, y will most likely become LDA this+1, y, and LDA (this+1), y will use half of your pointer along with the next byte and form an invalid pointer, causing you to access garbage data.

To do what you want you'll either have to use 2 pointers (one of them pointing one byte ahead of the other), or increment Y or the low byte of the pointer between the two accesses. Indirect addressing on the 6502 is not as flexible as you'd like.
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames »

As long as This is a set value and not a RAM location, 2 will not work and 3 will. If This is a RAM value, neither will work as you just can't do that. And remember, since that's a word sized pointer, you may be needing to do +2 to move to the next pointer, keep that in mind! :)
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

If you have an array of pointers on zero page, LDA (d,x) might be your best bet. It didn't get much use on a lot of 6502-based home computers because the built-in BASIC interpreter ate up a lot of zero page.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tokumaru wrote:
unregistered wrote:2.)Is (this)+1,y possible?
3.)Is (this+1),y possible?
These will probably assemble, but they will not work like you think. LDA (this)+1, y will most likely become LDA this+1, y, and LDA (this+1), y will use half of your pointer along with the next byte and form an invalid pointer, causing you to access garbage data.
:( Thank you though for being brave and explaning to me the truth about my second and third question. I just coded a solution yesterday thinking the other two questions weren't important. Thank you tokumaru! :D
tokumaru wrote:To do what you want you'll either have to use 2 pointers (one of them pointing one byte ahead of the other), or increment Y or the low byte of the pointer between the two accesses. Indirect addressing on the 6502 is not as flexible as you'd like.
Sorry, I dont understand this right now... but, maybe that'll be ok if one of the 2 ideas below becomes possible. :) If not, I'll swing back to learn this.
3gengames wrote:As long as This is a set value and not a RAM location, 2 will not work and 3 will. If This is a RAM value, neither will work as you just can't do that.
3gengames, thank you for explaining this. :D I don't think I could use a set value though because I'd have to recalculate it every time I added a line of code before it. Maybe I'm wrong about that? I dont know. :?
tepples wrote:If you have an array of pointers on zero page, LDA (d,x) might be your best bet.
Really?! :o 4.)Is LDA (this+3, x) possible?
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames »

unregistered wrote:
tepples wrote:If you have an array of pointers on zero page, LDA (d,x) might be your best bet.
Really?! :o 4.)Is LDA (this+3, x) possible?
Yes, as long as This is a ROM location that doesn't change (when compiled, not over the projects whole creation) then that would work. But, the thing you're missing is if you have a lot of pointers in zero page, then you need to just do the begging of the array+X to point to one, because that's what it does. If you have 3 pointers in an array, you can select any of the three by putting in the code LDA (ZeroPageArray,X) because it takes the array location, adds X to the pointer of it, then gets wherever THAT points to. :) If I could make something up in paint I would, but I'm too slow and my graduation party is begging in 2 hours. :P Think of it as a normal array (LDA Array,X) then then whatever that points to, it then looks at it. Remember, each pointer is 2 bytes so moving 1 byte ahead in the array will mean you have to either do a INX INX or a ASL A if you do a TAX to get X to something you need.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

unregistered wrote:Is LDA (this+3, x) possible?
It is, but again, I don't think it will do what you want. The ($XX), y addressing mode is meant for accessing an array through a pointer, while ($XX, x) is meant for using arrays of pointers. In the first case, the index register (Y) indexes the targeted data, in the second case, the index register (X) indexes a pointer in an array of pointers.

The reason why ($XX, x) is rarely used is because it can't index the target data in any way. Once the address of the pointer is calculated ($XX + x) and the pointer is used, the target is a single byte. There's no way to access any bytes after that one. If you do wish to access the next bytes, you have to manipulate the pointer itself (INC the lower byte, if it overflows INC the higher byte), which is terribly slow.

The +offset trick works with absolute addressing because the assembler calculates the absolute address for you based on the offsets you give it. With indirect addressing it's different, because it's not the assembler that will calculate the final address of the data, it's the CPU that will do it as the program runs. For this reason, if you try to use offsets they will not affect the final address, but rather the address of the pointer. I'm pretty sure that this is not what you want.

It seems you are a bit confused about the addressing modes, so I suggest you play a bit with ($XX, x) and ($XX), y using the 6502 simulator until you understand how they work.
Post Reply