libmsx
C library for MSX
Loading...
Searching...
No Matches
sprite.h
Go to the documentation of this file.
1// -*- coding: utf-8-unix -*-
2/*
3 * Copyright (c) 2021-2025 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 */
22#pragma once
23
24#ifndef SPRITE_H
25#define SPRITE_H
26
27#include <stdint.h>
28
29#include "vmem.h"
30
31// ---- Sprite
43 SPRITE_TAG_IC = (1<<5), // IC bit (Ignore Collision)
44 SPRITE_TAG_CC = (1<<6), // CC bit (Compose Color / Cancel Collision)
45 SPRITE_TAG_EC = (1<<7), // EC bit (Early Clock)
46};
47
51typedef uint8_t tagged_color_t;
52
56struct sprite {
57 uint8_t y;
58 uint8_t x;
59 uint8_t pat;
61};
62
68void sprite_set_x(struct sprite* s, int x);
74void sprite_set_y(struct sprite* s, int y);
81void sprite_set_xy(struct sprite* s, int x, int y);
87void sprite_set_pat(struct sprite* s, uint8_t pat);
93void sprite_set_color(struct sprite* s, tagged_color_t tagged_color);
94
103inline
104void vmem_set_sprite(vmemptr_t base, uint8_t plane, const struct sprite* s) {
105 vmem_write(base + plane * sizeof(struct sprite), (void*)s, sizeof(struct sprite));
106}
107
127
130#endif
uint8_t pat
sprite pattern number
Definition sprite.h:59
uint8_t y
y coordinates
Definition sprite.h:57
tagged_color_t tagged_color
EC | CC | IC | 0 | Color Code
Definition sprite.h:60
uint8_t x
x coordinates
Definition sprite.h:58
void sprite_set_pat(struct sprite *s, uint8_t pat)
MSX Set sprite pattern number to a struct sprite.
sprite_tag
Enumerations for tags of sprite attribute table.
Definition sprite.h:42
void vmem_set_sprite(vmemptr_t base, uint8_t plane, const struct sprite *s)
MSX Set sprite attribute table element.
Definition sprite.h:104
uint8_t tagged_color_t
Color code with tags of sprite attribute table.
Definition sprite.h:51
void sprite_set_x(struct sprite *s, int x)
MSX Set x coordinates to a struct sprite.
void vmem_init_sprites(vmemptr_t base)
MSX Initialize the sprite attribute table.
void sprite_set_xy(struct sprite *s, int x, int y)
MSX Set x and y coordinates to a struct sprite.
void sprite_set_y(struct sprite *s, int y)
MSX Set y coordinates to a struct sprite.
void sprite_set_color(struct sprite *s, tagged_color_t tagged_color)
MSX Set tags and color code to a struct sprite.
@ SPRITE_TAG_CC
Definition sprite.h:44
@ SPRITE_TAG_EC
Definition sprite.h:45
@ SPRITE_TAG_IC
Definition sprite.h:43
Element of sprite attribute table.
Definition sprite.h:56
void vmem_write(vmemptr_t dst, void *src, uint16_t len)
MSX Write a series of bytes to VRAM.
uint32_t vmemptr_t
Type for VRAM address.
Definition vmem.h:43
Data types and functions for VRAM access.