Coding NES Loops

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

Комментарии • 130

  • @NesHacker
    @NesHacker  Год назад +70

    UPDATE: There are multiple issues with how I treat the negative flag in this episode. Both DEX and SBC set the Negative Flag whenever the result has the 7th bit set. This means the flag will be set by a DEX when X = 255, and again with SBC for 200 - 50 = 150 (*1*0010110 in binary). Big mistake on my part, I apologize. Thank you very much to @TheWoodsieLord for pointing the error out!
    It's been a while! Hope you all like the video and let me know if there's a specific topic you'd like me to tackle next 😁

    • @RufusTodd
      @RufusTodd Год назад +3

      It’s been a wend.

    • @NesHacker
      @NesHacker  Год назад +2

      @@RufusTodd Did you just make a VBA joke? hahaha

    • @AndyScott
      @AndyScott Год назад +2

      Yes!!! So happy to see you're still at it!

    • @thinksie
      @thinksie Год назад

      This comment should be pinned, editing deletes the pin. xD

    • @matte.309
      @matte.309 Год назад +1

      You're videos are really great, I've struggled with the ".byte" ".word" or ".data" directives. I see them a lot in NES disassembly and I have a hard time getting my head around them.

  • @jaysonl
    @jaysonl Год назад +36

    The last time checked, you had somewhere around 300 subscribers, and now you've blown well past 10k! Well done!

    • @NesHacker
      @NesHacker  Год назад +9

      I think it was like over the course of a month the channel went from 1k to 10k subs, been growing at a good rate ever since.

    • @jaysonl
      @jaysonl Год назад +4

      @@NesHacker That's super awesome! Keep on going up, friend!

    • @LorenHelgeson
      @LorenHelgeson Год назад

      37K+ now. He's on fire!

    • @BillAnt
      @BillAnt Год назад

      ​@@LorenHelgeson- The loops are working great, branching out even more. ;)

  • @Favourites669
    @Favourites669 Год назад +22

    Indeed it's been a while, but totally worth the wait. Assembly is still hard for me to 'digest' but it gets much easier when it's explained in an interesting way and within a fun subject like the almighty NES. Keep 'em coming whenever possible man, we know life gets in the way most of the time. And sorry for my crappy english.

    • @NesHacker
      @NesHacker  Год назад +7

      It's a whole thing: learning assembly is rough, but *very* doable for most folks. Also: your English is superb :)

  • @FloatingSunfish
    @FloatingSunfish Год назад +33

    Not even VS Code can make Assembly programming painless.
    Really makes you appreciate how far we've come in terms of game programming.

    • @NesHacker
      @NesHacker  Год назад +14

      It can certainly make editing and organizing the files less of a chore, but yeah… assembly is assembly.

    • @BillAnt
      @BillAnt Год назад

      ​@@NesHacker- Assembly/machine code programming is like doing anal instead of regular sex. Enjoyable for some, not for others. lmao

  • @SamKickedOut
    @SamKickedOut Год назад +13

    Let’s go, another video!

    • @NesHacker
      @NesHacker  Год назад +7

      Yeppers :), I hope you enjoy it!

  • @ReachTimeToWin
    @ReachTimeToWin Год назад +12

    The return of the king
    Hope you stay doing more videos.

    • @NesHacker
      @NesHacker  Год назад +5

      :) that's the plan!

    • @near5148
      @near5148 Год назад +1

      ​@NesHacker these videos help me better understand how they work

  • @damianvila
    @damianvila Год назад +8

    Great video! It's nice to have you back. :) I personally would like a video explaining how Zelda's initial screen works. Specifically, how the waterfall, heart and fairy (in the scrolling screen) are animated, and how to change palettes on the fly. Cheers!

    • @NesHacker
      @NesHacker  Год назад +5

      Sure I can do something about that, it’s a pretty easy technique called palette cycling. I’m hoping to do another graphics video with more of a focus on programming at some point, so keep an eye out :)

  • @violator1017
    @violator1017 Год назад +10

    Man, you're PURE GOLD !
    A huge thank you and never stop this... it's one of the best if not the best NES related channel EVER MADE !
    Again, thanks a lot !🙏

    • @NesHacker
      @NesHacker  Год назад +4

      I will have you know I consist mostly of hydrogen, oxygen, and carbon ;). Thanks, and I hope to make many more videos in the future!

    • @violator1017
      @violator1017 Год назад +2

      @@NesHacker May the Lord of MOS hear you ! 😉

  • @EastCoastBaja
    @EastCoastBaja Год назад +4

    It's not even that this is the best NES programming series. This is the best series for programming and programming concepts in general. There are college classes that don't go this hard. If you ever decide to teach any other topics, you can bet I'll be on board.

    • @NesHacker
      @NesHacker  Год назад +2

      That's incredibly high praise. Thank you :)

  • @3DSage
    @3DSage Год назад +4

    I really enjoy how well you explain this! 😎👍

    • @NesHacker
      @NesHacker  Год назад +1

      And I really enjoy explaining it, thanks so much for watching :)

  • @xcruckx
    @xcruckx Год назад +3

    Love this channel, thank you for your videos! Keep it up!
    PS: do you have a Patreon?

    • @NesHacker
      @NesHacker  Год назад +5

      Thanks! No Patreon yet, but make sure you’re subbed cause I’ll be announcing something about that soon…

  • @GustavoValdiviesso
    @GustavoValdiviesso Год назад +7

    I won't complain about how long it take between your videos. I know how it is. Besides, it is worth the wait 😎

    • @NesHacker
      @NesHacker  Год назад +6

      Maybe you should complain more so it motivates me to put out videos faster haha xD

    • @GustavoValdiviesso
      @GustavoValdiviesso Год назад +3

      @@NesHacker There are other ways to motivate: I am a professor from a Brazilian university, working with Physics simulations, and programming 6502 for fun. Because of you and the way you organize your topics, I felt motivated to give a short course on 6502 asm myself. You see, in general Brazilians know no other languages and they miss so much because of it. So I translated the easy6502 page and used it for a 3h crash course. The feedback was amazing. So, thank you for motivating me 😉
      BTW, I have a science education channel in Portuguese called @Cienplifica and I haven't publish anything in three months or so, because of my classes and research. So I understand 👍

    • @NesHacker
      @NesHacker  Год назад +3

      @@GustavoValdiviesso That's super cool, it's awesome to hear that I had such an impact :D

  • @s14tam
    @s14tam Год назад +7

    Probably the coolest way I could think of to learn assembly programming! Please keep making great videos like these

    • @NesHacker
      @NesHacker  Год назад +2

      Absolutely, there are a lot more to come :)

  • @lunexbot8437
    @lunexbot8437 Год назад +3

    Early Christmas, lovely work!

    • @NesHacker
      @NesHacker  Год назад +1

      I give the gift of knowledge by way of crispy, fast-paced, and irreverent graphics ;)

  • @Favourites669
    @Favourites669 Год назад +2

    Also, totally jealous of those original NES classics you have there. :)

  • @randy7894
    @randy7894 Год назад +3

    Very well explained and some entertaining infographics. Thanks!

    • @NesHacker
      @NesHacker  Год назад +2

      Thank you! Did you know that the graphics work take the majority of the time of a video? About 75% of the overall time is spent in editing, graphics, and post production. So your compliment feels particularly nice 'cause I put a lot of time into that part of the process :D

    • @randy7894
      @randy7894 Год назад +2

      @@NesHacker I'm not surprised. But a treat tob watch.

  • @trapr00t
    @trapr00t Год назад +2

    Extremely cool video, enjoyed it a lot! Can't wait to learn how negative arithmetic works. Please do more videos, I simple can't wait! =D

  • @jwalshmorrissey
    @jwalshmorrissey Год назад +2

    Glad to see you back.

    • @NesHacker
      @NesHacker  Год назад +2

      It's good to be back :)

  • @andreazaffino
    @andreazaffino Год назад +2

    I’m really happy to see you again 👏

  • @mattmmilli8287
    @mattmmilli8287 Год назад +2

    This has value applied to modern day things for sure. Even higher level languages 🤔

    • @NesHacker
      @NesHacker  Год назад +1

      Mhm, that’s the cool part about CS fundamentals: they’re applicable in all sorts of contexts.

  • @thinksie
    @thinksie Год назад +3

    Next amazing video! Thousand thanks, your videos helped me a lot! I can use nesdev and know what's what and why :D
    I might be wrong, but:
    10:23 11111110(254) still sets the negative flag, any number ranging from 128(10000000) to 255(11111111) will in fact set the negative flag! The negative flag is just the 7th byte of a number. The numbers on NES range from -128 to 127 or 0 to 255.
    EDIT : 14:50 BPL ==> BCS. Also the carry will be set if it didn't have to borrow when subtracting.
    I love your vids though! I think I've seen each of your videos on NES minimum twice lol

    • @NesHacker
      @NesHacker  Год назад +2

      Yep, you’re right. I goofed hard. Thanks for pointing it out, I’ll make sure to update the errata in the pinned comment.

    • @thinksie
      @thinksie Год назад +1

      @@NesHacker The overflow flag would be most useful. I think it is set when the boundaries of signed numbers get crossed. (Nope, it gets way complicated then lol)
      Glad to could have helped! You're most welcome! ^ ^

    • @NesHacker
      @NesHacker  Год назад +2

      ​@@thinksie Added an update to the pinned comment, but still a huge bummer. I need to *not* rush the testing of the programs I put out there :(

    • @thinksie
      @thinksie Год назад +1

      @@NesHacker Right now I got interested, how to fix that in a program, you know for HP to work using the whole 0-255 we have.
      Ok, yeah, you'd probably need to use N V C and Z, all these flags, to distinguish the cases and for the program to act accordingly. That really does seem complicated ;-;
      I was making a table of that in paint, lol my brain explodes
      C to see if we crossed the byte boundary.
      V to see if the sign changed ONCE ( if it changed twice, then our C will tell us that :D)
      N to see the sign
      Z to check if the HP is 0
      Got it, there are 6 possibilities :D
      for N+ :
      V+ C+ | Impossible - did change sign, did cross the byte, positive
      V- C- | 20-5 = 15, didn't change sign, didn't cross the byte, positive
      V- C+ | 20-180 = (-160) = 95, didn't change sign, did cross the byte, positive
      V+ C- | 160 - 40 = 120, did change sign, didn't cross the byte, positive
      for N- :
      V+ C+ | 50 - 60 = (-10) = 245) did change sign, did cross the byte, negative
      V- C- | 160 - 5 = (-100) = 155 didn't change sign, didn't cross the byte, negative
      V- C+ | 140 - 180 = (-40) = 215 didn't change sign, did cross the byte, negative
      V+ C- | Impossible - did change sign, didn't cross the byte, negative
      Why two are impossible?
      N- V+ C+ | it has to cross, has to change the sign(so start as negative) and be positive
      the smallest negative number is 128. 128 - 100 = 28, didn't cross, 128 - 200 = -72, crossed but is negative, 128-255 = -127, crossed, but still is negative.
      N+ V+ C- | it cannot cross, has to change the sign(so start as positive) and be positive
      Whatever number we can subtract from a positive number, we cannot make it go negative all of a sudden without crossing the byte.

    • @NesHacker
      @NesHacker  Год назад +2

      @@thinksie Easiest way I can think to do the check is compare the HP value prior to the subtraction to the amount of damage. If the damage >= current HP then branch to the "lda #0", otherwise perform the subtraction and jump to the "sta $0300, x". But yeah that's way more complex than just "check a flag" 🤦‍♀ hahaha

  • @BrianBates128
    @BrianBates128 Год назад +3

    Thank you for returning! Great breakdown of the loop process and explaining unnamed loops

    • @NesHacker
      @NesHacker  Год назад +2

      Oh I never left, I just got a little sidetracked by "life stuff".

    • @BrianBates128
      @BrianBates128 Год назад +2

      @@NesHacker I totally understand. If you ever need anything else other than subscribers and likes, let us know!

  • @TheNuje
    @TheNuje Год назад +2

    I just love love LOVE how the carry flag between the Z80 and the 6502 behave in largely the same way, unless you're comparing and subtracting where it works exactly backwards.

    • @NesHacker
      @NesHacker  Год назад +3

      I should totally do videos on GameBoy programming, that will give me an excuse to dust off my *very* neglected Z80 assembly skills (oh the days of TI-85 game programming... how I miss you).

    • @TheNuje
      @TheNuje Год назад +1

      @@NesHacker I'd have to get used to not having IX/IY if I ever did anything on the GameBoy, but it would be fun to try it out!

  • @brunch1572
    @brunch1572 Год назад +1

    I enjoyed the video. Off topic, but I'm wondering if you have heard of the 65c02-based Commander X16 and what you think about it. I totally understand if you are only interested in the NES, its what your channel is about after all.

    • @NesHacker
      @NesHacker  Год назад +1

      I hadn't heard of it, but after a quick search I found some info about it on the C64 Wiki. Looks like a cool idea from what I can tell, though I still think there's something a bit more magical about getting programs to run on original vintage hardware ;D

  • @vuurniacsquarewave5091
    @vuurniacsquarewave5091 Год назад +2

    It's always a teeny tiny bit more efficient to count down in 6502 loops because of that convenient N flag behavior.

    • @NesHacker
      @NesHacker  Год назад +1

      Yeah but you can do 128 iterations max because the N flag is set when bit 7 is set, no?

    • @vuurniacsquarewave5091
      @vuurniacsquarewave5091 Год назад

      @@NesHacker Yes, that's definitely a limiting factor but it's also not super common that you need that many iterations of something. If execution time is not that critical, you can even add a byte of zero page as part of your counter, or if both X and Y are constantly needed in the body of your loop.
      But that's why assembly is awesome, you can always try to adapt things to the situation at hand.

  • @jengelenm
    @jengelenm Год назад +1

    Darn that was fast, i think i need to rewatch some videos and this one in slow-motion :)

  • @luzten
    @luzten Год назад +2

    Just THANK YOU. The production quality is massive as usual with your videos.

    • @NesHacker
      @NesHacker  Год назад +1

      No problem, I like making these as much as you all like to watch them :)

  • @DonovanMyers
    @DonovanMyers Год назад +1

    I was literally just at Pinball Pete's last weekend and took that same photo (of the SFII/MVC machines w/ the pinball in the background)! Had to do a double take.

    • @NesHacker
      @NesHacker  Год назад

      That’s awesome, I got that shot off a stock site though 😂

  • @oiyo6241
    @oiyo6241 Год назад +2

    Totally worth the wait ! Keep up the good work!

  • @1stacbats
    @1stacbats Год назад +2

    Another fantastic explanation 👌🏻

  • @zzeck431
    @zzeck431 Год назад +1

    Good video! I was concerned that perhaps you had stopped.
    This is probably all really weird feedback.
    You could probably lower your production style significantly, and still get your points across just fine.
    IMO the essential things are stuff like highlighting the code in the editor, and also the illustration of an arrow pointing at addresses.
    All the images, video clips, little animated vector art, game screenshots and footage, seem like they would take a lot of time to me!
    They do add a very polished feel to the video though!
    Could be I'm wrong about the time because I'm terrible at editing.
    You might also want to assume a bit more knowledge in the audience.
    Probably (I speculate) most viewers who find your videos will know something about a loop but be unfamiliar with how they are done in assembly language.
    So the card analogy might be unneeded then, and you could perhaps instead contrast asm with python or something.
    There's a bit of a disconnect in having github link, project people would build with command line stuff, etc and not assuming some slight programmin' experience.
    Maybe some audience survey could help on the community page?
    Could emphasize that people should go download and follow along through the video perhaps? Might get more people to take the plunge. "Here we can see on line X...", "Stepping through this in Mesen we see..." type of comments in the video or something. Visually, it's there, but I dunno. We also do not get a clear view of the whole file visually, introducing it. "In X file from github..."
    Anyway, maybe some of that is useful, or I could be just nuts.
    Next video suggestions:
    NMIs and how they complicate execution and design,
    Going through a game's code interacting with the PPU (probably early, simple, single screen game),
    Audio

    • @NesHacker
      @NesHacker  Год назад +5

      Woah, lots of thoughts there! Thanks for sharing. I think the graphics add a lot and allow me to talk about deeper concepts than just the code. As far as the target audience and what to cover and not to cover, I struggle with that a lot since I don't want to alienate the uninitiated... but I also know my vids can get tedious for those who just want to jump into the code. I've thought about it a lot and mostly just decided to keep trying things out and experimenting. Hopefully I'll find the sweet spot someday :)

    • @hicknopunk
      @hicknopunk Год назад +2

      I vote yes on the PPU

  • @brian8152
    @brian8152 Год назад +2

    "This is called Lupin" :^)

    • @NesHacker
      @NesHacker  Год назад

      Just wait until the 3rd installment...

  • @Robert_Shmigelsky
    @Robert_Shmigelsky Месяц назад

    I want to make sure I got this right. Since X is an offset, we're storing the value of 100 at addresses $0307, $0306, $0305, etc?
    lda #100
    ldx #7
    initialize_hp_loop:
    sta $0300, x
    dex
    bpl initialize_hp_loop

  • @eg6490
    @eg6490 Год назад +1

    Still an enigma when it comes to code, but still fun to watch
    This is something for much later, but I’d love to see your thoughts on a program out their called NES maker. It’s a cool project that’s supposed to help with nes dev.
    Would love to see what you think

    • @NesHacker
      @NesHacker  Год назад +3

      Mmm, iirc that's a commercial development product for making NES games? I've not used it personally so I don't know if it is good or bad. Mostly I just hack from scratch :)

    • @eg6490
      @eg6490 Год назад

      @@NesHacker it is commercial. About $40. Whether it’s worth the investment is up to the individual. But it is a neat thing developed by a few dudes in their free time. I still think it’s pretty neat In it’s current state

  • @MichaelShulski
    @MichaelShulski Год назад +2

    Can 6502 do recursion?

    • @NesHacker
      @NesHacker  Год назад +1

      Yep, it sure can. Though like any other machine the depth of the recursion is limited by the stack. I was thinking of doing an episode on subroutines and covering this a bit there.

  • @patrickcunningham5167
    @patrickcunningham5167 6 месяцев назад

    Once again I find myself comparing this channel to my assembly language course from my CS degree decades 8-| ago. Makes me wish they taught 6502 instead of x86.

  • @chrisdemerski1101
    @chrisdemerski1101 Год назад +1

    How I have missed you!

  • @jayjasespud
    @jayjasespud Год назад +2

    Yo you're back! Yes!

  • @ARCSYS4049
    @ARCSYS4049 Год назад +1

    Your face looks as though it is meant to house a magnificent beard.

    • @NesHacker
      @NesHacker  Год назад

      You’d think that, but mostly I just grow a good mustache xD

  • @seckinseckin3919
    @seckinseckin3919 Год назад

    Before i learn asm, i learnt how CPU works, Logisim is a good simulator for learn this. After i learn CPU logic then i wondered how assembly codes are understandable by CPU and where they kept.. and brought me to ROMs, compilers, lexical analysis, parses,tokes... etc.. i dig and dig to the core.. this is how i find videos like yours. Thanx

  • @16bitdude36
    @16bitdude36 Год назад +2

    YO,YOUR BACK!

    • @NesHacker
      @NesHacker  Год назад +2

      Yah, and hopefully for a good while :D

  • @schlangengrube157
    @schlangengrube157 Год назад +1

    You are back.🙂

  • @ikemkrueger
    @ikemkrueger Год назад +1

    That's by far the best series to learn assembler! I wanted to learn assembler a long time ago, and now I have a solid basic understanding of it. Thank you very much!

    • @NesHacker
      @NesHacker  Год назад

      You’re very welcome! I am very happy to hear that the series helped :)

  • @Shrek321
    @Shrek321 Год назад

    there are multiple advanced techniques you saved for other videos, bring those videos please

  • @ebs777
    @ebs777 Год назад +2

    These videos are gold. Thank you so much. I hope you make more very soon

    • @NesHacker
      @NesHacker  Год назад +2

      Thank you, I’m working on them full time now :)

  • @annarozin467
    @annarozin467 Год назад

    Amazing video editing, how do you do that?! I used to work as C programmer together with asm programmer who wrote the engine on a 8051/8051 chips

    • @NesHacker
      @NesHacker  Год назад

      After effects and final cut pro, just like everyone else haha :D

  • @wildside4822
    @wildside4822 Год назад

    Great vid. I'm a little confused, the code in the Github repo is different to the code in the video?? At 07:25 you are explaining the .byte directive but it is not in the example repo. Thanks again.

    • @wildside4822
      @wildside4822 Год назад

      Ah, OK, I figured it out. I think the Gihub code is a simplified version. Figuring out the .byte directive was the key

  • @BDJones055
    @BDJones055 Год назад

    NES Hacker is awesome. Thank you so much for providing this knowledge to us! I've been lurking around assembly language for quite a while but I've never found someone who does into a deep dive like this in a easily consumable way. PLEASE Keep doing these videos!

  • @vitmaubra
    @vitmaubra Год назад

    Your explanations are both deep and very, very , very clear. Hard to find something like that when it comes to programming nowadays. Congratulations.

  • @kythrathesuntamer9715
    @kythrathesuntamer9715 Год назад

    My only feedback is you're basically offering the most clear and understandable explainations of 6502 on youtube altogether. You're one of the easiest to actually grasp what you're saying although I should totally rewatch as it's been too long since I started originally.
    You must work really hard to make this stuff I'm so grateful you see I'm not entirely learning to be a game developer I'm- Interested in Assembly programming and I just am studying via the NES because it's so old tech that it's frustratingly limited and I just feel like when developers had to deal with those limits they wrote code that performed better and the current era has tragically given way to agile development that puts things together as quicky as possible and to hell with how it actually performs and as someone studying coding I just don't want to fall into the camp that doesn't give a fuck if my code actually executes on my machine quickly. I'm not as new to coding as i can come across i just don't have my name on a major project because it's hard to stay consistently on the path.

  • @ctrlAltReality
    @ctrlAltReality Год назад +1

    yai you are back

  • @liyifenn
    @liyifenn Год назад

    I love these videos so much. You and Retro Game Mechanics Explained are so, so, so joyous to listen to.

  • @ZenoTasedro
    @ZenoTasedro Год назад

    I consume a lot of deeply technical content, but I am pretty damn sure I've never seen that content look this good

  • @stephensteele2844
    @stephensteele2844 Год назад +1

    brotato addiction triggered

    • @NesHacker
      @NesHacker  Год назад +2

      I had no idea what "Brotato" was and now I am all like, "I need to go try that game now..." >.>

    • @stephensteele2844
      @stephensteele2844 Год назад

      @@NesHacker it was the soundtrack, its certainly a fun little game that can soak 100 hours or more if youre not careful :)

  • @mindphaserxy
    @mindphaserxy Год назад

    Dawg where you been...it's been months!

    • @NesHacker
      @NesHacker  Год назад

      I’ve been around but I’ve also been really busy, haha ;)

  • @TurboXray
    @TurboXray Год назад +1

    Unnamed labels are ~poor~ code design for lazy devs haha. Definitely judge anyone who uses them and claiming to come from a professional developer background.

    • @thinksie
      @thinksie Год назад +1

      Well, technically yeah, I would agree, but for /some/ simple loops it actually wouldn't make sense to give names to each and every one. At least I think so.

  • @alieander
    @alieander Год назад +2

    first lol

  • @claytonburton7721
    @claytonburton7721 Год назад

    Your video was awesome! This content desperately needs Promo`SM!!