programming a smooth scroll routine on the c64

  • Thread starter Thread starter replayuk
  • Start date Start date
  • Replies Replies 8
  • Views Views 333

replayuk

New member
Joined
Jul 4, 2014
Posts
81
Country
england
Region
lancashire
i`m just getting into this so be nice.

at the moment without much, i`m just moving the char`s to the left step by step...i`m using the action replay mrk 6, so please if you post code to scroll keep it to the real c64 code not vice or any other method!

I do have the expert cartridge with and without esm not as tho it matters!

ok

to scroll left char by char! i`m up to this!

1000 ldx%$00
1002 lda$07c1,x
1005 sta$07c0,x
1008 inx
1009 cpx%$27
100b bne$1002
100d rts

this scrolls chars accross the bottom part of the screen one by one until it reaches 27 chars across the bottom screen.
its a start i tried it and it works.

Now i want to pick up chars from a memory location place it on the screen and scroll it for now,

After this add raster intrupts and smooth scroll the screen !

any help would be nice, but as i say i`m in action replay 6 , i dont use any vice just pure.

thankyou everyone
 
not got my coding head on as I used to do this stuff but alas over 30 years ago :) .. but.

you want to move the whole screen via raster interrupt just above your scroller and putting it back just below, you can move the screen 8 pixels in any direction in time with the vsync then every 8th pixel you move it back to the start and move a whole character.

this gives you a pixel smooth scroll :) the one you are doing would scroll so fast you would really have no time to read it.

if i get my head on i want to have ago at this also see how much i remember (or forgotten). some of the things I used to do is beyond me now, I used to add drums (from microrhythm) to sid chip game songs, sanxion with heavy metal drum set :)
I used to crack games, make my own tape loaders with custom loading screens and music,,

I wouldn't know where to start now lol.

if you haven't already got one get the bible for all C64 coders "Commodore 64 Programmers Reference Guide"
 
Last edited:
First of, forget AR6 and doing it directly on C64. Why? ASM is evil, it so easy overwriting your code and you'll have to start over. Nowadays, it is much more convenient to use cross assembler and test it on VICE. Then do final tests on the real thing.

You are currently moving one line of characters per character, 8 pixels at a time. You need to create inner loop first (tie it to the vertical blank), and using hardware scrolling scroll it 1 pixel at a time. When you scroll it 8 times, move complete char like you are doing now. At the end just copy next character from your text message elsewhere in memory to the end of the line. Repeat everything. Do not forget to check for the end of your text message. Move to the beginning of text, when you reach the end.
 
Code:
[FONT=Consolas]* = $0801
          
Scroll_Txt_P1 = $fc
Scroll_Txt_P2 = $fd

IRQ1          = $0314
IRQ2          = $0315

Screen_Line7  = $04f0

Screen_Ctrl1  = $d011
Raster_Line   = $d012
Screen_Ctrl2  = $d016
Raster_Ack    = $d019
Raster_Int    = $d01a

IRC_Status    = $dc0d

ClearScreen   = $e544

StandardIRQ1  = $ea31
StandardIRQ2  = $ea81
      
* = $1000
;---------------------------------------
;--- Intro Entry Point               ---
;---------------------------------------

          sei
          jsr ClearScreen    ; Clear the screen
          
          lda #$7f           ; "Switch off" interrupts signals from CIA-1 
          sta IRC_Status
          lda IRC_Status
          
          lda #<Interrupt_1
          sta IRQ1    
          lda #>Interrupt_1
          sta IRQ2
          
          lda #$01           ; Enable raster interrupt signals from VIC 
          sta Raster_Int
          sta Raster_Ack     ; "Acknowledge" the interrupt by clearing the VIC's interrupt flag

          lda Screen_Ctrl1   
          and #$7f
          sta Screen_Ctrl1   ; Clear most significant bit in VIC's raster register 
          
;---------------------------------------
;--- Set pointers to Scroll Text     ---
;---------------------------------------

          lda #<Scroll_Text
          sta Scroll_Txt_P1
          lda #>Scroll_Text
          sta Scroll_Txt_P2
          
          cli

          jmp *

;---------------------------------------
;--- 1st Interrupt                   ---
;---------------------------------------
          
Interrupt_1
          
          lda Horizontal_Scroll_Ctr
          sta Screen_Ctrl2
          
          lda #<Interrupt_2
          sta IRQ1
          lda #>Interrupt_2
          sta IRQ2
          
          lda #$6a ; about screen line 8
          sta Raster_Line
          lda #$01
          sta Raster_Ack
          jmp StandardIRQ2

;---------------------------------------
;--- 2nd Interrupt                   ---
;---------------------------------------
          
Interrupt_2

          lda #$08               ; 1000 (40 columns on)
          sta Screen_Ctrl2

          dec Horizontal_Scroll_Ctr
          bpl Interrupt_2_Exit
          
          ldx #$00
Interrupt_2_Loop_1
          lda Screen_Line7+$1, x
          sta Screen_Line7, x
          inx
          cpx #$28
          bne Interrupt_2_Loop_1
          
          lda #$07
          sta Horizontal_Scroll_Ctr
          
          ldy #$00
Interrupt_2_Loop_2
          lda ( Scroll_Txt_P1 ), y
          and #$3f
          bne Horizontal_Scroll_End
          
          lda #<Scroll_Text
          sta Scroll_Txt_P1            
          lda #>Scroll_Text   
          sta Scroll_Txt_P2              
          jmp Interrupt_2_Loop_2
          
Horizontal_Scroll_End

          inc Scroll_Txt_P1
          bne Horizontal_Scroll_Add
          inc Scroll_Txt_P2
          
Horizontal_Scroll_Add

          sta Screen_Line7+$27

Interrupt_2_Exit
          
          lda #<Interrupt_1
          sta IRQ1
          lda #>Interrupt_1
          sta IRQ2
          
          lda #$62 ; about screen line 7
          sta Raster_Line
          
          lda #$01
          sta Raster_Ack
          
          jmp StandardIRQ2

;---------------------------------------
;--- Counter for Horizontal Scroll   ---
;---------------------------------------
          
Horizontal_Scroll_Ctr
          !byte $07

;---------------------------------------
;--- Scroll Text                     ---
;---------------------------------------

Scroll_Text
          !text "MRR19129170 SAYS THIS IS HOW YOU DO IT..."
          !byte $00[/FONT]
 
Whilst we're on the subject of C64 assembler / demo coding (which we are I suppose), there was a 'sweet spot' for colour fades in and out for text / sprites.
You could use the c64's white, gray and black but there are other sets of colours that you could use, blue and red were included in it.

Anybody remember coding these into your scrollers / greetings screens?? What colours did you go for??
 
I'd have to look in my source, but from memory & http://www.c64-wiki.com/index.php/Color :

Code:
Blues   : 06 14 03 01
Greens : 05 13 07 01
Greys : 11 12 15 01
Golds : 09 08 07 01
Reds : 02 04 10 01

You can also mix browns and greens to yellow (09 08 13 05 07 01). rainbow (02 10 08 07 03 14 06 05)

From source:
Code:
          !byte $0B,$0B,$0C,$0C,$0F,$0F,$01,$0F,$0F,$0C,$0C,$0B,$0B ; GREY
          !byte $00,$00,$00
          !byte $06,$06,$0E,$0E,$03,$03,$01,$03,$03,$0E,$0E,$06,$06 ; BLUE
          !byte $00,$00,$00
          !byte $09,$09,$08,$08,$07,$07,$01,$07,$07,$08,$08,$09,$09 ; BROWN
          !byte $00,$00,$00
          !byte $02,$02,$0A,$0A,$0D,$0D,$01,$0D,$0D,$0A,$0A,$02,$02 ; RED
          !byte $00,$00,$00


or

          !byte $0B,$0C,$0F,$01,$0F,$0C         ; DK GREY/GREY/LT GREY/WHITE
          !byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; BLACK
          !byte $0C,$0F,$01,$0F,$0C,$0B         ; GREY/LT GREY/WHITE
          !byte $00,$00,$00                     ; BLACK
          !byte $06,$0E,$03,$01,$03,$0E         ; BLUE/LT BLUE/CYAN/WHITE
          !byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; BLACK
          !byte $0E,$03,$01,$03,$0E,$06         ; LT BLUE/CYAN/WHITE
          !byte $00,$00,$00
 
I never got around to programming a smooth scroll, but i did manage to program a machine code scroll right down at the bottom of the screen.
I used the action replay Mrk6 i think, I`m guessing by the code some are listing in this thread your using some kind of emulator.

It would have been great to see code used to program the smooth scroll in the normal 1980`s fashion when emulators didn`t exist.

Great comments from everyone i enjoyed reading all of them thanks guys.
 
There are proper macro assemblers you can use directly on the C64 without needing to use monitors or emulators. When did the first useful version of Turbo Macro Assembler or something similar come out for the C64?

This is a recent version with many updated features (there's a version to use on a plain C64):
http://style64.org/release/turbo-macro-pro-sep06-style
 
Last edited:
This was initially written directly in a HEX monitor (Expert cartridge) in my bedroom on a C64 and colour TV when I was a kid, and rewritten/reversed for fun to answer the post.
 
Back
Top Bottom