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 > Howto flickerfree and moving rasterbar ?
2009-10-19 23:18
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



2009-10-20 04:10
chatGPZ

Registered: Dec 2001
Posts: 11386
the "trick" is how you move the rasterbar. the basic idea is, unless you really know what you are doing (and why), then do NOT ever alter the position where the raster irq is triggered (ie, $d012). first make the basic routine stable (that should be easy enough with the example code you got there), then add simple rasterbars to it (which then should be stable and flickerfree). now to move stuff around, simply alter the table where the colors are taken from. (think of more advanced stuff like a dozen bars jumping up and down-how would you do that by altering $d012 in the first place... the table thing comes into mind again :))
2009-10-20 06:05
Marauder/GSS
Account closed

Registered: Jul 2006
Posts: 224
if you want to move your *whole* color-bar/table up and down, then you could make your color-table bigger and just increase/decrease the pointer/start-positon where you're reading your colors from (-> lda coloursr,x)...
that way you don't have to alter the whole table and save some time... however works only if you don't want to have different color-bars jumping around...
2009-10-20 07:24
MagerValp

Registered: Dec 2001
Posts: 1078
The stable raster code that you started with (from the fridge) is timed for the hardware IRQ vector at $fffe, and you've changed the code to use the kernal IRQ vector at $0314. This fucks up the timing beyond repair. As others here not, you also can't move rastercode with $d012, as that also changes the timing.
2009-10-20 07:25
Skate

Registered: Jul 2003
Posts: 494
I agree with the guys above. Additionally moving $d012 is not that bad idea. But instead of self modifying code, I advice you to use zero page addresses holding raster positions.

Instead of

ldy #$34
sty $d012
...
...
...
ldy #$35
sty $d012

use

lda #$34
sta $a0 ; any available zeropage address is ok

ldy $a0
sty $d012
...
...
...
ldy $a0
iny
sty $d012

you should take care of cycle changes, adding removing some NOPs and BITs should be enough. After that to move the raster position just increase/decrease zeropage address ($a0 in this case) at the end of the frame.
2009-10-20 07:54
enthusi

Registered: May 2004
Posts: 677
you can switch off the screen (aka no badlines), then use stable raster and change $d012 but you probably dont want it this way.
2009-10-20 08:43
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
Thanks for quick response !

Anyone that could rework the code and be the first to publish a fully stable and flicker free moving rasterbar routine ?

2009-10-20 11:40
MagerValp

Registered: Dec 2001
Posts: 1078
No. We also won't do your homework, walk your dog, or call your grandma on her birthday.
2009-10-20 11:51
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
MagerValp, the time has come for someone to finally
publish a stable, flickerfree moving rasterbar routine.
The demand for one is out there ;-)
This is what´s missing on the Internet and on the CSDB forum.
2009-10-20 12:09
Moloch

Registered: Jan 2002
Posts: 2928
8bitforever - and you can be the one to do it! Do some studying and trial and error and be the first!

;)
2009-10-20 12:12
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Do a raster at line $xx, and then do this:

ldx #4 ;adjust this to remove flicker
.dex
bne .

ldx #0
..lda color,x
sta $d020
sta $d021
ldy timer,x
.dey
bne .
inx
bne ..


have it running in a monitor, and adjust the timer table to remove flicker.
2009-10-20 12:36
Frantic

Registered: Mar 2003
Posts: 1648
Wasn't there a routine in one of the C= Hacking issues, or do I remember wrong?
2009-10-20 20:41
chatGPZ

Registered: Dec 2001
Posts: 11386
rambones: thats not a stable raster routine.... it can be made flickerfree (or well, flickering in the border) though with proper delay values though, admitted :)
2009-10-21 06:43
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Groepaz: most 80s demos do this, and it works well :D
2009-10-21 06:44
HCL

Registered: Feb 2003
Posts: 728
Zzz. Stable, flickerfree moving rasterbars was *published* in 198x and 1000 demos have *published* it since then. ..and they are all on the internet with the code just there for you to read, if you just use some other tool than Notepad.
2009-10-21 08:50
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
I know they have been out there since the eighties but I´m trying to do some coding in 2009. Since we are here now in 2009 I would like to find the code using gogle or codebase64 or the CSDb forum.

So since you know the code and where to find it, could you please publish some stable, flickerfree moving rasterbar code here in ASCII.

Please, be helpful !
2009-10-21 09:17
Frantic

Registered: Mar 2003
Posts: 1648
...which makes me notice that Jackasser still haven't finished his codebase articles on stable timing. :)

//FTC
2009-10-21 09:49
Jetboy

Registered: Jul 2006
Posts: 337
Quote: I know they have been out there since the eighties but I´m trying to do some coding in 2009. Since we are here now in 2009 I would like to find the code using gogle or codebase64 or the CSDb forum.

So since you know the code and where to find it, could you please publish some stable, flickerfree moving rasterbar code here in ASCII.

Please, be helpful !


They are helpfull. They gave you all the info you need.
2009-10-21 09:57
Frantic

Registered: Mar 2003
Posts: 1648
If the help is not enough I suggest you buy a flickerfixer. ;)
2009-10-21 11:05
Graham
Account closed

Registered: Dec 2002
Posts: 990
Don't move the raster-IRQ, move the colors inside the color table.
2009-10-21 11:07
Marauder/GSS
Account closed

Registered: Jul 2006
Posts: 224
Quote: I know they have been out there since the eighties but I´m trying to do some coding in 2009. Since we are here now in 2009 I would like to find the code using gogle or codebase64 or the CSDb forum.

So since you know the code and where to find it, could you please publish some stable, flickerfree moving rasterbar code here in ASCII.

Please, be helpful !


if people would at least study the code and try to learn from, then they would understand what they're doing and could fix this by themelves...

just copy/paste code and using it without understanding is so lame...hehe *SCNR* (c;

and I also think people here were helpful, so do you homework now... :D
2009-10-21 12:02
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
What Graham said..
2009-10-21 13:01
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
OK, I will try that Graham and Jan.

Could you please give some sample code on howto move around
the colobar in the middle of this array below to an equal big shadow array ?

!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 $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $00
!byte $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $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
2009-10-21 13:24
Frantic

Registered: Mar 2003
Posts: 1648
This question makes it clear beyond belief that you should just take 10 minutes to read an introductory text to coding 6510 assembler in general. Are you seriously taking up peoples time by asking how to copy a few bytes of data from one place in memory to another place? Ever heard of LDA/STA? Ever heard of a loop?

Try learning something from this one:
http://codebase64.org/doku.php?id=magazines:chacking2#beginning..
2009-10-21 14:42
Marauder/GSS
Account closed

Registered: Jul 2006
Posts: 224
if you just want to move your rasterbar up 'n down, then you don't even need to copy data around in the table.
Just make your table bigger and adjust/modify the address where you're reading your colors from...
ofcoz don't work when you want to have mulitple "overlappin" color-bars, then lda/sta/loops is your friend, like frantic said...

DejaVu...Didn't I've already mentioned it in my first answer/post?! ^^



2009-10-21 14:59
MagerValp

Registered: Dec 2001
Posts: 1078
8bf: the answer has been posted here at least three times, together with several other helpful comments. If you don't understand the answer, you need to go back and study the basics. And no, you can't google your way to becoming a C64 demo coder. It takes a bit more effort than that. Not a whole lot mind you - 13 year old kids figured out this stuff in the 80s.
2009-10-21 15:17
Mr. SID

Registered: Jan 2003
Posts: 424
And they did it *without* Google! :)
2009-10-21 15:49
Carrion

Registered: Feb 2009
Posts: 317
13 year old did demos? nice.
[offtoopic]
But on last Silesia party there was a guy (about 35) with his 9 years old son. He said he never new what demoscene is but his son wants to code c64. after few talks to us (even me ;) he coded small and simple assembelr program. We need people like that to make our scene last for years.
2009-10-21 22:06
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Quote: OK, I will try that Graham and Jan.

Could you please give some sample code on howto move around
the colobar in the middle of this array below to an equal big shadow array ?

!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 $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $00
!byte $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $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


ldy sinus,x
lda color,y
sta color_buffer,y


you have several color tables,
you sta colors from them, into a buffer (mix the data)
you show this data
2009-10-22 06:56
HCL

Registered: Feb 2003
Posts: 728
Hmm.. First *someone* 9-year old starts to code c64, then *someone* asks for flickerfree moving raster stuff!? Is that just a coincidence or does your head go bling also!?!?!?
2009-10-22 07:18
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
LOL! well, just rip the code from somewhere, and use 1 hour to understand it then. no big prob :D
2009-10-22 08:13
Radiant

Registered: Sep 2004
Posts: 639
Quote: 13 year old did demos? nice.
[offtoopic]
But on last Silesia party there was a guy (about 35) with his 9 years old son. He said he never new what demoscene is but his son wants to code c64. after few talks to us (even me ;) he coded small and simple assembelr program. We need people like that to make our scene last for years.


This put a big smile on my face and made my day. Thanks for sharing it. :-)
2009-10-22 10:23
Frantic

Registered: Mar 2003
Posts: 1648
Offtopic: I really wonder what makes a 9 year old get the idea in these days that coding c64 is a thing you might want to do - especially if the father is not the one who is pushing things in that direction.
2009-10-22 12:46
WVL

Registered: Mar 2002
Posts: 902
He must have heard that c64 coders get all the hot chicks!
2009-10-22 12:55
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
Thanks for your effort to reply to the topic Jan !

You are about the only one in this forum that seems to understand that you have to start coding from somewhere :-)

ldy sinus,x
lda color,y
sta color_buffer,y

Could you please show some more code on how you create the the pointers and loops also. To create the repeating rasterbar movement in the colortable (array).
2009-10-22 13:02
Mr. SID

Registered: Jan 2003
Posts: 424
2009-10-22 13:26
Carrion

Registered: Feb 2009
Posts: 317
frantic:
Father of that kid bought him a c64 on ebay just for fun and the boy liked it from start :)
I just gave them my old FCIII cartridge so they can code more. for now he uses monitor to do that but later i'll show them turbo assembler :)
and I'm really impressed by progress that boy does.
2009-10-22 13:33
WVL

Registered: Mar 2002
Posts: 902
Quote: Thanks for your effort to reply to the topic Jan !

You are about the only one in this forum that seems to understand that you have to start coding from somewhere :-)

ldy sinus,x
lda color,y
sta color_buffer,y

Could you please show some more code on how you create the the pointers and loops also. To create the repeating rasterbar movement in the colortable (array).


How do you think it should work? What steps would you need? Make a flow diagram with all the necessary steps and then convert it to code.
2009-10-22 13:50
Marauder/GSS
Account closed

Registered: Jul 2006
Posts: 224
Quote: Thanks for your effort to reply to the topic Jan !

You are about the only one in this forum that seems to understand that you have to start coding from somewhere :-)

ldy sinus,x
lda color,y
sta color_buffer,y

Could you please show some more code on how you create the the pointers and loops also. To create the repeating rasterbar movement in the colortable (array).


give me more...give me more code please!?
Are you to lazy or not willing to understand and learn the basics *sigh* why not have a post on rent-a-coder?

*SCNR* (c;

don't take me to seriously... hehe
2009-10-22 13:55
chatGPZ

Registered: Dec 2001
Posts: 11386
Quote:
How do you think it should work? What steps would you need? Make a flow diagram with all the necessary steps and then convert it to code.


indeed. and if thats too much for you now, then take a step back, and do something simpler first which you can understand better. like moving an A back and forth on the screen or something like that.
2009-10-22 14:42
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
Move the non-zero bytes (colorbar) in the middle of the array back and forward and back forever within the array one byte at a time. And always zero in the array around the moved colorbar.

!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 $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $00
!byte $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $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

Can someone show the code for a routine like this ?
You are experts, arent you, easy then ... :-)

2009-10-22 14:46
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: Move the non-zero bytes (colorbar) in the middle of the array back and forward and back forever within the array one byte at a time. And always zero in the array around the moved colorbar.

!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 $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $00
!byte $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $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

Can someone show the code for a routine like this ?
You are experts, arent you, easy then ... :-)



It's like the Matrix... There is no spoon...

input:
.repeat 2
!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 $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $00
!byte $0b, $0b, $0c, $0c, $0f, $0f, $0d, $0d
!byte $0d, $0f, $0f, $0c, $0c, $0b, $0b, $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
.endrep

output:
.res 256,0

ldy ypos
ldx #0
:
lda input,y
iny
sta output,x
inx
bne :-
2009-10-22 14:55
Pantaloon

Registered: Aug 2003
Posts: 124
spoiler alert!! jackasser is revealing top secret stuff of the demoscene. BAN HIM!
2009-10-22 15:00
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
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.
2009-10-22 15:02
Marauder/GSS
Account closed

Registered: Jul 2006
Posts: 224
hehe... "Agent Smith, where are you?? we have here a..." :D

but I guess the next question is to convert it to ACME and how to use it/where are the "missing things/secrets"... ^^

*edit: well, a bit to late but not that wrong with my assumption *g*


2009-10-22 15:41
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
8bitforever:

if you do:

lda color,x
inx
lda color,x

what is x now ?

then your table has 0,0,0,0,0,0,0,0,color,0,0,0,0,0,0

so when you change x, it loads from different places.

as i showed, you can use a sinus curve for the x value, or you can just increase/decrease it.

before you do more, now take a piece of paper and make some pseudocode that is tested and works, then try to make 6510 AFTERWARDS.
2009-10-22 15:53
JackAsser

Registered: Jun 2002
Posts: 2014
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.


I don't want another rasterbars part. If you do, then you do it. If you have a learning problem then tough luck, you need to practice more. Actually practice is key to C64 coding... but since I actually think you're ignorant I suggest you buzz off and stalk some other forum.
2009-10-22 16:07
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
I'm not ignorant. I want to publish a flicker free rasterbar routine for other beginers like me.
There is no ascii published one out there.
I'm trying to learn. Can you please explain about your ypos-pointer. How and when do you update it.
I'm going to try out your code piece later tonight.
2009-10-22 16:32
WVL

Registered: Mar 2002
Posts: 902
OMG! it's 2009! that means that it's already more than 25 years ago people made moving rasterbars! There's already so much information on the internet that you'll have to find out for yourself.
2009-10-22 16:38
Marauder/GSS
Account closed

Registered: Jul 2006
Posts: 224
Y-Pos must be increased/decreased once per irq, so logical... ^^

oh come on... when g00gle can't find a source-code to a flickerfree rasterbar, then it's impossible to do... didn't you know?? (c;

2009-10-22 17:10
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
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.
2009-10-22 17:27
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.
2009-10-22 19:17
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)
2009-10-22 22:30
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....
2009-10-23 09:04
Stainless Steel

Registered: Mar 2003
Posts: 966
Someone make some interlaced flickering rasterbars, and then convert them to NUFLI please :-D
2009-10-23 12:44
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.
2009-10-23 15:23
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.
2009-10-23 19:35
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!)

:))
2009-10-23 21:37
GT
Account closed

Registered: Sep 2008
Posts: 308
Common guys, it is just a hoax. Don't spend time on it.
2009-10-23 21:49
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
2009-10-23 21:52
GT
Account closed

Registered: Sep 2008
Posts: 308
Do you know what an interrupt is ?
2009-10-23 22:10
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
Please try to help me out with my question if you have the knowledge to explain the problem.
Yes I know what an interrupt is.
2009-10-24 00:46
GT
Account closed

Registered: Sep 2008
Posts: 308
Quote: Please try to help me out with my question if you have the knowledge to explain the problem.
Yes I know what an interrupt is.


Yeah, tell me how a interrupt works. :)
2009-10-24 07:11
MagerValp

Registered: Dec 2001
Posts: 1078
Quote: Please try to help me out with my question if you have the knowledge to explain the problem.
Yes I know what an interrupt is.


That was explained in post #4 in this thread, which you apparently ignored. Stop cutting and pasting code. You need to write it yourself to understand it.
2009-10-24 08:31
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
Magervalp, Parts of the rasterbar code part is written by me. I have also tried to combine it with the original hardware irq vector code also. I have the same problem making it stable and flickerfree with that code.
Please compile and review the code. I need your deep knowledge to fix this.
2009-10-24 08:46
Steppe

Registered: Jan 2002
Posts:
No, you need to switch on your brain.
2009-10-24 11:16
chatGPZ

Registered: Dec 2001
Posts: 11386
the code has still the same problems that have been pointed out earlier in this thread. nothing more to say really.

"The last time I coded the c64 was some 23 years ago. For some reason I remember a lot of things."

hillarious =)


2009-10-24 11:48
Mr. SID

Registered: Jan 2003
Posts: 424
2009-10-24 16:44
Skate

Registered: Jul 2003
Posts: 494
@8bitforever: a quick dirty code for your pleasure. please don't ask any more questions (for a while at least).

	!to "rasterbars.prg",cbm

FIRST_RASTER_POSITION = $30

Y_POSITION = $f0 ; zeropage address

	* = $0801

	; SYS 2061 ($080d)
	!byte $0b, $08, $00, $00, $9e, $32, $30, $36, $31, $00, $00, $00

	* = $080d

	lda #$00
	sta Y_POSITION

	cld
	sei
	lda #$1f
	sta $dc0d
	sta $dd0d

	lda #<irq1
	ldx #>irq1
	sta $fffe
	stx $ffff

	lda #$35
	ldx #$ff
	sta $01
	txs

	lda #$01
	ldx #$1b
	ldy #FIRST_RASTER_POSITION
	sta $d01a
	stx $d011
	sty $d012

	ldy #$c8
	sty $d016

	asl $d019
	lda $dc0d
	lda $dd0d

	cli
	jmp *

irq1
	sta reseta1
	stx resetx1
	sty resety1

	lda #<irq2
	ldx #>irq2
	ldy #FIRST_RASTER_POSITION+1
	sta $fffe
	stx $ffff
	sty $d012
	asl $d019
	tsx
	cli
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop

irq2
	txs

	ldx #$08
	dex
	bne *-1
	bit $ea
	nop

	lda #FIRST_RASTER_POSITION+1
	cmp $d012
	beq start

start
!for i,12 {
	bit $eaea
}
	; draw bars
	ldx #$00
-	lda color_table,x
	sta $d020
	sta $d021
	ldy timing_table,x
	dey
	bne *-1
	inx
	cpx #200
	bne -

	; copy bar colors
	ldx #$00
	ldy Y_POSITION
-	lda color_bar,x
	sta color_table,y
	iny
	inx
	cpx #color_bar_end-color_bar
	bne -

	; move bar position between 0-156
	inc Y_POSITION : opcode1 = *-2
	lda Y_POSITION
	beq +
	cmp #156
	beq +
	jmp ++
+	lda opcode1 ; inc/dec opcode switch
	eor #$20
	sta opcode1

++	lda #<irq1
	ldx #>irq1
	ldy #FIRST_RASTER_POSITION
	sta $fffe
	stx $ffff
	sty $d012
	asl $d019

	lda #$00 : reseta1 = *-1
	ldx #$00 : resetx1 = *-1
	ldy #$00 : resety1 = *-1
	rti

!align 255,0,0

timing_table
!for i,32 {
	!byte 1,8,8,8,8,8,8,8
}

color_table
	!fill 256, 0

color_bar
	!byte $00,$02,$00,$02,$0a,$00,$02,$0a
	!byte $07,$00,$02,$0a,$07,$01,$00,$02
	!byte $0a,$07,$01,$01,$01,$01,$01,$01
	!byte $01,$01,$07,$0a,$02,$00,$01,$07
	!byte $0a,$02,$00,$07,$0a,$02,$00,$0a
	!byte $02,$00,$02,$00
color_bar_end = *
2009-10-24 17:03
Frantic

Registered: Mar 2003
Posts: 1648
Finally "2009" is really 2009, thanks to Skate! I guess, in the future, that we won't even have to surf the solutions up on Google/Forums/etc, but the machines will code the stuff for us instead. But that is for 2010 I guess... ;)
2009-10-24 17:24
Skate

Registered: Jul 2003
Posts: 494
@Frantic: see what happens when he tries to move rasterbars differently :)
2009-10-24 20:36
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
Thanks Skate, I can also make it stable and flickerfree when leaving out the irq3 part from the http://www.ffd2.com/fridge/vic/stableraster.txt.
You just removed that part. Can you make it stable with the irq part3 also ?

Magervalp, see my code below that uses kernal IRQ vector instead of hardware IRQ vector.
Perfectly stable moving flickerfree rasterbar based on the stable raster code http://www.ffd2.com/fridge/vic/stableraster.txt.

This is for you all other hardworking C64 coders that just started to code and want to learn fast like it is in 2009.
My message to the world. Here it is and easy to cut and paste. Secrets from the eighties revealed.


I present to you in ASCII, ready to compile with ACME:


!to "doubleirqrasterbarfinal.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 #$31 ;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 #$32 ;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 #$32 ;RASTER change yet?
cmp $d012
beq start ;If no waste 1 more
;cycle


start ;Start rasterbar


dec $d019

!for I, 16 { 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 #<irq2 ;Set IRQ to point
ldx #>irq2 ;to subsequent IRQ
ldy #$31 ;at line $b8
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


;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








2009-10-25 04:09
chatGPZ

Registered: Dec 2001
Posts: 11386
Quote:
Magervalp, see my code below that uses kernal IRQ vector instead of hardware IRQ vector.
Perfectly stable moving flickerfree rasterbar based on the stable raster code


except it isnt "perfectly stable" at all. you just pushed the flickering part into the borders. this is not bad per se for a simple rasterbar like this, but then again you dont need all that stable raster code at all for it =P
2009-10-25 06:33
MagerValp

Registered: Dec 2001
Posts: 1078
This reminds me of a quote on slashdot:

"Tell me, is there any kind of physical sensation associated with having an abnormally low IQ? Is there like a numbness or heaviness inside your head? Or is the affliction completely transparent to the sufferer?"
2009-10-25 06:57
Voltage
Account closed

Registered: Jul 2008
Posts: 14
@MagerValp: I'm oblivious. What does that mean?
2009-10-25 07:08
Skate

Registered: Jul 2003
Posts: 494
@Voltage: Shift raster timings a little bit and you'll get it. I didn't test 8bitforever's code but if you use stable raster routine without understanding it or at least without obeying some simple rules, it won't be stable anymore. Usually rules are broken by trying to change raster interrupt entry positions or adding/removing some irqs.
2009-10-25 07:10
8bitforever
Account closed

Registered: Oct 2009
Posts: 48

Groepaz, the stable rastercode is going to be used for other things and I should not have used the word perfectly stable.

I would like to give a big special thanks to those of you
how actually contributed with code in their comments:
Jan, Jackasser and Skate.
2009-10-25 21:50
chatGPZ

Registered: Dec 2001
Posts: 11386
"the stable rastercode is going to be used for other things and I should not have used the word perfectly stable."
you should have tried to understand how the code works in the first place. if you just blindly modify it like you did, then you can just aswell omit it completely, there is no difference.
2009-10-25 22:35
Street Tuff

Registered: Feb 2002
Posts: 88
now after you managed to code this hard routine i would like to be pleased if you code a nufli displayer for us.

regards
tuff
2009-10-26 01:11
Voltage
Account closed

Registered: Jul 2008
Posts: 14
Quote: @Voltage: Shift raster timings a little bit and you'll get it. I didn't test 8bitforever's code but if you use stable raster routine without understanding it or at least without obeying some simple rules, it won't be stable anymore. Usually rules are broken by trying to change raster interrupt entry positions or adding/removing some irqs.

Yeah I get the raster bits.

My comment was an attempt at a joke. As in... "Or is the affliction completely transparent to the sufferer?"
2009-10-26 09:41
cavey

Registered: Jul 2002
Posts: 68
fuck. And I thought I was an idiot for reading ripping and disecting a sprite routine many many years ago >_<
2009-10-28 21:15
8bitforever
Account closed

Registered: Oct 2009
Posts: 48
Cavey,
8 hours ago I coded my own four split rasterbar with moving colors within. The colors move with diffrent timing.
It´s all stable and flickerfree. I´m doing progress. :-)
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
Alakran_64
tlr
iAN CooG/HVSC
t0m3000/hf^boom!^ibx
Peacemaker/CENSOR/Hi..
The Syndrom/TIA/Pret..
MWR/Visdom
Mike
wil
Acidchild/Padua
Darkflight
tokra/Akronyme Analo..
Guests online: 122
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 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (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 Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

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