C64 Delay w/out cycle-counting?

  • Follow


How do I, using the VBLANK interrupt, a CIA-based interrupt, a VIC-II
interrupt, or in fact any method other than a number-based loop, pause
for a period of time such that, for example, a game or graphics demo
will function at a suitable speed?
0
Reply rose.joseph12 (88) 3/27/2012 1:54:29 PM

27.03.2012 16:54, Harry Potter kirjoitti:
> How do I, using the VBLANK interrupt, a CIA-based interrupt, a
> VIC-II interrupt, or in fact any method other than a number-based
> loop, pause for a period of time such that, for example, a game or
> graphics demo will function at a suitable speed?

Make a counter that will decrease one per interrupt until zero. This is
one example, 8 bit counter. It will stop at zero. When run in a
interrupt, it counts down in constant speed.

Code:

---- interrupt code ---
	ldx counter
	beq .off
	dex
	stx counter
..off
---- more interrupt code ----




In main code:

	lda #50		;50 interrupts
	sta counter	;set to countdown register
..wait 	lda counter
	bne .wait	;wait until zero. Interrupts are on, so counter
			;decreases.

Now we have waited one second, if this is run on a pal machine.

Of course the example of main code is a bit stupid - you usually can do
something in the main loop except waiting for a counter. For example, if
you need to load something, you can do it while waiting something on the
screen and so on. You just need to check the counter and when it is
zero, do next thing.

0
Reply pekka.NOtakala (8) 3/27/2012 10:04:10 PM


1 Replies
78 Views

(page loaded in 0.033 seconds)

Similiar Articles:













7/24/2012 5:57:20 PM


Reply: