Reduce dependence on global TEMP buffer

* display.S still uses this ... will be refactored completely with new video update
This commit is contained in:
Aaron Culliney 2014-05-11 19:18:53 -07:00
parent 4e6718be37
commit c22fbd0374
9 changed files with 31 additions and 22 deletions

View File

@ -761,13 +761,14 @@ void disk_io_initialize(unsigned int slot)
{
FILE *f;
int i;
char temp[PATH_MAX];
assert(slot == 6);
/* load Disk II rom */
if (!slot6_rom_loaded)
{
snprintf(temp, TEMPSIZE, "%s/slot6.rom", system_path);
snprintf(temp, PATH_MAX, "%s/slot6.rom", system_path);
if ((f = fopen( temp, "r" )) == NULL)
{
printf("Cannot find file '%s'.\n",temp);

View File

@ -20,6 +20,8 @@
#define BEGIN_MIX 20
#define TEXT_COLS 40
uint8_t temp[1024];// HACK to be removed
static uint8_t vga_mem_page_0[SCANWIDTH*SCANHEIGHT]; /* page0 framebuffer */
static uint8_t vga_mem_page_1[SCANWIDTH*SCANHEIGHT]; /* page1 framebuffer */

View File

@ -414,6 +414,7 @@ void c_interface_select_diskette( int drive )
curpos = entries - 1;
}
char temp[PATH_MAX];
for (;;)
{
for (i = 0; i < 18; i++)
@ -424,7 +425,7 @@ void c_interface_select_diskette( int drive )
strcpy( temp, " " );
if (ent_no >= 0 && ent_no < entries)
{
snprintf(temp, TEMPSIZE, "%s/%s",
snprintf(temp, PATH_MAX, "%s/%s",
disk_path, namelist[ent_no]->d_name);
if (!strcmp(temp, disk6.disk[drive].file_name))
{
@ -434,27 +435,27 @@ void c_interface_select_diskette( int drive )
stat(temp, &statbuf);
if (S_ISDIR(statbuf.st_mode))
{
snprintf(temp, TEMPSIZE, " %s/",
snprintf(temp, PATH_MAX, " %s/",
namelist[ ent_no ]->d_name );
}
else
{
snprintf(temp, TEMPSIZE, " %s",
snprintf(temp, PATH_MAX, " %s",
namelist[ ent_no ]->d_name );
}
if (c_interface_cut_name(temp))
{
strncat(temp, " <gz>", TEMPSIZE-1);
strncat(temp, " <gz>", PATH_MAX-1);
}
/* write protected disk in drive? */
else if ((in_drive) && (disk6.disk[drive].is_protected))
{
strncat(temp, (drive == 0) ? " <r1>" : " <r2>", TEMPSIZE-1);
strncat(temp, (drive == 0) ? " <r1>" : " <r2>", PATH_MAX-1);
}
else if (in_drive)
{
strncat(temp, (drive == 0) ? " <rw1>" : " <rw2>", TEMPSIZE-1);
strncat(temp, (drive == 0) ? " <rw1>" : " <rw2>", PATH_MAX-1);
}
}
@ -553,7 +554,7 @@ void c_interface_select_diskette( int drive )
{
int len;
snprintf(temp, TEMPSIZE, "%s/%s",
snprintf(temp, PATH_MAX, "%s/%s",
disk_path, namelist[ curpos ]->d_name );
len = strlen(disk_path);
@ -723,6 +724,8 @@ void c_interface_parameters()
c_interface_translate_screen( screen );
c_interface_print_screen( screen );
#define TEMPSIZE 1024
char temp[TEMPSIZE];
for (;;)
{
for (i = 0; (i < PARAMS_H) && (i < NUM_OPTIONS); i++)

View File

@ -169,6 +169,9 @@ static void c_calibrate_pc_joystick()
}
}
#define TEMPSIZE 256
char temp[TEMPSIZE];
#define CALIBRATE_SUBMENU_H 9
#define CALIBRATE_SUBMENU_W 40
char submenu[CALIBRATE_SUBMENU_H][CALIBRATE_SUBMENU_W+1] =
@ -369,6 +372,7 @@ static void c_calibrate_keypad_joystick()
uint8_t x_last=CALIBRATE_JOYMENU_W>>1, y_last=CALIBRATE_JOYMENU_H>>1;
const char* const spinney = "|/-\\";
uint8_t spinney_idx=0;
char temp[TEMPSIZE];
for (;;)
{
submenu[KEYPAD_SUBMENU_H-2][12] = joy_button0 ? 'X' : ' ';

View File

@ -891,7 +891,7 @@ ADDRS [0-9a-fA-F]+
/* copy file name */
ptr = debugtext;
while (!isspace(*debugtext)) ++debugtext;
int len = MIN(debugtext - ptr, TEMPSIZE-1);
int len = MIN(debugtext - ptr, DEBUG_BUFSZ-1);
strncpy(buf, ptr, len);
buf[len] = '\0';

View File

@ -464,6 +464,8 @@ void bload(FILE *f, char *name, int addrs) {
return;
}
#define TEMPSIZE 1024
char temp[TEMPSIZE];
while ((len = fread(temp, 1, TEMPSIZE, f)))
{
hexstr = (uint8_t*)temp;

View File

@ -468,7 +468,8 @@ void c_initialize_apple_ii_memory()
if (!iie_rom_loaded)
{
snprintf(temp, TEMPSIZE, "%s/apple_IIe.rom", system_path);
char temp[PATH_MAX];
snprintf(temp, PATH_MAX, "%s/apple_IIe.rom", system_path);
if ((f = fopen(temp, "r")) == NULL)
{
printf("Cannot find file '%s'.\n",temp);
@ -633,10 +634,10 @@ static void main_thread(void *dummyptr) {
extern void cpu_thread(void *dummyptr);
int main(int sargc, char *sargv[])
int main(int _argc, char **_argv)
{
argc = sargc;
argv = sargv;
argc = _argc;
argv = _argv;
load_settings(); /* user prefs */
c_initialize_firsttime(); /* init svga graphics and vm */

View File

@ -46,13 +46,9 @@ uint8_t apple_ii_64k[2][65536]; /* 128k memory */
uint8_t language_card[2][8192], language_banks[2][8192];
/* global ref to commandline args */
char **argv;
char **argv;
int argc;
/* misc arrays */
#define TEMPSIZE 4096
char temp[ TEMPSIZE ]; /* should be >=4096 (stuff depends on this) */
extern uint8_t *base_ramrd;
extern uint8_t *base_ramwrt;
extern uint8_t *base_textrd;

View File

@ -67,8 +67,8 @@ const char *def(const char* const src, const int expected_bytecount)
break;
}
char dst[TEMPSIZE];
snprintf(dst, TEMPSIZE-1, "%s%s", src, ".gz");
char dst[PATH_MAX];
snprintf(dst, PATH_MAX-1, "%s%s", src, ".gz");
gzdest = gzopen(dst, "wb");
if (gzdest == NULL) {
@ -159,8 +159,8 @@ const char *inf(const char* const src, int *rawcount)
}
int len = strlen(src);
char dst[TEMPSIZE];
snprintf(dst, TEMPSIZE-1, "%s", src);
char dst[PATH_MAX];
snprintf(dst, PATH_MAX-1, "%s", src);
if (! ( (dst[len-3] == '.') && (dst[len-2] == 'g') && (dst[len-1] == 'z') ) ) {
ERRLOG("Expected filename ending in .gz");
break;