Skip navigation
NintendoAge
Welcome, Guest! Please Login or Join
Loading...

Learning Assembly with KHAN (Adversary Development) Updated with new stuff!

Sep 19, 2013 at 8:56:55 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
I really really want to make NES games. I have lots of ideas for RPG's fleshed out on paper, and have designed pen and paper games before, but my true love are video games. I tried using the Nerdy Nights approach but I had a lot of trouble retaining any of the information I was looking at. I expressed my dire exasperation to KHAN Games one day and he offered to help me out with some one on one internet time and some personalized lessons. 

I wanted to keep a record of what I am learning here. Please note that so far, while this method is working for me, it might not work for everyone else! Khan told me to say that if anyone is interested in these lessons, to PM him for the files.

I HAVE NO IDEA WHAT WEEK IT IS ANYMORE: I've been busy. Let me first say though that Assembly is really hard, and KHAN has been really a lifeline in the development of this game. The sprite is now nearly fully functional. All that needs to be done is to allow him to climb down ladders, probably will be most tiles though first as me and KHAN have to kink out the collision code still. I redesigned the level so it looked better, and added a status bar to the top! 



WEEK FOUR: JUMPING SPRITES AND CODE CONSOLIDATION (FLAGS, TIMERS, & REGISTERS)

This week, I used my knowledge of subroutines to write and make some more to make my character jump. Earlier I had posted in the brewery with a question, at my first attempt at writing a subroutine without week 4's lesson in my possesion. I couldnt figure out why my routine wouldnt make my sprite jump, though through the use of timers, I was able to figure out how to make the sprites wait till they got to a certian y posistion and come back down. You can read all about that here http://nintendoage.com/forum/messageview.cfm?catid=22&th...

We also went over how consolidate code, I dont feel as comfortable converting all my code yet since I understand it in longform, but I think I get the main concept. Apart from the A register that I've been using so far, the NES has 2 other registers it can track, X & Y. This means there are 3 registers so I can use more than one register to consildate my code. Right now, it kind of looks like this: 

SampleRoutine:
  LDA $0300
  CLC
  ADC #$01
  STA $0300
  LDA $0304
  CLC
  ADC #$01
  STA $0304
  LDA $0308
  CLC
  ADC #$01
  STA $0308
  LDA $030C
  CLC
  ADC #$01
  STA $030C
  RTS

But with registers and subroutines, we can consolidate that and make a loop where we assign the vertical pos to the x register and incriment it 4 times. 

SampleRoutine:
  LDX #$00
.Loop:
  LDA $0300,x
  CLC
  ADC #$01
  STA $0300,x
  INX
  INX
  INX
  INX
  CPX #$10
  BNE .Loop
  RTS

What kind of makes this stuff so confusing is that this language of assembly is miserable. I'm taking python classes on the weekend and I am now at least sure after I master assembly python will be a piss in the pond

WEEK THREE: Subroutines Subroutines Subroutines:

This week was probably the most challenging of the lessons so far. My task was to animate my sprite so that it would walk foward convincingly with the little sprite animations I drew. I had to animate my sprite to walk right & left, and then for homework I had to get my guy to swing his sword with the B button. 

Here is the Subroutine I wrote to animate the walking. 

AnimateSpriteRight:    ;title of our subroutine (named very obviously so we can find it later)
  LDA RunTimer         ;load RunTimer variable
  CMP #$08             ;compare to $08
  BCC .Frame1          ;if it's less than $08, branch to .Frame1
  CMP #$10             ;compare to $10
  BCC .Frame2          ;if it's less than $10, branch to .Frame2
  CMP #$18             ;compare to $18
  BCC .Frame3          ;if it's less than $18, branch to .Frame3
  CMP #$20             ;compare to $20
  BCC .Reset           ;if it's less than $20, branch to .Reset
  RTS                  ;it will only get to this "RTS" if it is $20 or greater
.Frame1:
  INC RunTimer         ;constantly increment the RunTimer variable every frame
  LDA #$00             ;replacing the tiles of our sprites
  STA $0301
  LDA #$01
  STA $0305
  LDA #$02
  STA $0309
  LDA #$10
  STA $030D
  LDA #$11
  STA $0311
  LDA #$12
  STA $0315
  RTS
.Frame2:
  INC RunTimer         ;same as .Frame1, but with different tiles. It only gets to here
  LDA #$03             ;when the timer variable is at a different value.
  STA $0301
  LDA #$04
  STA $0305
  LDA #$05
  STA $0309
  LDA #$13
  STA $030D
  LDA #$14
  STA $0311
  LDA #$15 
  STA $0315
  RTS
.Frame3:
  LDA #$06
  STA $0301
  LDA #$07
  STA $0305
  LDA #$08
  STA $0309
  LDA #$16
  STA $030D
  LDA #$17
  STA $0311
  LDA #$18
  STA $0315
  INC RunTimer
  RTS
.Reset:                ;when it makes it down to the .Reset subroutine (the timer is between $19
  LDA #$00             ;and $20, right?) it resets the variable to $00 and starts over!
  STA RunTimer
  RTS

And Then I learned by using Variables, it was super easy to finish my homework! Was able to map the B button using the same techniques I learned to swing a sword. Happy with the progress this week! 


I also picked up the book learning assembly step by step that was reccomended by other members on here, so far, really enjoying it! I am hoping that we get to collision next week...


WEEK TWO: SPRITES AND BACKGROUNDS.

Another Update: I worked on my sprites some more. Happy with the way stuff is coming. 


Update: I finished my lesson for this week. This time we built a background using tools Shiru and Zzap made. This was really challenging, but it cemented in my mind how hex numbers work, and also taught me the joys of the programmers calc on windows 7.



The most challenging part was getting all 4 sprites to move with the controller, but it was good for me to go over the work from last week's lesson as I think it was important for cementing that way of thinking, before we get heavy into programming next week.  

Since I finished the lesson the day I got it, my goal for this week is to beautify and embelish these background tiles a bit and play some Wind Waker HD. 

There should be an updated learning.nes file attached but its not showing up on the post, mayhaps a mod can help? END OF UPDATE. 

I havent gotten the next week's lesson yet, but I have started work on it. I drew some sprites in TLP.
 (my gf advised me not to post to much, but people here wouldnt steal would they? I have way more I worked on tonight)

And I also drew out a level, KHAN said it was a little complicated, but we will make do


I still have to make a sample background tile so we can put that on a screen and have my sprite walk around it! Exciting! 

Most importantly, I have a concept and name for my game now, its called, Adversary. Got the name from member arch 8ngel.

WEEK ONE: GETTING SOMETHING ON THE SCREEN AND MOVING IT AROUND.

So my goal for the first week was to draw a sprite, get it on the screen, and then move it around using a controller. 



I got Tile Layer Pro and drew up this little sprite. Later, I got it to move around on the screen after writing my first subroutine! 

MoveSpriteUp:
  LDA UpHeld  
  CMP #$01  
  BNE .End
  LDA $0300
  SEC
  SBC #$01
  STA $0300
.End:
  RTS

That was exciting! I feel like I am starting to understand what these things are doing now. The bottom is the final product, I was also able to make this .nes file work on my Everdrive! I would post the rom file I made but I dont want to get in trouble

Edit: I've been told I wont get in trouble. Rom file is attached!



NEXT WEEK: BACKGROUNDS! 



-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins




Edited: 12/02/2013 at 08:45 AM by pk space jam

Sep 19, 2013 at 9:46:34 AM
arch_8ngel (68)
avatar
(Nathan ?) < Mario >
Posts: 35263 - Joined: 06/12/2007
Virginia
Profile
Cool! Keep at it!

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

Sep 19, 2013 at 11:17:36 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
Originally posted by: arch_8ngel

Cool! Keep at it!


Thanks! I am really excited to learn. I have ideas for games just waiting to be made... If anyone wants to ever collaborate on a game, hit me up once I'm trained! 

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Sep 19, 2013 at 11:43:09 AM
m308gunner (63)
avatar
(Jason ) < King Solomon >
Posts: 3636 - Joined: 05/07/2012
Connecticut
Profile
Nice! I'll be sending KHAN a message as well.

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

Sep 19, 2013 at 6:24:23 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
I'll be here if ya need help, or more info on how registers work, or weird quirks, optimizations, etc. I'm not good at teaching unless you know some beforehand, apparently.

Sep 19, 2013 at 9:17:13 PM
GradualGames (39)
avatar
(Derek Andrews) < El Ripper >
Posts: 1128 - Joined: 10/09/2009
Pennsylvania
Profile
Count me in as an additional source of question answering via PMs. I like to help when I can.

-------------------------
Creators of: Nomolos: Storming the CATsle, and The Legends of Owlia.

Sep 20, 2013 at 11:52:11 AM
thefox (0)
avatar
(Kalle Immonen) < Meka Chicken >
Posts: 533 - Joined: 07/08/2008
Finland
Profile
Originally posted by: pk space jam

I would post the rom file I made but I dont want to get in trouble
Who do you think you're going to get in trouble with?

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

Sep 20, 2013 at 11:53:31 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
Originally posted by: thefox

Originally posted by: pk space jam

I would post the rom file I made but I dont want to get in trouble
Who do you think you're going to get in trouble with?
I believe one of the rules of the site is that you aren't allowed to post ROMs



-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Sep 20, 2013 at 11:57:22 AM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Yeah, of games which are copyrighted and contained trademarks and all that other junk. Homebrew stuff is 100% fine.

Sep 20, 2013 at 12:02:03 PM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
Originally posted by: 3GenGames

Yeah, of games which are copyrighted and contained trademarks and all that other junk. Homebrew stuff is 100% fine.


Good to know! I will post my rom and asm file later tonight I guess after work! 

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Sep 20, 2013 at 7:19:01 PM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
Alright, so here is what I've created. I want to wait to get Khan's approval though before I post the asm file being that mostly he wrote it. Updating the original post with the file. While I wait for the next lesson I am going to stare at the nerdy nights tutorials for a bit. 

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins




Edited: 09/20/2013 at 07:21 PM by pk space jam

Sep 20, 2013 at 8:09:45 PM
HocusPocus (19)
avatar
< Meka Chicken >
Posts: 527 - Joined: 06/12/2011
United States
Profile
Awesome KHAN! That kind of help is priceless and those of us who are learning truly appreciate it.

When I was doing Ninja Pong Slapper BigJT_2 (Of Assimilate) helped me once a week. He literally sat on the phone with me on speaker phone for an hour or more with computers set up through log me in to help me with my code. He did this for like two months. Honestly, I didn't really know him that well (only met him once at the NA campout) and he was kind enough to donate his time to me.

It was one of the nicest things anyone has done for me and he helped me realize a dream of making a NES game and putting it on to a cart.

Keep it up guys. I'm getting the bug to code again and I hope to be back at it soon.

-------------------------
Get ready for Pascali :)

Sep 22, 2013 at 6:47:07 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
Thanks for all the interest, guys. I'll be replying to all of you who sent me a message now. I've been out of town. I'll be putting up lesson 2 tomorrow.

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

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Sep 23, 2013 at 8:45:03 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
I should note if anyone wants to work on an assignment together or want to PM me a question for whatever reason, go for it!

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Sep 23, 2013 at 11:04:03 AM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
Nice work! Keep pushing along.

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

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Sep 23, 2013 at 11:06:08 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
Originally posted by: Mario's Right Nut

Nice work! Keep pushing along.


Thank you! And thanks to everyone who has offered to help. I've managed to do 2 of the three things I've wanted in life. My band got signed, I pusblished a Pen & Paper game, and now all I have to do is make a video game and from there on out im pretty happy with whatever else happens with my life. 

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Sep 23, 2013 at 12:37:42 PM
GradualGames (39)
avatar
(Derek Andrews) < El Ripper >
Posts: 1128 - Joined: 10/09/2009
Pennsylvania
Profile
Originally posted by: pk space jam

Originally posted by: Mario's Right Nut

Nice work! Keep pushing along.


Thank you! And thanks to everyone who has offered to help. I've managed to do 2 of the three things I've wanted in life. My band got signed, I pusblished a Pen & Paper game, and now all I have to do is make a video game and from there on out im pretty happy with whatever else happens with my life. 

Noble goals. I feel much the same way about my games! The sky is the limit though, I'm sure I won't want to stop after just 2!


-------------------------
Creators of: Nomolos: Storming the CATsle, and The Legends of Owlia.

Oct 1, 2013 at 7:46:20 PM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
bump for updates

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Oct 2, 2013 at 8:13:29 AM
m308gunner (63)
avatar
(Jason ) < King Solomon >
Posts: 3636 - Joined: 05/07/2012
Connecticut
Profile
Looking good man!

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

Oct 3, 2013 at 8:20:32 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
Bump for week two of lessons.

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins




Edited: 10/04/2013 at 08:23 AM by pk space jam

Oct 4, 2013 at 8:31:32 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
More background tiles.

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Oct 4, 2013 at 10:21:08 PM
Beep Boop! (1)
avatar
(Bzzt Bzzzt) < Crack Trooper >
Posts: 161 - Joined: 09/25/2012
Korea, Dem. People's Rep of
Profile
Hey now that's a good sprite source to steal, thanks!

On a more serious note, Khan is the man! Hope you publish those specifically tailored tutorials someday. (unless you posted it somewhere and I missed it?)

Oct 4, 2013 at 10:27:38 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
I haven't published them, but I add people to the google drive folder where I am continuing to add them. If you're interested, feel free to ask.

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

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Oct 7, 2013 at 8:50:33 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
If anyone wants the ROM file, PM me, the files wont seem to load for some reason.

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins



Oct 25, 2013 at 10:12:44 AM
pk space jam (58)
avatar
(What is love?) < Meka Chicken >
Posts: 902 - Joined: 12/28/2012
New York
Profile
Bump for updates!

-------------------------
Buy my stuff (NES repros right now) here <------
Read about me learning NES programming here. 
Here's my band.
Pen & paper game I wrote about Dolphins