我是ASM的新手,我试图解决如何为以下代码创建延迟:
org $1000
loop: inc $d021
jmp loop发布于 2014-02-10 03:17:35
我想评论已经很清楚了。
每帧更改颜色的代码示例(1/50秒)
sei ; enable interrupts
loop1: lda #$fb ; wait for vertical retrace
loop2: cmp $d012 ; until it reaches 251th raster line ($fb)
bne loop2 ; which is out of the inner screen area
inc $d021 ; increase background color
lda $d012 ; make sure we reached
loop3: cmp $d012 ; the next raster line so next time we
beq loop3 ; should catch the same line next frame
jmp loop1 ; jump to main loop每秒钟更换颜色的代码示例
counter = $fa ; a zeropage address to be used as a counter
lda #$00 ; reset
sta counter ; counter
sei ; enable interrupts
loop1: lda #$fb ; wait for vertical retrace
loop2: cmp $d012 ; until it reaches 251th raster line ($fb)
bne loop2 ; which is out of the inner screen area
inc counter ; increase frame counter
lda counter ; check if counter
cmp #$32 ; reached 50
bne out ; if not, pass the color changing routine
lda #$00 ; reset
sta counter ; counter
inc $d021 ; increase background color
out:
lda $d012 ; make sure we reached
loop3: cmp $d012 ; the next raster line so next time we
beq loop3 ; should catch the same line next frame
jmp loop1 ; jump to main loop发布于 2014-02-09 07:47:29
例如:
loop: ldx $d021
inx
stx $d021
cpx #100
bne loop发布于 2016-05-02 18:54:09
这个怎么样?这应该会改变背景,等待4秒,然后再改变它。永远重复。
注意,您可以将秒数从0更改为255。
这是针对NTSC机器的,但是您可以将60更改为50 for PAL。
main:
inc $D021
ldx #4 // Wait 4 seconds
loop1:
ldy #60
loop2:
waitvb:
bit $D011
bpl waitvb
waitvb2:
bit $D011
bmi waitvb2
dey
bne loop2
dex
bne loop1
jmp mainhttps://stackoverflow.com/questions/21656605
复制相似问题