WIP:Dig Dug

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
User avatar
D3thAdd3r
Posts: 3293
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

WIP:Dig Dug

Post by D3thAdd3r »

I alluded to doing a port of Dig Dug, so I will just show a recent screenshot now that I have quite a lot of the game finished. I have about a 1.5 months of on and off development so far:
ddtest.jpg
ddtest.jpg (118.29 KiB) Viewed 6976 times
It is not finished, but I got across a huge hurdle that I was totally stuck on. Naturally you do all the little details that come easy and eventually you are 80% done, and all the things that did not have an immediately apparent solution are left to do. Thus the last 20% is as much work as the prior 80% in developing games, I find :roll:

The digging code was the hurdle and ended up being very difficult because of some of the nuances of the original which I wanted to replicate perfectly, and was about 75% of the time doing frame by frame+memory watching in an emulator and 75% more time trying and scrapping much code. Ended up with a whole bunch of tables to determine what tiles get dug at what distance, what tiles they turn into, per direction....pretty happy it works with just a couple bugs I know how to fix via table editing..quite epic how much time I dumped into this part of it but hell, it works now! I tried to dig out "uzebox" in the screenshot, with an arguable level of success there :lol:
dddigintro.jpg
dddigintro.jpg (42.86 KiB) Viewed 6972 times
High score and title screen are done, lives, 1ups, game overs, that is all done. I am most likely taking a deviation from the original, in that I converted it to single player only. This is due to ram limitations available to store the field state between player swaps;this might be a non-issue in the end with the 4bpp modes, but I will have to see where I am at when I get there. I do not think 2 player alternating gamelay, as the original, is really the pinnacle of multiplayer gaming anyway. So I wont feel bad if 2 player doesn't work out in the end.

I am reworking this to use SD instead of EEPROM to allow more and larger entries. It really is necessary for this game to have that much entries, and I don't care to use 2-3 EEPROM slots for this even though it is easier. I have rather elaborate, for an Uzebox game, graphics for both title/high score screens. Currently I went back to mode 3 for now to finish game logic, so I do not have the ability to display the title graphics as they make the game >64k. A very large decision needs to be made and I am procrastinating. Mode 13 or Mode 74. Either of these makes flash a non-issue, even with the large decorative graphics. Mode 13 would require a redesign of the title graphics(I have too much time into making them, to ditch them lightly), or possibly omitting them for the 128 tile limits. Ram tile tricks are required at a minimum. Mode 74 is more narrow than Mode 13, so I cannot do the side score panel in that case. Then I must do the score like the arcade version above the playfield....but this then comes tight up against the already short screen.....the screen needs to be short to blit 64 ram tiles...so many things pushing up against each other. The game itself simply cannot be done well with mode 3, because there is up to 8 enemies and there is bad flicker with even 6 due to ram tile limits. That's graphics stuff but I will figure it out, nothing that can't be done just decisions to make.

I have a possible work around for the short screen. It seems it might work well to fall back to 56 ram tiles(which buys me ram to do 2 player) without much flicker, and that also saves cycles in the worst case scenarios. I fear when all is said and done, I will have to drop to a screen height of 24 tiles to blit that much at slower 4bpp;that sucks. I think(and this makes mode 74's narrowness less of an issue) that I will do scoreboard on top, and make the field wider than the NES version that this port currently looks like. This will then be more like the arcade and have much more room to play in;so it is actually a gameplay issue as well..NES version is not ideal. With 24 or 25 tiles high it is even shorter than the NES version, so setting up the high point value-multi enemy squishing-rock falls that are the pinnacle of high skill play becomes almost impossible. I am probably going to scroll the whole field vertically to follow the player, so that the logical size of the playfield matches the arcade version even though you cannot see it all at the same time. This is the method GameBoy and PS1 ports I have seen dealt with it(arcade was vertically oriented). This saves the game from being a crappy port basically.

Sound, it is all there already. It is a clone of the NES sound and was done in my normal NSF->Midi->Uzebox method. This was made rather easy with Nebososo's Patch tool. It is essentially indiscernible from the original on all accounts. None of it uses noise or PCM. The inline mixer is used, and UART is turned on. There is an untested network state machine that retrieves the latest high scores in the background while waiting for vsync flag. This works with a tiny Tx/Rx buffer, and it only does the heavy stuff during the high score screen. I may have finally found a generic way to do this, and the uzebox.net server was built with this tiny buffer, zmodem-esque method in mind.

That's it for now. The player walks, digs, and responds to demo input almost perfectly. The harpoon shooting/pumping half way works, but the enemies do not function correctly with this yet. Once I get the enemies actually moving correctly I will release a playable demo. There is a lot of enemy logic already done, and as with all of this stuff, it was painstakingly derived by frame by frame analysis of the NES version with some hints from the Atari 7800 version's assembly code. In the end I will be happy if it feels authentic to the original, but enemy AI will likely not be exactly the same behavior.

Rant over for now, thanks for the interest if you read even half of that, the first playable demo might be the finished version if development keeps going this well.
ddtitle.jpg
ddtitle.jpg (16.8 KiB) Viewed 6975 times
User avatar
Kerby
Posts: 90
Joined: Wed Feb 06, 2013 6:02 pm

Re: WIP:Dig Dug

Post by Kerby »

I read everything! It was a very good game on NES, and I'm sure the port on Uzebox you will also very good!
it was painstakingly derived by frame by frame analysis of the NES version with some hints from the Atari 7800 version's assembly code.
- like a little bit more, if it is not a secret ?
Version for two players in this game does not necessarily ...
Screen version of the NES as the original would have been better ...
User avatar
uze6666
Site Admin
Posts: 4812
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: WIP:Dig Dug

Post by uze6666 »

Also read everything! :) That was a great game and I remember playing it in the arcades. Mode74 sound good to be, would give it it's own feel than the NES I think. You were thinking of mode13 using the 7 colors mode or 15 colors mode? For sure the 15 colors mode kills he performance. For the 7 colors mode, I've identified lots of optimizations in the blitter, so it could work out. But eh, mode74 is there and done!

Very pretty promising port, really looking forward this one! 8-)
User avatar
D3thAdd3r
Posts: 3293
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: WIP:Dig Dug

Post by D3thAdd3r »

uze6666 wrote:ou were thinking of mode13 using the 7 colors mode or 15 colors mode? For sure the 15 colors mode kills he performance.
The game works out to have more than 16 colors in the original, but I made some design choices where I made reasonable sacrifices and recolored things. Part of the color requirement is that the dirt changes color as you complete levels, so they must be separate colors set aside for that. I doesn't make a huge difference in the outcome luckily.

Jubatian had mentioned if Mode 13 is limited to 128 rom tiles, which it appears to be, then the ld-swap-ld method of blitting with 16 colors should be possible. Apparently that is faster as well, but that might just have to be a future thing when someone gets the drive to hit Mode 13 again. The 26 tiles wide on M74 is not the end of the world, sure 30 would be nicer, but as I understand it there are some tricks that work only on M74 which save precious cycles. I figure I am going to be in trouble on cycles no matter what I do so that does seem the logical choice right now to go M74. An extra color is very nice to have as well...but it seems there is no Gconvert support for M74.
Kerby wrote:- like a little bit more, if it is not a secret ?
There is source code(6502 assembly) available for a bunch of classic Atari games. Apparently someone dug some of this stuff out of a dumpster, old disks/etc, when Atari was cleaning house or going under or whatever. There is some hereand also some here. Pretty cool! It becomes difficult to follow the spaghetti code through the whole original game, so even having the source code I gained more knowledge by watching it run.

BTW Alec, it seems Mode 13 cannot change tile tables as of the last version?
User avatar
uze6666
Site Admin
Posts: 4812
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: WIP:Dig Dug

Post by uze6666 »

BTW Alec, it seems Mode 13 cannot change tile tables as of the last version?
I will have to check your questions on mode13 and come back to you.
User avatar
Jubatian
Posts: 1569
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: WIP:Dig Dug

Post by Jubatian »

Nice stuff! I read it just now, was a bit swamped in other things (and some video mode development) before.

Mode 74: It just fits. Mode 74 has 24 tiles of maximal width, but I see the game is 12 "big" tiles wide, so it just fits fine. Depending on what configuration you choose, the sprite blitter's performance can vary, Flight of a Dragon actually uses the most complex and thus slowest blitter to get all that on the screen, and it works (as I analyzed it hardly ever gets any near of running out of cycles), the screen is 196 pixels tall. In your demo it seems like you have a 176 pixels tall game field, 192 pixels total. For this game I don't think 60FPS is really necessary, you may consider going for 30FPS instead, doing alternating render & logic frames (FoaD does this, it also has quite complex physics to cope with). In FoaD the intensive part is actually not even the RAM tile count, rather that often it renders several sprite parts over each other (so does much more blitting than the RAM tile count alone would imply, often most sprites are totally unaligned, especially on slopes, demanding tons of fractional blits). So I think this should be very much doable. Mode 74 has no GConvert support, you have to generate tiles using Gimp sources with the generators provided with the mode. You can have 3 x 64 ROM tiles, either of these banks selectable (which may help for designing the title screen, and of course that's 192 tiles, not 128). You might check if it is possible to update GConvert to work for Mode 74 (the 8 color Mode 13's generator should work for Mode 74 with a few changes if such a generator was made).

Mode 13 + ld - swap - ld is possible if someone does it (see the Mode 13 topic), then you can use Mode 74's sprite engine as-is with it. But if you are ROM tile limited, then an alternative may be designing a Mode 13 which has more ROM tiles (it should also fit in the ld - ld concept, having 4 cycles extra per tile compared to ld - swap - ld), then maybe better keep ld - swap - ld for something named Mode 64.
User avatar
D3thAdd3r
Posts: 3293
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: WIP:Dig Dug

Post by D3thAdd3r »

I should say thanks for the encouragement/discussion guys, it helps motivation a lot as usual and I appreciate it.

M74 does seem the obvious choice but I want to make sure I am making the right trade offs(If mode 13 is viable at all...which I think it *maybe* is, making it harder to choose). Matching the arcade resolution has become much more appealing to me now that I see the difference the larger game field makes(you don't just get ran over immediately in later levels with many fast enemies and no room to maneuver). I really want the Uzebox port to be slightly "better" than the home versions from the 80s. Ideally I would have a play field of 14 "metatiles" wide, so 28 tiles. Vertically it would be 14.5 metatiles, which vertical scrolling allows for either M74 or M13 to match the arcade there. For M74 I would likely want to do horizontal scrolling to allow arcade width. Still trying to think how this will all look to scroll around like this(since the scoreboard will scroll too). Maybe I will look at M13 a bit, but it might be beyond my ability to modify right now.
Jubatian wrote:you may consider going for 30FPS instead, doing alternating render & logic frames
)
Unfortunately I cannot do 30hz on this one, because all movement for players and monsters is based on sub pixel "velocities". The enemies have different speeds, which get slightly faster and faster as the levels go on so it is not simply like moving 1 pixel every other frame...some 3 frames in a row move, then 1 don't, etc. I don't think I will be able to match the feel if I change logic frequency. So far it feels the same playing this and the NES version back to back.

I am dropping the max enemies back to 7 to match the arcade instead of NES' 8. After some research I think this has positive gameplay benefits(not just overcrowded with enemies and no room to maneuver in later levels) and ram tile requirements are less as well. 56 ram tiles should be fine now, so that makes a big difference on SCREEN_TILES_V. I got rocks working nearly perfect, I will perhaps post a youtube video soon.
User avatar
D3thAdd3r
Posts: 3293
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: WIP:Dig Dug

Post by D3thAdd3r »

Well about 3:40 in the morning and I best rest. Not sure how I went so nuts today, but the girl left me alone for a Saturday and I proceeded to develop this game for 14 hours straight....not saying I am proud of it, but it happened(and got a lot done) :shock:

Miscellaneous stuff is fixed and finished, and I went through and refactored a tons of code. It is much cleaner and easier to manage now, and also ends up at least as efficient as the premature optimizations I started with that turned into trouble. Investigated M13 and I think it works for this, will see tomorrow. The vertical scrolling idea I am going to run with, and I am ditching some of the NES stuff in favor of something that is new. I wont even talk about it yet since it is only appreciable in a playable demo.

I am going to run as short a screen as necessary, and as wide as possible. Essentially I have redesigned everything to look like this, where vertical scrolling will allow a very tall field:
ddverticalconcept.jpg
ddverticalconcept.jpg (35.11 KiB) Viewed 6844 times
There were a lot of changes to make it work, but now all the tedious stuff holding me back is done. In this scheme, flowers are much smaller than original..but I didn't really like the big gaudy flowers of the original anyway.
User avatar
uze6666
Site Admin
Posts: 4812
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: WIP:Dig Dug

Post by uze6666 »

Looks good!! 14 hours straight?? ...man I haven't done that in so many years! :P
User avatar
danboid
Posts: 2081
Joined: Sun Jun 14, 2020 12:14 am

Re: WIP:Dig Dug

Post by danboid »

How about posting some Dig Dug binaries eh DA?
Post Reply