Thursday, 17 January 2019

IRQhack64 serial transfer


Previously I had only used my IRQHack64 to load files from the SD card. I now wanted to turn to the transfer functions, enabled by the 6 pins sticking out of the cartridge.

The transfer is something that potentially brings the cart to a whole new level. With this port it's possible to send a file over the serial and the C64 runs it automatically.

Just to make this clear, IRQHack64 is not a substitute for a C64 serial port, it doesn't connect a modem, internet or MIDI. Your PC communicates with the Arduino inside the cart, and the Arduino+EPROM work their magic with the C64.

But as the Arduino inside the cart is not limited by C64 hardware speeds, the files move at a nice 57600 rate, and they move over to C64 even faster.

I have postponed testing his because firstly I knew it would probably be a chore, as the IRQHack64 software is not very clearly documented. All the sources have been made available, but there's no overall comprehensive guide for what the cart is supposed to do and how.

Also, the Arduino code, the EPROM code and the irqhack64.prg need to have compatible versions or the cartridge likely won't work.
Connecting the PC to the cart using an FTDI board
More importantly, I needed the FTDI board, which makes it possible to communicate with the Arduino Pro Mini inside through serial, while the cart is on-line.


Converting the IRQHackSend

I used the IRQHack64Turbo project as a starting point for examining what the software is supposed to do. At least after compiling the Arduino source I get a working cartridge that plays nice with the current EPROM and the menu program.

The IRQHackSend in the Tools folder is a separate software for sending files from the PC end. It was simple enough to adapt to Processing.

The program opens a 57600 connection to the Arduino inside the IRQHack64, sends the "1" character which tells the Arduino at that end to start receiving. After this the Processing source sends the file length bytes, two header bytes and data bytes just as the original source does, with suitable delays here and there.

Immediately I got my software to talk with the cart, as the IRQHack transmits the menu and other responses over the serial. Using single character commands over the connection, the C64 can be reset with or without the cartridge, the cart menu software can be triggered remotely from the serial and so on. This remote control-reset was a nice bonus. So far so good.

However, using the file transfer mode was not a success, as the resulting bytes were often garbage. For a while I thought the serial transfer was to blame, and I spent hours messing around with the Arduino source.


The Obvious Solution

Umm, it turns out there is a speed toggle that apparently affects how the memory write works. The cart might have even have worked out of the box (not that it came with a box), but I could have changed that accidentally. The serial was not to blame at all, at least with these small file sizes.

The source seems to indicate it's possible to change the speed through the time-based button press interface using more than 5 seconds pressing. The source is also where I found this feature even exists.

I changed the Arduino source so I could send the speed toggle through a serial command, so I could be more sure that it has been received. After that, the serial-transferred files & memory writes started working!

Below is a Processing source for sending a file over to the IRQHack cartridge, using the FTDI board as a serial port.


import processing.serial.*;

Serial myPort;

void setup()
{
  int port = -1;
  for(int i=0;i<Serial.list().length;i++){
    String stn = Serial.list()[i];
    println (i+":"+stn);
    if(stn.indexOf("USB0")>=0)port=i; 
  }
  if(port>=0){
    String portName = Serial.list()[port];
    println (portName);
    myPort = new Serial(this, portName, 57600);}
  else{
    println("NO USB found");
  }
}

void waiter(int amount){
  for(int i = 0;i<amount/10;i++){
    if (myPort.available() > 0)print (char(myPort.read()));      
    delay(10);
  }
}

void keyPressed(){
   int k=key;
   if(k=='1')send_file("myfile.prg"); // send this file
   if(k=='r')myPort.write('3'); // reset c64
   if(k=='c')myPort.write('4'); // reset c64 nocart
   if(k=='d')myPort.write('2'); // enter dir menu remotely
}

void send_file(String fname)

  myPort.write('1'); // "type" the Receive prog command at Irqhack's menu via serial

  byte prgdata[] = loadBytes(fname);
  
  waiter(250); // 250*10 millis, original delay(2500) millis
  
  byte low = (byte)(prgdata.length % 256);
  byte high = (byte)(prgdata.length / 256);
  
  myPort.write((low)); // write length to receiving end  
  myPort.write((high));
  
  for(int i=0;i<2;i++){ // write prg header
    myPort.write(char(prgdata[i]));
    if((i%32) == 0)delay(10);
  }
  for(int i=2;i<prgdata.length;i++){ // write actual data
    myPort.write(char(prgdata[i]));
    if((i%32) == 0)delay(10);
  }
  // we're done here
  waiter(1000);
}

void draw()
{  
  if (myPort.available() > 0) print (char(myPort.read()));         
}

This is a minimal Processing sketch. I've only tried it on Linux. It scans the serial list for the presence of the string USB0, this may vary depending on your computer and serial adapter/FTDI hardware.

The program reads all incoming characters and prints them on the console. Pressing '1' will send a file myfile.prg over the serial, if it exists. R and C keys resets the C64 and D makes the IRQhack enter the file selector menu. If there's no Arduino source change, there's no point sending a 'speed toggle' command.

Now that I already made the work on Processing, I modded the PETSCII editor to save & upload the exported prg through a keypress, so I can do PETSCII graphics on PC screen and experiment with results on the C64 screen.

After reducing the pre-delay in my sending routine to 250ms, it takes about a second to transmit the 2K PETSCII prg, so I can do it as often as I like. This was initially at 2000ms. It may be that different C64 units need a slightly different delay.

I've worked on it a bit more for my own setup.
Using the same approach on my Multipaint, it obviously works but as the export file sizes are 10K it already takes closer to 4 seconds to see the results on the C64 screen. But that's not bad at all. I could also revise the Multipaint export so it would send a smaller file in case less than full screen area has is in use. Sending packed files isn't that useful as the C64 will take some time extracting them.

This is still a great improvement over the SD card switch-a-roo between PC and C64. This feels like a real professional Commodore 64 graphics workstation!


Not so fast

I came across problems when transferring some small scene demo and game programs that would normally run from the SD card. Although size is not the only cause, it seems larger files (20K+) are more likely to fail.

I have to stress there is no randomness here, trying to send the same file repeatedly does not help, nor do the small straightforward files really ever fail to send.

*

To extend my review of IRQHack64, I'd now say the serial transfer/remote features are a very nice addition to a developer's toolbox, but it doesn't add much value to a casual user or game player.

For the above purposes, sending simple & short files repeatedly, the cartridge transfer functions still performs fine. For longer files and demo/game collecting it is better to move them on the SD card anyway, from where they can be run more reliably.

The cart receives a file and run it, although it would be in some situations more useful to send memory areas to C64 without resetting or running any code, for example overwriting portions of the graphics memory. But, without changing the EPROM code this situation probably can't be changed.

Thursday, 3 January 2019

2018

As last year, I try to recap the year.

Firstly, what I said in the 2017 post, the idea of platform-specific pages for the blog has not proceeded, although I've updated the existing Sinclair QL one. I'll have to look into it some more.

I have avoided buying more old computer hardware, although I did buy that atrocious hand held console and a crappy flea market NES-clone. And just at the end of 2018, a C128D motherboard. Oh well.

On with the show!


Releases, Coding, Events

At the end of 2017 I was quite enthusiastic about Sinclair QL, but it turned out I did not spend that much time with it after the beginning of 2018. Even the work on the still unreleased QLDD software was mostly done in late 2017.

Commodore 64 has kept its position as my retro favorite, and the building of a new desktop case for the computer has occupied much of my hobby-time (and this blog). I recently got my IRQhack64 transfer working and a more in-depth blog post is already in the works.

Multipaint was revised into a 2018 version, and a nice version it is. I'm beginning to see the need for better file handling (e.g. recent/last file, autosaves, overwrite warnings) and possible GUI updates.

Panasonic JR-200 returned in a more virtual form, with starting the work on an emulator. I hope this eventually results in something new for the platform.
As usual, I also produced some pixel/text graphics. One was sent to a disk cover competition, the first time I made a 5'25" disk cover. This type of scene output was quite unfamiliar to me, I've probably never seen demoscene disk covers before the 2010s.

The demogroup Desire asked me to make a picture for their X-party demo called C 64, Hear 64, and make it I did!


I didn't do that much graphics in 2018, it seems. But after Christmas, I released a new Commodore 64/plus4 game, Digiloi, following the footsteps of Fort Django. Another PETSCII showcase, it turned out much more popular than I thought it would be.

It also made the blog post about the game easily the most read entry in 2018 and one of the most read altogether.


I'm the first to say there's much more potential in PETSCII games than what I was able to put together here, as even I could see in hindsight it might be coded better in parts. Even as it is, more stuff could be moved on-screen, but the game was getting a bit crowded.

Also, the plus/4 conversion proved to me finally that this computer is something to explore a bit further.


Games, books, films

From the beginning of the year I have put more attention to Chess, playing puzzles and computer matches at Lichess.org, acquiring sets and reading literature. I even went to a beginners' tournament.

But I'm starting to waver a bit. The amount of time it would take to improve my skills might be disturbingly high. So far I've not seen reason to stop altogether. I'll blog about my experiences at some point.


During summer I played some Atari 2600, and recently I've enjoyed old Commodore 64 games such as Blue Max, Rambo and Raid Over Moscow, also taking mental notes about what makes these games click.

Of more modern games I played Tomb Raider 2013 version, as it worked quite nicely on my Linux. I also had a peep at Life is Strange, but it didn't catch my interest. At the very end of the year I put some effort to try to solve Zak McKracken and the Alien Mindbenders, but it's still going on. I still play Larn every now and then.

On the book front, I read a bunch of sci-fi books, with emphasis on bestsellers and famous books I might have missed earlier. Turns out there is quite a lot. Some of this I also documented in the blog, noting how many plots and ideas in these books have found their ways into various games.


Westworld was the most important TV series. I expected more nods to western cliches & classics, but the concept is less about the west and more about the responsibility towards the imaginary worlds we create. The parallels and connections to video game culture are obvious.

I liked the season 2 less, it felt more of a mixed bag and less purposeful than the first season.

W was an enjoyable Korean "paranormal romance" (genre made popular by Twilight, I guess) TV series which I learn is a quite common there. It's from 2016 but now shown on Finnish net TV. A comic book artist discovers a doorway into the comic world, bit like in that A-Ha video. The daughter of the artist gets involved with the tragic yet resourceful hero of the series and the indefinite murderer.

Take ... on ... me ..
The new Doctor Who with Jodie Whittaker was enjoyable TV somewhat in the same way the 1st new Who season (Eccleston) was, except with higher production. What I mean the writers have given up complex overarching plots and mysteries and concentrated on the one-off episodes, with less metaphysics. The format and storytelling was more straightforward.


This was clearly the most brutal reboot of the series in the 2000s. There was something of a post-Brexit and post-Trump vibe with the season. Instead of pushing the proud Britishness every now and then it tried to be a bit more considerate and inclusive in more ways than just adding a minority companion.

After the New Year's Eve episode I am even more convinced that the writers have decided to 'stretch' the narrative. What would have taken a few episodes at best for each new doctor, now takes a whole season. As the doc returns in 2020, they have plenty of time to think of a follow-up.

Solo: A Star Wars Story. To me it was a pleasant small surprise, even if the film does not add much to the broader 'Wars lore. Well, Lucas was originally influenced by early movie serials, and in Star Wars we now have them. Is that a good thing?

As Solo was the character that most embodied the "space cowboy" side of Star Wars, it makes sense to make his film a western. The space scenes on the other hand were a bit messy. What with the candy-colored Maelstrom and the Maw, it's like there never was a good clean space shot, the kind that made the original films so stylish.



On with 2019...!

Thursday, 27 December 2018

Digiloi: Action game with C64 default characters


Digiloi is a game I made for Commodore 64, using only the default character graphics (PETSCII) for visuals. For some time I've wanted to use this approach. Fort Django used PETSCII for the backgrounds, but all the gameplay worked with sprites.

There's nothing special about using PETSCII for games, it was done a lot back in the day. However, not many full screen action games were done using the technique, probably because sprites are far more useful and the clunky char-by-char movement was not that attractive.

This visual style is closer to ZX Spectrum game programming techniques, even if the Speccy does not have a character display. Many ZX games had movement restricted to the color grid, with big player "sprites" to compensate. Don Priestley used his unique techniques in Benny Hill, Popeye, Trap Door, Flunky etc.

Left: The old-style forest. Right: UFO attacks
Later, others made fast arcade type games with a more streamlined approach, for example Dan Dare IIISavage!, and Extreme. What I've done is a bit of a compromise between these, an arcade game following Priestley's non-scrolling style but ignoring the more complex aspects of his routines.

I could not achieve 50 frames per second for these big dudes. I wondered if I could stick to 1/2 or 1/4 framerate, knowing that each frame would add greatly to the amount of code that can be executed. I went for 1/3, which is something like 16.67 frames per second on a PAL machine.

I use 256-byte aligned buffers for holding the current screen background and building the screen for displaying. I discarded the idea of double-buffered page swapping routines as the color memory in this mode is fixed at $D800 anyway.

The visuals and game logic are orchestrated like this:

Frame 1:
The background screen & colors, which were built on entering the "room", are copied to the respective 256-byte aligned buffers using speedcode. Copying 2K of characters and colors takes nearly the entire frame.

+joystick poll, music/fx play

Frame 2:
The 8 x 8 character "sprites" are drawn over the 256-byte aligned buffers. Each large "sprite" graphic is stored in 143 reverse-ordered data bytes including color and line-padding zeroes. Some smaller graphic elements, like bullets, are drawn using hardcoded routines.

This uses something like third of a frame, depending on how many movable objects there are on screen.

+joystick poll, music/fx play

Frame 3:
The 256-byte aligned background buffer is copied to the visible screen using speedcode. Again, this is 2K and takes nearly the entire frame.

+joystick poll, music/fx play

During each frame the interrupt plays a GoatTracker SID tune and polls the joystick.

With this approach I balanced speed, memory and convenience. Especially I like convenience. The 256-aligned buffers are quite handy. When transfering the 8x8 character elements to the buffer, the writing address hi byte is INCed with self-modifying code to reach the next vertical line whereas X register handles the horizontal coordinate.

I already think I might have the graphic shapes erased with routines similar to drawing them, resulting in a faster screen clean-up. Also, I probably could use the X/Y registers without having to resort to the INC gimmick. But once I had my routines in place, I kind of prefer the 1/3 because it gives automatically a nice gameplay speed without having to slow things artificially. Convenience.

With the visuals, I took the easiest, black-background PETSCII approach. I noticed that PETSCII game visuals need a somewhat different approach than static screens: The overlaid "sprites" have to go well with the background without too large black outlines. I initially gave the main character a more rounded look as I would do in a picture, but this did not work with the background. I took most of the rounding off.

This not only influenced the character design but the backgrounds too, so there's more black empty space than would look good in a static picture.

2017? Well, um... I've been sitting on it for a while.
The game is pretty much 100% written in assembler, unlike Fort Django, which still had a fair amount of C code in it. There is still a short C scaffolding for initializing stuff, but after kicking off the main loop it's all asm.

I now feel it's not that much more difficult as the assembler can work quite easily with "variables" and tables, and the X and Y index registers make it easy to have array-like structures for game objects. Using the stack to store registers, it's possible to have hierarchical subroutines and sub-subroutines for various tasks and associated labeled memory locations as "local variables" if need arises.

Tools used:
  • CC65 cross-development package. This has C and assembler together. C is nice for initializing and testing ideas, though it seems I'm relying less and less on it. The included assembler has some things lacking in the code alignment and positioning department (stuff promised in the manual does not seem to work).
  • The text editor included with Linux Mint Mate, Xed or whatever it's called nowadays. Later in the project, I moved to Sublime Text with added 6502 asm highlighting.
  • VICE emulator. Obviously.
  • C64Debugger from Samar Productions. A neat tool for examining C64 memory content live as it is emulated. This was useful in getting the 256-byte aligned buffers working.
  • Marq's PETSCII editor. Not only it is good for creating static PETSCII screens, it does a good job with tiles and animated graphics. I did add custom ordered exporting code, though.
  • GoatTracker 2.73. Does the job well and has simple to understand sound fx routines (after understanding them, that is) and easy export.
  • Tiled. A friendly enough map editor that outputs csv. It's nice to be able to grab larger entities from the map or the tilesheet and paint with them. The tiles are exported as PNGs from the PETSCII editor straight into a tile sheet for Tiled.
  • Processing. For generating some of the tables and converting the Tiled csv directly into ordered room list in an assembler-friendly format. Also, the PETSCII editor modifications are made with Processing.

Commodore Plus/4 conversion note

As the game routine operates most heavily in an invisible back-buffer, there are not that many unique routines and addresses in use. So I could convert the game fairly fast to plus/4 simply by changing the speedcode to point to plus/4 character and color memory addresses.

The joystick reading needed a bit more investigating, but it's not that much more complex than on a C64. I added a keyboard key reading too to switch the music on and off. Sadly, there's only SID support on the sound side.

plus4 version
I re-painted the graphics using the PETSCII editor's plus/4 conversion as a starting point. Some coloring was hard-coded to the source (tut-tut!) but not at too many places. The result is not that different from the C64 original, but it has a bit more shine here and there.

It's more interesting to see that the code runs roughly 30% faster at places, even without trying any plus/4 specific tricks. More could be achieved with plus/4 on this type of game, than on a C64.

I can also see that despite having twice as fast processor, it does not mean a 2x speed. But, certainly the 1/2 framerate might be a more realistic goal even without modifying the routines too much.

*** 28.12.2018 plus/4 addition: The speed-up I'm talking about is not really present in the originally released Plus/4 conversion of the game. I have made a speeded up demo for plus/4 available at the download links below so you can see the game running at 25fps.

However this is a rough-at-the-edges implementation and I have no guarantee it works well all the time. Also, as the game runs faster it may be less playable. The plus/4 is quite a neat computer!


Some reflections

I've wondered why I don't finish more stuff. It's not really about available time.

My projects tend to follow this script:

1. Become enthusiastic about a visual/logical solution for graphics and animation routines, which are at first built with care and reason
2. Start building the game logic with fundamental routines, still maintaining neat hierarchy
3. Lose momentum. Become bored and make new additions without much thought, adding stuff outside the existing hierarchy, generating potential problems difficult to solve later
4. Hastily wrap up. Instead of creating more gameplay & narrative, be happy with finishing the thing

If something disturbs the game within phase 1-2, it's possible that the project never gets completed. If it gets past phase 2, I can at least stubbornly make a finished piece out of it.

One antidote is to try to make the start/game over/finishing logic fairly early on in the project, so it's basically "finished", although there might be a lot to do on the other parts. This is something I did here.

It might seem that more game content would be just incremental work. But again, creating and testing game content becomes increasingly painful as the game gains size. Add a level, it has to be tested. Add a monster type, all the rooms with it have to be tested. Add a weapon, all the areas have to be tested again.

No wonder games are sometimes pre-planned before coding anything. But I find it infinitely boring to try to design a whole game beforehand and then just code it, as lot of the fun arises from trying varieties and discovering things as I go along.

I'm also speculating that fatigue strikes because incremental work stages are boring. The first coding stages often bring an euphoria of seeing exponential results as a result of tiny amount of work or changes.

You'll need a Commodore 64 computer or a C64 emulator to play this game.

Direct download of D64 disk image with Commodore 64 and Plus/4 programs
Digiloi at csdb
At plus4world

Download the prg for the Commodore plus/4 speeded-up demo version here

Sunday, 23 December 2018

Chessboard modification


I received a 30cm chessboard box that was in a slightly poor condition. I have a better box in better shape (pictured above) so this was an opportunity to modify the damaged one.

The set is nostalgic for me as I played with similar pieces a lot during my childhood and youth in the 1980s-1990s. I believe these sets and likely the design itself originated somewhere in what was then the Soviet Union, and come in numerous variants and varying build quality. I have no idea how typical these might have been over there.

I am especially fond of the bishops, with no distracting "mitre" or knobs on them.

Admittedly the board is a bit dense for playing, although it looks visually pleasing to me and given the history I'm hardwired to accept this as a normal chessboard.

A board with slightly larger squares could still come handy. The goal at first was to increase the size of the playing squares, but I also became quite interested in the surface treatment.

Half board removed. The amount of dust is spectacular.
The box is 300 x 300 sized, with the original borders it makes the effective play area about 280 x 280 with 35 x 35 mm squares.

To fit this more with my blog theme, I used a Commodore 64 BASIC loop to calculate the measures. So, without the borders the square size becomes 300/8=37.5


The box is slightly deeper than it is wide, so I used 151.5/4 to get the other square dimension for each half-board, which was 37.875. Although this kind of precision is somewhat pointless for my handiwork, it is important for adding up the cumulative measures.

Sanding away the existing squares was the most boring work stage, although the actual sanding likely didn't take much more than 30 minutes altogether. The staining and lacquer treatment requires the surface to be well finished, and I used 80, 120, 240 and 320 grit sanding paper to get there.


Woodstaining

The measure marks were made to all edges of the board, then I used a paper knife along a ruler to pull grooves across and along the plywood. This means that when I brush in the dye, it won't be absorbed over the square edges.

