How is a 3D game like Ant Attack implemented?
How is a 3D game like Ant Attack implemented?
It occurred to me the other day, when I happened to see a screenshot of Ant Attack, that I have absolutely no idea how that sort of 3D display is implemented. I'm talking about the walls, as opposed to the characters (which I presume are sprites laid over the background). From a layman's perspective, it looks like the structures are made from vertical and diagonal lines, with stipple shading of different intensities on either side. Well I can draw lines, but how do you quickly fill an area with a stipple pattern?
I'm guessing the answer is that you don't "fill" an area. It'd be very slow. So maybe there's a selection of UDGs showing the shapes and corners, which are joined together to give the 3D structures effect? Is there a map, which contains the layout, from which the characters are found and printed? Or just a structure describing the graphics? There must be a map of some sort otherwise the game engine wouldn't know when the player is standing on a structure.
I was sort of under the impression that later 3D games had a set of graphical blocks which are drawn back to front. Maybe that's wrong too? But it really doesn't look like something like Ant Attack would be done that way.
So, keeping it dumb if you could guys ( ), how's it done?
I'm guessing the answer is that you don't "fill" an area. It'd be very slow. So maybe there's a selection of UDGs showing the shapes and corners, which are joined together to give the 3D structures effect? Is there a map, which contains the layout, from which the characters are found and printed? Or just a structure describing the graphics? There must be a map of some sort otherwise the game engine wouldn't know when the player is standing on a structure.
I was sort of under the impression that later 3D games had a set of graphical blocks which are drawn back to front. Maybe that's wrong too? But it really doesn't look like something like Ant Attack would be done that way.
So, keeping it dumb if you could guys ( ), how's it done?
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.
Re: How is a 3D game like Ant Attack implemented?
Well, I have a feeling that you are thinking in Zx Basic terms. That games like Ant Attack use UGDs, and instructions like PLOT or DRAW
Actually Ant Attack is writen mostly in machine code. It works a bit differently. You don't draw "lines" and later "fill" there. Drawing walls is the same operation as drawing sprites - copying bytes to screen memory. You don't draw outline and fill it later, you draw it already filled.
And I believe you draw it from top to bottom. So you draw the objects most far away first and the objects nearer later. This way you can partially or totally cover farer objects with nearer objects.
Others maybe will write more.
Actually Ant Attack is writen mostly in machine code. It works a bit differently. You don't draw "lines" and later "fill" there. Drawing walls is the same operation as drawing sprites - copying bytes to screen memory. You don't draw outline and fill it later, you draw it already filled.
And I believe you draw it from top to bottom. So you draw the objects most far away first and the objects nearer later. This way you can partially or totally cover farer objects with nearer objects.
Others maybe will write more.
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: How is a 3D game like Ant Attack implemented?
Here are the author’s notes on the game. He actually wrote on paper without an assembler on hand.
More about the game here.
More about the game here.
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.
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.
- arkannoyed
- Manic Miner
- Posts: 436
- Joined: Mon Feb 05, 2018 9:56 am
- Location: Northamptonshire
Re: How is a 3D game like Ant Attack implemented?
Generally the blocks are printed from the furthest away first, then the ones in front overwrite what lies behind them. In some cases there are checks to negate printing stuff that will eventually not be seen, but in the interests of speed, that’s often overlooked.if you look at one of the animated gifs I’ve posted previously of how chess2k18 constructs its board and pieces, you can see the process very clearly. Only difference being that the board squares and pieces print from the bottom up.
Re: How is a 3D game like Ant Attack implemented?
You draw the screen as blocks from back to front, and bottom to top of each stack. The blocks overlay each other so they appear to merge into single columns.
The problem comes when you want to update things quickly or scroll the screen.
I don't really know how Ant Attack does it, but if you look its map is fairly sparse so it could just be redrawing what's on screen every frame.
Knight Lore is quite slow when there are more things on screen, particularly moving things, as it keeps redrawing everything. If you look at a cheap game like Kirel you only move in whole blocks and it's very slow to update - presumably redrawing everything each time.
Quazatron is faster because the levels are laid out almost like the pyramid in Q*Bert, where it's impossible to go behind any of the scenery. It only has to sort the order of the sprites. Marble Madness and Gyroscope are other examples. Fairlight is similar, with painted backdrops, although with more sprites for things like tables, balconies, door-frames etc. that you can walk behind.
Head-Over-Heels optimises things for speed by defining a rectangle around the player sprite, and only redrawing blocks (in order) that overlap that area. Then that little area is copied to the screen. That way, it doesn't have to redraw everything on screen, and only has to redraw the area around enemies when they move. Having a small working window, instead of prepping the whole screen, also saves on memory usage, leaving more room for level data.
The problem comes when you want to update things quickly or scroll the screen.
I don't really know how Ant Attack does it, but if you look its map is fairly sparse so it could just be redrawing what's on screen every frame.
Knight Lore is quite slow when there are more things on screen, particularly moving things, as it keeps redrawing everything. If you look at a cheap game like Kirel you only move in whole blocks and it's very slow to update - presumably redrawing everything each time.
Quazatron is faster because the levels are laid out almost like the pyramid in Q*Bert, where it's impossible to go behind any of the scenery. It only has to sort the order of the sprites. Marble Madness and Gyroscope are other examples. Fairlight is similar, with painted backdrops, although with more sprites for things like tables, balconies, door-frames etc. that you can walk behind.
Head-Over-Heels optimises things for speed by defining a rectangle around the player sprite, and only redrawing blocks (in order) that overlap that area. Then that little area is copied to the screen. That way, it doesn't have to redraw everything on screen, and only has to redraw the area around enemies when they move. Having a small working window, instead of prepping the whole screen, also saves on memory usage, leaving more room for level data.
Re: How is a 3D game like Ant Attack implemented?
I posted this on another thread, but this is how Bobby Bearing draw the blocks inside the buffer on each screen transition, from left to right, bottom to top:
Re: How is a 3D game like Ant Attack implemented?
Isn't that another one where you can't actually go 'behind' any part of the scenery?
So it's all just moving sprites, and occasionally blocks done as sprites so they can move, or come down on top of you.
So it's all just moving sprites, and occasionally blocks done as sprites so they can move, or come down on top of you.
Re: How is a 3D game like Ant Attack implemented?
Excellent interview with Sandy White about how he created Ant Attack. He comes across as a really nice bloke!
[media]https://www.youtube.com/watch?v=RdrgBwSH9W8[/media]
I really wish he'd write a bit about his custom development hardware he made for his Spectrum. All there is is this tiny photo and what he mentions in the video.
[media]https://www.youtube.com/watch?v=RdrgBwSH9W8[/media]
I really wish he'd write a bit about his custom development hardware he made for his Spectrum. All there is is this tiny photo and what he mentions in the video.
Re: How is a 3D game like Ant Attack implemented?
https://spectrumcomputing.co.uk/index.p ... 6&id=21605
Something quite similar looking although not even close to being in the same league in game play!
Source code is there too if you want to take a look.
Something quite similar looking although not even close to being in the same league in game play!
Source code is there too if you want to take a look.
Re: How is a 3D game like Ant Attack implemented?
And Alien Evolution has a similar style, not sure if it uses the same technique: https://spectrumcomputing.co.uk/index.php?cat=96&id=149
Re: How is a 3D game like Ant Attack implemented?
It runs nicely enough, but what do you actually do? Am I missing the instructions somewhere?Woodster wrote: ↑Tue Jan 21, 2020 6:35 pm https://spectrumcomputing.co.uk/index.p ... 6&id=21605
Something quite similar looking although not even close to being in the same league in game play!
Source code is there too if you want to take a look.
Re: How is a 3D game like Ant Attack implemented?
I've finally found the "Softy" that he talks about in the video! It's one of these:Firefox wrote: ↑Tue Jan 21, 2020 6:25 pm Excellent interview with Sandy White about how he created Ant Attack. He comes across as a really nice bloke!
[media]https://www.youtube.com/watch?v=RdrgBwSH9W8[/media]
I really wish he'd write a bit about his custom development hardware he made for his Spectrum. All there is is this tiny photo and what he mentions in the video.
(There are photos and adverts for the first four generations of Softy on this page, and you can download a PDF of the first Softy's manual.)
So it turns out that a Softy is a kind mash-up of a ZX80, an EPROM programmer, and a ROM emulator. There's no BASIC interpreter or anything, just a little monitor-type program which allows you to edit hex values on a telly. The keyboard only has hex digits and monitor commands on it! It can emulate an EPROM via a cable that plugs into a DIP socket on the target system. It can also program EPROMs using the ZIF socket next to the keyboard.
If you zoom in on the tiny photo from Sandy's website above, you can make out that the thing in the foreground is a Softy, which has a big ribbon cable plugged into a homebrew Spectrum peripheral which is sitting in the mid-ground in the photo.
I'm still not entirely sure what his homebrew Spectrum peripheral did or how he actually used it, though.
If you compare a dump of Ant Attack to the hand assembled code on the sheet of lined A4, exactly those values are at the start address written on the sheet.
The Softy only has 1kB internally for buffering data in an emulated ROM, so... I'm guessing his peripheral disabled the Spectrum's ROM and replaced it with some kind of monitor ROM (probably much smaller than 16kB is size) that allowed data to be copied back and forth between the 1kB Softy area and the Spectrum's upper RAM?
Don't know how he would've saved his work between sessions. On EPROMs? On tape? (The Softy has a tape interface as well as the Spectrum.)
- Alessandro
- Dynamite Dan
- Posts: 1910
- Joined: Wed Nov 15, 2017 11:10 am
- Location: Messina, Italy
- Contact:
Re: How is a 3D game like Ant Attack implemented?
In the answers to his website's guestbook, Sandy tells some interesting stories about the game. For instance, he replied to me (almost 19 years ago! ) that by placing an AM radio beside the Spectrum while running Ant Attack, you can tune it to the RF produced by the Z80 chip and the circuit board, so you can actually hear the program executing, and that he used this method for debugging the code sometimes. By listening to the sound of the code executing, he was, for example, able to understand where it had got stuck if it crashed.
Re: How is a 3D game like Ant Attack implemented?
...Holy cr@p....Alessandro wrote: ↑Thu Jan 23, 2020 11:06 pm In the answers to his website's guestbook, Sandy tells some interesting stories about the game. For instance, he replied to me (almost 19 years ago! ) that by placing an AM radio beside the Spectrum while running Ant Attack, you can tune it to the RF produced by the Z80 chip and the circuit board, so you can actually hear the program executing, and that he used this method for debugging the code sometimes. By listening to the sound of the code executing, he was, for example, able to understand where it had got stuck if it crashed.
My Speccy site: thirdharmoniser.com
Re: How is a 3D game like Ant Attack implemented?
Nice. It never occurred ot me that the blocks are all either columns of a certain height, or a single block floating at height.Woodster wrote: ↑Tue Jan 21, 2020 6:35 pm https://spectrumcomputing.co.uk/index.p ... 6&id=21605
Source code is there too if you want to take a look.
That allows for both memory and speed optimisations, and you don't even realise there are things it can't do, like one block floating above another.
You could probably use the same optimisation for something like Knight Lore, except for perhaps wanting to put a deadly object under a disappearing platform. Although Head Over Heels would just use a deadly floor instead...
Re: How is a 3D game like Ant Attack implemented?
Many thanks for the tip, Alessandro!Alessandro wrote: ↑Thu Jan 23, 2020 11:06 pm In the answers to his website's guestbook, Sandy tells some interesting stories about the game.
On the first page is this gem:
Droky from Spain wrote: Ufff...too many hours playing AA on my B&W TV... Could you explain what are the devices that are
plugging in your speccy in the photo? Thanks for make me the life more funny (and sorry for my poor
english
So now I'm thinking that Sandy actually used a 16k Spectrum and his mysterious homebrew peripheral was actually a combined ROM + RAM pack. (Also, Sandy must have had a Softy 2 which could emulate 4kB ROMs - the original could only do 2kB.) I don't think it could have been a 48k Spectrum because it's not possible to override the upper memory from the edge connector (unlike the ZX81).Sandy White wrote: Hi Droky, I spent too many hours in front of a B&W TV too, writing AA! I wonder if they still make
B&W TVs? Anyway, glad you have enjoyed playing AA! One of the devices in the photo is a "Softy"
ROM emulator, and the other is a home-made adaptor which mapped the Softy into 4K of the Spectrum's
memory. Apart from the city data, and some BASIC to do scoring screens, AA fitted entirely into that
4K! The advantage was that if the Speccy crashed, it didn't take my machine code with it!
The Hacking 3D Ant Attack page has some good info on the memory layout of the game.
From that I think the ROM + RAM pack was probably organised like this:
Code: Select all
8000 4kB Softy (emulated ROM containing machine code)
9000 4kB EPROM (text messages + ammo box / girl graphics)
a000 4kB RAM (screen buffer)
b000 4kB RAM (buffers, state info, then graphics data from b700 on)
c000 4kB RAM? (city data)
d000 4kB RAM? (city data)
e000 4kB RAM? (city data)
f000 4kB RAM? (city data)
The city map could be in EPROM, but Sandy mentions several times that the unused aeroplane sprite was used in early development to indicate which block on the map was being edited.
Phew! Fun detective work! I'd still *really* like to see some decent photos of his homebrew gizmo, though.
Re: How is a 3D game like Ant Attack implemented?
If he was this kind of homebrew legend then he could have modded his board to get access to all the address lines before the ULA, couldn't he?Firefox wrote: ↑Fri Jan 24, 2020 5:28 pm So now I'm thinking that Sandy actually used a 16k Spectrum and his mysterious homebrew peripheral was actually a combined ROM + RAM pack. (Also, Sandy must have had a Softy 2 which could emulate 4kB ROMs - the original could only do 2kB.) I don't think it could have been a 48k Spectrum because it's not possible to override the upper memory from the edge connector (unlike the ZX81).
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: How is a 3D game like Ant Attack implemented?
"Sound of code" would make a great name for an album of some psychedelic nerdcore musicIn the answers to his website's guestbook, Sandy tells some interesting stories about the game. For instance, he replied to me (almost 19 years ago! ) that by placing an AM radio beside the Spectrum while running Ant Attack, you can tune it to the RF produced by the Z80 chip and the circuit board, so you can actually hear the program executing, and that he used this method for debugging the code sometimes. By listening to the sound of the code executing, he was, for example, able to understand where it had got stuck if it crashed.
Re: How is a 3D game like Ant Attack implemented?
I mean, it's possible, but he'd have to replace a 48k Spectrum's upper RAM's RAS/CAS generation logic on the main board with something more complicated that cut a 4kB or 8kB hole in the address map to allow the homebrew peripheral to respond to the address range without causing contention. The 16k Spectrum doesn't have that fitted, so it's much easier to build a plug-in gizmo that takes care of the whole top 32kB of the address map (essentially just a slightly fancier RAM pack).
I don't know for sure, I'm just having fun geeking out and trying to piece together how he did it from the scant clues available.
- WhatHoSnorkers
- Manic Miner
- Posts: 254
- Joined: Tue Dec 10, 2019 3:22 pm
Re: How is a 3D game like Ant Attack implemented?
I have a book on Software Testing from the old days, and this sort of thing was quite common back in the day. There's an album by Johan Johansson where he has a recording of music his father made by putting a radio inside an IBM 1401 computer and running various programs; quite haunting.Alessandro wrote: ↑Thu Jan 23, 2020 11:06 pm In the answers to his website's guestbook, Sandy tells some interesting stories about the game. For instance, he replied to me (almost 19 years ago! ) that by placing an AM radio beside the Spectrum while running Ant Attack, you can tune it to the RF produced by the Z80 chip and the circuit board, so you can actually hear the program executing, and that he used this method for debugging the code sometimes. By listening to the sound of the code executing, he was, for example, able to understand where it had got stuck if it crashed.
I have a little YouTube channel of nonsense
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
Re: How is a 3D game like Ant Attack implemented?
I need to have a go at something like this myself. I didn't think it could all be redrawn every frame fast enough, but with some optimisations it seems that's exactly what is going on. And drawing either a column or a floating block, rather than every possible combination of 8 block positions in a stack, allows for even more optimisation. I've got an idea for a different approach to the rendering though...
Re: How is a 3D game like Ant Attack implemented?
Ant Attack as an introduction to programming
https://happy-computing.weebly.com/tape.html
Pretty nice, but unfinished...
https://happy-computing.weebly.com/tape.html
Pretty nice, but unfinished...
Re: How is a 3D game like Ant Attack implemented?
Apologies, I’m unable to view a video where I am so I don’t know whether this is already addressed but because Ant Attack uses a regular grid of fixed-size blocks, there’s no need to draw back-to-front. You can very cheaply populate the screen — sprites aside — with no overdraw whatsoever by walking the level data from front to back and stopping as soon as you hit something to populate a triangular grid; since the triangles are a fixed shape they’re just bitmaps in the end.
Since the sprites can move only in integer grid positions it’s also easy to paint them on top without much complexity.
It’s only if you introduce map elements that are not exactly grid aligned that you need to start coming up with solutions that involve overdraw.
Since the sprites can move only in integer grid positions it’s also easy to paint them on top without much complexity.
It’s only if you introduce map elements that are not exactly grid aligned that you need to start coming up with solutions that involve overdraw.
Re: How is a 3D game like Ant Attack implemented?
If that's what you think, go ahead and try it! But that's not how Ant Attack or any of these other isometric games work.
That's how voxel-based games on PCs work, but the Spectrum doesn't have the processing power to work like that. Any one block might only be partly obscuring another block. So do you divide all your blocks up into 8 triangles and check against all 8 x 1/8s of the blocks that may be behind it? Or is it quicker just to draw them all over the top of each other?
That's how voxel-based games on PCs work, but the Spectrum doesn't have the processing power to work like that. Any one block might only be partly obscuring another block. So do you divide all your blocks up into 8 triangles and check against all 8 x 1/8s of the blocks that may be behind it? Or is it quicker just to draw them all over the top of each other?