<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Site-Server v6.0.0-9489d352f302c13358503a431019cc1446f74583-1 (http://www.squarespace.com) on Mon, 26 Aug 2024 20:34:58 GMT
--><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://www.rssboard.org/media-rss" version="2.0"><channel><title>Architecture Articles - Dustlayer</title><link>https://dustlayer.com/c64-architecture/</link><lastBuildDate>Sat, 14 Jun 2014 19:57:08 +0000</lastBuildDate><language>en-US</language><generator>Site-Server v6.0.0-9489d352f302c13358503a431019cc1446f74583-1 (http://www.squarespace.com)</generator><description><![CDATA[]]></description><item><title>Hardware Basics Part 2 - A Complicated Relationship</title><dc:creator>actraiser</dc:creator><pubDate>Tue, 07 May 2013 07:04:17 +0000</pubDate><link>https://dustlayer.com/c64-architecture/2013/5/7/hardware-basics-part-2-a-complicated-relationship</link><guid isPermaLink="false">511651d6e4b0a31c035e30aa:51694044e4b0fdc6c23d4b75:51856bf0e4b0a85f6b8a2cb1</guid><description><![CDATA[<ul>
<li><a href="https://dustlayer.com/c64-architecture/2013/5/7/hardware-basics-part-1-tick-tock-know-your-clock">Hardware Basics Part 1 - Tick Tock, know your Clock</a></li>
<li><strong>Hardware Basics Part 2 - A Complicated Relationship</strong></li>
</ul>

<hr />



  <h3>ϕ - the ruler of the system clock&nbsp;</h3><p>We have learned that various signals are generated somewhere in the Commodore C64, namely the Color Clock, Dot Clock and System Clock. And we also learned that we have exactly one period of the system clock - a so called CPU cycle - to draw 8 pixels to the screen.​&nbsp;</p><p>This already implies that the VIC-II must be somewhat involved during each Cycle - it is our video chip after all. And it actually has a much bigger role than you might expect. In fact I have not explained in the last article how the Dot Clock is transiting to the System Clock other than it is somewhere divided by the number 8.&nbsp;</p><p></p><p><span>You may be surprised to learn that the actual origin of the&nbsp;system clock signal is not the CPU 6510 but in fact the VIC-II. The VIC-II generates all clock frequencies for accessing the data bus for both, itself and the CPU.&nbsp;</span><span>Regulated by our crystal Y1&nbsp;</span><span>the VIC-II receives the Dot Clock signal which it converts to ultimately define the system clock rate which the VIC-II then sends out to the CPU 6510. The 6510 uses this unmodified signal to set the system clock rate for all other components in the system.&nbsp;</span><br></p><p></p><p><span>To get a better imagination, lets look at the VIC-II and the 6510, and I mean that we look at the actual integrated circuits sitting on your C64 main board. A few pins on each of the two chips are connected with each other.&nbsp;</span></p><p><span>​It all breaks down to<strong> the symbol&nbsp;ϕ</strong> which is the Greek letter&nbsp;</span><em>Phi</em><span>&nbsp;and &nbsp;pronounced just like the english word "Fee".&nbsp;</span></p><p>​The VIC-II has three related Pins labeled&nbsp;ϕ0,&nbsp;<span>ϕColor,</span><span>&nbsp;&nbsp;and&nbsp;ϕIN&nbsp;&nbsp;and the CPU 6510 has two Pins labeled&nbsp;</span><span>ϕ1 and&nbsp;</span><span>ϕ2 - the interplay between those signals result in the system wide clock frequency.&nbsp;</span></p><p><span>ϕIN and&nbsp;</span><span>ϕColor are Input Lines where the&nbsp;</span><span>ϕColor pin receives the Color Clock signal and the&nbsp;</span><span>ϕIN pin the Dot Clock signal. The&nbsp;</span><span>ϕ0 pin is an output line that sends out the Dot Clock signal divided by 8. That pin is connected to the CPU 6510 pin labeled 0IN and finally with this received t</span><span>he CPU propagates the unchanged system clock rate of 985.245 kHz on PAL respectively 1022.7 kHz on NTSC machines to all other components via the output pin ϕ2. &nbsp;But it does not end here - we get now to the delicate part of the VIC-II / CPU 6510 relationship.</span></p><h3>Dynamic Logic ​and the two phases</h3><p>From a system wide perspective the ϕ2 signal from the CPU 6510 - also referenced as Phase 2 - is of major importance for timing anything in the system. &nbsp;&nbsp;</p><p><span>The duration of a single period of ϕ2 is further divided into two phases ​- a phase where ϕ2 is set low and a phase where ϕ2 is set high. In the first phase, the low one, the VIC-II is allowed to read from the data bus and in the second phase it is the CPUs turn to access the bus, in fact as opposed to the VIC-II the CPU is eligible for both, read and write access. The two chips can not access the bus at the same time so VIC-II and the CPU have to take turns. This strange sounding principle is in fact an innovation called </span><em>Dynamic Logic</em><span> invented by MOS at a time when accessing the data bus on other systems was done using so-called Static Logic patterns. Effectively Dynamic Logic could be twice as fast as Static Logic implementations when used right.</span><br></p><p>You would now think that VIC-II and CPU 6510 share their phases within ϕ2 and everybody is happy but this is not entirely true. &nbsp;</p><p><span><strong>There are two&nbsp;occasions&nbsp; where the VIC-II actually needs more time than a low phase of&nbsp;</strong></span><span>ϕ2</span><strong>&nbsp;provides:&nbsp;</strong></p><ol><li>At the start of every 8th line starting with the first visible line on the screen the VIC-II needs 40 additional cycles to fetch character pointers.</li><li>When Sprites are involved, the VIC-II needs additional 2 cycles per activated Sprite.</li></ol><p>​Lets think about this. If the VIC-II steals 40 CPU Cycles on every 8th line it means that we only have 23 Cycles left on PAL respectively 25 Cycles left on NTSC machines for CPU instructions on every of those lines. The VIC-II work is not affected of course - after all it just greedily takes all Cycles it needs to complete the Raster Line. Since we have less Cycles for CPU related work left those lines are called <em>Bad Lines</em>. While they are the origin for lots of trouble they also opened up interesting ways to exploit how the VIC-II outputs to the screen.&nbsp;</p><p><span><strong>How does the VIC-II prevent the CPU to take its turn?&nbsp;</strong></span></p><p>Let's look at this diagram illustrating the way of the signals and the lines responsible to manage the&nbsp;<span>ϕ2 phases&nbsp;</span><span>- note that the pins below are not accurately drawn in respect to their real position at either chip.​</span></p>

































































 

  
  
    

      

      
        <figure class="
              sqs-block-image-figure
              intrinsic
            "
        >
          
        
        

        
          
            
              
              
          
            
                
                
                
                
                
                
                
                <img data-stretch="false" data-image="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png" data-image-dimensions="926x494" data-image-focal-point="0.5,0.5" alt="" data-load="false" elementtiming="system-image-block" src="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=1000w" width="926" height="494" sizes="(max-width: 640px) 100vw, (max-width: 767px) 100vw, 100vw" onload="this.classList.add(&quot;loaded&quot;)" srcset="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=100w 100w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=300w 300w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=500w 500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=750w 750w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=1000w 1000w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=1500w 1500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367824802037-XAW4ZFG3YI07MOMUYL73/Screen+Shot+2013-05-06+at+9.19.50+AM.png?format=2500w 2500w" loading="lazy" decoding="async" data-loader="sqs">

            
          
        
            
          
        

        
          
          <figcaption class="image-caption-wrapper">
            <p>​Flow of the various signals to generate the clock rate and to control the Dynamic Logic architecture for memory access.</p>
          </figcaption>
        
      
        </figure>
      

    
  






  <p><strong>Pins involved in the Frequency Flow&nbsp;</strong></p><ol><li>he Y1 Chrystal generates the initial frequency <span>of 14.31818MHz (NTSC) respectively of 17,734475MHz (PAL)T</span></li><li><span>Then the&nbsp;sub-color&nbsp;frequency of </span><span>3.58Mhz (</span><span>NT</span><span>SC) or 4.43MHz (PAL) is sent to the&nbsp;ϕCOLOR pin of the&nbsp;VIC-II to generate the appropriate video output. In a separate process, the Dot Clock Rate of 8.18Mhz (NTSC) respectively 7.88Mhz (PAL) is provided to the ϕIN line of the VIC-II.&nbsp;</span></li><li><span>The Dot Clock signal gets divided by 8 within the VIC-II and moves on via the Output Line&nbsp;ϕ0 to the CPU 6510</span></li><li><span>the 6510 receives the System Clock Rate at&nbsp;ϕ1 and directs it for output to&nbsp;ϕ2 so f</span><span>inally the unmodified System Clock Rate of 1.023MHz (NTSC) or&nbsp;0.985Mhz (PAL)&nbsp;is propagated to all other integrated circuit via&nbsp;ϕ2</span></li></ol><p><strong>Dynamic Logic supporting Pins</strong></p><ul><li>A - the BA pin at the VIC-II is wired to the CPU 6510 RDY pin. If BA is set high we have normal operations and the CPU knows it can do its read/write access to the data bus during a high ϕ2 phase. If the VIC-II needs more cycles because it is for instance fetching Character Pointers on every 8th line, BA is set low and by that RDY on the CPU side becomes low as well. When this happens, the CPU is finishing any remaining write operations and then stops accessing the data bus. &nbsp;</li><li>B - the AEC line signals the current phase within&nbsp;ϕ2. It is set low when the VIC-II accesses the bus and set high when it is the turn of the CPU. When the BA line is set to low, so is the AEC line.</li></ul><p> </p><p></p><h3>How the VIC-II defrauds the CPU 6510</h3><p>From the diagram above you can see that the VIC-II has control over the CPU access to the data bus. It can simply pause the 6510 activity by setting BA low. When the VIC-II has finished its extra work it returns BA to high indicating normal operations. </p><p><strong>Let's recap the order of events during the interplay of VIC-II and CPU 6510:&nbsp;</strong></p><ol><li><strong>Normal Operation: </strong>VIC-II and CPU share happily access to the data bus. When&nbsp;ϕ2 is low, it's the VIC-II turn, when&nbsp;ϕ2 is high, then it is the CPU 6510 turn. As long as the BA line of the VIC-II is set to high, this is what happens.</li><li><strong>VIC-II Stun: </strong>VIC-II &nbsp;needs more time to fetch Character Pointers or take care of Sprites. It ets BA low effectively telling the CPU that it is not supposed to do anything for some time on the data bus. The CPU finishes any remaining write operation which can take between 1-3 Cycles&nbsp;</li><li><strong>VIC-II TakeOver:</strong> After the CPU has finished writing ultimately the VIC-II is in control. It can now read from the data bus as long as required. For fetching Character Pointers that would be a time of 40 Cycles. </li><li><strong>VIC-II Release:</strong> Now that the Character Pointers are fetched, the VIC-II sets BA back to high and the CPU is now informed that we are back to normal operations.&nbsp;</li><li><strong>Back to Normal Operation:</strong> VIC-II and CPU again take turn in accessing the data bus within the two phases of&nbsp;ϕ2 .</li></ol><p> </p><p></p><h3>What is the big deal?</h3><p>The problem with this relationship between the VIC-II and the CPU 6510 are two things. First of all the CPU will finish any write access before it goes into "sleep mode". Write operations take up 1-3 Cycles depending on the instruction. This is an&nbsp;uncertainty we need to handle eventually.&nbsp;And of course, the other problem is that by stealing a number of cycles for VIC-II operations on a Raster Line, we have accordingly less CPU cycles in total left for CPU routines. </p><p>Often this is not an issue but when you reach for the stars and want to build great VIC-II effects which needs to be cycle exact then you need to take Bad Lines eventually into account and figure out how to work around or even with them.&nbsp;</p><p>-act</p><p></p>]]></description></item><item><title>Hardware Basics Part 1 - Tick Tock, know your Clock</title><dc:creator>actraiser</dc:creator><pubDate>Tue, 07 May 2013 07:04:11 +0000</pubDate><link>https://dustlayer.com/c64-architecture/2013/5/7/hardware-basics-part-1-tick-tock-know-your-clock</link><guid isPermaLink="false">511651d6e4b0a31c035e30aa:51694044e4b0fdc6c23d4b75:51856ba6e4b04fc5ce711261</guid><description><![CDATA[<ul>
<li><strong>Hardware Basics Part Part 1 - Tick Tock, know your Clock!</strong></li>
<li><a href="https://dustlayer.com/c64-architecture/2013/5/7/hardware-basics-part-2-a-complicated-relationship">Hardware Basics Part Part 2 - A complicated relationship</a></li>
</ul>

<hr />



  <h3>I see clocks everywhere - what is all this?</h3><p><span>Have you ever wondered why NTSC and PAL Commodore C64 have a different total number of available screen lines or why the NTSC model has a faster system clock rate? Do you know what a clock rate actually is? If not, then the next two articles are a great opportunity for you to shine in the next discussion on the architecture of 8-Bit computers. </span><span>​&nbsp;</span><br></p><p><strong>Y1 &nbsp;- the heartbeat of the Commodore C64</strong></p><p>​It all starts with Y1. Y1 is a crystal oscillator that uses ​the mechanical resonance of a vibrating crystal to create a signal with very precise frequency. Our Y1 Crystal in the Commodore C64 delivers a frequency signal of 14.31818MHz (NTSC) respectively of 17,734475MHz (PAL). This signal is also called the <em>Color Clock</em>.</p>

































































 

  
  
    

      

      
        <figure class="
              sqs-block-image-figure
              intrinsic
            "
        >
          
        
        

        
          
            
              
              
          
            
                
                
                
                
                
                
                
                <img data-stretch="false" data-image="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG" data-image-dimensions="231x287" data-image-focal-point="0.5,0.5" alt="" data-load="false" elementtiming="system-image-block" src="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=1000w" width="231" height="287" sizes="(max-width: 640px) 100vw, (max-width: 767px) 100vw, 100vw" onload="this.classList.add(&quot;loaded&quot;)" srcset="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=100w 100w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=300w 300w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=500w 500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=750w 750w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=1000w 1000w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=1500w 1500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1367908033041-OHQNRZEZCX1BNAFGRM9K/y1_crystal_ntsc.JPG?format=2500w 2500w" loading="lazy" decoding="async" data-loader="sqs">

            
          
        
            
          
        

        
          
          <figcaption class="image-caption-wrapper">
            <p>​The Y1 Crystal on NTSC Machines</p>
          </figcaption>
        
      
        </figure>
      

    
  






  <p><span>Why Color Clock? Why did Commodore use crystals which generate exactly either of those two frequencies? When you divide&nbsp;14.31818 by 4 you get&nbsp;3.579545 and when you divide&nbsp;17.734475 by 4 it results in&nbsp;4.433618.&nbsp;</span><span>Do those numbers eventually ring a bell already?&nbsp;</span><br></p><p>3.58Mhz is the color subcarrier frequency for the NTSC system while 4.43MHz corresponds to the color subcarrier frequency for PAL. Those frequencies are responsible how colors are displayed on our each TV systems. So that's the Color Clock.</p><p>An integrated C64 circuit called a Dual Voltage Controlled Oscillator further generate a 7.88MHz (PAL) respectively&nbsp;8.18MHz (NTSC) <em>Dot Clock</em> from this signal. Of course you wonder what a Dot Clock is.&nbsp;</p><p>A Dot Clock defines how many pixels can be drawn on the screen per each refresh. &nbsp;It is just simple math of the numbers of raster lines multiplied by the system refresh rate multiplied by the number of available pixels per each row. The properties of the C64 screen and the respective color standards lead to the required Dot Clock Rate which the Oscillator will generate for us.&nbsp;</p><p><strong>PAL: 50.125Hz (refresh rate) * 504 Pixels * 312 Lines =&nbsp;7.88MHz<br>NTSC: 59.826Hz (refresh rate) * 520 Pixels * 263 Lines = 8.18MHz</strong></p><p>This difference between PAL and NTSC systems leads to the problem that certain routines written for a PAL C64 may run 20% faster on a NTSC system while NTSC routines seem to be 16% slower on PAL. That is especially notable when comparing many SID musics composed on one machine but played back on the other, e.g. in games or intros. ​Interesting enough, while you would assume that this is a problem of the past, I want to remind you that many videogame console titles from Japan or the US where often not satisfactory adapted for the PAL market. Many PAL games, e.g. on Nintendo 64 ran 16% slower than the NTSC version of the same game on a US or Japanese Console - the reason is sloppy work on adapting to the PAL standard. &nbsp;</p><p>Back to the C64. Luckily many demos and a few games make sure they detect the underlying system correctly and change routines and timing in the code respectively. The common approach for commercial games was to create two versions of a product for NTSC and PAL markets though. This explains why there were so many PAL-Fixes for games across systems in the old days. PAL system owners wanted to play the latest US-Games when they were released and not wait for adapted versions released 6+ months later. Nowadays it is not a problem anymore as HDMI and 60HZ are standard for TVs and supported by all current generation consoles.</p><p>So we have come from the <strong>Color Clock</strong> to the <strong>Dot Clock</strong> and the final destination would be the <strong>System Clock </strong>which defines a <strong>CPU Cycle</strong>. The C64 is an 8-Bit Machine. This limits it to display 8 Pixels per each CPU cycle. One CPU-cycle corresponds therefor to 1/8 of the Dot Clock. Let's confirm this.</p><p><strong>PAL: 7.88MHz / 8 = 0.985Mhz<br>NTSC: 8.18MHz / 8 = 1.023MHz</strong></p><p>This seems to be right with what we read about the system clock rates on Commodore C64 NTSC and PAL machines. </p><p>Congratulations! You are now able explain why the C64 has a certain system clock rate and that one period of this rate corresponds to a CPU Cycle which is the time required to put 8 pixels to the screen. Let's do one more calculation to complete the picture! &nbsp;</p><p>How many CPU cycles do we need to generate one line of Pixels and how many CPU cycles are therefor theoretically required per each screen refresh? We know that 8 Pixels can be drawn per Cycle and we know the number of pixels per line - so this is all easy now.</p><p><strong>PAL: 504 Pixels / 8 = 63 Cycles per Line * 312 Lines = 19656 total CPU Cycles&nbsp;<br>NTSC: 520 Pixels / 8 = 65 Cycles&nbsp;<span>per Line * 263 Lines = 17095 total CPU Cycles&nbsp;</span></strong><span></span></p><p>Those are also numbers you might have encountered already somewhere - even on this site. ​</p><p><span><strong>Why is all this important in the first place?</strong> </span></p><p><span>It is first of all a good prelude to the next part which will further dissect the system clock rate and its origin in a delicate relationship between the VIC-II and the CPU 6510. We will soon learn that 63 available cycles per to be generated raster line on PAL respectively 65 cycles on NTSC machines turn out to be insufficient for certain VIC-II tasks which results in side effects you should be aware of - side effects that will usually be notable in demos and games.</span></p><p>-act</p><p>​</p>]]></description></item><item><title>Ram under Rom - a brief look into C64 memory</title><dc:creator>actraiser</dc:creator><pubDate>Sat, 13 Apr 2013 11:55:49 +0000</pubDate><link>https://dustlayer.com/c64-architecture/2013/4/13/ram-under-rom</link><guid isPermaLink="false">511651d6e4b0a31c035e30aa:51694044e4b0fdc6c23d4b75:516940d7e4b0f45e71c2c619</guid><description><![CDATA[<h3>64k is enough for anyone</h3><p>Imagine the C64 world to be a very long street with exactly 65536 properties. You usually have bungalow with one floor or apartment buildings with two floors occupying each a piece of land. </p><p>Each building has a house number or even a range of house numbers starting from 0 up to&nbsp;65535&nbsp;($0000 - $FFFF).&nbsp;<br></p><p>If we translate the actually kinda weak metaphor to software engineering we have first of all 65536&nbsp;memory locations in your Commodore C64 and each can hold one single byte - this is the C64 RAM. <em>On top</em> of this RAM there are a few areas with read only memory (ROM) &nbsp;which hold the BASIC interpreter, the KERNEL Routines and the Character Generator ROM. Last but not least there are some &nbsp;I/O mapped areas which basically means that memory locations are mapped to features in the I/O chips, e.g. in the SID and VIC-II. This overlapping memory design is often referred&nbsp;as "RAM under ROM" and addressing chips via memory address registers is called memory-mapped I/O.</p><p>That also means that as a C64 coder you for the most part are concerned about&nbsp;reading or writing to some location in memory.&nbsp;</p><h2>​</h2>
<h3>The Memory Layout when the C64 is turned on</h3><p>The initial memory configuration when turning on the C64 is targeted to BASIC programmers though there is 4Kbyte of RAM not used by BASIC and dedicated for machine language ​from $C000 to $CFFF. For games and demo programming, this is obviously not the best configuration though.</p>

































































 

  
  
    

      

      
        <figure class="
              sqs-block-image-figure
              intrinsic
            "
        >
          
        
        

        
          
            
              
              
          
            
                
                
                
                
                
                
                
                <img data-stretch="false" data-image="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png" data-image-dimensions="703x509" data-image-focal-point="0.5,0.5" alt="" data-load="false" elementtiming="system-image-block" src="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=1000w" width="703" height="509" sizes="(max-width: 640px) 100vw, (max-width: 767px) 100vw, 100vw" onload="this.classList.add(&quot;loaded&quot;)" srcset="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=100w 100w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=300w 300w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=500w 500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=750w 750w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=1000w 1000w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=1500w 1500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365874439435-TWP321ZYYXWIT32H4EXM/memory_map.png?format=2500w 2500w" loading="lazy" decoding="async" data-loader="sqs">

            
          
        
            
          
        

        
          
          <figcaption class="image-caption-wrapper">
            <p>The C64 Memory Configuration when turning on the machine.&nbsp;</p>
          </figcaption>
        
      
        </figure>
      

    
  






  
<p>To read from addresses which are located under ROM you have to briefly switch out a portion of ROM overlapping that area. &nbsp;If you would not do that, any READ access to those locations will &nbsp;return values from ROM but writing to the same addresses will put information into the respective RAM under ROM.<br></p><p>​As opposed to other 8bit-computers using the 6502 processor, the C64 has a slightly modified version of the CPU called 6510. The only significant difference to the standard 6502 is the possibility to choose between different memory layouts which makes the Commodore C64 very flexible. This is feature you use to switch out ROM overlapping RAM as required.&nbsp;</p>
<h3>​Mapping to the Chipset</h3><p>There is a special block of ROM overlapping the RAM from $D000 to $DFFF. First of all, there is the 4K large Character Generator ROM. The name sounds more complicated than it actually is. This area simply carries all available characters and symbols you can put on your screen using your C64 keyboard. Actually it's four different character sets each 1K in size. Since one single character is made of a 8x8 bits matrix every 1K-set holds 128 single chars. Not all chars are alphanumeric though, as there are also tons of different symbols available to print to the C64 screen. Additionally there are different version of each character stored in the Character Generator ROM: shifted, unshifted and reversed where reversed means that background color and character color are replaced with each other. &nbsp;</p><p>In the same address space starting at $D000 the I/O mapping to the C64 chips take place. The Video Controller VIC-II, the SID and also both CIAs are simply accessed ​by reading and writing to memory adresses in that area. The 1000 bytes of Color RAM maps the positions in Screen RAM 1:1. This means you can define colors in any position of the 40x25 screen matrix. Of each Color RAM byte only the lower nibble is actually used so smart programmers can utilize another 512 bytes by using the higher nibble of each Color RAM byte for something different. &nbsp;</p><p>​</p>

































































 

  
  
    

      

      
        <figure class="
              sqs-block-image-figure
              intrinsic
            "
        >
          
        
        

        
          
            
              
              
          
            
                
                
                
                
                
                
                
                <img data-stretch="false" data-image="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png" data-image-dimensions="782x581" data-image-focal-point="0.5,0.5" alt="" data-load="false" elementtiming="system-image-block" src="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=1000w" width="782" height="581" sizes="(max-width: 640px) 100vw, (max-width: 767px) 100vw, 100vw" onload="this.classList.add(&quot;loaded&quot;)" srcset="https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=100w 100w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=300w 300w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=500w 500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=750w 750w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=1000w 1000w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=1500w 1500w, https://images.squarespace-cdn.com/content/v1/511651d6e4b0a31c035e30aa/1365876400312-Q5C65GKYBSIYSOXGQ82Q/dustlayer.com-io-map.png?format=2500w 2500w" loading="lazy" decoding="async" data-loader="sqs">

            
          
        
            
          
        

        
          
          <figcaption class="image-caption-wrapper">
            <p>The i/O Map &nbsp;- The memory area from &nbsp;$D000 to $DFFF is pretty crowded</p>
          </figcaption>
        
      
        </figure>
      

    
  






  <h2>Summary</h2><p> </p><ul><li>There is 64 Kbyte RAM...</li><li>... plus 20 Kbyte ROM (Read Only) for BASIC, KERNEL and Character Generator ROM sharing address information with RAM</li><li>To read any byte in RAM which is "under ROM" you have to switch out the section of ROM which overlaps that particular RAM area. This ROM switching concept is the major difference between the 6510 CPU in the C64 and the 6502 CPU used in other 8Bit-Computers. The concept also allows many different memory configurations which can be optimized towards whatever use case needs to be taken care of.</li><li>The I/O chips are memory-mapped. You access features of SID, VIC-II etc by reading and writing to memory addresses.</li></ul><p><strong>Update June 14, 2014:<em> </em></strong><em>In an earlier version I mistakenly assumed that there might be an additional 512 Bytes of spare bytes available due to the fact that Color RAM only uses one Nibble to set color information. As it turned out (thanks&nbsp;</em>Csaba<em>!), the Color RAM is organized as 1024x4 Bit Static RAM, so there is no High Nibble to access, hence, there is no spare RAM here.</em></p><p> </p>























<input onclick="history.back(-1)" type="button" value="back" />]]></description></item></channel></rss>