void ami_file_req_init(void) { filereq = (struct FileRequester *)AllocAslRequest(ASL_FileRequest, NULL); savereq = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest, ASLFR_DoSaveMode, TRUE, ASLFR_RejectIcons, TRUE, ASLFR_InitialDrawer, nsoption_charp(download_dir), TAG_DONE); aslhookfunc.h_Entry = (void *)&ami_file_asl_mime_hook; aslhookfunc.h_SubEntry = NULL; aslhookfunc.h_Data = NULL; }
long ScreenMode(void) { if((AslBase = OpenLibrary("asl.library", 0)) != NULL) { struct ScreenModeRequester *sm; if((sm = AllocAslRequest(ASL_ScreenModeRequest,NULL))) { #ifdef DEBUG Printf("sm %08lx\n", sm); #endif if(AslRequestTags(sm, ASLSM_DoDepth, TRUE, ASLSM_DoWidth, TRUE, ASLSM_DoHeight, TRUE, ASLSM_MinDepth, 8, ASLSM_MaxDepth, 32, ASLSM_MinWidth, 640, ASLSM_MinHeight,480, ASLSM_MaxWidth, 1920, ASLSM_MaxHeight,1080, TAG_DONE)) { sprintf(cvar, "%d", sm->sm_DisplayWidth); set(obj->STR_width, MUIA_String_Contents, cvar); sprintf(cvar, "%d", sm->sm_DisplayHeight); set(obj->STR_height, MUIA_String_Contents, cvar); sprintf(cvar, "%d", sm->sm_DisplayDepth); set(obj->STR_depth, MUIA_String_Contents, cvar); int depth = sm->sm_DisplayDepth; if (depth == 8) set(obj->CH_fullscreen, MUIA_Selected, TRUE); else if ((depth > 8) && (depth < 16)) set(obj->STR_depth, MUIA_String_Contents, "16"); else if (depth> 16) set(obj->STR_depth, MUIA_String_Contents, "32"); } FreeAslRequest(sm); } if (AslBase) CloseLibrary(AslBase); } return 0; }
ULONG _AHIsub_AllocAudio( struct TagItem *tagList, struct AHIAudioCtrlDrv *AudioCtrl, struct DriverBase* AHIsubBase ) { struct FilesaveBase* FilesaveBase = (struct FilesaveBase*) AHIsubBase; char *ext = ""; if(AslBase == NULL) { return AHISF_ERROR; } dd = AllocVec(sizeof(struct FilesaveData),MEMF_CLEAR); if( dd != NULL ) { dd->fs_AHIsubBase = AHIsubBase; dd->fs_SlaveSignal = -1; dd->fs_MasterSignal = AllocSignal(-1); dd->fs_MasterTask = (struct Process *) FindTask(NULL); dd->fs_RecSlaveSignal = -1; dd->fs_RecMasterSignal = AllocSignal(-1); } else { return AHISF_ERROR; } if((dd->fs_MasterSignal == -1) || (dd->fs_RecMasterSignal == -1)) { return AHISF_ERROR; } dd->fs_Format = GetTagData(AHIDB_FileSaveFormat, FORMAT_8SVX, tagList); switch(dd->fs_Format) { case FORMAT_8SVX: ext = ".8SVX"; break; case FORMAT_AIFF: ext = ".AIFF"; break; case FORMAT_AIFC: ext = ".AIFC"; break; case FORMAT_S16: break; case FORMAT_WAVE: ext = ".WAV"; break; default: break; } { struct TagItem playtags[] = { { ASLFR_InitialFile, (ULONG) ext }, { ASLFR_DoSaveMode, TRUE }, { ASLFR_RejectIcons, TRUE }, { ASLFR_TitleText, (ULONG) LibName }, { TAG_DONE, 0 } }; struct TagItem rectags[] = { { ASLFR_RejectIcons, TRUE }, { ASLFR_TitleText, (ULONG) "Select a sound sample" }, { TAG_DONE, 0 } }; if(!(dd->fs_FileReq = AllocAslRequest(ASL_FileRequest, playtags))) { return AHISF_ERROR; } if(!(dd->fs_RecFileReq = AllocAslRequest(ASL_FileRequest, rectags))) { return AHISF_ERROR; } } return AHISF_KNOWHIFI|AHISF_KNOWSTEREO|AHISF_CANRECORD|AHISF_MIXING|AHISF_TIMING; }
// varargs AllocAslRequestTags APTR __stdargs AllocAslRequestTags( unsigned long type, Tag tag1,...) { return AllocAslRequest(type,(struct TagItem *)&tag1); }
static void do_file_dialog (unsigned int type) { struct FileRequester *FileRequest; struct Window *win; char buf[80]; char path[512]; const char *req_prompt; const char *req_pattern = 0; const char *req_lastdir; int req_do_save = FALSE; #ifdef __amigaos4__ int release_asl = 0; #endif if (type >= FILEDIALOG_MAX) return; if (!AslBase) { AslBase = OpenLibrary ("asl.library", 36); if (!AslBase) { write_log ("Can't open asl.library v36.\n"); return; } else { #ifdef __amigaos4__ IAsl = (struct AslIFace *) GetInterface ((struct Library *)AslBase, "main", 1, NULL); if (!IAsl) { CloseLibrary (AslBase); AslBase = 0; write_log ("Can't get asl.library interface\n"); } #endif } #ifdef __amigaos4__ } else { IAsl->Obtain (); release_asl = 1; #endif } FileRequest = AllocAslRequest (ASL_FileRequest, NULL); if (!FileRequest) { write_log ("Unable to allocate file requester.\n"); return; } /* Find this task's default window */ win = ((struct Process *) FindTask (NULL))->pr_WindowPtr; if (win == (struct Window *)-1) win = 0; /* * Prepare requester. */ switch (type) { default: /* to stop GCC complaining */ case FILEDIALOG_INSERT_DF0: case FILEDIALOG_INSERT_DF1: case FILEDIALOG_INSERT_DF2: case FILEDIALOG_INSERT_DF3: sprintf (buf, "Select image to insert in drive DF%d:", FILEDIALOG_DRIVE(type)); req_prompt = buf; req_pattern = "(#?.(ad(f|z)|dms|ipf|zip)#?|df?|?)"; req_lastdir = get_last_floppy_dir (); break; case FILEDIALOG_SAVE_STATE: req_prompt = "Select file to save emulator state to"; req_pattern = "#?.uss"; req_lastdir = get_last_savestate_dir (); req_do_save = TRUE; break; case FILEDIALOG_LOAD_STATE: req_prompt = "Select saved state file to load"; req_pattern = "#?.uss"; req_lastdir = get_last_savestate_dir (); break; } /* * Do the file request. */ if (AslRequestTags (FileRequest, ASLFR_TitleText, req_prompt, ASLFR_InitialDrawer, req_lastdir, ASLFR_InitialPattern, req_pattern, ASLFR_DoPatterns, req_pattern != 0, ASLFR_DoSaveMode, req_do_save, ASLFR_RejectIcons, TRUE, ASLFR_Window, win, TAG_DONE)) { /* * User selected a file. * * Construct file path to selected image. */ strcpy (path, FileRequest->fr_Drawer); if (strlen (path) && !(path[strlen (path) - 1] == ':' || path[strlen (path) - 1] == '/')) strcat (path, "/"); strcat (path, FileRequest->fr_File); /* * Process selected file. */ switch (type) { default: /* to stop GCC complaining */ case FILEDIALOG_INSERT_DF0: case FILEDIALOG_INSERT_DF1: case FILEDIALOG_INSERT_DF2: case FILEDIALOG_INSERT_DF3: set_last_savestate_dir (FileRequest->fr_Drawer); strcpy (changed_prefs.df[FILEDIALOG_DRIVE(type)], path); break; case FILEDIALOG_SAVE_STATE: set_last_savestate_dir (FileRequest->fr_Drawer); savestate_initsave (path, 1, 0); save_state (path, "Description"); break; case FILEDIALOG_LOAD_STATE: set_last_savestate_dir (FileRequest->fr_Drawer); savestate_initsave (path, 1, 0); savestate_state = STATE_DORESTORE; write_log ("Restoring state from '%s'...\n", path); break; } } FreeAslRequest (FileRequest); #ifdef __amigaos4__ if (release_asl) IAsl->Release (); #endif return; }
main(int argc, char *argv[]) { unsigned char str[256]; int i; int j; struct RastPort rp; unsigned char *pp; struct BitMap bm = { 256, /* bytes per row */ 8, /* rows */ 0, /* flags */ 1, /* depth */ 0, /* pad */ 0 /* planes */ }; struct TextAttr ta; struct TextFont *tf; struct FontRequester *fr; struct TagItem frtags[] = { ASL_Hail, (ULONG)"NetBSD font choices", ASL_Width, 640, ASL_Height, 400, ASL_LeftEdge, 10, ASL_TopEdge, 10, ASL_OKText, (ULONG)"Dump", ASL_CancelText, (ULONG)"Cancel", ASL_FontName, (ULONG)"topaz.font", ASL_FontHeight, 8L, ASL_FontStyles, FS_NORMAL, ASL_FuncFlags, FONF_STYLES | FONF_FIXEDWIDTH, TAG_DONE }; /* Let the user pick a font to dump */ if (fr = (struct FontRequester *) AllocAslRequest(ASL_FontRequest, frtags)) { if (!AslRequest(fr, NULL)) { FreeAslRequest(fr); fprintf(stderr, "User requested exit\n"); exit (0); } ta.ta_Name = (STRPTR)malloc(strlen(fr->fo_Attr.ta_Name)); strcpy(ta.ta_Name, fr->fo_Attr.ta_Name); ta.ta_YSize = fr->fo_Attr.ta_YSize; ta.ta_Style = fr->fo_Attr.ta_Style; ta.ta_Flags = fr->fo_Attr.ta_Flags; FreeAslRequest(fr); } else { fprintf(stderr, "Can't allocate Font Requestor\n"); exit (1); } /* Open the selected font */ tf = (struct TextFont *)OpenDiskFont (&ta); if (! tf) { fprintf (stderr, "Can't open font: %s\n", ta.ta_Name); exit (1); } #ifdef DEBUG fprintf(stderr, "Information on selected font:\n"); fprintf(stderr, "Name=%s\n", ta.ta_Name); fprintf(stderr, "Height=%d tf_Style=%x tf_Flags=%x Width=%d Baseline=%d\n", tf->tf_YSize, tf->tf_Style, tf->tf_Flags, tf->tf_XSize, tf->tf_Baseline); #endif /* Check for NetBSD restrictions */ if (tf->tf_Flags & FPF_PROPORTIONAL) { fprintf(stderr, "NetBSD does not support proportional fonts\n"); exit (1); } if (tf->tf_XSize > NetBSDwidth) { fprintf(stderr, "NetBSD does not support fonts wider than %d pixels\n", NetBSDwidth); exit (1); } /* Allocate area to render font in */ InitBitMap(&bm, 1, 256 * NetBSDwidth, tf->tf_YSize); InitRastPort (&rp); rp.BitMap = &bm; bm.Planes[0] = pp = AllocRaster (256 * NetBSDwidth, tf->tf_YSize); if (!pp) { fprintf (stderr, "Can't allocate raster!\n"); exit (1); } /* Initialize string to be rendered */ for (i = 32; i < 256; i++) { str[i - 32] = i; } /* Render string with selected font */ SetFont (&rp, tf); SetSoftStyle(&rp, ta.ta_Style ^ tf->tf_Style, FSF_BOLD | FSF_UNDERLINED | FSF_ITALIC); Move (&rp, 0, tf->tf_Baseline); ClearEOL(&rp); if (tf->tf_XSize != NetBSDwidth) { /* right-justify char in cell */ Move (&rp, NetBSDwidth - tf->tf_XSize, tf->tf_Baseline); /* Narrow font, put each character in space of normal font */ for (i = 0; i < (256 - 32); i++) { Text (&rp, &str[i], 1); Move (&rp, rp.cp_x + (NetBSDwidth - tf->tf_XSize), rp.cp_y); } } else { Text (&rp, str, 256 - 32); } /* Dump them.. */ printf ("/* Generated automatically by fontdumper.c. *DONT* distribute\n"); printf (" this file, it may contain information Copyright by Commodore!\n"); printf ("\n"); printf (" Font: %s/%d\n", ta.ta_Name, tf->tf_YSize); printf (" */\n\n"); printf ("unsigned char kernel_font_width = %d;\n", tf->tf_XSize); printf ("unsigned char kernel_font_height = %d;\n", tf->tf_YSize); printf ("unsigned char kernel_font_baseline = %d;\n", tf->tf_Baseline); printf ("short kernel_font_boldsmear = %d;\n", tf->tf_BoldSmear); printf ("unsigned char kernel_font_lo = 32;\n"); printf ("unsigned char kernel_font_hi = 255;\n\n"); printf ("unsigned char kernel_cursor[] = {\n"); for (j = 0; j < (tf->tf_YSize -1); j++) { printf ("0xff, "); } printf ("0xff };\n\n"); printf ("unsigned char kernel_font[] = {\n"); for (i = 0; i < 256 - 32; i++) { printf ("/* %c */", i + 32); for (j = 0; j < tf->tf_YSize; j++) { printf (" 0x%02x,", pp[i+j*256]); } printf ("\n"); } printf ("};\n"); CloseFont (tf); FreeRaster (pp, 256 * NetBSDwidth, tf->tf_YSize); return (0); }
/** * REQUESTFILE ARexx command * * @param rxmsg the message defining the ARexx context * @param args the command's arguments */ static void arexx_requestfile(struct RexxMsg *rxmsg, STRPTR args) { APTR arg_handle; struct { STRPTR stem; STRPTR drawer; STRPTR file; STRPTR pattern; STRPTR title; STRPTR positive; STRPTR negative; STRPTR acceptpattern; STRPTR rejectpattern; ULONG savemode; ULONG multiselect; ULONG drawersonly; ULONG noicons; } requestfile_arg; memset(&requestfile_arg,0,sizeof(requestfile_arg)); if ((arg_handle = ParseTemplate("STEM/K,DRAWER,FILE/K,PATTERN/K,TITLE/K,POSITIVE/K,NEGATIVE/K,ACCEPTPATTERN/K,REJECTPATTERN/K,SAVEMODE/S,MULTISELECT/S,DRAWERSONLY/S,NOICONS/S",args,&requestfile_arg))) { struct FileRequester *filereq = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL); if (filereq) { UBYTE *acceptpattern = NULL,*rejectpattern = NULL; int stem_len; char *stem_buf; char num_buf[32]; if (requestfile_arg.stem) { stem_len = strlen(requestfile_arg.stem); if ((stem_buf = (char *)malloc(stem_len+20))) { strcpy(stem_buf,requestfile_arg.stem); } else stem_len = 0; } else { stem_buf = 0; stem_len = 0; } if (requestfile_arg.acceptpattern) { int len = strlen(requestfile_arg.acceptpattern)*2+3; if ((acceptpattern = (UBYTE*)AllocVec(len,0))) ParsePatternNoCase(requestfile_arg.acceptpattern,(STRPTR)acceptpattern,len); } if (requestfile_arg.rejectpattern) { int len = strlen(requestfile_arg.rejectpattern)*2+3; if ((rejectpattern = (UBYTE*)AllocVec(len,0))) ParsePatternNoCase(requestfile_arg.rejectpattern,(STRPTR)rejectpattern,len); } if (AslRequestTags(filereq, ASLFR_Screen, main_get_screen(), requestfile_arg.title?ASLFR_TitleText:TAG_IGNORE, requestfile_arg.title, requestfile_arg.positive?ASLFR_PositiveText:TAG_IGNORE, requestfile_arg.positive, requestfile_arg.negative?ASLFR_NegativeText:TAG_IGNORE, requestfile_arg.negative, requestfile_arg.drawer?ASLFR_InitialDrawer:TAG_IGNORE, requestfile_arg.drawer, requestfile_arg.file?ASLFR_InitialFile:TAG_IGNORE, requestfile_arg.file, requestfile_arg.pattern?ASLFR_InitialPattern:TAG_IGNORE, requestfile_arg.pattern, rejectpattern?ASLFR_RejectPattern:TAG_IGNORE, rejectpattern, acceptpattern?ASLFR_AcceptPattern:TAG_IGNORE, acceptpattern, ASLFR_RejectIcons, requestfile_arg.noicons, ASLFR_DrawersOnly, requestfile_arg.drawersonly, ASLFR_DoMultiSelect, requestfile_arg.multiselect, ASLFR_DoSaveMode, requestfile_arg.savemode, requestfile_arg.pattern?ASLFR_DoPatterns:TAG_IGNORE, TRUE, TAG_DONE)) { int i; char *name; STRPTR dirname; BPTR dirlock; if (stem_buf) { strcpy(&stem_buf[stem_len],"PATH.COUNT"); sprintf(num_buf,"%ld",filereq->fr_NumArgs); MySetRexxVarFromMsg(stem_buf,num_buf,rxmsg); for (i=0;i<filereq->fr_NumArgs;i++) { sprintf(&stem_buf[stem_len],"PATH.%d",i); if ((dirname = NameOfLock(filereq->fr_ArgList[i].wa_Lock))) { if ((name = mycombinepath(dirname,filereq->fr_ArgList[i].wa_Name))) { MySetRexxVarFromMsg(stem_buf,name,rxmsg); free(name); } else MySetRexxVarFromMsg(stem_buf,"",rxmsg); FreeVec(dirname); } else MySetRexxVarFromMsg(stem_buf,"",rxmsg); } strcpy(&stem_buf[stem_len],"FILE"); MySetRexxVarFromMsg(stem_buf,filereq->fr_File,rxmsg); strcpy(&stem_buf[stem_len],"DRAWER"); MySetRexxVarFromMsg(stem_buf,filereq->fr_Drawer,rxmsg); strcpy(&stem_buf[stem_len],"PATTERN"); MySetRexxVarFromMsg(stem_buf,filereq->fr_Pattern,rxmsg); } if ((dirlock = Lock(filereq->fr_Drawer,ACCESS_READ))) { if ((dirname = NameOfLock(dirlock))) { if ((name = mycombinepath(dirname,filereq->fr_File))) { arexx_set_result(rxmsg,name); free(name); } FreeVec(dirname); } UnLock(dirlock); } } else { if (stem_buf) { strcpy(&stem_buf[stem_len],"PATH.COUNT"); MySetRexxVarFromMsg(stem_buf,"0",rxmsg); } arexx_set_result(rxmsg,""); } } FreeTemplate(arg_handle); } }