You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![no_std]externcrate alloc;use{
alloc::boxed::Box,
anyhow::Error,
crankstart::{
crankstart_game,
graphics::Graphics,
sprite::{Sprite,SpriteManager},Game,Playdate,},
crankstart_sys::{LCDBitmapFlip,PDRect},};structState{// If the sprite is not stored, the crash doesn't happen_sprite:Sprite,}implState{pubfnnew(_playdate:&Playdate) -> Result<Box<Self>,Error>{// Load an image, assign it to a custom-draw sprite, add the sprite.// Crash doesn't happen unless a bitmap is assigned to the sprite.let bitmap = Graphics::get().load_bitmap("graphics/wedge")?;let sprite_manager = SpriteManager::get_mut();letmut sprite = sprite_manager.new_sprite()?;// No crash unless it's custom-draw.
sprite.set_use_custom_draw()?;
sprite.set_image(bitmap,LCDBitmapFlip::kBitmapUnflipped)?;
sprite_manager.add_sprite(&sprite)?;Ok(Box::new(Self{_sprite: sprite }))}}implGameforState{fnupdate(&mutself,_playdate:&mutPlaydate) -> Result<(),Error>{Ok(())}fnupdate_sprite(&mutself, _:&mutSprite, _:&mutPlaydate) -> Result<(),Error>{Ok(())}// Same crash happens with or without this definition:fndraw_sprite(&self, _:&Sprite, _:&PDRect, _:&PDRect, _:&Playdate) -> Result<(),Error>{Ok(())}}crankstart_game!(State);
The result:
Loading C API game: target/Golf Date.pdx/pdex.so
16:23:47: Loading: OK
Thread 1 "PlaydateSimulat" received signal SIGSEGV, Segmentation fault.
0x0000555555968c88 in _compositeRow ()
(gdb) bt
#0 0x0000555555968c88 in _compositeRow ()
#1 0x00005555559735da in LCDBitmap_drawBitmap ()
#2 0x0000555555980d70 in LCD_drawBitmap ()
#3 0x00005555559828b9 in LCDSprite_draw ()
#4 0x000055555597d71c in LCDDisplayList_drawScreenRect ()
Dwarf Error: Cannot find DIE at 0xccf referenced from DIE at 0x1349f [in module target/Golf Date.pdx/pdex.so]
The backtrace is the same whether I define draw_sprite or not. Is it not being hooked up properly? Or is draw_sprite required to take some action that the SDK depends upon having happened?
The text was updated successfully, but these errors were encountered:
I don't recall seeing any C examples that use custom draw and then also set an image on the sprite. I'm not sure what the Playdate will do in that case.
If it's just something that shouldn't be done, I could make a doc comment :) A more mechanical fix might involve a bool on Sprite that tracks whether set_use_custom_draw has been called and whether an image has been set, failing if one or the other has already happened...
The backtrace suggests the crash is in the Playdate code, so maybe that's not a good thing to do? One could write a C version and see what happens. That, or ask on the forums.
Originally posted by @rtsuk in #35 (comment)
Here's a minimal reproduction:
The result:
The backtrace is the same whether I define
draw_sprite
or not. Is it not being hooked up properly? Or isdraw_sprite
required to take some action that the SDK depends upon having happened?The text was updated successfully, but these errors were encountered: