COMAL-80-USING-AUTORUN-LOADING -------------------------------------------------------------------------------------------------- TOOL: COMAL-80-C64 {Version 2.01} Language: COMAL - Structured BASIC Extra: - Author: Misel Zivanovic Note: (C) 22nd March 2026 - www.lived.ch, mzretro.ch Info: We are going to preload sprites and then load and run the main program. No extra interaction from the user's side needed! --------------------------------------------------------------------------------------------------- Now you can save plenty of memory by preloading parts of the code which not necessary must be always present. With COMAL you can use this very efficiently because it has memory area which will remain untouched when you load/run additional source code. Thanks to that, you can preload, like in our examples, sprites into the memory and then load the actually source code to access it. In our example, this is resulting in wonderful code reduction of more than 50%! Which means, you can be more creative! It is easy to achieve this and thanks to AUTORUN of the additional loaded code, user just need to load and run the first part of the code. Needless to say how you can use this to load more additional code. E.g. a complex game which would need more than 30KB memory. Thanks to the untouched areas, you can save all needed game elements and just access them again with the new source code you have loaded into the memory! I have a huge reduction of the BASIC Source Code free memory area. Practically 50% less compared to regular free memory. But imagine now just loading the second part of the game and there you have the standard 30KB free memory available again/combined with text sprites. Here only 8 sprites are used, but with the sprite pointer 245 you could have 10 sprites in that region and 3 in $33c region. And you also have the access to 32 sprites in COMAL-Sprite-Area! That's a total of 45 sprites! --------------------------------------------------------------------------------------------------- NOTE: This code is on the floppy disk too and can be loaded and started with RUN "*" --------------------------------------------------------------------------------------------------- PRELOAD PART! 0010 // basic end address at $3D00 0020 // above that are our sprites! 0025 // pointer start 15680 (245!) 0030 0035 POKE 28,00 // $00 0040 POKE 29,61 // $3D, dec 15616 0050 0060 // by mzretro.ch - lived.ch 0070 // misel zivanovic 0080 // load sprites and start 0090 // of the main program 0100 // using autorun! 0110 0120 PAGE 0130 0140 RESTORE mysprites 0150 FOR a:=0 TO 511 DO 0160 READ spritedata 0170 POKE 15680+a,spritedata 0180 ENDFOR a 0190 0200 autorun // load main program 0210 0220 PROC autorun CLOSED 0230 // ---------------------- 0240 // c64 version of autorun 0250 // ---------------------- 0260 PAGE 0270 USE graphics 0280 USE system 0290 textcolor(6); q5$:=CHR$(34) 0300 i5$:="loading active, wait..." 0310 j5$:="run"; h5$:=CHR$(19) 0320 n5$:="main" 0330 PRINT AT 4,1: j5$;q5$+n5$+q5$+h5$ 0340 POKE 649,3 0350 POKE 631,13 0360 POKE 198,1 0370 CURSOR 1,1 0380 textcolors(14,6,6) 0390 REPORT 1,""155""+i5$(1:23) 0400 ENDPROC autorun 0410 0415 mysprites: 3000 data $00,$00,$00,$00,$00,$00 3005 data $00,$00,$00,$00,$00,$00 3010 data $00,$00,$00,$00,$ff,$00 3015 data $03,$ff,$c0,$07,$e3,$e0 3020 data $07,$c3,$e0,$0f,$83,$f0 3025 data $0f,$f3,$f0,$0f,$f3,$f0 3030 data $0f,$f3,$f0,$0f,$f3,$f0 3035 data $07,$f3,$e0,$07,$f3,$e0 3040 data $03,$ff,$c0,$00,$ff,$00 3045 data $00,$00,$00,$00,$00,$00 3050 data $00,$00,$00,$00,$00,$00 3055 data $00,$00,$00,$00,$00,$00 3060 data $00,$00,$00,$00,$00,$00 3065 data $00,$00,$ff,$00,$03,$ff 3070 data $c0,$07,$c3,$e0,$07,$99 3075 data $e0,$0f,$f9,$f0,$0f,$f9 3080 data $f0,$0f,$f3,$f0,$0f,$e7 3085 data $f0,$0f,$cf,$f0,$07,$9f 3090 data $e0,$07,$81,$e0,$03,$ff 3095 data $c0,$00,$ff,$00,$00,$00 3100 data $00,$00,$00,$00,$00,$00 3105 data $00,$00,$00,$00,$00,$00 3110 data $00,$00,$00,$00,$00,$00 3115 data $00,$00,$00,$00,$00,$00 3120 data $ff,$00,$03,$ff,$c0,$07 3125 data $99,$e0,$07,$99,$e0,$0f 3130 data $99,$f0,$0f,$99,$f0,$0f 3135 data $80,$f0,$0f,$80,$f0,$0f 3140 data $f9,$f0,$07,$f9,$e0,$07 3145 data $f9,$e0,$03,$ff,$c0,$00 3150 data $ff,$00,$00,$00,$00,$00 3155 data $00,$00,$00,$00,$00,$00 3160 data $00,$00,$00,$00,$00,$00 3165 data $00,$00,$00,$00,$00,$00 3170 data $00,$00,$00,$00,$ff,$00 3175 data $03,$ff,$c0,$07,$c3,$e0 3180 data $07,$99,$e0,$0f,$99,$f0 3185 data $0f,$91,$f0,$0f,$c3,$f0 3190 data $0f,$89,$f0,$0f,$99,$f0 3195 data $07,$99,$e0,$07,$c3,$e0 3200 data $03,$ff,$c0,$00,$ff,$00 3205 data $00,$00,$00,$00,$00,$00 3210 data $00,$00,$00,$00,$00,$00 3215 data $00,$00,$00,$00,$00,$00 3220 data $00,$00,$00,$00,$00,$00 3225 data $00,$00,$ff,$00,$03,$ff 3230 data $c0,$07,$98,$e0,$07,$10 3235 data $60,$0e,$13,$f0,$0f,$90 3240 data $f0,$0f,$90,$70,$0f,$92 3245 data $70,$0f,$92,$70,$07,$90 3250 data $60,$07,$98,$e0,$03,$ff 3255 data $c0,$00,$ff,$00,$00,$00 3260 data $00,$00,$00,$00,$00,$00 3265 data $00,$00,$00,$00,$00,$00 3270 data $00,$00,$00,$00,$00,$00 3275 data $00,$00,$00,$00,$00,$00 3280 data $ff,$00,$03,$ff,$c0,$06 3285 data $38,$e0,$04,$92,$60,$0f 3290 data $9e,$70,$0f,$9e,$70,$0f 3295 data $3c,$f0,$0f,$99,$f0,$0f 3300 data $93,$f0,$04,$93,$e0,$06 3305 data $30,$60,$03,$ff,$c0,$00 3310 data $ff,$00,$00,$00,$00,$00 3315 data $00,$00,$00,$00,$00,$00 3320 data $00,$00,$00,$00,$00,$00 3325 data $00,$00,$00,$00,$00,$00 3330 data $00,$00,$00,$00,$ff,$00 3335 data $03,$ff,$c0,$06,$32,$60 3340 data $04,$12,$60,$0c,$f2,$70 3345 data $0c,$30,$70,$0c,$10,$70 3350 data $0c,$9e,$70,$0c,$9e,$70 3355 data $04,$1e,$60,$06,$3e,$60 3360 data $03,$ff,$c0,$00,$ff,$00 3365 data $00,$00,$00,$00,$00,$00 3370 data $00,$00,$00,$00,$00,$00 3375 data $00,$00,$00,$00,$00,$00 3380 data $00,$00,$00,$00,$01,$ff 3385 data $80,$0f,$ff,$f0,$0f,$ff 3390 data $f0,$39,$87,$1c,$31,$02 3395 data $0c,$39,$32,$4c,$39,$e6 3400 data $4c,$39,$cf,$1c,$39,$9e 3405 data $4c,$39,$3e,$4c,$39,$02 3410 data $0c,$39,$03,$1c,$0f,$ff 3415 data $f0,$0f,$ff,$f0,$01,$ff 3420 data $80,$00,$00,$00,$00,$00 3425 data $00,$00 --------------------------------------------------------------------------------------------------- MAIN PROGRAM PART! --------------------------------------------------------------------------------------------------- 0010 // (c) mzretro.ch 2026 0020 // basic end at $3D00 0030 POKE 28,0 // $00 0040 POKE 29,61 // $3D 0050 PAGE 0060 USE sprites 0070 USE graphics 0080 textbackground(0); textborder(0) 0090 textcolor(15) 0100 DIM xm(8), ym(8) 0110 sc:=0 // sprites 0120 sg:=0; ss:=0 // coll mode 0130 spd:=2 0140 POKE 53269,255 0150 FOR a:=0 TO 7 DO 0160 xm(a+1):=50+(a*28) 0170 ym(a+1):=98 0180 spritepos(a,xm(a+1),ym(a+1)) 0190 POKE 2040+a,245+a 0200 ENDFOR a 0210 info 0220 control: 0230 motion 0240 collcheck 0250 GOTO control 0260 PROC motion 0270 b:=PEEK(203) 0280 IF b=10 THEN 0290 xm(sc+1):=xm(sc+1)-spd 0300 ENDIF 0310 IF b=18 THEN 0320 xm(sc+1):=xm(sc+1)+spd 0330 ENDIF 0340 IF b=13 THEN 0350 ym(sc+1):=ym(sc+1)-spd 0360 ENDIF 0370 IF b=9 THEN 0380 ym(sc+1):=ym(sc+1)+spd 0390 ENDIF 0400 IF xm(sc+1)<0 THEN xm(sc+1):=0 0410 IF xm(sc+1)>300 THEN 0420 xm(sc+1):=300 0430 ENDIF 0440 IF ym(sc+1)<18 THEN ym(sc+1):=18 0450 IF ym(sc+1)>200 THEN 0460 ym(sc+1):=200 0470 ENDIF 0480 spritepos(sc,xm(sc+1),ym(sc+1)) 0490 IF b=56 THEN sc:=0 0500 IF b=59 THEN sc:=1 0510 IF b=8 THEN sc:=2 0520 IF b=11 THEN sc:=3 0530 IF b=16 THEN sc:=4 0540 IF b=19 THEN sc:=5 0550 IF b=24 THEN sc:=6 0560 IF b=27 THEN sc:=7 0570 CASE sc OF 0580 WHEN sc 0590 w$:="####"; t:=13 0600 PRINT AT 1,1: USING w$: sc 0610 PRINT AT 1,8: USING w$: xm(sc+1) 0620 PRINT AT 1,t: USING w$: ym(sc+1) 0630 OTHERWISE 0640 ENDCASE 0650 ENDPROC motion 0660 PROC collcheck 0670 sg:=PEEK(53279) 0680 PRINT AT 4,15: USING "###": sg 0690 ss:=PEEK(53278) 0700 PRINT AT 5,15: USING "###": ss 0710 ENDPROC collcheck 0720 PROC info 0730 sg:=PEEK(53279) 0740 PRINT AT 4,1: "sprite-gfx:" 0750 PRINT AT 5,1: "sprite-sprite:" 0760 PRINT AT 2,1: "sprite [x] [y]" 0770 PRINT AT 9,1: "select sprite 1-8" 0780 PRINT AT 10,1: "move with [wasd]" 0790 ENDPROC info ---------------------------------------------------------------------------------------------------