Sprite support.
This commit is contained in:
parent
6620f299a5
commit
8486c2e375
6 changed files with 120 additions and 0 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include "bitmap.c"
|
#include "bitmap.c"
|
||||||
#include "tile.c"
|
#include "tile.c"
|
||||||
#include "graphics.c"
|
#include "graphics.c"
|
||||||
|
#include "sprite.c"
|
||||||
|
|
||||||
|
|
||||||
void f256Init(void) {
|
void f256Init(void) {
|
||||||
|
@ -58,4 +59,6 @@ void f256Init(void) {
|
||||||
graphicsReset();
|
graphicsReset();
|
||||||
textReset();
|
textReset();
|
||||||
bitmapReset();
|
bitmapReset();
|
||||||
|
tileReset();
|
||||||
|
spriteReset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,7 @@ void f256Init(void);
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
#include "sprite.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
59
f256lib/sprite.c
Normal file
59
f256lib/sprite.c
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "sprite.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define OFF_SPR_ADL_L 1
|
||||||
|
#define OFF_SPR_POS_X_L 4
|
||||||
|
#define OFF_SPR_POS_Y_L 6
|
||||||
|
|
||||||
|
|
||||||
|
void spriteDefine(byte s, uint32_t address, byte size, byte CLUT, byte layer) {
|
||||||
|
uint16_t sprite = VKY_SP0_CTRL + (s << 3);
|
||||||
|
|
||||||
|
POKE(sprite, (size << 5) | (layer << 3) | (CLUT << 1));
|
||||||
|
POKEA(sprite + OFF_SPR_ADL_L, address);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void spriteSetPosition(byte s, uint16_t x, uint16_t y) {
|
||||||
|
uint16_t sprite = VKY_SP0_CTRL + (s << 3);
|
||||||
|
|
||||||
|
POKEW(sprite + OFF_SPR_POS_X_L, x);
|
||||||
|
POKEW(sprite + OFF_SPR_POS_Y_L, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void spriteSetVisible(byte s, bool v) {
|
||||||
|
uint16_t sprite = VKY_SP0_CTRL + (s << 3);
|
||||||
|
|
||||||
|
POKE(sprite, (PEEK(sprite) & 0xfe) | v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void spriteReset(void) {
|
||||||
|
byte x;
|
||||||
|
// Hide all sprites.
|
||||||
|
for (x=0; x<64; x++) spriteSetVisible(x, false);
|
||||||
|
}
|
48
f256lib/sprite.h
Normal file
48
f256lib/sprite.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SPRITE_H
|
||||||
|
#define SPRITE_H
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "f256.h"
|
||||||
|
|
||||||
|
|
||||||
|
void spriteDefine(byte s, uint32_t address, byte size, byte CLUT, byte layer);
|
||||||
|
void spriteSetPosition(byte s, uint16_t x, uint16_t y);
|
||||||
|
void spriteSetVisible(byte s, bool v);
|
||||||
|
void spriteReset(void);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SPRITE_H
|
|
@ -123,3 +123,11 @@ void tileSetVisible(byte t, bool v) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void tileReset(void) {
|
||||||
|
// Hide all tilemaps.
|
||||||
|
tileSetVisible(0, false);
|
||||||
|
tileSetVisible(1, false);
|
||||||
|
tileSetVisible(2, false);
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ void tileDefineTileMap(byte t, uint32_t address, byte tileSize, uint16_t mapSize
|
||||||
void tileDefineTileSet(byte t, uint32_t address, bool square);
|
void tileDefineTileSet(byte t, uint32_t address, bool square);
|
||||||
void tileSetScroll(byte t, byte xPixels, uint16_t xTiles, byte yPixels, uint16_t yTiles);
|
void tileSetScroll(byte t, byte xPixels, uint16_t xTiles, byte yPixels, uint16_t yTiles);
|
||||||
void tileSetVisible(byte t, bool v);
|
void tileSetVisible(byte t, bool v);
|
||||||
|
void tileReset(void);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Add table
Reference in a new issue