Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - ProgrammerNerd

Pages: [1]
1
Casio Calculators / What would benefit prizm programmers and users?
« on: September 03, 2014, 11:04:44 pm »
I have noticed that prizm development overall appears to be infrequent and comprised of a few developers and is not something that is done as much as, say TI calculator development at-least the ones were TI somewhat lets you control the device you purchased. I understand that they have a larger market share (not due to technical superiority) but I am still surprised in the lack of prizm development as, (I find anyways) that it is an easy platform to develop for. So I am wondering what do prizm developers want? Already we have good documentation on the prizm wiki, example code, libfxcg which is getting better almost on a daily basis and GCC support the sh4 target so it is easy to compile programs. I am wondering if there are any prizm users here who would have liked to make a prizm program but had issues doing such? These issues may have since been resolved or be something that I can resolve. I can say right now that after I do some smaller projects for the prizm I plan to work on a larger project. I think it will be a port of TuxMath but I am not sure if that is the right direction to take. I want to make something that will make a large positive impact on the community and I am not sure what to do. I am wondering what will really bring interest in the platform. I wonder what do the prizm users want to see?

2
Casio Calculators / Libfxcg bugs with fixes.
« on: August 24, 2014, 03:16:43 pm »
Libfxcg is by no means perfect.
I would normally just submit a pull request however there is no guarantee that affect people will be aware that it is a bug in libfxcg and not their code and how to fix it. I have long had these fixed in my fork but never bothered to really document my changes. I think having a topic will get noticed by more people so that they can too make these fixes and point out any other bugs that they may have found.
All bugs listed here affect the most recent version of libfxcg as of the time of writing this post and can be found here: https://github.com/Jonimoose/libfxcg
Of course older versions are affected as well. I know for a fact that the linker script fix affects even the old PrizmSdk 0.3 from 2011 located here http://www.cemetech.net/news.php?id=486 I could not see if other bugs affect this version as the source is not included for it's libc and I have not made tests for it and see no need to as it is obsolete.
Lets not limit ourselves to bugs or terrible code that affect both. If you see a bug that affects only libfxcg it is best reported. Really no-one should be using the old PrizmSdk 0.3 from 2011 however should you find a bug that affects it and you want to post it go ahead it may give people another reason to upgrade.
1. fread is broken.
The way fread should work is that every time it is called the data following the read data is read the next call. However the function will always read from the beginning of the file. As of writting the file located here https://github.com/Jonimoose/libfxcg/blob/master/libc/stdio.c says in fwrite
Code: [Select]
size_t ret = Bfile_ReadFile_OS(handle_tonative(stream->fileno), buffer, n, 0);
However it should be
Code: [Select]
    size_t ret = Bfile_ReadFile_OS(handle_tonative(stream->fileno), buffer, n, -1);
The only difference is that I changed the zero to a negative one. What this means is that it continues to read where it left off.
2. Linker script does not correctly handle BSS.
When you have static variables in a library you may be surprised to find that global and static variables are not initialized. Fix this by changing
Code: [Select]
        .bss : {
                _bbss = . ;
                *(.bss) *(COMMON);
                _ebss = . ;
        } >ram
To
Code: [Select]
        .bss : {
                _bbss = . ;
                *(.bss)
                *(.bss*)
                *(COMMON)
                _ebss = . ;
        } >ram
The reason why this works is that the linker will insert things such as .bss_variable_name when compiled in a library. This puts it in the proper section and upon start-up it will be cleared just like it should.
3. The memove implementation is terrible.
Actually I had worse insults that I was tempted to put but I am sure whoever wrote it makes better code by now and I do not want to hold this against them but
Code: [Select]
void* memmove(void* destination, const void* source, size_t num) {
void* d = malloc(num);
memcpy(d, source, num);
memcpy(destination, d, num);
free(d);
return destination;
}
Yes that is right, I did not make this code up for slander purposes. It is really in there in string.c
Lets replace it with something better
Code: [Select]
void *memmove(void *dst, const void *src, size_t count){
//From dietlibc
char *a = dst;
const char *b = src;
if (src!=dst){
if (src>dst){
while (count--) *a++ = *b++;
}else{
a+=count-1;
b+=count-1;
while (count--) *a-- = *b--;
}
}
return dst;
}
The reason it is considered a bug is because if you need to copy something larger than the small heap the function will fail.
4.The exit function crashes the calculator on purpose.
Code: [Select]
void exit(int status) {
    fprintf(stderr, "TERMINATED (%i)", status);
    // We don't have a clean way to exit (right now), so just crash it.
    ((void (*)())1)(); // Unaligned instruction
}
Actually we do have a clean way to exit. When this function is called there is usually a problem so the user should be able to see the error code. To do this we print the error message and use the GetKey function, from there the user can press the menu key when they are done reading the error code so just replace it with:
Code: [Select]
void exit(int status) {
fprintf(stderr, "TERMINATED (%i)\nPress menu key to exit\n", status);
int key;
while(1)
GetKey(&key);
}
Also edit the header stdlib.h change
Code: [Select]
void exit(int status);
to
Code: [Select]
void exit(int status) __attribute__ ((noreturn));
Also while you are there fix the abs definition so that it matches the source code.
Change
Code: [Select]
long abs(long n);
To
Code: [Select]
int abs(int x);
And now add #include <stdlib.h> to the top of stdlib.c
The reason for doing this is so that when compiling stdlib.c gcc knows that this function does not return in addition to the program you compile with gcc and libfxcg that involves exit. Yes we could just duplicate the __attribute__ ((noreturn)) to also be in stdlib.c but I feel that this is a cleaner solution. Also if stdlib.c fails to compile due to you including it, that means the headers suck and need improvement which is why I fixed the abs definition.
5. You cannot actually see the errors.
I don't really consider this a bug per say, however I believe it is much better to be able to see the error messages on screen instead of sending anything from stderr to the serial port.
So replace both fwrite_term and fwrite with
Code: [Select]
static size_t fwrite_term(const void *ptr, size_t size, size_t nitems,FILE *stream,int col){
static int termXfxcg,termYfxcg;
    char *buffer = alloca(1 + nitems * size);
if (buffer == NULL) {
IOERR(stream, ENOMEM);
return 0;
}

memcpy(buffer, ptr, nitems * size);
buffer[nitems * size] = '\0';
const char *outp = buffer;
char *eol;

// Loop over all lines in buffer, terminate once we've printed all lines.
do{
eol = strchr(outp, '\n');
if(eol) {
*eol = '\0';
}

// Cast to wider type for correct pointers
PrintMiniMini(&termXfxcg, &termYfxcg, outp, 0, col, 0);

// CR/LF if applicable
if(eol){
termXfxcg = 0;
termYfxcg += 10;
outp = eol + 1;
}
if(termYfxcg>=200)
termYfxcg=0;
}while (eol);
return nitems;
}
// TODO make ptr, stream restrict for optimization
size_t fwrite(const void *ptr,size_t size,size_t nitems,FILE *stream){
if (isstdstream(stream)) {
if(stream->fileno==2){
// stderr: display but red font
//return fwrite_serial(ptr, size, nitems, stream);
return fwrite_term(ptr, size, nitems, stream,TEXT_COLOR_RED);
}else if(stream->fileno==1){
// stdout: display
return fwrite_term(ptr, size, nitems, stream,TEXT_COLOR_BLACK);
}else{
// stdin..?
}
}
// TODO this must be able to fail, but how?
Bfile_WriteFile_OS(handle_tonative(stream->fileno), ptr, size * nitems);
return nitems;
}
Now in stdio.h remove the lines that say
Code: [Select]
unsigned short termx, termy;
6. fopen is also broken.
It is common knowledge that forgetting to null terminate a string that should be null terminated will cause a bug.
Look for:
Code: [Select]
Bfile_StrToName_ncpy(chars16, path, plen);
and replace it with
Code: [Select]
Bfile_StrToName_ncpy(chars16, path, plen+1);
This will null terminate the string.

3
Casio Calculators / Casio prizm Mandelbrot explorer
« on: August 22, 2014, 02:43:24 pm »
The Mandelbrot fractal is quite a sight.
Such wonder and amazement that can be found while viewing the Mandelbrot fractal can now be had on the Casio Prizm graphing calculator.
In addition this program can also be compiled for the PC assuming SDL is installed.
Just run make and it will be up and running.
There is very little difference in function between the PC version and the casio prizm version, the resolution is higher but that is it.

The controls are
Left, right, up, down moves the window in that direction
Menu key or ESC on the PC, exits to the menu or exits the program (PC)
F1 sets maximum iterations to 65535
F2 sets the maximum iterations to 224 (this is the default upon starting the program)
F3 toggles deep mode which is on by default. This means you can zoom in deeper with a slight performance hit.
I do not notice the difference
1 subtracts one from the maximum iterations
2 adds one to the maximum iterations
3 subtracts ten from the maximum iterations
4 adds ten to the maximum iterations
5 subtracts 100 from the maximum iterations
6 adds 100 to the maximum iterations
Shift zooms in
Alpha (ALT on PC) zooms out
Source code https://github.com/ComputerNerd/Mandelbrot-Casio-Prizm-Explorer
Binary https://github.com/ComputerNerd/Mandelbrot-Casio-Prizm-Explorer/blob/master/mandelbrot.g3a
Screen shots (from the PC version which gets very similar output differing only in resolution).


Anyways if you have any bug report(s), feature request(s), pull request(s), patch(es) or whatever relates to this I would be happy to hear about them.

4
Casio Calculators / Casio prizm PNG viewer
« on: May 31, 2014, 10:52:17 pm »
Download here http://www.casiopeia.net/forum/downloads.php?view=detail&df_id=147
Edit sorry to release a new version so soon but I just noticed that in certain instances libpng would output a harmless warning however this is annoying as it overlaps the image so I fixed the cause of the warning.
The source code can be found here https://github.com/ComputerNerd/Casio-ImageView
===========================================
Casio prizm PNG viewer
===========================================
This is a png viewer for the casio prizm.
It uses libpng (which is paired with zlib) to decompress a PNG file.
When you load a png file it is resampled to fill the screen but aspect ratio is preserved.
As of now a simple bilinear filtering is used
but if there is intrest I may replace it with something better.

The version you downloaded is version 1.0
It is likely that there will be versions
so if you notice that I post in the thread
see what I put it may be an update.

============================================
Controls
============================================
You will see a file browser on startup use the arrow pad to select a file.
Then press either F1 or EXE to select the PNG file.
Press any key except menu (which actully takes you to the menu)
to go back to the file browser.

===========================================
Notes and tips
===========================================
Since the casio prizm does not have lots of memory run pngout
on the images before putting them on your calculator.
I have included instructions on how to compile libpng and zlib here:
https://github.com/ComputerNerd/Casio-ImageView/blob/master/Compile%20Libpng
Following these instructions gets you a libraries (libpng and zlib)
that you could link against your add-in.
If you want to use a png in an add-in a good option would be to make a 16bit 1 channel image containg rgb565 data.
I however would not use png instead I would just use zlib directly with a simpler image format.
For example uint32_t width,uint32_t height, deflate compressed sequential rgb565 data created by zlib's deflate(2) function.
But if you feel comfortable with png that is an option.
Also you can store the pngs as a const array it does not need to be a file. I just used files because this is an image viewer.
The purpse of this program is simply to show off how capable the casio prizm is.
The PNG image format is well know and I think some people wrongly precive it as a very ram intensive thing to decode.
Libpng can output a row at a time or N amount of rows. When width!=384 or if height>=216 then the image is scaled
Ony enough ram to hold 2 rows is needed which is 6*width bytes of ram. I use bilinear scaling that is why two rows are needed to be read.
After the code interoplates the pixels the resulting pixel is converted to rgb565 and sent to VRAM.
When the width==384 and height<=216 a buffer is created and the image is read all at once
then simply converted to rgb565 and send to VRAM

