aboutsummaryrefslogtreecommitdiff
path: root/src/state.h
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2016-03-14 16:24:48 +0000
committerIan C <ianc@noddybox.co.uk>2016-03-14 16:24:48 +0000
commite23a3e98bf4afc6bc900a427c20c01feac476d1a (patch)
tree57957cf943e267445724b9339160b9d1890549a4 /src/state.h
parent9edfd06f3a609ff6a6c87e3d7bea4e1728eea474 (diff)
Initial code for handling of memory banks.
Diffstat (limited to 'src/state.h')
-rw-r--r--src/state.h41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/state.h b/src/state.h
index 0ebdce5..e10463c 100644
--- a/src/state.h
+++ b/src/state.h
@@ -19,7 +19,9 @@
-------------------------------------------------------------------------
- Stores assembly state.
+ Stores assembly state (passes, memory, etc).
+
+ Memory is arranged in banks of RAM of 64K each.
*/
@@ -28,23 +30,37 @@
/* ---------------------------------------- TYPES
*/
+#define BANK_SIZE 0x10000u
+
typedef enum
{
MSB_Word,
LSB_Word
} WordMode;
+
+typedef struct mbnk
+{
+ unsigned number; /* The bank number, 0 .. n */
+ Byte memory[BANK_SIZE]; /* The memory in that bank */
+ int min_address_used; /* Will be BANK_SIZE if not used */
+ int max_address_used; /* Will be -1 if not used */
+ struct mbnk *next; /* The next memory bank */
+} MemoryBank;
+
/* ---------------------------------------- INTERFACES
*/
-/* Clear state to default. This creates 64K of RAM to write into.
+/* Clear state to default. This creates 64K of RAM to write into and sets
+ zero as the current bank.
*/
void ClearState(void);
-/* Sets the number of bytes in RAM. Addressing always starts from zero.
+/* Sets the current bank to use. If it's never been used before it will be
+ initialised as an empty 64K of RAM.
*/
-void SetAddressSpace(int size);
+void SetAddressBank(unsigned bank);
/* Move onto the next pass
@@ -103,22 +119,13 @@ void PCWriteWord(int i);
void PCWriteWordMode(int i, WordMode mode);
-/* Get the minimum address written to
-*/
-int GetMinAddressWritten(void);
-
-
-/* Get the maximum address written to
-*/
-int GetMaxAddressWritten(void);
-
-
-/* Access the address space directly
+/* Gets a list of the banks used. A NULL return means no memory was written
+ to at all.
*/
-const Byte *AddressSpace(void);
+const MemoryBank *MemoryBanks(void);
-/* Read a byte from the address space
+/* Read a byte from the current bank.
*/
Byte ReadByte(int addr);