コード例 #1
0
ファイル: dosio.cpp プロジェクト: FREEWING-JP/np2pi
BOOL file_listnext(FLISTH hdl, FLINFO *fli) {

	FLHDL			flhdl;
	Str255			fname;
	unsigned long	dt;

	flhdl = (FLHDL)hdl;
	if ((flhdl == NULL) || (flhdl->eoff)) {
		goto ffn_err;
	}
	fname[0] = 0;
	flhdl->pb.dirInfo.ioNamePtr = fname;
	flhdl->pb.dirInfo.ioDrDirID = flhdl->tagid;
	flhdl->pb.dirInfo.ioFDirIndex = flhdl->index;
	flhdl->pb.dirInfo.ioACUser = 0;
	if (PBGetCatInfo(&flhdl->pb, false) != noErr) {
		flhdl->eoff = TRUE;
		goto ffn_err;
	}
	flhdl->index++;
	if (fli) {
		fli->caps = FLICAPS_SIZE | FLICAPS_ATTR | FLICAPS_DATE | FLICAPS_TIME;
		if (flhdl->pb.hFileInfo.ioFlAttrib & ioDirMask) {
			fli->attr = FILEATTR_DIRECTORY;
			fli->size = 0;
			dt = flhdl->pb.dirInfo.ioDrCrDat;
		}
		else {
			fli->attr = FILEATTR_ARCHIVE;
			fli->size = flhdl->pb.hFileInfo.ioFlLgLen;
			dt = flhdl->pb.hFileInfo.ioFlMdDat;
		}
		if (flhdl->pb.hFileInfo.ioFlAttrib & 0x01) {
			fli->attr |= FILEATTR_READONLY;
		}
		cnvdatetime(dt, &fli->date, &fli->time);
		mkcstr(fli->path, sizeof(fli->path), fname);
	}
	return(SUCCESS);

ffn_err:
	return(FAILURE);
}
コード例 #2
0
ファイル: d_screen.cpp プロジェクト: FREEWING-JP/np2pi
void dialog_scropt(void) {

	DialogPtr		hDlg;
	ControlHandle	chipbtn[2];
	ControlHandle	grcgbtn[4];
	ControlHandle	lcdbtn[2];
	ControlHandle	skipbtn;
	ControlHandle	c16btn;
	UINT			chip;
	UINT			grcg;
	UINT			color16;
	UINT			lcd;
	UINT			skipline;
	UINT			val;
	char			work[32];
	Str255			workstr;
	int				done;
	short			item;
	UINT			update;
	UINT			renewal;
	BYTE			waitval[6];

	hDlg = GetNewDialog(IDD_SCREENOPT, NULL, (WindowPtr)-1);
	if (!hDlg) {
		return;
	}
	chipbtn[0] = (ControlHandle)GetDlgItem(hDlg, IDC_GDC7220);
	chipbtn[1] = (ControlHandle)GetDlgItem(hDlg, IDC_GDC72020);

	grcgbtn[0] = (ControlHandle)GetDlgItem(hDlg, IDC_GRCGNON);
	grcgbtn[1] = (ControlHandle)GetDlgItem(hDlg, IDC_GRCG);
	grcgbtn[2] = (ControlHandle)GetDlgItem(hDlg, IDC_GRCG2);
	grcgbtn[3] = (ControlHandle)GetDlgItem(hDlg, IDC_EGC);

	c16btn = (ControlHandle)GetDlgItem(hDlg, IDC_PC980124);

	lcdbtn[0] = (ControlHandle)GetDlgItem(hDlg, IDC_LCD);
	lcdbtn[1] = (ControlHandle)GetDlgItem(hDlg, IDC_LCDX);
	skipbtn = (ControlHandle)GetDlgItem(hDlg, IDC_SKIPLINE);

	chip = (np2cfg.uPD72020)?1:0;
	setchip(chipbtn, chip);
	grcg = np2cfg.grcg & 3;
	setgrcg(grcgbtn, grcg);
	color16 = (np2cfg.color16)?1:0;
	SetControlValue(c16btn, color16);

	val = np2cfg.wait[0];
	if (val > 32) {
		val = 32;
	}
	SPRINTF(work, str_u, val);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_TRAMWAIT), workstr);
	val = np2cfg.wait[2];
	if (val > 32) {
		val = 32;
	}
	SPRINTF(work, str_u, val);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_VRAMWAIT), workstr);
	val = np2cfg.wait[4];
	if (val > 32) {
		val = 32;
	}
	SPRINTF(work, str_u, val);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_GRCGWAIT), workstr);
	val = np2cfg.realpal;
	if (val > 64) {
		val = 64;
	}
	SPRINTF(work, str_d, val - 32);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_REALPAL), workstr);

	lcd = np2cfg.LCD_MODE & 3;
	SetControlValue(lcdbtn[0], lcd & 1);
	SetControlValue(lcdbtn[1], (lcd & 2) >> 1);
	skipline = (np2cfg.skipline)?1:0;
	SetControlValue(skipbtn, skipline);
	SPRINTF(work, str_u, np2cfg.skiplight);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_SKIPLIGHT), workstr);

	SetDialogDefaultItem(hDlg, IDOK);
	SetDialogCancelItem(hDlg, IDCANCEL);

	done = 0;
	while(!done) {
		ModalDialog(NULL, &item);
		switch(item) {
			case IDOK:
				update = 0;
				if (np2cfg.uPD72020 != chip) {
					np2cfg.uPD72020 = chip;
					update |= SYS_UPDATECFG;
					gdc_restorekacmode();
					gdcs.grphdisp |= GDCSCRN_ALLDRAW2;
				}
				if (np2cfg.grcg != grcg) {
					np2cfg.grcg = grcg;
					update |= SYS_UPDATECFG;
					gdcs.grphdisp |= GDCSCRN_ALLDRAW2;
				}
				if (np2cfg.color16 != color16) {
					np2cfg.color16 = color16;
					update |= SYS_UPDATECFG;
				}

				GetDialogItemText(GetDlgItem(hDlg, IDC_TRAMWAIT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 32) {
					val = 32;
				}
				waitval[0] = val;
				waitval[1] = (val)?1:0;
				GetDialogItemText(GetDlgItem(hDlg, IDC_VRAMWAIT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 32) {
					val = 32;
				}
				waitval[2] = val;
				waitval[3] = (val)?1:0;
				GetDialogItemText(GetDlgItem(hDlg, IDC_GRCGWAIT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 32) {
					val = 32;
				}
				waitval[4] = val;
				waitval[5] = (val)?1:0;
				if (memcmp(np2cfg.wait, waitval, 6)) {
					CopyMemory(np2cfg.wait, waitval, 6);
					update |= SYS_UPDATECFG;
				}
				GetDialogItemText(GetDlgItem(hDlg, IDC_REALPAL), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work) + 32;
				if (val > 64) {
					val = 64;
				}
				if (np2cfg.realpal != val) {
					np2cfg.realpal = val;
					update |= SYS_UPDATECFG;
				}

				renewal = 0;
				if (np2cfg.skipline != skipline) {
					np2cfg.skipline = skipline;
					renewal = 1;
				}
				GetDialogItemText(GetDlgItem(hDlg, IDC_SKIPLIGHT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 255) {
					val = 255;
				}
				if (np2cfg.skiplight != val) {
					np2cfg.skiplight = val;
					renewal = 1;
				}
				if (renewal) {
					pal_makeskiptable();
				}
				if (np2cfg.LCD_MODE != lcd) {
					np2cfg.LCD_MODE = lcd;
					pal_makelcdpal();
					renewal = 1;
				}
				if (renewal) {
					update |= SYS_UPDATECFG;
					scrndraw_redraw();
				}

				sysmng_update(update);
				done = IDOK;
				break;

			case IDCANCEL:
				done = IDCANCEL;
				break;

			case IDC_LCD:
				lcd ^= 1;
				SetControlValue(lcdbtn[0], lcd & 1);
				break;

			case IDC_LCDX:
				lcd ^= 2;
				SetControlValue(lcdbtn[1], (lcd & 2) >> 1);
				break;

			case IDC_SKIPLINE:
				skipline ^= 1;
				SetControlValue(skipbtn, skipline);
				break;

			case IDC_GDC7220:
				chip = 0;
				setchip(chipbtn, chip);
				break;

			case IDC_GDC72020:
				chip = 1;
				setchip(chipbtn, chip);
				break;

			case IDC_GRCGNON:
				grcg = 0;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_GRCG:
				grcg = 1;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_GRCG2:
				grcg = 2;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_EGC:
				grcg = 3;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_PC980124:
				color16 ^= 1;
				SetControlValue(c16btn, color16);
				break;
		}
	}
	DisposeDialog(hDlg);
}
コード例 #3
0
AROS_UFH3(void, packet_reply,
          AROS_UFHA(struct ph_mount *, mount,     A1),
          AROS_UFHA(APTR,              dummy,   A5),
          AROS_UFHA(struct ExecBase *, SysBase, A6)) {   

    AROS_USERFUNC_INIT

    struct DosPacket *dp;
    struct ph_packet *pkt;
    struct IOFileSys *iofs;
    struct ph_handle *handle;

    /* retrieve the message and fish the packet out */
    dp = (struct DosPacket *) GetMsg(&(mount->reply_port))->mn_Node.ln_Name;
    pkt = (struct ph_packet *) dp->dp_Link;

    D(bug("[packet] got reply packet %d (%s)\n", dp->dp_Type, act_str(dp->dp_Type)));

    /* get the iofs back */
    iofs = (struct IOFileSys *) dp->dp_Arg7;

    /* dos error code comes back in Res2 */
    if (dp->dp_Res1 == DOSFALSE) {
        iofs->io_DosError = dp->dp_Res2;

        /* do any cleanup from the request (eg freeing memory) */
        switch (dp->dp_Type) {
            case ACTION_FINDINPUT:
            case ACTION_FINDOUTPUT:
            case ACTION_FINDUPDATE:
                FreeMem((APTR) BADDR(dp->dp_Arg1), sizeof(struct ph_handle));
                break;

            case ACTION_SAME_LOCK:
                /* DOSFALSE & no error means the locks are different */
                if (iofs->io_DosError == 0)
                    iofs->io_Union.io_SAME_LOCK.io_Same = LOCK_DIFFERENT;
                break;

            case ACTION_PARENT:
                /* no error means they tried to go up past the root. The
                 * packet system allows this, IOFS does not */
                if (iofs->io_DosError == 0)
                    iofs->io_DosError = ERROR_OBJECT_NOT_FOUND;
                break;

            /* a zero result is not an error for the following three packet
             * types. We shouldn't really be here */
            case ACTION_SEEK:
                iofs->io_Union.io_SEEK.io_Offset = dp->dp_Res1;
                iofs->io_DosError = 0;
                break;
            case ACTION_READ:
        	iofs->io_Union.io_READ.io_Length = dp->dp_Res1; 
        	iofs->io_DosError = 0;
        	break;
            case ACTION_SET_FILE_SIZE:
                iofs->io_DosError = 0;
                break;
        }

        /* kill the packet */
        DeletePool(pkt->pool);

        D(bug("[packet] returning error %ld\n", iofs->io_DosError));

        /* and tell them */
        ReplyMsg((APTR) iofs);

        return;
    }

    /* no error */
    iofs->io_DosError = 0;
    
    /* populate the iofs with the results. note that for packets that only
     * return success/failure we have nothing to do, so they're not listed
     * here */
    switch (dp->dp_Type) {

        case ACTION_COPY_DIR:
        case ACTION_COPY_DIR_FH:
        case ACTION_LOCATE_OBJECT:
        case ACTION_PARENT:
        case ACTION_PARENT_FH:
            handle = (struct ph_handle *) AllocMem(sizeof(struct ph_handle), MEMF_PUBLIC | MEMF_CLEAR);
            if (handle == NULL) {
                iofs->io_DosError = ERROR_NO_FREE_STORE;
                break;
            }

            /* we'll need the lock they gave us for future operations */
            handle->actual = (void *) dp->dp_Res1;
            handle->is_lock = TRUE;
            handle->mount = mount;

            iofs->IOFS.io_Unit = (struct Unit *) handle;

            break;

        case ACTION_FINDINPUT:
        case ACTION_FINDOUTPUT:
        case ACTION_FINDUPDATE: {
            /* handlers return "internal data" (typically a lock, though we
             * can't assume that) in fh_Arg1. we need to keep it for later
             * filehandle operations.
             * the calls that need this data (e.g. ACTION_READ/WRITE/SEEK)
             * take it directly in dp_Arg1 */
            handle = (struct ph_handle *) BADDR(dp->dp_Arg1);
            handle->actual = (void *) handle->fh.fh_Arg1;
            handle->is_lock = FALSE;
            handle->mount = mount;

            iofs->IOFS.io_Unit = (struct Unit *) handle;

            break;
        }

        case ACTION_FREE_LOCK:
        case ACTION_END:
            /* free up our data */
            handle = (struct ph_handle *) iofs->IOFS.io_Unit;
            FreeMem((APTR) handle, sizeof(struct ph_handle));
            iofs->IOFS.io_Unit = NULL;
            break;

        case ACTION_READ:
            if (dp->dp_Res1 == -1)
        	iofs->io_DosError = dp->dp_Res2;
            iofs->io_Union.io_READ.io_Length = dp->dp_Res1;
            break;

        case ACTION_WRITE:
            iofs->io_Union.io_WRITE.io_Length = dp->dp_Res1;
            break;

        case ACTION_SEEK:
            if (dp->dp_Res1 == -1)
                iofs->io_DosError = dp->dp_Res2;
            else
                iofs->io_Union.io_SEEK.io_Offset = dp->dp_Res1;
            break;

        case ACTION_SET_FILE_SIZE:
            if (dp->dp_Res1 == -1)
                iofs->io_DosError = dp->dp_Res2;
            break;

        case ACTION_SAME_LOCK:
            iofs->io_Union.io_SAME_LOCK.io_Same = LOCK_SAME;
            break;

        case ACTION_EXAMINE_OBJECT:
        case ACTION_EXAMINE_FH: {
            struct FileInfoBlock *fib = (struct FileInfoBlock *) BADDR(dp->dp_Arg2);
            struct ExAllData *ead = iofs->io_Union.io_EXAMINE.io_ead;
            ULONG size = iofs->io_Union.io_EXAMINE.io_Size;
            ULONG mode = iofs->io_Union.io_EXAMINE.io_Mode;
            ULONG comment_len = 0, filename_len = 0;

            iofs->io_DirPos = fib->fib_DiskKey;

            /* make sure we have enough room for everything that came back */
            if (size < sizeof(struct ExAllData) +
                       (mode >= ED_COMMENT ? (comment_len = fib->fib_Comment[0]) : 0) +
                       (mode >= ED_NAME    ? (filename_len = fib->fib_FileName[0]) : 0)) {
                iofs->io_DosError = ERROR_BUFFER_OVERFLOW;
                FreeMem(fib, sizeof(struct FileInfoBlock));
                break;
            }

            /* copy stuff from the fib to the ead */
            switch (mode) {
                case ED_OWNER:
                    ead->ed_OwnerUID = fib->fib_OwnerUID;
                    ead->ed_OwnerGID = fib->fib_OwnerGID;

                case ED_COMMENT:
                    /* store the comment in the spare space after the ead and
                     * the filename */
                    ead->ed_Comment = (UBYTE *) ead + sizeof(struct ExAllData) + filename_len + 1;
                    strcpy(ead->ed_Comment,
                        mkcstr(pkt->pool, fib->fib_Comment));

                case ED_DATE:
                    ead->ed_Days = fib->fib_Date.ds_Days;
                    ead->ed_Mins = fib->fib_Date.ds_Minute;
                    ead->ed_Ticks = fib->fib_Date.ds_Tick;

                case ED_PROTECTION:
                    ead->ed_Prot = fib->fib_Protection;
                    
                case ED_SIZE:
                    ead->ed_Size = fib->fib_Size;

                case ED_TYPE:
                    ead->ed_Type = fib->fib_EntryType;

                case ED_NAME:
                    /* store the name in the spare space after the ead */
                    ead->ed_Name = (UBYTE *) ead + sizeof(struct ExAllData);
                    strcpy(ead->ed_Name, mkcstr(pkt->pool, fib->fib_FileName));
               
                case 0:
                    ead->ed_Next = NULL;
                    break;

                default:
                    iofs->io_DosError = ERROR_BAD_NUMBER;
                    break;
            }

            FreeMem(fib, sizeof(struct FileInfoBlock));

            break;
        }

        case ACTION_EXAMINE_NEXT: {
            struct FileInfoBlock *fib = iofs->io_Union.io_EXAMINE_NEXT.io_fib;
            strcpy(fib->fib_FileName, mkcstr(pkt->pool, fib->fib_FileName));
            strcpy(fib->fib_Comment, mkcstr(pkt->pool, fib->fib_Comment));
            break;
        }

        case ACTION_IS_FILESYSTEM:
            iofs->io_Union.io_IS_FILESYSTEM.io_IsFilesystem = TRUE;
            break;

        case ACTION_CREATE_DIR:
            handle = (struct ph_handle *) AllocMem(sizeof(struct ph_handle), MEMF_PUBLIC | MEMF_CLEAR);
            if (handle == NULL) {
                iofs->io_DosError = ERROR_NO_FREE_STORE;
                break;
            }

            /* we'll need the lock they gave us for future operations */
            handle->actual = (void *) dp->dp_Res1;
            handle->is_lock = TRUE;
            handle->mount = mount;

            iofs->IOFS.io_Unit = (struct Unit *) handle;

            break;

        case ACTION_READ_LINK:
            iofs->io_Union.io_READ_SOFTLINK.io_Size = dp->dp_Res1;
            iofs->io_DosError = dp->dp_Res1 < 0 ? dp->dp_Res2 : 0;
            break;

        case ACTION_MORE_CACHE:
            iofs->io_Union.io_MORE_CACHE.io_NumBuffers = dp->dp_Res1;
    }

    /* done with the packet */
    DeletePool(pkt->pool);

    /* send it back */
    ReplyMsg((APTR) iofs);

    AROS_USERFUNC_EXIT
}