static void poscheck (struct hardfiledata *hfd, int len) { int ret; uae_u64 pos = 0; if (hfd->handle_valid == HDF_HANDLE_LINUX) { ret = uae_fseeko64 (hfd->handle->h, 0, SEEK_CUR); if (ret) { gui_message ("hd: poscheck failed. seek failure, ret %d", ret); abort (); } pos = uae_ftello64 (hfd->handle->h); } else if (hfd->handle_valid == HDF_HANDLE_ZFILE) { pos = zfile_ftell (hfd->handle->zf); } if (len < 0) { gui_message ("hd: poscheck failed, negative length! (%d)", len); abort (); } if (pos < hfd->offset) { gui_message ("hd: poscheck failed, offset out of bounds! (0x%llx < 0x%llx)", pos, hfd->offset); abort (); } if (pos >= hfd->offset + hfd->physsize - hfd->virtual_size || pos >= hfd->offset + hfd->physsize + len - hfd->virtual_size) { gui_message ("hd: poscheck failed, offset out of bounds! (0x%llx >= 0x%llx, LEN=%d)", pos, hfd->offset + hfd->physsize, len); abort (); } if (pos & (hfd->ci.blocksize - 1)) { gui_message ("hd: poscheck failed, offset not aligned to blocksize! (0x%llx & 0x%04.4x = 0x%04.4x\n", pos, hfd->ci.blocksize, pos & hfd->ci.blocksize); abort (); } }
static int hdf_seek (struct hardfiledata *hfd, uae_u64 offset) { size_t ret; if (hfd->handle_valid == 0) { gui_message ("hd: hdf handle is not valid. bug."); abort(); } if (offset >= hfd->physsize - hfd->virtual_size) { gui_message ("hd: tried to seek out of bounds! (0x%llx >= 0x%llx)\n", offset, hfd->physsize); abort (); } offset += hfd->offset; if (offset & (hfd->ci.blocksize - 1)) { gui_message ("hd: poscheck failed, offset=0x%llx not aligned to blocksize=%d! (0x%llx & 0x%04.4x = 0x%04.4x)\n", offset, hfd->ci.blocksize, offset, hfd->ci.blocksize, offset & (hfd->ci.blocksize - 1)); abort (); } if (hfd->handle_valid == HDF_HANDLE_LINUX) { ret = uae_fseeko64 (hfd->handle->h, offset, SEEK_SET); if (ret) { write_log("hdf_seek failed\n"); return -1; } } else if (hfd->handle_valid == HDF_HANDLE_ZFILE) { zfile_fseek (hfd->handle->zf, (long)offset, SEEK_SET); } return 0; }
/* * CAPS support proper starts here * * This is more or less a straight copy of Toni's Win32 code */ int caps_init (void) { static int init, noticed; unsigned int i; struct CapsVersionInfo cvi; if (init) return 1; if (!load_capslib ()) { write_log ("Failed to load CAPS plug-in.\n"); if (noticed) return 0; gui_message ("This disk image needs the C.A.P.S. plugin\n" "which is available from\n" "http//www.caps-project.org/download.shtml\n"); noticed = 1; return 0; } init = 1; cvi.type = LIB_TYPE; CAPSGetVersionInfo (&cvi, 0); write_log ("CAPS: library version %d.%d\n", cvi.release, cvi.revision); for (i = 0; i < 4; i++) caps_cont[i] = CAPSAddImage (); return 1; }
bool uae_ppc_direct_physical_memory_handle(uint32_t addr, uint8_t *&ptr) { ptr = get_real_address(addr); if (!ptr) gui_message(_T("Executing PPC code at IO address %08x!"), addr); return true; }
/* * Save the currently loaded configuration. */ void uae_save_config (void) { FILE *f; char tmp[257]; /* Back up the old file. */ strcpy (tmp, optionsfile); strcat (tmp, "~"); write_log ("Backing-up config file '%s' to '%s'\n", optionsfile, tmp); rename (optionsfile, tmp); write_log ("Writing new config file '%s'\n", optionsfile); f = fopen (optionsfile, "w"); if (f == NULL) { gui_message ("Error saving configuration file.!\n"); // FIXME - better error msg. return; } // FIXME - either fix this nonsense, or only allow config to be saved when emulator is stopped. if (uae_get_state () == UAE_STATE_STOPPED) save_options (f, &changed_prefs, 0); else save_options (f, &currprefs, 0); fclose (f); }
static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int *cloanto_rom) { unsigned char buffer[20]; int i, j, cr = 0; fprintf(stderr,"read_kickstart\n"); if (cloanto_rom) *cloanto_rom = 0; i = zfile_fread (buffer, 1, 11, f); if (strncmp ((char *) buffer, "AMIROMTYPE1", 11) != 0) { zfile_fseek (f, 0, SEEK_SET); } else { cr = 1; } if (cloanto_rom) *cloanto_rom = cr; i = zfile_fread (mem, 1, size, f); if (i != 8192 && i != 65536 && i != 131072 && i != 262144 && i != 524288 && i != 524288 * 2 && i != 524288 * 4) { gui_message ("Error while reading Kickstart ROM file."); return 0; } if (i == size / 2) memcpy (mem + size / 2, mem, size / 2); if (cr) { if (!decode_cloanto_rom (mem, size, i, 0)) return 0; } if (currprefs.cs_a1000ram) { int off = 0; a1000_bootrom = xcalloc (262144, 1); while (off + i < 262144) { memcpy (a1000_bootrom + off, kickmemory, i); off += i; } memset (kickmemory, 0, kickmem_size); a1000_handle_kickstart (1); dochecksum = 0; i = 524288; } zfile_fclose (f); for (j = 0; j < 256 && i >= 262144; j++) { if (!memcmp (mem + j, kickstring, strlen (kickstring) + 1)) break; } if (j == 256 || i < 262144) dochecksum = 0; if (dochecksum) kickstart_checksum (mem, size); return 1; }
static void ersatz_failed (void) { if (already_failed) return; already_failed = 1; gui_message ("Diskfile in DF0: is not compatible with Kickstart replacement.\n"); uae_restart (-1, NULL); }
int current_hpos (void) { int hp = current_hpos_safe (); if (hp < 0 || hp > 256) { gui_message(_T("hpos = %d!?\n"), hp); hp = 0; } return hp; }
/*---------------------------------------------------------------------*/ static gboolean watch_hup( GIOChannel *chann, GIOCondition condition, gpointer data ) { if( hop_pid ) { hop_pid = 0; gui_message( "Hop has terminated unexpectidely" ); close_io_channels(); } return FALSE; }
static void poscheck (struct hardfiledata *hfd, int len) { off_t pos; if (hfd->offset != hfd->offset2 || hfd->size != hfd->size2) { gui_message ("hd: memory corruption detected in poscheck"); abort (); } pos = lseek ((int)hfd->handle, 0, SEEK_CUR); if (pos == -1 ) { gui_message ("hd: poscheck failed. seek failure, error %d", errno); abort (); } if (len < 0) { gui_message ("hd: poscheck failed, negative length! (%d)", len); abort (); } if ((uae_u64)pos < hfd->offset) { gui_message ("hd: poscheck failed, offset out of bounds! (0x%llx < 0x%llx)", pos, hfd->offset); abort (); } if ((uae_u64)pos >= hfd->offset + hfd->size || (uae_u64)pos >= hfd->offset + hfd->size + len) { gui_message ("hd: poscheck failed, offset out of bounds! (0x%llx >= 0x%llx, LEN=%d)", pos, hfd->offset + hfd->size, len); abort (); } if (pos & (hfd->blocksize - 1)) { gui_message ("hd: poscheck failed, offset not aligned to blocksize! (0x%llx & 0x%04.4x = 0x%04.4x\n", pos, hfd->blocksize, pos & hfd->blocksize); abort (); } }
void do_cycles_slow (unsigned long cycles_to_add) { if ((pissoff -= cycles_to_add) >= 0) return; cycles_to_add = -pissoff; pissoff = 0; while ((nextevent - currcycle) <= cycles_to_add) { int i; /* Keep only CPU emulation running while waiting for sync point. */ if (is_syncline > 0) { int rpt = read_processor_time (); int v = rpt - vsyncmintime; int v2 = rpt - is_syncline_end; if (v > vsynctimebase || v < -vsynctimebase) { v = 0; } if (v < 0 && v2 < 0) { pissoff = pissoff_value; return; } } else if (is_syncline < 0) { int rpt = read_processor_time (); int v = rpt - is_syncline_end; if (v < 0) { pissoff = pissoff_value; return; } is_syncline = 0; } cycles_to_add -= nextevent - currcycle; currcycle = nextevent; for (i = 0; i < ev_max; i++) { if (eventtab[i].active && eventtab[i].evtime == currcycle) { if (eventtab[i].handler == NULL) { gui_message(_T("eventtab[%d].handler is null!\n"), i); eventtab[i].active = 0; } else { (*eventtab[i].handler)(); } } } events_schedule (); } currcycle += cycles_to_add; }
static int hdf_seek (struct hardfiledata *hfd, uae_u64 offset) { off_t ret; DEBUG_LOG ("called with offset=0x%llx\n", offset); if (hfd->offset != hfd->offset2 || hfd->size != hfd->size2) { gui_message ("hd: memory corruption detected in seek"); abort (); } if (offset >= hfd->size) { gui_message ("hd: tried to seek out of bounds! (0x%llx >= 0x%llx)\n", offset, hfd->size); abort (); } offset += hfd->offset; if (offset & (hfd->blocksize - 1)) { gui_message ("hd: poscheck failed, offset not aligned to blocksize! (0x%llx & 0x%04.4x = 0x%04.4x)\n", offset, hfd->blocksize, offset & (hfd->blocksize - 1)); abort (); } if (offset >= 0x80000000 && sizeof (off_t) < sizeof (uae_u64)) { DEBUG_LOG ("Failed to seek passed 2GB limit (0x%llx)\n", offset); return -1; } ret = lseek ((int)hfd->handle, offset, SEEK_SET); if (ret == -1) { DEBUG_LOG ("seek failed\n"); return -1; } DEBUG_LOG ("seek okay\n"); return 0; }
void gui_draw_screen(void) { int w; fwc = SDL_MapRGB(screen->format, 0, 128, 0); /* Clear */ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 48, 0)); gui_dirty(NULL); gui_logo(fwc); /* Oscilloscope frames */ w = (screen->w - 270) / 2 - 8; gui_bar(270 - 2, 8 - 2, w + 4, 128 + 4, fwc, screen); gui_bar(270 + w + 8 - 2, 8 - 2, w + 4, 128 + 4, fwc, screen); /* Song info panel */ gui_bar(6, 54, 258, 4 * FONT_CH + 12 + 8, fwc, screen); gui_cpuload(0); gui_voices(0); gui_instructions(0); /* Instructions */ gui_bar(6, 150, screen->w - 12, FONT_CH * 8 + 12, fwc, screen); gui_text(12, 156, "\005\001\003ESC to quit " "\005R to reload sounds\n" "\005\001\002F1..\005\001\003F12 for chromatic " "playing\n" "\005\001\005Shift or \005\001\004Ctrl for " "legato mode on the F keys\n" "\005*/\005/ to increase/decrease modulation\n" "\005\001\004PgUp/\005\001\004PgDn to " "shift one octave up/down\n" "\005P/\005Y to start/stop sound " "\005K to kill all sounds\n" "\005\001\003End/\005\001\004Home or " "\005\001\003Del/\005\001\003Ins to " "select next/previous bank\n" "\005+/\005- to select next/previous bank object\n", screen); gui_bankinfo(0, NULL, NULL); /* Message bar */ gui_bar(6, screen->h - FONT_CH - 12 - 6, screen->w - 12, FONT_CH + 12, fwc, screen); gui_message(NULL, -1); }
void plot_data_cb(const char *msg, void*) { const int samples = rtosc_argument(msg, 0).i; //Construct blob piecewise if(rtosc_message(dsp_osc_buf, 2048, "/ui/plot", "b", samples, NULL)) { //Fill reserved space float *data = (float*) rtosc_argument(dsp_osc_buf,0).b.data; for(int i=0; i < samples; ++i) data[i] = get_sample((float)i/samples); } gui_message(dsp_osc_buf); }
static int amiga_parse_option(const char *option, const char *value, int type) { // some strings are modified during parsing char *value2 = strdup(value); int result = cfgfile_parse_option(&currprefs, (char*) option, (char*) value2, type); free(value2); write_log("set option \"%s\" to \"%s\" (result: %d)\n", option, value, result); if (result != 1) { gui_message("Option failed: %s = %s", option, value); amiga_log_warning("failed to set option \"%s\" to \"%s\" " "(result: %d)\n", option, value, result); } return result; }
void jit_abort (const TCHAR *format,...) { static int happened; int count; TCHAR buffer[WRITE_LOG_BUF_SIZE]; va_list parms; va_start (parms, format); count = _vsntprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms); writeconsole (buffer); va_end (parms); if (!happened) gui_message (_T("JIT: Serious error:\n%s"), buffer); happened = 1; uae_reset (1, 0); }
static int hdf_write_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) { int outlen = 0; if (hfd->ci.readonly) { if (g_debug) { write_log("hfd->readonly\n"); } return 0; } if (hfd->dangerous) { if (g_debug) { write_log("hfd->dangerous\n"); } return 0; } hfd->cache_valid = 0; hdf_seek (hfd, offset); poscheck (hfd, len); memcpy (hfd->cache, buffer, len); if (hfd->handle_valid == HDF_HANDLE_LINUX) { outlen = fwrite (hfd->cache, 1, len, hfd->handle->h); //fflush(hfd->handle->h); if (g_debug) { write_log("wrote %u bytes (wanted %d) at offset %llx\n", outlen, len, offset); } const TCHAR *name = hfd->emptyname == NULL ? _T("<unknown>") : hfd->emptyname; if (offset == 0) { long outlen2; uae_u8 *tmp; int tmplen = 512; tmp = (uae_u8*)xmalloc (uae_u8, tmplen); if (tmp) { memset (tmp, 0xa1, tmplen); hdf_seek (hfd, offset); outlen2 = fread (tmp, 1, tmplen, hfd->handle->h); if (memcmp (hfd->cache, tmp, tmplen) != 0 || outlen != len) gui_message (_T("\"%s\"\n\nblock zero write failed!"), name); xfree (tmp); } } } else if (hfd->handle_valid == HDF_HANDLE_ZFILE) { outlen = zfile_fwrite (hfd->cache, 1, len, hfd->handle->zf); } return outlen; }
static int zlib_test (void) { #if defined WIN32 && !defined __MINGW32__ static int zlibmsg; if (is_zlib) return 1; if (zlibmsg) return 0; zlibmsg = 1; gui_message("zip and gzip support disabled because zlib1.dll is missing"); return 0; #else /* On non-Windows platforms, we can safely assume (I think) that if we got this * far zlib is present - Rich */ return 1; #endif }
void do_cycles_slow (unsigned long cycles_to_add) { #ifdef WITH_X86 #if 0 if (x86_turbo_on) { execute_other_cpu_single(); } #endif #endif if (!currprefs.cpu_thread) { if ((pissoff -= cycles_to_add) >= 0) return; cycles_to_add = -pissoff; pissoff = 0; } else { pissoff = 0x40000000; } while ((nextevent - currcycle) <= cycles_to_add) { if (is_syncline) { if (event_check_vsync()) return; } cycles_to_add -= nextevent - currcycle; currcycle = nextevent; for (int i = 0; i < ev_max; i++) { if (eventtab[i].active && eventtab[i].evtime == currcycle) { if (eventtab[i].handler == NULL) { gui_message(_T("eventtab[%d].handler is null!\n"), i); eventtab[i].active = 0; } else { (*eventtab[i].handler)(); } } } events_schedule (); } currcycle += cycles_to_add; }
static bool load_qemu_implementation(void) { #ifdef WITH_QEMU_CPU write_log(_T("PPC: Loading QEmu implementation\n")); memset(&impl, 0, sizeof(impl)); UAE_DLHANDLE handle = uae_qemu_uae_init(); if (!handle) { #ifdef FSUAE gui_message(_T("PPC: Error loading qemu-uae plugin\n")); #else notify_user (NUMSG_NO_PPC); #endif return false; } write_log(_T("PPC: Loaded qemu-uae library at %p\n"), handle); /* Retrieve function pointers from library */ impl.init = (ppc_cpu_init_function) uae_dlsym(handle, "ppc_cpu_init"); //impl.free = (ppc_cpu_free_function) uae_dlsym(handle, "ppc_cpu_free"); //impl.stop = (ppc_cpu_stop_function) uae_dlsym(handle, "ppc_cpu_stop"); impl.external_interrupt = (qemu_uae_ppc_external_interrupt_function) uae_dlsym(handle, "qemu_uae_ppc_external_interrupt"); impl.map_memory = (ppc_cpu_map_memory_function) uae_dlsym(handle, "ppc_cpu_map_memory"); impl.run_continuous = (ppc_cpu_run_continuous_function) uae_dlsym(handle, "ppc_cpu_run_continuous"); impl.check_state = (ppc_cpu_check_state_function) uae_dlsym(handle, "ppc_cpu_check_state"); impl.set_state = (ppc_cpu_set_state_function) uae_dlsym(handle, "ppc_cpu_set_state"); impl.reset = (ppc_cpu_reset_function) uae_dlsym(handle, "ppc_cpu_reset"); impl.in_cpu_thread = (qemu_uae_ppc_in_cpu_thread_function) uae_dlsym(handle, "qemu_uae_ppc_in_cpu_thread"); impl.lock = (qemu_uae_lock_function) uae_dlsym(handle, "qemu_uae_lock"); // FIXME: not needed, handled internally by uae_dlopen_plugin // uae_dlopen_patch_common(handle); uae_patch_library_ppc(handle); return true; #else return false; #endif }
void romwarning (const int *ids) { int i, exp; TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH]; TCHAR tmp3[MAX_DPATH]; exp = 0; tmp2[0] = 0; i = 0; while (ids[i] >= 0) { struct romdata *rd = getromdatabyid (ids[i]); getromname (rd, tmp1); _tcscat (tmp2, L"- "); _tcscat (tmp2, tmp1); _tcscat (tmp2, L"\n"); if (rd->type & (ROMTYPE_A2091BOOT | ROMTYPE_A4091BOOT)) exp++; i++; } translate_message (exp ? NUMSG_EXPROMNEED : NUMSG_ROMNEED, tmp3); gui_message (tmp3, tmp2); }
static struct MultiDisplay *getdisplay2 (struct uae_prefs *p, int index) { write_log ("Multimonitor detection disabled\n"); Displays[0].primary = 1; Displays[0].monitorname = "Display"; int max; int display = index < 0 ? p->gfx_apmode[screen_is_picasso ? APMODE_RTG : APMODE_NATIVE].gfx_display - 1 : index; max = 0; while (Displays[max].monitorname) max++; if (max == 0) { gui_message (_T("no display adapters! Exiting")); exit (0); } if (index >= 0 && display >= max) return NULL; if (display >= max) display = 0; if (display < 0) display = 0; return &Displays[display]; }
const TCHAR *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth) { int PixelFormat; const char *ext1; static TCHAR errmsg[100] = { 0 }; static int init; ogl_enabled = 0; if (currprefs.gfx_filter != UAE_FILTER_OPENGL) { _tcscpy (errmsg, _T("OPENGL: not enabled")); return errmsg; } w_width = w_w; w_height = w_h; t_width = t_w; t_height = t_h; t_depth = depth; hwnd = ahwnd; total_textures = 2; if (isfullscreen() > 0 && WIN32GFX_GetDepth (TRUE) < 15) { _tcscpy (errmsg, _T("OPENGL: display depth must be at least 15 bit")); return errmsg; } for (;;) { memset (&pfd, 0, sizeof (pfd)); pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA; pfd.cColorBits = depth; pfd.iLayerType = PFD_MAIN_PLANE; openglhdc = GetDC (hwnd); if (!arbMultisampleSupported) { PixelFormat = ChoosePixelFormat (openglhdc, &pfd); // Find A Compatible Pixel Format if (PixelFormat == 0) { // Did We Find A Compatible Format? _tcscpy (errmsg, _T("OPENGL: can't find suitable pixelformat")); return errmsg; } } else { PixelFormat = arbMultisampleFormat; } if (!SetPixelFormat (openglhdc, PixelFormat, &pfd)) { _stprintf (errmsg, _T("OPENGL: can't set pixelformat %x"), PixelFormat); return errmsg; } if (!(hrc = wglCreateContext (openglhdc))) { _tcscpy (errmsg, _T("OPENGL: can't create gl rendering context")); return errmsg; } if (!wglMakeCurrent (openglhdc, hrc)) { _tcscpy (errmsg, _T("OPENGL: can't activate gl rendering context")); return errmsg; } #ifdef FSAA if(!arbMultisampleSupported) { if(InitMultisample(openglhdc, &pfd)) { OGL_free (); _tcscpy (errmsg, "*"); return errmsg; } } #endif break; } glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size); required_texture_size = 2 << exact_log2 (t_width > t_height ? t_width : t_height); if (max_texture_size < t_width || max_texture_size < t_height) { _stprintf (errmsg, _T("OPENGL: %d * %d or bigger texture support required\nYour gfx card's maximum texture size is only %d * %d"), required_texture_size, required_texture_size, max_texture_size, max_texture_size); return errmsg; } required_sl_texture_size = 2 << exact_log2 (w_width > w_height ? w_width : w_height); if (currprefs.gfx_filter_scanlines > 0 && (max_texture_size < w_width || max_texture_size < w_height)) { gui_message (_T("OPENGL: %d * %d or bigger texture support required for scanlines (max is only %d * %d)\n") _T("Scanlines disabled."), required_sl_texture_size, required_sl_texture_size, max_texture_size, max_texture_size); changed_prefs.gfx_filter_scanlines = currprefs.gfx_filter_scanlines = 0; } ext1 = glGetString (GL_EXTENSIONS); if (!init) write_log (_T("OpenGL extensions: %s\n"), ext1); if (strstr (ext1, "EXT_packed_pixels")) packed_pixels = 1; if (strstr (ext1, "WGL_EXT_swap_control")) { wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress ("wglSwapIntervalEXT"); wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress ("wglGetSwapIntervalEXT"); if (!wglGetSwapIntervalEXT || !wglSwapIntervalEXT) { write_log (_T("OPENGL: WGL_EXT_swap_control extension found but no wglGetSwapIntervalEXT or wglSwapIntervalEXT found!?\n")); wglSwapIntervalEXT = 0; wglGetSwapIntervalEXT = 0; } } sl_ti2d_internalformat = GL_RGBA4; sl_ti2d_format = GL_RGBA; sl_ti2d_type = GL_UNSIGNED_SHORT_4_4_4_4_EXT; ti2d_type = -1; if (depth == 15 || depth == 16) { if (!packed_pixels) { _stprintf (errmsg, _T("OPENGL: can't use 15/16 bit screen depths because\n") _T("EXT_packed_pixels extension was not found.")); OGL_free (); return errmsg; } ti2d_internalformat = GL_RGB5_A1; ti2d_format = GL_RGBA; ti2d_type = GL_UNSIGNED_SHORT_5_5_5_1_EXT; } if (depth == 32) { ti2d_internalformat = GL_RGBA; ti2d_format = GL_RGBA; ti2d_type = GL_UNSIGNED_BYTE; if (!packed_pixels) { sl_ti2d_internalformat = GL_RGBA; sl_ti2d_format = GL_RGBA; sl_ti2d_type = GL_UNSIGNED_BYTE; } } if (ti2d_type < 0) { _stprintf (errmsg, _T("OPENGL: Only 15, 16 or 32 bit screen depths supported (was %d)"), depth); OGL_free (); return errmsg; } glGenTextures (total_textures, tex); /* "bitplane" texture */ glBindTexture (GL_TEXTURE_2D, tex [0]); glTexImage2D (GL_TEXTURE_2D, 0, ti2d_internalformat, required_texture_size, required_texture_size,0, ti2d_format, ti2d_type, 0); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); glDisable (GL_DEPTH_TEST); glEnable (GL_TEXTURE_2D); glDisable (GL_LIGHTING); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ogl_enabled = 1; OGL_resize (w_width, w_height); OGL_refresh (); init = 1; write_log (_T("OPENGL: using texture depth %d texture size %d * %d scanline texture size %d * %d\n"), depth, required_texture_size, required_texture_size, required_sl_texture_size, required_sl_texture_size); return 0; }
void combat_enemy_move() { int first_char; int i, v, x, y; int k, l; int active_chars; int is_using_bow = character_using_bow(active_character); if (combat_party_size <= 0) combat_loosed(); /* choose whom to attack */ first_char = lotr_rnd(combat_party_size) - 1; for (i = first_char ;;) { int is_near = abs(active_character->x - combat_party[i]->x) < MAP_NEAR_DISTANCE; is_near = is_near && abs(active_character->y - combat_party[i]->y) < MAP_NEAR_DISTANCE; if ((is_near || is_using_bow) && combat_party[i]->life >= 6 && (combat_party[i]->ring_mode != 2 || ring_not_working)) { break; } i = (i + 1) % combat_party_size; if (i == first_char) { /* nobody founded */ i = -1; break; } } if (i >= 0) { combat_attack(active_character, combat_party[i]); return; } /* choose a shortest path to our opponent */ combat_area_init(); for (i = 0; i < combat_enemies_num; ++i) if (active_character != combat_enemies[i]) { x = combat_enemies[i]->x / 4 - combat_x; y = combat_enemies[i]->y / 4 - combat_y; combat_area[x][y] = 0; } combat_stack_size = 0; combat_stack_start = 0; active_chars = 0; for (i = 0; i < combat_party_size; ++i) if (combat_party[i]->life >= 6) { active_chars++; if (combat_party[i]->ring_mode == 2 && !ring_not_working) continue; x = combat_party[i]->x / 4 - combat_x; y = combat_party[i]->y / 4 - combat_y; combat_area[x][y] = 0; for (k = -MAP_NEAR_DISTANCE / 4; k <= MAP_NEAR_DISTANCE / 4; ++k) for (l = -MAP_NEAR_DISTANCE / 4; l <= MAP_NEAR_DISTANCE / 4; ++l) if (x + k >= 0 && x + k < COMBAT_WIDTH && y + l >= 0 && y + l < COMBAT_HEIGHT && combat_area[x + k][y + l] >= 1000) { combat_area[x + k][y + l] = 1; combat_stack[combat_stack_size][0] = x + k; combat_stack[combat_stack_size][1] = y + l; combat_stack_size++; } } if (active_chars == 0) combat_loosed(); if (combat_stack_size == 0) { active_character->x = -1; snprintf(combat_result_text, sizeof(combat_result_text), "%s abandons the battle.", active_character->name); gui_message(combat_result_text, 1); return; } combat_stack_proceed(); x = active_character->x / 4 - combat_x; y = active_character->y / 4 - combat_y; v = combat_area[x][y]; if (x > 0 && combat_area[x - 1][y] != 0 && combat_area[x - 1][y] < v && map_can_move_to(active_character, combat_x + x - 1, combat_y + y)) { character_move_left(active_character); active_character->ap -= COMBAT_MOVE_COST; return; } if (x + 1 < COMBAT_WIDTH && combat_area[x + 1][y] != 0 && combat_area[x + 1][y] < v && map_can_move_to(active_character, combat_x + x + 1, combat_y + y)) { character_move_right(active_character); active_character->ap -= COMBAT_MOVE_COST; return; } if (y > 0 && combat_area[x][y - 1] != 0 && combat_area[x][y - 1] < v && map_can_move_to(active_character, combat_x + x, combat_y + y - 1)) { character_move_up(active_character); active_character->ap -= COMBAT_MOVE_COST; return; } if (y + 1 < COMBAT_HEIGHT && combat_area[x][y + 1] != 0 && combat_area[x][y + 1] < v && map_can_move_to(active_character, combat_x + x, combat_y + y + 1)) { character_move_down(active_character); active_character->ap -= COMBAT_MOVE_COST; return; } /* we do not know what to do */ active_character->ap = 0; }
int combat_frame() { if (!combat_mode) return 0; if (active_character->action != CHARACTER_STAY) { character_frame(active_character); map_display(0, 0); goto end_combat_frame; } if (gui_mode() == DIALOG_MESSAGE) { gui_frame(); if (gui_mode() != DIALOG_MESSAGE) { if (combat_who_attacked->life <= 0 && game_in_party(combat_who_attacked)) gui_player_dead(combat_who_attacked, 0); combat_character_finished(); } goto end_combat_frame; } if (combat_attack_animation) { combat_attack_animation = 0; /* message switches to next player */ gui_message(combat_result_text, 1); goto end_combat_frame; } if (game_in_party(active_character)) { if (gui_frame() != MAIN_MENU) goto end_combat_frame; if (game_get_moving()) combat_player_move(); } else { combat_enemy_move(); if (active_character->x < 0) goto end_combat_frame; } if (!combat_attack_animation && active_character->ap <= 0) combat_character_finished(); map_display(0, 0); end_combat_frame: map_animate_frame(); return combat_mode; }
int dos_errno (void) { DWORD e = GetLastError (); //write_log (_T("ec=%d\n"), e); switch (e) { case ERROR_NOT_ENOUGH_MEMORY: case ERROR_OUTOFMEMORY: return ERROR_NO_FREE_STORE; case ERROR_FILE_EXISTS: case ERROR_ALREADY_EXISTS: return ERROR_OBJECT_EXISTS; case ERROR_WRITE_PROTECT: case ERROR_ACCESS_DENIED: return ERROR_WRITE_PROTECTED; case ERROR_FILE_NOT_FOUND: case ERROR_INVALID_DRIVE: case ERROR_INVALID_NAME: case ERROR_PATH_NOT_FOUND: case ERROR_NOT_READY: case ERROR_BAD_UNIT: case ERROR_REQUEST_ABORTED: case ERROR_INVALID_HANDLE: case ERROR_DEV_NOT_EXIST: case ERROR_INVALID_PARAMETER: case ERROR_NETNAME_DELETED: case ERROR_NETWORK_ACCESS_DENIED: case ERROR_BAD_NET_NAME: case ERROR_BAD_NETPATH: case ERROR_NETWORK_BUSY: case ERROR_SEM_TIMEOUT: return ERROR_OBJECT_NOT_AROUND; case ERROR_HANDLE_DISK_FULL: case ERROR_DISK_FULL: return ERROR_DISK_IS_FULL; case ERROR_SHARING_VIOLATION: case ERROR_BUSY: case ERROR_USER_MAPPED_FILE: return ERROR_OBJECT_IN_USE; case ERROR_CURRENT_DIRECTORY: return ERROR_DIRECTORY_NOT_EMPTY; case ERROR_NEGATIVE_SEEK: case ERROR_SEEK_ON_DEVICE: return ERROR_SEEK_ERROR; default: { static int done; if (!done) gui_message (_T("Unimplemented error %d\nContact author!"), e); done = 1; } return ERROR_NOT_IMPLEMENTED; } }
static void ersatz_init (void) { int f; uaecptr request; uaecptr a; already_failed = 0; write_log ("initializing kickstart replacement\n"); if (disk_empty (0)) { already_failed = 1; gui_message ("You need to have a diskfile in DF0 to use the Kickstart replacement!\n"); uae_restart (-1, NULL); return; } regs.s = 0; /* Set some interrupt vectors */ for (a = 8; a < 0xC0; a += 4) { put_long (a, 0xF8001A); } regs.isp = regs.msp = regs.usp = 0x800; m68k_areg (regs, 7) = 0x80000; regs.intmask = 0; /* Build a dummy execbase */ put_long (4, m68k_areg (regs, 6) = 0x676); put_byte (0x676 + 0x129, 0); for (f = 1; f < 105; f++) { put_word (0x676 - 6*f, 0x4EF9); put_long (0x676 - 6*f + 2, 0xF8000C); } /* Some "supported" functions */ put_long (0x676 - 456 + 2, 0xF80014); put_long (0x676 - 216 + 2, 0xF80020); put_long (0x676 - 198 + 2, 0xF80026); put_long (0x676 - 204 + 2, 0xF8002c); put_long (0x676 - 210 + 2, 0xF8002a); /* Build an IORequest */ request = 0x800; put_word (request + 0x1C, 2); put_long (request + 0x28, 0x4000); put_long (request + 0x2C, 0); put_long (request + 0x24, 0x200 * 4); m68k_areg (regs, 1) = request; ersatz_doio (); /* kickstart disk loader */ if (get_long (0x4000) == 0x4b49434b) { /* a kickstart disk was found in drive 0! */ write_log ("Loading Kickstart rom image from Kickstart disk\n"); /* print some notes... */ write_log ("NOTE: if UAE crashes set CPU to 68000 and/or chipmem size to 512KB!\n"); /* read rom image from kickstart disk */ put_word (request + 0x1C, 2); put_long (request + 0x28, 0xF80000); put_long (request + 0x2C, 0x200); put_long (request + 0x24, 0x200 * 512); m68k_areg (regs, 1) = request; ersatz_doio (); /* read rom image once again to mirror address space. not elegant, but it works... */ put_word (request + 0x1C, 2); put_long (request + 0x28, 0xFC0000); put_long (request + 0x2C, 0x200); put_long (request + 0x24, 0x200 * 512); m68k_areg (regs, 1) = request; ersatz_doio (); disk_eject (0); m68k_setpc (0xFC0002); fill_prefetch_slow (); uae_reset (0); ersatzkickfile = 0; return; } m68k_setpc (0x400C); fill_prefetch_slow (); /* Init the hardware */ put_long (0x3000, 0xFFFFFFFEul); put_long (0xDFF080, 0x3000); put_word (0xDFF088, 0); put_word (0xDFF096, 0xE390); put_word (0xDFF09A, 0xE02C); put_word (0xDFF09E, 0x0000); put_word (0xDFF092, 0x0038); put_word (0xDFF094, 0x00D0); put_word (0xDFF08E, 0x2C81); put_word (0xDFF090, 0xF4C1); put_word (0xDFF02A, 0x8000); put_byte (0xBFD100, 0xF7); put_byte (0xBFEE01, 0); put_byte (0xBFEF01, 0x08); put_byte (0xBFDE00, 0x04); put_byte (0xBFDF00, 0x84); put_byte (0xBFDD00, 0x9F); put_byte (0xBFED01, 0x9F); }