Page 1 of 1

Finally learning ASM

Posted: Tue May 18, 2021 10:36 am
by CurlyPaul
After many years, and many attempts, I've finally managed to emmerse myself in enough ASM to be able to start to understand it, largely due to the excellent resources we have in this site.

For the last few weeks, I've been working through the beginner series, and pulled it together into this POC below. Almost all of the code comes from Keith's lessons, so hopefully it's attributed well enough.

This first pass shows a sprite using a back buffer, which is unnessary at this point I was just interested in doing that. I'm interested in any c&c, but particularly around where I'm calculating the next line for the sprint, feels like I'm making a massive meal out of this and there is an obviously easier/quicker way to acheive this. I was not expecting boolean checks to be so difficult.

Next I'm going to look at setting the pallette correctly and animating the sprite

Re: Finally learning ASM

Posted: Tue May 18, 2021 11:21 am
by CurlyPaul
Sorry, I thought I was posting this in the CPC forum, where it would be better suited

Re: Finally learning ASM

Posted: Tue May 18, 2021 10:17 pm
by akuyou
I've moved it to CPC, but don't worry, so long as it's vaguely in the right place! (not in the c64 section!)

I've had a quick look and the code you've written looks very good!

See my attachment... There's no tutorial for it yet, as it's a 'Work in progress', but here is an 'Advanced bitmap example', which uses a better get next line routine, pretty much the one that ChibiAkumas uses.

The GetNextLine routine uses self modifying code to change the condition, there's no pushes and pops either so it will be faster.

This example uses a screen 256 pixels wide (it's faster and more compatible with other systems)... for this reason the 'Add' command in the get next line routine uses a value of &C040, not &C050... I think if you change that, then it will work with the default screen size.

If you'd rather re-work your existing example, that's also fine, try to rewrite the code so the Pushes can be removed from the Get next line routines, as they are slow commands... don't worry too much though, these are things you'll figure out with time, so as your game progresses, you'll naturally start to learn and realize ways to make the code better.

Re: Finally learning ASM

Posted: Wed May 19, 2021 4:00 pm
by CurlyPaul
Oh wow, thanks for looking at it :)

I have seen some of the examples with self modification, but wanted to understand what problem they solve fully before I started using them. Looks like I've arrived, but that was the entire point of this repo, to gain understanding. Same with the getNextLine section, you didn't have an example of how to do it when the screen starts ar &4000, so seems like a good place to get stuck in.

The thing I'm currently playing with is the screen and the sprite, trying to get my own sprite to display as intended but getting confused yesterday and undecided which mode to go for. I'm more drawn to the demo scene than game building atm, so less fussed about compatibility, and more interested in a deep understanding of how I can abuse each system.

Thanks for all the great tutorials dude, so many resources for assembler are ood themselves, and don't explain much, but you've got me started now!

Re: Finally learning ASM

Posted: Wed May 26, 2021 11:42 pm
by CurlyPaul
Well it's coming along, and I'm buzzing from finally cracking ASM.

I'm starting to see how unmanageable the sprite data and meta data starts to get, so really need to delve into the latest Suckhunt video and soak up how that does it. I want to be able to show a complex series of frames, for a different number of ticks, but going to park that to look at sounds next.

Current progress though :

Re: Finally learning ASM

Posted: Thu May 27, 2021 9:25 pm
by akuyou
Your pickle example looks great, from the video, and what you're describing suggests you've got to grips with what you need for the sprite animation you want.

With the exception of ChibiAkumas Ep 2, The games I've written (even suck hunt) only use simple looping animation, where each frame is show for the same length of time.

I'm guessing you may want something more complex, for which I'd personally use some kind of script, with a sequence of sprite pointers, and time each sprite should be shown - ChibiAkumas did this, it had animation 'scripts' (sequences of bytes), which could loop sequences of sprites, movement directions and firing patterns - the game had a small 'parser' for the byte data.

I'm planning to do something similar in my next little game, but I think that you'll have worked out your own better solution by the time the tutorials are coming out.

All the best

The ChibiAkumas EP2 Script example:

Code: Select all

; First byte is the 'Tick map' which defines when the animation should update
defb %00000010		;Anim Freq
; all remaining bytes are anim frames in the form Command-Var-Var-Var
defb 01,128+01,0,0		;Sprite Anim
defb 01,128+02,0,0		;Sprite Anim
defb 00				;End of loop

Re: Finally learning ASM

Posted: Thu May 27, 2021 11:43 pm
by CurlyPaul
Cheers dude, and yeah that snippet shows the kind of thing I'm thinking of, i'll take a look at chibi, so much to to soak up at the minute but I'm getting around to it all. I really appreciate all these resources you've made, I feel like I've crossed a barrier now and I just can't put it down. Feels like coding used to before work got in the way and made it feel like, work ha

Just been going over some of simplyfying some bits and peices and the penny has dropped about how CA_Cursor_ProcessDirections is actually working :-D I'm still not clear why it's using exx instead of just pushing hl, but I'm satisfied I get what it's doing now