5
Casio Calculators / MPEG2 player for casio prizm
« on: April 13, 2014, 05:08:52 pm »
This is more of a front-end to libmpeg2
The source code can be found at https://github.com/ComputerNerd/Casio-prizm-mpeg2-player
You can download the file here http://www.casiopeia.net/forum/downloads.php?view=detail&df_id=146
The latest version is 1.031 which fixes a scaling bug that causes some pixels to be ignored.
Version 1.3 fixed an issue on real hardware where the screen would get corrupt. It is highly recommend that you run the latest version. Running 1.2 or older is a bad choice.
To use this program you will see a file browser
I have it set to show *.m2v files because there is no audio but it may play mpeg2 with audio (untested) but it will be ignored
As for what resolution you should make the video I would not go over half of screen resolution it should support 384x216 maximum but malloc errors are encountered
While the video is playing press exit to go back to the file browser if you want to do such.
In the readme I have included compiling instructions if you are interested in using libmpeg2 in one of your own projects.
To encode video I used
the following avisynth script
AviSource("FILE PATH HERE")
BilinearResize(176,96)
ChangeFPS(128,13)
AssumeFPS("ntsc_video")
ConvertToYV12()

To encode the video I used HC encoder http://hank315.nl/

There are some settings that you should be aware of please use 1:1 ratio for pixels
Also if you want height to be a multiple of 16 instead of 32 make sure progress sequence is checked (In settings 2)

Icon from http://www.pubzi.com/f/Movie-icon.svg

6
Casio Calculators / Delete this topic please
« on: April 03, 2014, 08:34:54 pm »
I resolved the issue myself it was a silly mistake.

7
Casio Calculators / Quick tick count question. [Resolved]
« on: March 17, 2014, 08:53:03 pm »
I was wondering is there a way to get a more precise tick count than 128 ticks per second on the casio prizm? I have no idea if such an option exists or even what to look for. It appears that 128 ticks per second is the best the RTC can do. If anyone has knowledge of a way to get a more precise tick count than please do tell.

8
Casio Calculators / Open Jazz jackrabbit Casio prizm port
« on: December 16, 2013, 12:48:17 am »
Edit I have released a new version that address some graphical issues on the HUD and fixes the fact that it is impossible to exit the game. The reason it is fixed is because instead of using a fixed Save/load vram address which may only be correct on a certian firmware version it instead searches for it.
I have ported open Jazz jackrabbit to the casio prizm. Here are the controls
Code: [Select]
keys[C_UP].key = KEY_PRGM_UP;
keys[C_DOWN].key = KEY_PRGM_DOWN;
keys[C_LEFT].key = KEY_PRGM_LEFT;
keys[C_RIGHT].key = KEY_PRGM_RIGHT;
keys[C_JUMP].key = KEY_PRGM_ALPHA;
keys[C_SWIM].key = keys[C_JUMP].key;
keys[C_FIRE].key = KEY_PRGM_SHIFT;
keys[C_CHANGE].key = KEY_PRGM_OPTN;//change weapon
keys[C_ENTER].key = KEY_PRGM_RETURN;
keys[C_ESCAPE].key = KEY_PRGM_EXIT;
keys[C_STATS].key = KEY_PRGM_F1;
keys[C_PAUSE].key = KEY_PRGM_F2;
keys[C_YES].key = KEY_PRGM_F3;
keys[C_NO].key = KEY_PRGM_F4;
Here is the source code https://github.com/ComputerNerd/Open-Jazz-Jackrabbit-Casio-Prizm-port
And here is the binary.
http://www.casiopeia.net/forum/downloads.php?view=detail&df_id=145
To use the program place openjazz.g3a in the root directory then create a folder called jazz place openjazz.000 in that folder then download one of the many versions of jazz jackrabbit and place the resource files in that folder. You do not need the sound files and you do not need the "extra" files for example the cd version includes a demo of another game you don't need that you also don't need the *.exe file also there are some unneeded cutscene files that take up lots of memory those are not needed when in doubt use grep on the source code to see if the file is needed.
Edit Screenshots:


Pages: [1]