ZX Spectrum Game Development Noob Questions

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
Mozartkügel
Drutt
Posts: 27
Joined: Fri Jun 07, 2019 8:19 am
Location: Finland

ZX Spectrum Game Development Noob Questions

Post by Mozartkügel »

Hi guys! I'm pretty much completely new to the ZX Spectrum, but I've recently gotten interested and fallen in love with many of the old home computers and consoles (in addition to the ones I was most in contact with back in the day), especially the 8-bit ones, and the Speccy is one of the computers on the top of my list! :)

I remember feeling intrigued about the funny colors of spectrum games in gaming magazines as a kid. Now when "everything's the same" when it comes to computers, the Speccy's restricted graphics come across as really unique and even legendary. That's one thing I love about the 8-bit generation of machines, you can usually almost immediately tell the difference from the graphics and music if it's for example a spectrum-, c64-, nes-, msx or amstrad cpc- game! Also a limited colour palette partly forces the graphics artist to better design choices than a large one (many times probably inadvertently on some of the old games).

Anyways, I was thinking of trying to set up some small start of a game on the spectrum with Z88DK, and as a complete noob I'd really appreciate if someone could point me in the correct direction about ZX Spectrum development. I'm not going to try to push the system to its limits and I've got very limited free time at the moment, so I'll have to leave assembly for the future.

1A. Is there a simple "standard" graphics tool that has emerged that "everyone" uses (comparable to spritepad and charpad on the c64), that can export the graphics in tables for assembler and preferably C too? I've seen multipaint before, but I haven't tried it yet: http://multipaint.kameli.net/

1B. If I understood correctly you can have two colors per 8x8 cell on the spectrum? (I've read about Nirvana+ but these questions would be from a standard speccy view).

1C. Are the Bright and normal variants of the colours usable on cell level or do you have to choose for the whole screen which ones to use?

1D. I suppose you can't use basic colour and bright colour of the same colour in the same cell?

2A. Is there some simple AY music tracker that can export music to be fairly easily used with Z88DK?

2B. Do homebrew spectrum games usually support both beeper sound of the early models and AY sound?

3. Does someone know if there's a Z88DK template / code skeleton / boilerplate code somewhere to be found that would incorporate basic stuff you'd need for a game, i.e. user defined characters for graphics + AY music/sfx + input of both kempston and zx interface 2? So far I mostly found snippets or finished games where the code is so big and mixed with assembly it becomes a bit overwhelming.

Actually in this moment I read that Nixy the Glade Sprite (which looks like a very fun and great looking game) has been made with AGD, I think that is something that I'd might wanna look into too.

Thanks in advance for any help! :)
dfzx
Manic Miner
Posts: 673
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Game Development Noob Questions

Post by dfzx »

Mozartkügel wrote: Fri Jun 07, 2019 8:51 am Anyways, I was thinking of trying to set up some small start of a game on the spectrum with Z88DK,...
Shameless plug: my Z88DK getting started with Spectrum development guide is here.
Mozartkügel wrote: Fri Jun 07, 2019 8:51 am 3. Does someone know if there's a Z88DK template / code skeleton / boilerplate code somewhere to be found that would incorporate basic stuff...
No, that approach doesn't really work with the Spectrum, either with Z88DK, ASM or anything else. Every byte matters, and just hauling in a whole mass of pre-written stuff in the hope that it's useful will just fill the memory. You have to adapt your coding discipline back to the 1980s mindset - economical, with attention to detail. That's what still makes it fun, 35 years after we started. You don't have to start by obessing to the level some experts on here do, you can strike a happy medium which suits you.

Others will doubtless answer your other questions. I'm at work so don't have time right now. :)
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: ZX Spectrum Game Development Noob Questions

Post by Alessandro »

Welcome on the forum Mozartkügel!

To ask your questions, I'll first presume that by "cell" you mean one of the low resolution attribute blocks of the Spectrum display. They are 768 starting from the one in the top left corner and are memorized between addresses 22527 and 23295 of the computer's RAM. Each one of them can hold at any given time 1 INK value (pixel color), 1 PAPER value (background color), 1 BRIGHT value and 1 FLASH value (alternates between INK and PAPER). Whereas pixels are memorized between 16384 and 22527 for a total of 6144.

INK and PAPER can assume values ranging from 0 (black) to 7 (white). 8 means "transparent", i.e. leave the old attribute unchanged. 9 means that the INK or PAPER value will be set to contrast with the color of PAPER and INK respectively.

FLASH and BRIGHT can be set to 0 (off), 1 (on) or 8 (unchanged).

The above answers to your questions 1B, 1C, and 1D, however I'd suggest you to consult Chapter 16 of the Spectrum programming manual.

As for the other questions:

1A) There are a number of programs for that purpose, there is no de facto standard. Personally I have been using ZX-Paintbrush for years.

2A) Same goes here, there is no de facto standard although Vortex Tracker, now at version 2.5, is my personal choice.

