home *** CD-ROM | disk | FTP | other *** search
Wrap
///////////////////////////////////////////////////////////////////////////// // // This file is Copyright 1992,1993 by Warwick W. Allison. // This file is part of the gem++ library. // You are free to copy and modify these sources, provided you acknowledge // the origin by retaining this notice, and adhere to the conditions // described in the file COPYING.LIB. // ///////////////////////////////////////////////////////////////////////////// #include "vdi.h" #include <vdibind.h> #include <aesbind.h> #include <values.h> #include <stdio.h> #define USEME // The following is an interesting hack. It works, but it's NOT NICE! //#define USEME if (this!=CurrentVDI) BeCurrent() //#include <osbind.h> // My first attempt to make TRULY virtual devices. // When I get info on GDOS's MEMORY.SYS driver, I hope to use that. // //static VDI* CurrentVDI=0; //void VDI::BeCurrent() //{ // CurrentVDI=this; // if (mfdb.fd_addr) Setscreen(mfdb.fd_addr,-1,-1); //} static const NWI=11; static const NWO=64; static int StdWorkIn[]={1,1,1,1,1,1,1,1,1,1,2}; VDI::VDI() : WorkIn(new int[NWI]), WorkOut(new int[NWO]), ExtWorkOut(new int[NWO]) { int j; for (j=0; j<NWI; j++) WorkIn[j]=StdWorkIn[j]; Handle=graf_handle(&j,&j,&j,&j); v_opnvwk(WorkIn,&Handle,WorkOut); q_extnd(1,ExtWorkOut); mfdb.fd_addr=0; // 0=std, right? Or should I use (long)Logbase(); mfdb.fd_w=Width(); mfdb.fd_h=Height(); mfdb.fd_wdwidth=Width()/SHORTBITS; mfdb.fd_stand=0; mfdb.fd_nplanes=NumberOfPlanes(); mfdb.fd_r1=0; mfdb.fd_r2=0; mfdb.fd_r3=0; LocalRaster=FALSE; } VDI::VDI(VDI& v) : WorkIn(new int[NWI]), WorkOut(new int[NWO]), ExtWorkOut(new int[NWO]) { int j; for (j=0; j<NWI; j++) WorkIn[j]=v.WorkIn[j]; Handle=v.Handle; v_opnvwk(WorkIn,&Handle,WorkOut); q_extnd(1,ExtWorkOut); mfdb.fd_addr=v.mfdb.fd_addr; mfdb.fd_w=Width(); mfdb.fd_h=Height(); mfdb.fd_wdwidth=Width()/SHORTBITS; mfdb.fd_stand=0; mfdb.fd_nplanes=NumberOfPlanes(); mfdb.fd_r1=0; mfdb.fd_r2=0; mfdb.fd_r3=0; LocalRaster=FALSE; } VDI::VDI(short* raster) : WorkIn(new int[NWI]), WorkOut(new int[NWO]), ExtWorkOut(new int[NWO]) { int j; for (j=0; j<NWI; j++) WorkIn[j]=StdWorkIn[j]; Handle=graf_handle(&j,&j,&j,&j); v_opnvwk(WorkIn,&Handle,WorkOut); q_extnd(1,ExtWorkOut); if (raster) { mfdb.fd_addr=(long)raster; LocalRaster=FALSE; } else { mfdb.fd_addr=(long)new short[NumberOfPlanes()*Height()*Width()/SHORTBITS]; LocalRaster=TRUE; } mfdb.fd_w=Width(); mfdb.fd_h=Height(); mfdb.fd_wdwidth=Width()/SHORTBITS; mfdb.fd_stand=0; mfdb.fd_nplanes=NumberOfPlanes(); mfdb.fd_r1=0; mfdb.fd_r2=0; mfdb.fd_r3=0; } VDI::VDI(const char* metafile) { if (vq_vgdos()) { // What do I do? } else { Handle = GDOS_NONE; } } VDI::~VDI() { v_clsvwk(Handle); if (LocalRaster) delete (short*)mfdb.fd_addr; } void VDI::clrwk() { v_clrwk(Handle); } void VDI::updwk() { v_updwk(Handle); } int VDI::swr_mode (int mode) { return vswr_mode (Handle, mode); } void VDI::s_color (int index, int rgb[]) { vs_color (Handle, index, rgb); } int VDI::sl_type (int style) { return vsl_type (Handle, style); } void VDI::sl_udsty (int pat) { vsl_udsty (Handle, pat); } int VDI::sl_width (int width) { return vsl_width (Handle, width); } int VDI::sl_color (int index) { return vsl_color (Handle, index); } void VDI::sl_ends (int begstyle, int endstyle) { vsl_ends (Handle, begstyle, endstyle); } int VDI::sm_type (int symbol) { return vsm_type (Handle, symbol); } void VDI::sm_height (int height) { vsm_height (Handle, height); } int VDI::sm_color (int index) { return vsm_color (Handle, index); } int VDI::st_height (int height, int *charw, int *charh, int *cellw, int *cellh) { return vst_height (Handle, height, charw, charh, cellw, cellh); } int VDI::st_point (int point, int *charw, int *charh, int *cellw, int *cellh) { return vst_point (Handle, point, charw, charh, cellw, cellh); } int VDI::st_rotation (int ang) { return vst_rotation (Handle, ang); } int VDI::st_font (int font) { return vst_font (Handle, font); } int VDI::st_color (int index) { return vst_color (Handle, index); } int VDI::st_effects (int effects) { return vst_effects (Handle, effects); } void VDI::st_alignment (int hin, int vin, int *hout, int *vout) { vst_alignment (Handle, hin, vin, hout, vout); } int VDI::sf_interior (int style) { return vsf_interior (Handle, style); } int VDI::sf_fill (int style) { return vsf_fill (Handle, style); } int VDI::sf_style (int style) { return vsf_style (Handle, style); } int VDI::sf_color (int index) { return vsf_color (Handle, index); } int VDI::sf_perimeter (int vis) { return vsf_perimeter (Handle, vis); } void VDI::sf_udpat (int pat[], int planes) { vsf_udpat (Handle, pat, planes); } int VDI::st_load_fonts (int select) { return vst_load_fonts (Handle, select); } void VDI::st_unload_fonts (int select) { vst_unload_fonts (Handle, select); } void VDI::s_clip (int clip_flag, int pxyarray[]) { vs_clip (Handle, clip_flag, pxyarray); } void VDI::bar (int pxyarray[]) { USEME; v_bar (Handle, pxyarray); } void VDI::arc (int x, int y, int radius, int begang, int endang) { USEME; v_arc (Handle, x, y, radius, begang, endang); } void VDI::pieslice (int x, int y, int radius, int begang, int endang) { USEME; v_pieslice (Handle, x, y, radius, begang, endang); } void VDI::circle (int x, int y, int radius) { USEME; v_circle (Handle, x, y, radius); } void VDI::ellarc (int x, int y, int xrad, int yrad, int begang, int endang) { USEME; v_ellarc (Handle, x, y, xrad, yrad, begang, endang); } void VDI::ellpie (int x, int y, int xrad, int yrad, int begang, int endang) { USEME; v_ellpie (Handle, x, y, xrad, yrad, begang, endang); } void VDI::ellipse (int x, int y, int xrad, int yrad) { USEME; v_ellipse (Handle, x, y, xrad, yrad); } void VDI::rbox (int pxyarray[]) { USEME; v_rbox (Handle, pxyarray); } void VDI::rfbox (int pxyarray[]) { USEME; v_rfbox (Handle, pxyarray); } void VDI::justified (int x, int y, char *str, int len, int word_space, int char_space) { USEME; v_justified (Handle, x, y, str, len, word_space, char_space); } int VDI::sin_mode (int dev, int mode) { return vsin_mode (Handle, dev, mode); } void VDI::rq_locator (int x, int y, int *xout, int *yout, int *term) { vrq_locator (Handle, x, y, xout, yout, term); } int VDI::sm_locator (int x, int y, int *xout, int *yout, int *term) { return vsm_locator (Handle, x, y, xout, yout, term); } void VDI::rq_valuator (int in, int *out, int *term) { vrq_valuator (Handle, in, out, term); } void VDI::sm_valuator (int in, int *out, int *term, int *status) { vsm_valuator (Handle, in, out, term, status); } void VDI::rq_choice (int cin, int *cout) { vrq_choice (Handle, cin, cout); } int VDI::sm_choice (int *choice) { return vsm_choice (Handle, choice); } void VDI::rq_string (int len, int echo, int echoxy[], char *str) { vrq_string (Handle, len, echo, echoxy, str); } int VDI::sm_string (int len, int echo, int echoxy[], char *str) { return vsm_string (Handle, len, echo, echoxy, str); } void VDI::sc_form (int form[]) { vsc_form (Handle, form); } void VDI::ex_timv (void *time_addr, void **otime_addr, int *time_conv) { vex_timv (Handle, time_addr, otime_addr, time_conv); } void VDI::show_c (int reset) { USEME; v_show_c (Handle, reset); } void VDI::hide_c () { USEME; v_hide_c (Handle); } void VDI::q_mouse (int *pstatus, int *x, int *y) { vq_mouse (Handle, pstatus, x, y); } void VDI::ex_butv (void *new_p, void **old) { vex_butv (Handle, new_p, old); } void VDI::ex_motv (void *new_p, void **old) { vex_motv (Handle, new_p, old); } void VDI::ex_curv (void *new_p, void **old) { vex_curv (Handle, new_p, old); } void VDI::q_key_s (int *state) { vq_key_s (Handle, state); } void VDI::q_extnd (int flag, int work_out[]) { vq_extnd (Handle, flag, work_out); } int VDI::q_color (int index, int flag, int rgb[]) { return vq_color (Handle, index, flag, rgb); } void VDI::ql_attribute (int atrib[]) { vql_attribute (Handle, atrib); } void VDI::qm_attributes (int atrib[]) { vqm_attributes (Handle, atrib); } void VDI::qf_attributes (int atrib[]) { vqf_attributes (Handle, atrib); } void VDI::qt_attributes (int atrib[]) { vqt_attributes (Handle, atrib); } void VDI::qt_extent (char *str, int extent[]) { vqt_extent (Handle, str, extent); } int VDI::qt_width (int chr, int *cw, int *ldelta, int *rdelta) { return vqt_width (Handle, chr, cw, ldelta, rdelta); } int VDI::qt_name (int element, char *name) { return vqt_name (Handle, element, name); } void VDI::q_cellarray (int pxyarray[], int row_len, int nrows, int *el_used, int *rows_used, int *status, int color[]) { vq_cellarray (Handle, pxyarray, row_len, nrows, el_used, rows_used, status, color); } void VDI::qin_mode (int dev, int *mode) { vqin_mode (Handle, dev, mode); } void VDI::qt_fontinfo (int *minade, int *maxade, int distances[], int *maxwidth, int effects[]) { vqt_fontinfo (Handle, minade, maxade, distances, maxwidth, effects); } void VDI::qt_font_info (int *minade, int *maxade, int distances[], int *maxwidth, int effects[]) { vqt_font_info (Handle, minade, maxade, distances, maxwidth, effects); } void VDI::pline (int count, int pxyarray[]) { USEME; v_pline (Handle, count, pxyarray); } void VDI::pmarker (int count, int pxyarray[]) { v_pmarker (Handle, count, pxyarray); } int VDI::gtext (int x, int y, char *str) { USEME; return v_gtext (Handle, x, y, str); } void VDI::fillarea (int count, int pxyarray[]) { USEME; v_fillarea (Handle, count, pxyarray); } void VDI::cellarray (int pxyarray[], int row_length, int elements, int nrows, int write_mode, int colarray[]) { USEME; v_cellarray (Handle, pxyarray, row_length, elements, nrows, write_mode, colarray); } void VDI::contourfill (int x, int y, int index) { USEME; v_contourfill (Handle, x, y, index); } void VDI::r_recfl (int pxyarray[]) { vr_recfl (Handle, pxyarray); } void VDI::ro_cpyfm (int mode, int pxyarray[], const MFDB& src, const MFDB& dst) { vro_cpyfm (Handle, mode, pxyarray, &src, &dst); } void VDI::rt_cpyfm (int mode, int pxyarray[], const MFDB& src, const MFDB& dst, int color[]) { vrt_cpyfm (Handle, mode, pxyarray, &src, &dst, color); } void VDI::r_trnfm (const MFDB& src, const MFDB& dst) { vr_trnfm (Handle, &src, &dst); } void VDI::get_pixel (int x, int y, int *pel, int *indx) { USEME; v_get_pixel (Handle, x, y, pel, indx); } void VDI::q_chcells (int *n_rows, int *n_cols) { vq_chcells (Handle, n_rows, n_cols); } void VDI::exit_cur () { USEME; v_exit_cur (Handle); } void VDI::enter_cur () { USEME; v_enter_cur (Handle); } void VDI::curup () { USEME; v_curup (Handle); } void VDI::curdown () { USEME; v_curdown (Handle); } void VDI::curright () { USEME; v_curright (Handle); } void VDI::curleft () { USEME; v_curleft (Handle); } void VDI::curhome () { USEME; v_curhome (Handle); } void VDI::eeos () { USEME; v_eeos (Handle); } void VDI::eeol () { USEME; v_eeol (Handle); } void VDI::s_curaddress (int row, int col) { vs_curaddress (Handle, row, col); } void VDI::curtext (char *s) { USEME; v_curtext (Handle, s); } void VDI::rvon () { USEME; v_rvon (Handle); } void VDI::rvoff () { USEME; v_rvoff (Handle); } void VDI::q_curaddress (int *cur_row, int *cur_col) { vq_curaddress (Handle, cur_row, cur_col); } int VDI::q_tabstatus () { return vq_tabstatus (Handle); } void VDI::hardcopy () { USEME; v_hardcopy (Handle); } void VDI::dspcur (int x, int y) { USEME; v_dspcur (Handle, x, y); } void VDI::rmcur () { USEME; v_rmcur (Handle); } void VDI::form_adv () { USEME; v_form_adv (Handle); } void VDI::output_window (int *pxyarray) { USEME; v_output_window (Handle, pxyarray); } void VDI::clear_disp_list () { USEME; v_clear_disp_list (Handle); } void VDI::bit_image (const char *filename, int aspect, int x_scale, int y_scale, int h_align, int v_align, int *pxyarray) { v_bit_image (Handle, filename, aspect, x_scale, y_scale, h_align, v_align, pxyarray); } void VDI::q_scan (int *g_slice, int *g_page, int *a_slice, int *a_page, int *div_fac) { vq_scan (Handle, g_slice, g_page, a_slice, a_page, div_fac); } void VDI::alpha_text (const char *string) { USEME; v_alpha_text (Handle, string); } int VDI::s_palette (int palette) { return vs_palette (Handle, palette); } void VDI::sound (int frequency, int duration) { USEME; v_sound (Handle, frequency, duration); } int VDI::s_mute (int action) { return vs_mute (Handle, action); } void VDI::t_resolution (int xres, int yres, int *xset, int *yset) { vt_resolution (Handle, xres, yres, xset, yset); } void VDI::t_axis (int xres, int yres, int *xset, int *yset) { vt_axis (Handle, xres, yres, xset, yset); } void VDI::t_origin (int xorigin, int yorigin) { vt_origin (Handle, xorigin, yorigin); } void VDI::q_dimensions (int *xdimension, int *ydimension) { vq_dimensions (Handle, xdimension, ydimension); } void VDI::t_alignment (int dx, int dy) { vt_alignment (Handle, dx, dy); } void VDI::sp_film (int index, int lightness) { vsp_film (Handle, index, lightness); } int VDI::qp_filmname (int index, char *name) { return vqp_filmname (Handle, index, name); } void VDI::sc_expose (int state) { vsc_expose (Handle, state); } void VDI::meta_extents (int min_x, int min_y, int max_x, int max_y) { USEME; v_meta_extents (Handle, min_x, min_y, max_x, max_y); } void VDI::write_meta (int num_intin, int *a_intin, int num_ptsin, int *a_ptsin) { USEME; v_write_meta (Handle, num_intin, a_intin, num_ptsin, a_ptsin); } void VDI::m_pagesize (int pgwidth, int pgheight) { vm_pagesize (Handle, pgwidth, pgheight); } void VDI::m_coords (int llx, int lly, int urx, int ury) { vm_coords (Handle, llx, lly, urx, ury); } void VDI::m_filename (const char *filename) { vm_filename (Handle, filename); } void VDI::escape2000 (int times) { USEME; v_escape2000 (Handle, times); } unsigned long VDI::q_vgdos () { return vq_vgdos (); } void VDI::getbitmap_info (int ch, long *advancex, long *advancey, long *xoffset, long *yoffset, int *width, int *height, short **bitmap) { USEME; v_getbitmap_info (Handle, ch, advancex, advancey, xoffset, yoffset, width, height, bitmap); } void VDI::qt_f_extent (const char *str, int extent[]) { vqt_f_extent (Handle, str, extent); } void VDI::ftext (int x, int y, const char *str) { USEME; v_ftext (Handle, x, y, str); } //void VDI::killoutline (void *component) { USEME; v_killoutline (Handle, component); } void VDI::getoutline (int ch, int *xyarray, char *bezarray, int maxverts, int *numverts) { USEME; v_getoutline (Handle, ch, xyarray, bezarray, maxverts, numverts); } void VDI::st_scratch (int mode) { vst_scratch (Handle, mode); } void VDI::st_error (int mode, int *errorvar) { vst_error (Handle, mode, errorvar); } int VDI::st_arbpt (int point, int *wchar, int *hchar, int *wcell, int *hcell ) { return vst_arbpt (Handle, point, wchar, hchar, wcell, hcell ); } void VDI::qt_advance (int ch, int *xadv, int *yadv, int *xrem, int *yrem) { vqt_advance (Handle, ch, xadv, yadv, xrem, yrem); } void VDI::qt_devinfo (int device, int *isdev, char *drivername ) { vqt_devinfo (Handle, device, isdev, drivername ); } int VDI::savecache (char *filename ) { return v_savecache (Handle, filename ); } int VDI::loadcache (char *filename, int mode ) { return v_loadcache (Handle, filename, mode ); } int VDI::flushcache () { return v_flushcache (Handle); } int VDI::st_setsize (int point, int *wchar, int *hchar, int *wcell, int *hcell ) { return vst_setsize (Handle, point, wchar, hchar, wcell, hcell ); } int VDI::st_skew (int skew ) { return vst_skew (Handle, skew ); } // void VDI::qt_get_tables (void **gascii, void **style ) { vqt_get_tables (Handle, gascii, style ); } void VDI::qt_get_table (short **map) { vqt_get_table (Handle, map ); } void VDI::qt_cachesize (int which_cache, size_t *size ) { vqt_cachesize (Handle, which_cache, size ); } int VDI::bez (int count, int *xyarr, char *bezarr, int extent[4], int *npts, int *nmvs) { USEME; return v_bez (Handle, count, xyarr, bezarr, extent, npts, nmvs); } int VDI::bez_fill (int count, int *xyarr, char *bezarr, int extent[4], int *npts, int *nmvs) { USEME; return v_bez_fill (Handle, count, xyarr, bezarr, extent, npts, nmvs); } int VDI::bez_qual (int percent, int *actual) { USEME; return v_bez_qual (Handle, percent, actual); } int VDI::bez_on () { return v_bez_on (Handle); } void VDI::bez_off () { v_bez_off (Handle); } void VDI::shtext (int wsid, int x, int y, const char *text, int color, int xshadow, int yshadow ) { USEME; v_shtext (wsid, x, y, text, color, xshadow, yshadow ); } void VDI::set_app_buff (void **buf_p, int size) { v_set_app_buff (buf_p, size); } // Shorthands... int VDI::st_height(int height) { int j; return st_height(height,&j,&j,&j,&j); } int VDI::st_point(int point) { int j; return st_point(point,&j,&j,&j,&j); } void VDI::st_alignment(int hin, int vin) { st_alignment(hin,vin,&hin,&vin); } void VDI::clip() { int j[]={0,0,MaxX(),MaxY()}; s_clip(1,j); } void VDI::clip(int x1, int y1, int x2, int y2) { int j[]={x1,y1,x2,y2}; s_clip(1,j); } void VDI::clip_off() { static int j[]={0,0,0,0}; s_clip(0,j); } void VDI::bar(int x1, int y1, int x2, int y2) { int pxy[]={x1,y1,x2,y2}; bar(pxy); } void VDI::rbox(int x1, int y1, int x2, int y2) { int pxy[]={x1,y1,x2,y2}; rbox(pxy); } void VDI::rfbox(int x1, int y1, int x2, int y2) { int pxy[]={x1,y1,x2,y2}; rfbox(pxy); } void VDI::line(int x1, int y1, int x2, int y2) { int pxy[]={x1,y1,x2,y2}; pline(2,pxy); } void VDI::marker(int x, int y) { int pxy[]={x,y}; pmarker(1,pxy); } void VDI::r_recfl(int x1, int y1, int x2, int y2) { int pxy[]={x1,y1,x2,y2}; r_recfl(pxy); } void VDI::ro_cpyfm (int mode, int pxyarray[], VDI& from) { ro_cpyfm(mode,pxyarray,from.mfdb,mfdb); } void VDI::rt_cpyfm (int mode, int pxyarray[], VDI& from, int color[]) { rt_cpyfm(mode,pxyarray,from.mfdb,mfdb,color); } void VDI::r_trnfm (VDI& from) { r_trnfm(from.mfdb,mfdb); } void VDI::ro_cpyfm(int mode, int pxyarray[]) { ro_cpyfm(mode,pxyarray,mfdb,mfdb); } void VDI::rt_cpyfm(int mode, int pxyarray[], int color[]) { rt_cpyfm(mode,pxyarray,mfdb,mfdb,color); } void VDI::r_trnfm() { r_trnfm(mfdb,mfdb); } int VDI::Charwidth() { int settings[10]; qt_attributes(settings); return settings[6]; } int VDI::Charheight() { int settings[10]; qt_attributes(settings); return settings[7]; } int VDI::Charcellwidth() { int settings[10]; qt_attributes(settings); return settings[8]; } int VDI::Charcellheight() { int settings[10]; qt_attributes(settings); return settings[9]; }