With time rapidly running out for this challenge I’m hoping to at least get a simple animation working on the Electron. Once I had written my first simple test code I discovered that the “calcscrloc” code had a couple of bugs.

Below is the debugged Calculate Screen Location Routine:

.calcscrloc

NOP ; CALCULATE MEMORY LOCATION

NOP ; STORE IN &70,&71

NOP ; A 0/1 FOR EVEN/ODD

TYA ; READY TO PROCESS

LSR A ; DIVIDE BY 2

LSR A ; DIVIDE BY 2 (4)

LSR A ; DIVIDE BY 2 (8)

STA &70 ; USE AS TEMP STORE

ASL A ; MULT BY 2

ASL A ; MULT BY 2 (4)

CLC

ADC &70 ; ADD ORIG VALUE (X5)

CLC

ROR A ; SHIFT RIGHT BIT 0 IN C

STA &71

LDA #0

ROR A ; SHIFT C INTO BIT 7

STA &70

TYA ; ORIGINAL Y COORD

AND #7 ; BITS 0-2

ORA &70 ; ADD 0 TO 7

STA &70 ; STORE

LDA &71

CLC

ADC #&30 ; ADD SCREEN BASE

STA &71 ; STORE

TXA ; READY TO MULT BY 4

AND #&C0 ; TOP 2 BITS

LSR A ; MOVE RIGHT

LSR A ; MOVE RIGHT

LSR A ; MOVE RIGHT

LSR A ; MOVE RIGHT

LSR A ; MOVE RIGHT

LSR A ; BITS ARE NOW 0-1

CLC

ADC &71 ; ADD TO MS BYTE

STA &71

TXA ; READY TO CONT MULT BY 4

AND #&3E ; BITS 1-5

ASL A ; MULT BY 2

ASL A ; MULT BY 2 (4)

CLC

ADC &70 ; ADD TO LS BYTE

STA &70

LDA #0

ADC &71 ; ADD CARRY TO MS BYTE

STA &71

TXA ; NEED ODD / EVEN

AND #&01 ; WE JUST NEED BIT 0

RTS

.incscrrow

NOP ; INCREMENT SCREEN MEM ROW

PHA ; PRESERVE A

TXA ; TRANSFER TO PRESERVE

PHA ; PRESERVE X

TYA ; TRANSFER TO PRESERVE

PHA ; PRESERVE Y

INC &70

LDA &70

AND #&7 ; USE BITS 0-2

BEQ incscrrow_1

.incscrrow_2

PLA ; POP (Y)

TAY

PLA ; POP (X)

TAX

PLA ; POP A

RTS

.incscrrow_1

DEC &70 ; DECREMENT BACK

LDA &70

AND #&F8 ; MASK OUT BITS 0-2

CLC

ADC #&80 ; ADD THE LS OF &280

STA &70

LDA #0

ADC #&2 ; ADD THE MS OF &280

CLC

ADC &71 ; ADD EXISTING MS BYTE

STA &71

JMP incscrrow_2

So I now have the following BASIC code creating a very simple animation moving the ball down the screen:

OLDX%=-1

OLDY%=-1

FOR A%=0 TO 251 STEP 2

IF OLDX% <> -1 THEN X%=OLDX%:Y%=OLDY%:CALL removeball

X%=79

Y%=A%

Z=USR(displayball)

OLDX%=X%

OLDY%=Y%

NEXT

It is however very flickery and so I may need to see if doing the remove within the assembly is going to be faster than doing it in BASIC.