2B) They might support both or just the beeper or just AY sound. My games, for instance, usually have beeper sound effects and AY background music. Of course the AY-8912 chip is natively present on the 128K and later models only.

3) I never used Z88DK since I am ignorant about C but there are folks here who can help you with that.

Finally, if you wish to see more games authored with AGD, I can point you to my own ones (go to my website and select Retroinformatica/Mio software). Feel free to ask me any information about them.

Hope that helps :D
Last edited by Alessandro on Fri Jun 07, 2019 9:47 am, edited 1 time in total.
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: ZX Spectrum Game Development Noob Questions

Post by djnzx48 »

Hi, welcome to the forum!
Mozartkügel wrote: Fri Jun 07, 2019 8:51 am 1A. Is there a simple "standard" graphics tool that has emerged that "everyone" uses (comparable to spritepad and charpad on the c64), that can export the graphics in tables for assembler and preferably C too? I've seen multipaint before, but I haven't tried it yet: http://multipaint.kameli.net/
ZX-Paintbrush is probably the most well-known one, but you can also use standard PC graphics tools and then use something like SevenuP, bmp2scr or img2spec to convert. I believe SevenuP has several options for exporting so you can also use it for sprites.
Mozartkügel wrote: Fri Jun 07, 2019 8:51 am 1B. If I understood correctly you can have two colors per 8x8 cell on the spectrum? (I've read about Nirvana+ but these questions would be from a standard speccy view).
Assuming a static screen, that is correct. Since the screen cells are displayed one line at a time, by changing the colours in sync with the raster you can get up to 16 colours in a single cell.
Mozartkügel wrote: Fri Jun 07, 2019 8:51 am 1C. Are the Bright and normal variants of the colours usable on cell level or do you have to choose for the whole screen which ones to use?
It's based on 8x8 cells. So it can be varied across the whole screen.
Mozartkügel wrote: Fri Jun 07, 2019 8:51 am 1D. I suppose you can't use basic colour and bright colour of the same colour in the same cell?
Not without using multicolour. There's only one bit per cell with brightness information, so both colours have to be the same bright level. However, the colour black is unaffected by the bright bit so both levels of black will look the same.
Mozartkügel wrote: Fri Jun 07, 2019 8:51 am 2A. Is there some simple AY music tracker that can export music to be fairly easily used with Z88DK?
Pretty much any interrupt-based tracker will work as far as I'm aware. For the PC, you have Vortex Tracker 2.5, Arkos Tracker 2, WYZ Tracker, and chipnsfx (command line). Vortex is the most popular option out of those. You can either use the export function in the editor (useful if you're dealing with a single song) or include the song files along with a standalone player.
Mozartkügel wrote: Fri Jun 07, 2019 8:51 am 2B. Do homebrew spectrum games usually support both beeper sound of the early models and AY sound?
It depends, you can have ingame options depending on what you want to support. On the machines that do have AY, it's mixed a lot quieter than the beeper, so you may not want to have them playing at once (or the AY can be drowned out). You could use beeper for sound effects and AY for music, or just play everything on the AY.

Also, although the AY chip was only added starting with the 128K model, it was also available as a third-party hardware addon as well as being built-in to the Timex models. So you can still include AY music in a 48K game.
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: ZX Spectrum Game Development Noob Questions

Post by Ralf »

Hi!
Good luck with Speccy programming.

Here are Some answers for your questions. Sorry for being concise, I'm writing from work ;)

1A. Yes, it's called Sevenup
1B Yes, without advanced tricks you have only 2 colours per character
1C You set bright on char level so each 8x8 pixels area is either bright or not
1D Yes, you can't mix bright and non-bright in a cell
2A AY trackers are generally difficult stuff but I would suggest Vortex Tracker as it runs under Windows
2B It differs. You can do a game just with some beeper buzzes, you can do a game with beeper music, you
can do a game with AY music. Generally if a game has some music, you score extra fame from the gamers ;)
3. There are some full environments for games making like AGD or some libraries for C like Churerra. Do some search
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: ZX Spectrum Game Development Noob Questions

Post by djnzx48 »

Alessandro wrote: Fri Jun 07, 2019 9:34 am INK and PAPER can assume values ranging from 0 (black) to 7 (white). 8 means "transparent", i.e. leave the old attribute unchanged. 9 means that the INK or PAPER value will be set to contrast with the color of PAPER and INK respectively.

FLASH and BRIGHT can be set to 0 (off), 1 (on) or 8 (unchanged)
If I may add to this: these attribute values of 8 or 9 are only abstractions used by the BASIC interpreter for printing coloured graphics. They don't actually exist in the hardware, nor in machine code programs that don't use ROM routines.
User avatar
Mozartkügel
Drutt
Posts: 27
Joined: Fri Jun 07, 2019 8:19 am
Location: Finland

Re: ZX Spectrum Game Development Noob Questions

Post by Mozartkügel »

Thanks so much for your answers/info/links and the warm welcome guys! I got a lot to sink my teeth into now and I pretty much got all of my questions answered! I will reply properly in the evening because I am too at work now. :mrgreen:

One follow up question if I may, does anyone have experience what version of AGD would make sense to use? I noticed there are AGD, MPAGD and AGDX. As I mentioned before I wouldn't be looking to push the limits of the Speccy, rather I'm looking for simplicity but with the possibility for all the parts needed for a finished game and "product". I forgot to mention that the final goal somewhere in the future would still be to put it on C-cassette, so I guess that might imply level compressing (uugh) and loader/tape mastering (eek, help me!) :lol:

[mention]Alessandro[/mention] Beatuiful games, especially Sophia 1&2 and Doom pit caught my eye! I got to check these out properly asap.
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: ZX Spectrum Game Development Noob Questions

Post by djnzx48 »

I don't know much about AGD versions, but if you're looking to use a compressor, there's a good article here: http://hype.retroscene.org/blog/dev/740.html
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: ZX Spectrum Game Development Noob Questions

Post by Ralf »

AGD is a good choice for someone who doesn't want to go pure assembler path. I don't use it myslef but believe it's quite easy to begin.

It has limitations, you won't be able to make any kind of game with it. You won't do a scrolling game, 3D game or something with really big sprites.

Also people using tools for game making sometimes make their games very similar to other existing ones. I guess it's the problem of starting from the same tutorial example ;)

But a lot is possible. Definitely check games from Alessandro, he certainly knows how to use AGD to make some good and original stuff.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: ZX Spectrum Game Development Noob Questions

Post by Alessandro »

Mozartkügel wrote: Fri Jun 07, 2019 11:46 am One follow up question if I may, does anyone have experience what version of AGD would make sense to use? I noticed there are AGD, MPAGD and AGDX. As I mentioned before I wouldn't be looking to push the limits of the Speccy, rather I'm looking for simplicity but with the possibility for all the parts needed for a finished game and "product". I forgot to mention that the final goal somewhere in the future would still be to put it on C-cassette, so I guess that might imply level compressing (uugh) and loader/tape mastering (eek, help me!) :lol:

@Alessandro Beatuiful games, especially Sophia 1&2 and Doom pit caught my eye! I got to check these out properly asap.
Thanks! :D

About the distinction between the different AGD versions floating around:

Arcade Game Designer. This is the basic original version, created by Jonathan Cauldwell to run on a common 128K and later model. Needless to say it's much easier to develop your game on PC/Linux/Macintosh etc. under emulation and employ real hardware (when available!) just to test it before release. Note: Of course the same applies with every kind of development for such an old system; an advanced text editor like Notepad++ will be very useful in writing your own bits of BASIC/Assembly/C etc.
AGD comes with a detailed guide that contains every information you need to start off creating even a simple test game. The latest stable version is 4.7; there is also a v4.8 around but as Jonathan himself says it's "untested and with no guarantees".
Compared with MPAGD it might seem less user friendly because you must use the keyboard to do everything, and it does not have the same number of keyboard shortcuts and information provided by AGDx. In a nutshell, AGD is pretty much a relic of the past nowadays; even Jonathan has concentrated his efforts on the newer multi-platform version.

Multi-Platform AGD. The newer development environment created by Jonathan runs under Windows and is arguably more accessible to someone who prefers a more conventional point-and-click user interface. It is called Multi-Platform because it can allow you to develop titles for other platforms such as the Amstrad CPC 464 or the ZX Next. Other advantages include the possibility of managing the scripts as simple text files and to export the whole game as a Z80 Assembly source code. However - at least in my experience - it can be difficult to navigate through the various windows, and the saving system seems pretty confusing, with just too many temporary files around. Most recent version is 0.74.

AGDx. This is a reworking of the original AGD editor made by a group called AGD Labs. Basically it lets you do the same things of AGD, but with a much larger amount of information about sprites and graphic blocks, many shortcuts, a sort of undo system, bug fixes etc. That makes it is much easier not only to create your own game but also to add custom bits of code for special sound and/or visual effects. It also employs a sort of shorthand for scripts, for instance PUTBLOCK becomes PBLK. This is done in order to save memory.
Unfortunately, the program is hard to get because it is almost exclusively available through subscription to a closed Facebook group. Personally Facebook is anathema to me because I consider it to be one of the most blatant manifestation of evil :twisted: However AGDx has become my tool of choice since I was working at Sophia II. One of the group members, Mr Highrise (Allan Turvey) has a YouTube channel where he posts tutorials and the odd bit of additional code. The latest version in my possession is 4.7xLb.

Tony Thompson has created a Windows-based environment for AGDx, but after a period of continuous updates, it has not been touched in the last three months. I haven't tried it so I cannot tell you more.

Finally, there is the AGD official forum. Of course it is focused more on AGD and MPAGD, but the advice you find there can be also used in AGDx.

Data compression will be extremely useful if you plan to take advantage of the 128K and later models' extra RAM. Keep in mind that AGD and its derivates are meant to create stand-alone titles that can run on a 48K, but you can author a multi-level game by creating each level as a single distinct game. Most of the times I employed ZX7, a very good and versatile tool made by Einar Saukas. Sometimes I also used Exomizer, which yields slightly higher compression ratios but it's not as fast or flexible as ZX7.

As for tape management, you can, at least for the beginning, stay with the Spectrum ROM loading routines. Custom loaders add extra flair and are useful for people who like to load their games on physical hardware, even from their PCs, but they are not necessary nowadays. That said, I went as far as creating a turbo custom loader myself.
User avatar
Mozartkügel
Drutt
Posts: 27
Joined: Fri Jun 07, 2019 8:19 am
Location: Finland

Re: ZX Spectrum Game Development Noob Questions

Post by Mozartkügel »

Once more, many, many thanks to everyone for all the tips and info! What an uplifting welcome to the Speccy scene! :D I've been checking out a lot of ZX Spectrum homebrew game-videos the last couple of days, and I must say what fantastic, fun & beautiful games there seem to be popping up for it!

Wow, thanks for the extensive info about the different AGD versions Alessandro! I was thinking about using C first, but AGD really gets me excited. I'd need to play around with it some and see how it feels. I'm thinking about MPAGD because of the convenience being able to use a mouse / gui, but there's certainly a charm running AGDx natively (even on an emulator). I think I'll start with doing some pixel art while letting all the thoughts and info settle in.
Alessandro wrote: Fri Jun 07, 2019 9:34 am My games, for instance, usually have beeper sound effects and AY background music.
That sounds like a great idea! Do the newer speccys still have the beeper although they have the AY?
Ralf wrote: Fri Jun 07, 2019 12:31 pm Also people using tools for game making sometimes make their games very similar to other existing ones. I guess it's the problem of starting from the same tutorial example ;)
I'm trying to think of how to not make myself guilty of this. As an artsy-fartsy type I many times appreciate the graphics/pixel art and the music the most In games. I do love some C programming too although I'm not that great at it, however I have to force myself to try and be interested in game design and level design :D I kinda like "generic platformers", haha.
Alessandro wrote: Fri Jun 07, 2019 3:12 pm
Data compression will be extremely useful if you plan to take advantage of the 128K and later models' extra RAM. Keep in mind that AGD and its derivates are meant to create stand-alone titles that can run on a 48K, but you can author a multi-level game by creating each level as a single distinct game. Most of the times I employed ZX7, a very good and versatile tool made by Einar Saukas. Sometimes I also used Exomizer, which yields slightly higher compression ratios but it's not as fast or flexible as ZX7.

As for tape management, you can, at least for the beginning, stay with the Spectrum ROM loading routines. Custom loaders add extra flair and are useful for people who like to load their games on physical hardware, even from their PCs, but they are not necessary nowadays. That said, I went as far as creating a turbo custom loader myself.
Thanks for all the tips! Data compression is still a very "advanced topic" for me. I have to take things one step at a time I think. I've done some small games and C programming for 8-bit systems over the years, and even more than before lately, but I've avoided compression so far :D A loader with a loading screen would definitaly be on the list for my game, but let's see how far in the future that still is with too many 'retrodev' projects started from before, a day job, small kids etc.

I don't know yet how many "user defined characters" / "blocks" and sprites you can have in AGD or on a spectrum (yet), but when I look at your games there seems to be a lot of graphics already in the intro picture, intro menu and then the game itself. Are all those parts "separate games" and new graphics are loaded into ram inbetween? Or perhaps the intro screen and the intro menu is one "game", and then as you said, subsequent levels are also loaded as separate games?

Btw. I thought I saw someone write somewhere that there would be some AY music collection that you can use for your games? Has someone heard of something like that?
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: ZX Spectrum Game Development Noob Questions

Post by djnzx48 »

The 128K models technically don't have a physical beeper, as the design was modified to output sound through the TV speaker. But the beeper is still available on the standard port along with the new AY chip.

You can check out https://zxart.ee/eng/music/ for a large music collection. Or you could find someone willing to write something for you - if you wanted music for a game I could try making a track or two.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: ZX Spectrum Game Development Noob Questions

Post by Alessandro »

Mozartkügel wrote: Sun Jun 09, 2019 12:33 am I don't know yet how many "user defined characters" / "blocks" and sprites you can have in AGD or on a spectrum (yet), but when I look at your games there seems to be a lot of graphics already in the intro picture, intro menu and then the game itself. Are all those parts "separate games" and new graphics are loaded into ram inbetween? Or perhaps the intro screen and the intro menu is one "game", and then as you said, subsequent levels are also loaded as separate games?
Hi, it's pretty much the second thing you wrote. More precisely:
  • the loading screen is loaded separately from tape;
  • the intro screen, key redefinition routine, level management, high score table etc. are all parts of a program specifically written from scratch in Z80 Assembly. In my first attempts I coded the "housekeeping" program in compiled BASIC but then I developed a sort of template in Assembly, much more efficient in terms of speed and RAM usage;
  • levels are stored in the Spectrum (128K and later) RAM banks as "games" authored with AGD and compressed with ZX7 in order to fit into each RAM bank, which can hold up to 16 Kb of data.
However, these are advanced techniques; to this day, as far as I know the only ones who employed AGD to make multi-level games are me and Alexei Kashkarov (kas29). I'd suggest you for the time being to create a simple game that can run on a 48K model just to "learn the ropes". We do it to amuse ourselves and other folks who share our pleasure in retrogaming, so there is no hurry to do everything at once. Heck, the very first game I created was a Manic Miner clone - hardly something that had not been done before :mrgreen:

Finally, AGD allows you to place a maximum of 12 sprites per screen at once. You can define a maximum of 254 low resolution blocks, which can hold different properties - solid blocks, platform blocks, empty (i.e. background) blocks etc. There is no limit at the quantity of different blocks that you can place on each screen instead.

One more suggestion: music can be composed with the beeper as well, but due to the limitations of the Spectrum architecture, it cannot be played while playing but only in menus/intros/outros etc. That is, unless you wish your in-game music to sound like it was played on a muted xylophone :lol: like in Manic Miner, Jet Set Willy or Brian Bloodaxe. For the first purpose, there is a great tracker-like utility called Beepola which re-creates various beeper music engines (here you can find a patched version which corrects a bug in the original). Whether you like them or not is a matter of taste ;) I employed it to compose the intro/outro and menu tunes for my game Cousin Horace - which being designed for the 48K loads in separate parts.
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: ZX Spectrum Game Development Noob Questions

Post by Ralf »

Btw. I thought I saw someone write somewhere that there would be some AY music collection that you can use for your games? Has someone heard of something like that?
As people said there is https://zxart.ee/eng/music/
Or you can also check https://bulba.untergrund.net/music_e.htm

The good tool for working with them is Vortex Tracker. These songs are stored in files like .ay or .pt3 and you need to convert them
to binary or Spectrum tape image so they can be used in a Spectrum program

You'll soon discover that most of these tunes come from Russia and neighbour countries. It's actually not a surprise,
they had and still have a very active demoscene where a lot of music was made just for fun or to be played at the demoparty.

Personally I used some of them in my own games. I'd have an advice - don't expect that you check out 3 tunes and find a proper one
for your game. You'll probably need to search through over 100 of them as most of them are decent but nothing special and very generic.
So finding something standing out of the crowd requires some effort.

You probably should also consider copyright issues. Personally I didn't try to contact the authors (it could be hard in many cases) but always
included the info about them in the final game. I believe it's an honest approach and it worked for me but I'm generally easygoing
about copyrights as I said in many another threads ;)
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: ZX Spectrum Game Development Noob Questions

Post by Alessandro »

I would only add to what Ralf wrote above that the best solution is always to compose your own tunes for the game. Even if your knowledge of music is rudimentary - as it is my case by the way - it is much more satisfying, suits your needs according to the atmosphere you want to give to your game, and you do not have to ask permissions to anyone.

I'd also like to add that about 3 out of 4 AY tracks you are likely to find in repositories are pseudo-techno stuff which makes my ears bleed after a few minutes. Of course, your mileage may vary :lol:
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: ZX Spectrum Game Development Noob Questions

Post by R-Tape »

djnzx48 wrote: Sun Jun 09, 2019 5:59 am Or you could find someone willing to write something for you - if you wanted music for a game I could try making a track or two.
[mention]Mozartkügel[/mention]: BITE. HIS. HAND. OFF. :mrgreen:
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: ZX Spectrum Game Development Noob Questions

Post by djnzx48 »

Ouch, that hurt!!
User avatar
Mozartkügel
Drutt
Posts: 27
Joined: Fri Jun 07, 2019 8:19 am
Location: Finland

Re: ZX Spectrum Game Development Noob Questions

Post by Mozartkügel »

djnzx48 wrote: Sun Jun 09, 2019 5:59 am The 128K models technically don't have a physical beeper, as the design was modified to output sound through the TV speaker. But the beeper is still available on the standard port along with the new AY chip.
Ahaa, thanks!
djnzx48 wrote: Sun Jun 09, 2019 5:59 am You can check out https://zxart.ee/eng/music/ for a large music collection. Or you could find someone willing to write something for you - if you wanted music for a game I could try making a track or two.
Thanks for the link! How kind of you to offer help! Usually I like to do all parts for my games myself, but it's nice to know there's help if I end up in "development hell". :)
Alessandro wrote: Sun Jun 09, 2019 9:38 am Hi, it's pretty much the second thing you wrote. More precisely:
  • the loading screen is loaded separately from tape;
  • the intro screen, key redefinition routine, level management, high score table etc. are all parts of a program specifically written from scratch in Z80 Assembly. In my first attempts I coded the "housekeeping" program in compiled BASIC but then I developed a sort of template in Assembly, much more efficient in terms of speed and RAM usage;
  • levels are stored in the Spectrum (128K and later) RAM banks as "games" authored with AGD and compressed with ZX7 in order to fit into each RAM bank, which can hold up to 16 Kb of data.
However, these are advanced techniques; to this day, as far as I know the only ones who employed AGD to make multi-level games are me and Alexei Kashkarov (kas29). I'd suggest you for the time being to create a simple game that can run on a 48K model just to "learn the ropes". We do it to amuse ourselves and other folks who share our pleasure in retrogaming, so there is no hurry to do everything at once. Heck, the very first game I created was a Manic Miner clone - hardly something that had not been done before :mrgreen:
Thanks for the technical info! "Lost in my Spectrum" looks great in my opinion! What else could you ask from a game! (I'm serious haha). Yeah I guess I should start really small, but the housekeeping part and/or compression is still the goal later. I've done a few small games and tests for other machines before so I'm hungry to expand from mini games to "medium-small games" :D the game I'm working on at the moment "Baron Lovejoy Travels in Time" for the C64/Vic-20/Plus4/Lynx is slowly getting to the point of "learn compression and housekeeping or fail" :mrgreen: (On the Lynx I fortunately know how to load in new parts from cartridge).

Here's a two of my latest Lynx minigames if you/someone wants to check them out:

Reiko's Robot Run (Atari Lynx)
https://youtu.be/Yx6iY0BGHac

Sylvester the Lumberjack (Atari Lynx)
https://youtu.be/sNk89-C9haI

And here's my current work in progress game "Baron Lovejoy Travels in Time" for multiple old systems:

BLJ VIC-20
https://youtu.be/0N5QRlkUTjo

BLJ C64 2.1
https://youtu.be/F4sLV00e0wo

I got this megalomanic idea when I saw a developer called "Misfit" from Finland releasing his game "Rodmän" for several old home computers. Since then I've seen a few similar multi platform projects on the web. It's too much fun getting to understand better how some of the classic systems work and how to create games for them.

I forgot to mention that I looove tape loaders / games on cassette, so preferably a "one load"-game would be the ultimate goal, but I might have to set up things in an easier way to start with. Also I'm hoping to add the ZX Spectrum to the list of "ports" of my game (If I don't start a completely new/separate one for the Speccy). I'm so excited about the Speccy, it's unique graphics, its fantastic homebrew scene and wonderful community. But yeah, I should probably start really small anyway at first with a new system.

Actually I noticed yesterday that Manic Pietro is open source and written in C, so that had me starting to reconsider doing my first Spectrum game in C after all, hmm...

Yeah I agree that there can't be a hurry. After a long day after putting the kids to sleep I have to borrow time from sleep to work on my "retro projects of passion" for a little while, so I've put up a five to ten years time budget for "Baron Lovejoy". :mrgreen:
Alessandro wrote: Sun Jun 09, 2019 9:38 am Finally, AGD allows you to place a maximum of 12 sprites per screen at once. You can define a maximum of 254 low resolution blocks, which can hold different properties - solid blocks, platform blocks, empty (i.e. background) blocks etc. There is no limit at the quantity of different blocks that you can place on each screen instead.
Thanks! I wonder what the sprite size is in AGD? The sprites in your games looked big and nice!

I started wondering about software sprites too. In AGD that seems to be taken care of for you, but if I'd code in C that would be another story. I wouldn't mind having the sprites moving one "cell" / 8 pixels at a time and not being transparent in my first game. Then I could be moving on to more advanced software sprites in a later game. However I haven't yet seen any new homebrew game that doesn't do pixel movement and "transparency", so the standards are already set high on the speccy scene! :D

Does software sprites work about like this simplified: you check where your sprite is -> then copy the data of the background "cells" of that position -> then paste the sprite data (and color data) on top of the bakground data and draw the combined stuff to screen?
Ralf wrote: Sun Jun 09, 2019 11:14 am
Btw. I thought I saw someone write somewhere that there would be some AY music collection that you can use for your games? Has someone heard of something like that?
As people said there is https://zxart.ee/eng/music/
Or you can also check https://bulba.untergrund.net/music_e.htm

Personally I used some of them in my own games. I'd have an advice - don't expect that you check out 3 tunes and find a proper one
for your game. You'll probably need to search through over 100 of them as most of them are decent but nothing special and very generic.
So finding something standing out of the crowd requires some effort.

You probably should also consider copyright issues. Personally I didn't try to contact the authors (it could be hard in many cases) but always
included the info about them in the final game. I believe it's an honest approach and it worked for me but I'm generally easygoing
about copyrights as I said in many another threads ;)
Thanks for all the info Ralf! Yes, the copyright was actually what I was thinking of. I was wondering if it was some sort of database where copmposers knowingly would have put their stuff for use. I guess giving credit and/or trying to contact would be OK in most cases since the database is massive.
Alessandro wrote: Sun Jun 09, 2019 12:45 pm I would only add to what Ralf wrote above that the best solution is always to compose your own tunes for the game. Even if your knowledge of music is rudimentary - as it is my case by the way - it is much more satisfying, suits your needs according to the atmosphere you want to give to your game, and you do not have to ask permissions to anyone.

