Working on ASM Tutorials! (Episode 4 out now!)

Rob Burrito

New member
sounds fun with the templates. writing them from scratch helps with critical thinking, and of course the goal. but if you were getting a bunch of them to look at i could see the template being much easier to review. i actually didn't know you could just keep hitting run, so still learning there. in the meantime made myself learn address definition labels. also realized i have an extra line for "start:" that i don't need since i never jump or branch to it. teaching can be tough with how specific you have to be, i appreciate you taking the time to put it together, look over exercises and respond!
 

chronosv2

New member
Well, I've had situations where run worked multiple times and cases where it did not, so I made the template so that as long as a user fills in their code where specified it will always work. Users don't have to work with anything out of the scope of what I've taught them (except for JMP but I thought it was simple enough that it wouldn't cause a problem. You can also watch the memory value change each time you click run, and maybe I'm a little strange but I like that interactivity.

As for responding to challenges and questions, over my lifetime I've had a number of teachers that just did the bare minimum, and I feel like I could have learned just as well with a few supplementary books on my own, if not better. I have no training as a teacher but I take a little pride in the fact that I value passing on knowledge, and it's hard to grow when your questions and missteps go unanswered.
 

chronosv2

New member
For anyone interested, the next part is out! I'm starting to feel a little more comfortable doing this. Still some moments of silence and "Um" or "Uh" but I feel like I'm getting used to it!
 

Rob Burrito

New member
thanks for the new tutorial! definitely helps get a better grasp on what is happening with assembly. appreciate you taking the time to run through this and make the videos/challenges! only question i have is i noted the exercise location for the first two tutorial challenges start folks at $0100, isn't that something to be avoided as a starting point since $0100-$01FF dedicated to stack memory on the NES? still not 100% sure on stack usage techniques so might be fine haha, just curious there.

Code:
define AndLoc $0100
define OrLoc $0101
define XorLoc $0102

LDA #%10010011
AND #%11100010
STA AndLoc
CMP #$82
BNE overwrite 

LDA #%10100011
ORA #%11100111
STA OrLoc
CLC
CMP #$e7
BNE overwrite

LDA #%11110011
EOR #%11111111
STA XorLoc
CLC
CMP #$0c
BNE overwrite
JMP noOverwrite

overwrite:
LDA #$FE	
STA AndLoc
STA OrLoc
STA XorLoc

noOverwrite:
BRK

comments welcome!
 

chronosv2

New member
Nicely done on the challenge! You even went and used conditions, which I hadn't expected. My solution to this challenge is a whole lot simpler. Haha.

As for storing things in the memory locations I am, you're correct.
I really shouldn't be storing things in those locations. I think that's actually the general 6502 stack location.
When we're working with NESMakr and ASM6 the assembler typically allocates memory for us when we create variables. There might be cases where we'll have to make our own allocations but when I looked at a RAM dump of a NESMaker game, I noticed the Zero Page had a lot of information stored inside of it, so I didn't think it was safe to try and put anything there.

I'll keep in mind for the challenges in the future to just use the Zero Page. Easier and less work to get the memory monitor showing that, anyway.
I also just realized I can edit the templates and the page to not do that, so it won't cause confusion in the future.

Edit: Fixed it so I'm not interfering with the Stack anymore. Thanks for the catch!
Edit 2: I just tested something Stack-related. Technically my code would be fine so long as the Stack never ended up 253 entries long. When you push entries to the stack it starts at $01FF and goes backward. So in the case of Challenge 2 if you had 253 stack entries you'd start overwriting the variables.
 

Rob Burrito

New member
sweet, wanted to mention the new template was super easy to work with coming from the easy6502 site. if anything too easy haha. there's not much out there in the form of exercises relevant to nes games or game making in general, so these are really helpful getting some understanding of how the commands are relevant to games. looking forward to more, and thanks for the follow up on some stack insight!
 

chronosv2

New member
Rob Burrito said:
sweet, wanted to mention the new template was super easy to work with coming from the easy6502 site. if anything too easy haha.
There are three reasons why I approach the challenges the way I do. The templates are the way they are so that a person following my tutorials doesn't have to stray too far from what I've already taught. Once I've covered the important commands then the challenge templates might start looking like the following:
Code:
define SolutionVariable $00
;Write the solution to the challenge here.
At least, as long as we're covering the basics. Once we get into NESMaker specific stuff the challenge site will have pages without the simulator, instead having blocks of ASM code to download or copy into a file for use with NESMaker itself. I guess then I'll still be asking people to post their ASM code here, but then I'll be plugging each person's work into NESMaker to see if it works as the challenge suggests.
The second reason is the fact that I'm trying to keep these accessible for people that have never written a line of code in their lives. NESMaker is attracting a lot of non-coders, and I want to show people that the coding part isn't nearly as scary and intimidating as they seem to think.
The last reason is honestly the most damning of them, and that reason is that I honestly have zero teaching experience. I've tried to help people learn things in person (I'm my family's techie), but I've never tried teaching a programming course, so I really have no idea how much exposition is optimal for people to get the most out of this without causing non-coders to feel overwhelmed.

Rob Burrito said:
there's not much out there in the form of exercises relevant to nes games or game making in general, so these are really helpful getting some understanding of how the commands are relevant to games.
As soon as NESMaker 4.1.0 comes out I'll open the gates to NESMaker specific code. After I cover this last basics episode my plan was to start digging deeper NESMaker's code, but I don't want to do that when large blocks of code are going to change. It'd be really bad to tear down and write new scripts only for people to encounter this in the future and it not make any sense because the code-base is entirely different.

Rob Burrito said:
looking forward to more, and thanks for the follow up on some stack insight!
I'm glad you're enjoying the tutorials! I'm very glad to be making them. I hope these tutorials help prove that if someone who's not even been using 6502 ASM for two months can learn and begin teaching it, anyone who wants to put forth the effort can do it. I've actually been testing all of the presentations on a friend of mine who I'd consider a non-coder to get feedback on where parts are confusing or where I've worded something poorly.

As for the information on the Stack, curiosity is one of my main driving factors. I didn't know the answer to that myself so I decided I'd try it out and see what I found out. :D
Thank you very much for the input!
 

chronosv2

New member
The next episode is up! And I seem to be "Um" and "Uh"-ing less, too!
Looks like I'm getting used to things.
Sorry this one took so long! Lots of distractions and other stuff coming up.
I'll upload a video covering the solution to the second challenge soon.
 

Kasumi

New member
The division routine in the video gets the wrong result if the repeated subtractions do not result in exactly zero.

10/3=3. That routine gets 4.
Code:
ldx #$00
divideLoop:
inx;x is now 1
sec
sbc #3;A is now 7
beq divideDone
bcc divideDone
jmp divideLoop
inx;x is now 2
sec
sbc #3;A is now 4
beq divideDone
bcc divideDone
jmp divideLoop
inx;X is now 3
sec
sbc #3;A is now 1
beq divideDone
bcc divideDone
jmp divideLoop
inx;X is now 4
sec
sbc #3;A is now -2
beq divideDone
bcc DivideDone

This should work:
Code:
ldx #$FF;Start at one less than zero because there will always be one loop
sec
divideLoop:
inx
sbc temp
bcs divideLoop
And it's faster per loop as well. To get the remainder you add temp after the loop.

You can also speed up the multiplication loop but it doesn't get the wrong result so long as X isn't zero which isn't really worth making a special case for.
 

chronosv2

New member
Oh. I'll take that down and remove it. I apparently didn't know what I was talking about.
Probably why someone who has only 2 months of experience with ASM shouldn't be covering algorithms yet.

Thank you for the catch!

I'll be temporarily taking down the video (Thanks, YouTube, for taking away annotations!), and where the erroneous slide was I'll link to your response here.
Edit: Video is back up, the erroneous slide has been replaced with a screen directing users to your post.
 
Hi Kevin S, I'm Kevin R. Will check out more of your video series here shortly, looks good.
I have a similar series of ASM videos on youtube and will be getting back to them as they were a great way to motivate me to learn. https://www.youtube.com/watch?v=AjN06WqFpeo&t=2s I was basically just using this book https://archive.org/details/6502_Assembly_Language_Programming
I haven't yet played with my NES maker, been busy and now I've decided I need to learn Blender which is similar to other 3D programs I've used so it's actually pretty easy going so far. Will probably be getting back to ASM learning and NESmaker in the new year. :) Love seeing the games in development!
 

chronosv2

New member
So now that I've got the generic ASM stuff out of the way, what's the first thing people would like to see me program for NESMaker?
Dissect some engine code? Code something simple from scratch?

Or I could dissect some of my own scripts and show off how I got them to work.

Any input would be appreciated!
 

Dirk

Member
chronosv2 said:
Or I could dissect some of my own scripts and show off how I got them to work.

That would be of course interesting. I would also be interested in how to change the bounding box for dodging or when the player would get shrunk.
 

chronosv2

New member
I believe the bounding box is stored in a collision table and would be very difficult (if not impossible) to modify in realtime -- I think that's why people use "object swapping" to do ducking. It eats up a GameObject but it's better than nothing.
I'll ask around about the object swapping method though. If that answers the question sufficiently I could try and teach people about that.
 

Dirk

Member
chronosv2 said:
I'll ask around about the object swapping method though. If that answers the question sufficiently I could try and teach people about that.

That sounds interesting. I'd like to try that, but I have no clue how to.
 

Dirk

Member
Oh, I had an idea for a HUD. Instead of a permanent HUD having the remaining hearts shown above the player when he gets hit and then disappearing after 1 second or so and maybe have the score only displayed when points are being collected.
 

Rob Burrito

New member
chronosv2 said:
Code something simple from scratch? Or I could dissect some of my own scripts and show off how I got them to work.

i'd like to see either of these^ wouldn't worry about taking apart the game engine till folks are alittle further along. Challenge 3 i'm still working on, hope to get it soon!
 
Top Bottom