Tuesday, 14 February 2017

Fort Django v1.1



I made a small update to my Commodore 64 game Fort Django. The most important changes are:

-A choice of a whole new map with new background graphics
-New enemy behavior (in the new map)
-Music and Sound FX and a choice between them

The old game mode (map1) should play almost identically as before.

Use joystick in port 2. Turn up and down in the title screen to select the map. Turn left and right to switch between sound fx and music. Fire starts the game.

As before, you shoot enemies and try to find the exit. Collecting bags gives extra bonus depending on how quickly you have moved from the last bag. (The bonus keeps decreasing from $900)


Internally, I changed a few things to make the new map fit. The memory use was extremely lazy in the old version. Many c variables and arrays are now changed to direct memory read/writes. I relocated these higher up, so the compiled code and data area have more room to breath.

I added a scanline interrupt for the music routine, which plays out the in-game music I created with Goattracker 2, using subtunes for different program sections. The main game tune can be turned off. The sound effects make use of the Goattracker sound fx routines which are simple but suitable for this type of game. If the music is off, there are more sounds, but one channel is always reserved for sound fx. I'd say overall the sounds are better than the old ones, even though I sort of miss the sharp gunshot sound. The tunes try hard to sound something between Rambo/Platoon but a Galway or Dunn I ain't.

The sprite updates are more rigorously done during the vblank so I have more time during the frame for doing other calculations, should they be needed. However the game pretty much runs during the vblank anyway.


The new map takes the player to a vaguely central american temple, giving the game some more of that Pitfall/Rick Dangerous vibe. The new map has a bit different play style too. The rooms are more open and there's more opportunities for platform game elements.

There's new enemy behavior in this new map. For example, the enemies only shoot when facing the player. The enemies can also crouch like the player, so the player can't use always the same trick when entering the screen. Some of the enemy behavior and timing is adjusted on a room-by-room basis, so the rooms can contain a small pre-defined "action puzzle".

Internally, the two enemies are switched occasionally. Inside the program logic only one of them does the shooting and crouching. But the switching gives an impression of both having the same freedom. This is not especially elegant but given how the two enemies have been programmed it's a nice fix.

The splash screen and ending have been adjusted, but I felt a weird respect toward the old map and did not alter the graphics there at all.

It was nice to revisit the program, but in the future, I'd probably prefer making something new than try to continue adding to Fort Django.

About the first version

Fort Django v1.1 at CSDb

Sunday, 18 December 2016

A few Commodore 64 images

Here's some Commodore 64 visuals I've been working on recently.

Boabots:


The two snake heads were laid out long time ago, but the detailing and background was done recently. The overall composition was in flux as I kept changing the position of the heads, adding the third blurred head relatively late in the process.

Never thought I'd say this but I feel c64 hires is easier than multicolor. Obviously, the resolution is higher, but importantly, the color choices are always local. With multicolor, you have to decide the overall background color at some point and that choice often has tricky consequences.

Page at CSDb


Lawless of the West:


Another hires. This is an obvious tribute to the Commodore 64 game Law of the West, but it also derives a little from Edvard Munch's Evening on Karl Johan, though not very consciously. Other references: Italian westerns and a bit of McCabe & Mrs. Miller too. The grouping of characters also reminds me of the Italian comic Gli Aristocratici.

I have wanted to use a vanishing point perspective in a C64 pic for some time, and it is quite challenging to both have a sense of space and human characters in the same pic. Even here the people are sort of pasted on front of the background.

Page at CSDb


Hokuto Force logo:


This is a PETSCII character art I made for the group Hokute Force for an Commodore 64 intro coded by Flavioweb. I went for a "metal band style" with some ninja-fic touches.

I'm quite happy how it turned out. Again, character art shows it's force: If this had been a multicolor bitmap, I might not have come up with the idea or been able to follow it through.

In hindsight as I look at the space between the F and the O, the gap should have been maybe a bit narrower... Oh, well.

The way the logo is presented in the intro is a bit different, the above is a compromise between the intended logo and how it works in the intro.

Page at CSDb

Saturday, 3 December 2016

6502 notes

I've been dabbling in 6502 machine code for a long time, but only recently started to get a hold of it. My initial touchpoint was the machine code monitor on the Action Replay VI module on the C64 and a battered copy of the Commodore 64 Programmer's Reference I found from a flea market in early 1990s.

Which I obviously still have.
These days, I know a bit more, but certain things are a bit difficult to remember. Here's some.


How the Carry (C) affects the ADC and SBC instructions (and the difference)

For the longest time I did not get this. For additions, carry is cleared (with CLC) and then becomes set if the addition crosses the 255 boundary. The C flag is then carried (duh) over to the next ADC instruction as a +1. With subtraction, it's the reverse: the carry is previously set and then becomes cleared if the subtraction crosses 0. When clear, the SBC #$00 performs a SBC #$01, for example. After this, 16-bit addition and subtraction became easier to understand.

;Incrementing a 16-bit value at $C000-$C001 with ADC

    CLC          ;Clear Carry
    LDA $C000
    ADC #$01     ;if $FF is crossed Carry becomes set
    STA $C000
    LDA $C001
    ADC #$00     ;is like 1 if Carry is set
    STA $C001

;Decrementing a 16-bit value at $C000-$C001 with SBC

    SEC          ;Set Carry
    LDA $C000
    SBC #$01     ;if $FF is crossed Carry becomes clear
    STA $C000
    LDA $C001
    SBC #$00     ;is like 1 if Carry is clear
    STA $C001


When is the Overflow (V) flag set?

This flag is not that useful to me, but I don't want to forget what it does.

As two bytes are added together with ADC, as above, the calculation is at the same time evaluated as unsigned and "signed". If the numbers as "signed" cross a boundary of (-127...128) the overflow will be set.

I've come across a misconception that says "if the 7th bit of the original value and the resulting calculation are different, then the overflow is set."

However, the following will not trigger the overflow flag, even though the 7th bit clearly changes:

    CLC
    LDA #$FF     ; 0b11111111 (-1) is the original value
    ADC #$02     ; 0b00000010
                 ; 0b00000001 (+1) is the result

I won't go around doing the two's complement explanation, which frankly just makes it more difficult to understand for me. Let's just have a look at how the signed numbers work:

Positive values:

00000000 = 0
00000001 = 1
00000010 = 2
00000011 = 3
00000100 = 4
...
00001000 = 8
...
00010000 = 16
...
00100000 = 32
...
01000000 = 64
...
01111111 = 127

The negative numbers have their minus sign bit set:

11111111 = -1
11111110 = -2
11111101 = -3
11111100 = -4
11111011 = -5
...
11110111 = -9
...
11101111 = -17
...
11011111 = -33
...
10111111 = -65
...
10000000 = -128

There's no special "signed mode" for the ADC command. Simply, if within the above representation, you do a calculation that crosses over 127, or under -128, the V flag will be set. Just like the C will be used when crossing over 0...255 in the ordinary representation.

So what the above example does is -1+2, which does not cross this boundary any more than 1+2 would set the C flag.

The reformulated rule: "If values with a similar 7th bit are added together, and the 7th bit changes, the V flag is set."

For the most part I don't see the point of the signed-system, as I can usually pretend that 128 or 32768 is the zero point in an unsigned calculation.

Here, have a picture of a silly robot that makes it all easier to understand.

How the Indexed Indirect and Indirect Indexed addressing modes work

Most of these things have no place in fast code, hence I had not really looked at them.

Perhaps the funniest personal discovery was to see that it's possible to point to a 16-bit address using the indirect indexed addressing mode. I did not know the 6502 was capable of doing this so directly (relatively speaking). It's bit like z80's ld (de),a but not really. Because there is no 16-bit register as such, incrementing the address is a matter of using the ADC on the stored value as described in the first topic above.

Usually a memory fill is done effectively with something like this, which would fill the C64 default screen area with a "space".

    LDA #$20
    LDX #$FF
loop:
    STA $0400,X
    STA $0500,X
    STA $0600,X
    STA $0700,X
    DEX
    BNE loop
    RTS

We can write the start address to a location in a zero page and use the indexed indirect mode to write to the address, at the same time incrementing the stored value with a 16-bit addition.

Some have suggested that the zero-page works as a bunch of additional "registers" for the 6502 and this seems to validate that idea slightly.

(It is extremely slow, though)

    LDA #$04    ;high byte of start address $0400
    STA $11     ;store at zero page
    LDA #$00    ;low byte of start address $0400
    STA $10     ;store at zero page
    LDY #$00    ;we won't change the Y in the following
loop:
    LDA #$20    ;fill with ASCII space       
    STA ($10),Y ;write to address stored at zp $10-$11
    CLC         ;clear Carry
    LDA #$01    ;low byte of 16-bit addition
    ADC $10     ;add to low byte

    STA $10
    LDA #$00    ;high byte of 16-bit addition
    ADC $11     ;add to high byte (+Carry)
    STA $11
    CMP #$08    ;are we at $08xx?
    BEQ exit
    JMP loop
exit: 
    RTS



When to use BPL, BMI, BCS, BCC branching operations

Some of my earliest code tended to work with BEQ and BNE only. Quite a lot can be achieved with them. The classic loop already used above, works without comparison instructions at all. Besides this, it can make a big speed difference how the '0' is used in data/tables.

    LDX #$0B
loop:
    INC $d020
    DEX
    BNE loop

My first instinct has been to use the BPL and BMI opcodes as they sounded nice and simple: Branch on PLus and Branch on MInus.

However, the BPL/BMI work with the signed interpretation discussed above. Parts of code might work as intended if the numbers happened to be in the +0...127 boundary, which probably confused me in the past.

So the BCC (Branch if Carry Clear) and BCS (Branch if Carry Set) are used instead when dealing with unsigned number comparisons, even if they sound less friendly.

    LDA #$20
    CMP #$21
;C=0

    LDA #$20
    CMP #$20
;C=1

    LDA #$20
    CMP #$1F
;C=1

This ought to branch if the A value is lesser than the one it is compared to:

    LDA #$1F   ; $00-$1F will result in C=0
    CMP #$20
    BCC branch ; (branches in this case)

The next one branches if the A value is equal or greater than the one it is compared to:

    LDA #$20   ; $20-$FF will result in C=1
    CMP #$20
    BCS branch ; (branches in this case)

So, yeah.

Strangely enough many of the webpages and even books about 6502 are incomplete when it comes to explaining in detail what each of the commands do. Even the books might just state that a particular opcode "affects" a certain flag, but may not open up how exactly that flag is affected.

Friday, 18 November 2016

Saboteur! remake

How it all began...
I've always been a bit of a fan of this atmospheric ninja/industrial espionage game released in the 1980s on ZX Spectrum, Commodore 64 and various other platforms. Now I'm looking at the recent (2015) version of Saboteur! at clivetownsend.com, from none other than... Clive Townsend, the original author.

Based on Unity/WebGL, it runs happily on a modern browser.  Before I say anything, I'd urge anyone who finds the game working on their computer to simply go and pay the small fee for the full game. Especially all those naughty people who played the original Saboteur games for free back in the day :)

With remakes of old games, I often feel that any changes to the original seem "wrong". Nothing like that here. The original central gameplay is intact. There are simply visual and especially aural improvements that make the experience of revisiting Saboteur more interesting. The game has also been expanded greatly, which I'll discuss below.

There are various options that need some attention before playing seriously. You'll have to sign in to get the full game, but as a bonus you get to save your highscores, achievements and other progress to your online account. As for the options, the game was initially set as "fast", but I found the "normal" speed most satisfying at least for now. The QAOP keyboard controls are satisfactory. The ninja moves with arrow keys too but the QAOP gives a crisper response at least on my computer.

As the game replicates the original, the controls have not been updated in any way. Especially the jumping sections may put off people who are used to a bit more fluid, console-type games.

The menu graphics are all new, high resolution, but the game graphics are Spectrum-like, and boldly so. You can also select C64 colours if they are more to your taste. I wouldn't have blamed the author for changing the graphical style altogether, but it's good to have the ZX Spectrum style pixeling here.

Guess which mode?
Well, there are in fact more graphics modes than the ZX/C64, but they have to be found in-game and they only work in the original warehouse area. Making them work was not 100% obvious, so here goes: After you've found the different "VR goggles" in the expanded game, start a new game from the beginning, then press ESC to get to the expanded graphic mode options.

However, even the ZX and C64 modes are not identical to the originals: there are tiny updates and added detail here and there. The new grenade explosion is pretty mighty.


The New Story

Like many players, I didn't know that blowing up the bomb was not enough to truly complete the mission. The disk has to be retrieved, too. Then it gets interesting. After you think you've completed the mission, there's more to do but I won't say anything about it here in case someone is a newcomer.

...Well, ok. I have to say something. What unfolds is a completely new Saboteur adventure, which is more modern, storyboarded kind of game. There's more to read, for instance, as the ninja communicates with the radio dispatcher, Metal Gear style. The style stays true to the 8-bit limitations, it's just as if the Speccy had a huge amount of memory. Even if I suspect some scenes would not run on a standard Spectrum the effects never go overboard.

