forked from WartyMN/F256-FileManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory.h
123 lines (93 loc) · 7.12 KB
/
memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* memory.h
*
* Created on: December 4, 2022
* Author: micahbly
*/
#ifndef MEMORY_H_
#define MEMORY_H_
/* about this class
*
* this header represents a set of assembly functions in memory.asm
* the functions in this header file are all related to moving memory between physical F256jr RAM and MMU-mapped 6502 RAM
* these functions neeed to be in the MAIN segment so they are always available
* all functions that modify the LUT will reset it to its original configurate before exiting
*
*/
/*****************************************************************************/
/* Includes */
/*****************************************************************************/
#include "app.h"
/*****************************************************************************/
/* Macro Definitions */
/*****************************************************************************/
#define PARAM_FOR_ATTR_MEM true // param for functions updating VICKY screen memory: make it affect color/attribute memory
#define PARAM_FOR_CHAR_MEM false // param for functions updating VICKY screen memory: make it affect character memory
#define ZP_BANK_SLOT 0x10 // zero-page address holding the LUT slot to be modified (0-7) (eg, if 0, will be $08,if 1, $09, etc.)
#define ZP_BANK_NUM 0x11 // zero-page address holding the new LUT bank# to be set in the ZP_BANK_SLOT
#define ZP_OLD_BANK_NUM 0x12 // zero-page address holding the original LUT bank # before being changed
#define ZP_TO_ADDR 0x13 // zero-page address holding address to copy to, for ML copy routine (3b)
#define ZP_FROM_ADDR 0x16 // zero-page address holding address to copy from, for ML copy routine (3b)
#define ZP_COPY_LEN 0x19 // zero-page address holding number of bytes to copy, for ML copy routine (3b)
#define ZP_PHYS_ADDR_LO 0x1C // zero-page address pointing to a 20-bit physical memory address
#define ZP_PHYS_ADDR_MI 0x1D // zero-page address pointing to a 20-bit physical memory address
#define ZP_PHYS_ADDR_HI 0x1E // zero-page address pointing to a 20-bit physical memory address
#define ZP_CPU_ADDR_LO 0x1F // zero-page address pointing to a 16-bit address in 6502 memory space (virtual 64k)
#define ZP_CPU_ADDR_HI 0x20 // zero-page address pointing to a 16-bit address in 6502 memory space (virtual 64k)
#define ZP_SEARCH_LOC_BYTE 0x21 // zero-page address holding the current search location's byte offset within the page being searched
#define ZP_SEARCH_LOC_PAGE 0x22 // zero-page address holding the current search location's page number within the bank being searched
#define ZP_SEARCH_LOC_BANK 0x23 // zero-page address holding the current search location's bank number
#define ZP_TEMP_1 0x24 // zero-page address we will use for temp variable storage in assembly routines
#define ZP_OTHER_PARAM 0x25 // zero-page address we will use for communicating 1 byte to/from assembly routines
#define ZP_OLD_IO_PAGE 0x26 // zero-page address holding the original IO page # before being changed
//#define ZP_X 0x13 // zero-page address we will use for passing X coordinate to assembly routines
//#define ZP_Y 0x14 // zero-page address we will use for passing Y coordinate to assembly routines
//#define ZP_SCREEN_ID 0x15 // zero-page address we will use for passing the screen ID to assembly routines
// starting point for all storage to extended memory. if larger than 8K, increment as necessary
#define EM_STORAGE_START_CPU_ADDR 0xA000 // when copying file data to EM, the starting CPU address (16 bit)
#define EM_STORAGE_START_PHYS_ADDR 0x28000 // when copying file data to EM, the starting physical address (20 bit)
//#define EM_STORAGE_START_SLOT 0x06 // the 0-7 local CPU slot to map it into - i/o + kernel#2 slot
#define EM_STORAGE_START_SLOT 0x05 // the 0-7 local CPU slot to map it into - overlay slot
#define EM_STORAGE_START_PHYS_BANK_NUM 0x14 // the system physical bank number/slot where EM storage starts for us.
/*****************************************************************************/
/* Enumerations */
/*****************************************************************************/
/*****************************************************************************/
/* Structs */
/*****************************************************************************/
/*****************************************************************************/
/* Global Variables */
/*****************************************************************************/
/*****************************************************************************/
/* Public Function Prototypes */
/*****************************************************************************/
// call to a routine in memory.asm that modifies the MMU LUT to bring the specified bank of physical memory into the CPU's RAM space
// set zp_bank_num before calling.
// returns the slot that had been mapped previously
uint8_t __fastcall__ Memory_SwapInNewBank(uint8_t the_bank_slot);
// call to a routine in memory.asm that modifies the MMU LUT to bring the back the previously specified bank of physical memory into the CPU's RAM space
// relies on a previous routine having set ZP_OLD_BANK_NUM. Should be called after Memory_SwapInNewBank(), when finished with the new bank
// set zp_bank_num before calling.
void __fastcall__ Memory_RestorePreviousBank(uint8_t the_bank_slot);
// call to a routine in memory.asm that returns whatever is currently mapped in the specified MMU slot
// set zp_bank_num before calling.
// returns the slot that had been mapped previously
uint8_t __fastcall__ Memory_GetMappedBankNum(void);
// call to a routine in memory.asm that writes an illegal opcode followed by address of debug buffer
// that is a simple to the f256jr emulator to write the string at the debug buffer out to the console
//void __fastcall__ Memory_DebugOut(void);
// call to a routine in memory.asm that copies specified number of bytes from src to dst
// set zp_to_addr, zp_from_addr, zp_copy_len before calling.
// credit: http://6502.org/source/general/memory_move.html
// void __fastcall__ Memory_Copy(void);
// call to a routine in memory.asm that copies specified number of bytes from src to dst
// set zp_to_addr, zp_from_addr, zp_copy_len before calling.
// this version uses the F256's DMA capabilities to copy, so addresses can be 24 bit (system memory, not CPU memory)
// in other words, no need to page either dst or src into CPU space
//void __fastcall__ Memory_CopyWithDMA(void);
// call to a routine in memory.asm that fills the specified number of bytes to the dst
// set zp_to_addr, zp_copy_len to num bytes to fill, and zp_other_byte to the fill value before calling.
// this version uses the F256's DMA capabilities to fill, so addresses can be 24 bit (system memory, not CPU memory)
// in other words, no need to page either dst into CPU space
//void __fastcall__ Memory_FillWithDMA(void);
#endif /* MEMORY_H_ */