Carefully testing the board, the pieces don't touch the stained parts yet
Still, the brushwork needs to be careful. It was better to allow the liquid to flood towards the edge instead of trying to brush directly along the grooves. Firstly, the absorption effect is quite forceful, and secondly, the brush could also easily touch the other square which would be "goodbye, board" to me.

The cuts across need to be quite deep whereas the cuts along can be shallow.


Lacquer

After letting the staining dry overnight, I applied urethane alkyd lacquer on the surface. One layer of the lacquer was nearly enough to make the kind of smooth surface I looked for. After 24h drying I made a light in-between sanding with the 320 grit paper, wiped out the dust with a moist rag, waited a bit and added another layer.

But after half an hour I dared to test the whole set. (This is still without the lacquer)
Afterwards I'm quite happy with the surface. I did get those tiniest bubbles for both layers. This might be unacceptable in a continuous table surface, but with this kind of checkered board it is not too visible. If you look for them they are there.

Can the bubbles be avoided? It turns out I had not heeded the instructions: the first layer ought to be thinned by 20% and multiple thin layers would be better than 1-2 thick layers. Also, a proper brush might have helped reduce the "bubbles".

Comparing the new width squares with the old.
The paper knife technique has the weakness that the grooves will remain visible. More often than not paints and lacquers tend to highlight scratches, dirt and unevenness, than smooth them out. Still, I don't think these grooves are ugly.

An alternative approach might have been to make a new board layer entirely from plywood and glue it on top of the existing one, this way I could have avoided the sanding. But it would have been a different project.



Thursday, 13 December 2018

Panasonic JR-200 emulation

Feeling a bit nostalgic, not only because it's an old computer, but because the early days of this blog was very much about Panasonic JR-200UP.

At that time I had hoped I could code something on the platform, especially as Marq went through the trouble of finding about most of the hardware and I spent time figuring out the tape format.

The lack of an emulator discouraged me, as I tend to code with extremely short build cycles, compiling the code every few seconds almost. The fun and nostalgia of tape loaded binaries fades quite rapidly.

Panyansonic by FIT.
At one point the solution could have been a device that helps transfer the data rapidly to the real computer. Although it showed promise it begun to feel fiddly altogether, and somewhat slow to set up compared to an emulator.

There has been James the Animal Tamer's JR200 emulation that I have never seen running, as it only runs on some Windows version. Also, the scanline/vblank emulation is apparently non-existent. The JR200 quite probably does not have a software-accessible, simple way to track the screen refresh accurately.

The trick is to rig the interrupt to work with the internal timer in that capacity, using an address to catch the currently written attribute, as in the Panyansonic and SR-200 intros made by FIT. I felt the emulator ought to be able to somehow work with this trick.


The Emulator

My emulation project had a few false starts over the years. I had to learn 8-bit assembly more in the meantime and something about how chips work before I begun to have the mindset necessary for building an emulation. Again, I work on Processing/Java.

I did some limited C64 emulation for myself in the recent past, which was a simpler task in the sense that I didn't set the bar very high and there are existing emulators to compare it to. (More about this, maybe, one day).

Left: Incomplete handling of Carry flag at one opcode caused glitching in the SR-200 scrollers. Right: opcode fixed
Here I had to enter the realm of the 6800 processor which is not as familiar to me as the 6502, and hardware that only has been properly documented by Marq, and even that documentation is not entirely complete.

The experience with 6502 was of course very helpful. One early issue was that in 6800, the C flag is treated differently in Subtract with Carry, i.e. the opposite of how it works in 6502. But all in all, the stack commands and how the stack works with JSR, RTS, is quite similar. 6800 stores 16-bit values in HI-LO format instead of LO-HI, which can make things more intuitive.

Over the years I've thought you need to be a genius to write an emulator, but it's not rocket science in the end. To me the key was to make the emulator do something visible in the first hours. So I wrote a few opcodes like INC addr16 and JMP opcode, after which I could already start looking at video emulation.

No joystick yet...
After a preliminary video mode was complete, I made a 256-entry switch-case list that treats each and every opcode as a separate entity. Non-implemented opcodes freeze the emulation and print out the address together with a list of opcodes that have so far been executed. This list can be used to track problems.

As the 6800 is very orthogonal the emulation code could be made much smaller. But it might have resulted in code that either doesn't work at all or works completely, which can be a very frustrating situation. So I guess I'm using an "agile" approach. The downside can be that early errors may be left hanging in some opcodes while rest of the similar instructions work, and these can be difficult to track.

Mind you, the emulation is far, far from complete, which is where the real difficulty lies. For my current purposes it doesn't really have to be complete, as I only wanted to ease the development of JR-200 code, if I ever get interested in that again. So, at least for now, it won't be a public project. I thought if it could run the tiny Nyansonic demo, then all would be well. And it sort of does.

Friday, 30 November 2018

C64 modding on

(Part IV of an ongoing series)

A couple of things have been done to the boxed C64.


Arduino programmer port

The PS/2 keyboard adapter is Arduino-based, which still needs updating. I moved the Arduino USB connector, and added a switch for turning off the power line to the C64, so the Arduino can be programmed with the cover on using the normal USB-B cable.

However I still wouldn't dare hot-plug the thing, but at least I don't have to pull the cable out of the motherboard every time.

Left: The cartridge button, Right: The programmer port
This setup helped me in repairing the keyboard adapter code a bit faster. The keymap corresponds better with my "Deltaco" PS/2 mini keyboard, and it's less prone to freezing. It works fine with many kinds of applications.

I also tried to use one of the alternative keymaps to route the arrow keys to correspond with the joystick 1 directions. You know, if you turn the stick in C64 BASIC you get 1,2, <-, space ... This would be nice as then I could keep a joystick only in port 2 and play those rare 1-port games with the keyboard. And the approach does work, for example, in my copy of Cosmic Causeway and Falcon Patrol 2 the adapter gives excellent control.

But in Boulder Dash and IK+, the approach did not work. This is likely because although the joystick port reading has been (unofficially) mapped to various addresses, the keyboard does not come in with the deal. If the game uses those other addresses, it won't work. Well, a nice idea anyway.


Front Panel Cartridge button

I added a cartridge function button to the front panel. The downside of this boxed model is the cart buttons tend to be too far to operate, so this became a necessity.

The contact wires are pulled back below the motherboard, to the vicinity of the cartridge port, from where they are connected to the cart. This requires a small wiring mod to the cartridge too. The IRQHack64 cartridge has a programmer port with GND, but the other pin needed to be brought out with a separate wire.

Crudeness at the backside. The pins connect the cartridge wires brought from under the motherboard.
As an aside, I transferred a fair amount of one-file game prgs to the IRQHack, and more than 80% of them run. This gives me a more positive impression of this cart than my unlucky first experiences indicated. Even in the cases where the game doesn't run, more often than not I can find an image that works.

I'd like to bring the IRQHack SD-card reader to the front, and possibly change it to normal size SD, but this would be a huge commitment to that cartridge, and extending all sorts of cables might not be such a good idea. Updating the IRQHack menu could be on the schedule too, but that requires some more effort.


In hindsight

All in all, I'm starting to see certain weaknesses in this box layout. Mostly the problems could be overcome with the above additions. It could have been smarter to make the additions to a proper breadbox model, like others have done, but this project apparently isn't entirely about smartness.

At least Chessmaster 2100 can be played with the keyboard...
I now have the more finished product C-keys adapter, but whether I will use it in this project or not, remains to be seen. Having the Arduino here gives more freedom and flexibility, but likely the finished adapter simply works better.

The needed changes point towards a further iteration of the box. I might have been on the right track when I thought about more unconventional board positioning, the cartridge at rear isn't exactly the best place for it now.

Again, more pre-planning might have helped in this matter. For example, a pre-emptive "network" of wires and connectors somewhere below the board could have been useful too, as now each new function needs improvised wiring and holes within the box.

Part I

Part II

Part III

Sunday, 18 November 2018

More Scifi bestsellers

Again, a mixture of science fiction books I've read recently.

Frederik Pohl: Gateway (1977)

I played the Gateway computer game way back, but had never read the book until now. Which was a mistake, as the book is rather good.

Humanity has spread to the solar system and discovered the ancient Heechee artefacts, a vast number of starships that travel faster than light. But as the Heechee are not around, nothing is understood about the ships. The destinations are random and guesswork at best. Journeys may take long enough to cause death by starvation, and some launches never return for other reasons.

Which is indeed like a synopsis for a game
High prices are paid to "prospectors", people willing to take up this cosmic lottery, as some of the destinations are huge payoffs, as are any discoveries about how the ships work. A nice outline for a game, indeed!

Pohl describes a kind of ridiculous market ecosystem that has arisen from this exploitation, vaguely reminiscent of the satire in The Merchants of Space. The book cleverly interweaves the cosmic dimension with the protagonists' retrospective reflection in the hands of an artificial psychiatrist.


Robert Heinlein: Starship Troopers (1959)

The intro is rather chilling; the heroes' jet-packed exoskeleton mobile infantry platoon terrorizes an alien city with nukes, incinerating anybody that comes across, presumably civilian or not. Mind you, these aliens are not yet the bugs, but a humanoid culture with technology and language of their own. There appears to be no critical reflection on this act.

The alien "bugs" we meet later, are not just stand-ins for "commies", they are explicitly stated to be an example of communism in the extreme.

One of those books that can justifiably be translated to an FPS
Heinlein also puts anti-Marxist and anti-communists sentiments in the mouths of the mentors. Marx's theory of work is stated to be wrong, as an amount of work does not guarantee a valuable outcome. Instead Heinlein seems to support the idea that all worthwhile things have to be earned. To simplify, the value morality here is that nothing that is easy to learn is worthy. Both individual and the society are tempered through hardships. The pinnacle of this seems to be the kind of camaraderie that arises from military training and bonding.

That's all interesting, but the moral tracts begin to sound like an extremist wishlist though, death penalty for "incurables", tempering our appreciation of freedom through war, and strict military discipline as a road towards enlightened citizenship.

Numerous games and film are influenced by Starship Troopers, there's a Starship Troopers OVA, and obviously there is a game-of-the-film too, one I never played.


Larry Niven: Ringworld (1970)

The story really laces mysteries on each other: Firstly, the reader discovers the human race has developed to the point they live centuries, and are able to transport instantaneously anywhere on Earth. Then we discover that an alien race, the Puppeteers, who have not been seen for centuries, have now appeared with news that have long-term repercussions for the whole galaxy. The reputedly cowardly Puppeteers, for one, are going to leave the galaxy altogether. In the midst of this all, a mysterious massive artefact is discovered in a star system somewhat outside the human known space...

Some passages made me think of Elite (the computer game), can't pinpoint exactly why. At least the Wing Commander Kilrathi are supposedly based on the Kzinti. There are also Ringworld PC games, but I've not touched them.

I also felt that He-Man the original animated series is partly inspired by this setting too, and not only because there's a Teela in both. The easygoing mixture of fantasy and sci-fi, flying cycles and swords makes it feel a bit like an adventure in Eternia.


He was a hero. You could tell. You didn't need to see him fighting dragons. You need only see the muscles, the height, the black metal sword.  [...] He was clean shaven. [...] His hair was long and ash blond and not too clean, and the hairline shaped a noble brow. Around his waist was a kind of kirtle, the skin of some animal.

Ok, so that could be nearly any generic barbarian, but I still think I'm on to something.

The universe of the book is very colorful, with near-nonsensical and comical events juxtaposed with hard science lessons. It perhaps takes a physicist to speculate on the impossible and the improbable in a captivating way.


John Christopher: The Tripods (1967-1968)

Here's a nostalgic childhood favorite, oriented more towards younger readers. The trilogy(!) describes an invaded Earth, where whole generations of people are accustomed to submitting themselves to high-rise sized machines in the shape of, well, tripods.

There's a nostalgic TV series of the Book
The tripods perform a "capping" ritual on people on the verge of adulthood, the cap is a technology that stunts the creative growth of the person's mind for life. As a consequence, people have no knowledge of humanity's past, electricity or even steam power. Past artefacts and whole ruined cities exist, but people are not encouraged to be too curious of these.

The story initially works as an allegory for the fear of growing up (well, it's also explicitly about it). The aliens could again be seen as us, as they behave unto as as we do unto "lesser" beings.

There's an interesting but flawed ZX Spectrum Game of the TV series of the Book
The story hasn't aged too badly, but the position of girls in this boyish adventure, and in the depicted world, is somewhat weird. I could suppose the aliens wanted to enforce gender roles for some reason or other, but why would they subscribe to a human idea of the "fairer sex"?

The broader political message might be about the weight of our freedoms. It appears to the reader the capping affects humanity quite little, whereas it also rids people of wars and perhaps pollution too, given the medieval lifestyle. Most people are not directly subjected to heavy slavery and appear to be able to play a range of emotions after all. This is a point made in the book, too, as the main character is tempted to live a better position than at home, risking the mission at hand.