You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.2 KiB
75 lines
2.2 KiB
#pragma once
|
|
#include "olcPixelGameEngine.h"
|
|
#include "SMX.h"
|
|
|
|
using namespace olc;
|
|
|
|
|
|
class PGEX_SMX : public PGEX{
|
|
|
|
public:
|
|
PGEX_SMX():PGEX(true){};
|
|
//SMX "screen" is 12x21
|
|
//Each panel is 4x7
|
|
static void SMXStateChangedCallback(int pad, SMXUpdateCallbackReason reason, void *pUser)
|
|
{
|
|
PGEX_SMX *pSelf = (PGEX_SMX*) pUser;
|
|
pSelf->SMXStateChanged( pad, reason );
|
|
}
|
|
|
|
static void SMXLogCallback(const char *log)
|
|
{
|
|
printf("-> %s\n", log);
|
|
}
|
|
|
|
void SMXStateChanged(int pad, SMXUpdateCallbackReason reason)
|
|
{
|
|
printf("Device %i state changed: %04x\n", pad, SMX_GetInputState(pad));
|
|
|
|
}
|
|
|
|
virtual void OnAfterUserCreate()override{
|
|
SMX_Start( SMXStateChangedCallback, this );
|
|
};
|
|
|
|
virtual void OnAfterUserUpdate(float fElapsedTime)override{
|
|
std::string lightData;
|
|
for (int pad=0;pad<2;pad++){
|
|
for(int i=0;i<9;i++){
|
|
int row=0;
|
|
for(int y=i/3*7;y<i/3*7+7;y+=2){
|
|
int col=0;
|
|
for(int x=i%3*4;x<i%3*4+4;x++){
|
|
if(row%2==1&&col%4==0){
|
|
col++;
|
|
continue;
|
|
}
|
|
Pixel p(pge->GetDrawTarget()->GetPixel(x,y));
|
|
lightData.append(1,p.r);
|
|
lightData.append(1,p.g);
|
|
lightData.append(1,p.b);
|
|
col++;
|
|
}
|
|
row+=2;
|
|
}
|
|
row=1;
|
|
for(int y=i/3*7+1;y<i/3*7+7;y+=2){
|
|
int col=0;
|
|
for(int x=i%3*4;x<i%3*4+4;x++){
|
|
if(row%2==1&&col%4==0){
|
|
col++;
|
|
continue;
|
|
}
|
|
Pixel p(pge->GetDrawTarget()->GetPixel(x,y));
|
|
lightData.append(1,p.r);
|
|
lightData.append(1,p.g);
|
|
lightData.append(1,p.b);
|
|
col++;
|
|
}
|
|
row+=2;
|
|
}
|
|
}
|
|
}
|
|
SMX_SetLights2( lightData.data(), lightData.size() );
|
|
}
|
|
}; |