pokenar
Lunatic Red Eyes
- 46
- Posts
- 17
- Years
- Seen Aug 5, 2024
But... what does coding have to do with a map editor, unless there is a function I never used, the coding is up to the script editor you use.What I've always had trouble with is the coding. You should make this as simple as possible for those who are beginners at coding and don't know anything about it.
I still can't believe I haven't fixed that yet. XD
But this is normal, I haven't actually added that yet.
Also, I've added Day/Night pokemon support to MEH, so you can add different Pokemon to different times of day. Currently it requires primaldialga's DNS although a different system may or may not be released at a later time. Also, the tool currently doesn't auto-inject the ASM, so it's kinda useless for the general public at the moment. But for those who want to try it out, here's the ASM:
Spoiler:
Code:.text /*Basic THUMB Headers, should be included in all ASM Routines*/ .align 2 .thumb .thumb_func .global daynightlevelswitch @.org 0x08800000 main: sub r0, r0, r4 /*Subtracts the value of R4 from R0, giving us a clean pointer to use*/ ldr r2, statusbyte /*Loads the ram offset 0x03005542 to R2*/ ldrb r2, [r2] /*Loads the byte contained in the offset*/ ldr r1, timetable ldrb r2, [r1, r2] add r2, r0, r2 b check night: add r2, r0, #0x0 add r2, #0x10 check: ldrb r1, [r2, #0x3] /*Loads the byte stored at the pointer's location plus 3 for checking*/ cmp r1, #0xFF beq nodata cmp r1, #0x8 /*Compares R2 with 0x08, the tell tale sign of a rom pointer, which is what should be stored here if you are using this hack*/ bne nextnormal /*If not equal, load as usual - Thanks Shiny Quagsire!*/ ldr r0, [r2, #0x0] /*Loads the word stored at the location pointed to in R2, the pointer to the wild data*/ nextnormal: add r0, r4, r0 /*Adds the number of bytes from the start of the table that the wild Pokémon slot the game has selected is*/ add r4, r0, #0x0 /*Adds the contents of R0 into R4*/ ldrb r0, [r4, #0x1] /*Loads the upper level limit for the Pokémon if they're stored systematically*/ ldrb r1, [r4, #0x0] /*Loads the lower level limit*/ cmp r0, r1 /*Compares the levels*/ bcc here /*If R0 < R1 goto "here"*/ ldrb r5, [r4, #0x0] /*Loads the lower level limit into R5*/ b here2 here: ldrb r5, [r4, #0x1] /*Reverses the lower and upper level limits to*/ ldrb r0, [r4, #0x0] /*avoid bugs if R0 was smaller than R1 above*/ here2: sub r4, r0, r5 /*Subtracts upper and lower level limits and stores results into R4*/ add r4, #0x1 /*Not entirely sure why, but it's from the original code, and is important for level loading, as leaving it out leads to odd bugs*/ lsl r4, r4, #0x18 /*This line and the next line make sure that you are only passing a byte to the next part of the routine, so it doesn't bug out*/ lsr r4, r4, #0x18 ldr r2, return /*Loads the return offset to R2*/ bx r2 /*Executes a Branch and Exchange goto to the offset contained within the register, ensuring it remains in THUMB mode by being 1 greater than the wanted location*/ nodata: sub r2, r2, r0 cmp r2, #0xC beq night add r2, r0, #0x0 b check .align statusbyte: .word 0x0203C000 return: .word 0x08082915 timetable: .word timetable2 timetable2: .byte 0x10 /*Amount to add to pointer per timezone*/ .byte 0x0 .byte 0x4 .byte 0x8 .byte 0x10 .byte 0x10
Code:.text .align 2 .thumb .thumb_func .global daynightwildswitch @.org 0x08800060 main: ldr r0, [r7, #0x4] push {r0} ldrb r0, enable_swarming cmp r0, #0x0 beq noswarm ldr r0, var_4fff bl var_decrypt ldrh r0, [r0, #0x0] cmp r0, #0x1 bge swarm noswarm: pop {r0} push {r2} daynight: ldr r2, statusbyte ldrb r2, [r2] ldr r1, timetable ldrb r2, [r1, r2] add r2, r0, r2 b check night: add r2, r0, #0x0 add r2, #0x10 check: ldrb r1, [r2, #0x3] cmp r1, #0xFF beq nodata cmp r1, #0x8 bne nextnormal ldr r0, [r2, #0x0] nextnormal: add r0, r4, r0 ldrh r0, [r0, #0x2] back: ldr r1, lastpokemon strh r0, [r1, #0x0] add r1, r5, #0x0 pop {r2} ldr r3, Back bx r3 swarm: pop {r0} ldr r0, var_4ffe bl var_decrypt sub r2, r0, #0x2 ldr r1, currentmap ldr r1, [r1] ldrb r1, [r1, #0x4] ldrb r3, [r1, #0x6] lsl r3, #0x8 add r1, r1, r3 ldrh r2, [r2, #0x0] cmp r1, r2 bne daynightone ldrh r0, [r0, #0x0] b back var_decrypt: ldr r1, vardecrypt bx r1 daynightone: ldr r0, [r7, #0x4] push {r0} b daynight nodata: sub r2, r2, r0 cmp r2, #0xC beq night add r2, r0, #0x0 b check .align Back: .word 0x08082b51 lastpokemon: .word 0x0300555C statusbyte: .word 0x0203C000 vardecrypt: .word 0x0806E455 var_4fff: .word 0x00004FFF /*Replace this with whatever variable you would like to use*/ var_4ffe: .word 0x00004FFE /*Replace this with whatever variable you would like to use*/ currentmap: .word 0x03005008 /*Save block for maps. Here it contains a pointer to the actual map header and player position*/ timetable: .word timetable2 timetable2: .byte 0x10 /*Amount to add to pointer per timezone*/ .byte 0x0 .byte 0x4 .byte 0x8 .byte 0x10 .byte 0x10 .align 2 enable_swarming: .byte 0x0
These are for Fire Red and replace the two routines in this thread. Insertion is exactly the same and only those two routines are required. It also supports swarming although it's disabled by default, but can be activated using the flag at the bottom called "enable_swarming". The how-to on this is also in the thread, although the variable for the map operates slightly different. To change the map, set the variable 0x4FFE with the top byte as the bank and the bottom one as the map. So if I wanted a swarm on Route 1 I'd set variable 0x4FFE to 0x0313, since it's bank 3 and map 0x13 (19 in decimal).
Well, I'm happy to say that unlike Amap 1.92, when I save the rom after editing it with this, I can still open it in GBAPGE, though I can't delete events so I can't test that portion.
Last edited by a moderator: