diff --git a/compiler/src/prog8/optimizer/CallGraph.kt b/compiler/src/prog8/optimizer/CallGraph.kt index c2a12d9ae..715cbc303 100644 --- a/compiler/src/prog8/optimizer/CallGraph.kt +++ b/compiler/src/prog8/optimizer/CallGraph.kt @@ -104,7 +104,12 @@ class CallGraph(private val program: Program): IAstVisitor { } override fun visit(subroutine: Subroutine) { - if((subroutine.name=="start" && subroutine.definingScope().name=="main") + val alwaysKeepSubroutines = setOf( + Pair("main", "start"), + Pair("irq", "irq") + ) + + if(Pair(subroutine.definingScope().name, subroutine.name) in alwaysKeepSubroutines || subroutine.name== initvarsSubName || subroutine.definingModule().isLibraryModule) { // make sure the entrypoint is mentioned in the used symbols addNodeAndParentScopes(subroutine) diff --git a/examples/rasterbars.p8 b/examples/rasterbars.p8 index 94a5c0ffe..503082a6e 100644 --- a/examples/rasterbars.p8 +++ b/examples/rasterbars.p8 @@ -5,10 +5,11 @@ ~ main { sub start() { - c64.SCROLY &= %11101111 ; blank the screen - c64utils.set_rasterirq_excl(40) + c64.SCROLY &= %11101111 ; blank the screen + c64utils.set_rasterirq_excl(40) ; register exclusive raster irq handler while(true) { + ; enjoy the moving bars :) } } @@ -20,22 +21,20 @@ const ubyte barheight = 4 ubyte[] colors = [6,2,4,5,15,7,1,13,3,12,8,11,9] ubyte color = 0 - ubyte ypos = 0 + ubyte yanim = 0 sub irq() { - Y++ ; slight timing delay to avoid rasterline transition issues - ubyte rasterpos = c64.RASTER - if color!=len(colors) { c64.EXTCOL = colors[color] + c64.RASTER += barheight ; next raster Irq for next color color++ - c64.RASTER = rasterpos+barheight } else { - ypos += 2 c64.EXTCOL = 0 color = 0 - c64.RASTER = sin8u(ypos)/2+40 + yanim += 2 + c64.RASTER = sin8u(yanim)/2+30 ; new start of raster Irq } + c64.SCROLY &= $7f ; set high bit of the raster pos to zero } }