/* * 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 WITHOUT_SPRITE #ifndef F256LIB_AMALGAMATED_BUILD #include "f_sprite.h" #endif #define OFF_SPR_ADL_L 1 #define OFF_SPR_POS_X_L 4 #define OFF_SPR_POS_Y_L 6 static byte _spriteCtl[64]; void spriteDefine(byte s, uint32_t address, byte size, byte CLUT, byte layer) { uint16_t sprite = VKY_SP0_CTRL + (s * 8); byte sz; switch (size) { case 8: sz = 3; break; case 16: sz = 2; break; case 24: sz = 1; break; case 32: sz = 0; break; } _spriteCtl[s] = (sz << 5) | (layer << 3) | (CLUT << 1); POKE(sprite, _spriteCtl[s]); POKEA(sprite + OFF_SPR_ADL_L, address); } void spriteSetPosition(byte s, uint16_t x, uint16_t y) { uint16_t sprite = VKY_SP0_CTRL + (s * 8); 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 * 8); POKE(sprite, _spriteCtl[s] | v); } void spriteReset(void) { byte x; // Init and Hide all sprites. for (x=0; x<64; x++) { _spriteCtl[x] = 0; //spriteSetVisible(x, false); } } #endif