/* functions */ void cleanup_narrator() { if (wmes) CloseDevice(wmes); if (WPort) DeletePort(WPort); if (RPort) DeletePort(RPort); if (wmes) DeleteExtIO(wmes); if (rmes) DeleteExtIO(rmes); }
void cleanup() { if(OpenedConsole) CloseConsole(writeReq); if(readReq) DeleteExtIO(readReq); if(readPort) DeletePort(readPort); if(writeReq) DeleteExtIO(writeReq); if(writePort) DeletePort(writePort); if(win) CloseWindow(win); if(IntuitionBase) CloseLibrary(IntuitionBase); }
void CloseIO(void) { if(consoleyes) CloseConsole(); if(conreadreq) DeleteExtIO((struct IORequest *)conreadreq); if(conreadport) DeleteMsgPort(conreadport); if(conwritereq) DeleteExtIO((struct IORequest *)conwritereq); if(conwriteport) DeleteMsgPort(conwriteport); if(timeryes) CloseTimer(timerreq); if(timerreq) DeleteExtIO((struct IORequest *)timerreq); if(timerport) DeleteMsgPort(timerport); }
__stkargs void cleanup_timer(struct timerequest ** tr) { struct MsgPort *tp; struct timerequest *tmp; UBYTE pFlags; if (*tr) { tmp = *tr; tp = tmp->tr_node.io_Message.mn_ReplyPort; if (tp) { /* abort the current request */ pFlags = tp->mp_Flags; /* still needed for DeletePort */ tp->mp_Flags = PA_IGNORE; AbortIO((struct IORequest *) tmp); WaitIO((struct IORequest *) tmp); while (GetMsg(tp)); Forbid(); tp->mp_Flags = pFlags; DeletePort(tp); Permit(); } CloseDevice((struct IORequest *) tmp); DeleteExtIO((struct IORequest *) tmp); } *tr = NULL; }
int cw_device_close(void) { unsigned int i; /* mute all sids */ memset(sidbuf, 0, sizeof(sidbuf)); for (i = 0; i < sizeof(sidbuf); i++) { write_sid(i, 0, i / 0x20); } for (i = 0; i < 2; i++) { if (gCatweaselReq[i]) { CloseDevice((struct IORequest *)gCatweaselReq[i]); if (gCatweaselReq[i] != NULL) { DeleteExtIO((struct IORequest *)gCatweaselReq[i]); } if (gDiskPort[i] != NULL) { DeletePort(gDiskPort[i]); } gCatweaselReq[i] = NULL; gDiskPort[i] = NULL; } } log_message(LOG_DEFAULT, "CatWeasel Device: closed"); return 0; }
__stkargs int setup_timer(LONG unit, struct timerequest ** tr) { struct MsgPort *timerport; struct timerequest *req; if (*tr) return 1; if (!(timerport = (struct MsgPort *) CreatePort(0L, 0L))) { *tr = NULL; printf("setup_timer: could not create port\n"); return 0; } if (!(req = (struct timerequest *) CreateExtIO(timerport ,sizeof(struct timerequest)) )) { DeletePort(timerport); *tr = NULL; printf("setup_timer: could not get request\n"); return 0; } if (OpenDevice(TIMERNAME, unit, (struct IORequest *) req, 0L)) { CloseDevice((struct IORequest *) req); DeleteExtIO((struct IORequest *) req); DeletePort(timerport); printf("setup_timer: could not open timer\n"); *tr = NULL; return 0; } *tr = req; return 1; }
void stop_noise(void) { AbortIO(&(audioreq->ioa_Request)); FreeMem(chipnoisedata, sizeof(noisedata) ); CloseDevice(&(audioreq->ioa_Request)); DeleteExtIO(&(audioreq->ioa_Request), sizeof(*audioreq)*2); DeletePort(nport); }
static void gettimeofday_shutdown(void) { if (TimerIO) { CloseDevice(TimerIO); DeleteExtIO(TimerIO); } if (TimerMP) { DeletePort(TimerMP); } TimerBase = NULL; }
void delete_timer(struct timerequest *tr) { struct MsgPort *tp; if (tr != 0) { tp = tr->tr_node.io_Message.mn_ReplyPort; if (tp != 0) { DeletePort(tp); } CloseDevice((struct IORequest *) tr); DeleteExtIO((struct IORequest *) tr); } }
void closetimer() { if (TimerIO) { /* Delete any pending timer requests */ if (!(CheckIO((struct IORequest *)TimerIO))) AbortIO((struct IORequest *)TimerIO); CloseDevice((struct IORequest *) TimerIO); DeleteExtIO((struct IORequest *) TimerIO); } if (TimerMP) { DeletePort(TimerMP); } }
int cw_device_open(void) { static int atexitinitialized = 0; unsigned int i; if (atexitinitialized) { cw_device_close(); } gSIDs = 0; gSwapSIDs = FALSE; for (i = 0; i < 2; i++) { if ((gDiskPort[i] = CreatePort(NULL, 0)) != NULL) { if (gCatweaselReq[i] = (struct IOExtTD *)CreateExtIO(gDiskPort[i], sizeof(struct IOExtTD))) { if (OpenDevice("catweaselsid.device", i, (struct IORequest *)gCatweaselReq[i], 0)) { DeleteExtIO((struct IORequest *)gCatweaselReq[i]); DeletePort(gDiskPort[i]); gCatweaselReq[i] = NULL; gDiskPort[i] = NULL; } else { gSIDs++; } } } } if (gSIDs == 0) { return -1; } if (gCatweaselReq[1] && gCatweaselReq[0] == NULL) { gSwapSIDs = TRUE; } /* install exit handler, so device is closed on exit */ if (!atexitinitialized) { atexitinitialized = 1; atexit((voidfunc_t)cw_device_close); } sidfh = 1; /* ok */ return 1; }
void _glfwPlatformCloseWindow( void ) { // Restore mouse pointer (if hidden) _glfwPlatformShowMouseCursor(); // Destroy OpenGL context if( _glfwWin.Context ) { #ifdef _GLFW_STORMMESA AmigaMesaDestroyContext( _glfwWin.Context ); #endif _glfwWin.Context = NULL; } // Close window if( _glfwWin.Window ) { CloseWindow( _glfwWin.Window ); _glfwWin.Window = NULL; } // Close screen if( _glfwWin.Fullscreen && _glfwWin.Screen ) { CloseScreen( _glfwWin.Screen ); } _glfwWin.Screen = NULL; // Close input device I/O request if( _glfwWin.InputIO ) { CloseDevice( (struct IORequest *) _glfwWin.InputIO ); DeleteExtIO( (struct IORequest *) _glfwWin.InputIO ); _glfwWin.InputIO = NULL; } // Close input device message port if( _glfwWin.InputMP ) { DeletePort( _glfwWin.InputMP ); _glfwWin.InputMP = NULL; } }
int main(void) { struct IOStdReq *ior; struct MsgPort *mp; char buff[10]; Printf("main\n"); if (mp = (struct MsgPort *)CreatePort(0,0)) { Printf("got port\n"); if (ior = (struct IOStdReq *) CreateExtIO(mp, sizeof(struct IOStdReq))) { Printf("got extio\n"); if (OpenDevice("example.device",0,(struct IORequest*)ior,0) == 0) { Printf("opened device\n"); ior->io_Data = buff; ior->io_Command = CMD_READ; ior->io_Length = 1; DoIO((struct IORequest *)ior); Printf("done read\n"); ior->io_Data = buff; ior->io_Command = CMD_WRITE; ior->io_Length = 1; DoIO((struct IORequest *)ior); Printf("done write\n"); CloseDevice((struct IORequest *)ior); } DeleteExtIO((struct IORequest *)ior); } DeletePort(mp); } Printf("done\n"); return 0; }
int main( void ) { struct Process *Proc = ( struct Process * )FindTask( 0L ); BlankMsg *FreeMsg; LONG ReturnVal = 0; if( Proc->pr_CLI ) { STRPTR Str = BADDR((( struct CommandLineInterface * ) BADDR( Proc->pr_CLI ))->cli_CommandName ); CopyMem( Str + 1, PrefsPath, *Str ); PrefsPath[*Str] = '\0'; strcat( PrefsPath, ".prefs" ); } IntuitionBase = OpenLibrary( "intuition.library", 37L ); GfxBase = OpenLibrary( GRAPHICSNAME, 37L ); GarshnelibBase = OpenLibrary( "Garshnelib.library", 37L ); if( IntuitionBase && GfxBase && GarshnelibBase ) { ClientPort = CreateMsgPort(); TimerPort = CreateMsgPort(); if( ClientPort && TimerPort ) { TimeOutIO = ( struct timerequest * ) CreateExtIO( TimerPort, sizeof( struct timerequest )); if( TimeOutIO && !OpenDevice( "timer.device", UNIT_VBLANK, ( struct IORequest * )TimeOutIO, 0L )) { ClientPort->mp_Node.ln_Name = PortName; ClientPort->mp_Node.ln_Pri = 0L; AddPort( ClientPort ); CurPrefs = LoadPrefs( PrefsPath ); CurrentTime( &InitSecs, &InitMicros ); RangeSeed = InitSecs + InitMicros; Blank( CurPrefs ); while( FreeMsg = ( BlankMsg * )GetMsg( ClientPort )) { if( FreeMsg->bm_Type & BF_REPLY ) FreeVec( FreeMsg ); else { FreeMsg->bm_Type |= BF_REPLY; ReplyMsg(( struct Message * )FreeMsg ); } } if( CurPrefs ) FreeVec( CurPrefs ); if( !PortRemoved ) RemPort( ClientPort ); } if( TimeOutIO ) { if( TimeOutIO->tr_node.io_Device ) CloseDevice(( struct IORequest * )TimeOutIO ); DeleteExtIO(( struct IORequest * )TimeOutIO ); } } else { Complain( "ClientPort or TimerPort failed to open." ); ReturnVal = 2; } if( ClientPort ) { BlankMsg *TmpMsg; while( TmpMsg = ( BlankMsg * )GetMsg( ClientPort )) { TmpMsg->bm_Flags |= BF_REPLY; ReplyMsg(( struct Message * )TmpMsg ); } DeleteMsgPort( ClientPort ); } if( TimerPort ) DeleteMsgPort( TimerPort ); } else { Complain( "A library failed to open." ); ReturnVal = 1; } if( GarshnelibBase ) CloseLibrary( GarshnelibBase ); if( GfxBase ) CloseLibrary( GfxBase ); if( IntuitionBase ) CloseLibrary( IntuitionBase ); return ReturnVal; }
int _glfwPlatformOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode, int accumredbits, int accumgreenbits, int accumbluebits, int accumalphabits, int auxbuffers, int stereo, int refreshrate ) { struct TagItem tagList[ 25 ]; int tagNR, accumbits; // Calculate sum of accumulator bits accumbits = accumredbits + accumgreenbits + accumbluebits + accumalphabits; // Clear window state _glfwWin.Screen = NULL; _glfwWin.Window = NULL; _glfwWin.Context = NULL; _glfwWin.PointerHidden = 0; _glfwWin.PointerSprite = NULL; _glfwWin.InputMP = NULL; _glfwWin.InputIO = NULL; // Create input.device message port if( !(_glfwWin.InputMP = CreatePort( NULL, 0 )) ) { _glfwPlatformCloseWindow(); return GL_FALSE; } // Create input.device I/O request if( !(_glfwWin.InputIO = (struct IOStdReq *) CreateExtIO( _glfwWin.InputMP, sizeof(struct IOStdReq) )) ) { _glfwPlatformCloseWindow(); return GL_FALSE; } // Open input.device (for pointer position manipulation) if( OpenDevice( "input.device", 0, (struct IORequest *)_glfwWin.InputIO, 0 ) ) { DeleteExtIO( (struct IORequest *) _glfwWin.InputIO ); _glfwWin.InputIO = NULL; _glfwPlatformCloseWindow(); return GL_FALSE; } // Do we want fullscreen? if( _glfwWin.Fullscreen ) { // Open a new Amiga screen if( !_glfwOpenScreen( &width, &height, &redbits, &greenbits, &bluebits, refreshrate ) ) { _glfwWin.Fullscreen = GL_FALSE; } } // Select window properties tagNR = 0; tagList[ tagNR ].ti_Tag = WA_Left; tagList[ tagNR++ ].ti_Data = 0; tagList[ tagNR ].ti_Tag = WA_Top; tagList[ tagNR++ ].ti_Data = 0; tagList[ tagNR ].ti_Tag = WA_IDCMP; tagList[ tagNR++ ].ti_Data = IDCMP_REFRESHWINDOW | IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE | IDCMP_ACTIVEWINDOW | IDCMP_INACTIVEWINDOW | IDCMP_RAWKEY | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS; tagList[ tagNR ].ti_Tag = WA_ReportMouse; tagList[ tagNR++ ].ti_Data = TRUE; tagList[ tagNR ].ti_Tag = WA_RMBTrap; tagList[ tagNR++ ].ti_Data = TRUE; tagList[ tagNR ].ti_Tag = WA_NoCareRefresh; tagList[ tagNR++ ].ti_Data = FALSE; tagList[ tagNR ].ti_Tag = WA_SimpleRefresh; tagList[ tagNR++ ].ti_Data = TRUE; tagList[ tagNR ].ti_Tag = WA_Activate; tagList[ tagNR++ ].ti_Data = TRUE; tagList[ tagNR ].ti_Tag = WA_CloseGadget; tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : TRUE; tagList[ tagNR ].ti_Tag = WA_SizeGadget; tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : ( _glfwWinHints.WindowNoResize ? FALSE : TRUE ); tagList[ tagNR ].ti_Tag = WA_DepthGadget; tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : TRUE; tagList[ tagNR ].ti_Tag = WA_DragBar; tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? FALSE : TRUE; tagList[ tagNR ].ti_Tag = WA_Borderless; tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? TRUE : FALSE; tagList[ tagNR ].ti_Tag = WA_Backdrop; tagList[ tagNR++ ].ti_Data = _glfwWin.Fullscreen ? TRUE : FALSE; if( _glfwWin.Fullscreen ) { tagList[ tagNR ].ti_Tag = WA_CustomScreen; tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Screen; tagList[ tagNR ].ti_Tag = WA_Width; tagList[ tagNR++ ].ti_Data = width; tagList[ tagNR ].ti_Tag = WA_Height; tagList[ tagNR++ ].ti_Data = height; } else { tagList[ tagNR ].ti_Tag = WA_GimmeZeroZero; tagList[ tagNR++ ].ti_Data = TRUE; tagList[ tagNR ].ti_Tag = WA_InnerWidth; tagList[ tagNR++ ].ti_Data = width; tagList[ tagNR ].ti_Tag = WA_InnerHeight; tagList[ tagNR++ ].ti_Data = height; tagList[ tagNR ].ti_Tag = WA_MinWidth; tagList[ tagNR++ ].ti_Data = 20; tagList[ tagNR ].ti_Tag = WA_MinHeight; tagList[ tagNR++ ].ti_Data = 20; tagList[ tagNR ].ti_Tag = WA_MaxWidth; tagList[ tagNR++ ].ti_Data = 9999; tagList[ tagNR ].ti_Tag = WA_MaxHeight; tagList[ tagNR++ ].ti_Data = 9999; tagList[ tagNR ].ti_Tag = WA_Title; tagList[ tagNR++ ].ti_Data = (ULONG) "GLFW Window"; tagList[ tagNR ].ti_Tag = WA_ScreenTitle; tagList[ tagNR++ ].ti_Data = (ULONG) "GLFW Application"; } tagList[ tagNR ].ti_Tag = TAG_DONE; // Open window _glfwWin.Window = OpenWindowTagList( NULL, tagList ); if( !_glfwWin.Window ) { _glfwPlatformCloseWindow(); return GL_FALSE; } // Fullscreen/windowed post fixups if( _glfwWin.Fullscreen ) { // Don't show screen title ShowTitle( _glfwWin.Screen, FALSE ); // Remember window size _glfwWin.Width = _glfwWin.Window->Width; _glfwWin.Height = _glfwWin.Window->Height; } else { // If we are not in fullscreen mode, get screen handle from window _glfwWin.Screen = _glfwWin.Window->WScreen; // Get ModeID for the current video mode _glfwWin.ModeID = GetVPModeID( &_glfwWin.Screen->ViewPort ); // Remember window size _glfwWin.Width = _glfwWin.Window->GZZWidth; _glfwWin.Height = _glfwWin.Window->GZZHeight; } // Put window on top WindowToFront( _glfwWin.Window ); // Create OpenGL context #ifdef _GLFW_STORMMESA tagNR = 0; tagList[ tagNR ].ti_Tag = AMA_Window; tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Window; tagList[ tagNR ].ti_Tag = AMA_RastPort; tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Window->RPort; tagList[ tagNR ].ti_Tag = AMA_Screen; tagList[ tagNR++ ].ti_Data = (ULONG) _glfwWin.Screen; tagList[ tagNR ].ti_Tag = AMA_Left; tagList[ tagNR++ ].ti_Data = 0; tagList[ tagNR ].ti_Tag = AMA_Bottom; tagList[ tagNR++ ].ti_Data = 0; tagList[ tagNR ].ti_Tag = AMA_Width; tagList[ tagNR++ ].ti_Data = _glfwWin.Width; tagList[ tagNR ].ti_Tag = AMA_Height; tagList[ tagNR++ ].ti_Data = _glfwWin.Height; tagList[ tagNR ].ti_Tag = AMA_DoubleBuf; tagList[ tagNR++ ].ti_Data = GL_TRUE; tagList[ tagNR ].ti_Tag = AMA_RGBMode; tagList[ tagNR++ ].ti_Data = GL_TRUE; tagList[ tagNR ].ti_Tag = AMA_AlphaFlag; tagList[ tagNR++ ].ti_Data = alphabits ? GL_TRUE : GL_FALSE; tagList[ tagNR ].ti_Tag = AMA_NoDepth; tagList[ tagNR++ ].ti_Data = depthbits ? GL_FALSE : GL_TRUE; tagList[ tagNR ].ti_Tag = AMA_NoStencil; tagList[ tagNR++ ].ti_Data = stencilbits ? GL_FALSE : GL_TRUE; tagList[ tagNR ].ti_Tag = AMA_NoAccum; tagList[ tagNR++ ].ti_Data = accumbits ? GL_FALSE : GL_TRUE; tagList[ tagNR ].ti_Tag = AMA_DirectRender; tagList[ tagNR++ ].ti_Data = GL_TRUE; tagList[ tagNR ].ti_Tag = AMA_DrawMode; tagList[ tagNR++ ].ti_Data = AMESA_AGA_C2P; tagList[ tagNR ].ti_Tag = TAG_DONE; _glfwWin.Context = AmigaMesaCreateContext( tagList ); #endif if( !_glfwWin.Context ) { _glfwPlatformCloseWindow(); return GL_FALSE; } // Make current #ifdef _GLFW_STORMMESA AmigaMesaMakeCurrent( _glfwWin.Context, _glfwWin.Context->buffer ); #endif return GL_TRUE; }
void DeleteStdIO (struct IORequest *ioreq) { DeleteExtIO (ioreq); }
void main(int argc,char *argv[]) { int unit; char *devicename; /* ML */ if (argc!=2 && argc!=3) exit(0); unit = argv[1][0]-'0'; if (unit!=0 && unit!=1) exit(0); port = (struct MsgPort *)CreatePort(0,0); if (!port) exit(10); req = (struct IOStdReq *)CreateExtIO(port, sizeof(struct IOExtTD)); if (!req) exit(11); devicename="ide.device"; /* ML */ if (argc==3) devicename=argv[2]; /* ML */ if (OpenDevice (devicename,unit,(struct IORequest *)req,0)) exit(12); mu = (struct MyUnit *)req->io_Unit; if (argc==2) { printf("Device %d:\n",mu->mdu_UnitNum); if (mu->mdu_drv_type==ATAPI_DRV) { printf(" ATAPI device\n"); printf(" Motor is : "); if (mu->mdu_motor==0) printf("OFF\n"); else printf("ON\n"); printf(" Disk change count : %d\n",mu->mdu_change_cnt); printf(" Disk inserted : "); if (mu->mdu_no_disk==0) printf("YES\n"); else printf("NO\n"); } else if (mu->mdu_drv_type==ATA_DRV) { printf(" ATA device\n"); if (mu->mdu_lba) { printf(" LBA"); if (mu->mdu_numlba) printf(" - %d user addressable sectors\n",mu->mdu_numlba); else printf("\n"); } else printf(" no LBA\n"); printf(" Sectors per track : %d\n",mu->mdu_sectors_per_track); printf(" Heads : %d\n",mu->mdu_heads); printf(" Cylinders : %d\n",mu->mdu_cylinders); printf(" Size : %d MB\n",mu->mdu_sectors_per_track*mu->mdu_heads*mu->mdu_cylinders/2048); printf(" Motor is : "); if (mu->mdu_motor==0) printf("OFF\n"); else printf("ON\n"); } else printf(" not present\n",unit); if (mu->mdu_drv_type!=UNKNOWN_DRV && mu->mdu_auto) { printf(" Serial number : %s\n",mu->mdu_ser_num); printf(" Firmware revision : %s\n",mu->mdu_firm_rev); printf(" Model number : %s\n",mu->mdu_model_num); } } else { sprintf(hlp,"Ram:Drive%d",unit); if ((fd = fopen(hlp,"w"))!=NULL) { if (mu->mdu_drv_type==ATAPI_DRV) { fprintf(fd,"ATAPI\n"); } else if (mu->mdu_drv_type==ATA_DRV) { fprintf(fd,"ATA\n"); if (mu->mdu_lba) { fprintf(fd,"LBA %d\n",mu->mdu_numlba); } else fprintf(fd,"noLBA 0\n"); fprintf(fd,"%d\n",mu->mdu_sectors_per_track); fprintf(fd,"%d\n",mu->mdu_heads); fprintf(fd,"%d\n",mu->mdu_cylinders); fprintf(fd,"%d\n",mu->mdu_sectors_per_track*mu->mdu_heads*mu->mdu_cylinders/2048); } else fprintf(fd,"NONE\n"); if (mu->mdu_drv_type!=UNKNOWN_DRV) { if (mu->mdu_auto) { fprintf(fd,"[%s]\n",mu->mdu_ser_num); fprintf(fd,"[%s]\n",mu->mdu_firm_rev); fprintf(fd,"[%s]\n",mu->mdu_model_num); } else fprintf(fd,"X\nX\nX\n"); } } fclose(fd); } CloseDevice((struct IORequest *)req); DeleteExtIO((struct IORequest *)req); DeletePort(port); exit(0); }