TileMap v1.0

Struggling with Fuse or trying to find an emulator with a specific feature. Ask your questions here.
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

TileMap v1.0

Post by obo »

I've released version 1.0 of TileMap, my playable game map (Windows only). It runs many Spectrum emulations in parallel, with some data sharing between instances.

The test version from a few months back only supported Jet Set Willy. This update adds Jet Set Willy II+, Dynamite Dan, Dynamite Dan II, Spindizzy, Starquake, and Technician Ted. I've a couple more games in the works too.

Download from: https://simonowen.com/spectrum/tilemap/
User avatar
g0blinish
Manic Miner
Posts: 281
Joined: Sun Jun 17, 2018 2:54 pm

Re: TileMap v1.0

Post by g0blinish »

32bit need too.
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

g0blinish wrote: Sun Oct 28, 2018 6:11 am 32bit need too.
Added! It's not quite as fast as the 64-bit version, but it may be the only option for some.
User avatar
hitm4n
Manic Miner
Posts: 604
Joined: Fri Nov 17, 2017 12:56 pm

Re: TileMap v1.0

Post by hitm4n »

What an awesome idea and app. Enjoyed watvhing the Starquake vid from your site.
I don't have anything cool to put here, so i'll just be off now to see a priest with yeast stuck between his teeth and his friend called Keith who's a hairpiece thief...
llewelyn
Manic Miner
Posts: 205
Joined: Thu Feb 22, 2018 3:27 pm
Location: virginias eastern shore
Contact:

Re: TileMap v1.0

Post by llewelyn »

An explanation would be nice! I mean, I went to your download page and watched the video of 'spindizzy' and so I assume that the advantage is of being able to move around the entire playable area? The controls are a bit confusing though - its probably me being thick and ancient and not a games player as a rule!

Looks jolly nice though and must have been a hell of a lot of work. Congrats.
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: TileMap v1.0

Post by Einar Saukas »

Great app!

It would make games like Sabre Wulf a lot easier. You would instantly see location of all map pieces and the path to reach them...
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: TileMap v1.0

Post by Ralf »

I've got an error message at start:

Sorry, your D3D hardware lacks structured buffer support

Does it mean that some modern graphic card is required?
User avatar
Kweepa
Manic Miner
Posts: 311
Joined: Sat Feb 03, 2018 6:14 pm
Location: Albuquerque, New Mexico

Re: TileMap v1.0

Post by Kweepa »

This is incredible! Great work!
I love that it only runs the rooms you can see, and presumably has to synchronise them when they are revealed.
And even fully zoomed out in JSW the 64bit version only uses about 25% CPU and runs at 50fps (on my laptop).

I have a couple of suggestions:
- presumably Spindizzy is drawn back to front. If the player sprite is blocked you could just draw the room(s) in front semi transparent, fading them in and out... Oh, having read the controls I see you manually turn off the other rooms. Probably a lot more work then.
- the movement from room to room is rather jerky in the video. maybe if the player xy doesn't change much you could move more smoothly (eg using a damped approach function).
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

llewelyn wrote: Sun Oct 28, 2018 2:54 pm An explanation would be nice!
I'd say more people have been confused by it than got it straight away! It lets you play the original games, but see more than just a single room. That's about all it does. I'll write up some details on how it works, in case anyone wants to try converting other games (not all are suitable).

Einar Saukas wrote: Sun Oct 28, 2018 3:25 pm Great app!

It would make games like Sabre Wulf a lot easier. You would instantly see location of all map pieces and the path to reach them...
I've mostly added Sabre Wulf, but have some data synchronisation issues to solve, so it didn't make it into v1.0. You're right it does make the games a lot easier, though I've been enjoying just exploring -- that's why game cheats are on by default too. :)

Ralf wrote: Sun Oct 28, 2018 3:39 pm I've got an error message at start:

Sorry, your D3D hardware lacks structured buffer support

Does it mean that some modern graphic card is required?
I've tested it on systems with Intel integrated graphics from a few years ago, so it shouldn't need anything too new or fancy. It could be worth updating your graphics drivers to see if that helps. Failing that, PM me some hardware details (motherboard and/or graphics card) and I'll look into it. The structured buffers are needed for byte-level access to the Spectrum display data. At times it's converting hundreds of images every frame, so it needs to be pretty quick.

Kweepa wrote: Sun Oct 28, 2018 3:52 pm I love that it only runs the rooms you can see, and presumably has to synchronise them when they are revealed.
Maybe surprisingly, it doesn't need to do any synchronisation when they're revealed, it just continues running them from where they were. It mostly only needs to synchronise when you change rooms, unless there's some shared global state they need to track (Sabre Wulf does that for the Wulf and Natives).
And even fully zoomed out in JSW the 64bit version only uses about 25% CPU and runs at 50fps (on my laptop).
The CPU runs the Z80 emulations, and copies the Spectrum display data from each at the end of each frame, but that's about it. If you press End to zoom out in Starquake it's running 512 emulations in parallel, which pushes it the hardest of the currently supported games. The GPU still does most of the heavy lifting with display generation, and will probably be 20-50% on a typical system.
- presumably Spindizzy is drawn back to front. If the player sprite is blocked you could just draw the room(s) in front semi transparent, fading them in and out...
The tiles are drawn in the order they're added, but that happens to give enough back-to-front to give the desired effect. However, TileMap doesn't currently know when the player sprite is being blocked, as it sees only flat areas of screen data. Even the screen overlapping is an illusion, using an auto-generated mask. That said, it would be possible to use the coordinates of the main sprite, together with the mask data from screens that could obscure the current screen, to achieve that semi-transparent effect. It's those kind of possibilities that have made TileMap a fun project to work on.
- the movement from room to room is rather jerky in the video. maybe if the player xy doesn't change much you could move more smoothly (eg using a damped approach function).
It does use an easing function [sin(1.5707963 * t], but only over 200ms duration. It may be as simple as increasing the duration, which was mostly chosen for large map jumps. It could perhaps have different values depending on whether the new room is already visible -- short for large jump, longer for smaller pans. I experimented with smooth tracking of Willy in JSW, to always keep him centred, but it looked worse. I think it may be the 50Hz sync on a 60Hz monitor, so I'll have to try again when I can get hold of a GSync monitor.

Thanks for the feedback all!
User avatar
druellan
Dynamite Dan
Posts: 1466
Joined: Tue Apr 03, 2018 7:19 pm

Re: TileMap v1.0

Post by druellan »

What an incredible idea. ¡Love it! Game maps is something I'm starting to dig in, but this is on a whole new level.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: TileMap v1.0

Post by ZXDunny »

Just gonna add a vote for Auf Monty...
User avatar
Pobulous
Dynamite Dan
Posts: 1346
Joined: Wed Nov 15, 2017 12:51 pm

Re: TileMap v1.0

Post by Pobulous »

I wonder how far it can be pushed.
How about:
Nonterraqueous
Tantalus
Explorer
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: TileMap v1.0

Post by Morkin »

Quite an intriguing idea. Nice for those of us who struggle to get off the first screen in Technician Ted.. :roll:
Pobulous wrote: Tue Oct 30, 2018 12:21 pm Explorer
:lol:
My Speccy site: thirdharmoniser.com
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

Auf Wiedersehen Monty does seem well suited. Though I don't have an AY emulation at the moment, so no music :(

Tantalus shouldn't be a problem size-wise, though I'm not familiar with the gameplay, which useful to know it's working properly. I remember Nonterraqueous 1 from back in the day, which was big but pretty sparse.

I'm hoping tempt someone else to have a go at porting, once I've got a description of how to do it. Soon...
User avatar
druellan
Dynamite Dan
Posts: 1466
Joined: Tue Apr 03, 2018 7:19 pm

Re: TileMap v1.0

Post by druellan »

Something interesting might be Robin of the Wood, since it is a game based almost purely on random positions on the map.
I'm not sure if the positions are resolved before the player enters a room, but if that is the case, could be interesting to watch realtime 8-)
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

All cases I've seen so far generate the item locations when the game starts, and that seems the best place to do when there are limits to the number of certain items types that can appear. That's certainly true for Dynamite Dan, Dynamite Dan II, Starquake, and Sabre Wulf. Dynamite Dan II does that for objects on all 8 islands at the start of the game, so you can look ahead to see where the record will be!

TileMap waits until the game state has initialised before cloning across all rooms, so they're given the same starting state. That ensures the same items are in each room when the player finally enters them.
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: TileMap v1.0

Post by djnzx48 »

Can this work for games where enemies and objects move between the rooms? I've got a game in mind that I'd be interested in porting with this if it's possible.
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

djnzx48 wrote: Fri Nov 02, 2018 4:20 am Can this work for games where enemies and objects move between the rooms? I've got a game in mind that I'd be interested in porting with this if it's possible.
Yes, though it will require some knowledge of the data involved in the object's state, and maybe the code that manages it.

In Sabre Wulf the Wulf is effectively a global object that moves between rooms, as it runs back and forth at the bottom of the map. In TileMap the active room containing Sabreman owns the Wulf state data, and takes snapshots after it is updated. That data snapshot is global to the game, and before each room runs the Wulf code it takes a fresh copy to synchronise it. It gives the overall effect that there is only one and it's moving between rooms.

It might still depend on the game you have in mind, but I believe it should be possible. There's some flexibility to change the approach if that doesn't quite fit.
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: TileMap v1.0

Post by djnzx48 »

Thanks, I've got a build working now and found the room address, so I'll see if I can make any progress on this.
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

If you're at the stage of building TileMap itself, make sure you've pulled the latest code. I simplified the code hooking yesterday, so existing hook handlers will need adjusting. There are still some build issues with the Z library it uses as a sub-module, which doesn't yet play nice with recent Visual Studio versions. It just means ignoring some link warnings until it gets fixed.

Shout if you need any more details.
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

In case it's useful, I've written up some details on how TileMap works: https://simonowen.com/articles/tilemap/
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: TileMap v1.0

Post by djnzx48 »

Here's what I've managed so far. Still need to get the rooms to remain synchronised and prevent the enemies attacking the player in inactive rooms.

Image

I noticed that BRIGHT colours don't work for some reason, is that just something on my end?
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

It wasn't just you, non-bright colours were broken. It's been like that since the start and I'd never noticed. I've just pushed a fix for it -- thanks!

It's great to see your progress so far! I've generally found most games have a single call to the routine that adds and manages the enemies, which could be returned from in the inactive case. If you're lucky the main loop is a big list of calls, and you can try them off one by one -- that was certainly the case for the Dynamite Dans, and I think Starquake too.

If the synchronisation remains a problem it might need some special handling in the underlying engine. I have wondered whether games that run frame synced could stay frame synced across all instances. If that needs enhancing I'll take a look. I'll see if I can commit a partial progress update for Sabre Wulf, since that has some locking and shared data use, which may work for you too.
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: TileMap v1.0

Post by djnzx48 »

Thanks, the Sabre Wulf code would be useful to look at. I've located the main loop which does happen to be a series of CALLs, and I've found some addresses for the enemy structures. This game has some quite odd code in places, such as using a loop of LDI: DJNZ to draw the sprite rows even though they're only three columns wide.

I don't think it uses any HALTs so it might be a problem that some rooms run faster than others. If the enemies are being synced every frame then maybe it doesn't matter that the collion code is still running?

I'm not sure how to go about finding the RNG seed, since I couldn't find any references to FRAMES. There's a single LD A, R instruction operating on something that looks like it might be an RNG, but I haven't checked it yet.
obo
Drutt
Posts: 31
Joined: Sat Sep 01, 2018 11:08 am
Location: Nottingham, UK
Contact:

Re: TileMap v1.0

Post by obo »

I'll look at getting some SW code up after work tomorrow, as it's getting a bit late here now. It's also not frame synced, and even worse it runs the player at intervals that depend on when the ROM frame counter advances. For that reason I used a single hook to either store the data (active room) or fetch a copy to use (other rooms). It's using a std::shared_lock so multiple threads can read, the single writing thread can have exclusive access to update it.

For the RNG, I'd probably start by randomising the Z80_R(tile) value after loading the snapshot to see if it helps. I've been tracking down the use of R in SpecEmu using Debug -> Run Until -> Opcode -> LD A,R. If they don't trigger it might require a bit of extra detective work. A typical RNG will usually read a few values, have some shifts and maybe XORs, and store back in the same location it read from. They tend to look fairly distinctive.
Post Reply