53272

From C64-Wiki
Jump to navigationJump to search

Address 53272 ($D018) is a VIC-II register that generally tells the graphics chip where to "look for graphics", in conjunction with both the text screen and with bitmap graphics.

The text screen[edit | edit source]

When in text screen mode, the VIC-II looks to 53272 for information on where the character set and text screen character RAM is located:

  • The four most significant bits form a 4-bit number in the range 0 thru 15: Multiplied with 1024 this gives the start address for the screen character RAM.
  • Bits 1 thru 3 (weights 2 thru 8) form a 3-bit number in the range 0 thru 7: Multiplied with 2048 this gives the start address for the character set.

Try pasting following code into your favourit C64 emulator just started (use ALT+insert in Vice), then press ENTER, then type RUN and type ENTER:

100 print "vic-ii character memory locator"
105 print chr$(147)
110 print "------------------------------"
130 v=peek(53272) : rem read the value from 53272
140 print "value at 53272 = ";v;
150 b = v
160 l = 7
170 print " (bin "; : gosub 3000
180 print ")"
200 rem calculate screen ram address
210 s=int(v/16) : rem get the 4 most significant bits
220 print "4 msb: "; s; "dec ";
230 b = s
240 l = 4
250 print "(bin "; : gosub 3000
260 a=s*1024
270 print ")"
280 print "screen ram address: ";a
300 rem calculate character set address
310 c=(v and 14)/2 : rem get bits 1-3
320 print "3 lsb: "; c; "dec";
330 b = c
340 l = 3
350 print " (bin "; : gosub 3000
360 a=c*2048
370 print ")"
380 print "character set address: ";a
400 end
3000 rem binary conversion
3010 n$ = ""
3020 for i=7 to 0 step -1
3030 rem if i < l then goto 3060
3040 n$ = n$ + chr$(48 + int(b/2^i))
3050 b=b-(int(b/2^i)*2^i)
3060 next i
3070 print right$(n$,l);
3080 return 

Result:

------------------------------
value at 53272 =  21  (bin 0010101)
4 msb:  1 dec (bin 0001)
screen ram address:  1024
3 lsb:  2 dec (bin 010)
character set address:  4096


Bitmap mode[edit | edit source]

In bitmap mode, 53272 is used to indicate the start address of the bitmap itself, and of the color information to go with the bitmap. Note that with the bitmap in multicolor mode, one of the available colors are always located in the character color RAM, regardless of the contents of 53272.

  • The four most significant bits form a 4-bit number in the range 0 thru 15: Multiplied with 1024 this gives the start address for the color information.
  • Bit 3 indicates whether the bitmap begins at start address 0/$0 (bit set to "0"), or at 8192/$2000 (bit set to "1").

VIC banks[edit | edit source]

Notice that all the start addresses of character sets, screen character RAM, bitmaps, and color information, are all relative to the start address of the current VIC bank!.