Advertisement
Meneer_Jansen

Part 1. General (My notes on the Commodore 64)

May 20th, 2020 (edited)
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.93 KB | None | 0 0
  1. _____ _ ____ __ _ _
  2. |_ _| |__ ___ / ___/ /_ | || |
  3. | | | '_ \ / _ \ | | | '_ \| || |_
  4. | | | | | | __/ | |__| (_) |__ _|
  5. |_| |_| |_|\___| \____\___/ |_|
  6. __ __ _ _ _ _ _
  7. \ \ / /_ _| | | _| |_| |__ _ __ ___ _ _ __ _| |__
  8. \ \ /\ / / _` | | |/ / __| '_ \| '__/ _ \| | | |/ _` | '_ \
  9. \ V V / (_| | | <| |_| | | | | | (_) | |_| | (_| | | | |
  10. \_/\_/ \__,_|_|_|\_\\__|_| |_|_| \___/ \__,_|\__, |_| |_|
  11. |___/
  12.  
  13. Personal notes from "MeneerJansen"
  14. PM me via www.lemon64.com/forum
  15. The most recent version of this text file
  16. can be found on: https://pastebin.com/hmpJmurr
  17.  
  18.  
  19.  
  20. o==========o
  21. | CONTENTS |
  22. o==========o
  23.  
  24. P A R T 1 : G E N E R A L
  25.  
  26. pastebin.com/hmpJmurr
  27.  
  28. A. Introduction
  29.  
  30. B. Recommended literature
  31.  
  32. X. References
  33.  
  34.  
  35. P A R T 2 : M E M O R Y M A P O F T H E C 6 4
  36.  
  37. pastebin.com/XjwVy4pD
  38.  
  39. A. General table
  40.  
  41. B. How RAM is used by CPU and VIC
  42.  
  43. C. VIC memory banks
  44. 1. General
  45. 2. Bank positions in RAM
  46. 3. Character ROM access
  47.  
  48. D. I/O memory map
  49.  
  50. X. References
  51.  
  52.  
  53. P A R T 3 : T H E V I C C H I P
  54.  
  55. pastebin.com/wsY1zDmY
  56.  
  57. A. Memory banks (reprise)
  58.  
  59. B. RAM, ROM, CPU and VIC
  60. 1. RAM vs. CPU/VIC access
  61. 2. CPU: switch between I/O and char ROM
  62. 3. I/O memory map
  63. 4. The 47 VIC registers
  64.  
  65. C. Memory types
  66. 1a. Character (generator) ROM
  67. 1b. Character memory/RAM (replacement for ROM)
  68. 2. Bitmap
  69. 3. Screen RAM/scr mem/video matrix/vid RAM (char position)
  70. 4. Color RAM (char color)
  71. 5. Bank config examples
  72.  
  73. D. Discussion
  74.  
  75. E. Bug
  76.  
  77. X. References
  78.  
  79.  
  80. P A R T 4 : D I S P L A Y M O D E S
  81.  
  82. pastebin.com/tjPEr8Bq
  83.  
  84. A. Introduction
  85.  
  86. B. Standard text mode
  87.  
  88. C. Bitmap single color
  89.  
  90. D. Bitmap multicolor
  91.  
  92. E. Multicolor text mode
  93.  
  94. F. ECM text mode
  95.  
  96. X. References
  97.  
  98.  
  99. P A R T 5 : S P R I T E S
  100.  
  101. pastebin.com/MAWHB9Xg
  102.  
  103. A. Activate & define
  104.  
  105. B. Position
  106.  
  107. C. Position beyond 255
  108.  
  109. D. Expand sprites
  110.  
  111. E. Collision detection
  112.  
  113. F. Multicolor
  114.  
  115. Y. Registers
  116.  
  117. X. References
  118.  
  119.  
  120. P A R T 6 . T H E S I D C H I P
  121.  
  122. pastebin.com/MZvuRWw5
  123.  
  124. A. Introduction
  125. 1. General
  126. 2. Music
  127. 3. Samples
  128.  
  129. B. SID models
  130.  
  131. C. Input/output
  132. 1. How to play
  133. 2. Use voice 3 as modulator
  134.  
  135. X. References
  136.  
  137.  
  138. P A R T 7 : S O M E A S S E M B L Y N O T E S
  139.  
  140. pastebin.com/PLvNc6tD
  141.  
  142. A. Some mnemonics
  143.  
  144. B. RAM locations
  145.  
  146. C. Masking
  147.  
  148. D. Self modifying code
  149.  
  150. E. Error codes
  151.  
  152. F. Writing under Kernal ROM bug
  153.  
  154. G. Indirect indexed addressing
  155.  
  156. Z. All opcodes
  157.  
  158. Y. Tips
  159.  
  160. X. References
  161.  
  162.  
  163. P A R T 8 . T U R B O M A C R O P R O
  164.  
  165. pastebin.com/w8VCLbEx
  166.  
  167. A. TMP with and without a REU
  168. 1. General
  169. 2. Memory map
  170.  
  171. B. Status line & tips 'n hints
  172. 1. Status line
  173. 2. Tips/hints
  174.  
  175. C. A REU in general
  176.  
  177. D. BASIC ROM shadowing
  178.  
  179. E. The jump from 140_hex
  180.  
  181. F. TMP: REU banks and RAM
  182. 1. General
  183. 2. TMP's four states
  184.  
  185. G. Appendix: Set colors for TMP
  186.  
  187. X. References
  188.  
  189.  
  190.  
  191. A P P E N D I X A : U S E C U S T O M F O N T S
  192.  
  193. pastebin.com/Ac9E82MF
  194.  
  195. A. General
  196. 1. Procedure
  197. 2. Example using VIC bank 0
  198. 3. Example using VIC bank 2
  199. 4. Example using VIC bank 3
  200.  
  201. B. BASIC
  202.  
  203. C. Assembly
  204.  
  205. X. References
  206.  
  207.  
  208. A P P E N D I X B : P E T S C I I
  209.  
  210. pastebin.com/EE826WT7
  211.  
  212. A. Character ROM (reprise)
  213.  
  214. B. PETSCII
  215.  
  216. X. References
  217.  
  218.  
  219. A P E N D I X C : F I L E M A N A G E M E N T
  220.  
  221. pastebin.com/KWh5aXcr
  222.  
  223. A. General
  224.  
  225. B. When channel is still open
  226.  
  227. X. References
  228.  
  229.  
  230. A P E N D I X D : S C A N L I N E S
  231.  
  232. pastebin.com/Xd2inZjv
  233.  
  234. A. Scan lines
  235.  
  236. B. Raster time
  237.  
  238. C. Bad line
  239.  
  240. D. Some calculations
  241.  
  242. X. References
  243.  
  244.  
  245. -<>-<>-<>-<>-<>-<>-<>-
  246.  
  247.  
  248.  
  249.  
  250.  
  251. .---------------------------.
  252. ( P A R T 1 . G E N E R A L )
  253. `---------------------------´
  254.  
  255.  
  256. o=================o
  257. | A. Introduction |
  258. o=================o
  259.  
  260. These are my personal notes (text files) that I referred to when I was trying to learn something about Assembly programming for the Commodore 64. To me it's like a walkthrough of a game. Hence the name of this collection of text files: "The C64 Walkthrough".
  261.  
  262. Programming "anything graphical" on the C64 is very, very complex. One does not only have to master a programming language (like BASIC or Assembly) but also has to have quite the deep understanding of the C64's inner workings as well as it's use of memory addresses (i.e. the memory map). For example, to print a single character on screen in Assembly one has to store the hexadecimal value of a letter character to memory address FFD2_hex. One also has to realize that this address is part of the kernal (yes, that is spelled the correct Commodore way) and not of the graphic chip. Even if one uses BASIC then one falls back to POKE-ing values into memory addresses very soon, which is the same as LDA- and STA-ing values in Assembly.
  263.  
  264. The real art is to not go down the rabbit hole too much and to collect "just" the right amount of books, websites and tutorials.
  265.  
  266. You also *ABSOLUTELY NEED* to keep reference books and manuals handy. One can only use the text files that I wrote with the programmers reference guide [1], a good memory map [2, 4], a book on Assembly language [3] and the manual from the SID chip [6].
  267.  
  268. What you already need to know (roughly) if you want to read these docs (use Google and Wikipedia):
  269.  
  270. - Decimal, hexadecimal and binary number systems.
  271. - Bits and bytes, what is an address, nybble.
  272. - The terms ROM and RAM.
  273. - What is clock frequency.
  274. - What is a sprite.
  275. - The C64's CPU is the MOS 6510 (compatible w/ the 6502).
  276. - The C64's graphics chip is the VIC-II.
  277. - CIA = complex input/output adapter.
  278. - CIA1 = keyboard, joystick, paddles, datasette, IRQ control.
  279. - CIA2 = serial bus, RS-232, VIC memory, NMI control.
  280. - Basic programming skills in BASIC (poke, peek, print).
  281. - MSB = most significant bit, LSB = ..., low byte, high byte.
  282. - What is Character ROM (4 kB), kernal ROM (8 kB), BASIC ROM (8 kB).
  283. - Address bus (16 bit), memory bus (8 bit).
  284. - Petscii codes.
  285. - What the term "machine language" means.
  286.  
  287.  
  288. o============================o
  289. | B. Recommended literature |
  290. o============================o
  291.  
  292. The books "The Programmers reference guide" [1] and "Mapping the C64" [2] are written very well. However, I consider them to be reference-books, not study books. Another reference that one must always keep handy is the "HTML version of the memory map" [4]. I converted it into a PDF file for easy reading.
  293.  
  294. Most people recommend reading the brilliant book "Machine language for the C64" by the brilliant Jim Butterfield to learn Assembly. However, like the book's title says, it's mainly about machine language: it uses a machine language monitor (MLM) to program Assembly. Additionally, it has no chapters about the most important and expensive feature of the C64: graphics & sprites. So I read [3]. That one is quite complex at some points and uses BASIC to explain graphics. Therefore it looks to me like the author was struggling a bit w/ Assembly himself and was coming from BASIC. I read those books to learn the basics of Assembly. I didn't read them thoroughly: they're not focused enough on Assembly to learn how games were programmed.
  295.  
  296. Goal was to be able to read and understand something like the extensive set of tutorials by Georg Rottensteiner (https://www.georg-rottensteiner.de/en/index.html) or the book "Retro game dev - C64 edition" by Derek Morris (www.retrogamedev.com).
  297.  
  298.  
  299. o===============o
  300. | X. References |
  301. o===============o
  302.  
  303. [1] "C64 programmer's reference guide", Commodore Business Machines and Howard W. Sams and Co. publ., First ed. second printing (1983).
  304.  
  305. [2] "Mapping the C64", Sheldon Leemon, Compute! Publications Inc., ISBN 0-942386-23-X (1984).
  306.  
  307. [3] "Commodore 64/128 Assembly language programming", Mark Andrews, Howard W. Sams & Co. publ., ISBN 0-672-22244-5, First ed. (1986).
  308. Bombjack download link:
  309. https://commodore.bombjack.org/books/commodore/books/Commodore_64_128_Assembly_Language_Programming.zip
  310.  
  311. [4] HTML C64 memory map by Joe Forster:
  312. https://sta.c64.org/cbm64mem.html
  313.  
  314. [5] "Machine language for the C64, 128, and other Commodore computers", Jim Butterfield, Prentice Hall publ., ISBN 0-89303-652-8 (1986).
  315.  
  316. [6] Data sheet from the 6582 (click on: "Files"):
  317. http://sid.kubarth.com
  318.  
  319. [7] "Programming the C64 the definitive guide", Raetro Collin West, Compute! Publications Inc., ISBN 0-942386-50-7 (1985).
  320.  
  321. [8] Bombjack:
  322. https://commodore.bombjack.org/commodore/books.htm
  323.  
  324.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement