Link

Animate “Lord British” Signature

Table of contents

  1. Introduction
  2. Loop Over Steps in Signature
  3. Sub-Routine for Incrementing $80/$81
  4. Draw Signature Pixel at Given Location
  5. Other Routines Used
  6. Signature Data

Lord British animated signature

Introduction

Routine is in $609D and is called from $6050.

The data is in pairs of coordinates at $6257 and null-terminated. The 00 is at $646B so there are 266 coordinates.

We put the initial data point address in $80/$81.

609D    A9 57       LDA #$57
609F    85 80       STA $80
60A1    A9 62       LDA #$62
60A3    85 81       STA $81

Loop Over Steps in Signature

This is the start of our while loop. We read the x-coordinate and break out if when we read a 00 from the data array.

We’ll use an (INDIRECT,X) addressing mode with X always at 00.

The x-coordinate is stored in $6080.

60A5    A2 00       LDX #$00
60A7    A1 80       LDA ($80,X)
60A9    F0 1C       BEQ $60C7
60AB    8D 80 60    STA $6080

We then call a sub-routine to increment $80 including carrying over to $81.

60AE    20 34 62    JSR $6234

We then take 0xBF and subtract the next datum from it to get the y-coordinate. This is stored in $6081.

0xBF is basically height of the signature and the data points represent the y-coordinate from the baseline which is why we substract from it.

60B1    A9 BF       LDA #$BF
60B3    38          SEC
60B4    E1 80       SBC ($80,X)
60B6    8D 81 60    STA $6081

We use our sub-routine to increment the data pointer again.

60B9    20 34 62    JSR $6234

We now call a sub-routine that draws the pixel.

60BC    20 04 62    JSR $6204

Then we pause for a little bit (a time interval of 0x40) while checking for any keypress.

60BF    A9 40       LDA #$40
60C1    20 46 62    JSR $6246

Then we jump back to the start of the loop.

60C4    4C A5 60    JMP $60A5

We branch here when done, and return.

60C7    60          RTS

Sub-Routine for Incrementing $80/$81

Increments $80 and if it’s wrapped back to 00, increment $81 as well.

6234    E6 80       INC $80
6236    D0 02       BNE $623A

6238    E6 81       INC $81

623A    60          RTS

Draw Signature Pixel at Given Location

The x-coordinate is in $6080 and the y-coordinate in $6081.

We actually draw two pixels for every data point.

The way this is achieved is to temporarily increment the x-coordinate, draw the pixel, decrement back to the original amount and continue running the drawing code a second time.

6204    EE 80 60    INC $6080
6207    20 0D 62    JSR $620D
620A    CE 80 60    DEC $6080

Here is the individual (not double) pixel drawing code…

We load get y-coordinate and put it in the Y-index.

620D    AD 81 60    LDA $6081
6210    A8          TAY

We take the low bit of the y-coordinate (i.e. whether it’s odd or even) and store it as the high bit of temporary memory location $6233. In other words, if the y-coordinate is even, store 0x00, if the y-coordinate is odd, store 0x80.

This is achieved as follows (the accumulator still has the y-coordinate)

  • shift the accumulator right, putting the low bit in the carry flag
  • zero out the accumulator
  • rotate the accumulator bits so the carry flag becomes the high bit
6211    4A          LSR A           ;
6212    A9 00       LDA #$00        ;
6214    6A          ROR A           ;
6215    8D 33 62    STA $6233       ;

Now using the tables in TBLS loaded in at $E000, look up the base address for the y-coordinate and put it in $84/$85.

The LSB of the base address is in the table $E000[y-coordinate] and the MSB of the base address is in the table $E0C0[y-coordinate].

6218    B9 00 E0    LDA $E000,Y
621B    85 84       STA $84
621D    B9 C0 E0    LDA $E0C0,Y
6220    85 85       STA $85

$E180[x] tells us what to add to the base address to get the address containing the pixel.

$E29F[x] tells us the bit in that byte to set.

$6233 is OR’d in as well to set the high bit if the y-coordinate is odd.

