Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > stable rasters (again...)
2007-08-15 13:42
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
stable rasters (again...)

I have been playing with double irq for some time and I can't put the code to work, can someone please have a look
and tell me why I can't get my raster bars stable, thanks.
I use kickassembler and the code is an adaptation of the one here: http://codebase64.org/doku.php?id=base:fli_displayer


.pc = $0801 "Basic Program"
:BasicUpstart($1000)

.pc = $1000

	jmp start
irq0:	
	dec $d019
	inc $d012
	lda #<irq1
	sta $fffe      // set up 2nd IRQ to get a stable IRQ
	
	
	cli

        // Following here: A bunch of NOPs which allow the 2nd IRQ
        // to be triggered with either 0 or 1 clock cycle delay
        // resulting in an "almost" stable IRQ.

	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
irq1:
	nop
	nop
	nop
	nop
	nop
	nop
	
	nop
	nop
	nop
	
	bit $ea
	
	
	
	
	
	lda #$2d
	sta $d012
	lda #<irq0
	sta $fffe      // switch IRQ back to first stabilizer IRQ
	
	
	lda $d012
	cmp $d012      // stabilize last jittering cycle
	beq delay2      // if equal, 2 cycles delay. else 3 cycles delay

	

delay2:

	    
       ldx #$00			  //2
v:     lda rastercols,x   //4
	   sta $d020 		  //4
//	   sta $d021		  //4
//nop
//nop
bit $ea
	   ldy delay,x		  //4
	   dey				  //2
	   bne *-1			  //2 or 3
	   inx				  //2
	   cpx #48			  //2
	   bne v			  //2  or 3  = 30
	
	   bit $ea
	   
/*	
	ldx #$10
wait:	dex
	bne wait
*/


        // Following here is the main FLI loop which forces the VIC-II to read
        // new color data each rasterline. The loop is exactly 23 clock cycles
        // long so together with 40 cycles of color DMA this will result in
        // 63 clock cycles which is exactly the length of a PAL C64 rasterline.


	asl $d019
	
nmi:
	rti

start:
	sei
	lda #$35
	sta $01        // disable all ROMs
	lda #$7f
	sta $dc0d      // no timer IRQs
	lda $dc0d      // clear timer IRQ flags
	lda #$1b
	sta $d011
	lda #$2d
	sta $d012
	   
 
     
 
         lda #$00    //Set Background
         ldx #BLACK    //and Border colors
        
         sta $d020   //turn off sprites
         stx $d021

	lda #<irq0
	sta $fffe
	lda #>irq0
	sta $ffff
	lda #<nmi
	sta $fffa
	lda #>nmi
	sta $fffb      // dummy NMI to avoid crashing due to RESTORE
	lda #$01
	sta $d01a      // enable raster IRQs



	dec $d019      // clear raster IRQ flag
	cli
	jmp *          // that's it, no more action needed

.pc = $0c00         
rastercols:			.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
					.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
					.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, BLACK
					.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
					.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
					.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, BLACK
.pc = $0d00         					
delay:				.byte $08,$01,$08,$08,$08,$08, $08, $08
					.byte $08,$01,$08,$08,$08,$08, $08, $08
					.byte $08,$01,$08,$08,$08,$08, $08, $08
					.byte $08,$01,$08,$08,$08,$08, $08, $08
					.byte $08,$01,$08,$08,$08,$08, $08, $08
					.byte $08,$01,$08,$08,$08,$08, $08, $08
					.byte $08,$01,$08,$08,$08,$08, $08, $08
					.byte $08,$01,$08,$08,$08,$08, $08, $08
 
... 11 posts hidden. Click here to view all posts....
 
2007-08-15 17:12
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Thank you Slammer, I have added th epha and pla's but when I run it the result is the same as above
2007-08-15 18:07
tlr

Registered: Sep 2003
Posts: 1790
Post a binary of your non-working build please.
2007-08-15 20:34
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Here tlr, http://rapidshare.com/files/49211708/doubleirq2.prg

Thank you
2007-08-15 21:07
tlr

Registered: Sep 2003
Posts: 1790
Quote: Here tlr, http://rapidshare.com/files/49211708/doubleirq2.prg

Thank you


POKE4138,234:RUN

You have miscalculated the timing somewhere. This replaces the bit $ea with two nops.

I think you want it to be 46 cycles in the second interrupt upto the lda $d012; cmp $d012.
(Had to check my old stable rasters for this so I hope I haven't mistaken myself.)
2007-08-15 21:41
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Thank tlr you but the result is just the same

here is the code again with the pha and pla's

.pc = $0801 "Basic Program"
:BasicUpstart($1000)

.pc = $1000

jmp start
irq0: pha
dec $d019
inc $d012
lda #<irq1
sta $fffe // set up 2nd IRQ to get a stable IRQ


cli

// Following here: A bunch of NOPs which allow the 2nd IRQ
// to be triggered with either 0 or 1 clock cycle delay
// resulting in an "almost" stable IRQ.

nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
irq1:/*

pla
pla
pla


lda #$2d
sta $d012
lda #<irq0
sta $fffe // switch IRQ back to first stabilizer IRQ


lda $d012
lda $d012
sta $d020
//cmp $d012 // stabilize last jittering cycle
//beq delay2 // if equal, 2 cycles delay. else 3 cycles delay



delay2:


ldx #$00 //2
v: lda rastercols,x //4
sta $d020 //4
// sta $d021 //4
//nop
//nop
bit $ea
ldy delay,x //4
dey //2
bne *-1 //2 or 3
inx //2
cpx #48 //2
bne v //2 or 3 = 30

bit $ea

/*
ldx #$10
wait: dex
bne wait
*/





asl $d019
pla
nmi:
rti

start:
sei
lda #$35
sta $01 // disable all ROMs
lda #$7f
sta $dc0d // no timer IRQs
lda $dc0d // clear timer IRQ flags
lda #$1b
sta $d011
lda #$2d
sta $d012




lda #$00 //Set Background
ldx #BLACK //and Border colors

sta $d020 //turn off sprites
stx $d021

lda #<irq0
sta $fffe
lda #>irq0
sta $ffff
lda #<nmi
sta $fffa
lda #>nmi
sta $fffb // dummy NMI to avoid crashing due to RESTORE
lda #$01
sta $d01a // enable raster IRQs



dec $d019 // clear raster IRQ flag
cli
jmp * // that's it, no more action needed

.pc = $0c00
rastercols: .byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, BLACK
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, BLACK
.pc = $0d00
delay: .byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
2007-08-15 21:48
tlr

Registered: Sep 2003
Posts: 1790
?
doubleirq2.prg works fine with the poke I gave you.

The code you posted now is very different from doubleirq2.prg. The actual stable-code has been commented out for instance. And the number of cycles from irq1 upto the lda $d012 is nowhere near 46 cycles.
2007-08-15 22:35
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
I tried the poke but didn't see it stables perhaps I messed something. I am going to copy the first code and use it again.

thanks
2007-08-16 14:00
JackAsser

Registered: Jun 2002
Posts: 2014
After request from Algarbi@#c-64 i post (converted to CA65 for your inconvinience):

.segment "CODE"

.define BLUE 6
.define PURPLE 4
.define GREEN 5
.define LIGHT_RED 10
.define BLACK 0
.define WHITE 1
.define ORANGE 8

jmp start
irq0: pha
dec $d019
inc $d012
lda #<irq1
sta $fffe ; set up 2nd IRQ to get a stable IRQ


cli

; Following here: A bunch of NOPs which allow the 2nd IRQ
; to be triggered with either 0 or 1 clock cycle delay
; resulting in an "almost" stable IRQ.

nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
irq1:

pla
pla
pla

lda #$2d
sta $d012
lda #<irq0
sta $fffe ; switch IRQ back to first stabilizer IRQ

pha
pla
pha
pla
pha
pla
nop
bit $ff

lda $d012
cmp #$2f
bne :+
:

ldx #$00 ;2
v: lda rastercols,x ;4
sta $d020 ;4
; sta $d021 ;4
;nop
;nop
bit $ea
ldy delay,x ;4
dey ;2
bne *-1 ;2 or 3
inx ;2
cpx #48 ;2
bne v ;2 or 3 = 30

bit $ea

.if 0
ldx #$10
wait: dex
bne wait
.endif





asl $d019
pla
nmi:
rti

start:
sei
lda #$35
sta $01 ; disable all ROMs
lda #$7f
sta $dc0d ; no timer IRQs
lda $dc0d ; clear timer IRQ flags
lda #$1b
sta $d011
lda #$2d
sta $d012




lda #$00 ;Set Background
ldx #BLACK ;and Border colors

sta $d020 ;turn off sprites
stx $d021

lda #<irq0
sta $fffe
lda #>irq0
sta $ffff
lda #<nmi
sta $fffa
lda #>nmi
sta $fffb ; dummy NMI to avoid crashing due to RESTORE
lda #$01
sta $d01a ; enable raster IRQs

dec $d019 ; clear raster IRQ flag
cli

; Some silly loop to enforce unstable timing (hopefully)
:
lda #$00
ldx $40
lda $c000,x
lda $c0ff,x
inc $40
inc $c000,x
inc $c0ff,x
jmp :-

.align 256

rastercols:



.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE,ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, BLACK
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, ORANGE
.byte BLUE, PURPLE, GREEN, LIGHT_RED, PURPLE, BLACK, WHITE, BLACK

.align 256
delay:
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08
.byte $08,$01,$08,$08,$08,$08, $08, $08

2007-08-16 14:14
Zyron

Registered: Jan 2002
Posts: 2381
Quote:
sta $d020 ;turn off sprites


Oh, that's how it's done! ;D
2007-08-16 15:27
Frantic

Registered: Mar 2003
Posts: 1648
hä hä hä
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
E$G/HF ⭐ 7
Guests online: 126
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.066 sec.