Pages

Wednesday, 12 February 2020

Fooling around some more with THEC64 Microcomputer


I already made some (premature) notes about THE C64 emulator machine. Here are some of the things I have been doing with it.

Before I go further, just to wrap up:
  • Just a teeny bit laggy, but the framerate seemed smooth
  • But be mindful of the 50hz - 60hz capability of your display (60hz PAL is unreal)
  • Can do VIC-20 mode too
  • The joystick is bit clunky but has those nice extra mappable buttons & the useful menu key
  • Does only HDMI, not even separate audio
  • ... but a HDMI-VGA adapter with audio split can help, but obviously a 50hz display is needed for smooth and correct speed.
By the way I have not opened my THE C64 yet, I've seen the pictures and it's unlikely I will do any mods in the near future so I'll let it be.


CJM file-specific parameter text files

Just saying what the manual says. If you insert a memory stick into THE C64, you can load disk images (.d64) and program files (.prg) directly from the stick.

If you put rambo.d64 disk image on your memory stick, and have a rambo.cjm text file at the same folder, you can create a joystick configuration that maps the weapon change key (space) with the extra joystick buttons.

X:64,pal,accuratedisk,driveicon
J:1*:JU,JD,JL,JR,JF,JF,SP,SP,JF,SP,B,C,JF,4,5
J:2:JU,JD,JL,JR,JF,JF,F1,F2,JF,1,2,3,JF,F3,F4

Games such as Mercenary, Elite and any flight simulators can be obviously enhanced by this feature, even if these games often have far more buttons than the joystick has.

My palette is a bit iffy today, can't care to fix it
But certainly speed controls in Elite, missile target, launch & unarm keys could be configured this way. (It's just that C64 Elite is a bit crap.)

I also found the joystick a bit physically clumsy for these extra buttons, so it wasn't so enjoyable with Rambo. But there's no stopping using a proper 2000s USB gamepad with four-button cluster and shoulder buttons. How authentic is that... well, there were gamepads back in the day too.

For Twin Tornado, I tried this:

X:64,pal
J:1:JU,JD,JL,JR,JF,JF,F1,F2,JF,1,2,3,JF,F3,F4
J:2*:JU,JD,JL,JR,JF,JF,CO,/,JF,H,Y,A,JF,4,5

I put throttle controls to triangle buttons and wing adjust to the two leftmost of the tiny buttons. Third tiny button turns on the combat sights. Note that for "comma" I used CO, as obviously a real comma might mess the syntax.

Twin Tornado has serial head-to-head mode but this can't be done with THEC64
The simulator boasts surprisingly fast wireframe 3D. To fly the Tornado, Increase throttle to max, release wheel brake with SPACE. Pull up when appropriate. Once in air, switch gear and flaps with T and R respectively.

As a variable-sweep wing fighter, the Panavia Tornado can pull its wings back. Switch them to a position of 68 degrees and then you can reach Mach 1.0+ speeds. The wings can't be switched back unless you drop speed.

To get Digital Integration's Tomahawk to respond, I tried this:

X:64,pal
J:1:JU,JD,JL,JR,JF,JF,F1,F2,JF,1,2,3,JF,F3,F4
J:2*:JU,JD,JL,JR,JF,JF,A,Q,JF,S,W,P,JF,4,5

The throttle and collective controls are mapped to the triangle buttons and the two first tiny buttons. The third tiny button swaps between weapon systems, once they have been activated with key C on the keyboard.

To get that Apache up in the air, increase both collective and throttle until the copter starts to rise. Then you can turn the nose down a bit so it begins to move forward. Then re-adjust the throttle/collective to maintain level flight.

It's a bit hard to tell 8-bit flight simulators apart.
I noticed that trying to use the mapped keys and joystick in very complex motions, it may inadvertently activate a key that's not involved at all. Such as Pause in the case of Tomahawk. This might have happened with the real keyboard too, it's just that back in the day the keys did not receive these combinations so easily.

I have also felt the joystick gets a bit stuck once in a while. Perhaps it will loosen up a bit over time.

They really added some weight to it! Should have weighted the shaft, though.



Cartridge & Disk images

I was interested in whether THE C64 can accept cartridges, not just games but things like Action Replay VI or Final Cartridge III.

Long story short, AVI did not seem to work whereas FCIII did. It's one way to access a machine code monitor. I'd prefer the AVI monitor, though.

I encountered some hiccups with more complex disk loaders. I was a bit saddened that the Ultima IV remaster D81 image (a large-capacity disk image) would not run further than the intro screen.

So, the utility cart support in THE C64 is a bit more haphazard and might not behave entirely as one would wish, but it's not all a loss.

On the plus side, "easyflash" carts work and many important multi-disk games have been modded to work on these images, so welcome Project Firestart and Ultima IV remastered after all!

I felt that the savestates are unlikely to work on anything that sounds a bit non-standard, such as these cart image games.

The few demoscene intros I tried appeared fine, though borders were cropped at times. There is another display mode in THE C64 that shows more of the borders, but may result in a smaller mid-screen area for games.

I perhaps wouldn't use THE C64 for running demoscene demos anyway, as there is no support for CRT display and the SID emulation is what it is.


Disk image file handling

You can have C64-compatible .PRG files directly on the memory stick, but many games come in the .D64 disk image format, which can be a container for multiple C64 files.

THE C64 facilitates loading these disk contents directly from the menus (the first file will be loaded), but to have more sophisticated handling of these virtual floppies you need to use BASIC.

As THE C64 by default mounts an empty C64 floppy image in the .D64 format, it's easy to save BASIC code snippets to the disk using

SAVE "MYPROG",8

and load them back with

LOAD "MYPROG",8

It may make sense to backup that disk image once in a while.

You can check the contents of a disk image with

LOAD "$",8

followed with

LIST

Remember that reading the directory with LOAD "$",8 will destroy the current BASIC program in memory!

Removing files is a bit trickier, and you can't simply overwrite a file by saving it with the same filename. Three commands are required (each followed with return):

OPEN 15,8,15
PRINT #15,"S0:MYPROG"
CLOSE 15

S0 stands for SCRATCH0.



BASIC

Transferring code from PC over to THE C64 is not a very exciting prospect, you have to use the USB stick and that kind of slows things down a bit.

Once in a while it is fun to play around with the BASIC, although I rarely have patience to do anything large with it.

The trade-off with the 8-bit interpreted BASIC is that it's very easy to start a program and get things going, but as the program gets larger it becomes slow and difficult to organize.

So it might be good to have some kind of rough paper plan for the program as it grows. Experience with other languages is also a good teacher.

There are also ways to embed forethought into your program. Although you can always clear the screen and set the colors with a PRINT statement...


a subroutine could be called instead.

10 GOSUB 9000
100 REM main loop
200 GOTO 100
9000 REM clear screen subroutine
9010 PRINT "[clrhome][white]"; : REM use the real characters
9020 POKE 53280,0 : REM border black
9030 POKE 53281,0 : REM background black
9100 RETURN

So, every time you want to clear the screen and reset the colors, use GOSUB 9000.

The downside here is that you might not remember what GOSUB 9000 stands for, and the program becomes less readable. Unlike ZX Spectrum, C64 BASIC does not allow the use of variables as label names (which might slow down the calls besides).

So, use discretion!

Remember that editor screen codes can be inserted in the BASIC " quotes.
So, if normally pressing SHIFT+CLR/HOME clears the screen immediately, typing it after a " will enter the character code instead. Again closing the quote with " will again make the key work directly. Cursor keys, home/clr cursor and reverse on/off can be used this way.

So it's one way of positioning the cursor:

PRINT "[clrhome][down][down][down][down][right][right][right]HELLO"

[clrhome] implies pressing the key clr/home and so on. This would position the text down 4 rows and right 3 columns from the top left corner.

Then, later you can consider whether the screen-clearing has some kind of effect in it or not. Only changing the contents of that one subroutine you can change all screen clears in your program. Or replace it with a machine code call, etc.

There might be subroutine for "press any key", so it could always be called the same way and display that message too.

The subroutine call overhead is significant in BASIC, so it might be better avoided inside the main loop of an action game.

For displaying characters more directly, sometimes POKEing the display may be better than PRINTING character codes.

10 X=20
20 Y=12
30 POKE 1024+X+Y*40,1

This should display an 'A' at roughly at the middle of the screen. Bear in mind that generally PRINTing is faster than trying to combine many characters through POKEs.

Reading the joystick from BASIC is not hard. You have to decipher all the directions one at a time in case there are multiple directions and buttons pressed at once.

10 J=PEEK(56320)
20 IF (J AND 1)=0 THEN PRINT"UP"
30 IF (J AND 2)=0 THEN PRINT"DOWN"
40 IF (J AND 4)=0 THEN PRINT"LEFT"
50 IF (J AND 8)=0 THEN PRINT"RIGHT"
60 IF (J AND 16)=0 THEN PRINT"FIRE"
70 GOTO 10

In case you only need two opposite directions and no fire button, direct values can be used:

10 J=PEEK(56320)
20 IF J=119 THEN PRINT "RIGHT"
30 IF J=111 THEN PRINT "LEFT"
40 GOTO 10

This would spare the interpreter from making more calculations than needed.

The additional keys (and keyboard altogether) of THE C64 Joystick can be read like this:

10 GET A$
20 IF A$="Y" THEN PRINT "THEC64 EXTRA BUTTON 1"
30 IF A$="N" THEN PRINT "THEC64 EXTRA BUTTON 2"
40 IF A$<>"" THEN IF ASC(A$)=13 THEN PRINT "THEC64 EXTRA BUTTON 3"
50 GOTO 10

This assumes a THEC64 joystick with the default config of Y, N and RETURN. Of course the keys can be used too. I'm unsure if the RETURN key could be done with some other means, but at least that works.

Unless the joystick has been configured to other keys, the triangular buttons do nothing.

Wednesday, 5 February 2020

Orion Millennium chess computer 6 in 1


From 2004, the box has a still young-ish Karpov's face on it. I'm wondering if he is recommending the product or the game of chess in general!

As far as actual chess-playing goes, this kind of cheap chess computer is now mostly superseded by mobile phones at the low end, and digital boards towards the higher end. As a design object, a more vintage device would have been prettier, but it's not the ugliest I've seen.

It's not just a chess computer, the featured six games are Chess, Checkers, Othello/Reversi, 4-in-a-row, Halma and Nim. Incidentally, Nim was probably one of the first electronically implemented "digital" games. I'm only looking at the chess variant here.

The machine operates with 4 AA batteries, and there is no connector for a power supply.

First a small disappointment: The chessmen were missing from the box, only the generic button-like pieces for the other games were left. As this cost me only 4 euros I don't mind that much. The instructions were in place. Even in good complete condition, I'm not seeing people asking more than 20 euros for this.

I used my magnetic pieces from a tiny travel set. They are a bit too small and a bit hard to tell apart, but at least I could test the board.


The board feel is sturdy and weighty enough, the footprint is less than A4, squares are 21mm giving about 168mm board size. Given the chessmen are not large to begin with, it's a pity there is no storage for them in the case itself, it wouldn't have made the computer much larger.

After inserting the batteries, the computer gave a friendly beep. It works!

The moves are activated by pushing the board at the starting position and then the ending position. This can be done with the pieces. It's not highly convenient but at least simple to understand. I felt I had to press the squares quite hard. Typing in the moves might have been more effective, but there's no option for that.

At the start it felt needlessly complicated that I had to perform the pushing of opponent's moves too. But it is understandable, as it prevents mistakes from happening.

In castling, you need to perform both the king and the rook moves.

As the computer is initially in a tutor mode, some moves were greeted with 'bad move' sounds. The step has to be passed with 'next move' key. I felt sometimes pressing this also switched the player sides. Hmm. Well, the tutor can be turned off by pressing first what looks like the "Cancer" horoscope symbol, and then the tutor key.


Playing

I played one game from start to finish against the computer, at the default level, which must be really easy. In this opening (Ruy Lopez), it seems the opening library ended after 4 moves (4 white, 4 black pieces moved) as then the computer started using time for thinking. Thinking took about 10 seconds on this default level.

Me vs. Millennium Orion 1-0:

1. e4 e5 2. Nf3 Nc6 3. Bb5 Nf6 4. O-O Nxe4
5. Bxc6 dxc6 6. Nxe5 Be6 7. h3 Bc5 8. d3 Nf6
9. Bg5 O-O 10. Nd2 Qd4 11. Bxf6 gxf6 12. Nef3 Qxb2
13. Nh4 Bxa2 14. Qg4+ Kh8 15. Rfc1 a5 16. Ne4 Bd4
17. Nf5 Qxa1 18. Qg7#

My move 15. Rfc1 was made by the computer too, as I had managed to mess the turn order because of the tutor mode. After that, I turned off the tutor.

Looking at the game in Stockfish, I made a mess out of it at the very start but the computer did not follow through in this level. (That 15. Rfc1 move was a mistake, too).

It does look like two noobs playing. The game ended with the computer allowing me to checkmate even though it could have been prevented.


The manual indicates there are many combinations of difficulty/time options to make the computer play a harder game. It's just not easy to figure out what the levels are and what level of human play they might correspond to. But I suspect the thinking time will increase drastically on the higher levels.

It's also possible to adjust the play style between passive and aggressive (5 levels, normal giving the best play). Perhaps I'll try to challenge a more difficult level some time.

The computer includes a library of "classic" chess games, including Fischer, Karpov, Kasparov and the Kasparov/Deep Blue games, a total of 320 games. These are listed in the manual but they are not dated. It is unclear if the AI is able to draw any wisdom out of these games, probably not.

(This also means there are more Kasparov than Karpov games stored inside!)