Skip to content

Commit

Permalink
EvmuLcd refactor and screen refresh asynchronicity
Browse files Browse the repository at this point in the history
1) EVMU_VERSION - bumped to 1.6.0
2) EvmuLcd
    - icons are now flags, so multiple can be set/get at a time
    - every toggle without side-effects is now a public variable
    - virtual method for refreshing the screen
    - signals for refreshing screen, icons changing, and screen being
      turned on/off
    - properties implemented
    - some sketchiness with storing/maintaining changes for icons has
      been resolved
    - everything should be implemented with BARE MINIMAL update
      frequency
    - MAYBE work later for screensaver updating (no code pat for that
      yet)
    - still need to implement STAD register!
    - screen refresh divisor has now become a public, configurable property
3) EvmuPic
    - added a comment for clarity
4) libGimbal
    - synchronized repo
  • Loading branch information
gyrovorbis committed Mar 4, 2023
1 parent 3f101ac commit bb62102
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 178 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.10)

set(EVMU_VERSION_MAJOR 1)
set(EVMU_VERSION_MINOR 5)
set(EVMU_VERSION_PATCH 1)
set(EVMU_VERSION_MINOR 6)
set(EVMU_VERSION_PATCH 0)
set(EVMU_VERSION
${EVMU_VERSION_MAJOR}.${EVMU_VERSION_MINOR}.${EVMU_VERSION_PATCH})

Expand Down
5 changes: 2 additions & 3 deletions legacy/source/formats/gyro_vmu_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,10 @@ int gyVmuLcdFileLoadAndStart(VMUDevice *dev, const char *filePath) {
dev->lcdFile = gyVmuLcdFileLoad(filePath);

if(dev->lcdFile) {
EvmuLcd_setDisplayEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(dev)->pLcd, GBL_TRUE);
EvmuLcd_setScreenEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(dev)->pLcd, GBL_TRUE);
EvmuLcd_setRefreshEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(dev)->pLcd, GBL_TRUE);
gyVmuLcdFileFrameStart(dev, 0);
for(int i = 0; i < EVMU_LCD_ICON_COUNT; ++i)
EvmuLcd_setIconEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(dev)->pLcd, i, GBL_FALSE);
EvmuLcd_setIcons(EVMU_DEVICE_PRISTINE_PUBLIC(dev)->pLcd, EVMU_LCD_ICONS_NONE);
dev->lcdFile->state = LCD_FILE_STATE_PLAYING;
return 1;
} else {
Expand Down
2 changes: 1 addition & 1 deletion legacy/source/gyro_vmu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int gyVmuDeviceLoadState(VMUDevice* dev, const char *path) {

//force shit to refresh!!
//dev->display.screenChanged = 1;
EvmuLcd_setUpdated(EVMU_DEVICE_PRISTINE_PUBLIC(dev)->pLcd, GBL_TRUE);
EVMU_DEVICE_PRISTINE_PUBLIC(dev)->pLcd->screenChanged = GBL_TRUE;

dev->lcdFile = NULL;
}
Expand Down
33 changes: 14 additions & 19 deletions legacy/wrappers/cpp/include/evmu-core-cpp/evmu_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class VmuDevice {
//====== LCD SCREEN DISPLAY ==========
bool getDisplayPixelValue(unsigned x, unsigned y) const;
bool setDisplayPixelValue(unsigned x, unsigned y, bool value) const;
bool isDisplayModeIconEnabled(EVMU_LCD_ICON icn) const;
bool setDisplayModeIconEnabled(EVMU_LCD_ICON icn, bool enabled=true) const;
EVMU_LCD_ICONS displayIconsEnabled(void) const;
void setDisplayIconsEnabled(EVMU_LCD_ICONS icn) const;
bool isDisplayPixelGhostingEnabled(void) const;
bool isDisplayLinearFilteringEnabled(void) const;
void setDisplayLinearFilteringEnabled(bool value) const;
Expand Down Expand Up @@ -306,10 +306,10 @@ inline bool VmuDevice::setDisplayPixelValue(unsigned x, unsigned y, bool value)


inline bool VmuDevice::isDisplayEnabled(void) const {
return EvmuLcd_displayEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd);
return EvmuLcd_screenEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd);
}
inline void VmuDevice::setDisplayEnabled(bool enabled) const {
EvmuLcd_setDisplayEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, enabled);
EvmuLcd_setScreenEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, enabled);
}
inline bool VmuDevice::isDisplayUpdateEnabled(void) const {
return EvmuLcd_refreshEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd);
Expand All @@ -318,31 +318,26 @@ inline void VmuDevice::setDisplayUpdateEnabled(bool enabled) const {
return EvmuLcd_setRefreshEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, enabled);
}

