Anyone still coding the Commodore 64 (real or emulated)?

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
Istar
Baaaaaa!
Baaaaaa!
Posts: 4869
Joined: Mon Apr 22, 2002 4:42 pm 0
Location: London, UK.

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Istar »

I've never found a decent schematic or block diagram with enough detail to emulate Shifter - kudos to you for tackling it.

'Official' documentation on the 6502 instruction decode is scarce. I have a Mostek Test Sample block summary, acquired many moons ago in the way such things must be - a dark night, a windswept moor, trenchcoats and briefcases and poison-tipped umbrellas, that sort of thing. ;)

To be honest, it's not much use, and the docs you can find on the net these days tend to be better in terms of detail - what there is of it. I've ended-up pretty much reverse-engineering the logic based on a (very) detailed analysis of the instruction bitmaps, deriving likely array configurations using the published specs and the 'unassigned' patterns of the undocumented opcodes. There's a link to some early work in the 'Show us...' projects thread, but it's come a long way since then.

It's cycle accurate, handles the vagaries of all the addressing mode and branch instruction modifiers, and knows about the undocumented opcodes and undocumented 'peculiarities' like the page-boundary JMP bug. It's also thread-safe, so it's quite fun to instantiate a dozen side-by-side and have them start executing a block of code in parallel - and yes, that does imply a number of interesting possibilities that I'm playing with... ;)

Once I've got the VIC20 and VCS emulated accurately, it'll be ready for prime-time. In the meantime, it provides a rather nice 'live' reference base for the custom assembler I've written (which was where this all started, about two years ago) which gives me cycle timing per instruction and block as I type...
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Dio »

Nice work. I'll need to do something about the undocumented stuff at some point I'm sure, at the moment they all just trap, although nothing hits it yet. I'm reasonably confident in the cycle accuracy of mine though - if it runs a VCS it has to be pretty good :D.

As to the Shifter, the demo and atari forum guys have done an excellent job over the years deconstructing the internals. This series (it was continued a few issues later in five more parts) covers most of the key points. That work's still going on now - there's a lot of discussion about Glue/Shifter wake-up modes still going on (some of the clock phasing is fixed at boot time rather than by design or under software control).
Kronos

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Kronos »

Thought I would do a bit of an update on this (and once again many thanks to all the helpful suggestions)

1. I have finally found a copy of something I'm sure I can have a bash at to atleast turn some algorithms into code without my head splitting in two learning Assembler at the same time. So that will keep me from getting discouraged atleast.

2. Thought I would connected a laptop to a DVD recorder and record many a session of the game in question on MAME for reference (stuff like max number of players + bullets for example along with the feel of the game/speed etc) and with a bit of luck have a source for the samples in the game.

3. Started working on some suitable graphics in both Mono and colour modes to mock up what might look best, so far it's pretty much going to be Mono ie 2 colours per character block for a clean look as close to the arcade as possible.

4. Looked at a couple of software sprite techniques to try and get my head around that (too many moving objects for just 8 sprites and as suspected they can move anywhere on the screen at any time so re-using via sprite multiplexing looks incredibly difficult)

5. Messed about with some artwork for the actual original game covers to see if I could make a nice 16-colour splash screen for it like some of the Atari 8bit remakes have.

6. Made sure my trusty Commodore 128D and 1084S monitor were working, it's a lovely machine so thought I would use that to write it on. This lasted several hours in the summer house to *make sure* the C64 mode worked perfectly via some good old fashioned C64 gaming sessions :lol:

The plan is to

flesh out the game in a C64 codeable algorithm,
do some basic graphics in PSP and convert it to binary with some virtual graph paper I made,
write something in laser basic (so atleast I get *somewhere* and not too disheartened about lack of actual progress to show as this drags on no doubt)
compile it too see how much faster it runs at best using above said code.

Then finally go back and re-do it properly in Assembler (after learning it well enough!) with the samples and hopefully at full speed. My aim is to make it as good as the Atari 8bit version.

Lofty plan for me indeed as I haven't coded properly since doing my 1 level kludges in Blitz Basic on my A1200 in the mid 90s, but need to set my goals via do-able tasks so here's hoping it happens. Once I am atleast half finished on the first attempt I will reveal which game it is so you can all laugh at what a mountain I've turned this technical mole hill into :lol: I may do a version for the Amiga once I've done all the graphics in Blitz just so it also exists on the Amiga somewhere too but thats miles ahead.

Question, I would like to transfer some real C64 commercial program in this package I'm purchasing to D64 format, I'm guessing I just need the cable to connect the 1541 to a PC and transfer it right? The 1541 is slowwwwwwww, and would be nice to do some of it on VICE etc.

PS If anyone has any kind of link to how Gauntlet was coded on the c64 that would help, as that game also uses too many characters to use hardware sprites for very similar reasons to why I can't, so must be character graphic manipulation.
User avatar
Istar
Baaaaaa!
Baaaaaa!
Posts: 4869
Joined: Mon Apr 22, 2002 4:42 pm 0
Location: London, UK.

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Istar »

silent_unicorn wrote:PS If anyone has any kind of link to how Gauntlet was coded on the c64 that would help, as that game also uses too many characters to use hardware sprites for very similar reasons to why I can't, so must be character graphic manipulation.
I have no idea how Gauntlet was coded on the C64, but I do know that you don't HAVE to use hardware sprites - it's perfectly possible to write a game with your own blitter and collision-detection routines to do playfield updating. Using hardware sprites just takes some of the strain out of doing it.

Most of the machines I've ever coded on haven't had hardware sprite capabilities (VIC20, ST, Newbrain, Einstein, Spectrum, etc etc) and they seem to make do ok... :lol:
Kronos

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Kronos »

Dio wrote:
KlaxonCow wrote:You're not supposed to be able to play samples at all. Nor should you be able to have more than 8 sprites on-screen at once. Nor should it be capable of displaying more than so many colours in certain graphics modes. Commodore hardware is still unique in allowing the ability to actually display different graphics modes on the same screen simultaneously.
ST could do multimode screens (although it did only have two to choose from) - The Pawn is a fairly early commercial ST game that does this, for example. I think the Atari 400/800 series could as well, and it had display lists to do it automatically rather than under interrupt control.

Actually from the reading I've been doing on the C64 the ST's video chip is reasonably similar in some of the ways you can abuse it (border removal, that sort of thing).

Looks like the C64 is much easier to emulate though because the timing's less flexible (scan lines aren't all the same length on the ST if you start really flipping the bits around).

And even a Spectrum could play samples ;). Badly.

Haha is that the famous 'medeor alerd' sample of Meteor Alert you're referencing on the speccy? :)

The Pawn :wub: also had that amazing 512 colour loading screen, that was awesome to boot up and watch I remember it so well. I actually have a copy of Quantum Paint too, which using C64 style IFLI tricks claimed 4096 colours from the original ST (not forgetting Spectrum 512 which is pretty much the same routine to get about 48? colours per scan line and NewTek did the same thing on the Amiga's highest resolution to get more than 16 colours per scanline IIRC.

As for the C64 IMO they weren't all as identical as they should have been, I remember Z from Rhino marketing would crash on my friends C64 after 5 minutes but not on mine, which was an earlier version with orange function keys. And we used my tape deck so it wasn't a load error :? Don't forget though both machines (and the Vic20) were designed by Shiraz Shivji at Commodore with only approx 3 years apart. Had the ST's design been left to completion at Commodore I think apart from a SID instead of the YM soundchip it would be similar. And possibly the better shifter chip as Dio stated in another thread for hardware scrolling. Hell Gauntlet 1 is for me the most impressive early title for any machine in its Atari ST incarnation. Shame they never did it on the Amiga and Gauntlet 2 was crap looking.

One thing I will say about the C64 is that despite it only having 16 colours, the choice of those 16 colours is remarkably convenient. Have a good look at the colours available and there is almost a workable 5 shades for each 7 primary colours (cyan yellow magenta[possibly] blue green red + greyscale) Off the top of my head the different colour dreadnoughts of Uridium spring to mind. gray, gold, blue etc etc. Every machine has it's plus points and I distinctly remember a very good comparision of the Colecovision and the Atari 5200/8bit which I can't find anymore via googling.

Anyway my demo of the moment is Soiled Legacy by Resource. Nice all round demo which I really like. Nice TV captured youtube of it here which I couldn't get to work in ViCE. Even has moving FLI images with transition effects, not bad for a 1mhz 4/16 colour machine from 1982 :)
Kronos

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Kronos »

Istar wrote:
silent_unicorn wrote:PS If anyone has any kind of link to how Gauntlet was coded on the c64 that would help, as that game also uses too many characters to use hardware sprites for very similar reasons to why I can't, so must be character graphic manipulation.
I have no idea how Gauntlet was coded on the C64, but I do know that you don't HAVE to use hardware sprites - it's perfectly possible to write a game with your own blitter and collision-detection routines to do playfield updating. Using hardware sprites just takes some of the strain out of doing it.

Most of the machines I've ever coded on haven't had hardware sprite capabilities (VIC20, ST, Newbrain, Einstein, Spectrum, etc etc) and they seem to make do ok... :lol:
Yes but I am a 6502 assembley coding n00b remember, so it would have been faster written in Laser Basic using hardware sprites that's all ;)
User avatar
thalamus
Baaaaaaa!
Baaaaaaa!
Posts: 5325
Joined: Mon Jun 30, 2003 10:15 am 0
Yahoo Messenger: thelizard_uk@yahoo.com
Location: Canada
Contact:

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by thalamus »

Istar wrote:Using hardware sprites just takes some of the strain out of doing it.
Haha. Did anyone ever use the in-built hardware collision detection? :)
"We don't have a great war in our generation, or a great depression, but we do, we have a great war of the spirit. We have a great revolution against the culture. The great depression is ourlives. We have a spiritual depression." - Tyler Durden
User avatar
sack
Baaaaaaa!
Baaaaaaa!
Posts: 7077
Joined: Fri May 10, 2002 4:13 pm 0
XBL Gamertag: evilgopher
PSN: sixFiveOhTwo
Location: Rijswijk, The Netherlands
Contact:

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by sack »

thalamus wrote:
Istar wrote:Using hardware sprites just takes some of the strain out of doing it.
Haha. Did anyone ever use the in-built hardware collision detection? :)
only from basic as a kid... but to make up for it I didn't use the MSB register :)
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Dio »

silent_unicorn wrote:Haha is that the famous 'medeor alerd' sample of Meteor Alert you're referencing on the speccy? :)
I was thinking of 'Ghostbusters' myself, but, yeah.
One thing I will say about the C64 is that despite it only having 16 colours, the choice of those 16 colours is remarkably convenient. Have a good look at the colours available and there is almost a workable 5 shades for each 7 primary colours (cyan yellow magenta[possibly] blue green red + greyscale)
It's not got any highly saturated colours though, so everything always looks a bit brown or pale blue.

I got some hints from the VCS colour implementation I did why it's like that - the VCS palette uses a constant chroma amplitude (or zero for greyscale) and can only vary chroma phase and the luminance. For example this gives you a choice of a dark red or a pink, but you can't get the saturated bright red the Spectrum has.

I suspect the C64 uses a similar trick - both chips are by MOS, after all.
Kronos

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Kronos »

thalamus wrote:
Istar wrote:Using hardware sprites just takes some of the strain out of doing it.
Haha. Did anyone ever use the in-built hardware collision detection? :)
Luckily (if there were enough sprites) any collision of any kind ie sprite/sprite or sprite/bitmap other than colour zero ofcourse, would be instant death so does that make it any more useable in that instance? :)

I was thinking of maybe using a table of co-ords for every enemy object/shot and your shot objects and just check if it's in the same place as your player for the character graphics every frame if possible. Good way of doing it? (there will only be about 20 things max)

And for the other element of death before re-drawing the software sprite to the new position I was going to just check to make sure that memory address for the screen co-ord was equal to colour zero/blank.

Actually I was just playing the game and have found a possible sneaky way of using sprites after all. Whilst there are many enemies they're not all moving at once and if I limit the moving enemies to 4 that leaves me with your player and the possibility of two enemy and your own bullet. Might be able to do a routine to animate (but not move) the 'sleeping' enemies as they're dormant using character graphics and then when another enemy sprite becomes free (ie it's killed) superimpose it on the UDG version of a dormant enemy and then wipe out the UDG version underneath and start it moving. Good or bad idea you think people?

My other option is use character graphics for the shots. Using dx/dy type monitoring of the shots I could check ahead in the direction the shot is going and just kill it if it hits anything (ie if the position it is about to go to is not blank in the screen address). This would leave me 7 active enemies and the player sprite to mess about with giving 7 active enemies at any one time max. Good idea? Is this the normal way of doing it for shooty games?

I think the illusion would be ok with only 4 enemies 'active' at a time but need to check this a bit more on the Atari 8bit version though.
User avatar
gravy
Sheepie Whore
Sheepie Whore
Posts: 19572
Joined: Wed May 01, 2002 1:28 pm 0
Location: The Other Place

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by gravy »

thalamus wrote:
Istar wrote:Using hardware sprites just takes some of the strain out of doing it.
Haha. Did anyone ever use the in-built hardware collision detection? :)
Only shit games mostly. Pixel perfect collision sucks balls, it's very rare that approach makes a fun game.
User avatar
Istar
Baaaaaa!
Baaaaaa!
Posts: 4869
Joined: Mon Apr 22, 2002 4:42 pm 0
Location: London, UK.

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Istar »

silent_unicorn wrote:Yes but I am a 6502 assembley coding n00b remember, so it would have been faster written in Laser Basic using hardware sprites that's all ;)
You'd be surprised - after all, how many objects on the screen are 'collidable'? Hundreds? Or just a few? Even BASIC can handle a co-ordinate table scan of, say, a dozen sets of X/Y pairs looking for intersects in a reasonably short time. And if it's too slow, ask how many collisions you need to check per frame? If you can get away with splitting the table into two and check alternately, or splitting into more and keeping track of an indexer per frame so you know which table to scan, this makes it entirely do-able. Plus, you get better control of the intersect region rather than just having an event triggered whenever even a single pixel overlap occurs.
silent_unicorn wrote:I was thinking of maybe using a table of co-ords for every enemy object/shot and your shot objects and just check if it's in the same place as your player for the character graphics every frame if possible. Good way of doing it? (there will only be about 20 things max)
Ah, there you go - and there are ways of optimising that even beyond dividing the table. Like, for example, having the table(s) as a slightly more complex object list, where every object updates its own co-ordinates in the table when it moves (or, alternatively, you update the co-ordinates in the table and the objects obey it) and at the same time do a fast scan of a subset of the table (i.e. things marked as collidable with this object) and set a 'hit' flag in that row. At the end of the frame (or start of the next) your table scan then becomes nothing more than a tally of hit flags. Hell, why not dispense with the flag altogether and write an index entry into another table when you register a hit - then your table scan is only against the hit-table, which you purge after processing anything in it ready for the next frame...

You're still doing the same amount of work to effect the collision-detection, but you're reducing the number of things to check. And that's the trick - collision detection takes a finite amount of time, which you can't do much about - but you can try to reduce the number of times you execute the check...

EDIT: Don't forget to do what you can to short-circuit your table scans as well; if your table is sorted by absolute pixel position, for example, you can stop scanning for possible collisions as soon as you hit an object which is greater than (position + width , position + depth). If you haven't found anything within that margin, nothing else in the table can be near it, so stop looking.
Kronos

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Kronos »

Still working on this, it hasn't fallen by the wayside at all. I'm hoping to have an early demo of this running soon after a lot of delays just getting hold of a copy of either Laser Basic or White Lightning (for the Basic Lightning component). Still on the lookout for Laser Compiler though but that's not needed just yet.

Anyway after a long time away time to actually get something together. Have skimmed through the manual and there are some [not very detailed] commands about software sprites to use, the annoying thing is I read about some other commands and keep coming up with other games that need to be converted to the c64 too *gnnn* Also there is a lot more commands than I remember and there are several ways of both implementing the game logic/core code as well as the actual game graphics routines so may have to write two versions of some routines and check which is fastest.

So far I have got the most basic routine to get the title screen up and arcade perfect looking and in a couple of weeks hopefully the background graphics too. I think the game is possible using character graphics as software sprites in the same way the Atari home computer version was done. I have made an optimistic first stab at using upto 16 enemies, so thats potentially 34 objects to track. We shall see. I hope to get the sampled sound routine working soon, just need to read up a bit more to find a safe area of memory to store the samples so Laser Basic won't obliterate them. Also need to do some quick and dirty routines for 1 player and 1 enemy so I can check if I can still use my initial idea to check the contents of the video memory mapped into the C64 for collision detection within Laser Basic, if I can't then this will be a major blow as no collision detection for the software sprites is included in the command list.
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Dio »

tufty wrote:
KlaxonCow wrote:you've got a slow CPU
An early example of the megahertz myth. 6502@1Mhz ~= Z80@2Mhz, due to the way the instructions are implemented.
One of the things I've done recently is add a few more CPU stats to Emu. Very roughly, a 1.2MHz 6502 (in the VCS emulator) is executing about the same number of instructions per second as the 3.5MHz Z80 (in the Spectrum emulator) - something in the 370-420k region (with about 10% wait states on both in the apps I was testing).

It's still hard to judge the relative horsepower, given that the Z80 can do quite a bit more per instruction, but I'd say what I estimated originally is about right; the BBC's 2MHz 6502 was probably on a par or a little ahead of the Spectrum, but the C64's 1MHz 6502 was well behind.
User avatar
Muttley
Sheepie Whore
Sheepie Whore
Posts: 13169
Joined: Thu Apr 25, 2002 12:30 pm 0
XBL Gamertag: Mu77ley
Location: In a maze of twisty passages, all alike.
Contact:

Re: Anyone still coding the Commodore 64 (real or emulated)?

Post by Muttley »

Very late to the party here, but today I blogged how I had my dev environment set up for doing c64 stuff: http://www.muttleyville.org/?p=57
Muttley's Blog: Rarely updated, occasionally interesting… maybe
RetroRemakes Framework: Open Source BlitzMax Game Framework
MuttMod: My Open Source BlitzMax Modules
Post Reply