Moving the Picture Origin on the Commodore VIC-20

The VIC-20's VIC chip provides a simple yet flexible video display and one of the features that can be quite useful is the ability to alter the picture origin on the screen. This feature allows us to move the position that the screen displays on the TV up and down or left and right by changing either of two memory locations.

TV Picture Origin

Two memory locations define the TV picture origin.

$9000 (36864)

Horizontal TV picture origin / interlace bit

Bit 7
The interlace bit, which we'll ignore for this article. Default: 0.
Bits 6-0
The horizontal origin. To move the picture origin to the left reduce the number and to move it to the right increase the number. Every change moves the picture by 4 pixels. Default: 5 on NTSC systems, 12 on PAL systems.

$9001 (36865)

Vertical TV Picture Origin

To move the picture origin up reduce the number and to move it down increase the number. Every change moves the picture by 2 pixels. Default: 25 on NTSC systems, 38 on PAL systems.

Simple Vertical Scroll Program

The programs below simply scrolls the screen from a position off the bottom up to the default origin at the top. Both programs store the default location and therefore will work on PAL or NTSC systems.

You may want to run each program with the normal colour scheme as well as with alternative colour schemes which make the scrolling look better. For example to change to a black background and border with yellow text:

POKE 36879,8:POKE 646,7

Basic

10 D=PEEK(36865)
20 FOR X=190 TO D STEP -1
30 POKE 36865, X
40 FOR Y=1 TO 3:NEXT
50 NEXT

Assembler

Below is a simple assembler program to do the same as the Basic program. It could easily be entered using Vicmon, please see Beginning Assembly Programming on the Commodore VIC-20 for more details on how to use it. The program is only small so it could fit in the tape buffer at location 828 ($33C).

      JMP MAIN
DFLT  NOP          ; VAR: Default vertical picture origin minus one
MAIN  LDX $9001
      DEX          ; Decrement picture origin to make loop simpler
      STX DFLT     ; Store default vertical picture origin minus one
      LDA #$BE     ; Begin with picture origin off screen
LOOP  STA $9001    ; Change vertical picture origin
      LDX #$09
WAIT  LDY #$FF
WAI2  DEY
      BNE WAI2
      DEX
      BNE WAIT
      SBC #$01     ; Move picture origin up one
      CMP DFLT     ; Is vertical picture origin back at default?
      BNE LOOP
      BRK

Simple Horizontal Scroll Program

The program below simply scrolls the screen from a position off the right of the screen to the default origin on the left. The program stores the default location and therefore will work on PAL or NTSC systems. As with the vertical scroll program above it is worth experimenting with different screen colours.

Basic

10 D=PEEK(36864)
20 FOR X=60 TO D STEP -1
30 POKE 36864, X
40 FOR Y=1 TO 6:NEXT
50 NEXT

Video of Simple Scrollers

You can see the scrollers being written in Basic and Assembler in the video below:

Creative Commons License
Moving the Picture Origin on the Commodore VIC-20 by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Share This Post

Feedback/Discuss

Related Articles

80 Columns in Software on the Commodore VIC-20

If you have good eyesight, a well-tuned display and patience it is possible to use 80 columns in software on the VIC-20. This is really just an experiment but considering the limitations of the Vic I ...   Read More

64 Column Text Mode on the Commodore VIC-20

With a little lateral thinking and by putting the television on its side we can create a 64 column sideways text mode on the VIC-20. This article will demonstrate this and show how it is done. Previo...   Read More

Getting the Address of BASIC Variables on the VIC-20

Getting the address of a BASIC variable can be useful if you want to pass data to a machine code routine or want to access the bytes of a variable directly to improve speed and reduce garbage collectio...   Read More

Saving and Loading Memory on the VIC-20

Saving and loading memory is quite easy on the VIC-20 once you know how. However, it isn't obvious how to do this and therefore this article will present a few simple ways of doing it from BASIC and A...   Read More

Basic Line Storage on the VIC-20

BASIC programs are stored in memory using a simple structure that we can investigate and manipulate. This article will show how they are stored and contains a BASIC program to go through each line of ...   Read More