I'd also like to add that about 3 out of 4 AY tracks you are likely to find in repositories are pseudo-techno stuff which makes my ears bleed after a few minutes. Of course, your mileage may vary :lol:
Yeah, usually I like to do all parts for my games myself, but it's nice to know there's a backup plan if needed. Haha, I grew up on mostly european games in the 80s, so I expect all games to have 80s / early 90s "electronic pop music" no matter what the game is about or what would really be fitting ;D
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: ZX Spectrum Game Development Noob Questions

Post by djnzx48 »

Mozartkügel wrote: Tue Jun 11, 2019 8:06 am I started wondering about software sprites too. In AGD that seems to be taken care of for you, but if I'd code in C that would be another story. I wouldn't mind having the sprites moving one "cell" / 8 pixels at a time and not being transparent in my first game. Then I could be moving on to more advanced software sprites in a later game. However I haven't yet seen any new homebrew game that doesn't do pixel movement and "transparency", so the standards are already set high on the speccy scene! :D
I don't think games using 8-pixel character movement are naturally 'worse'. It can be a great way to have colourful sprites and backgrounds without causing any clash, and makes it easier to do fullscreen scrolling. For some examples you can see: Sgt. Helmet Zero, Sword of Ianna, The Amazing Rocketeer, Metal Man Reloaded.
Mozartkügel wrote: Tue Jun 11, 2019 8:06 am Does software sprites work about like this simplified: you check where your sprite is -> then copy the data of the background "cells" of that position -> then paste the sprite data (and color data) on top of the bakground data and draw the combined stuff to screen?
The main decision to make with sprites is whether you'll draw them directly to the screen, or first draw them to a buffer (to avoid flicker) and then copy that to the screen. If you use a buffer, you don't have to copy the whole thing to the screen every frame, but only the parts that change. With the 128K machines you also have support for native hardware double buffering, so you can sync your graphics to the 50Hz display without the need for expensive copying.

For masked sprites, a common technique is to save the background area where the sprite needs to go into a buffer, and then draw the sprite onto the screen. (These operations could be combined into one step.) Then to erase the sprite, you copy the background back.

Many games also use XORed sprites, which are a lot simpler. After using XOR to draw a sprite, XORing it back in the exact same place will erase it, eliminating the need for separate buffers. The downside is that simple backgrounds are required, and they don't look so good when one sprite overlaps another.

When using coloured sprites, you also need to decide how the sprite colours will interact with the background. Many games will have the main sprite assume the colour of whatever background element is behind it. However, you can also choose to display the main sprite with its own colour, resulting in a coloured mask that follows the character around. The Wally games are a good example of this.
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: ZX Spectrum Game Development Noob Questions

Post by Ralf »

Sylvester the Lumberjack (Atari Lynx)
You could really try to do a Spectrum clone of Lumberjack game. If would be easy enough and if I recall correctly you said you have some artistic skills so nice graphics would help a lot.