We're not in Ninja Kansas anymore
The new area deviates a bit from the "one item held" logic of the original, as you can now possess keys and other quest items. Also, the map is no longer strictly two-dimensional as you can enter from front and back of the screen to different sections of the map. There are quest-oriented sections and then time-based map areas that are more reminiscent of the original Saboteur game. There are also jumping areas that make me pull my hair out in frustration, like I was ten years old playing Jet Set Willy. Maybe I can blame the keyboard here!

There's now more to do, new enemy types and behavior, more switches, keys and moving mechanisms to set and reset. There's also a lot of detail and humor, such as winks and nods to 1980s pop culture, ninja schlock and earlier computer culture. What I appreciate is that all the references are from the period, no internet memes in sight! No doubt we'll get to learn some more about the Saboteur world and how the first game ties to the sequel, the Avenging Angel.

Maybe, just maybe, I would have preferred a bit more compartmentalized play experience, such as new missions instead of this longer quest. Yet, altogether the new sections are well organized and as you get further you're bound to be obsessed with seeing it all through. Obviously the new material in no way detracts from the original game, which is intact. As with the original, the difficulty levels alter the game experience and the map a bit, and I'm looking forward trying to complete the harder modes. If a true Saboteur III appears, this all certainly seems very promising for it!

The game is quite a perfect treat to those who liked the original, and I think those who grew with 8-bit games should find it interesting. More changes might have been needed to win over more new fans, but then again too many changes might have lost that Saboteur charm.

Saboteur at Clivetownsend.com



Tuesday, 1 November 2016

Jean-Michel Jarre at Helsinki

The doors open...

I always thought that the "computer crowd" in the 1980s perhaps listened proportionally more Jarre, Kraftwerk, Tangerine Dream and Vangelis than the general population. At least in Europe. Well, who knows.

I felt a few words about the Jarre concert yesterday was in order. It was a good, entertaining show. I've never seen Jarre live, so I only knew about the massive concerts in a roundabout way, through TV shows and all.

These circular projections had a laser-like intensity.
This small scale fit Jarre well. The tracks had been transformed into faster, shorter, more trance-like versions, while the visuals were an unrelenting barrage of old-fashioned wireframe vector graphics, geometric shapes, point clouds and realtime video feeds. Jarre played a touchscreen app, a guitar and of course the laser harp, so he was not exactly sitting still behind his gear either. The recent Electronica-collaborations appear to have been helpful for renewing the setlist.

Equinoxe album art was also used for humorous effect.
The stage had been arranged into layers of semi-transparent mobile grids to which the graphics were projected. Some of the sheets were behind the stage and some on the front and sides. This, on occasions, gave a surprisingly three-dimensional feel to the stage. It worked especially well when there was a central object to look at and a cluster of moving tiny objects. (Scene demos, anyone?)

I found it, for this time at least, more interesting than Kraftwerk's recent turn to 3D material, but I can also understand the German quartet would not want their clear-cut images to be split into smithereens.

Guess what? A new Oxygène
On occasions, I felt that some old tracks that on album had good structure and progression had been reduced to almost medley-like appearances in-between altered material. This then led me to think why some tracks were not used, as they could have worked better in new form. For example, Magnetic Fields II (old track) or Téo and Téa (a more recent track) might have fit in this show almost unaltered, yet they were not played at all.

I'm also glad that although Jarre's music has benefited from the back-and-forth influence with the recent electronic music styles, the songs were not altered to the Guetta/Skrillex EDM-dubstep mould.

Sorry about the bit poor photos. I did not even think I'd get the urge to take my camera out so often.

The famous Laser Harp


Saturday, 29 October 2016

Johnny Mnemonic and your dad's cyberpunk

Only recently I got to see Johnny Mnemonic (1995), based on the William Gibson short story. Given the bad reputation I found it to be surprisingly nice little film. Surely the acting and directing is not that great, but there's lot of cyber-cheese, inventive sets and visuals. These 1 and 30 minutes pack quite a punch. Thanks to Marq "the Finn" for delivering the goods.

We get to see what Internet is like in 2021:


A lot of man-machine interaction:


Why is the AI always an ethereal female?


Jacking into Cyberspace:


What it amounts to is a glorified Excel? Minority Report, eat your heart out:


Of course, the entities met in Cyberspace are distorted, disembodied heads and generally incomprehensible visuals:


In any Cyberpunk setting, The Rich live classy:


While the poor are left to collect scraps:


Big corporations piss on your humanity. Perhaps a shock to the system is in order:


And that's not nearly all! I wouldn't even think of spoiling some of the best stuff. All in all it's a pretty good visualization of Gibson's universe. It's hardly Blade Runner-quality but an enjoyable treat and possibly the most pure filmatisation of what Cyberpunk meant back in the day.


Sunday, 23 October 2016

New Spectrum, New C64?

Recently, there have been some rumors about new models of ZX Spectrum and Commodore 64. Whereas we've lately seen the ZX Spectrum Recreated and the Spectrum Vega /plus game console, the Next promises to be something more like a real computer, like the ZX Evolution. Following the blueprints of C64 Reloaded, Individual Computers seeks to produce both new cases and new stock of the Reloaded. There's also a funding campaign for something called THE 64, which sounds a bit too ambitious to be honest.

Although the new computers would be compatible with their respective originals, they are not exact replicas. And why would they be, really? The world deserves a better C64 and a better Spectrum. Such a project would also open up the possibility for further "cloning" with contemporary means, ensuring the platforms live on.

Anyway, all this made me think, what would I like to see from such a project?

Overall, the new computers could be more flexible for building different types of cases and input/output solutions. The 1980s home computers were notoriously closed products. Many connectors could be made as header pins, and the responsibility for building the less often used connectors would be up to the owner or third parties.

There are two schools of thought about the video output. Others would like a current (hdmi) video output for modern displays, whereas others see old-fashioned monitors and TVs as a must. One possibility is to have modular video output, you'd only get what you need. However it can be a bit of a space-waster really. ZXEvo has it pretty good, a VGA output and then header pins for RGB.

Given this overall idea, below are my wishlists. These are simply fantasy as I can't really plan this type of stuff.

The Fantasy models:




  • Circuitboard footprint that fits in at least some Spectrum model case (preferably the toastrack 128, but maybe +2/+3)
  • A new z80 processor 3,5mHz/7mHz/14mHz
  • 48K-64K base RAM, Memory expansions through the 128K memory model or more as in Russian machines (Evolution).
  • FPGA ULA video generation. Preferably pins for RGB and composite, but also modern hdmi.
  • FPGA YM audio generation. Also a socket for real YM
  • Alterable timing schemes: Russian Pentagon, British Spectrum, something new? (Not sure how to achieve this)
  • SD card reader. I would maybe leave out the floppy controller.
  • First 16K as re-writable/replaceable ROM, or as RAM with write protect.
  • Reasonably compatible zxbus/edge connector pinout
  • Keyboard input pins compatible with the original spectrum, but also USB or at least PS/2
  • Audio jack/pins
  • Joystick pins (sinclair/kempston)
  • Kempston mouse compatible mouse port, maybe USB or at least PS/2

So, quite similar to ZX Evolution really. The major difference is trying to make it fit in smaller space and leave out certain things. I'm not too keen on new display modes, but why not.

If there has to be a new case, borrow ideas from 128K Spectrum or Sinclair QL, but a bit flatter if possible. The QL keys looked cool but I guess they have to go. The Next renders look good but in my opinion round shapes never quite belonged with the Spectrum... What I'm looking at is a keyboard-less case, that could be altered to integrate a keyboard.

then...




  • Original footprint circuit board, preferably short board
  • A new 6502 processor? Does such a thing exist?
  • 64K memory, expansions via the REU standard. Also REU on board, what's the maximum, 16MB?
  • Standard serial port (real 1541, SD2IEC)
  • SD card reader
  • Cartrdige expansion as 100% cartridge-compatible as possible.
  • FPGA SID. Audio generation via SID emulation, also a socket for real SID 8580/6581 or Swinsid
  • FPGA VIC-II. Video generation, preferably both composite/RGB and modern hdmi
  • Joystick ports/pins
  • Commodore mouse compatible mouse port, maybe USB or at least PS/2
  • Keyboard input pins compatible with the original C64, but also USB or at least PS/2
  • Audio jack

The C64 is a tricky thing. With Spectrum, the specs are simple and there's also some precedent for ignoring them. Consider the Russian scene for example, who have very nearly redefined what a ZX Spectrum is. But with Commodore 64, fans would not be satisfied with anything less than a timing-exact, perfect, real thing.

If there's a new case, it would be C64C-style, and forget the original brown breadbox colors. Yes the breadboard is nostalgic but it's a bit too tall and ugly to be honest. With keyboards it's a different thing. Many functioning originals exist so it would be wise to allow using the genuine item. This pretty much then defines the form of the computer. Proper arrow keys would be welcome, though.