65X-DOS/include/kernel/hardware/vera.h

159 lines
4.2 KiB
C
Raw Normal View History

2024-07-07 17:37:04 +02:00
// SPDX-License-Identifier: MIT
//
// boot/vera.h
2024-07-08 05:08:08 +02:00
// Defines for the VERA chip
2024-07-07 17:37:04 +02:00
//
// Copyright © 2024 Kyle J Cardoza <Kyle.Cardoza@icloud.com>
2024-07-08 05:08:08 +02:00
#ifdef __CALYPSI_CC__
#include <stddef.h>
#include <stdint.h>
#endif
2024-07-07 17:37:04 +02:00
#define AUTO_NONE 0x000000
#define AUTO_INC_1 0x100000
#define AUTO_INC_2 0x200000
#define AUTO_INC_4 0x300000
#define AUTO_INC_8 0x400000
#define AUTO_INC_16 0x500000
#define AUTO_INC_32 0x600000
#define AUTO_INC_64 0x700000
#define AUTO_INC_128 0x800000
#define AUTO_INC_256 0x900000
#define AUTO_INC_512 0xA00000
#define AUTO_INC_40 0xB00000
#define AUTO_INC_80 0xC00000
#define AUTO_INC_160 0xD00000
#define AUTO_INC_320 0xE00000
#define AUTO_INC_640 0xF00000
#define DISABLED 0
#define ENABLED 1
#define VERA_L_BPP1 0b00000000
#define VERA_L_BPP2 0b00000001
#define VERA_L_BPP4 0b00000010
#define VERA_L_BPP8 0b00000011
#define VERA_L_BITMAP 0b00000100
#define VERA_L_T256C 0b00001000
#define VERA_L_32W 0b00000000
#define VERA_L_64W 0b00010000
#define VERA_L_128W 0b00100000
#define VERA_L_256W 0b00110000
#define VERA_L_32H 0b00000000
#define VERA_L_64H 0b01000000
#define VERA_L_128H 0b10000000
#define VERA_L_256H 0b11000000
#define VERA_TILESIZE8x8 0b00000000
#define VERA_TILESIZE16x8 0b00000001
#define VERA_TILESIZE8x16 0b00000010
#define VERA_TILESIZE16x16 0b00000011
// The base address of the VERA chip
#define VERA_BASE 0x00DF00
// Offsets (relative to VERA_BASE) for each VERA register
#define VERA_ADDRx_L VERA_BASE + 00
#define VERA_ADDRx_M VERA_BASE + 01
#define VERA_ADDRx_H VERA_BASE + 02
// Accssible with ADDRSEL 0
#define VERA_ADDR0_L VERA_BASE + 00
#define VERA_ADDR0_M VERA_BASE + 01
#define VERA_ADDR0_H VERA_BASE + 02
// Accssible with ADDRSEL 1
#define VERA_ADDR1_L VERA_BASE + 00
#define VERA_ADDR1_M VERA_BASE + 01
#define VERA_ADDR1_H VERA_BASE + 02
#define VERA_DATA_0 VERA_BASE + 0x03
#define VERA_DATA_1 VERA_BASE + 0x04
#define VERA_CTRL VERA_BASE + 0x05
#define VERA_IEN VERA_BASE + 0x06
#define VERA_ISR VERA_BASE + 0x07
#define VERA_IRQLINE_L VERA_BASE + 0x08
#define VERA_SCANLINE_L VERA_BASE + 0x08
// Accssible with DCSEL 0
#define VERA_DC_VIDEO VERA_BASE + 0x09
#define VERA_DC_HSCALE VERA_BASE + 0x0A
#define VERA_DC_VSCALE VERA_BASE + 0x0B
#define VERA_DC_BORDER VERA_BASE + 0x0C
// Accssible with DCSEL 1
#define VERA_DC_HSTART VERA_BASE + 0x09
#define VERA_DC_HSTOP VERA_BASE + 0x0A
#define VERA_DC_VSTART VERA_BASE + 0x0B
#define VERA_DC_VSTOP VERA_BASE + 0x0C
// Layer 0
#define VERA_L0_CONFIG VERA_BASE + 0x0D
#define VERA_L0_MAPBASE VERA_BASE + 0x0E
#define VERA_L0_TILEBASE VERA_BASE + 0x0F
#define VERA_L0_HSCROLL_L VERA_BASE + 0x10
#define VERA_L0_HSCROLL_H VERA_BASE + 0x11
#define VERA_L0_VSCROLL_L VERA_BASE + 0x12
#define VERA_L0_VSCROLL_H VERA_BASE + 0x13
// Layer 1
#define VERA_L1_CONFIG VERA_BASE + 0x14
#define VERA_L1_MAPBASE VERA_BASE + 0x15
#define VERA_L1_TILEBASE VERA_BASE + 0x16
#define VERA_L1_HSCROLL_L VERA_BASE + 0x17
#define VERA_L1_HSCROLL_H VERA_BASE + 0x18
#define VERA_L1_VSCROLL_L VERA_BASE + 0x19
#define VERA_L1_VSCROLL_H VERA_BASE + 0x1A
// Audio
#define VERA_AUDIO_CTRL VERA_BASE + 0x1B
#define VERA_AUDIO_RATE VERA_BASE + 0x1C
#define VERA_AUDIO_DATA VERA_BASE + 0x1D
// SPI (Unused in prototype four!)
#define VERA_SPI_DATA VERA_BASE + 0x1E
#define VERA_SPI_CTRL VERA_BASE + 0x1F
// VRAM layout
#define TEXT_CONSOLE_TILES 0x000800
#define TEXT_CONSOLE0_VRAM 0x001800 // Runs up to 0x5800
#define TEXT_CONSOLE_SPRITE_BITMAPS 0x005800
#define VERA_PSG_BASE 0x01F9C0
#define VERA_PALETTE_BASE 0x01FA00
#define VERA_SPRITE_ATTR_BASE 0x01FC00
2024-07-08 05:08:08 +02:00
// The assembler can't handle this stuff.
#ifdef __CALYPSI_CC__
void vera_set_address_0(uint32_t addr);
void vera_set_address_1(uint32_t addr);
uint8_t vera_read_data_reg_0(void);
uint8_t vera_read_data_reg_1(void);
uint16_t vera_read_data_reg(void);
void vera_write_data_reg_0(uint8_t new_value);
void vera_write_data_reg_1(uint8_t new_value);
void vera_write_data_reg(uint16_t new_value);
void vera_reset(void);
void vera_mem_read(void *dest, uint32_t src, size_t length);
void vera_mem_write(uint32_t dest, void *src, size_t length);
void vera_mem_set(uint32_t dest, uint8_t value, size_t length);
#endif