llvm-mos-sdk
atari2600-common
mapper_xram_single.h
Go to the documentation of this file.
1
// Copyright 2022 LLVM-MOS Project
2
// Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3
// See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4
// information.
5
6
// Functions for single-area RAM bank switching schemes.
7
// (3E, E7)
8
9
#ifndef _MAPPER_XRAM_H_
10
#define _MAPPER_XRAM_H_
11
12
#include <mapper.h>
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
18
// RAM bank index type.
19
typedef
unsigned
char
ram_bank_t
;
20
21
// Macro to declare a variable in XRAM.
22
// - index = XRAM bank index
23
// - declaration = variable declaration
24
// This will declare two variables, one read-only and one write-only.
25
// For example, DECLARE_XRAM_VARIABLE(0, int my_var)
26
// creates two variables: my_var_read and my_var_write.
27
// NOTE: These variables are not initialized by default.
28
#define _DECLARE_XRAM_VARIABLE(index, declaration) \
29
__attribute__((section(".xram" #index "_read"))) volatile const declaration##_read; \
30
__attribute__((section(".xram" #index "_write"))) volatile declaration##_write;
31
32
#define DECLARE_XRAM_VARIABLE(index, declaration) _DECLARE_XRAM_VARIABLE(index, declaration)
33
34
// Switch in a RAM bank.
35
void
ram_select
(
ram_bank_t
bank_id
);
36
37
// Switch to another RAM bank and call this function.
38
__attribute__((callback(2))) void banked_call_ram(
ram_bank_t
bank_id
,
39
void
(*
method
)(
void
));
40
41
// Write a byte to extended RAM at set offset
42
// RAM must be selected first, or use banked_call_ram
43
void
xram_write
(
int
offset,
unsigned
char
value);
44
45
// Read a byte from extended RAM at set offset
46
// RAM must be selected first, or use banked_call_ram
47
unsigned
char
xram_read
(
int
offset);
48
49
#ifdef __cplusplus
50
}
51
#endif
52
53
#endif // _MAPPER_H_
ram_bank_t
unsigned char ram_bank_t
Definition:
mapper_xram_single.h:19
bank_id
char bank_id
Definition:
mapper.h:97
xram_write
void xram_write(int offset, unsigned char value)
ram_select
void ram_select(ram_bank_t bank_id)
method
void(* method)(void))
Definition:
mapper_xram_single.h:39
xram_read
unsigned char xram_read(int offset)
Generated by
1.8.17