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-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 */
21#pragma once
22
23#ifndef SPRITE_H
24#define SPRITE_H
25
26#include <stdint.h>
27
28#include "vmem.h"
29
30// ---- Sprite
42 SPRITE_TAG_IC = (1<<5), // IC bit (Ignore Collision)
43 SPRITE_TAG_CC = (1<<6), // CC bit (Compose Color / Cancel Collision)
44 SPRITE_TAG_EC = (1<<7), // EC bit (Early Clock)
45};
46
50typedef uint8_t tagged_color_t;
51
55struct sprite {
56 uint8_t y;
57 uint8_t x;
58 uint8_t pat;
60};
61
67void sprite_set_x(struct sprite* s, int x);
73void sprite_set_y(struct sprite* s, int y);
80void sprite_set_xy(struct sprite* s, int x, int y);
86void sprite_set_pat(struct sprite* s, uint8_t pat);
92void sprite_set_color(struct sprite* s, tagged_color_t tagged_color);
93
102inline
103void vmem_set_sprite(vmemptr_t base, uint8_t plane, const struct sprite* s) {
104 vmem_write(base + plane * sizeof(struct sprite), (void*)s, sizeof(struct sprite));
105}
106
126
129#endif
uint8_t pat
sprite pattern number
Definition sprite.h:58
uint8_t y
y coordinates
Definition sprite.h:56
tagged_color_t tagged_color
EC | CC | IC | 0 | Color Code
Definition sprite.h:59
uint8_t x
x coordinates
Definition sprite.h:57
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:41
void vmem_set_sprite(vmemptr_t base, uint8_t plane, const struct sprite *s)
MSX Set sprite attribute table element.
Definition sprite.h:103
uint8_t tagged_color_t
Color code with tags of sprite attribute table.
Definition sprite.h:50
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:43
@ SPRITE_TAG_EC
Definition sprite.h:44
@ SPRITE_TAG_IC
Definition sprite.h:42
Element of sprite attribute table.
Definition sprite.h:55
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:42
Data types and functions for VRAM access.