Moving sprites

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
bobs
Microbot
Posts: 106
Joined: Thu Dec 28, 2017 8:26 am
Location: UK
Contact:

Re: Moving sprites

Post by bobs »

You can always see if there’s anything of use to you on my 8-bit coding blog:
https://bobs8bb.wordpress.com
Have covered sprites, keyboard routines, and much else besides
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: Moving sprites

Post by MrPixel »

AndyC wrote: Sun Mar 25, 2018 12:50 pm One of the hardest things to get over when it comes to assembly on the Spectrum is realising that things like "sprites" aren't really things at all. That's why you'll struggle to find a "move a sprite" routine, everything is faking it and the best approach varies upon exactly what you're trying to accomplish.

Ultimately a sprite is just something drawn onto the screen, destroying whatever was there before. Moving it therefore is a case of restoring the background and then drawing it again in a slightly different position (possibly with a different animation frame) to give the impression that something has moved.

Now how you do that is a whole different issue. An easy way is to draw the sprite using XOR operations, taking advantage of the fact that doing the same thing again will restore the original image. It works well for plain backgrounds where sprites are unlikely to overlap, but soon gets very messy when things can overlap a lot. The other end of the stick is simply not to worry about it at all and simply redraw the entire playable area every time from scratch. It's a lot more work, but if you have scrolling backgrounds you may find you'd need to redraw most of the screen anyway and so a more simplistic approach like that can be just as effective. Various other intermediate approaches also exist, whether saving and restoring the background or redrawing it in any "dirty" areas. Each has it's own advantages and disadvantages that make them more suitable in certain circumstances.
how do i run an SCL. File? that's the only way ZX asm 3.0 will run :?
User avatar
PeterJ
Site Admin
Posts: 6858
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Moving sprites

Post by PeterJ »

SCL (* .scl) - a format for storing TR-DOS-files

I have not heard of ZX ASM 3 before but looking on Google it seems to be Russian and comes as a SCL or TRD TR-DOS image for Russian Clones.

You would be better off using Pasmo, ZX-Spin or similar. Have you looked at the material that other people have posted you links to?

Peter
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Moving sprites

Post by Ralf »

SCL (* .scl) - a format for storing TR-DOS-files
If you are new to Spectrum emulation, I would suggest using Spectaculator:

http://www.spectaculator.com/downloads/

Many people (including me ;) ) believe it's the most friendly of emulators. Speaking of .scl files you just click on it in Windows and it opens (assuming you created file associations during install)

Spectaculator is not free but you have 30 days of trial.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Moving sprites

Post by Nomad »

Ralf wrote: Sun Mar 25, 2018 11:17 am
Like others have pointed out, you are looking at Pasmo or Zeus for cross development. There are some other choices but those seem to be the big two.
You forgot about Sjasm. It's big too. And my personal choice for years ;)
Ah I didn't know about this.. nice
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Moving sprites

Post by Alessandro »

Talking about learning Z80 Assembly on the Spectrum, I would heartily recommend anyone who wishes to undertake such an endeavor, besides the already given recommendations, Ian Sinclair's Introducing Spectrum Machine Code, together with Rodnay Zaks's Programming the Z80 and Lance A. Leventhal's Z80 Assembly Language Programming for a more comprehensive and in-depth approach. The last two books helped me so much from a first glance, that I ultimately found and bought a second-hand copy of Italian editions of both of them.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Moving sprites

Post by Nomad »

Zaks & Leventhal's books are good. But they take a lot of dedication to get the most from them.

I prefer the Leventhal books but they are both good. Dry but good. It would make a great youtube lecture series I figure probably 100-150 hours or so but it would be good.
User avatar
PeterJ
Site Admin
Posts: 6858
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Moving sprites

Post by PeterJ »

[mention]Alessandro[/mention],

The Introducing Spectrum Machine Code book is available here if anyone wants to download a copy.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Moving sprites

Post by Alessandro »

PeterJ wrote: Mon Apr 02, 2018 3:30 pm @Alessandro,

The Introducing Spectrum Machine Code book is available here if anyone wants to download a copy.
Thank you [mention]PeterJ[/mention], I downloaded the PDF scan from the WOS archive ages ago, and could not find a suitable link for the life of me!
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Choosing an Assembler

Post by MrPixel »

is there a good Z80 assembler (not zeus, i already went down that rabbit hole once) that i can use to start properly making games or, at least graphics :?:

***Title changed by Mod****
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: Moving sprites

Post by Ast A. Moore »

There are plenty of Z80 assemblers to choose from. Some cater to the ZX Spectrum specifically. Some even let you assemble your source online. I think you need to focus on learning the Spectrum’s architecture and Z80 assembly language and worry about the tools later. In fact, you can use any number of assemblers written for the Spectrum itself (i.e. running on it natively).
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Wall_Axe
Manic Miner
Posts: 492
Joined: Mon Nov 13, 2017 11:13 pm

Re: Moving sprites

Post by Wall_Axe »

you are using windows?
on linux you can create a 'makefile' which really helps, to get makefiles running on windows is a hassle. I've never learnt how to do bat files on windows.

the makefile basically compiles your game and runs the emulator...only if it compiled successfully..which is very useful

That being said pasmo is a good compiler, it generates the .tap file for you, which is ready to be loaded into the emulator.

if your game isnt that complicated and doesnt need proper sprites you could go for boriel's basic, which also lets you use assembly routines mixed in with basic.

i usually make my own tools to get graphics into spectrum format (which i lost), zx paintbrush is spectrum oriented..but i dont know how to get the picture exported as bytes, which is what you need.
User avatar
PeterJ
Site Admin
Posts: 6858
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Moving sprites

Post by PeterJ »

Hi [mention]MrPixel[/mention] you will find a lot of appropriate answers and tutorials on the threads you started here:

viewtopic.php?f=6&t=554

And here:

viewtopic.php?f=6&t=559

Regarding graphics, ZX Paintbrush is recommended in the thread you started here:

viewtopic.php?f=7&t=657

I use a mix of Pasmo, and ZX-Spin running in a Windows XP Virtual Machine. As others have said Spin is very dated and not recommended by many, but it is a very good all in one solution for beginners IMHO.

You do need to do a lot of reading (as many others have said) before you starting typing at the keyboard though. If you really want to learn there is no magic wand or overnight solution. Once it starts to click, even at a simple level which is where I am at, the sense of achievement is amazing.
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Moving sprites

Post by Ralf »

is there a good Z80 assembler ... that i can use to start properly making games or, at least graphics
You don't make graphics with assembler, you make them with graphics editor ;) When they are ready you display them with assembler.

What you need is actually some tool to convert graphics into notation acceptable for assembler. I remember from your another post that you didn't want to use standard PC graphic editors but if you changed your mind then Sevenup is a tool for you.

You create some graphics, save them as standard picture (.png, .bmp, .gif etc) and import it to Sevenup. Then you configure your output, do export and get things like .BYTE 1,2,3 You paste it into your assembler code and can use it since that moment in your program.

As for the assembler if you don't want use Zeus then the most popular options are Pasmo and SjasmPlus.
Post Reply