From 0336fe73660d2d86f60e5086a01a9ae7c1525606 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Fri, 8 Dec 2017 22:12:31 -0600 Subject: [PATCH] Documentation for files --- src/apple2.c | 3 +++ src/log.c | 6 ++++++ src/main.c | 8 ++++++++ src/mos6502.arith.c | 5 ++++- src/mos6502.bits.c | 3 +++ src/mos6502.branch.c | 3 +++ src/mos6502.c | 22 ++++------------------ src/mos6502.exec.c | 3 +++ src/mos6502.loadstor.c | 3 +++ src/mos6502.stat.c | 3 +++ src/option.c | 6 +++++- src/vm_screen.c | 8 ++++++++ src/vm_segment.c | 19 ++++--------------- 13 files changed, 57 insertions(+), 35 deletions(-) diff --git a/src/apple2.c b/src/apple2.c index 3b880c6..ae05470 100644 --- a/src/apple2.c +++ b/src/apple2.c @@ -1,5 +1,8 @@ /* * apple2.c + * + * Here we have support for the apple2 machine. I suspect that we will + * need to break this file up into components in the future... */ #include "apple2.h" diff --git a/src/log.c b/src/log.c index 14e5941..b3336cd 100644 --- a/src/log.c +++ b/src/log.c @@ -1,3 +1,9 @@ +/* + * log.c + * + * The functions here support our logging mechanism. + */ + #include #include #include diff --git a/src/main.c b/src/main.c index 2bf86fd..1db2f03 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,11 @@ +/* + * main.c + * + * Here we define the main entry point for the program; we also define a + * couple of functions to run when we start (init) and finish + * (...finish). + */ + #include #include #include diff --git a/src/mos6502.arith.c b/src/mos6502.arith.c index b07a638..eb75028 100644 --- a/src/mos6502.arith.c +++ b/src/mos6502.arith.c @@ -1,5 +1,8 @@ /* - * mos6502.inst.c + * mos6502.arith.c + * + * We define here the logic for arithmetic instructions for the MOS 6502 + * processor. */ #include "mos6502.h" diff --git a/src/mos6502.bits.c b/src/mos6502.bits.c index f5fabbc..2e271ec 100644 --- a/src/mos6502.bits.c +++ b/src/mos6502.bits.c @@ -1,5 +1,8 @@ /* * mos6502.bits.c + * + * The code here is used to implement instructions which operate + * specifically on bits of values. */ #include "mos6502.h" diff --git a/src/mos6502.branch.c b/src/mos6502.branch.c index ba03191..8e93e83 100644 --- a/src/mos6502.branch.c +++ b/src/mos6502.branch.c @@ -1,5 +1,8 @@ /* * mos6502.branch.c + * + * This is all the logic we use for branch instructions, which are used + * for conditional expressions. */ #include "mos6502.h" diff --git a/src/mos6502.c b/src/mos6502.c index b2b4c69..eb4ff94 100644 --- a/src/mos6502.c +++ b/src/mos6502.c @@ -1,23 +1,9 @@ /* - * Ideas: + * mos6502.c * - * The mos6502 code would _just_ emulate said chip. It would not be a - * technical part of the computer, and it would in other words be - * decoupled from the notion of a commadore, apple ii, etc. - * - * What you need to do in order to emulate the chip is be able to know - * about _memory_, and know about _registers_. Things like disk drives, - * screens, etc. are sort of beyond its knowledge. But memory and - * registers must be _local_ to the chip's workings; it must be able to - * directly modify those, as well as share memory/registers/etc. with - * other parts of a platform. - * - * Observations: - * - there can only be one chip at a given time; therefore we can get - * away with some kind of singleton to represent the chip - * - registers and memory need to be available to the chip, but the - * chip should not know about the larger platform; we should have - * pointers to all of that in the chip structure + * These functions are kind of the "top-level", if you will, for the MOS + * 6502 processor. You can create the processor struct, operate on the + * stack, etc. */ #include diff --git a/src/mos6502.exec.c b/src/mos6502.exec.c index 98b31b8..1f015d3 100644 --- a/src/mos6502.exec.c +++ b/src/mos6502.exec.c @@ -1,5 +1,8 @@ /* * mos6502.exec.c + * + * These instructions concern program execution; things like JMP, JSR, + * BRK, and so forth. */ #include "mos6502.h" diff --git a/src/mos6502.loadstor.c b/src/mos6502.loadstor.c index 5860e13..14cefa4 100644 --- a/src/mos6502.loadstor.c +++ b/src/mos6502.loadstor.c @@ -1,5 +1,8 @@ /* * mos6502.loadstor.c + * + * These are all the instructions which load and store values into + * various registers and places in memory. */ #include "mos6502.h" diff --git a/src/mos6502.stat.c b/src/mos6502.stat.c index 52d9688..4718189 100644 --- a/src/mos6502.stat.c +++ b/src/mos6502.stat.c @@ -1,5 +1,8 @@ /* * mos6502.stat.c + * + * The "stat", here, is short for status; these instructions all + * directly modify the status (P) register. */ #include "mos6502.h" diff --git a/src/option.c b/src/option.c index 512b039..85eeb44 100644 --- a/src/option.c +++ b/src/option.c @@ -1,5 +1,9 @@ /* - * options.c + * option.c + * + * This file contains the functions which support our CLI options; you + * are both able to parse options and retrieve information from that + * option parsing. */ #include diff --git a/src/vm_screen.c b/src/vm_screen.c index ccec4ea..65fe7dd 100644 --- a/src/vm_screen.c +++ b/src/vm_screen.c @@ -1,3 +1,11 @@ +/* + * vm_screen.c + * + * Functions here support drawing to the virtual machine's "screen"; + * exactly how that is done is an abstraction to the rest of the + * program, which only knows to call the functions here. + */ + #include #include "log.h" diff --git a/src/vm_segment.c b/src/vm_segment.c index 0f147f3..3977206 100644 --- a/src/vm_segment.c +++ b/src/vm_segment.c @@ -1,21 +1,10 @@ /* * vm_segment.c - * memory segments for our virtual machine * - * Memory segments can be used for almost any kind of storage we can - * imagine. The most obvious use would be for system memory, but others - * would include physical disk media (floppy disks, hard drives). - * - * You may note that we assume memory segments are organized into 8bit - * values (the `vm_8bit` type). It's certainly possible to create memory - * segments which are organized into arbitrary boundaries; 2, 3, 4 - * bytes, you know, go nuts! - * - * To do so, however, we would be adding a fair bit of complexity, and - * (at the moment of this writing at least) I am not convinced there is - * a good use-case for doing so. Your bog-standard computer of _today_ - * is still using memory organized into bytes. Your hard drive is also - * using bytes. Etc. + * The functions here allow you to allocate generic blocks of memory (or + * "segments") for use anywhere else in the software. They can be used + * to represent machine memory, removable media (like floppy disks), + * etc. */ #include