inline bool VmuDevice::isDisplayModeIconEnabled(EVMU_LCD_ICON icn) const {
return icn < EVMU_LCD_ICON_COUNT?
EvmuLcd_iconEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, icn) : 0;
inline EVMU_LCD_ICONS VmuDevice::displayIconsEnabled(void) const {
return EvmuLcd_icons(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd);
}

inline bool VmuDevice::setDisplayModeIconEnabled(EVMU_LCD_ICON icn, bool enabled) const {
if(icn < EVMU_LCD_ICON_COUNT) {
EvmuLcd_setIconEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, icn, enabled);
return true;
} else return false;
inline void VmuDevice::setDisplayIconsEnabled(EVMU_LCD_ICONS icons) const {
EvmuLcd_setIcons(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, icons);
}

inline bool VmuDevice::isDisplayPixelGhostingEnabled(void) const {
return EvmuLcd_ghostingEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd);
return !!EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd->ghostingEnabled;
}
inline void VmuDevice::setDisplayPixelGhostingEnabled(bool enabled) const {
EvmuLcd_setGhostingEnabled(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, enabled);
EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd->ghostingEnabled = enabled;
}

inline bool VmuDevice::isDisplayLinearFilteringEnabled(void) const {
return EvmuLcd_filter(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd) == EVMU_LCD_FILTER_LINEAR;
return EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd->filterEnabled;
}
inline void VmuDevice::setDisplayLinearFilteringEnabled(bool enabled) const {
EvmuLcd_setFilter(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd,
enabled? EVMU_LCD_FILTER_LINEAR : EVMU_LCD_FILTER_NONE);
EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd->filterEnabled = enabled;
}

