Demonstration of speed of C64’s basic

Ah, this takes me way back in time… Just wanted to test the speed of C64’s basic with a simple program of controlling a worm. The video:

It was 1987 when I last coded with Commodore 64. ..and I admit it: I never learned 6502 / 6510 assembly well.. On Amiga I have done 680×0 assembly coding a lot, though…

Let’s see a picture of the source code:

1024 is the starting address of C64’s screen memory and 56320 is the address of joystick port 2.

If you want to download the d64 image with the program, it’s available below:

VERY fun way to play C64’s Pitstop II

It was, when I was about 10 – 11 years old, when I invented this kind of style to beat the computer player on Commodore 64’s Pitstop II. Watch the video:

The computer player is stuck behind me and AI computer player and eventually the computer player’s tires will blow up. After that, it’s easy to win the race. 🙂

This might be very fun with two human players. 🙂

For Relaxation: THE C64 Joystick with Manic Miner 64DX

Commodore 64 gets still new games or remakes of the old ones. In the end of the year 2019 was released Manic Miner 64DX. I tried my new retro joystick with it. The video below may give a picture can it be used for playing this kind of game:

Manic Miner 64DX for the Commodore 64

If you want to download this game, here’s the link: https://csdb.dk/release/?id=185586

Playing old retro games helps me to cut loose from my hard studies. This is perhaps because playing retro games today is not so serious as it was back in the day when the games were new.

Some pictures of the joystick:

Retro games also take me back in time. As a programmer I also think at the same time while playing the how the games might be programmed.

AmiKIT – Compiling a C program to Play a MED module

I recently downloaded from the official AmiKIT site the free version of AmiKIT. It’s great! I love it! I love the Amiga!

While testing the AmiKIT in an environment, that reminds me of the environment I had with the good old Amiga 4000, I got a spark to learn Amiga things again.

It would be nice finish my old classic 2D Ultima style RPG game. But where to find the needed documentation?

Below is a little video of my AmiKIT early adventure:

In the video an old C program to play MED music modules is compiled and tested. The C compiler that is used is VBCC.

Below is that program in full:

/* This program loads a module, and plays it. Uses medplayer.library,
   octaplayer.library and octamixplayer.library, if required. Could be
   used as a small simple replacement of OctaMEDPlayer. */

#include <stdio.h>

#include <exec/types.h>
#include <libraries/dos.h>
#include <proto/exec.h>
#include <proto/dos.h>

/* These two must be included in this order. */

/* #include "proplayer.h" */
#include "proto/medplayer.h"
#include "proplayer.h"



int main(int argc,char *argv[])
{
    struct MMD0 *sng;

    struct Library *MEDPlayerBase = NULL;

    if(argc < 2) {
        printf("Usage: example2 <song>\n");
        return;
    }
    /* Assume 4-ch mode (medplayer.library)
       We use V7 to obtain RequiredPlayRoutine */
    MEDPlayerBase = OpenLibrary("medplayer.library",0);
    if(!MEDPlayerBase) {
        printf("Can't open medplayer.library!\n");
        return;
    }
    printf("Loading...\n");
    sng = LoadModule(argv[1]);
    if(!sng) {
        printf("Load error.");
        goto exit;
    }
   GetPlayer(0);
    PlayModule(sng);

    printf("Press Ctrl-C to quit.\n");
    Wait(SIGBREAKF_CTRL_C);

exit:
    FreePlayer();
    UnLoadModule(sng);
    CloseLibrary(MEDPlayerBase);
    return 0;
}

Time will tell if my RPG made on Amiga will be ever finished…

Suicide Express (C64) cover made with PO-28 Robot

I recently got for birthday present a Pocket Operator PO-28 Robot. It’s a pocket synthesizer with sounds that remind me of C64’s SID sounds.

20190703_154000 (2)

PO-28 Robot

 

I made a short cover of Commodore 64’s Suicide Express tune with it. For me it is an unforgetable tune. The cover is only 30 seconds loop..

In the video below it’s played for 4 times.

Back in the day I enjoyed Suicide Express as game probably because of the music. It would be fun to remake this game.

🙂

Unlimited Objects Source Code

In my old blog post I gave some idea how to implement “unlimited objects” program. In the original video I used 16 canvases with 16 images + the actual visible canvas. Two canvases only is sufficient.

In the source (Cerberus X) below, no external graphics files are needed:

Import mojo2

Function Main()
	New MyApp
End

Class MyApp Extends App
	
	Field gfxCopy:Image[16]
	Field ccanvas:Canvas
	Field counter:Int
	Field angle:Float	
	Field canvas:Canvas
	
	Field scaleX:Float, scaleY:Float
		
	Field x:Float, y:Float
	Field r:Float
	
	Method OnCreate()
			
		canvas = New Canvas()
		counter = 0
		
		For Local i:Int = 0 To 15
			gfxCopy[i] = New Image(640,480,.0,.0)
		Next
		
		ccanvas = New Canvas(gfxCopy[0])
		
		scaleX = DeviceWidth / 640
		scaleY = DeviceHeight / 480
		
		r = 100
		SetUpdateRate(60)
	End
	
	Method OnUpdate()

	End
	
	Method OnRender()
		
		angle = angle + 2

		x = Cos(angle) * r + 640 / 2
		y = Sin(angle) * r + 480 / 2
		
		r = r + 0.1

		counter = counter + 1
		If counter = 16 Then counter = 0
				
		ccanvas.SetRenderTarget(gfxCopy[counter])
		ccanvas.SetColor(1,1,0)
		ccanvas.DrawCircle(x,y,32)
		ccanvas.SetColor(1,0,1)
		ccanvas.DrawCircle(x,y,30)
		
		ccanvas.Flush()
		
		canvas.PushMatrix()
		canvas.Scale(scaleX,scaleY)
		
		canvas.Clear	

		canvas.DrawImage(gfxCopy[counter],0,0)

		canvas.Flush()
		canvas.PopMatrix()
						
	End
	
End Class

The program gives different output, if the calculations are in OnUpdate() on HTML5 target.




Below is the old video I’ve made previously:

Source code license: MIT.

Good Commodore 64 games I’ve previously forgotten and which could be re-made

In my old blog post I discussed my computer gaming history with Vic 20 And Commodore 64. Of course, I forgot some nice games that as re-made could be good games even today.

First, I’d like to mention the game I have discussed before: Stix.

I’ve even started to make a remake of this game to Android. Though, I think this project will take some time to get finished.

One game we played with my friends as youngsters a lot is Artillery Duel.

This could be a nice Android game with possibility to play with others via the internet.

Omega Race has been for example to the Amiga as shareware remake game. It would be nice to make some kind of version of this game to Android, too. Below a video of the Vic 20 version of this game:

I’ve started to make a remake also from this game to Android…

Cataball is also something, that could be interesting to make to Android platform. Video of the Commodore 64 version:

With nice backgrounds with parallax scrolling, the result could be nice.

Also, a version of Gyruss to Android could be nice.

One of my online games reminds me of this game, namely Defense III.

Let’s see how the Android versions turn out to be… 🙂

 

Old School XII – Unlimited Objects

The idea to Old School XII comes from Amiga demos from the early 90’s. First there was lots of competition in the Amiga demo scene on who makes a demo with most amount of bobs (blitter objects) in one 50Hz frame. Eventually we saw bob demos with unlimited amount of bobs!

The amount of bobs is basically unlimited; only the visible area of the screen limits the amount of moving bobs. This is achieved with actually only one bob!

I made today this effect in Monkey X.

The implementation in Monkey X is done by using multiple canvases with images. One canvas is used to draw into screen, the rest of of the canvases are used to achieve the unlimited objects effect.

Below is the video of the Monkey X implementation:

I haven’t yet tested if less amount of canvases is sufficient, but in the beginning of the code I wrote the following:

		For Local i:Int = 0 To 15
			gfxCopy[i] = New Image(640,480,.0,.0)
			ccanvas[i] = New Canvas(gfxCopy[i])
		Next

The only object is drawn subsequently to each of created canvases. The following line does the magic of unlimited objects:

canvas.DrawImage(gfxCopy[counter],0,0)

For the end below is one Amiga demo with unlimited bobs:

I made HD (or HQ) version of the video later today:

That’s all for now!

Starfield cube 2 and other Blitz3D demos

I haven’t done much 3D programming in Blitz3D. You can achieve quite a lot with a small effort with it. Also in Monkey2 programming language is the main functionality of Blitz3D. The idea to program a starfield cube came from an Amiga remix tune, that has speech in it: ”Starfield in a box. OMG it is rotating!” Back in the time it was hard to program things like that in assembly on Amiga. Nowadays even I can put a code together, that does the job in Blitz3D.

Starfield cube 2:

Making the starfield cube 2 program made me to create also the following video as a result of inspiration with Blitz3D:

