delay64: nop delay62: nop delay60: nop delay58: nop delay56: nop delay54: nop delay52: nop delay50: nop delay48: nop delay46: nop delay44: nop delay42: nop delay40: nop delay38: nop delay36: nop delay34: nop delay32: nop delay30: nop delay28: nop delay26: nop delay24: nop delay22: nop delay20: nop delay18: nop delay16: nop delay14: nop delay12: rts delay63: nop delay61: nop delay59: nop delay57: nop delay55: nop delay53: nop delay51: nop delay49: nop delay47: nop delay45: nop delay43: nop delay41: nop delay39: nop delay37: nop delay35: nop delay33: nop delay31: nop delay29: nop delay27: nop delay25: nop delay23: nop delay21: nop delay19: nop delay17: nop delay15: .byte $04, $00 ; NOOP $00 = 3 cycles rts
Otherwise a branch might end up crossing a page border and you'll lose a cycle somewhere which usually takes a long time to find.
irq2: :IRQ_LeadIn #1 ldx #$07 dex bne *-1 bit $ffff nop ldx #$00 d16: ldy #$00 :SET_GRAPHICS_BANKS($4400,$5800) lda #$1b sta $d011 lda #$0f sty x sta x,x //32 sty x sta x //33 :timer1 //34 :timer1 //35 :timer1 //36 :timer1 //37 :timer1 //38 :timer1 //39 :timer2 //3a & 3b :timer1 //3c :timer1 //3d :timer1 //3e :timer1 //3f :timer1 //40 :timer1 //41 :timer2 //42 & 43 :timer1 //44 :timer1 //45 :timer1 //46 ldx #106+21 stx $d009 stx $d00b stx $d00d stx $d00f ldx #$41 stx $47fc ldx #$45 stx $47fd ldx #$50 stx $47fe ldx #$50 stx $47ff ldx #$00 sty x sta x :timer1 :timer1 :timer2 :timer1 :timer1 :timer1 :timer1 :timer1 :timer1 :timer2 :timer1 :timer1 :timer1 :timer1 :timer1 :timer1 :timer2 ldx #106+42 stx $d009 stx $d00b stx $d00d stx $d00f ldx #$42 stx $47fc ldx #$46 stx $47fd ldx #$50 stx $47fe ldx #$50 stx $47ff ldx #$00 sty x sta x :timer1 :timer1 :timer1 :timer1 :timer1 .pseudocommand timer1 { bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff sty x sta x } .pseudocommand timer2 { bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff bit $ffff sty x sta x,x sty x sta x }
#pybegin badline_offset = 2 for i in range(16): if i%8 == badline_offset: # bad line print "sta $d016,y" else: print "jsr delay44" print "sta $d016" print "stx $d016" #pyend
:open_border (2,16) .macro open_border(badline_offset,total_lines) { .for (i=0;i<total_lines;i++) { jsr delay44 .if i&7 == badline_offset: stx $d016 sta $d016,y } stx $d016 sta $d016 } } Delay44: .for (i=0;i<4;i++) { pha pla } nop nop rts
.var i = 0 :open_border(2,16) .macro open_border(badline_offset,total_lines) { .for (i=0;i<total_lines;i++) { jsr Delay44 stx $d016 .if([i&7] == badline_offset) { sta $d016,y stx $d016 } sta $d016 } } Delay44: .for (i=0;i<4;i++) { pha pla } nop nop rts