inline int VmuDevice::getDisplayPixelGhostValue(unsigned x, unsigned y) const {
Expand Down Expand Up @@ -416,11 +411,11 @@ inline LCDFile* VmuDevice::getLcdFile(void) const {
}

inline bool VmuDevice::hasDisplayChanged(void) const {
return EvmuLcd_updated(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd);
return EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd->screenChanged;
}

inline void VmuDevice::setDisplayChanged(bool val) const {
EvmuLcd_setUpdated(EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd, val);
EVMU_DEVICE_PRISTINE_PUBLIC(_dev)->pLcd->screenChanged = val;
}


Expand Down
108 changes: 60 additions & 48 deletions lib/api/evmu/hw/evmu_lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@
#define EVMU_LCD_H

#include "../types/evmu_peripheral.h"
#include <gimbal/meta/signals/gimbal_signal.h>

#define EVMU_LCD_TYPE (GBL_TYPEOF(EvmuLcd))
#define EVMU_LCD_NAME "lcd"
#define EVMU_LCD_TYPE (GBL_TYPEOF(EvmuLcd))
#define EVMU_LCD_NAME "lcd"

#define EVMU_LCD(instance) (GBL_INSTANCE_CAST(instance, EvmuLcd))
#define EVMU_LCD_CLASS(klass) (GBL_CLASS_CAST(klass, EvmuLcd))
#define EVMU_LCD_GET_CLASS(instance) (GBL_INSTANCE_GET_CLASS(instance, EvmuLcd))
#define EVMU_LCD(instance) (GBL_INSTANCE_CAST(instance, EvmuLcd))
#define EVMU_LCD_CLASS(klass) (GBL_CLASS_CAST(klass, EvmuLcd))
#define EVMU_LCD_GET_CLASS(instance) (GBL_INSTANCE_GET_CLASS(instance, EvmuLcd))

#define EVMU_XRAM_BANK_SIZE 0x80
#define EVMU_XRAM_BANK_COUNT 3
#define EVMU_LCD_PIXEL_WIDTH 48
#define EVMU_LCD_PIXEL_HEIGHT 32
#define EVMU_LCD_GHOSTING_FRAMES 25
#define EVMU_XRAM_BANK_SIZE 0x80
#define EVMU_XRAM_BANK_COUNT 3
#define EVMU_LCD_PIXEL_WIDTH 48
#define EVMU_LCD_PIXEL_HEIGHT 32
#define EVMU_LCD_ICON_COUNT 4
#define EVMU_LCD_GHOSTING_FRAMES 25
#define EVMU_LCD_SCREEN_REFRESH_DIVISOR 50

#define GBL_SELF_TYPE EvmuLcd

GBL_DECLS_BEGIN

GBL_FORWARD_DECLARE_STRUCT(EvmuLcd);

GBL_DECLARE_ENUM(EVMU_LCD_REFRESH_RATE) {
EVMU_LCD_REFRESH_83HZ,
EVMU_LCD_REFRESH_166HZ
Expand All @@ -31,63 +36,70 @@ GBL_DECLARE_ENUM(EVMU_XRAM_BANK) {
EVMU_XRAM_BANK_ICON
};

GBL_DECLARE_ENUM(EVMU_LCD_ICON) {
EVMU_LCD_ICON_FILE,
EVMU_LCD_ICON_GAME,
EVMU_LCD_ICON_CLOCK,
EVMU_LCD_ICON_FLASH,
EVMU_LCD_ICON_COUNT
GBL_DECLARE_FLAGS(EVMU_LCD_ICONS) {
EVMU_LCD_ICONS_NONE = 0x0,
EVMU_LCD_ICON_FILE = 0x1,
EVMU_LCD_ICON_GAME = 0x2,
EVMU_LCD_ICON_CLOCK = 0x4,
EVMU_LCD_ICON_FLASH = 0x8,
EVMU_LCD_ICONS_ALL = 0xf
};

GBL_DECLARE_ENUM(EVMU_LCD_FILTER) {
EVMU_LCD_FILTER_NONE,
EVMU_LCD_FILTER_LINEAR,
EVMU_LCD_FILTER_COUNT
};
GBL_CLASS_DERIVE(EvmuLcd, EvmuPeripheral)
EVMU_RESULT (*pFnRefreshScreen)(GBL_SELF);
GBL_CLASS_END

GBL_CLASS_DERIVE_EMPTY (EvmuLcd, EvmuPeripheral)
GBL_INSTANCE_DERIVE_EMPTY(EvmuLcd, EvmuPeripheral)
GBL_INSTANCE_DERIVE(EvmuLcd, EvmuPeripheral)
GblBool screenChanged;
GblBool ghostingEnabled;
GblBool filterEnabled;
GblBool screenSaverEnabled; ///< Continue updating when display is disabled
GblSize screenRefreshDivisor; ///< How many hardware refreshes before software refresh
GBL_INSTANCE_END

GBL_PROPERTIES(EvmuLcd,
(enabled, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
(screenEnabled, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
(refreshEnabled, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
(refreshRate, GBL_GENERIC, (READ, WRITE), GBL_ENUM_TYPE),
(ghostingEnabled, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
(changed, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE)
(filterEnabled, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
(icons, GBL_GENERIC, (READ, WRITE), GBL_FLAGS_TYPE)
)

EVMU_EXPORT GblType EvmuLcd_type (void) GBL_NOEXCEPT;

EVMU_EXPORT GblBool EvmuLcd_displayEnabled (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setDisplayEnabled (GBL_SELF, GblBool enabled) GBL_NOEXCEPT;
GBL_SIGNALS(EvmuLcd,
(screenRefresh, (GBL_INSTANCE_TYPE, pReceiver)),
(screenToggle, (GBL_INSTANCE_TYPE, pReceiver),
(GBL_BOOL_TYPE, enabled)),
(iconsChange, (GBL_INSTANCE_TYPE, pReceiver),
(GBL_FLAGS_TYPE, flags))
)

EVMU_EXPORT GblBool EvmuLcd_refreshEnabled (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setRefreshEnabled (GBL_SELF, GblBool enabled) GBL_NOEXCEPT;
EVMU_EXPORT GblType EvmuLcd_type (void) GBL_NOEXCEPT;

EVMU_EXPORT EVMU_LCD_REFRESH_RATE
EvmuLcd_refreshRate (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setRefreshRate (GBL_SELF, EVMU_LCD_REFRESH_RATE rate) GBL_NOEXCEPT;
EVMU_EXPORT EvmuTicks EvmuLcd_refreshRateTicks (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT GblBool EvmuLcd_screenEnabled (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setScreenEnabled (GBL_SELF, GblBool enabled) GBL_NOEXCEPT;

EVMU_EXPORT GblBool EvmuLcd_iconEnabled (GBL_CSELF, EVMU_LCD_ICON icon) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setIconEnabled (GBL_SELF, EVMU_LCD_ICON icon, GblBool enabled) GBL_NOEXCEPT;
EVMU_EXPORT GblBool EvmuLcd_refreshEnabled (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setRefreshEnabled (GBL_SELF, GblBool enabled) GBL_NOEXCEPT;

EVMU_EXPORT GblBool EvmuLcd_pixel (GBL_CSELF, GblSize row, GblSize col) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setPixel (GBL_SELF, GblSize row, GblSize col, GblBool enabled) GBL_NOEXCEPT;
EVMU_EXPORT EVMU_LCD_REFRESH_RATE
EvmuLcd_refreshRate (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setRefreshRate (GBL_SELF, EVMU_LCD_REFRESH_RATE rate) GBL_NOEXCEPT;
EVMU_EXPORT EvmuTicks EvmuLcd_refreshRateTicks (GBL_CSELF) GBL_NOEXCEPT;

EVMU_EXPORT uint8_t EvmuLcd_decoratedPixel (GBL_CSELF, GblSize row, GblSize col) GBL_NOEXCEPT;
EVMU_EXPORT EVMU_LCD_ICONS
EvmuLcd_icons (GBL_CSELF) GBL_NOEXCEPT;

EVMU_EXPORT GblBool EvmuLcd_ghostingEnabled (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setGhostingEnabled (GBL_SELF, GblBool enabled) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setIcons (GBL_SELF, EVMU_LCD_ICONS icons) GBL_NOEXCEPT;

EVMU_EXPORT EVMU_LCD_FILTER
EvmuLcd_filter (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setFilter (GBL_SELF, EVMU_LCD_FILTER filter) GBL_NOEXCEPT;
EVMU_EXPORT GblBool EvmuLcd_pixel (GBL_CSELF, GblSize row, GblSize col) GBL_NOEXCEPT;

EVMU_EXPORT GblBool EvmuLcd_updated (GBL_CSELF) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setUpdated (GBL_SELF, GblBool updated) GBL_NOEXCEPT;
//EVMU_EXPORT uint8_t EvmuLcd_filteredPixel (CSELF, GblSize row, GblSize col) GBL_NOEXCEPT;
EVMU_EXPORT void EvmuLcd_setPixel (GBL_SELF,
GblSize row,
GblSize col,
GblBool enabled) GBL_NOEXCEPT;

EVMU_EXPORT uint8_t EvmuLcd_decoratedPixel (GBL_CSELF, GblSize row, GblSize col) GBL_NOEXCEPT;

GBL_DECLS_END

Expand Down
2 changes: 1 addition & 1 deletion lib/lib/libgimbal
2 changes: 1 addition & 1 deletion lib/source/hw/evmu_buzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ EVMU_EXPORT float EvmuBuzzer_pcmGain(const EvmuBuzzer* pSelf) {
pSelf_->tonePeriod > EVMU_BUZZER_FREQ_RESP_BASE_OFFSET_ +
GBL_COUNT_OF(freqResponse_))
{
return EVMU_BUZZER_FREQ_RESP_DEFAULT_VALUE_;
return (float)EVMU_BUZZER_FREQ_RESP_DEFAULT_VALUE_ / (float)EVMU_BUZZER_FREQ_RESP_MAX_VALUE_;
} else {
return (float)freqResponse_[pSelf_->tonePeriod -
EVMU_BUZZER_FREQ_RESP_BASE_OFFSET_] /
Expand Down
Loading

0 comments on commit bb62102

Please sign in to comment.