Copy Link
Add to Bookmark
Report

Scrolling Text

Assembler coding - Lesson 8

eZine's profile picture
Published in 
Assembler coding
 · 24 Nov 2022

Enough of Sprites for the moment, in this lesson we will learn how to scroll text across the screen from right to left.

Lets explain a bit more about this. Firstly the C64 has 40 columns, each character is in one of these columns. This means you have a maximum of 40 characters on one line or row across the screen.

When you want to do a scroll however, in any direction, you need to place the new character at the far side of the screen where the scroll starts. But, if you are in 40 column mode you would be able to see the new data being placed on the screen totally messing up the effect of the smooth scroll. So what you do is place the C64 into 38 column mode. This expands the border by 1 character at either side.

The next process is to shift the entire row of 40 characters one place left (for a left scroll that is). You then place the next character, move the entire row left again, and so on.

Well enough of this, lets do the code:

  10 ORG 8192 
20 LDA #147
30 JSR $FFD2
40 LDA #23
50 STA 53272
60 LDA #00
70 STA 53280
80 STA 53281
90 STA MESSPO
100 SCROLL LDA 53270
110 ORA #07
120 AND #247
130 STA 53270
140 NOTZERO LDX MESSPO
150 CHARS LDA MESS,X
160 CMP #93
170 BNE NOTDONE
180 LDA #00
190 STA MESSPO
200 JMP SCROLL
210 NOTDONE STA 1983
220 INC MESSPO
230 LDX #00
240 INITDONE JSR DELAY
250 DEC 53270
260 INX
270 CPX #07
280 BNE INITDONE
290 LDX #00
300 LDY #01
310 NEXT LDA 1944,Y
320 STA 1944,X
330 INY
340 INX
350 CPX #39
360 BNE NEXT
370 JMP SCROLL
380 DELAY LDA #50
390 STA TIMER
400 LOOP1 LDY #50
410 LOOP DEY
420 DEY
430 BNE LOOP
440 DEC TIMER
450 BNE LOOP1
460 RTS
470 MESSPO DFB 00
480 TIMER DFB 00
490 MESS DFM "HELLO THERE FROM ROB & BJOERN OF 8 BIT CORE ............]"

Ok, lets begin with the discussion on how it works.


10 Sets the program origin (I have not put this in all programs, but you have to)

20 & 30 Clear the screen

40 & 50 Switch characters to lowercase

60 - 90 Border & Background to colour black, and also set the label MESSPO to zero. This is the pointer to the message data

100 - 130 This turns on the last 3 bits of 53270 and sets the remaining 5 to zero. This turns on 38 column mode and gets ready for smooth scrolling left. (we decrement this from 7 to 0 and each time we do, each character is smooth scrolled by one pixel left. This is how you get the smooth scroll).

140 - 200 Here we load the X register with the message pointer (MESSPO) and then load the character data from the location of the message (MESS + X) like in lesson 2. We then check to see if the character is ] (Value 93), this means the end of the message. If it isn't branch to NOTDONE, otherwise reset message pointer and start again.

210 This line places the character at the far right of the screen.

220 Here we increment the message pointer MESSPO by 1 ready for the next character

230 - 280 Here we use a little routine to decrement the last 3 bits of 53270 (as described earlier to give us a 1 pixel scroll left for all characters). The routine again uses a subroutine to provide delay time.

300 - 370 This part is quite clever. We set X = 0, Y = 1. We then load from the row we are working on, i.e. (FARLEFT + Y) or (1944 + Y) in our example. Well Y = 1 so we actually load the value from 1945. We then place it at (1944 + X) and as X = 0, we place this data at 1944. We then increase X and Y by one and continue up the row moving the characters down the row one by one. REMEMBER you must START at the OPPOSITE end to where your scroll begins, otherwise you will ERASE your character data.

380 - 460 This is the delay subroutine

470 & 480 These setup memory locations for the assembler

490 Defines the message


This is a cool little program, I love scrolls. BTW if you want to scroll in the right direction, you simply increment from 0 to 7 for 53270, place your data at the left and move the data starting from the RIGHT side of the screen. Just the reverse of we did here.

After running this program, you will find again that you get glitchy operation. Again we use interrupts to remedy this. With interrupts we could also have the screen split into 2 parts. One having a LEFT scroll, the other having a RIGHT scroll.

I think its about time we saw these interrupts ...

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT