Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ulih
gargoyle
gargoyle-gitupdate120.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gargoyle-gitupdate120.patch of Package gargoyle
--- terps/git/Makefile +++ terps/git/Makefile @@ -43,7 +43,7 @@ # You shouldn't have to change anything from here on down. MAJOR = 1 -MINOR = 1 +MINOR = 2 PATCH = 0 include $(GLKINCLUDEDIR)/$(GLKMAKEFILE) --- terps/git/README.txt +++ terps/git/README.txt @@ -6,8 +6,6 @@ I wrote Git because I want people to be able to write huge games or try out complicated algorithms without worrying about how fast their games are going to run. I want to play City of Secrets on a Palm without having to wait ten seconds between each prompt. -Currently, Git only works on Unix, but I'm very interested in getting it to work on other platforms. If you want to do a new port, I'd love to hear from you. - Have fun, and let me know what you think! Iain Merrick @@ -76,11 +74,13 @@ GCC 3 has bigger problems than I thought. On PowerPC, the direct threading option results in much slower code; and on x86, terp.c crashes GCC itself if direct threading is used. Therefore, I recommend that you use GCC 2.95 if possible. If you only have GCC 3, don't define USE_DIRECT_THREADING, at least until the compiler bug is fixed. +Since the previous update, GCC 4 has been released, but I haven't evaluated it yet. If you want to give it a try, let me know how you get on! + Some Glk libraries, such as xglk, can't deal with memory-mapped files. You can tell that this is happening if Git can open .ulx files, but complains that .blb files are invalid. The solution is to use gitWithStream() rather than git() in your startup file, and make sure you're giving it a file stream rather than a memory stream. If you're using the git_unix.c startup file, just make sure USE_MMAP isn't defined. -1-byte and 2-byte local variables are not implemented yet. +1-byte and 2-byte local variables are not implemented yet. This means git can't currently play games created with the Superglus system. This will be fixed at some point. -In the search opcodes, direct keys don't work unless they're exactly 4 bytes long. (This is also a bug in glulxe; I inherited it by reusing zarf's code.) +In the search opcodes, direct keys don't work unless they're exactly 4 bytes long. -------------------------------------------------------------------------------- @@ -102,10 +102,24 @@ Thanks also to Joe Mason, Adam Thornton, Simon Baldwin and Joonas Pihlaja who were among the first to try it out and complain that it wasn't working. Joonas also gets special brownie points for trying out more bizarre boundary cases than I realised existed in the first place. +Tor Andersson was apparently the first person to use setmemsize, since he also explained why it didn't work and contributed a fix. Thanks, Tor! + -------------------------------------------------------------------------------- * Version History +1.2.0 2008-01-06 Minor version increment for VM spec 3.1. + Implemented mzero and mcopy, but not malloc and mfree (yet). + +1.1.3 2006-10-04 Fixed a bug in the cache logic that broke the game Floatpoint. + Added some other caching tweaks and put in a few more asserts. + +1.1.2 2006-08-22 streamnum in filter I/O mode no longer prints a garbage char. + Merged in David Kinder's updated Windows startup code. + +1.1.1 2006-08-17 Wow, over a year since the last update. + Rolled in Tor Andersson's fix for setmemsize. + 1.1 2004-12-22 Minor version increment because we now implement VM spec 3.0. Implemented new Unicode opcodes and string types. --- terps/git/compiler.c +++ terps/git/compiler.c @@ -42,7 +42,7 @@ git_uint32 address; // The glulx address of this instruction. git_sint16 codeOffset; // Offset from the block header to the compiled code for this instruction. git_sint16 branchOffset; // If non-zero, offset to a branch opcode followed by a glulx address. - int isReferenced; // Set to TRUE if this can be the destination of a jump. + long isReferenced; // Set to TRUE if this can be the destination of a jump. } PatchNode; @@ -178,11 +178,14 @@ while (!done) { + // If we don't have room for more code, abort. + if ((void*) (sCodeTop + 2) >= (void*) (sTempStart - 1)) + { + longjmp (sJumpBuf, LONGJMP_CACHE_FULL); + } + // Create a temporary patch node for this instruction. - --sTempStart; - abortIfBufferFull (); - sPatch = sTempStart; sPatch->address = pc; sPatch->codeOffset = sCodeTop - (git_uint32*)gBlockHeader; @@ -218,6 +221,8 @@ // patch node and at least two words of space free. assert (sPatch != NULL); + sPatch->branchOffset = 0; // Make sure the patch isn't treated as a branch. + sCodeTop = ((git_uint32*)gBlockHeader) + sPatch->codeOffset; if (i == LONGJMP_CACHE_FULL) @@ -247,6 +252,8 @@ } } + assert ((void*) sCodeTop <= (void*) sTempStart); + // We now know where the block ends. endOfBlock = pc; @@ -344,6 +351,8 @@ gBlockHeader->compiledSize = sCodeTop - (git_uint32*) gBlockHeader; gBlockHeader->glulxSize = endOfBlock - pc; gBlockHeader->runCounter = 0; + + assert(gBlockHeader->compiledSize > 0); // And we're done. return (git_uint32*) (gBlockHeader + 1); @@ -365,14 +374,18 @@ if (h->glulxSize > 0) { ++blockCount; - runCount += h->runCounter >> 16; } } - // For now, the cut-off is just half the average run count. - // (The 16-bit shifts are intended to prevent overflow.) + for (h = start ; h < top ; h = END_OF_BLOCK(h)) + { + if (h->glulxSize > 0) + { + runCount += (h->runCounter + blockCount + 1) / blockCount; + } + } - return ((runCount / blockCount) << 16) / 2; + return runCount / 2; } static void compressWithCutoff (git_uint32 cutoff) @@ -391,13 +404,15 @@ BlockHeader * next = END_OF_BLOCK(h); if (h->runCounter >= cutoff && h->glulxSize > 0) { + git_uint32 size = h->compiledSize; + // Lower the run count of the saved blocks so that they'll // stick around in the short term, but eventually fall out // of the cache if they're not used much in the future. h->runCounter /= 2; - memmove (sCodeTop, h, h->compiledSize * sizeof(git_uint32*)); - sCodeTop += h->compiledSize; + memmove (sCodeTop, h, size * sizeof(git_uint32*)); + sCodeTop += size; ++saveCount; } else --- terps/git/gestalt.c +++ terps/git/gestalt.c @@ -5,7 +5,7 @@ switch (sel) { case GESTALT_SPEC_VERSION: - return 0x00030000; + return 0x00030100; case GESTALT_TERP_VERSION: return GIT_VERSION_NUM; @@ -24,6 +24,17 @@ case GESTALT_UNICODE: return 1; + + case GESTALT_MEM_COPY: + return 1; + + case GESTALT_MALLOC: + // TODO + return 0; + + case GESTALT_MALLOC_HEAP: + // Currently, the heap is never active. + return 0; case GESTALT_GIT_CACHE_CONTROL: return 1; --- terps/git/git.c +++ terps/git/git.c @@ -45,7 +45,11 @@ { // We support version 3.0, which adds Unicode functionality. } - else if (version > 0x0300FF) + else if (version >= 0x030100 && version <= 0x0301FF) + { + // We support version 3.1, which adds some memory-management opcodes. + } + else { fatalError ("Can't run this game, because it uses a newer version " "of the gamefile format than Git understands. You should check " --- terps/git/git.h +++ terps/git/git.h @@ -64,7 +64,10 @@ GESTALT_UNDO = 3, GESTALT_IO_SYSTEM = 4, GESTALT_UNICODE = 5, - + GESTALT_MEM_COPY = 6, + GESTALT_MALLOC = 7, + GESTALT_MALLOC_HEAP = 8, + // This special selector returns 1 if the cache control // opcodes 'git_setcacheram' and 'git_prunecache' are available. --- terps/git/git_windows.c +++ terps/git/git_windows.c @@ -12,12 +12,12 @@ winglk_set_gui(100); winglk_app_set_name("Git"); winglk_set_menu_name("&Git"); - winglk_window_set_title("Windows Git "GIT_VERSION_STR); - winglk_set_about_text("Windows Git "GIT_VERSION_STR"-WinGlk1.25"); + winglk_window_set_title("Windows Git"); + winglk_set_about_text("Windows Git "GIT_VERSION_STR"-WinGlk1.30"); gFilename = (char*)winglk_get_initial_filename(cmdline, "Select a Glulx game to run", - "Glulx Files (.blb;.ulx)|*.blb;*.ulx|All Files (*.*)|*.*||"); + "Glulx Files (.ulx;.blb;.blorb;.glb;.gblorb)|*.ulx;*.blb;*.blorb;*.glb;*.gblorb|All Files (*.*)|*.*||"); winglk_load_config_file(gFilename); return gFilename ? 1 : 0; --- terps/git/labels.inc +++ terps/git/labels.inc @@ -187,6 +187,11 @@ LABEL (binarysearch) LABEL (linkedsearch) +LABEL (mzero) +LABEL (mcopy) +LABEL (malloc) +LABEL (mfree) + LABEL (git_setcacheram) LABEL (git_prunecache) --- terps/git/memory.c +++ terps/git/memory.c @@ -103,20 +103,20 @@ int resizeMemory (git_uint32 newSize) { git_uint8* newRam; - + if (newSize < gOriginalEndMem) return 1; // New size is too small. - - gRamStart -= RAM_OVERLAP; // Adjust RAM boundary to include some ROM. - gRam = gRam + gRamStart; - newRam = realloc (gRam, newSize - gRamStart); - gRamStart += RAM_OVERLAP; // Restore boundary to its previous value. - if (newRam == NULL) + gRamStart -= RAM_OVERLAP; // Adjust RAM boundary to include some ROM. + newRam = realloc(gRam + gRamStart, newSize - gRamStart); + if (!newRam) + { + gRamStart += RAM_OVERLAP; // Restore boundary to its previous value. return 1; // Failed to extend memory. - - gRam = newRam; + } + gRam = newRam - gRamStart; gEndMem = newSize; + gRamStart += RAM_OVERLAP; // Restore boundary to its previous value. return 0; } --- terps/git/opcodes.c +++ terps/git/opcodes.c @@ -439,6 +439,15 @@ case op_debugtrap: parseL (pc, label_debugtrap); break; + + // Memory management + + case op_mzero: parseLL (pc, label_mzero); break; + case op_mcopy: parseLLL (pc, label_mcopy); break; + + case op_malloc: parseLS (pc, label_malloc); break; + case op_mfree: parseL (pc, label_mfree); break; + // Special Git opcodes --- terps/git/opcodes.h +++ terps/git/opcodes.h @@ -100,6 +100,11 @@ #define op_callfii (0x162) #define op_callfiii (0x163) +#define op_mzero (0x170) +#define op_mcopy (0x171) +#define op_malloc (0x178) +#define op_mfree (0x179) + // Special cache control opcodes. #define op_git_setcacheram (0x7940) --- terps/git/savefile.c +++ terps/git/savefile.c @@ -144,6 +144,11 @@ if (chunkSize & 1) glk_get_char_stream (file); } + else if (chunkType == read32("MAll")) + { + fatalError ("Sorry, this saved game can't be loaded, because it uses " + "dynamic memory allocation which Git does not currently support."); + } else { // Unknown chunk type -- just skip it. --- terps/git/terp.c +++ terps/git/terp.c @@ -679,7 +679,7 @@ if (L7 < 0) buffer [L2++] = '-'; - if (L6 > L2) + if (L6 >= L2) goto do_pop_call_stub; // We printed the whole number already. // If we're in filter mode, push a call stub @@ -1206,6 +1206,48 @@ protectPos = L1; protectSize = L2; NEXT; + + // Memory management (new with glulx spec 3.1) + + do_mzero: + if (L1 > 0) { + if (L2 < gRamStart || (L2 + L1) > gEndMem) + memWriteError(L2); + memset(gRam + L2, 0, L1); + } + NEXT; + + do_mcopy: + if (L1 > 0) { + if (L2 < 0 || (L2 + L1) > gEndMem) + memReadError(L2); + if (L3 < gRamStart || (L3 + L1) > gEndMem) + memWriteError(L3); + // ROM and ROM are stored separately, so this is a bit fiddly... + if (L2 > gRamStart) { + // Only need to copy from RAM. Might be overlapping, so use memmove. + memmove(gRam + L3, gRam + L2, L1); + } else if ((L2 + L1) <= gRamStart) { + // Only need to copy from ROM. Can't overlap, so memcpy is safe. + memcpy(gRam + L3, gRom + L2, L1); + } else { + // Need to copy from both ROM and RAM. + L4 = (L2 + L1) - gRamStart; // Amount of ROM to copy. + memcpy(gRam + L3, gRom + L2, L4); + memmove(gRam + L3 + L4, gRam + L2 + L4, L1 - L4); + } + } + NEXT; + + do_malloc: + // TODO + fatalError ("Sorry, git does not yet implement the \"malloc\" instruction."); + goto finished; + + do_mfree: + // TODO + fatalError ("Sorry, git does not yet implement the \"mfree\" instruction."); + goto finished; // Special Git opcodes --- terps/git/version.h +++ terps/git/version.h @@ -1,4 +1,4 @@ // Automatically generated file -- do not edit! #define GIT_MAJOR 1 -#define GIT_MINOR 1 +#define GIT_MINOR 2 #define GIT_PATCH 0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor