{{htmlmetatags>metatag-robots=()
metatag-title=(Memory layout used by MIDRES library)
metatag-keywords=(C,library,Midres,Animation,Tiles,Commodore 64,Commodore VIC20,Commodore 16)
metatag-description=(MIDRES library tries to exploit the similarities between different chipsets and architectures. One of the similarities is the memory mapping of the various features.)
metatag-media-og:image=(:midres_library:memory_layout_vic20_unexpanded.png)
metatag-og:title=(Memory layout used by MIDRES library)
metatag-og:description=(MIDRES library tries to exploit the similarities between different chipsets and architectures. One of the similarities is the memory mapping of the various features.)
}}
====== MEMORY LAYOUT USED BY MIDRES ======
In order to make the compiled code as efficient as possible, the [[:midres_library|MIDRES library]] introduces the fewest possible abstractions. In particular, it tries to exploit the similarities between different chipsets and architectures. One of the similarities is the memory mapping of the various features.
Therefore, here below we give a series of functional mapping primitives and their relative in-memory deployment for the various architectures.
----
===== FUNCTIONAL MAPPING =====
==== START ADDRESS =====
Each architecture has a starting address where the compiled C code (the assembly code) begins. As a rule, it begins at the start of the equivalent BASIC program. In fact, the cc65 compiler generates the appropriate "loader" which is nothing more than a "SYS" towards the first assembly instruction.
Sometimes, due to the overlap between the graphics memory and the BASIC program, it was necessary to relocate the starting address to a different location. In this case, a small loader (written in BASIC) is attached, which takes care of loading from disk the assembly in the correct location before starting it.
==== SCREENS =====
This type of memory maps a surface of letters (or "tiles") made up of a certain number of rows and columns. Each letter (or "tile") is represented by an 8-bit unsigned number. This number represents an index in the special memory (see below).
==== TILESETS =====
This type of memory contains the pixel-by-pixel and monochrome representation of each letter (or "tile") indicated by the 8-bit unsigned number, as present in video (text) memory (see above).
==== BITBLITS =====
This type of memory can be used by displacement primitives (or "bitblits"), and does not necessarily correspond to anything visible on the screen.
----
===== ARCHITECTURES =====
==== COMMODORE VIC 20 (unexpanded) ====
* **START ADDRESS:** $1000
* **SCREENS**: 1
* **TILESETS**: 4 (4 ROM)
* **BITBLITS**: 0
{{ :midres_library:memory_layout_vic20_unexpanded.png?nolink |}}
----
==== COMMODORE VIC 20 (32KB expansion) ====
* **START ADDRESS:** $2000
* **SCREENS**: 7
* **TILESETS**: 7 (3 RAM + 4 ROM)
* **BITBLITS**: 6
{{ :midres_library:memory_layout_vic2024.png?nolink |}}
----
==== COMMODORE 64 ====
* **START ADDRESS:** $0801
* **SCREENS**: 16
* **TILESETS**: 6 (4 RAM + 2 ROM)
* **BITBLITS**: 15
{{ :midres_library:memory_layout_c64.png?nolink |}}
----
==== COMMODORE 16 ====
* **START ADDRESS:** $1000
* **SCREENS**: 3
* **TILESETS**: 8 (4 RAM + 4 ROM)
* **BITBLITS**: 2
{{ :midres_library:memory_layout_c16.png?nolink |}}
----
==== COMMODORE PLUS/4 ====
* **START ADDRESS:** $4000
* **SCREENS**: 7
* **TILESETS**: 15 (11 RAM + 4 ROM)
* **BITBLITS**: 6
{{ :midres_library:memory_layout_plus4.png?nolink |}}