1
0
Fork 0
forked from len0rd/rockbox

yet more code cleanup, quick snapshot feature,sound should no longer crash,light optimizations

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11041 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Anton Romanov 2006-09-25 09:44:10 +00:00
parent 52f4c4c82b
commit ec2a5cce1a
21 changed files with 125 additions and 2033 deletions

View file

@ -1,3 +1,5 @@
25.09.2006 yet more code cleanup, quick snapshot feature,sound should no longer crash,light optimizations
04.09.2006 code cleanup; now using IRAM correctly (i hope) 04.09.2006 code cleanup; now using IRAM correctly (i hope)
31.08.2006 far better sound, volume option is working now 31.08.2006 far better sound, volume option is working now

View file

@ -5,11 +5,12 @@
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/ # \/ \/ \/ \/ \/
# #
OPT_FLAGS=-O3 -funroll-loops
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) -I. $(TARGET_INC) -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) -I. $(TARGET_INC)
CFLAGS = $(INCLUDES) $(GCCOPTS) -O2 $(TARGET) $(EXTRA_DEFINES) \ CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) \
-DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN $(OPT_FLAGS) $(PROFILE_OPTS)
ifdef APPEXTRA ifdef APPEXTRA

View file

@ -8,7 +8,6 @@ rom_imag.c
snapshot.c snapshot.c
spconf.c spconf.c
spect.c spect.c
spectkey.c
spkey.c spkey.c
spmain.c spmain.c
spperif.c spperif.c

View file

@ -33,15 +33,7 @@ void *my_malloc(size_t size)
if (size + 4 > abs(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. */ /* We've made our point. */
return NULL; return NULL;
} }

View file

@ -32,7 +32,10 @@ char msgbuf[MAXMSGLEN];
char *spif_get_filename(void) char *spif_get_filename(void)
{ {
char *name=NULL; char *name=NULL;
/* char *name, *s; #if 0
/* should be implemented when adding ability */
/* to open snapshots from within zxbox */
char *name, *s;
s = get_filename_line(); s = get_filename_line();
for(; *s && isspace((int) *s); s++); for(; *s && isspace((int) *s); s++);
@ -44,7 +47,7 @@ char *spif_get_filename(void)
printf("Canceled!\n"); printf("Canceled!\n");
return NULL; return NULL;
} }
*/ #endif
return name; return name;
} }
@ -52,7 +55,11 @@ char *spif_get_tape_fileinfo(int *startp, int *nump)
{ {
*startp=*nump=0; *startp=*nump=0;
char *name=NULL; char *name=NULL;
/* char *name, *s; #if 0
/* should be implemented when adding ability */
/* to tapes snapshots from within zxbox */
char *name, *s;
int res; int res;
s = get_filename_line(); s = get_filename_line();
@ -81,14 +88,14 @@ char *spif_get_tape_fileinfo(int *startp, int *nump)
if(res < 2) *startp = -1; if(res < 2) *startp = -1;
if(res < 3) *nump = -1; if(res < 3) *nump = -1;
*/ #endif
return name; return name;
} }
void put_msg(const char *msg) void put_msg(const char *msg)
{ {
#ifndef USE_GRAY #ifndef USE_GRAY
rb->splash (HZ/10,true , msg ); rb->splash (HZ/2,true , msg );
#else #else
LOGF(msg); LOGF(msg);
(void)msg; (void)msg;

View file

@ -16,7 +16,7 @@
#define ZX_DOWN BUTTON_DOWN #define ZX_DOWN BUTTON_DOWN
#define ZX_LEFT BUTTON_LEFT #define ZX_LEFT BUTTON_LEFT
#define ZX_RIGHT BUTTON_RIGHT #define ZX_RIGHT BUTTON_RIGHT
#define ZX_SELECT BUTTON_SELECT #define ZX_SELECT BUTTON_ON
#define ZX_MENU BUTTON_MODE #define ZX_MENU BUTTON_MODE
#elif CONFIG_KEYPAD == GIGABEAT_PAD #elif CONFIG_KEYPAD == GIGABEAT_PAD

View file

@ -25,7 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include "helpers.h" #include "helpers.h"
/*#include <errno.h>*/
#include "zxconfig.h" #include "zxconfig.h"
#define DIR_SEP_CHAR '/' #define DIR_SEP_CHAR '/'

View file

@ -33,17 +33,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/*#include <errno.h>*/
/*#include "string.h"*/
#include <sys/types.h> #include <sys/types.h>
#define COMPRESS_SAVE 1 #define COMPRESS_SAVE 1
static char quick_snap_file[MAXFILENAME]; static char quick_snap_file[]="/.rockbox/zxboxq.z80";
static int qsnap_created = 0;
typedef struct { typedef struct {
int isfile; int isfile;
/*FILE *fp;*/
int fd; int fd;
unsigned len; unsigned len;
@ -65,7 +62,7 @@ static int snread(void *ptr, int size, SNFILE *snfp)
int i; int i;
byte *dest; byte *dest;
if(snfp->isfile) /*return (int) fread(ptr, 1, (size_t) size, snfp->fp);*/ if(snfp->isfile)
return (int) rb->read( snfp->fd,ptr, (size_t) size); return (int) rb->read( snfp->fd,ptr, (size_t) size);
dest = (byte *) ptr; dest = (byte *) ptr;
@ -177,7 +174,6 @@ struct z80_page_s {
#define z80_pg_size 3 /* sizeof(struct z80_page_s)=3 */ #define z80_pg_size 3 /* sizeof(struct z80_page_s)=3 */
/*static FILE *savfp;*/
static int savfd; static int savfd;
static int memptr; static int memptr;
@ -282,13 +278,9 @@ static void snsh_z80_save(int fd)
Bit 5 : 1=Block of data is compressed Bit 5 : 1=Block of data is compressed
Bit 6-7: No meaning Bit 6-7: No meaning
*/ */
/*fwrite(&z80, z80_145_size, 1, fp);*/
rb->write(fd,&z80,z80_145_size); rb->write(fd,&z80,z80_145_size);
if(!to_comp) if(!to_comp)
/*fwrite(z80_proc.mem + 0x4000, 0xC000, 1, fp);*/
rb->write(fd,z80_proc.mem + 0x4000,0xC000); rb->write(fd,z80_proc.mem + 0x4000,0xC000);
else { else {
memptr = 0x4000; memptr = 0x4000;
@ -327,8 +319,6 @@ static void snsh_sna_save(int fd)
sna.im = z80_proc.it_mode & 0x03; sna.im = z80_proc.it_mode & 0x03;
/*fwrite(&sna, sna_size, 1, fp);
fwrite(z80_proc.mem + 0x4000, 0xC000, 1, fp);*/
rb->write(fd,&sna, sna_size); rb->write(fd,&sna, sna_size);
rb->write(fd,z80_proc.mem + 0x4000, 0xC000); rb->write(fd,z80_proc.mem + 0x4000, 0xC000);
@ -590,21 +580,13 @@ static void snsh_sna_load(SNFILE *fp)
sp_init_screen_mark(); sp_init_screen_mark();
} }
/*
static void cleanup_qsnap(void)
{
if(qsnap_created) rb->remove(quick_snap_file);
}
*/
static void save_snapshot_file_type(char *name, int type) static void save_snapshot_file_type(char *name, int type)
{ {
/*FILE *snsh;*/
int snsh; int snsh;
snsh = rb->open(name, O_WRONLY); snsh = rb->open(name, O_WRONLY);
if(snsh < 0) { if(snsh < 0) {
snsh = rb->creat(name, O_WRONLY); snsh = rb->creat(name, O_WRONLY);
/* sprintf(msgbuf, "Could not open snapshot file `%s', %s",
name, strerror(errno));*/
if(snsh < 0) { if(snsh < 0) {
put_msg("Could not create snapshot file"); put_msg("Could not create snapshot file");
return; return;
@ -633,22 +615,14 @@ void save_snapshot_file(char *name)
} }
save_snapshot_file_type(filenamebuf, type); save_snapshot_file_type(filenamebuf, type);
char msgbuf [MAXFILENAME];
/* sprintf(msgbuf, "Saved snapshot to file %s", filenamebuf); rb->snprintf(msgbuf,MAXFILENAME, "Saved snapshot to file %s", filenamebuf);
put_msg(msgbuf);*/ put_msg(msgbuf);
} }
void save_quick_snapshot(void) void save_quick_snapshot(void)
{ {
/* if(!qsnap_created) { save_snapshot_file_type(quick_snap_file, SN_Z80);
if(tmpnam(quick_snap_file) == NULL) {
put_msg("Could not create temporary file for quick snapshot");
return;
}
qsnap_created = 1;
atexit(cleanup_qsnap);
}
save_snapshot_file_type(quick_snap_file, SN_Z80);*/
} }
void save_snapshot(void) void save_snapshot(void)
@ -665,7 +639,6 @@ void save_snapshot(void)
void load_snapshot_file_type(char *name, int type) void load_snapshot_file_type(char *name, int type)
{ {
int filetype = FT_SNAPSHOT; int filetype = FT_SNAPSHOT;
/*FILE *snsh;*/
int snsh; int snsh;
SNFILE snfil; SNFILE snfil;
@ -705,10 +678,14 @@ void snsh_z80_load_intern(byte *p, unsigned len)
void load_quick_snapshot(void) void load_quick_snapshot(void)
{ {
if(!qsnap_created) { int qsnap;
qsnap = rb->open(quick_snap_file,O_RDONLY);
if(qsnap < 0) {
put_msg("No quick snapshot saved yet"); put_msg("No quick snapshot saved yet");
return; return;
} }
else
rb->close ( qsnap );
load_snapshot_file_type(quick_snap_file, SN_Z80); load_snapshot_file_type(quick_snap_file, SN_Z80);
} }

View file

@ -19,7 +19,6 @@
*/ */
#include "misc.h" #include "misc.h"
#include "spconf_p.h" #include "spconf_p.h"
#include "spver.h"
#include "interf.h" #include "interf.h"
#include "spscr_p.h" #include "spscr_p.h"
#include "spkey.h" #include "spkey.h"
@ -29,7 +28,6 @@
#include "zxconfig.h" #include "zxconfig.h"
#include "stdio.h" #include "stdio.h"
#include "string.h" #include "string.h"
/*#include <errno.h>*/
#include "sys/types.h" #include "sys/types.h"
#include "helpers.h" #include "helpers.h"
#include "ctype.h" #include "ctype.h"
@ -42,17 +40,7 @@ char *spcf_init_snapshot = NULL;
int spcf_init_snapshot_type; int spcf_init_snapshot_type;
char *spcf_init_tapefile = NULL; char *spcf_init_tapefile = NULL;
int spcf_init_tapefile_type; int spcf_init_tapefile_type;
#ifndef USE_GRAY
#define exit(i) rb->splash(HZ*1,true,"Exit: %d",i)
#else
#define exit(i) i=i
#endif
#define MAXLINELEN 512
/*static int linectr;
static FILE *conffp;
static int conffd;
static const char *conffile;
*/
static int file_type = -1; static int file_type = -1;
static int file_subtype; static int file_subtype;

File diff suppressed because it is too large Load diff

View file

@ -732,252 +732,3 @@ void spkb_refresh(void)
z80_inports[KEMP_PORT] = pv; z80_inports[KEMP_PORT] = pv;
} }
#if 0
static void print_help(int lev)
{
lev=lev;
#if 0
switch(lev) {
case 0:
printf(" = ZX Spectrum Emulation (C) Szeredi Miklos 1996-98 = \n"
" ----------------------------------------------------------\n"
" Left Shift Spectrum - CAPS SHIFT \n"
" Right Shift Spectrum - SYMBOL SHIFT \n"
" Alt \"True\" Shift \n"
" Ctrl Commands \n"
" ----------------------------------------------------------\n"
" Ctrl-c F10 Quit \n"
" Ctrl-h F1 More help \n"
" Ctrl-t F2 Save snapshot \n"
" Ctrl-l F3 Load snapshot \n"
" Ctrl-p F4 Play tape \n"
" Ctrl-q F5 Reset \n"
" Ctrl-o F6 Pause/unpause tape \n"
" Ctrl-s F7 Stop tape \n"
" Ctrl-f Fast \n"
" Ctrl-n Normal speed \n"
" Ctrl-b Pause/Unpause emulator \n"
" Ctrl-m Toggle sound \n"
" Ctrl-y Toggle quick loading of tapes \n"
" Ctrl-\\ F9 Refresh screen / reset keyboard \n"
" ==========================================================\n");
break;
case 1:
printf(" = ZX Spectrum Emulation (C) Szeredi Miklos 1996-98 = \n"
" ----------------------------------------------------------\n"
" More help: \n"
" ----------------------------------------------------------\n"
" Ctrl-h F1 Normal help \n"
" Ctrl-k Display (undisplay) keyboard \n"
" Ctrl-w Ctrl-F2 Save temporary snapshot \n"
" Ctrl-e Ctrl-F3 Load temporary snapshot \n"
" Ctrl-r Save to tapefile \n"
" Ctrl-, Reduce screen size (X only) \n"
" Ctrl-. Increase screen size (X only) \n"
" Ctrl-. Toggle private color-map (X only) \n"
" Ctrl-= Decrease frame frequency \n"
" Ctrl-- Increase frame frequency \n"
" Ctrl-] Increase sound buffer size \n"
" Ctrl-[ Decrease sound buffer size \n"
" ==========================================================\n");
break;
case 2:
printf(
" --------------------------------------------------------------------- \n"
"|BLUE |RED |MAGENT|GREEN |CYAN |YELLOW|WHITE | | |BLACK | \n"
"| 1 ! | 2 @ | 3 # | 4 $ | 5 %% | 6 & | 7 ' | 8 ( | 9 ) | 0 _ | \n"
"|EDIT |CAPS |TRU VD|INV VD| <- | v | ^ | -> |GRAPH |DELETE| \n"
"|DEF FN|FN |LINE |OPEN# |CLOSE#|MOVE |ERASE |POINT |CAT |FORMAT| \n"
" ------------------------------------------------------------------------ \n"
" |SIN |COS |TAN |INT |RND |STR$ |CHR$ |CODE |PEEK |TAB | \n"
" | Q <= | W <> | E >= | R < | T > | Y AND| U OR | I AT | O ; | P \" | \n"
" |PLOT |DRAW |REM |RUN |RAND |RETURN|IF |INPUT |POKE |PRINT | \n"
" |ASN |ACS |ATN |VERIFY|MERGE | [ | ] |IN |OUT |(C) | \n"
" ------------------------------------------------------------------------ \n"
" |READ |RESTOR|DATA |SGN |ABS |SQR |VAL |LEN |USR | |\n"
" |A STOP| S NOT|D STEP| F TO |G THEN| H ^ | J - | K + | L = | |\n"
" |NEW |SAVE |DIM |FOR |GO TO |GO SUB|LOAD |LIST |LET |ENTER|\n"
" | ~ | | | \\ | { | } |CIRCLE|VAL$ |SCRN$ |ATTR | |\n"
" -------------------------------------------------------------------------- \n"
" | |LN |EXP |LPRINT|LLIST |BIN |INKEY$| PI | | | \n"
" | CAPS | Z : | X GBP| C ? | V / | B * | N , | M . |SYMBOL| BREAK | \n"
" | SHIFT |COPY |CLEAR |CONT |CLS |BORDER|NEXT |PAUSE |SHIFT | SPACE | \n"
" | |BEEP |INK |PAPER |FLASH |BRIGHT|OVER |INVERS| | | \n"
" ----------------------------------------------------------------------- \n"
);
break;
}
/* if(need_switch_mode) {
printf(" Press ENTER to continue! \n");
while(getchar() != '\n');
}*/
#endif
}
#endif
#ifdef DEBUG_Z80
extern int deb_steps;
#endif
#define CF(x) ((x) + 12)
int spkey_keyfuncs(void)
{
static int help_mode = 0;
int lch;
int new_help_mode;
lch = spkb_last.keysym;
if(!(spkb_last.modif & funcshift) &&
(lch < SK_F1 || lch > SK_F12 ||
(spkb_last.modif & SKMod1Mask))) return 0;
if(lch >= 'A' && lch <= 'Z') lch += 32;
if((spkb_last.modif & funcshift) && lch >= SK_F1 && lch <= SK_F12)
lch = CF(lch);
new_help_mode = 0;
switch(lch) {
case 'c':
/* case SK_F10:
exit(0);*/
case 'p':
case SK_F4:
spkey_textmode();
start_play();
spkey_screenmode();
break;
case 'r':
spkey_textmode();
start_rec();
spkey_screenmode();
break;
case 'o':
case SK_F6:
pause_play();
break;
case 's':
case SK_F7:
stop_play();
break;
case 'f':
sp_nosync = 1;
sp_paused = 0;
autoclose_sound();
break;
case 'n':
sp_nosync = 0;
sp_paused = 0;
break;
case 'b':
sp_paused = !sp_paused;
if(sp_paused) clear_keystates();
/*sprintf(msgbuf, "%s emulator", sp_paused ? "Paused" : "Unpaused");
put_msg(msgbuf);*/
/* rb->splash (HZ*2, true,sp_paused ? "Paused" : "Unpaused");*/
break;
case 'q':
case SK_F5:
z80_reset();
break;
case 't':
case SK_F2:
spkey_textmode();
save_snapshot();
spkey_screenmode();
break;
case 'l':
case SK_F3:
spkey_textmode();
load_snapshot();
spkey_screenmode();
break;
#ifdef DEBUG_Z80
case 'v':
deb_steps = 0;
break;
#endif
case '=':
if(showframe < 10) showframe++;
/* sprintf(msgbuf, "showframe: %i", showframe);
put_msg(msgbuf);*/
break;
case '-':
if(showframe > 1) showframe--;
/* sprintf(msgbuf, "showframe: %i", showframe);
put_msg(msgbuf);*/
break;
case ']':
if(bufframes < 25) bufframes++;
/* sprintf(msgbuf, "msgbuf, bufframes: %i", bufframes);
put_msg(msgbuf);*/
setbufsize();
break;
case '[':
if(bufframes > 1) bufframes--;
/* sprintf(msgbuf, "bufframes: %i", bufframes);
put_msg(msgbuf);*/
setbufsize();
break;
case 'm':
sound_on = !sound_on;
/* sprintf(msgbuf, "sound %s", sound_on ? "on" : "off");
put_msg(msgbuf);*/
break;
case 'h':
case SK_F1:
/* case SK_Help:
spkey_textmode();
print_help(help_mode);
spkey_screenmode();
new_help_mode = 1 - help_mode;
break;*/
/* case 'k':
spkey_textmode();
if(!display_keyboard()) print_help(2);
spkey_screenmode();
break;*/
case '\\':
case SK_F9:
spscr_refresh_colors();
/* sp_init_screen_mark(); already donde in prev fn. */
clear_keystates();
break;
case '.':
resize_spect_scr(scrmul+1);
break;
case ',':
resize_spect_scr(scrmul-1);
break;
case 'y':
sp_quick_load = !sp_quick_load;
/* sprintf(msgbuf, "Quick load %s", sp_quick_load ? "on" : "off");
put_msg(msgbuf);*/
break;
case 'w':
case CF(SK_F2):
save_quick_snapshot();
break;
case 'e':
case CF(SK_F3):
load_quick_snapshot();
break;
case 'j':
privatemap = !privatemap;
/* sprintf(msgbuf, "Private colormap %s", privatemap ? "on" : "off");
put_msg(msgbuf);*/
spscr_refresh_colors();
break;
}
help_mode = new_help_mode;
return 1;
}

View file

@ -207,7 +207,6 @@ extern void spkey_screenmode(void);
extern const int need_switch_mode; extern const int need_switch_mode;
extern int spkey_keyfuncs(void);
extern void spkb_refresh(void); extern void spkb_refresh(void);
extern void clear_keystates(void); extern void clear_keystates(void);
extern int display_keyboard(void); extern int display_keyboard(void);

View file

@ -31,7 +31,6 @@
#include "sptape.h" #include "sptape.h"
#include "spsound.h" #include "spsound.h"
#include "snapshot.h" #include "snapshot.h"
#include "spver.h"
#include "spconf.h" #include "spconf.h"
@ -48,15 +47,15 @@
#include "zxbox_keyb.h" #include "zxbox_keyb.h"
int endofsingle; int endofsingle IBSS_ATTR;
int sp_nosync = 0; int sp_nosync IBSS_ATTR = 0;
int showframe = 1; int showframe IBSS_ATTR = 1;
int load_immed = 1; int load_immed = 1;
qbyte sp_int_ctr = 0; qbyte sp_int_ctr IBSS_ATTR = 0;
int intkeys[5]; int intkeys[5] IBSS_ATTR;
#ifdef USE_DJGPP #ifdef USE_DJGPP
#define DOS #define DOS
@ -354,6 +353,8 @@ static bool zxbox_menu(void)
static const struct menu_item items[] = { static const struct menu_item items[] = {
{ "VKeyboard", NULL }, { "VKeyboard", NULL },
{ "Play/Pause Tape", NULL }, { "Play/Pause Tape", NULL },
{ "Save quick snapshot", NULL },
{ "Load quick snapshot", NULL },
{ "Save Snapshot", NULL }, { "Save Snapshot", NULL },
{ "Toggle \"fast\" mode", NULL }, { "Toggle \"fast\" mode", NULL },
{ "Options", NULL }, { "Options", NULL },
@ -380,22 +381,27 @@ static bool zxbox_menu(void)
break; break;
case 1: case 1:
pause_play(); pause_play();
/* SPNM(load_trapped) = 1;
DANM(haltstate) = 1;
DANM(tc) = 0;*/
menu_quit=1; menu_quit=1;
break; break;
case 2: case 2:
save_quick_snapshot();
menu_quit = 1;
break;
case 3:
load_quick_snapshot();
menu_quit = 1;
break;
case 4:
save_snapshot(); save_snapshot();
break; break;
case 3: case 5:
sp_nosync=!sp_nosync; sp_nosync=!sp_nosync;
menu_quit=1; menu_quit=1;
break; break;
case 4: case 6:
options_menu(); options_menu();
break; break;
case 5: case 7:
menu_quit=1; menu_quit=1;
exit=1; exit=1;
break; break;

View file

@ -28,7 +28,6 @@ extern volatile int screen_visible;
extern void init_spect_scr(void); extern void init_spect_scr(void);
extern void destroy_spect_scr(void); extern void destroy_spect_scr(void);
extern void resize_spect_scr(int newsize);
extern void update_screen(void); extern void update_screen(void);
extern void flash_change(void); extern void flash_change(void);
extern void translate_screen(void); extern void translate_screen(void);

View file

@ -63,7 +63,7 @@ static int last_not_played=0;
static int sndstate = SPS_CLOSED; static int sndstate = SPS_CLOSED;
static void close_snd(int normal); static void close_snd(int normal);
unsigned short my_buf[TMNUM*2*3*2] IBSS_ATTR; unsigned short my_buf[TMNUM*2*3*2];
const byte lin8_ulaw[] = { const byte lin8_ulaw[] = {
@ -128,8 +128,6 @@ void init_spect_sound(void)
} }
//#define VOLREDUCE settings.volume
//
#ifndef VOLREDUCE #ifndef VOLREDUCE
#define VOLREDUCE 0 #define VOLREDUCE 0
#endif #endif
@ -190,8 +188,9 @@ void autoclose_sound(void)
void get_more(unsigned char** start, size_t* size) void get_more(unsigned char** start, size_t* size)
{ {
doneplay = 1; doneplay = 1;
*start = (unsigned char*)(my_buf); rb->pcm_play_stop();
*size = TMNUM*4*3*2; (void)*start;
(void)*size;
} }
/* sp_sound_buf is Unsigned 8 bit, Rate 8000 Hz, Mono */ /* sp_sound_buf is Unsigned 8 bit, Rate 8000 Hz, Mono */
@ -216,7 +215,7 @@ void write_buf(void){
= my_buf[j+10] = my_buf[j+11] \ = my_buf[j+10] = my_buf[j+11] \
= (((byte)sp_sound_buf[i])<<8) >> settings.volume; = (((byte)sp_sound_buf[i])<<8) >> settings.volume;
rb->pcm_play_data(&get_more,NULL,0); rb->pcm_play_data(&get_more,(unsigned char*)(my_buf),TMNUM*4*3*2);
#if 0 #if 0
/* can use to save and later analyze what we produce */ /* can use to save and later analyze what we produce */

View file

@ -39,8 +39,6 @@ int spt_auto_stop = 1;
static int playing = 0; static int playing = 0;
static int paused = 0; static int paused = 0;
/*static FILE *tapefp;*/
/*static int *tapefp;*/
static char tapename[MAXFILENAME]; static char tapename[MAXFILENAME];
static int tapetype; static int tapetype;
@ -93,10 +91,10 @@ static void put_seg_desc(void)
len = get_seglen(); len = get_seglen();
me = msgbuf; me = msgbuf;
rb->snprintf(me,MAXDESCLEN, "%4i: ", currseg); rb->snprintf(me,MAXDESCLEN, "%4d: ", currseg);
me = me+rb->strlen(me); me = me+rb->strlen(me);
if(segtype >= SEG_DATA && len) { if(segtype >= SEG_DATA && len) {
rb->snprintf(me,MAXDESCLEN, "%5li bytes, ", len); rb->snprintf(me,MAXDESCLEN, "%5ld bytes, ", len);
me = me+rb->strlen(me); me = me+rb->strlen(me);
} }
@ -120,7 +118,7 @@ static void put_seg_desc(void)
put_msg(msgbuf); put_msg(msgbuf);
} }
else { else {
rb->snprintf(msgbuf,MAXDESCLEN, "%4i:", currseg); rb->snprintf(msgbuf,MAXDESCLEN, "%4d:", currseg);
put_tmp_msg(msgbuf); put_tmp_msg(msgbuf);
} }
} }
@ -315,11 +313,11 @@ void play_tape(void)
datak = (int) (get_segpos() / 1000); datak = (int) (get_segpos() / 1000);
if(datak > lastdatak) { if(datak > lastdatak) {
/* if(ingroup) sprintf(msgbuf, "%4i: ", currseg); if(ingroup) rb->snprintf(msgbuf,MAXDESCLEN, "%4d: ", currseg);
else sprintf(msgbuf, " "); else rb->snprintf(msgbuf,MAXDESCLEN, " ");
sprintf(msgbuf+strlen(msgbuf), "%3ik", datak); rb->snprintf(msgbuf+rb->strlen(msgbuf),MAXDESCLEN, "%3dk", datak);
put_tmp_msg(msgbuf); put_tmp_msg(msgbuf);
*/
lastdatak = datak; lastdatak = datak;
} }
} }
@ -367,19 +365,20 @@ rovid: 2..5
#define BIT1_MAX 9 #define BIT1_MAX 9
#define LEADER_MIN_COUNT 512 #define LEADER_MIN_COUNT 512
/* #if 0
static int rec_segment; static int rec_segment;
static int rec_state = RC_NONE; static int rec_state = RC_NONE;
static byte *recbuf = NULL; static byte *recbuf = NULL;
static const char *waitchars = "-\\|/"; static const char *waitchars = "-\\|/";
*/ #endif
static int recording = 0; static int recording = 0;
void rec_tape(void) void rec_tape(void)
{ {
/* static byte lastmic = 0; #if 0
static byte lastmic = 0;
static int lastlen = 0; static int lastlen = 0;
static int whole; static int whole;
static int leadercount; static int leadercount;
@ -524,18 +523,21 @@ void rec_tape(void)
} }
lastlen = 0; lastlen = 0;
}*/ }
#endif
} }
static void stop_recording(void) static void stop_recording(void)
{ {
/* if(recording) { #if 0
if(recording) {
recording = 0; recording = 0;
free(recbuf); free(recbuf);
recbuf = NULL; recbuf = NULL;
rb->close(tapefp); rb->close(tapefp);
}*/ }
#endif
} }
static void restart_playing(void) static void restart_playing(void)
@ -634,8 +636,10 @@ void stop_play(void)
if(paused) paused = 0; if(paused) paused = 0;
} }
else if(recording) { else if(recording) {
/* sprintf(msgbuf, " * Stopped recording tape `%s' * ", tapename); #if 0
put_msg(msgbuf);*/ sprintf(msgbuf, " * Stopped recording tape `%s' * ", tapename);
put_msg(msgbuf);
#endif
stop_recording(); stop_recording();
} }
} }
@ -696,9 +700,7 @@ void qload(void)
if(!playing) { if(!playing) {
if(paused) unpause_playing(); if(paused) unpause_playing();
else { else {
spkey_textmode();
start_play(); start_play();
spkey_screenmode();
} }
} }
if(!playing) { if(!playing) {

View file

@ -1,29 +0,0 @@
/*
* Copyright (C) 1996-1998 Szeredi Miklos
* Email: mszeredi@inf.bme.hu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See the file COPYING.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include "config.h"
#define SPECTEMU_VERSION "0.94"
#ifdef Z80C
#define SPECTEMU_TYPE "c"
#else
#define SPECTEMU_TYPE "i"
#endif

View file

@ -25,11 +25,10 @@
#include <time.h> #include <time.h>
#include "zxconfig.h" #include "zxconfig.h"
#include "helpers.h" #include "helpers.h"
Z80 PRNM(proc); Z80 PRNM(proc) IBSS_ATTR;
byte PRNM(inports)[PORTNUM];
byte PRNM(outports)[PORTNUM];
byte PRNM(inports)[PORTNUM] IBSS_ATTR;
byte PRNM(outports)[PORTNUM] IBSS_ATTR;
#ifdef SPECT_MEM #ifdef SPECT_MEM
#define NUM64KSEGS 3 #define NUM64KSEGS 3

View file

@ -62,8 +62,8 @@ static unsigned char *gbuf;
static unsigned int gbuf_size = 0; static unsigned int gbuf_size = 0;
#endif #endif
long video_frames = 0; long video_frames IBSS_ATTR = 0 ;
long start_time = 0; long start_time IBSS_ATTR = 0;
enum plugin_status plugin_start(struct plugin_api* api, void* parameter) enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{ {
@ -73,7 +73,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->pcm_play_stop(); rb->pcm_play_stop();
#endif #endif
rb->splash(HZ, true, "Welcome to ZXBox"); rb->splash(HZ, true, "Welcome to ZXBox");
sp_init();
#ifdef USE_IRAM #ifdef USE_IRAM
/* We need to stop audio playback in order to use IRAM */ /* We need to stop audio playback in order to use IRAM */
@ -83,6 +82,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->memset(iedata, 0, iend - iedata); rb->memset(iedata, 0, iend - iedata);
#endif #endif
sp_init();
#ifdef USE_GRAY #ifdef USE_GRAY
/* get the remainder of the plugin buffer */ /* get the remainder of the plugin buffer */
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
@ -101,8 +102,17 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
#endif #endif
start_time = *rb->current_tick; start_time = *rb->current_tick;
#ifdef RB_PROFILE
rb->profile_thread();
#endif
start_spectemu(parameter); start_spectemu(parameter);
#ifdef RB_PROFILE
rb->profstop();
#endif
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
rb->cpu_boost(false); rb->cpu_boost(false);
#endif #endif
@ -269,25 +279,3 @@ void press_key(int c){
process_keys(); process_keys();
} }
void spkey_textmode(void)
{
}
void spkey_screenmode(void)
{
}
void spscr_refresh_colors(void)
{
}
void resize_spect_scr(int s)
{
/* just to disable warning */
(void)s;
}
int display_keyboard(void)
{
return 0;
}

View file

@ -19,14 +19,13 @@ extern int intkeys[5];
/* undef not to use grayscale lib */ /* undef not to use grayscale lib */
#if !defined HAVE_LCD_COLOR && LCD_PIXELFORMAT != HORIZONTAL_PACKING #if !defined HAVE_LCD_COLOR && LCD_PIXELFORMAT != HORIZONTAL_PACKING
/* grayscale is far slower for now at least on ipods :( */
#define USE_GRAY #define USE_GRAY
#define USE_BUFFERED_GRAY #define USE_BUFFERED_GRAY
#endif #endif
#define Z80C #define Z80C
#define MULTIUSER 0
#define DATADIR "."
/* Always define this for the spectrum emulator. */ /* Always define this for the spectrum emulator. */
#define SPECT_MEM 1 #define SPECT_MEM 1
@ -42,20 +41,11 @@ extern int intkeys[5];
/* Define this to use an alternative way of passing the z80 processor /* Define this to use an alternative way of passing the z80 processor
data to the z80 instruction emulation functions. May make emulation data to the z80 instruction emulation functions. May make emulation
faster on some machines, but not on intel, and sparc. */ faster on some machines, but not on intel, and sparc. */
#undef PROCP /* seems not to have effect on arm targets */ /* seems not to have effect on arm targets */
/* #define PROCP */ #undef PROCP
/*#define PROCP*/
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */ /* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1 #define STDC_HEADERS 1
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
#endif #endif

View file

@ -1,11 +1,18 @@
#include "zxvid_com.h" #include "zxvid_com.h"
#if !defined USE_GRAY && LCD_PIXELFORMAT == HORIZONTAL_PACKING && LCD_DEPTH < 4 #if !defined USE_GRAY && LCD_DEPTH < 4
/* screen routines for greyscale targets not using greyscale lib */ /* screen routines for greyscale targets not using greyscale lib */
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
#define FB_WIDTH ((LCD_WIDTH+3)/4) #define FB_WIDTH ((LCD_WIDTH+3)/4)
unsigned char pixmask[4] ICONST_ATTR = { unsigned char pixmask[4] ICONST_ATTR = {
0xC0, 0x30, 0x0C, 0x03 0xC0, 0x30, 0x0C, 0x03
}; };
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
unsigned char pixmask[4] ICONST_ATTR = {
0x03, 0x0C, 0x30, 0xC0
};
#endif
void init_spect_scr(void) void init_spect_scr(void)
{ {
@ -49,7 +56,7 @@ void update_screen(void)
int srcx, srcy=0; /* x / y coordinates in source image */ int srcx, srcy=0; /* x / y coordinates in source image */
image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF; image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
unsigned mask; unsigned mask;
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
for(y = 0; y < LCD_HEIGHT; y++) for(y = 0; y < LCD_HEIGHT; y++)
{ {
frameb = rb->lcd_framebuffer + (y) * FB_WIDTH; frameb = rb->lcd_framebuffer + (y) * FB_WIDTH;
@ -64,6 +71,24 @@ void update_screen(void)
image += (srcy>>16)*WIDTH; /* and possibly to the next row. */ image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */ srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
} }
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
int shift;
for(y = 0; y < LCD_HEIGHT; y++)
{
frameb = rb->lcd_framebuffer + (y/4) * LCD_WIDTH;
srcx = 0; /* reset our x counter before each row... */
shift = ((y & 3 ) * 2 );
mask = pixmask[y & 3];
for(x = 0; x < LCD_WIDTH; x++)
{
frameb[x] = (frameb[x] & ~mask) | ((image[(srcx>>16)]&0x3) << shift );
srcx += X_STEP; /* move through source image */
}
srcy += Y_STEP; /* move through the source image... */
image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
}
#endif
if ( settings.showfps ) { if ( settings.showfps ) {
int percent=0; int percent=0;