forked from len0rd/rockbox
Initial commit of zxbox - a ZX Spectrum emulator ported by Anton Romanov. It theoretically runs on all targets, but I have not included it in the Archos builds because it is just too slow to be usable.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10950 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1350d57751
commit
05a7f14f8d
88 changed files with 19624 additions and 0 deletions
55
apps/plugins/zxbox/helpers.c
Normal file
55
apps/plugins/zxbox/helpers.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "zxconfig.h"
|
||||
|
||||
int my_getc(int fd){
|
||||
unsigned char c;
|
||||
if ( rb->read(fd, &c, 1) )
|
||||
return c;
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
|
||||
off_t my_ftell(int fd){
|
||||
return rb->lseek(fd, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
int my_putc(char c , int fd){
|
||||
return rb->write(fd,&c,1);
|
||||
}
|
||||
|
||||
void *my_malloc(size_t size)
|
||||
{
|
||||
static char *offset = NULL;
|
||||
static int totalSize = 0;
|
||||
char *ret;
|
||||
|
||||
int remainder = size % 4;
|
||||
|
||||
size = size + 4-remainder;
|
||||
|
||||
if (offset == NULL)
|
||||
{
|
||||
offset = rb->plugin_get_audio_buffer(&totalSize);
|
||||
}
|
||||
|
||||
if (size + 4 > abs(totalSize) )
|
||||
{
|
||||
/* printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");*/
|
||||
/* We've made our point. */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = offset + 4;
|
||||
*((unsigned int *)offset) = size;
|
||||
|
||||
offset += size + 4;
|
||||
totalSize -= size + 4;
|
||||
return ret;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue