libmsx
C library for MSX
Loading...
Searching...
No Matches
vdp_unsafe.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 */
17#pragma once
18
19#ifndef VDP_UNSAFE_H_
20#define VDP_UNSAFE_H_
21
22#include <stdint.h>
23
24#include "io.h"
25#include "vmem.h"
26#include "bios.h"
27
46inline void VDP_SET_CONTROL_REGISTER(uint8_t reg, uint8_t val) {
47 vdp_port1 = val;
48 vdp_port1 = reg | 0x80;
49}
50
65inline void VDP_SET_CONTROL_REGISTER_POINTER(uint8_t reg) {
66 VDP_SET_CONTROL_REGISTER(17, reg | 0x80);
67}
68
87
99inline void VDP_SET_CONTROL_REGISTER_VALUE(uint8_t val) {
100 vdp_port3 = val;
101}
102
118inline void VDP_SET_STATUS_REGISTER_POINTER(uint8_t reg) {
120}
121
132inline uint8_t VDP_GET_STATUS_REGISTER_VALUE(void) {
133 return vdp_port1;
134}
135
148 if (0 < msx_get_version()) {
149 VDP_SET_CONTROL_REGISTER(14, (uint8_t)(((loc) >> 14) & 7));
150 }
151 vdp_port1 = (uint8_t)((loc) & 255);
152 vdp_port1 = (uint8_t)(((loc) >> 8) & 0x3F | 0x40);
153}
154
167 if (0 < msx_get_version()) {
168 VDP_SET_CONTROL_REGISTER(14, (uint8_t)(((loc) >> 14) & 7));
169 }
170 vdp_port1 = (uint8_t)((loc) & 255);
171 vdp_port1 = (uint8_t)(((loc) >> 8) & 0x3F);
172}
173
187inline void VDP_SET_VMEM_VALUE(uint8_t val) {
188 vdp_port0 = val;
189}
190
203inline uint8_t VDP_GET_VMEM_VALUE(void) {
204 return vdp_port0;
205}
206
209#endif // VDP_UNSAFE_H_
C language I/F for MSX BIOS routines.
uint8_t msx_get_version(void)
MSX Returns MSX system version code.
Definition bios.h:69
uint8_t VDP_GET_VMEM_VALUE(void)
MSX Read a value from VRAM.
Definition vdp_unsafe.h:203
void VDP_SET_CONTROL_REGISTER_VALUE(uint8_t val)
MSX2 Write a value to the VDP control register pointed by R#17.
Definition vdp_unsafe.h:99
void VDP_SET_VMEM_WRITE_POINTER(vmemptr_t loc)
MSX Set VRAM address for subsequent writing to VRAM.
Definition vdp_unsafe.h:147
void VDP_SET_VMEM_READ_POINTER(vmemptr_t loc)
MSX Set VRAM address for subsequent reading from VRAM.
Definition vdp_unsafe.h:166
void VDP_SET_STATUS_REGISTER_POINTER(uint8_t reg)
MSX2 Set VDP status register number for subsequent reading from the VDP status register.
Definition vdp_unsafe.h:118
void VDP_SET_CONTROL_REGISTER_POINTER_AUTO_INCREMENT(uint8_t reg)
MSX2 Set VDP control register number for subsequent writing to the series of VDP control registers.
Definition vdp_unsafe.h:84
uint8_t VDP_GET_STATUS_REGISTER_VALUE(void)
MSX Reads a value from VDP status register.
Definition vdp_unsafe.h:132
void VDP_SET_CONTROL_REGISTER(uint8_t reg, uint8_t val)
MSX Write a value to the specified VDP control register.
Definition vdp_unsafe.h:46
void VDP_SET_VMEM_VALUE(uint8_t val)
MSX Write a value to VRAM.
Definition vdp_unsafe.h:187
void VDP_SET_CONTROL_REGISTER_POINTER(uint8_t reg)
MSX2 Set VDP control register number for subsequent writing to the VDP control register.
Definition vdp_unsafe.h:65
uint32_t vmemptr_t
Type for VRAM address.
Definition vmem.h:42
Definition of I/O ports.
static volatile __sfr vdp_port1
Definition io.h:25
static volatile __sfr vdp_port3
Definition io.h:27
static volatile __sfr vdp_port0
Definition io.h:24
Data types and functions for VRAM access.