Moving the Picture Origin on the Commodore VIC-20

  /     /   Commodore     Programming     Retro     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.

Related Articles

Changing Screen Dimensions on the Commodore VIC-20

To make the most of the limited amount of memory on the VIC-20, we can increase and decrease the screen size depending on our program's priorities and what we want to achieve. If we increase the size ...   Read More

40 Columns in Basic on the Commodore VIC-20

There are a number of programs that allow you to use 40 columns of text from Basic on a Commodore VIC-20. This can be useful as by default the Vic's screen is 22 columns by 23 rows. They are supplied...   Read More

Adding a Basic Stub to a VIC-20 Assembly Language Program

To make machine language programs more friendly it is nice to add a basic stub which contains a line with a SYS statement to start the code. This is easy to do on the Vic-20 and the process gives you ...   Read More

Creating a TTY Simulator in Assembly Language on the VIC-20

The Vicmon machine language cartridge is an excellent tool for exploring the Vic-20. This article and its associated video will show you how to use it to create a simple program that will change the n...   Read More

Beginning Assembly Programming on the Commodore VIC-20

The Commodore Vic-20 is a great machine to learn an assembly language on. It was released in 1981 and was the first computer to sell one million units, which contributes to its popularity today. The ...   Read More

Sign up to get new articles straight to your inbox.

Delivered by FeedBurner

Comments

blog comments powered by Disqus