Saturday 4 April 2015

68k Part 1 - Easy now, raster lines and mouse buttons

Starting really simple now, lets change the colour of the raster lines and check the mouse buttons...

Changing the default colours on the Amiga

Yes there will be a heavy influence from the ScoopexUs 'Amiga Hardware Programming' tutorials on YouTube for the next few blog posts for sure. How can there not be? they are just so good!

I'm only learning, just a 68k noob!

I'm just trying to mess around with my own sections of code, for my own sanity, checking that I do sort of understand and hopefully will stick in my head for a while!  I will try to comment my code the best I can so that it explains itself.  Please PLEASE suggest better ways to do stuff, my samples sure wont be perfect.

My first snippet

Create a new file in Asm-One and copy paste the following code (or download source here).

This simple sample changes the default background and foreground colours, if the right mouse button is pressed down, it will change the colours whilst it's being pressed.  If the left mouse button is pressed the program is ended.

loop:
 
 btst #10, $dff016 ; test RIGHT mouse click
 bne default

; colours when right click is pressed
 
 move.w #$0f0, $dff180 ; moving colour in to background colour
 move.w #$0ff, $dff182 ; moving colour in to foreground colour

 bra  checkExit
 
default:

; default colours

 move.w #$f00, $dff180 ; moving colour in to background colour
 move.w #$ff0, $dff182 ; moving colour in to foreground colour 
 
checkExit:

 btst #6, $bfe001  ; test LEFT mouse click
 bne loop

 rts 

So I'm updating the colours every frame, I probably only need to do it at the start of the first raster line for each frame, but just as a sample I think it's ok.

Comment here or get involved on twitter: @rich_lloyd

Back with Amiga 68k Assembler, with ASM-ONE! C'MON!

OK so I started learning 68k assembler a while back now (2013!!) and it's tough, really tough.  I think it's more a case of just needing the time and focus to concentrate so that it absorbs in my brain.  Life and work gets in the way!!

I've been coding higher level languages for many many years now so it's not like I'm starting from scratch.  The hardest part for me is understanding the hardware, and how all the different code integrates to build the bigger picture.

Long story short - I've had a break away from the assembler world, and now I'm back and determined to get SOMEWHERE in 68k for the Amiga!  C'MON!

Comment here or get involved on twitter: @rich_lloyd

New goals!

Here's a list of things I would LOVE to achieve, once I've got a small library of techniques, hopefully I can start working towards the bigger goal of creating an Intro / Demo / Game.

  • Understanding  68k basics.  Moving stuff around in memory and program flow
  • Get a grip of the Copper, custom backgrounds
  • Draw a sprite!
  • Move a sprite!!
  • Mouse Input
  • Keyboard Input
  • Joystick Input
  • Play a music track / audio
  • Display Text
  • Create a simple Intro / Demo / Game
The ultimate goal would be to have made something awesome that fits on a floppy disc and runs on a regular Amiga machine.  I'll be happy with it running on the Amiga 1200, but if I can get it working on the Amiga 500 and upwards that really would be an achievement.

My new setup - AsmOne, lets get coding!

To achieve my goals, coding directly on my Amiga 1200 through my whole learning journey will be well... a very slow experience.  Lets get real, I'll be coding on my Windows laptops, then transferring the files to my Amiga now and then to check it works on real hardware.

My Windows setup with WinUAE, AsmOne and Notepad++
My Windows setup with WinUAE, AsmOne and Notepad++

Depending on the time of day, I'll be switching between 2 laptops (Windows 7 and Windows 8), but both will have identical set-ups.

Naturally I use WinUAE which is an amazing Amiga Emulator, you can download it here:

WinUAE Downloadhttp://www.winuae.net/frames/download.html

I've created a folder on my machine and set up as a hard drive (DH0:) when I launch WinUAE.  This means I can view files in BOTH the emulated Amiga and in Windows.  Makes it so easy to copy files about, especially when looking through examples online, I can just drop in to that folder and my emulated Amiga can see them straight away.  Happy days!

The assembler I will now be using to learn 68k will be AsmOne, mainly because there are plenty of examples out there that use it, and also off the back of Photon's truly amazing tutorials on YouTube which I have linked before, but will link again further down.

AsmOne Downloadhttp://www.theflamearrows.info/documents/ftp.html

Now I 'could' use the AsmOne text editor through the Amiga emulator, but in all honesty, it's slow.  Here's a better idea, as my files can be seen in Windows, I can use a modern text editor!!  Save the changes, and the Amiga will get updated.

For now I use Notepad++ , you can even import the 68k Assembly language definition for syntax highlighting etc...

Notepad++ Download here:
http://notepad-plus-plus.org/

Get the language definition here:
http://notepad-plus.sourceforge.net/commun/userDefinedLang/68K_Assembly.xml

So the last bit of setup I have, is that the folder I have on my Windows drive is actually part of my OneDrive (it could easily be a DropBox or GoogleDrive, etc... ).  As I work on multiple machines, my files instantly get synchronised so it makes it so much easier for me to pick up where I left when I get a spare moment.

68k references

Sure thing Google is your friend here, as well as the usual Amiga websites.  I have found it harder than I thought to hunt down things when I've had issues, so I'm just sharing some links here that might help out:
Make sure you subscribe to Photon's YouTube channel, includes excellent tutorials for Amiga Hardware Programming as well as other great Amgia stuff like demos.

ScoopexUs YouTube channel here - https://www.youtube.com/user/ScoopexUs

If you find a goldmine of reference then please let me know!

Here's a couple of books I find REALLY helpful when trying to get my head in the zone!


Comment here or get involved on twitter: @rich_lloyd

Wednesday 28 May 2014

Memories of considering the Commodore Amiga 500...

Back in 1991 our well used Spectrum +2 was fully loved, however it didn't know it would soon be replaced... by the Amiga 500!

International Amiga Day is approaching us so just wanted to share some of my memories of the exciting time of upgrading our family computer.  Comment here or get involved on twitter: @rich_lloyd


We had always been a ZX Spectrum household.  First it was the rubber keys, then the +2.  Long loading times and 16 colours was the norm. A lot of my friends had speccys, so sharing games was frequent, the world of the ZX Spectrum was more than enough. Even the BBC Micro was exciting, mainly exposed to at school this tank like machine was great!

After joining secondary school there was a shake up in my world of computers. The Acorn Archimedes!  This was a machine from the future...

  • It had colours, bright clear screen which displayed crisp clean graphics. 
  • A MOUSE, wow this was science fiction right here. 
  • Disks, the quickest thing I'd ever witnessed
...this era of computing was about to change.  If you'd asked me right there if I wanted an Archimedes I would have said YES... but where are the games?  This amazing machine had the stigma of being an educational beast, not really your full all round home entertainment machine.

The Amiga 500 has entered the building

It was now becoming clear that the well loved ZX Spectrum was starting to fall behind and a new machine was about to replace it.  I remember very clearly going in to Dixons, Salisbury with my Dad to inspect the latest home computers and there it was the Amiga 500.  We asked for a demo of what the machine could do, and I will never forget what we experienced.  

Shadow of the Beast 2




First up was Shadow of the Beast 2.  After seeing the most amazing animation intro to any game of my life, the title screen appeared with the most beautiful music and stunning visuals.  We were instantly sold.  To this day the music is still stuck in my head.

Amiga Workbench




We were then shown the power of a multitasking computer when booting up the Amiga Workbench.  A clock in one window, some classical music being played in another.  There was also the power of desktop publishing (DTP), something we massively take for granted.  Produce documents which could be printed in your own home.  I could see this was ticking all of my Dad's boxes.

Deluxe Paint




Not to forget Deluxe Paint, Photoshop of it's day, this powerful art program was ground breaking.

Touch Me


The novelty of using a mouse was extremely exciting, a completely new way to interact with a computer.  The concept of Drawers (Folders) and Windows of icons was just pure wizardry.  Using the mouse for games was also a crazy thing, it wasn't a joystick!

I remember touching the keys was a joy, how they felt on the finger tips, solid.  This was a REAL keyboard it had Function keys and Amiga keys, WOW.

So it ticked all the boxes, games + art programs for me, desktop publishing + spreadsheets for my Dad. Everyone's a winner!

But before we handed over all our money we visited a friend with an Amiga just to double check it was all it was cracked up to be.  The main demo I remember is...

Puggs In Space




Again, seeing a full on animation on a home computer was mind blowing.  Watching a 'cartoon' on a computer and not a TV.

The Amiga 500 really was something special.  The quality of sound and visuals really were something new and exciting to experience.  The general feeling of power was felt every time you inserted a new disk for the first time.  When playing a game you never new what it was going to be like, but you knew it would be engaging.  You'd always be reassuringly hugged by the Amiga, no matter what.

The Amiga.  Friends forever.

Comment here or get involved on twitter: @rich_lloyd

Mario Twins Shiggity Shiggity Shwa...

A little bit off topic, but recently remembered this Flash animation from quite a number of years ago now.

Didn't matter where you were or who you are, back in the day Nintendo ruled and there was no avoiding Super Mario Bros.  There have been many parodies and jokes over the years, and this one has stuck with me.

Ahh the Mario Twins.  This tickles me



Comment here or get involved on twitter: @rich_lloyd


Friday 7 March 2014

What I really wanted in October 1991... Amiga Computing issue 41 reveals all...

That's right, I recently sat down and browsed through an old Amiga Computing magazine I had... 

Issue 41 to be exact, why issue 41 I hear you not ask?  Well I've kept all the Amiga Format, Amiga Power and Amiga Computing magazines we ever had.  Recently in conversation the game Mega Lo Mania for the Amiga came up.  Turns out issue 41 of Amiga Computing had a review of that very game, and a great review too 93%.
Amiga Computing - Issue 41 - October 1991

As I was browsing... 

I came across one of those ads that advertised every game under the sun, there's plenty of them, this one was for 'Special Reserve'. Before I flicked the page over I realised, as a 12 year old kid, scribbled next to the things I wanted.  So I thought I'd share with you these things...

My wish list October 1991

The Amiga games/software I wanted in alphabetical order:
  • AMOS (Games Creator) - £32.99
    Yes as a 12 year old I was desperate to be a games programmer, I was so naive, but Google didn't exist so didn't know what was out there, this seemed to be the obvious choice.  I owe a lot to AMOS, it spring boarded my programming career! 
  • ELF - £16.49
    I remember now, for some reason the advertising for this game really appealed to me. To this day I've never played it, I must fire it up on my Amiga 1200.  I've got a feeling it had bad reviews.
  • HOLLYWOOD COLLECTION (Robocop, Ghostbusters 2, Indy Jones, Batman Movie) - 19.99
    Of course I wanted this, how awesome are these bunch of games! Never had this collection. Remember playing Robocop and being slightly disappointed. I'm assuming that was Indiana Jones and the last crusade, I played it on other platforms and loved it.  Never played Ghostbusters 2 or Batman Movie.
  • RAINBOW COLLECTION (Bubble Bobble, Rainbow Islands, New Zealand Story) - £13.99
    Bubble Bobble and Rainbow Islands were a MASSIVE favourite on our ZX Spectrum. Remember seeing the vibrant colours on the Amiga version and really wanted to be in those worlds. I did play New Zealand Story in the end, but I don't think it had the same energy as the other 2 games.
OK so there were a couple of accessories I wanted too...

Many joystick options available back in the day, but the Quickshot Maverick was the one I wanted

  • Quickshot 138F Maverick 1 - £12.99
  • Roctec External Drive - £54.99
So I was after an awesome joystick and external floppy drive, never did get a joystick better than a standard Competition Pro, but did get the 2nd floppy drive about a year later.

And then there was the Nintendo Gameboy...

OK so I LOVED my Amiga, it was great then, and it still is today. At the time I never had a Nintendo product, they were top of their game and the Gameboy was so amazing.  This is what I wanted.  After months of my Mum pretending to not understand what a gamethingy was she secretly got me one for Xmas that year.


The Gameboy games I desperately wanted was Formula 1 Race (with four player adaptor) £29.49 and Super Mario Land £19.49.  What I find funny about this selection is that I didn't know ANYONE else with a Gameboy at the time, so no idea why I chose the four way adaptor.  Super Mario Land became a massive favourite of mine, but I never did get or play Formula 1 Race.

Yup they were the top things I wanted.  Nothing too exciting I know, but it's just funny looking back on things that a 12 year old me wanted.  When I look at all the other things on offer at the time, makes me chuckle.

Right I must get back to coding in Amiga Assembler...

Comment here or get involved on twitter: @rich_lloyd


Monday 20 January 2014

Creating an Amiga boot sequence for WHDLoad... MY way!

Slow/cumbersome typing to maximise memory via WHDLoad? Sod that! Time for my OWN quick menu...

All of the following is probably basic stuff for regular Amiga fans, but as it was all new to me I thought maybe I'll share my experience in case it helps others.

Recently realised after regularly typing lots to launch games via WHDLoad and Shell prompt, why I don't I write my own boot sequence?! With my OWN short cut buttons!  Is this even possible?

YES and I've written how I achieved it!

I'll point out now that even though I grew up with the Amiga, and yes tinkered around with coding/Workbench/Shell etc... it has now dawned on me, actually I just touched the surface of how the whole Amiga worked.

Lets get a Hard Drive... oh hello WHDLoad?

Always having had an Amiga 500, when I saw a cheap Amiga 1200 on ebay I couldn't resist getting it. OK it had a bust floppy drive, but that was easily sorted by buying one from Amiga Kit (http://www.amigakit.eu).

No memory extension with just 2Mb RAM and no hard drive.  After a bit of hunting around I purchased a Compact Flash card + connector from ebay to finally hook up my Amiga 1200 with a hard drive.

Took Amiga apart, fitted the Compact Flash connector, turned it on, BAM job done.  It was at this point I was introduced to WHDLoad.  Always having an Amiga 500, floppy disks were THE only way, (sure I bet you can by a CF connector today).  I'm still not sure what a hard drive would have done back in the day, just one big floppy disk? to save games? backups?   But now it turns out games and programs can be stored on the harddrive and launched via WHDLoad.

As my Amiga 1200 has minimal RAM, I can't launch WHDLoad games in Workbench itself, clearly not enough memory, so there is an option when I reboot my machine holding down the left mouse button launches a Shell window prompt.  From here I have to locate the directory on the hard drive of the game I wish to launch then type out a command to launch it.  As Workbench hasn't loaded yet, the memory is ready and waiting to load+launch the game.

Great!
My Amiga 1200 in action! (Chaos Engine)

OK... my poor fingers!

Yes I do miss the Amiga keyboard, yes keyboards have come a long way since.  When I want to simply launch a game, there's actually a lot of typing.  Sometimes I have to double check the folder structure spelling, then locate the directory with the game in it. Then launch it.  Yes, this IS straight forwards stuff, but feels like there's so much typing for such a simple task, especially for games I play over and over again.

A script has got to be quicker than this each time!!

Let me introduce you to S:Startup-Sequence ...

When I reboot my machine and hold down the left mouse button, it interrupts the boot sequence and loads a bare minimum option menu so that memory is available to launch stuff.  Being pretty naive, I thought this was something special with having WHDLoad installed.  It's not.

When I realised there MUST be a script somewhere that controls the boot sequence I started to ask questions on Twitter.  As usual I was kindly pointed in to the right direction, and this is where I met S:Startup-sequence for the first time.

If you open the Shell in WorkBench you can type:

ed S:Startip-sequence

This opens the file in a basic text editor, here you can see each step in the boot up.  After having a quick look around, I found this:

C:Bblank

C:GetMouseInput LOCAL

IF $MouseInput EQ 1
  Unset MouseInput
  C:SetPatch QUIET
  C:Assign >NILL: ENV: RAM:
  C:Assign >NIL: T: RAM:
  C:Execute S:Maxmem-Sequence
  EndCLI >NIL:
EndIF


From this small section of the whole script I could see that there's a check for the left mouse button, if it's pressed then it clears the memory, then executes another script called S:Maxmem-sequence.

Firing up Maxmem-sequence in the text editor, I could see the quick menu that I see when I reboot.  Excellent, I can now see the commands to launch a window with quick options.

LAB Start

C:Requestchoice >ENV:Choice "Maxmem-Sequence""Choose:""RADboot""KGLoad""Reboot""Prompt"

IF $Choice EQ "1"
  Skip RADboot
ENDIF

IF $Choice EQ "2"
  Skip KGLoad
ENDIF

IF $Choice EQ "3"
  Skip Reboot
ENDIF

IF $Choice EQ "0"
  Skip Prompt
ENDIF


Above you can see the script pops up a window with 4 options, there are then some basic IF statements to work out what the user selected. Interestingly the last button has the ID of 0.

Lets make our own script

I had to do some googling regarding Shell commands and running scripts on the Amiga.

This link is a great reference for AmigaDos:
http://winuaehelp.back2roots.org/background/amigados.htm

Scripts can be created by creating an empty text file using the regular text editor, then on each line use the AmigaDos commands just the same as if you were typing in a Shell window.

FACT: After 20+ years of using the command, I've only just realised the the Shell command CD means Change Directory.

Once you have created your script file and saved it, you have to change the protection settings of the file to be able to run it as a script.

So if you have created a new script file called "myscript" in the S: director, then open the Shell window and type:
protect S:myscript RWES
(For info: r=read, w=write, e=execute, d=delete, s=script, p=pure)

From a shell prompt you can now type: myscript and it will run. Great!

I created my own script called RichMenu which prompts the user with a window with options of quick shortcuts to games.  Using what I had just learnt this was easy, then for each option in my script all I have to do is change directory to the games' folder then call WHDLoad, as a quick example this is my script:

LAB Start

C:Requestchoice >ENV:Choice "RichMenu""Choose:""Zool""Chaos Engine"

IF $Choice EQ "1"
  Skip Zool
ENDIF

IF $Choice EQ "0"
  Skip Chaos
ENDIF
LAB Zool
  CD Games1:A500_A600_ETOZGames/Z/Zool
  WHDLoad Zool.slave
  EndCLI >NIL:

LAB Chaos
  CD Games:A500_A600/c/ChaosEngine
  WHDLoad ChaosEngine.slave
  EndCLI >NIL:
Editing the RichMenu script


Great this fires up a window with the options Zool and Chaos Engine, user selects and instantly launches the selected game.   The script works!

IT WORKS!
Now I just need to go back to the original Maxmem-sequence script and add an extra option.  When selected this option just runs RichMenu.  BINGO!

Here's a snippet of the new change:

LAB Start

C:Requestchoice >ENV:Choice "Maxmem-Sequence""Choose:""RADboot""KGLoad""Reboot""Prompt""Rich Menu"

IF $Choice EQ "1"
  Skip RADboot
ENDIF

IF $Choice EQ "2"
  Skip KGLoad
ENDIF

IF $Choice EQ "3"
  Skip Reboot
ENDIF

IF $Choice EQ "4"
  Skip Prompt
ENDIF

IF $Choice EQ "0"
  Skip RichMenu
ENDIF

...

LAB RichMenu
  C:Execute >NIL: S:RichMenu
  EndCLI >NIL:

To summarise

  • S:Startup-sequence checks to see if left mouse button is down.
  • If it's down then clears memory and calls, S:Maxmem-sequence
  • S:Maxmem-sequence has been updated with an extra option called "Rich Menu"
  • When "Rich Menu" is selected it calls the script called RichMenu
  • RichMenu contains shortcut options to popular games I play, when a game is selected, it changes directory to the selected game, then game is launched with WHDLoad
  • Lots of fun had

And that's it!  I hope this makes sense, and someone one day might find it useful!

Comment here or get involved on twitter: @rich_lloyd



Monday 6 January 2014

Porting Nimble Jim over to the OUYA, easy enough? Of course it is!

So last November I got involved with the #SpeccyJam event and entered my game Nimble Jim for Windows, now it's time for the OUYA...

Comment here or get involved on twitter: @rich_lloyd

As you'll know we only had a week to produce a game in the style of a ZX Spectrum game which could run on any platform. Because it's my favourite language I wrote my game in C# and the easiest platform to get up to speed quickly is Windows. Even though it was rushed, I actually designed my code structure to be as generic as possible with the mindset of porting to other platforms. This meant I could actually choose different game engines to display and my main game code wouldn't need to change.

Because of speed and the opportunity to port to multiple platforms I chose XNA/Monogame to render my game. Actually the game I finally submitted was just XNA for Windows. As time was tight I just didn't get a chance to test or submit the game on Android/Linux/OUYA, so stuck with Windows.

That was a few weeks ago now and it's been bugging me that I didn't get a chance to produce for different platforms. So I managed to get a small bit of time over the winter break to have a bit of a play with MonoGame and the different platform options.

Port the game to mobile devices?

From past experience I know it actually takes a bit of time to get the controls just right for mobile devices playing games. People like Orange Pixel have really nailed it with their mobile games, (http://www.orangepixel.net/). Yes I managed to create an Android project and it ran my code on my phone (Samsung Galaxy S4), however at the moment in my code I've only got checks for key presses for the Windows version.

The OUYA

I was one of the original backers for the OUYA KickStarter project, hoping I'd have the console months/weeks ahead of launch to get familiar and start coding for it. OK there were delays and only received it a couple of days before launch day which has left a bitter taste in my mouth. STILL, it's a console, and a console I can easily port code to!!

So I have mixed feelings about the OUYA, but essentially would love to produce a game for the OUYA console. In MonoGame they have a project template for the OUYA, oh wait, I wrote my code using MonoGame :) Just create an OUYA project just like the Android project I thought and away I go... no... there's a few hoops to jump through first!

Hoops?! What hoops?

I'm just going to give you a brief run down of the steps I took to get working on the OUYA, but please visit here: https://devs.ouya.tv/developers/docs/mono-game for more details and will probably be kept up to date with changes.

First of all you need to sign up to be an OUYA Developer on the website: https://devs.ouya.tv/ this registers you and lets you download the latest OUYA Development Kit ODK.

Make sure you download the latest MonoGame build. There are more up to date branches of the code, but I used the latest stable release (MonoGame 3.0.1 for Visual Studio 2010). I can't remember if it's included with MonoGame or part of the ODK, there is a more up to date OUYA library to use with MonoGame, you just open the solution, build, then copy the output to a safe location and reference your project to the new library.

Connect your OUYA to your PC via USB cable, I've seen online a few people have had problems with windows not installing the driver straight away. I'm using Windows 7 and it updated drivers as soon as I plugged it and didn't have any problems.

I did have to update Google USB drivers .inf file with some OUYA information. I also had to add a line of text to the ADB USB .ini file so that the ADB manager could see the OUYA console. I wont go in to detail here, but all the details you need can be found right here: https://devs.ouya.tv/developers/docs/setup

Lastly make sure your OUYA is setup for developer mode in the Advanced Options, this will allow for it to communicate to your PC and deploy apps etc...

Those are the setup steps I took. Back to my Visual Studio project, I found I have to Rebuild my project and then Deploy which sends all the files over to the OUYA and installs them. Then I can hit the Play button and my game almost instantly starts playing on the OUYA!! At the moment this only seems to work in Debug mode, when I try Release mode, it deploys but won't run from Visual Studio. I have to go to my Play menu on the OUYA and I can see my game in the menu options where I can run it.

I hope this has all been useful for you?! I made a quick video giving the overview here:

Comment here or get involved on twitter: @rich_lloyd