| | 8bitforever Account closed
Registered: Oct 2009 Posts: 48 |
Howto flickerfree and moving rasterbar ?
<Post edited by moderator on 20/10-2009 01:24>
Making a perfect stable, flickerfree and moving rasterbar is harder than I thought.
Why and which changes are needed to the code below to fulfill my dream about the flickerfree rasterbar?
The code is based on http://www.ffd2.com/fridge/vic/stableraster.txt.
Acme code ready to compile:
!to "doubleirqrasterbar1.prg",cbm
*= $0800
!byte $00,$0c,$08,$0a,$00,$9e,$33,$32,$37,$36,$38,$00,$00,$00,$00
raspos = $00
maxpos = $7c
*= $8000 ;Assemble to $8000
cld ;Clear Decimal Mode
sei ;Disable IRQ's
lda #$1f ;Disable CIA IRQ's
sta $dc0d
sta $dd0d
; lda #<nmi ;Install NMI into
; ldx #>nmi ;Hardware NMI and
; sta $fffa ;RESET Vectors
; sta $fffc
; stx $fffb
; stx $fffd
lda #<irq1 ;Install RASTER IRQ
ldx #>irq1 ;into Hardware
sta $0314 ;Interrupt Vector
stx $0315
; lda #$35 ;Set MMU to RAM at
; ldx #$ff ;$a000-$bfff and
; sta $01 ;$e000-$ffff
; txs ;Clear the STACK
lda #$01 ;Enable RASTER IRQ
ldx #$1b ;High bit of RASTER
ldy #$34 ;compare register
sta $d01a ;and RASTER IRQ to
stx $d011 ;line $34
sty $d012
;NOTE double IRQ
;cannot be on or
;around a BAD LINE!
;(Fast Line)
lda #$0e ;Set Background
ldx #$06 ;and Border colors
ldy #$00 ;to default and
sta $d020 ;turn off sprites
stx $d021
sty $d015
jsr clrscreen
jsr clrcolor
; jsr printtext
asl $d019 ;Ack any previous
lda $dc0d ;IRQ's
lda $dd0d
cli ;Renable IRQ's
jmp * ;Endless Loop
irq1
sta reseta1 ;Preserve A,X and Y
stx resetx1 ;Registers
sty resety1 ;VIA self modifying
;code
;(Faster than the
;STACK is!)
lda #<irq2 ;Set IRQ Vector
ldx #>irq2 ;to point to the
ldy #$35 ;next part of the
sta $0314 ;Stable IRQ
stx $0315 ;ON NEXT LINE!
sty $d012
asl $d019 ;Ack RASTER IRQ
tsx ;We want the IRQ
cli ;To return to our
nop ;endless loop
nop ;NOT THE END OF
nop ;THIS IRQ!
nop
nop ;Execute nop's
nop ;until next RASTER
nop ;IRQ Triggers
nop
nop ;2 cycles per
nop ;instruction so
nop ;we will be within
nop ;1 cycle of RASTER
nop ;Register change
; nop ;<--- remove 1 NOP for PAL
irq2
txs ;Restore STACK
;Pointer
ldx #$08 ;Wait exactly 1
dex ;lines worth of
bne *-1 ;cycles for compare
bit $ea ;Minus compare
nop ;cycles
; nop ;<--- remove 1 NOP for PAL
lda #$35 ;RASTER change yet?
cmp $d012
beq start ;If no waste 1 more
;cycle
start
ldx raspos
cpx #maxpos
beq setrastup
inx
stx raspos
cpx #maxpos
bne rasterbarctrl
setrastup
ldx #$00
stx raspos ;Reset raster positon to
;zero if maximum has been reached.
rasterbarctrl
ldx raspos
ldy rastmov,x ;Wait for rasterline $3D-$96 at $D012
wait cpy $d012
bne wait
;rasterbar
ldx #$00
copy11 ldy rastime,x
dey
bne *-1
lda coloursr,x
sta $d020
sta $d021
inx
cpx #$10
bne copy11
lda #<irq3 ;Set IRQ to point
ldx #>irq3 ;to subsequent IRQ
ldy #$b8 ;at line $68
sta $0314
stx $0315
sty $d012
asl $d019 ;Ack RASTER IRQ
lda #$00 ;Reload A,X,and Y
reseta1 = *-1 ;registers
ldx #$00
resetx1 = *-1
ldy #$00
resety1 = *-1
; rti ;Return from IRQ
jmp $ea31
irq3
sta reseta2 ;Preserve A,X,and Y
stx resetx2 ;Registers
sty resety2
ldx #$0a ;Waste some more
dex ;time so effect
bne *-1 ;can be seen
nop
; lda #$0e ;More colors
; ldx #$06
; nop:nop
; sta $d021 ;Cool! subsequent
; stx $d021 ;IRQ's are also
;stable :-)
;Unless you are
;running realtime
;code :-)
ldy #$18 ;Waste time so this
dey ;IRQ does not try
bne *-1 ;to reoccur on the
;same line!
lda #<irq1 ;Reset Vectors to
ldx #>irq1 ;first IRQ again
ldy #$34 ;at line $34
sta $0314
stx $0315
sty $d012
asl $d019 ;Ack RASTER IRQ
lda #$00 ;Reload A,X,and Y
reseta2 = *-1 ;registers
ldx #$00
resetx2 = *-1
ldy #$00
resety2 = *-1
; rti ;Return from IRQ
jmp $ea81
;Pound RESTORE to
;get back to Turbo
nmi
asl $d019 ;Ack all IRQ's
lda $dc0d
lda $dd0d
lda #$81 ;reset CIA 1 IRQ
ldx #$00 ;remove raster IRQ
ldy #$37 ;reset MMU to roms
sta $dc0d
stx $d01a
sty $01
ldx #$ff ;clear the stack
txs
cli ;reenable IRQ's
jmp $9000 ;back to Turbo
clrscreen
lda #$20 ;Clear the screen
ldx #$00
clrscr sta $0400,x
sta $0500,x
sta $0600,x
sta $0700,x
dex
bne clrscr
rts
clrcolor
lda #$03 ;Clear color memory
ldx #$00
clrcol sta $d800,x
sta $d900,x
sta $da00,x
sta $db00,x
dex
bne clrcol
rts
printtext
lda #$16 ;C-set = lower case
sta $d018
ldx #$00
moretext lda text1,x
bpl lower ;upper case ?
eor #$80 ;yes
bne lower+2
lower and #$3f ;lower case
sta $0450,x
inx
cpx #$78
bne moretext
exit rts
text1
!scr "Stable Raster IRQ sourc"
!scr "e (PAL/NTSC) "
!scr "All Code by Fungus 1996"
!scr " "
!scr "Feel free to use and mo"
!scr "dify this code :)"
;------------------------------------------------------------------------------- -
;raster data
;------------------------------------------------------------------------------- -
rastime
!byte $08,$08,$08,$08,$08,$08,$08,$01
!byte $08,$08,$08,$08,$08,$08,$08,$01
coloursr
!byte $0b,$0b,$0c,$0c,$0f,$0f,$0d,$0d
!byte $0d,$0f,$0f,$0c,$0c,$0b,$0b,$00
rastmov
!byte $3D,$3D,$3E,$3E,$3F,$3F,$40,$40,$41,$42,$43,$44,$45,$46,$47,$48
!byte $49,$4A,$4C,$4E,$50,$52,$54,$56,$58,$5A,$5C,$5E,$60,$62,$64,$66
!byte $68,$6A,$6C,$6E,$70,$72,$74,$76,$78,$7A,$7C,$7E,$80,$82,$84,$86
!byte $88,$8A,$8C,$8E,$8F,$90,$91,$92,$93,$94,$94,$95,$95,$96,$96,$95
!byte $95,$94,$94,$93,$93,$92,$91,$90,$8F,$8E,$8D,$8D,$8B,$89,$87,$85
!byte $83,$81,$7F,$7D,$7B,$79,$77,$75,$73,$71,$6F,$6D,$6B,$69,$67,$65
!byte $63,$61,$5F,$5D,$5B,$59,$57,$55,$53,$51,$4F,$4D,$4B,$49,$48,$47
!byte $46,$45,$44,$43,$42,$41,$40,$40,$3F,$3F,$3E,$3E
|
|
... 71 posts hidden. Click here to view all posts.... |
| | Krill
Registered: Apr 2002 Posts: 2980 |
Actually there's all info on the net to code such a trivial thing. Probably no ready-made source code which does exactly what you want, but all the parts are there.
I also suggest to try some other forums. Forum-64.de comes to mind, but it's primarily in German. |
| | WVL
Registered: Mar 2002 Posts: 902 |
Quote: I have one experimental flickerfree moving raster bar running now !
Thanks Jackasser and Jan !
I will try to combine it with the fungus stable raster code soon. Then I will publish the first flicker free moving rasterbar on the Internet.
The code will be ready to compile in ACME.
All of you who thinks this code is out there please provide
a link. Make sure it´s flickerfree first.
Coolio! I'm guessing the sourcecode for the first flicker free moving rasterbar on the Internet will have the same impact as the very first Mix Club Style Sid ehr.. Sid Style Club Mix... no... Style Sid Mix Club.. no... erh.. thing on the internet!
Fame be yours!
(Sorry Jan, I couldnt resist :D) |
| | FATFrost Account closed
Registered: Sep 2003 Posts: 211 |
only make a rasterbar routine that is better than everyone else's otherwise flaming is to be had.... |
| | Stainless Steel
Registered: Mar 2003 Posts: 966 |
Someone make some interlaced flickering rasterbars, and then convert them to NUFLI please :-D
|
| | Jetboy
Registered: Jul 2006 Posts: 337 |
Quote: Thanks Jackasser, Im trying to open up the matrix of the holy C64 coding. Hope to be able to show my finished flickerfree routine here soon. But I need more of your important code to finish. Please give some more code Jackasser. For the sake of fast progress. Its 2009.
The Matrix is closing in.
If they will write it for you, that wont be YOUR ROUTINE. |
| | Ninja
Registered: Jan 2002 Posts: 411 |
The Best C64 Ml tutorial collection
Read, try, read more, try harder, read more again, try really hard. Then come back... Honestly, your type of questions fit books or articles way better than forums. |
| | Angel of Death
Registered: Apr 2008 Posts: 211 |
Quote: Coolio! I'm guessing the sourcecode for the first flicker free moving rasterbar on the Internet will have the same impact as the very first Mix Club Style Sid ehr.. Sid Style Club Mix... no... Style Sid Mix Club.. no... erh.. thing on the internet!
Fame be yours!
(Sorry Jan, I couldnt resist :D)
LOL and more LOL.
This thread is getting better by the post.
Maybe HCL, x-Bow and +h should give this person not a tutorial as such but more a slap on the head and a good telling off for not coding stuff yourself. (just as it was done in the old days!)
:)) |
| | GT Account closed
Registered: Sep 2008 Posts: 308 |
Common guys, it is just a hoax. Don't spend time on it. |
| | 8bitforever Account closed
Registered: Oct 2009 Posts: 48 |
I have followed your instructions and changed the rasterbar movement code part to move the colourbar within the array instead of using raster positions. This works perfectly stable and flickerfree within my simple irq setup routine not shown in this forum. But when I combine the rasterbar code with the stable raster code at http://www.ffd2.com/fridge/vic/stableraster.txt it starts to flicker.
Please compile and see what it looks like. Use a Commodore 64 with PAL.
Can someone suggest code changes to make it stable and flickerfree ?
Or please explain why it´s not maybe possible to make it perfectly stable with the stableraster code from http://www.ffd2.com/fridge/vic/stableraster.txt.
Acme code ready to compile:
!to "doubleirqrasterbar2.prg",cbm
*= $0800
!byte $00,$0c,$08,$0a,$00,$9e,$33,$32,$37,$36,$38,$00,$00,$00,$00
ypos1=$32
ypos2=$10
constant32=$32
constant10=$10
turn=$00
*= $8000 ;Assemble to $8000
cld ;Clear Decimal Mode
sei ;Disable IRQ's
lda #$1f ;Disable CIA IRQ's
sta $dc0d
sta $dd0d
; lda #<nmi ;Install NMI into
; ldx #>nmi ;Hardware NMI and
; sta $fffa ;RESET Vectors
; sta $fffc
; stx $fffb
; stx $fffd
lda #<irq1 ;Install RASTER IRQ
ldx #>irq1 ;into Hardware
sta $0314 ;Interrupt Vector
stx $0315
; lda #$35 ;Set MMU to RAM at
; ldx #$ff ;$a000-$bfff and
; sta $01 ;$e000-$ffff
; txs ;Clear the STACK
lda #$01 ;Enable RASTER IRQ
ldx #$1b ;High bit of RASTER
ldy #$34 ;compare register
sta $d01a ;and RASTER IRQ to
stx $d011 ;line $34
sty $d012
;NOTE double IRQ
;cannot be on or
;around a BAD LINE!
;(Fast Line)
lda #$0e ;Set Background
ldx #$06 ;and Border colors
ldy #$00 ;to default and
sta $d020 ;turn off sprites
stx $d021
sty $d015
jsr clrscreen
; jsr clrcolor
; jsr printtext
asl $d019 ;Ack any previous
lda $dc0d ;IRQ's
lda $dd0d
cli ;Renable IRQ's
jmp * ;Endless Loop
irq1
sta reseta1 ;Preserve A,X and Y
stx resetx1 ;Registers
sty resety1 ;VIA self modifying
;code
;(Faster than the
;STACK is!)
lda #<irq2 ;Set IRQ Vector
ldx #>irq2 ;to point to the
ldy #$35 ;next part of the
sta $0314 ;Stable IRQ
stx $0315 ;ON NEXT LINE!
sty $d012
asl $d019 ;Ack RASTER IRQ
tsx ;We want the IRQ
cli ;To return to our
nop ;endless loop
nop ;NOT THE END OF
nop ;THIS IRQ!
nop
nop ;Execute nop's
nop ;until next RASTER
nop ;IRQ Triggers
nop
nop ;2 cycles per
nop ;instruction so
nop ;we will be within
nop ;1 cycle of RASTER
nop ;Register change
; nop ;<--- remove 1 NOP for PAL
irq2
txs ;Restore STACK
;Pointer
ldx #$08 ;Wait exactly 1
dex ;lines worth of
bne *-1 ;cycles for compare
bit $ea ;Minus compare
nop ;cycles
; nop ;<--- remove 1 NOP for PAL
lda #$35 ;RASTER change yet?
cmp $d012
beq start ;If no waste 1 more
;cycle
start ;Start rasterbar
dec $d019
!for I, 10 { nop }
ldy #$00
loop1
ldx #$08
loop2
lda $2500,y
sta $d020
sta $d021
iny
dex
beq loop1
!for I, 20 { nop }
colourbarlines
cpy #$4f
bne loop2
controlypos
ldx ypos1
cpx #constant32
beq turndown
cpx #constant10
beq turnup
jmp out
turndown
lda #$00
sta turn
lda #constant32
sta ypos1
lda #constant10
sta ypos2
jmp out
turnup
lda #$01
sta turn
lda #constant10
sta ypos1
lda #constant32
sta ypos2
jmp out
out
ldx turn
cpx #01
bne next
inc ypos1
jmp outout
next
dec ypos1
jmp outout
outout
ldy ypos1
ldx #0
mixcol
lda $2300,y
iny
sta $2500,x
inx
cpx #$4f
bne mixcol
;End rasterbar
lda #<irq3 ;Set IRQ to point
ldx #>irq3 ;to subsequent IRQ
ldy #$b8 ;at line $68
sta $0314
stx $0315
sty $d012
asl $d019 ;Ack RASTER IRQ
lda #$00 ;Reload A,X,and Y
reseta1 = *-1 ;registers
ldx #$00
resetx1 = *-1
ldy #$00
resety1 = *-1
; rti ;Return from IRQ
jmp $ea31
irq3
sta reseta2 ;Preserve A,X,and Y
stx resetx2 ;Registers
sty resety2
ldx #$0a ;Waste some more
dex ;time so effect
bne *-1 ;can be seen
nop
; lda #$0e ;More colors
; ldx #$06
; sta $d021 ;Cool! subsequent
; stx $d021 ;IRQ's are also
;stable :-)
;Unless you are
;running realtime
;code :-)
ldy #$18 ;Waste time so this
dey ;IRQ does not try
bne *-1 ;to reoccur on the
;same line!
lda #<irq1 ;Reset Vectors to
ldx #>irq1 ;first IRQ again
ldy #$34 ;at line $34
sta $0314
stx $0315
sty $d012
asl $d019 ;Ack RASTER IRQ
lda #$00 ;Reload A,X,and Y
reseta2 = *-1 ;registers
ldx #$00
resetx2 = *-1
ldy #$00
resety2 = *-1
; rti ;Return from IRQ
jmp $ea81
;Pound RESTORE to
;get back to Turbo
nmi
asl $d019 ;Ack all IRQ's
lda $dc0d
lda $dd0d
lda #$81 ;reset CIA 1 IRQ
ldx #$00 ;remove raster IRQ
ldy #$37 ;reset MMU to roms
sta $dc0d
stx $d01a
sty $01
ldx #$ff ;clear the stack
txs
cli ;reenable IRQ's
jmp $9000 ;back to Turbo
clrscreen
lda #$20 ;Clear the screen
ldx #$00
clrscr sta $0400,x
sta $0500,x
sta $0600,x
sta $0700,x
dex
bne clrscr
rts
clrcolor
lda #$03 ;Clear color memory
ldx #$00
clrcol sta $d800,x
sta $d900,x
sta $da00,x
sta $db00,x
dex
bne clrcol
rts
printtext
lda #$16 ;C-set = lower case
sta $d018
ldx #$00
moretext lda text1,x
bpl lower ;upper case ?
eor #$80 ;yes
bne lower+2
lower and #$3f ;lower case
sta $0450,x
inx
cpx #$78
bne moretext
exit rts
text1
!scr "Stable Raster IRQ sourc"
!scr "e (PAL/NTSC) "
!scr "All Code by Fungus 1996"
!scr " "
!scr "Feel free to use and mo"
!scr "dify this code :)"
;------------------------------------------------------------------------------- -
;raster data
;------------------------------------------------------------------------------- -
*=$2300
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $0b, $0c, $0c, $0f, $0f, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
*=$2500
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
|
| | GT Account closed
Registered: Sep 2008 Posts: 308 |
Do you know what an interrupt is ? |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - Next | |