; A beat a program sets for itself. ; ; The only regular thing this machine had was the screen finishing a frame, sixty times a ; second and not negotiable. That is a clock a program BORROWS: every duration becomes a ; multiple of 16.67 ms, so a sixteenth note at 120 beats a minute - 125,000 cycles, which is ; seven and a half frames - cannot be asked for at all. ; ; Counted in cycles, because that is what everything else on this machine is counted in. ; ; Written by Anachronaut #Program start: ; ---- Repeating, and polled ---- ; ; 100,000 cycles, a tenth of a second. Four of them, so the whole thing is 400,000 and the ; recorded cycle count is the check that the period is what it says. INIA 0x01 OUTA 0x52 INIA 0x86 OUTA 0x53 INIA 0xA0 OUTA 0x54 ; 0x0186A0 INIA 0x03 OUTA 0x51 ; Run, repeat, no interrupt. INIB 0d4 everyTick: INA 0x50 PSHB INIB 0x01 AND POPB BRQ everyTick ; Not yet. INIA 0d46 OUTA 0x00 DECB BNB everyTick ; ---- And looking is what answered it ---- ; ; The bit came down when it was read, so asking again immediately says nothing has happened ; since. A timer whose flag stayed up would look like a beat every time round the loop. INA 0x50 INIB 0x01 AND BRQ tickCleared INIA 0d78 ; 'N' OUTA 0x00 BRI oneShot tickCleared: INIA 0d89 ; 'Y' OUTA 0x00 oneShot: ; ---- Once, and then stopped ---- ; ; Without the repeat bit it runs its period out and turns itself off, which the status port ; says: bit 1 is whether it is running. RSTA OUTA 0x51 ; Stop first, so starting below is a start. INIA 0x01 OUTA 0x51 ; Run, no repeat. waitOnce: INA 0x50 INIB 0x01 AND BRQ waitOnce INIA 0d46 OUTA 0x00 INA 0x50 INIB 0x02 ; RUNNING AND BRQ stopped INIA 0d78 OUTA 0x00 BRI done stopped: INIA 0d89 OUTA 0x00 done: INIA 0d10 OUTA 0x00 HALT #Vectors Boot start