libmsx
C library for MSX
Loading...
Searching...
No Matches
bmem.h
Go to the documentation of this file.
1// -*- coding: utf-8-unix -*-
2/*
3 * Copyright (c) 2021-2024 Daishi Mori (mori0091)
4 *
5 * This software is released under the MIT License.\n
6 * See https://github.com/mori0091/libmsx/blob/main/LICENSE
7 *
8 * GitHub libmsx project\n
9 * https://github.com/mori0091/libmsx
10 */
55#pragma once
56
57#include <stdint.h>
58#ifndef BMEM_H_
59#define BMEM_H_
60
61#include <vmem.h>
62
74typedef uint32_t bmemptr_t;
75
82inline uint8_t bmem_bank_of(bmemptr_t loc) {
83 return (uint8_t)((loc >> 14) & 255);
84}
85
91uint8_t bmem_get_bank(void) __naked;
92
98void bmem_set_bank(uint8_t bank) __naked;
99
119uint8_t bmem_get(bmemptr_t src);
120
128
157void bmem_read(bmemptr_t src, void* dst, uint16_t len);
158
166void bmem_copy_to_vmem(bmemptr_t src, vmemptr_t dst, uint32_t len);
167
197
200#endif // BMEM_H_
201
uint8_t bmem_bank_of(bmemptr_t loc)
Returns the segment number corresponding to the specified address of the banked memory.
Definition bmem.h:82
uint32_t bmemptr_t
Type of an address of banked memory.
Definition bmem.h:74
uint8_t bmem_get_bank(void) __naked
Get the current segment number of banked memory at page 2 (0x8000..0xbfff).
void bmem_set_bank(uint8_t bank) __naked
Expose a 16KiB segment of banked memory at page 2 (0x8000..0xbfff).
uint16_t bmem_get_u16(bmemptr_t src)
Read 16-bits value from banked memory.
void bmem_bload_s(bmemptr_t src)
Load a BSAVE formatted binary in banked memory into VRAM.
uint8_t bmem_get(bmemptr_t src)
Read byte from banked memory.
void bmem_copy_to_vmem(bmemptr_t src, vmemptr_t dst, uint32_t len)
Copy from banked memory to VRAM.
void bmem_read(bmemptr_t src, void *dst, uint16_t len)
Read byte sequence from banked memory.
uint32_t vmemptr_t
Type for VRAM address.
Definition vmem.h:42
Data types and functions for VRAM access.