10

I am playing with my old C64 and fiddling with with VIC-II registers. I am using the great Programmer's Reference Guide, but there is something I don't quite get.

According to the register map, addres 53272 ($D018) is where pointers are stored, with the bits being

VM13 VM12 VM11 VM10 CB13 CB12 CB11 --

It also says, that to set the character pointer addres, you should set VM13-VM10 as the MSB.

However, the example in the reference guide gives me (at page 104).

POKE53272,(PEEK(53272)AND240)ORA

enter image description here

where A can be 0, 2, 4, 6, 8, 10, 12, 14.

If my calculations are correct though, this is setting CB13 to CB11, and not the VM bits.

What am I missing here?

2
  • True, then again, without linking the whole page - or at least adding a full reference it's hard to say where this got wrong. What is the book are you talking about? There are several books with that name. Also what page. Maybe add a link or better a scan of the relevant page(es).
    – Raffzahn
    Sep 11, 2021 at 20:34
  • @Raffzahn I added a link to the guide, plus page number. Note also that the example works fine. Sep 11, 2021 at 20:46

1 Answer 1

7

[All following references are in relation to the Archive.Org copy of the Commodore 64 Programmer's Reference Guide ISBN 0-672-22056-3]

VM13 VM12 VM11 VM10 CB13 CB12 CB11 --

  • VM13..VM10 define the screen memory (VM -> Video Matrix).

  • CB13..CB11 defines the character image memory aka the character generator image (CB -> Character Base).

It also says, that to set the character pointer addres, you should set VM13-VM10 as the MSB.

The character pointer is a 10 bit counter internal to the VIC, which combined with the Video Matrix (VM13..VM10) gives the memory address where the next character to be displayed is located. See page 436.

The character pointer is nothing one can manipulate (in full). Only the screen address part (VM13..10) can be changed - the pointer (part) to be set.

Similar the character data address is an internal value created from the character base (CB13..11), the character fetched (from screen memory) and the 3 bit row counter. See page 437. It can not be set directly. Only CB13..11 - the pointer (part) to be manipulated.

So which of both pointers do you want to manipulate?

Video Matrix

The area where the VIC fetches the character to be displayed.

To set the screen memory address for the VIC, the upper 4 bits (VM13..10) have to be manipulated as described on Page 102:

POKE 53272,(PEEK(53272) AND 15) OR A

This will set those to the value in A. Valid values are found in the table on top of page 103. Essentially these are the values 0..15 shifted by 4. If your input is not shifted, this can be done with

POKE 53272,(PEEK(53272) AND 15) OR (A * 16)

Character Base

That's where the bitmap image for each character is stored. One byte per scan line, 8 in total. See page 107 Character Definition for more details.

To set the address, where the VIC looks up each fetched character for its bitmap, the next 3 bits (CB13..11) need to be set as shown on page 104:

POKE 53272,(PEEK(53272) AND 240) OR A

This will set those to the value in A. Valid values are found in the table right after of page 104. Essentially these are the values 0..7 shifted left by 1. If your input is not already shifted, this can be done with

POKE 53272,(PEEK(53272) AND 240) OR (A * 2)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .