added fxdrawframes to the ArduboyFX examples.
This commit is contained in:
parent
c5dc1be337
commit
91c809697b
6 changed files with 86 additions and 28 deletions
BIN
Examples/ArduboyFX/fxdrawframes/fxdata/fxdata-data.bin
Normal file
BIN
Examples/ArduboyFX/fxdrawframes/fxdata/fxdata-data.bin
Normal file
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
/**** FX data header generated by fxdata-build.py tool version 1.12 ****/
|
||||
/**** FX data header generated by fxdata-build.py tool version 1.15 ****/
|
||||
|
||||
using uint24_t = __uint24;
|
||||
|
||||
|
|
|
@ -4,17 +4,66 @@
|
|||
//Initialize the arduboy object
|
||||
use arduboy_rust::prelude::*;
|
||||
const arduboy: Arduboy2 = Arduboy2::new();
|
||||
|
||||
// FX Data
|
||||
const FX_DATA_PAGE: u16 = 0xfffd;
|
||||
const FX_DATA_BYTES: u32 = 674;
|
||||
const ArduboyLogo: u32 = 0x000000;
|
||||
const ArduboyLogoWidth: u16 = 88;
|
||||
const ArduboyLogoHeight: u16 = 16;
|
||||
const FXLogo: u32 = 0x0000B4;
|
||||
const FXLogoWidth: u16 = 28;
|
||||
const FXLogoHeight: u16 = 16;
|
||||
const ArduboyLogo_Frame: u32 = 0x000128;
|
||||
const ArduboyLogo_LastFrame: u32 = 0x000290;
|
||||
|
||||
enum State {
|
||||
Init,
|
||||
Logo,
|
||||
Wait,
|
||||
Main,
|
||||
}
|
||||
static mut state: State = State::Init;
|
||||
static mut timer: u8 = 0;
|
||||
//The setup() function runs once when you turn your Arduboy on
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn setup() {
|
||||
// put your setup code here, to run once:
|
||||
arduboy.begin();
|
||||
fx::begin_data(FX_DATA_PAGE);
|
||||
arduboy.clear();
|
||||
arduboy.print(f!(b"Holmes is cool!\0"));
|
||||
arduboy.display();
|
||||
}
|
||||
#[no_mangle]
|
||||
#[export_name = "loop"]
|
||||
pub unsafe extern "C" fn loop_() {
|
||||
// put your main code here, to run repeatedly:
|
||||
if !arduboy.next_frame() {
|
||||
return;
|
||||
}
|
||||
arduboy.poll_buttons();
|
||||
match state {
|
||||
State::Init => {
|
||||
fx::set_frame(ArduboyLogo_Frame, 0);
|
||||
state = State::Logo;
|
||||
}
|
||||
State::Logo => {
|
||||
if fx::draw_loaded_frame() == 0 {
|
||||
state = State::Wait;
|
||||
timer = 60;
|
||||
}
|
||||
}
|
||||
State::Wait => {
|
||||
fx::draw_frame(ArduboyLogo_LastFrame);
|
||||
timer -= 1;
|
||||
if timer == 0 {
|
||||
state = State::Main;
|
||||
}
|
||||
}
|
||||
State::Main => {
|
||||
if arduboy.just_pressed(A | B) {
|
||||
state = State::Init;
|
||||
}
|
||||
}
|
||||
}
|
||||
fx::display_clear();
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ extern "C"
|
|||
{
|
||||
FX::begin(datapage);
|
||||
}
|
||||
void arduboyfx_begin_data_save(uint16_t datapage,uint16_t savepage )
|
||||
void arduboyfx_begin_data_save(uint16_t datapage, uint16_t savepage)
|
||||
{
|
||||
FX::begin(datapage,savepage);
|
||||
FX::begin(datapage, savepage);
|
||||
}
|
||||
void arduboyfx_display()
|
||||
{
|
||||
|
@ -22,83 +22,87 @@ extern "C"
|
|||
{
|
||||
FX::display(true);
|
||||
}
|
||||
void arduboyfx_draw_bitmap(int16_t x,int16_t y,uint24_t address,uint8_t frame,uint8_t mode )
|
||||
void arduboyfx_draw_bitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8_t mode)
|
||||
{
|
||||
FX::drawBitmap(x,y,address,frame,mode);
|
||||
FX::drawBitmap(x, y, address, frame, mode);
|
||||
}
|
||||
void arduboyfx_read_data_array(uint24_t address,uint8_t index,uint8_t offset,uint8_t elementSize,uint8_t * buffer,size_t length )
|
||||
void arduboyfx_read_data_array(uint24_t address, uint8_t index, uint8_t offset, uint8_t elementSize, uint8_t *buffer, size_t length)
|
||||
{
|
||||
FX::readDataArray(address,index,offset,elementSize,buffer,length);
|
||||
FX::readDataArray(address, index, offset, elementSize, buffer, length);
|
||||
}
|
||||
void arduboyfx_set_frame(uint24_t frame,uint8_t repeat )
|
||||
void arduboyfx_set_frame(uint24_t frame, uint8_t repeat)
|
||||
{
|
||||
FX::setFrame(frame,repeat);
|
||||
FX::setFrame(frame, repeat);
|
||||
}
|
||||
uint8_t arduboyfx_draw_loaded_frame()
|
||||
{
|
||||
return FX::drawFrame();
|
||||
}
|
||||
uint24_t arduboyfx_draw_frame(uint24_t address)
|
||||
{
|
||||
return FX::drawFrame(address);
|
||||
return FX::drawFrame(address);
|
||||
}
|
||||
void arduboyfx_set_cursor(int16_t x,int16_t y)
|
||||
void arduboyfx_set_cursor(int16_t x, int16_t y)
|
||||
{
|
||||
FX::setCursor(x,y);
|
||||
FX::setCursor(x, y);
|
||||
}
|
||||
void arduboyfx_draw_string_fx(uint24_t address)
|
||||
{
|
||||
FX::drawString(address);
|
||||
FX::drawString(address);
|
||||
}
|
||||
void arduboyfx_draw_string_buffer(const uint8_t * buffer )
|
||||
void arduboyfx_draw_string_buffer(const uint8_t *buffer)
|
||||
{
|
||||
FX::drawString(buffer);
|
||||
FX::drawString(buffer);
|
||||
}
|
||||
void arduboyfx_draw_string(const char *str)
|
||||
{
|
||||
FX::drawString(str);
|
||||
FX::drawString(str);
|
||||
}
|
||||
void arduboyfx_set_cursor_x(int16_t x)
|
||||
{
|
||||
FX::setCursorX(x);
|
||||
FX::setCursorX(x);
|
||||
}
|
||||
void arduboyfx_set_cursor_y(int16_t y)
|
||||
{
|
||||
FX::setCursorY(y);
|
||||
FX::setCursorY(y);
|
||||
}
|
||||
void arduboyfx_set_font(uint24_t address, uint8_t mode)
|
||||
{
|
||||
FX::setFont(address,mode);
|
||||
FX::setFont(address, mode);
|
||||
}
|
||||
void arduboyfx_set_font_mode(uint8_t mode)
|
||||
{
|
||||
FX::setFontMode(mode);
|
||||
}
|
||||
void arduboyfx_set_cursor_range(int16_t left,int16_t wrap)
|
||||
void arduboyfx_set_cursor_range(int16_t left, int16_t wrap)
|
||||
{
|
||||
FX::setCursorRange(left, wrap);
|
||||
}
|
||||
void arduboyfx_draw_number_i16(int16_t n, int8_t digits)
|
||||
{
|
||||
FX::drawNumber(n,digits);
|
||||
FX::drawNumber(n, digits);
|
||||
}
|
||||
void arduboyfx_draw_number_i32(int32_t n, int8_t digits)
|
||||
{
|
||||
FX::drawNumber(n,digits);
|
||||
FX::drawNumber(n, digits);
|
||||
}
|
||||
void arduboyfx_draw_number_u16(uint16_t n, int8_t digits)
|
||||
{
|
||||
FX::drawNumber(n,digits);
|
||||
FX::drawNumber(n, digits);
|
||||
}
|
||||
void arduboyfx_draw_number_u32(uint32_t n, int8_t digits)
|
||||
{
|
||||
FX::drawNumber(n,digits);
|
||||
FX::drawNumber(n, digits);
|
||||
}
|
||||
void arduboyfx_draw_char(uint8_t c)
|
||||
{
|
||||
FX::drawChar(c);
|
||||
}
|
||||
uint8_t arduboyfx_load_game_state(uint8_t *gameState,size_t size)
|
||||
uint8_t arduboyfx_load_game_state(uint8_t *gameState, size_t size)
|
||||
{
|
||||
return FX::loadGameState(gameState, size);
|
||||
}
|
||||
void arduboyfx_save_game_state(uint8_t *gameState,size_t size)
|
||||
void arduboyfx_save_game_state(uint8_t *gameState, size_t size)
|
||||
{
|
||||
FX::saveGameState(gameState, size);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ pub fn draw_bitmap(x: i16, y: i16, address: u32, frame: u8, mode: u8) {
|
|||
pub fn draw_frame(address: u32) -> u32 {
|
||||
unsafe { arduboyfx_draw_frame(address) }
|
||||
}
|
||||
pub fn draw_loaded_frame() -> u8 {
|
||||
unsafe { arduboyfx_draw_loaded_frame() }
|
||||
}
|
||||
pub fn set_frame(frame: u32, repeat: u8) {
|
||||
unsafe { arduboyfx_set_frame(frame, repeat) }
|
||||
}
|
||||
|
@ -114,6 +117,8 @@ extern "C" {
|
|||
fn arduboyfx_set_frame(frame: c_ulong, repeat: c_uchar);
|
||||
#[link_name = "arduboyfx_draw_frame"]
|
||||
fn arduboyfx_draw_frame(address: c_ulong) -> c_ulong;
|
||||
#[link_name = "arduboyfx_draw_loaded_frame"]
|
||||
fn arduboyfx_draw_loaded_frame() -> c_uchar;
|
||||
#[link_name = "arduboyfx_set_cursor"]
|
||||
fn arduboyfx_set_cursor(x: c_int, y: c_int);
|
||||
#[link_name = "arduboyfx_set_cursor_x"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue