Wednesday, November 26, 2008

Cool Electronics things....

So first a couple of links:-


http://www.belogic.com/uzebox/index.htm
http://www.ladyada.net/make/fuzebox/


Now whats this got to do with anything? Well have a look at these videos




Very cool indeed, more so because its not a particually expensive chip. So I was wondering what more you could do with it, and I've been having a look at some videos, and the specs. Now I've always used PIC Microchips, but I've noticed an increasing number of projects using these ATmega things and after looking at the datasheets, I can see why. The assembler is actually pretty nice! It looks normal! PIC stuff is okay, but I'm not a fan where as the ATmega has 32 registers, hardware multiplys, and most instructions take a single cycle! Now that IS interesting! Now have a look at this video....





This guy does various demos with it, and he gets some pretty cool results for such a small little device. So, I've ordered myself a little kit to playwith, and I might try hooking it up to a VGA monitor (I'm still struggling with PAL colour output, this phase shift stuff is a tad confusing). The other thing this little chip can do that PIC's simply can't, is address external RAM without having to do all the work yourself! Thats awesome! It means you could have megs of addressable SRAM (in the same way a Plus/4 could) without any speed loss, where as a PIC would really struggle as you have to set address lines, read and write data lines et..

What I would really like to try is making a GPU for a plus4. If I use dual port RAM, I could get the plus4 to write into the ATmegas ram, then get it to use it as a frame buffer and render things. This means you could switch the plus4's screen off (saving lots of CPU time), and then output the signal from the cartridge's ATmega chip. You could then add sprites, sound and all the rest without too much effort. if you really wanted to, you could have multiple chips each doing a different job - one for 10 channel SID emulation (or something), another for pure sample playback, and perhaps one to deal with chatacter maps, and another could add sprites etc... kinda like an arcade machine does.

Course...that won't happen. but i'd love to try and hook one up to a Plus4 and see what it would be like. Having already done a RAM expansion without opening up the plus4, I don't see why something like this couldn't be done - it'd be neat!

Sunday, November 23, 2008

JAR files.

I've been having a little trouble getting resources inside JAR files working, I took some code from my mobile phone days and used it inside Minus4j without any luck. The idea being that I could package the ROM and WAVE files up in the JAR file, and so I wouldn't have to do a slow load over HTTP.

I've now managed to get this working by using the main minus4j class rather than a java object. No idea why this matters, but it does, and it's now working. This means I can now package up ROMs and samples without having the extra paramaters or load commands, which it turn will spead up loading.

I'm also planing to add a virtual keyboard that will let you click keys rather than search for them - Saying I don't get bored of all this first of course....

Friday, November 21, 2008

Minus4j Version 1.5 released.

I've just released the latest version of Minus4j, this is the one thats been up on plus4 world for a week or so. Its got some major improvements like Audio, joystick/key combos and auto starting via the filename.

  • Added a paramater for the initial frameskip value.
  • Removed software screen scale and now use built in JAVA one - should be MUCH faster.
  • Added ESCAPE key (Escape)
  • Added RUN STOP key - ` (backwards apostrophe, beside 1 key)
  • Added the * key (numpad)
  • Added undocumented opcode LAS,Y ($BB) command. Danger Diamonds now runs.
  • Minus4j now picks up sys0000 style RUN commands from the filename. So games like "mercenary_sys23552.prg" now work without a seprate RUN command.
  • Minus4j now picks up g12AB style RUN commands from the filename. So games like "mercenary_g5C00.prg" now work without a seprate RUN command.
  • TED Sound!!!
  • TED Samples!!
  • New "sound" paramater. sound=off or sound=on are valid. ON by default.
  • You can now press F7 while running to toggle sound (mute).
  • Added VOLUME control register.
  • If joystick is enabled, CursorKeys and Space key is disabled.
  • INSERT now does a soft reset.
  • Emulator now shuts down better.

    You can get the latest version from minus4.plus4.net.
  • Sunday, November 16, 2008

    Virtual Machine JOY!!

    I've just installed Microsoft's Virtual PC 2007 with Ubuntu running as a VirtualMachine, and its all going pretty well for a first install....so much so, that I'm typing this inside the Ubuntu VM! I've been testing the java version of Minus4 and it runs pretty well here, of course this is a pretty big machine (quad core, 4gig ram etc.) so its not a big surprise... still, at 50fps its pretty solid.

    Once you scale the screen it starts to get sluggish, but a single frameskip pushes it up into the mid 40s and another to an solid 50. This is fine for games like mercenary that didn't draw the screen that much - or even XeO3 as I only draw the screen every second frame.

    I still have to get sound working - and get the screen res fixed as its currently locked to 896x600 for some odd reason. Once I've done that I'm going to try and get mono installed ready for some real work! Then I want to get a Mac VM created (if possible) and try the same stuff there. This would give me a solid development platform and let me do ALL my work from a single machine/desktop! How fekin' cool is that!

    Let there be sound!

    After a marathon day yesterday I managed to get some audio into Minus4j, and it really does make a huge difference. For the moment its TED sound only, and I do still have a little bit to do yet before its really nice, for a start volume isn't used at all! I ported this code directly from Minus4w and have only just noticed that theres no volume control on it, doppy bugger that I am. Still, you now get 2 TED channels (tone and noise) and samples (using the TED). Samples are a bit crude to say the least, so I'll need to work on that a little - although I think I'm driving my wife mad listening to odd sounding beeps all day, oh well.

    Once I have TED music in a better state, I'll port over my SID music player, and although its far from great (its a little rough and uses NO filters), it's still a good 1st step. After that, D64 support will almost bring it in line with Minus4w! Almost.... I'll need to see if its possible to save data to the local machine which would allow you to save games etc. other wise adventure games would be a pain. The solution to this I guess would be to port Minus4 to C# and Mono, this would allow it to run on any machine, AND on silverlight at a later date. It might also be a good time to use my cycle exact CPU I wrote about 6 years ago! It was designed to be more in line with YAPE than my scanline based one.

    Still, thats a loooooooooooooooooooooong way off, and theres loads to do before that. Russell also pointed out that I could let Minus4j host my debug stub as well, meaning you could develop and debug Plus4 apps on Linux or Mac OS, which would be cool.

    Anyway, head over to www.PlusWorld.com to see (and hear) the latest one in action! I've also started validating demos on Plus4 world, and although some just dont work, many work fine and its a much easier way of browsing them. We should really do an online demo page so you can have simple access to them.

    Saturday, November 15, 2008

    Even more java love.

    I've updated Plus4 World with the latest version of Minus4j. I've added a couple of handy features that allow even more games to run. The change list is below, and although I've not offically released this you can go and sample its goodness at plus4world.

  • Added a paramater for the initial frameskip value.
  • Removed software screen scale and now use built in JAVA one - should be MUCH faster.
  • Added ESCAPE key (Escape)
  • Added RUN STOP key - ` (backwards apostrophe, beside 1 key)
  • Added the * key (numpad)
  • Added undocumented opcode LAS,Y ($BB) command. Danger Diamonds now runs.
  • Minus4j now picks up sys4172 style RUN commands from the filename. So games like mercenary_sys23552.prg now work without a seprate RUN command.
  • Minus4j now picks up g12AB style RUN commands from the filename. So games like mercenary_g5C00.prg now work without a seprate RUN command.

    I'm also looking to add sound just now. This is a long standing issue that I'd love to fix so I've been looking at a couple of other emulators and how they handle sound. I not have my Java applet buzzing with noise so thats a good start! I should now only have to port over my TED sound stuff (and later SID sounds) in order to get it playing. Although theres obviously a long way to go before that, but at least theres a buzz about the place now.
  • Thursday, November 13, 2008

    More improvements to Minus4j

    So I was adding the escape and run-stop keys to the emulator last night, and was about to change the fire key from space to control (or something) when I hit a road block. Java doesn't GIVE you acess to the control key - or shift and ALT for that matter. These keys come through as modifiers, meaning you only get them when another key is pressed. Fek.

    I'll need to look at other emulators and see what they do, but if this is the case Im not sure where fire will go - unless I disable the KEYBOARD "space" while joystick is active. Thats a bit fudgy, but it would work.

    Oh well, I'll just have to carry on until I figure out something better.

    And another thing.... In the future I hope to ditch Java altogether and move to Silverlight which is all C# (much nicer!). Someones already done a simple spectrum emulator HERE and while its not ballistic (because it still quite new), it will be better in the future, and MUCH nicer to code for. I suspect any C++ app can be ported over to it reasonably easily - since its C# and not java. Very cool.

    Tuesday, November 11, 2008

    Polls are now closed....

    So...I thought it was time for another poll. Heres the results of the last ones.

    What do you hope to do with XeO3?
  • Just play it! 52 (60%)
  • Just to look through the source for ideas 14 (16%)
  • Make my own levels. 7 (8%)
  • Reskin the whole game to make my own shoot-em-up. 6 (6%)
  • Use the full source code to make a complely different game. 6 (6%)
  • I'm not interested at all 1 (1%)


    Which platform are you most interested in?
  • Commodore 64 56 (41%)
  • Commodore Plus/4 27 (20%)
  • All of them!! 15 (11%)
  • Amstrad CPC 14 (10%)
  • Commodore 64 Super CPU 10 (7%)
  • I'd like it on a different platform... 7 (5%)
  • Sinclair Spectrum 5 (3%)

    So a couple of surprises.... One that theres actually 10 SCPU users! (unless he cheated and voted 10 times....), second that the CPC version out stripped the Speccy. Course, that could just mean we dont get a lot of speccy folk dropping by.

    But with the main poll having a few folk actually wanting to use the source/scripting, I thought I'd ask another one. have any of you ACTUALLY looked at the demo scripting? Or better yet, even done something with it?!?!? Theres a new Poll over on the right, so let me know.
  • Sunday, November 09, 2008

    More Java - man I hate java...

    So with the release yesterday Minus4j is actually in pretty reasonable shape. Sure it needs the source cleaned a little - theres loads of commented out crap in there, but on the whole not bad. So as I was adding another paramater to it (allowing you to specify the initial frame skip - since Xeo3 runs at 25Hz, you never NEED 50fps drawing), I suddenly realised that these days, Java probably provides image scaling as part of the API!

    And sure enough.... there it is. So, I've now removed the software scale I was using and now use the API. This is of couse good for 2 reasons. One... being part of the API means it might be assembler optimised, and not just some tacky code I did, and second it reduces the code I've to maintain. Its all good.

    Before I set it all aside again, I'm going to look into sound. I do this every 3 years or so to see how much effort it would be to add sound to Minus4j. When I started, you just couldn't, but there are now a few apps which do what I need to, so chances are its not too hard. All I really need is a buffer or two that plays music at a specific rate through a software buffer. I can then fill this up as I emulate things. This would let me plug in TED and SID music - not to mention samples that Minus4w can play. That would be cool - then all I'd need is some basic D64 support!

    Oh... and while I won't release all these little bits, I will update both my blog and Plus4world to use all the latest stuff, then release it when theres enough to package it all up.

    Saturday, November 08, 2008

    Speed UP! Slooooow down....

    So, it turns out the Java compiler is fine (I think). My timing code (that makes the game run at a specific FPS) appears to be crippling things. But I have no idea how. If I take out my timing code and run the game unscaled it ticks along at 350fps - or 7 times the normal frame rate. It looks like thats correct too as everything is moving about 7x the speed, so I think the FPS counter is working.

    So... whats wrong with my timing loop thats crippling it so much? I've tried to set and FPS of 200, but as soon as I do that, it tops out at 65fps. If I remove a couple of lines (the bit that makes it work), it jumps up to 350 again. So somethings rotten right in the state of Denmark... So, heres the timing loop, perhaps someone out there will spot it and save me staring at boring code for hours on end.....


    long tLastGameFrame = System.currentTimeMillis();
    long tNextGameFrame = tLastGameFrame + FPSRate;

    Last = tLastGameFrame;
    while (true)
    {
    long tNow = System.currentTimeMillis();

    // Quick check to see it timer has gone backwards!!
    if( tNow < tLastGameFrame ){
    tLastGameFrame= tNow;
    }

    // Check to see if system is stuttering due background OS stuff.
    // if jumped ahead over 5 seconds, then just reset...
    if( (tNow-tNextGameFrame) > 5000 ){
    tNextGameFrame = tNow;
    }

    // Timer has gone backwards
    if( tNow < tLastGameFrame ){
    tLastGameFrame= tNow;
    }


    dTime = (int)(tNow - Last);
    if (dTime >= 1000){
    dTime -= 1000; // dont get 0 (1000/1001)
    actualfps = CurrentFPSCount;
    CurrentFPSCount=0;
    Last = tNow;
    }

    // Now the main timing loop
    if( tNextGameFrame >= tNow )
    {
    // do nothing...or yield/sleep
    } else
    {
    while( tNow>tNextGameFrame){
    tLastGameFrame = tNextGameFrame;
    tNextGameFrame += FPSRate;
    }
    CurrentFPSCount++;
    }


    And there you go... pretty simple. Oh, and the reason for the backwards check is because in the modern world of clock syncing (to time.com or something), your clock might briefly go backwards. If this happens timer loops break - had this happen twice! Once on mobile phones, and once on a PC. Took me AGES to figure out the Mobile phone one, but fortunately I remembered about it for the PC.