6222    AE 80 60    LDX $6080
6225    BD 9F E2    LDA $E29F,X
6228    BC 80 E1    LDY $E180,X
622B    11 84       ORA ($84),Y
622D    0D 33 62    ORA $6233
6230    91 84       STA ($84),Y

6232    60          RTS

6233    55

Other Routines Used

  • $6246 — Wait For Specified Amount Unless There’s Been A Keypress

Signature Data

6257                                     54 BD 55 BC 57
625C    BC 59 BC 5B BC 5C BD 5C BE 5B BF 59 BF 58 BE 58
626C    BD 57 BB 56 BA 56 B9 55 B8 55 B7 54 B6 54 B5 53
627C    B4 53 B3 52 B2 52 B1 51 B0 4F B0 4E B0 4D B1 4D
628C    B2 4E B3 50 B3 51 B2 54 B2 55 B1 56 B1 57 B0 59
629C    B0 5B B0 5D B0 5F B0 61 B0 63 B0 65 B0 67 B0 69
62AC    B0 6B B0 6D B0 6F B0 71 B0 73 B0 75 B0 77 B0 79
62BC    B0 7B B0 7D B0 7F B0 81 B0 83 B0 85 B0 87 B0 89
62CC    B0 8B B0 8D B0 8F B0 91 B0 93 B0 95 B0 97 B0 99
62DC    B0 9B B0 9D B0 9F B0 A1 B0 A3 B0 A5 B0 A7 B0 A9
62EC    B0 AB B0 AD B0 AF B0 B1 B0 B3 B0 B5 B0 B7 B0 B9
62FC    B0 BB B0 BD B0 BF B0 C1 B0 C3 B0 C5 B0 C7 B0 C9
630C    B0 CA B0 CB B1 CC B1 CD B2 5E B8 5E B7 5D B6 5D
631C    B5 5C B4 5C B3 5D B2 5F B2 60 B2 61 B3 61 B4 62
632C    B5 62 B6 63 B7 63 B8 62 B9 60 B9 5F B9 69 B9 6A
633C    B8 6A B7 69 B6 69 B5 68 B4 68 B3 67 B2 6B B8 6C
634C    B9 6E B9 77 B9 75 B9 74 B9 73 B8 73 B7 72 B6 72
635C    B5 71 B4 71 B3 72 B2 74 B2 75 B3 76 B4 77 B5 77
636C    B6 78 B7 78 B8 79 B9 79 BA 7A BB 7A BC 7B BD 7B
637C    BE 76 B3 77 B2 8B BE 8B BD 8A BC 8A BB 89 BA 89
638C    B9 88 B8 88 B7 87 B6 87 B5 86 B4 86 B3 85 B2 8C
639C    BF 8E BF 8F BF 90 BE 90 BD 8F BC 8F BB 8E BA 8E
63AC    B9 8C B9 8F B8 8F B7 8E B6 8E B5 8D B4 8D B3 8C
63BC    B2 8A B2 88 B2 87 B3 96 B9 97 B8 97 B7 96 B6 96
63CC    B5 95 B4 95 B3 94 B2 98 B8 99 B9 9B B9 A1 B9 A0
63DC    B8 A0 B7 9F B6 9F B5 9E B4 9E B3 9D B2 A2 BC A2
63EC    BB A9 BC A9 BB A8 BA A8 B9 A7 B8 A7 B7 A6 B6 A6
63FC    B5 A5 B4 A5 B3 A6 B2 A8 B2 A9 B2 AA B3 A5 B9 A6
640C    B9 AA B9 B2 B9 B1 B8 B1 B7 B0 B6 B0 B5 AF B4 AF
641C    B3 AE B2 B3 BC B3 BB BB B8 BA B9 B8 B9 B7 B9 B6
642C    B8 B6 B7 B7 B6 B8 B5 B9 B4 B9 B3 B8 B2 B6 B2 B5
643C    B2 B4 B3 C5 BE C5 BD C4 BC C4 BB C3 BA C3 B9 C2
644C    B8 C2 B7 C1 B6 C1 B5 C0 B4 C0 B3 BF B2 C5 B9 C6
645C    B9 C7 B8 C7 B7 C6 B6 C6 B5 C5 B4 C5 B3 C6 B2 00