Xbox Afterglow Controller

This controller is an excellent replacement to own when you need a good joystick controller when testing functions in either Commodore 64 Basic or Assembly language. These days you don’t need to own a Commodore 64 computer and joystick to write programs that utilize a joystick controller since the VICE C64 emulator permits the use of connecting an Xbox gamepad controller such as the PDP Afterglow Wired Controller for Xbox 360

This one boasts a similar design to the one I currently own. It provides SmartTrack technology that manages very precise reaction time when the controller is being moved. It had a license with the original Xbox 360. It contains vibration feedback rumble motors which will cause the controller to “shake” when you bump into a wall, an explosion goes off, etc. when playing an actual game. Finally it also has a built in headset communicator port.

The cool thing that initially attracted me to this controller was it’s sleek design and I noticed how you can see through it since it had a transparent covering. For someone who actually loves playing with electronics personally, this was a gem for me completely. I’m certain you will find this interesting too.

Another thing I found pretty beneficial about is that it has a nice rubber cord instead of one of those cords that tangle up quite a bit after frequent use. I’ve never gotten it into a knot, and this has made its value even more precious to me. Plus as a bonus, the cord is really long and allows more freedom of movement when you are playing an intense game and need to stand up and move around.

The material is identical to other Xbox controllers and has a plastic base surrounding it. To boot, you just can’t beat the lights that are seen underneath (known as LEDs). This is where they get the name “Afterglow” from. The truth is it has 4 separated light emitting diodes placed separately from each other that create a nice illumination when glaring at it. I think it’s also totally cool playing it in the dark and watching it light up and create shadows against my walls.

Now that you have learned a little about it, let’s see how we can use it to control a character on the screen. We will create a simple Commodore 64 Basic program with a simple sprite that can be moved around with the Xbox Afterglow controller. I will also show you exactly how this can be configured inside of the VICE C64 emulator. We will also send a command to flash the screen when a button controller is held down to make it more interesting.

If you need a good VICE tutorial, be sure to watch my VICE C64 Emulator video on YouTube.

The screenshot seen here is how the VICE C64 emulator appears when you first start the program. It launches you immediately into Basic where we can begin writing code to send commands to our Xbox controller.

Go into the VICE C64 Emulator Settings menu and choose Joystick Settings.  Once you open it up, you will see an area on the left that says Joystick in Port #1 and on the right it shows Joystick in port #2. If you select the down arrow and you have the Xbox Afterglow controller plugged in and configured then you can tell the emulator to manage control so it can be used in your programs.  Once you have it selected to show PC joystick #1 you are are set to go!

Finally we present the Commodore 64 Basic program that sets up our sprite movement. Seen here is a red spaceship that can be moved around with the Xbox Afterglow controller. The program itself does not check for any out of range boundaries, so if you move the controller too far to the left, right, up or down you will get an error.

It can be corrected by changing lines 210-240 as seen here. Note: JY (register 56320) sends a command to the Xbox Afterglow controller and checks for movement based on binary bits being masked.

210 IFJY=11THENX1=X1-1:IFX1<18THENX1=18
220 IFJY=7THENX1=X1+1:IFX1>255THENX1=255
230 IFJY=14THENY1=Y1-1:IFY1<52THENY1=52
240 IFJY=13THENY1=Y1+1:IFY1>236THENY1=236

The adjustments check for this:

Line 210 will wait until the sprite moves to the left and then reaches value 18. If the sprite tries to move further to the left, checking if X1 is less than 18, then the sprite will remain at value 18 at the X register (which controls the horizontal movement).

Line 220 will wait until the sprite moves to the right and then reaches value 255. If the sprite tries to move further to the right, checking if X1 is greater than 255, then the sprite will remain at value 255 at the X register (which controls the horizontal movement). More advanced code will check for the sprite moving beyond this point using register 53264 which manages the Most Significant Bit (controls low and high bit checking).

Line 230 will wait until the sprite moves up and then reaches value 52. If the sprite tries to move up more, checking if Y1 is less than 52, then the sprite will remain at value 52 at the Y register (which controls the vertical movement).

Line 240 will wait until the sprite moves to down and then reaches value 236. If the sprite tries to move down further, checking if Y1 is greater than 18, then the sprite will remain at value 236 at the Y register (which controls the vertical movement).

The new code screenshot is seen here in the VICE C64 emulator.