The tiger in the cube (in some parts of the video) is from a photo of my trip to Zoo of Helsinki (Korkeasaaren eläintarha). The tiger seemed to be a bit stressed while people were watching it. Though, I remember someone saying it’s smart, because it uses the same always the same paths, when walking.

Example of Own Font Class in Monkey X

I seem to live in the past… Monkey X programming language has evolved into Monkey2, but I’m still sometimes using Monkey X.

I made an example class to use in Monkey X with bitmap fonts converted with my Font 2 PNG. The example uses old Mojo-module, but old examples on scaling bitmap font made with Font 2 PNG will give you an idea of an alternative way to implementing this.

Next, let’s take a look at a screenshot:

Next to the code:

Import mojo
Import brl.stream
Import brl.filestream

Function Main()
	New MyApp
End

Class MyFont
	Field maxHeight:Int
	Field fontDat:Int[][]
	Field gfxFont:Image
	Field scale:Float
End

Class MyApp Extends App
	
	Field gfxBG:Image
	Global font1:MyFont
	Global font2:MyFont

	Method OnCreate()

		Local file:FileStream
		
		' -------
		' Font 1
		' -------
		font1 = New MyFont
		font1.gfxFont = LoadImage("font1.png")
		font1.fontDat = allocateArray(95,2)
		font1.scale = 1
		font1.maxHeight = 71

		file = FileStream.Open("monkey://data/font1.dat","r")
		
		For Local i:Int = 0 To 95 - 1
			font1.fontDat[i][0] = file.ReadInt()
			font1.fontDat[i][1] = file.ReadInt()
		Next				
		
		file.Close()

		' -------	
		' Font 2
		'--------
		font2 = New MyFont
		font2.gfxFont = LoadImage("font2.png")
		font2.fontDat = allocateArray(95,2)
		font2.scale = 1
		font2.maxHeight = 43

		file = FileStream.Open("monkey://data/font2.dat","r")
	
		For Local i:Int = 0 To 95 - 1
			font2.fontDat[i][0] = file.ReadInt()
			font2.fontDat[i][1] = file.ReadInt()
		Next				
		
		file.Close()
		
		gfxBG = LoadImage("bg.jpg")
		
		SetDeviceWindow(640,480,0)
		
		SetUpdateRate(30)
	End
	
	Method OnRender()
		SetBlend AlphaBlend
		SetAlpha 1
		DrawImage gfxBG,0,0

		drawString(font1, "Testing font 1", 10, 10)
		drawString(font2, "Testing font 2", (640 - (stringWidth(font2, "Testing font 2") * font2.scale)) / 2, (480 - (font2.maxHeight * font2.scale)) / 2)
	End
	
	Function drawString(font:MyFont, text:String, x:Float, y:Float)
		Local len = text.Length()
		
		Local chrs:Int[]
		chrs = text.ToChars()
		
		For Local i = 0 To len - 1
			'                               pos. in font.png          width in pixels in font.png
			DrawImageRect font.gfxFont, x, y, font.fontDat[chrs[i]-32][0], 0, font.fontDat[chrs[i]-32][1], font.maxHeight, 0 , font.scale, font.scale,0
			x = x + font.fontDat[chrs[i]-32][1] * font.scale
		Next

	End
	
	Function stringWidth:Int(font:MyFont, text:String)
		Local len:Int = text.Length()
		Local chrs:Int[]
		Local length:Int = 0
		
		chrs = text.ToChars()
		
		For Local i:Int = 0 To len - 1
			length = length + font.fontDat[chrs[i]-32][1]
		Next
		
		Return length
	End
	
	Function allocateArray:Int[][](i:Int, j:Int)
    	Local arr:Int[][] = New Int[i][]
    	
    	For Local index = 0 Until i
    	    arr[index] = New Int[j]
    	Next
    	
    	Return arr		
	End

End Class

Font 2 PNG prints the max height of the font after converting. The value is in practice just the height of the png-file.

As a reminder: Font 2 PNG produces two files, font.png and font.dat for one font. The font.dat-file holds the information for each character with two 4 byte integers, first tells the position in pixels in font, the second the width of the chatacter in pixels.

I hope this example gives you some ideas on how to use different fonts converted with Font 2 PNG.

Feel free to use the code above.

PS. I also made new version of part 1 of my Old School series demonstration in Monkey X. Video below:

From the source code in the video you’ll get an idea, how this font class could be used with Mojo2-module.

That’s it from my “hobby corner” tonight!