Skip to content

Commit

Permalink
FXSDK Source code
Browse files Browse the repository at this point in the history
  • Loading branch information
BeefStew34 authored Jan 8, 2023
1 parent e42e5d7 commit 964a707
Show file tree
Hide file tree
Showing 2 changed files with 229 additions and 0 deletions.
83 changes: 83 additions & 0 deletions FXVideoPlayer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include "fxlib.h"
#include "FXVideoPlayer.h"


int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned int key;

Bdisp_AllClr_DDVRAM();

handle = Bfile_OpenFile(PathName,_OPENMODE_READWRITE);


PrintXY(0, 0, "hold + to pause",1);
PrintXY(0, 8, "- to quit", 1);
PrintXY(0, 16, "0 to restart", 1);
PrintXY(0, 56, "Any Key to start", 1);
GetKey(&key);
bf = Bfile_ReadFile(handle, &Compressed_frame, 2000, 0);
decode_frame();
while (1) {
if (IsKeyDown(KEY_CHAR_0) == 1)
FrameCount = 0;
if (IsKeyDown(KEY_CHAR_PLUS) == 1)
play = 0;
if (IsKeyUp(KEY_CHAR_PLUS) == 1)
play = 1;
if (IsKeyDown(KEY_CHAR_MINUS) == 1)
break;

if (play == 1) {
bf = Bfile_ReadFile(handle, &Compressed_frame, 2000, FrameCount);
decode_frame();
Bdisp_PutDisp_DD();
Sleep(100);
}
}
//Old Frame By Frame Debug Code
/*GetKey(&key);
switch(key){
case KEY_CTRL_UP:
bf = Bfile_ReadFile(handle,&Compressed_frame,2000,FrameCount);
decode_frame();
Sleep(150);
break;
case KEY_CHAR_0:
FrameCount = 0;
bf = Bfile_ReadFile(handle,&Compressed_frame,2000,FrameCount);
decode_frame();
break;
}
}*/
return 1;
}



//************** Please do not change the following source. ****************


#pragma section _BR_Size
unsigned long BR_Size;
#pragma section


#pragma section _TOP

//****************************************************************************
// InitializeSystem
//
// param : isAppli : 1 = Application / 0 = eActivity
// OptionNum : Option Number (only eActivity)
//
// retval : 1 = No error / 0 = Error
//
//****************************************************************************
int InitializeSystem(int isAppli, unsigned short OptionNum)
{
return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}

#pragma section

146 changes: 146 additions & 0 deletions FXVideoPlayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@

// itoa - https://wiki.planet-casio.com/en/Syscalls
#include "fxlib.h"
#define SCA 0xD201D002
#define SCB 0x422B0009
#define SCE 0x80010070
typedef int(*sc_iv)(void);
typedef void(*sc_viuc)( int, unsigned char* );
typedef void(*sc_vpuc)(unsigned char*);
const unsigned int sc0541[] = { SCA, SCB, SCE, 0x0541 };
#define itoa (*(sc_viuc)sc0541)

//https://www.liquisearch.com/nibble/extracting_a_nibble_from_a_byte
#define HI_NIBBLE(b) (((b) >> 4) & 0x0F)
#define LO_NIBBLE(b) ((b) & 0x0F)


//char Menu[][5] = {"One","Two","Three","Four","Five","Six"};
//char Menu[][5] = {"One","Two"};


unsigned char Compressed_frame[1024];
unsigned long Frame[256];


int FrameCount = 0;

FONTCHARACTER PathName[]={'\\' ,'\\','c','r','d','0','\\','v','i','d','.','c','a','l',0};
//FONTCHARACTER PathName[]={'\\' ,'\\','f','l','s','0','\\','n','u','m','.','j','o','e',0};

unsigned char viewnumber[8];
int handle,bf,index,bitCount,j,output;
int drawIndex = 0;
int debug_Count = 0;
unsigned char highNibble,lowNibble;
char play = 1;

void decode_frame(){
int rep,bits,i=0;
int x =0;
int y =0;

for(i =0;i < 2000; ++i){
int repititions = HI_NIBBLE(Compressed_frame[i]);
char data = LO_NIBBLE(Compressed_frame[i]);
int BitOrder[4];
if(!Compressed_frame[i]){
FrameCount += i+1;
return;
}
for(bits =3; bits > -1; --bits){
if(data & 0x1){
BitOrder[bits] = 1;
}
else{
BitOrder[bits] = 0;
}
data= data >> 1;
}

for(rep =0;rep < repititions; ++rep){

for(bits = 0; bits < 4; ++bits){
//Had a funny problem where the bottem four pixels where at the wrong place
//and had to shuffle everything around
if(y < 60){
Bdisp_SetPoint_VRAM(x,y+4,BitOrder[bits]);
}
else{
Bdisp_SetPoint_VRAM(x,y-60,BitOrder[bits]);
}

y++;
if(y==64){
y= 0;
x++;
}
}
}
}
}

void print_Frame(){
int x,i,y;
for(x=0; x < 256; ++x)
{
if(x%2 ==0){
for(bitCount =32; bitCount>1; --bitCount)
{
if (Frame[x] & 0x01) {
Bdisp_SetPoint_VRAM(x/2,bitCount,1);
}
else
{
Bdisp_SetPoint_VRAM(x/2,bitCount,0);
}
Frame[x] = Frame[x] >> 1;

}
}
else
{
for(bitCount = 64; bitCount>32; --bitCount)
{
if (Frame[x] & 0x01) {
Bdisp_SetPoint_VRAM(x/2,bitCount,1);
}
else
{
Bdisp_SetPoint_VRAM(x/2,bitCount,0);
}
Frame[x] = Frame[x] >> 1;

}
}
}
}
void make_Frame(){
int x,y;
for(x=0; x < 128; ++x){
for(y= 0; y < 8; ++y){
if(y < 4){
//Frame[x][y] = 0x1A;
}
else{
//Frame[x][y] = 0x1A;
}
}
}
}
/*void draw_menu() {
int i;
int maxLoop = 3;
int MenuSize = sizeof(Menu) / sizeof(Menu[0]);
if(MenuSize < 3)
{
maxLoop = MenuSize;
}
for(i = 0; i < maxLoop; ++i){
Bdisp_AreaReverseVRAM(3,(i)*21,125,(i+1)*21);
locate(2,(i*3)+2);
//PrintRev(Menu[i]);
}
Bdisp_AreaReverseVRAM(6,((drawIndex)*21),122,((drawIndex+1)*21));
}*/

0 comments on commit 964a707

Please sign in to comment.