Files
VCCPlusOSS/sdk/cmoc/include/vcc/bank.h
T

32 lines
1.5 KiB
C

// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef VCC_BANK_H
#define VCC_BANK_H
#define BANK_FIRST_PAGE 0x28
#define BANK_PAGE_SIZE 8192u
#define BANK_CAPACITY 32768u
// Claim the BASIC program's dedicated physical blocks $28-$2B ($50000-$57FFF).
// The caller reserves this RAM for assets. Opening and closing do not clear it.
// Requires stock CoCo 3 BASIC task 0, 512 KiB or more, and a normal CMOC layout
// below $8000. On RAM expansions retain BASIC's default $FF9B bank/prefix and
// map; these write-only settings cannot be reconstructed after custom paging.
// Compatible with gime_open(). Use from foreground code; open with IRQ enabled.
// Return 1 on success, 0 for an unsupported setup or a second open.
unsigned char bank_open(void);
// Transfer exactly length bytes at a byte offset measured from BANK_FIRST_PAGE.
// A transfer may span pages. The complete range must fit BANK_CAPACITY.
// Supply a caller-owned C buffer entirely below $8000; read requires writable
// data, write accepts const data. A zero length needs no buffer and permits
// offset == BANK_CAPACITY. Return 1 on success or 0 before copying any bytes.
// Between calls both MMU tasks and the normal expansion group must stay under
// BASIC's control. Each short copy restores the CPU mapping and interrupt mask.
unsigned char bank_read(unsigned offset, void *destination, unsigned length);
unsigned char bank_write(unsigned offset, const void *source, unsigned length);
// Release the claim. Safe to repeat. RAM contents survive until reused/reset.
void bank_close(void);
#endif