示例#1
0
        private void Jazz2_ProcessFound(object sender, EventArgs e)
        {
            var functionPointer = jazz2.Allocate(
                0x50,                                       // push eax
                0x55,                                       // push ebp
                0xBD, 0x00, 0x00, 0x00, 0x00,               // mov ebp,00000000
                0xC7, 0x45, 0x00, 0x01, 0x00, 0x00, 0x00,   // mov [ebp],00000001
                0x8B, 0x45, 0x00,                           // mov eax,[ebp]
                0x83, 0xF8, 0x01,                           // cmp eax,01
                0x74, 0xF8,                                 // je ...
                0x58,                                       // pop eax
                0x5D,                                       // pop epb
                0xE8, 0x00, 0x00, 0x00, 0x00,               // call 00000000
                0xC3                                        // ret
                );

            loadPointer = jazz2.Allocate(0x00, 0x00, 0x00, 0x00);
            jazz2.Write(functionPointer + 3, (int)loadPointer);
            jazz2.Write(functionPointer + 25, jazz2.Address + 0x8F0C0);
            jazz2.Write(jazz2.Address + 0x3FD49, functionPointer);

            var functionPointer2 = jazz2.Allocate(
                0x50,                                       // push eax
                0x55,                                       // push ebp
                0xBD, 0x00, 0x00, 0x00, 0x00,               // mov ebp,00000000
                0xC7, 0x45, 0x00, 0x02, 0x00, 0x00, 0x00,   // mov [ebp],00000002
                0x8B, 0x45, 0x00,                           // mov eax,[ebp]
                0x83, 0xF8, 0x02,                           // cmp eax,02
                0x74, 0xF8,                                 // je ...
                0x58,                                       // pop eax
                0x5D,                                       // pop epb
                0x83, 0xFF, 0xFD,                           // cmp edi,-03
                0x0F, 0x84, 0x00, 0x00, 0x00, 0x00,         // je ....
                0xC3                                        // ret
                );

            jazz2.Write(functionPointer2 + 3, (int)loadPointer);
            jazz2.Write(functionPointer2 + 29, jazz2.Address + 0x66217);
            jazz2.Write(jazz2.Address + 0x66290, (byte)0xE8);
            jazz2.Write(jazz2.Address + 0x66291, functionPointer2);
        }
        public void OnLoadLevel(Jazz2 jazz2)
        {
            jazz2.Read(jazz2.Address + 0x1F3884, out string levelName, 32);
            var levelIndex = Array.IndexOf(LevelOrder, levelName.ToLower());

            if (levelIndex >= 0 && levelIndex < LevelSettings.Count)
            {
                var nextLevel = levelIndex + 1 < LevelOrder.Length ? LevelOrder[levelIndex + 1] : "ending";
                jazz2.Write(jazz2.Address + 0x14D5D3, nextLevel, 32);
                LevelSettings[levelIndex].OnLoadLevel(jazz2, rng);
            }
        }
示例#3
0
        public void OnLoadTilset(Jazz2 jazz2, Random rng)
        {
            if (RandomizeColors)
            {
                if (bitShifts == null)
                {
                    bitShifts = Enumerable.Range(0, 3)
                                .Select(x => 8 * x)
                                .OrderBy(x => rng.Next())
                                .ToArray();
                }

                int[] colors = new int[256];
                jazz2.Read(jazz2.Address + 0x1607A0, colors);
                for (int i = 0; i < colors.Length; i++)
                {
                    var r = colors[i] & 0xFF;
                    var g = (colors[i] >> 8) & 0xFF;
                    var b = (colors[i] >> 16) & 0xFF;
                    colors[i] = r << bitShifts[0] | g << bitShifts[1] | b << bitShifts[2];
                }
                jazz2.Write(jazz2.Address + 0x1607A0, colors);
            }
        }
示例#4
0
        public void OnLoadLevel(Jazz2 jazz2, Random rng)
        {
            jazz2.Read(jazz2.Address + 0x1191D4, out IntPtr eventsPointer);
            jazz2.Read(eventsPointer, out eventsPointer);

            if (events == null)
            {
                var characterCount = 0;
                var characters     = new int[5];
                if (Jazz)
                {
                    characters[characterCount++] = 55;
                }
                if (Spaz)
                {
                    characters[characterCount++] = 89;
                }
                if (Lori)
                {
                    characters[characterCount++] = 61;
                }
                if (Frog)
                {
                    characters[characterCount++] = 47;
                }
                if (Bird)
                {
                    characters[characterCount++] = 8;
                }
                character = characters[rng.Next(characterCount)];

                jazz2.Read(jazz2.Address + 0x10F14C, out int width);
                jazz2.Read(jazz2.Address + 0x1191AC, out int height);

                events = new int[width * height];
                jazz2.Read(eventsPointer, events);

                var eventLookups = new Dictionary <int, int>();
                for (int i = 0; i < events.Length; i++)
                {
                    var eventId    = events[i] & 0xFF;
                    var eventGroup = EventGroups.FirstOrDefault(x => x.EventsFrom.Any(y => y.EventId == eventId));
                    if (eventGroup != null)
                    {
                        if (eventGroup.RandomizeIndividually)
                        {
                            events[i] = eventGroup.EventsTo[rng.Next(eventGroup.EventsTo.Count)].EventId;
                        }
                        else
                        {
                            if (!eventLookups.TryGetValue(eventId, out int newEventId))
                            {
                                newEventId            = eventGroup.EventsTo[rng.Next(eventGroup.EventsTo.Count)].EventId;
                                eventLookups[eventId] = newEventId;
                            }
                            events[i] = newEventId;
                        }
                    }
                }
            }

            jazz2.Write(eventsPointer, events);
            jazz2.Write(jazz2.Address + 0x1C89E0, character);
            //jazz2.Write(jazz2.Address + 0x14D613, song, 32);
        }