diff --git a/compiler/res/prog8lib/cx16/sprites.p8 b/compiler/res/prog8lib/cx16/sprites.p8 index b85ae74ac..e4ee38b7b 100644 --- a/compiler/res/prog8lib/cx16/sprites.p8 +++ b/compiler/res/prog8lib/cx16/sprites.p8 @@ -34,6 +34,22 @@ sprites { cx16.vpoke(1, sprite_reg+7, height_flag<<6 | width_flag<<4 | palette_offset&15) ; 64x64 pixels, palette offset } + sub reset(ubyte spritenum_start, ubyte count) { + ; resets all sprite attributes for the given sprite range + ; this removes these sprites from the screen completely + ; (without disabling sprites globally so the mouse cursor remains visible) + if spritenum_start > 127 + return + if count + spritenum_start > 128 + return + cx16.VERA_CTRL = $00 + cx16.VERA_ADDR_H = $11 + cx16.VERA_ADDR = VERA_SPRITEREGS + spritenum_start * $0008 + repeat count { + unroll 8 cx16.VERA_DATA0 = $00 + } + } + sub data(ubyte spritenum, ubyte bank, uword addr) { addr >>= 5 addr |= (bank as uword)<<11 diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 15ceea66a..dc2e9f2f5 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,6 +2,8 @@ TODO ==== +- make "block address must be at least program load address + 20 (to allow for startup logic)" more flexible; the 20 should be a constant in the compilation target + ... diff --git a/examples/test.p8 b/examples/test.p8 index eebff9d94..47531cd53 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,12 +1,19 @@ +%import sprites %import textio %option no_sysinit %zeropage basicsafe main { sub start() { - txt.print_uwhex(sys.progstart(), true) - txt.spc() - txt.print_uwhex(sys.progend(), true) - txt.nl() + ubyte sprite + + for sprite in 1 to 99 { + sys.wait(1) + sprites.init(sprite, 0, 0, sprites.SIZE_8, sprites.SIZE_8, sprites.COLORS_256, 0) + sprites.pos(sprite, 10 + sprite*10, 10+sprite*4) + } + + sprites.reset(1, 100) + } }