Quick Post: Slow text on the Commodore

Quick Post: Slow text on the Commodore

An "almost teenager", Josh, sent me an email yesterday asking how I do slow text on the Commodore. He is just starting assembly at 12 which is pretty impressive. He's been using KickAssembler, but wants to try it "on hardware".

It's not difficult really. There are probably a lot of ways to do this, here's how I do it in Turbo Macro Pro.

Let's start with some text: ARE YOU KEEPING UP?

We'll store it:

mytext     .null "are you keeping up?"

; the null here just appends a 0 at the end so
; we know when to stop - it's the same as:

mytext     .text "are you keeping up?"
           .byte 0
           
           

Now we need to display it. We'll use the kernal routine $ffd2 and loop through the text one character at a time. In a second, this will give us a good place to introduce a delay.

prnt
      ldx #0
loop  lda mytext,x
      beq ahead
      jsr $ffd2
      inx
      jmp loop
ahead

Easy right? When the A register contains a zero it skips ahead and we're done.

Now let's make a subroutine to slow it down.

slow
        .block
        lda #200
        ldy #17
loop    cmp $d012
        bne loop
        dey
        bne loop
        rts
        .bend

There are several ways to do blocks and scoping in KickAssembler, and it uses colons after labels, so if you're copying this to that assembler, the easiest is probably to make the above into (same same):

slow: {
        lda #200
        ldy #17
loop    cmp $d012
        bne loop
        dey
        bne loop
        rts
      }
See, not that different

This is only a little tricky for a beginner. Remember we're using this to waste time to print slowly.

First we load A with 200, which is the raster line we're going to wait for. This will slow things down a fair bit, but loading Y with 17 means we're going to wait for that raster line 17 times before continuing. Feel free to play around with these numbers to speed things up or slow them down.

So now our code will look like this:

prnt
      ldx #0
loop  lda mytext,x
      beq ahead
      jsr $ffd2
      jsr slow
      inx
      jmp loop
ahead

Easy right?

Now you can play around and make effects like this:

Thanks to young Josh for the question and happy coding.