VIC-20-ANIMATIONS-NO-HARDWARE-SPRITES-WE-WILL-USE-CHARACTERS SPEEDING-UP-THE-PROCESS! -------------------------------------------------------------------------------------------------- TOOL: COMMODORE VIC-20 - BASIC 2 Language: BASIC Extra: - Author: Misel Zivanovic Note: (C) 10th JAN 2026 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- PART I The last, theoretical, lesson was fun {to me, haha}. I found this little spot: $02a1 - $02ff 0673 - 0767 0094 bytes And we will use it to speed up the execution of this animation we {or I} made not so long ago. Not much is there to make it a bit faster, except this small loop {setting the 4th color} 400 rem middle cyan 401 for e=0 to 505 402 poke 38400+e,2+8 403 next ...and below, PART II is the font copy code {ROM to RAM} So that will be our tasks for today. We are dealing here with 506 bytes and that is very practical. If we divide it, we get clear 253 bytes {#$fd} To have this quickly done, we have one loop and two start addresses! 1st one is $9600 and the 2nd $96fd. The accumulator will be charged with 10, hex #$0a. {Cyan and normal {not reverse}} This will do: It looks like this in ML-Monitor: lda #$0a a9 0a lda #$0a ldx #$00 a2 00 ldx #$00 loop sta $9600,x 9d 00 96 sta $9600,x sta $96fd,x 9d fd 96 sta $96fd,x inx e8 inx cpx #$fd e0 fd cpx #$fd bne loop d0 f5 bne $0404 rts 60 rts Now we just need to tell to VIC to cooperate... And it is done! I won't complain at all. This small code change made the whole thing close to 5 seconds faster! Before close to 13 seconds, now it needs precisely 8 seconds. Mission successfully accomplished! PART II --------------------------------------------------------------------------------------------------- Are we happy? Yes we are... but... What about this? Is this the under the 5 seconds task, or maybe even under three seconds? Well, try it and see it! Close to 80 bytes are still available. More than enough for this task! 107 rem char trans 110 t=6144:s=32768 111 for a=0 to 1023 112 poket+a,peek(a+s) 113 next How to proceed here? t = POKE and s=PEEK... We have 4 pages or 1024 bytes. If we go the full range there are 2 possibilities {actually more!} Using the LOW-/HIGH-byte counter or we just simple use the LOW-byte only, 4x! That is the easiest way and faster than BASIC all day long! And we are not counting cycles here anyway! Let's proceed with that solution for now! ldx #$00 a2 00 ldx #$00 loop lda $8000,x bd 00 80 lda $8000,x sta $1800,x 9d 00 18 sta $1800,x lda $80ff,x bd 00 81 lda $8100,x sta $18ff,x 9d 00 19 sta $1900,x lda $81ff,x bd 00 82 lda $8200,x sta $19ff,x 9d 00 1a sta $1a00,x lda $82ff,x bd 00 83 lda $8300,x sta $1aff,x 9d 00 1b sta $1b00,x inx e8 inx cpx #$ff e0 ff cpx #$ff bne loop d0 e3 bne $1402 rts 60 rts Amazing! With little to practically no efforts at all, we managed to reduce the execution time from close to 13 seconds, down to approximately 2.5 seconds! That is fantastic! And all we did, was replacing 2 BASIC FOR NEXT LOOPS with assembler FOR NEXT LOOPS! They are easy to handle and understand. FOR NEXT LOOPS are used a lot and are slowing down the whole program! However, not if you replace them with assembler FOR NEXT LOOPS! Now you know how it is done! {And it's the same for VIC, C64 and C128 because they have the same assembler commands} --------------------------------------------------------------------------------------------------- SOURCE CODE - ALL IN ONE - {can be copy/pasted into VICE VIC-20 Emulator} --------------------------------------------------------------------------------------------------- 50 a=643:b=644 51 poke51,0:poke52,24 52 poke55,0:poke56,24 53 poke a,0:poke b,24 54 clr 80 sys 58719 81 print "lived.ch, mzretro.ch" 82 print 83 print "sprite anim" 84 print "-------------" 85 print "press any key" 86 get a$:if a$="" then 86 87 rem 100 sys 58719:rem cls 101 poke 36869,254 102 rem top blue 103 rem also border 104 poke 36879,8+6+(0*16) 105 rem bottom yellow 106 poke 36878,7*16 107 rem ------------ 108 rem 36878 reg mc 109 for a=0 to 16 110 read w 111 poke 673+a,w 112 next 113 data 169,10,162,0,157,0,150,157,253 114 data 150,232,224,253,208,245,96,0 115 rem ------------ 116 rem char trans 117 for a=17 to 17+32 118 read ws 119 poke -17+(692+a),ws 120 next 121 data 162, 0, 189, 0, 128, 157, 0, 24, 189 122 data 0, 129, 157, 0, 25, 189, 0, 130, 157 123 data 0,26, 189, 0, 131, 157, 0, 27, 232 124 data 224, 255, 208, 227, 96, 0 125 sys 692 126 rem ------------ 127 rem anim 1+1 + 1 128 t=6144 129 for c=50 to 50+119 130 read d 131 poke-50+(t+8+(c)),d:next 132 rem 1st pos: 150 rem ab 151 rem cd 152 rem e 153 data 21,95,123,127,243,252,63,48 154 data 64,16,0,192,0,0,0,0 156 data 48,124,123,122,86,251,252,252 157 data 0,4,4,106,168,0,0,0 158 data 52,52,52,186,186,130,170,40 159 rem ------------ 200 rem anim 201 rem fg 202 rem hi 203 rem j 204 data 0,21,95,123,127,243,252,63 205 data 16,64,0,0,192,0,0,0 206 data 48,48,124,123,122,86,251,252 207 data 0,0,4,4,106,168,0,0 208 data 252,52,52,186,186,186,130,40 209 rem ------------ 250 rem shooting: 251 rem kl 252 rem mn 253 rem op 254 data 21,95,123,127,243,244,63,48 255 data 64,64,0,192,0,0,0,0 256 data 48,124,111,105,86,239,252,252 257 data 0,16,16,168,160,0,0,0 258 data 52,52,52,186,186,130,170,40 259 rem ------------ 300 rem cursor 301 poke 7424,0 302 poke 7425,85 303 poke 7426,109 304 poke 7427,56 305 poke 7428,109 306 poke 7429,56 307 poke 7430,109 308 poke 7431,85 309 rem ------------ 401 rem middle cyan 402 sys 673:poke 646,2+8 403 rem anim start 453 sys 58753 454 print 455 print " ab" 456 print " cd" 457 print " e" 458 for a=0 to 250:next 459 sys 58753 460 print 461 print " fg" 462 print " hi" 463 print " j" 464 for a=0 to 250:next 465 sys 58753 466 print 467 print " kl" 468 print " mn" 469 print " o" 470 for a=0 to 125:next 471 goto 453 --------------------------------------------------------------------------------------------------- In case you wonder how all this is being made, just check the screenshot. I am working with C128 emulation, Notepad von Windows and VIC-20 emulation. Mostly i am programming using Notepad von Windows and do just copy/paste the code to VIC-20. It means i am manually adding/modifying line numbers.