void vm_xputch(char x, char y, char attr, char ch) { unsigned long address; address = vm_screenaddress(x, y); _farpokeb(_go32_conventional_mem_selector(), address, ch); _farpokeb(_go32_conventional_mem_selector(), address + 1L, attr); }
void vm_puts(char x, char y, char *str) { char ofs; ofs = 0; while (*str) { unsigned long address; address = vm_screenaddress(x + ofs, y); _farpokeb(_go32_conventional_mem_selector(), address, *str); str++; ofs++; } }
/* Copy data into the clipboard, return zero if successful. */ unsigned set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) { __dpmi_regs regs; unsigned truelen; unsigned long xbuf_addr, buf_offset; unsigned char *dp = Data, *dstart = dp; if (Format != CF_OEMTEXT) return 3; /* need to know final size after '\r' chars are inserted (the standard CF_OEMTEXT clipboard format uses CRLF line endings, while Emacs uses just LF internally). */ truelen = Size + 1; /* +1 for the terminating null */ if (!Raw) { /* avoid using strchr because it recomputes the length everytime */ while ((dp = memchr (dp, '\n', Size - (dp - dstart))) != 0) { truelen++; dp++; } } if (clipboard_compact (truelen) < truelen) return 1; if ((xbuf_addr = alloc_xfer_buf (truelen)) == 0) return 1; /* Move the buffer into the low memory, convert LF into CR-LF if needed. */ if (Raw) { dosmemput (Data, Size, xbuf_addr); /* Terminate with a null, otherwise Windows does strange things when the text size is an integral multiple of 32 bytes. */ _farpokeb (_dos_ds, xbuf_addr + Size, '\0'); } else { dp = Data; buf_offset = xbuf_addr; _farsetsel (_dos_ds); while (Size--) { /* Don't allow them to put binary data into the clipboard, since it will cause yanked data to be truncated at the first null. */ if (*dp == '\0') return 2; if (*dp == '\n') _farnspokeb (buf_offset++, '\r'); _farnspokeb (buf_offset++, *dp++); } /* Terminate with a null, otherwise Windows does strange things when the text size is an integral multiple of 32 bytes. */ _farnspokeb (buf_offset, '\0'); } /* Stash away the data we are about to put into the clipboard, so we could later check inside get_clipboard_data whether the clipboard still holds our data. */ if (clipboard_storage_size < truelen) { clipboard_storage_size = truelen + 100; last_clipboard_text = (char *) xrealloc (last_clipboard_text, clipboard_storage_size); } if (last_clipboard_text) dosmemget (xbuf_addr, truelen, last_clipboard_text); /* Calls Int 2Fh/AX=1703h with: DX = WinOldAp-Supported Clipboard format ES:BX = Pointer to data SI:CX = Size of data in bytes Return Values AX == 0: Error occurred <> 0: OK. Data copied into the Clipboard. */ regs.x.ax = 0x1703; regs.x.dx = Format; regs.x.si = truelen >> 16; regs.x.cx = truelen & 0xffff; regs.x.es = xbuf_addr >> 4; regs.x.bx = xbuf_addr & 15; __dpmi_int (0x2f, ®s); free_xfer_buf (); /* If the above failed, invalidate the local copy of the clipboard. */ if (regs.x.ax == 0) *last_clipboard_text = '\0'; /* Zero means success, otherwise (1, 2, or 3) it's an error. */ return regs.x.ax > 0 ? 0 : 3; }
int Main(int argc, char **argv) { if(argc > 1 && festring(argv[1]) == "--version") { std::cout << "Iter Vehemens ad Necem version " << IVAN_VERSION << std::endl; return 0; } #ifdef __DJGPP__ /* Saves numlock state and toggles it off */ char ShiftByteState = _farpeekb(_dos_ds, 0x417); _farpokeb(_dos_ds, 0x417, 0); #endif /* __DJGPP__ */ femath::SetSeed(time(0)); game::InitGlobalValueMap(); scriptsystem::Initialize(); databasesystem::Initialize(); game::InitLuxTable(); ivanconfig::Initialize(); igraph::Init(); game::CreateBusyAnimationCache(); globalwindowhandler::SetQuitMessageHandler(game::HandleQuitMessage); msgsystem::Init(); protosystem::Initialize(); igraph::LoadMenu(); for(;;) { int Select = iosystem::Menu(igraph::GetMenuGraphic(), v2(RES.X / 2, RES.Y / 2 - 20), CONST_S("\r"), CONST_S("Start Game\rContinue Game\r" "Configuration\rHighscores\r" "Quit\r"), LIGHT_GRAY, CONST_S("Released under the GNU\r" "General Public License\r" "More info: see COPYING\r"), CONST_S("IVAN v" IVAN_VERSION "\r")); switch(Select) { case 0: if(game::Init()) { igraph::UnLoadMenu(); game::Run(); game::DeInit(); igraph::LoadMenu(); } break; case 1: { festring LoadName = iosystem::ContinueMenu(WHITE, LIGHT_GRAY, game::GetSaveDir()); if(LoadName.GetSize()) { LoadName.Resize(LoadName.GetSize() - 4); if(game::Init(LoadName)) { igraph::UnLoadMenu(); game::Run(); game::DeInit(); igraph::LoadMenu(); } } break; } case 2: ivanconfig::Show(); break; case 3: { highscore HScore; HScore.Draw(); break; } case 4: #ifdef __DJGPP__ /* Loads numlock state */ _farpokeb(_dos_ds, 0x417, ShiftByteState); #endif return 0; } } }
void vga_writeb(unsigned addr, unsigned char c) { _farpokeb(_dos_ds, addr, c); }
void display_dos_putch(int x, int y, int ch, int co) { _farpokeb(videomem, (y * 80 + x) * 2, ch); _farpokeb(videomem, (y * 80 + x) * 2 + 1, co); }