If-directives work like in standard programming languages. With an .if directive you have the proceeding directive executed only if a given boolean expression is evaluated to true. Here are some examples:
// Set x to 10 if x is higher that 10 .if (x>10) .eval x=10 // Only show rastertime if the ‘showRasterTime’ boolean is true .var showRasterTime = false .if (showRasterTime) inc $d020 jsr PlayMusic .if (showRasterTime) dec $d020
You can group several statements together in a block with {…} and have them executed together if the boolean expression is true:
// If IrqNr is 3 then play the music .if (irqNr==3) { inc $d020 jsr music+3 dec $d020 }
By adding an else statement you can have an expression executed if the boolean expression is false:
// Add the x’th entry of a table if x is positive or // subtract it if x is negative .if (x>=0) adc zpXtable+x else sbc zpXtable+abs(x) // Init an offset table or display a warning if the table length is exceeded .if (i<tableLength) { lda #0 sta offset1+i sta offset2+i } else { .error "Error!! I is too high!" }