void dma_finalize() { if (!__initialized) return; __dpmi_unlock_linear_region(&__locked_data); __djgpp_nearptr_disable(); }
void Sys_Error (char *error, ...) { va_list argptr; if (!dedicated || !dedicated->value) dos_restoreintr(9); /* FS: Give back the keyboard */ Sys_SetTextMode(); printf ("Sys_Error: "); va_start (argptr,error); vprintf (error,argptr); va_end (argptr); printf ("\n"); __dpmi_free_physical_address_mapping(&info); __djgpp_nearptr_disable(); /* FS: Everyone else is a master DOS DPMI programmer. Pretty sure CWSDPMI is already taking care of this... */ #if 0 { /* we crash here so we can get a backtrace. Yes it is ugly, and no this should never be in production! */ volatile int j,k; fflush(stdout); j=0; k=5/j; /* divide by zero! */ } #endif exit (1); }
/*--------------------------------------------------------------------------*/ UCHAR *GenericSvgaScreen::GetVideoAddress(void) { #if defined(DOUBLE_BUFFER) && !defined(LOCAL_BUFFERING) UCHAR* pMem = GetFrameBufferAddress( mwHRes * mwVRes * 2 ); #else UCHAR* pMem = GetFrameBufferAddress( mwHRes * mwVRes ); #endif #ifdef DPMI_API_DJGPP int ret = __djgpp_nearptr_enable(); if (ret != 0) { return NULL; } else { return NULL; } __djgpp_nearptr_disable(); #endif #ifdef DOUBLE_BUFFER # ifdef LOCAL_BUFFERING mpTargetMem = pMem; pMem = new UCHAR[mwHRes * mwVRes]; # else pMem += mwHRes * mwVRes; # endif #endif return pMem; }
void Sys_Quit (void) { if(!dedicated || !dedicated->value) dos_restoreintr(9); /* FS: Give back the keyboard */ if (unlockmem) { dos_unlockmem (&start_of_memory, end_of_memory - (int)&start_of_memory); } Sys_SetTextMode(); __dpmi_free_physical_address_mapping(&info); __djgpp_nearptr_disable(); /* FS: Everyone else is a master DOS DPMI programmer. Pretty sure CWSDPMI is already taking care of this... */ exit (0); }
/** * Grab the coordinates for the line and draw * each of them */ void draw(Line *line) { if(__djgpp_nearptr_enable() == 0) { printf("Error accessing 64k of memory. Exiting"); exit(-1); } VGA += __djgpp_conventional_base; set_mode(VGA_256_COLOR_MODE); Coord *item = line->start; while(item != NULL) { plot_pixel(item->x, item->y, 100); item = item->next; } while(1 == 1) { } __djgpp_nearptr_disable(); set_mode(TEXT_MODE); }
static void driver_exit(void) { if (mapping.address != 0) { __dpmi_free_physical_address_mapping(&mapping); mapping.address = 0; } if (nearptr_enabled) { __djgpp_nearptr_disable(); nearptr_enabled = FALSE; } if (data_locked) { fb_dos_unlock_data(&video, sizeof(video)); fb_dos_unlock_data(&blitter, sizeof(blitter)); data_locked = FALSE; } fb_dos_exit(); }
int Driver_Display_Bitmap( char* buffer, int line, int col ) { int y, used_col; char* target; #ifdef DJGPP char cbuf = 0; int i; #endif #ifdef DJGPP_USE_NEAR_POINTERS if( djgpp_use_nearpointers ) if( ! __djgpp_nearptr_enable() ) /* doesn't work, probably under some real OS like NT or dosemu! */ djgpp_use_nearpointers = 0; else Vio += __djgpp_conventional_base; #endif #ifdef DJGPP if( !djgpp_use_nearpointers ) for( i = 0; i < vio_Height*vio_ScanLineWidth; i++ ) dosmemput( &cbuf, 1, (unsigned long) Vio+i ); else /*FALLTHROUGH*/ #endif memset( Vio, 0, vio_Height * vio_ScanLineWidth ); if ( line > vio_Height ) line = vio_Height; if ( col > vio_ScanLineWidth ) used_col = vio_ScanLineWidth; else used_col = col; target = Vio + ( line - 1 ) * vio_ScanLineWidth; for ( y = 0; y < line; y++ ) { #ifdef DJGPP if( !djgpp_use_nearpointers ) dosmemput( buffer, used_col, (unsigned long)target ); else /*FALLTHROUGH*/ #endif memcpy( target, buffer, used_col ); target -= vio_ScanLineWidth; buffer += col; } #ifdef DJGPP_USE_NEAR_POINTERS if( djgpp_use_nearpointers ) { Vio -= __djgpp_conventional_base; __djgpp_nearptr_disable(); } #endif return 1; /* success */ }
int gr_init(void) { int org_gamma; int retcode; int mode = SM(320,200); // Only do this function once! if (gr_installed==1) return 3; #ifdef __DJGPP__ if (!__djgpp_nearptr_enable()) { printf("nearptr enable=%x\n", __dpmi_error); return 10; } #ifndef SAVEGR gr_video_memory = (unsigned char *)(__djgpp_conventional_base + 0xa0000); #else gr_video_memory=(unsigned char *)-1; #endif pVideoMode = (volatile ubyte *)(__djgpp_conventional_base+0x449); pNumColumns = (volatile ushort *)(__djgpp_conventional_base+0x44a); pNumRows = (volatile ubyte *)(__djgpp_conventional_base+0x484); pCharHeight = (volatile ushort *)(__djgpp_conventional_base+0x485); pCursorPos = (volatile ushort *)(__djgpp_conventional_base+0x450); pCursorType = (volatile ushort *)(__djgpp_conventional_base+0x460); pTextMemory = (volatile ushort *)(__djgpp_conventional_base+0xb8000); #endif #ifndef __DJGPP__ if (gr_init_A0000()) return 10; #endif // Save the current text screen mode if (gr_save_mode()==1) return 2; #ifndef NOGRAPH // Save the current palette, and fade it out to black. gr_palette_read( gr_pal_default ); gr_palette_faded_out = 0; org_gamma = gr_palette_get_gamma(); gr_palette_set_gamma( 0 ); gr_palette_fade_out( gr_pal_default, 32, 0 ); gr_palette_clear(); gr_palette_set_gamma( org_gamma ); gr_sync_display(); gr_sync_display(); #endif #ifdef __DJGPP__ #ifdef SAVEGR __djgpp_nearptr_disable(); #endif #endif MALLOC( grd_curscreen,grs_screen,1 ); memset( grd_curscreen, 0, sizeof(grs_screen)); // Set the mode. if ((retcode=gr_set_mode(mode))) { gr_restore_mode(); return retcode; } //JOHNgr_disable_default_palette_loading(); // Set all the screen, canvas, and bitmap variables that // aren't set by the gr_set_mode call: grd_curscreen->sc_canvas.cv_color = 0; grd_curscreen->sc_canvas.cv_drawmode = 0; grd_curscreen->sc_canvas.cv_font = NULL; grd_curscreen->sc_canvas.cv_font_fg_color = 0; grd_curscreen->sc_canvas.cv_font_bg_color = 0; gr_set_current_canvas( &grd_curscreen->sc_canvas ); #if 0 if (!dpmi_allocate_selector( &gr_fade_table, 256*GR_FADE_LEVELS, &gr_fade_table_selector )) Error( "Error allocating fade table selector!" ); if (!dpmi_allocate_selector( &gr_palette, 256*3, &gr_palette_selector )) Error( "Error allocating palette selector!" ); #endif // if (!dpmi_allocate_selector( &gr_inverse_table, 32*32*32, &gr_inverse_table_selector )) // Error( "Error allocating inverse table selector!" ); // Set flags indicating that this is installed. gr_installed = 1; #ifdef __GNUC__ atexit((void (*)) gr_close); #else atexit(gr_close); #endif return 0; }