Let me explain more about this Lumberjack thing if someone missed it. It all began a few years ago with indie game for modern computers coming form Poland, my home country (that's why I rememeber about it ;) )

So there is an extremely simple game about Lumberjack chopping a tree. But some people say it's very playable, at least for a short time ;)
It got quite a lot of clones on retro systems.

It would be nice to have it on Spectrum as well.

Examples for C64 and Amiga:
https://www.youtube.com/watch?v=LXFEwsI5ifs

https://www.youtube.com/watch?v=jm_fXT3DpgI
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: ZX Spectrum Game Development Noob Questions

Post by R-Tape »

Ralf wrote: Tue Jun 11, 2019 10:22 am You could really try to do a Spectrum clone of Lumberjack game. If would be easy enough and if I recall correctly you said you have some artistic skills so nice graphics would help a lot.
I think you should have a bash at this too Ralf. Considering the amazing job you did on Flappy Bird ZX, this has your name all over it!
User avatar
Mozartkügel
Drutt
Posts: 27
Joined: Fri Jun 07, 2019 8:19 am
Location: Finland

Re: ZX Spectrum Game Development Noob Questions

Post by Mozartkügel »

djnzx48 wrote: Tue Jun 11, 2019 9:51 am
I don't think games using 8-pixel character movement are naturally 'worse'. It can be a great way to have colourful sprites and backgrounds without causing any clash, and makes it easier to do fullscreen scrolling. For some examples you can see: Sgt. Helmet Zero, Sword of Ianna, The Amazing Rocketeer, Metal Man Reloaded.
I agree that it's not worse by default. Ah, I love all those nifty ways people work with the limitations of the Speccy and create beautiful graphics!

Thanks for the info on software sprites, this helps a lot understanding them better!
Ralf wrote: Tue Jun 11, 2019 10:22 am
Sylvester the Lumberjack (Atari Lynx)
You could really try to do a Spectrum clone of Lumberjack game. If would be easy enough and if I recall correctly you said you have some artistic skills so nice graphics would help a lot.

Let me explain more about this Lumberjack thing if someone missed it. It all began a few years ago with indie game for modern computers coming form Poland, my home country (that's why I rememeber about it ;) )

So there is an extremely simple game about Lumberjack chopping a tree. But some people say it's very playable, at least for a short time ;)
It got quite a lot of clones on retro systems.

It would be nice to have it on Spectrum as well.
I really loved the idea of that game, that's why I wanted to borrow the idea and make a version of my own for the Lynx. Nintendo's Game & Watch games were the first video games I ever played as a kid (a few friends had them), and I loved them immediately :D Simple and frantic games like that can be very fun. I think many people our age go full circle with games and start enjoying more simple games again on "retro" machines. Vectrex Roli puts it in a very funny way here in this video (about 10:35 - 12:00)
https://youtu.be/0LVAp23opAo?t=635

Btw. Amiga version obviously gets bonus points for having Monty Python's lumberjack song as background music. :mrgreen:

This Timberman Game & Watch video made me giggle as well:
https://www.youtube.com/watch?v=WFj3HKCTaQM

I've considered porting the Lumberjack game to other systems, but I think I want to do something new, because at first I did a prototype of it on Pico-8, then I took it pretty far on the Gamebuino Meta until I realized (once again) that I can't get proper enjoyment unless I create games for REAL old school systems, so then I started it a third time for the Lynx and finished it. So I've almost done it three times already :D I suppose quite a lot of the C code would be re-usable on the Speccy with Z88DK. I need to think about it some more, because starting out really small would indeed probably be a good idea.
User avatar
Joefish
Rick Dangerous
Posts: 2042
Joined: Tue Nov 14, 2017 10:26 am

Re: ZX Spectrum Game Development Noob Questions

Post by Joefish »

One option you can take with character movement and machine code is to define yourself up to 256 UDGs, each with its own colour attribute. Make sure you can draw all your levels and all your sprites from these 256.

Then, your back-buffer for preparing a screen is a 'map' that only needs one byte per character space, to store the UDG that goes there. This lets you redraw a changing or scrolling background into the buffer very fast. The buffer can also be bigger than the screen you want to show, so things like 3x3 or 4x4 tiles can be drawn 'over-the-edge' of the screen display. Then you add your sprites as more UDGs (again, just one byte per character space). Then what you need is a fast renderer that can re-draw the real screen quickly from this UDG 'map'.

There are several optimisations you can make to speed things up:
(1) Store the UDGs starting at a memory address divisible by 256. And store the first byte of all 256 UDGs first, then the second, then the third...etc. to the eighth byte, then 256 attribute bytes. To access a UDG, set the high byte of a memory address to where they start, then put the UDG number in the low byte. That tells you where the UDG starts. To get the next byte of the UDG, in machine code, you can INC the high-byte of the memory address (instead of the low byte) to skip forward 256 bytes.
(2) Have UDG #0 as your empty background, and set its INK and PAPER the same. Then your renderer knows for character 0 it only has to copy the attribute to the screen, not any pixel data. You could have, for example, the first 8 UDGs simply have the same colour INK as they do PAPER, and program the renderer to only copy their attributes, not pixels - for a range of colours.

For semi-transparent sprites (i.e. they let the PAPER colour of the background through in places) your map needs to store 2 bytes per character cell; one for the UDG and one for the attribute. You might want to store 10 bytes of data to define each UDG - 8 bytes for pixel data, one byte for an 'AND-mask' of which background attribute bits to let through and a second 'OR-byte' (or 'XOR' byte) of which attribute bits to forcibly set in the combined attribute of sprite and background. Then when you draw a sprite, whichever background colour is already set for that character cell, your sprite UDG replaces it for pixel data, but combines the previous PAPER colour with its own INK.
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: ZX Spectrum Game Development Noob Questions

Post by djnzx48 »

There's an interesting approach described here, using compiled 8x8 tile routines to quickly scroll the screen. I made a small demo based on that concept and it works quite nicely, but I only managed as far as a static screen display.
User avatar
Mozartkügel
Drutt
Posts: 27
Joined: Fri Jun 07, 2019 8:19 am
Location: Finland

Re: ZX Spectrum Game Development Noob Questions

Post by Mozartkügel »

[mention]Joefish[/mention] This is beyond my programming capabilities (at least yet ;) ) but very informative and interesting stuff nevertheless! I can understand it theoretically, but I wouldn't be able to translate it into code. I'll need to start out simpler. Anyway, I'm sure there's others who will benefit from this knowledge you shared too.

[mention]djnzx48[/mention] Thanks for linking to that approach too!
Post Reply