Title: ASM request: LA DX gba color adjust from Oracle games Post by: arablizzard2413 on February 19, 2011, 10:49:58 AM I apologize if I made any errors, I'm working off notes I made a year ago when I gave up.
Ok, first some back story: the Oracle games adjust the palettes on the fly when the game detects it's running on a gba (initializes b as 01 on boot?) since their screens show colors darker than on the original gbc screen. There is a gbc emulator for NDS (Lameboy) that doesn't support the bit that tells the game it's gba but it can be hacked to do so (rom offsets below). I prefer using the gba colors since they look better to me on the NDS's screen. I'm still very new to gameboy rom hacking, it's possible I -could- do this on my own, but the problem is I'm not familiar enough with how gbc roms are structured so I don't know how to find a large enough unused section to inject the code into or really what calculations the code is doing to modify the palette as it's read. Anyway, I would like to add the asm that adjusts the palettes in the Oracle games to Link's Awakening so I can use it on Lameboy. I know the location of the code that does it (0xfc067), I was able to find it by putting access breakpoints in bgb's debugger on FF68-FF6B write and FF96 read, write. tl;dr Asm N00b needs help injecting longer code into Link's Awakening to adjust the palette as it's read into memory. Would be eternally grateful for the hack done on either the 1.1 or 1.2 version of the Link's Awakening DX rom. For those interested: Palette change + Advance Shop open (Ages/Seasons) 0x15c: 02 -> 00 Advance Shop open, Palette change disabled (Ages/Seasons) 0x15c: 02 -> 00 0xfc03e: 20 -> 18 Advance Shop open, Use detect gba code for palette change 0x12536: D0 -> 00 (Ages) OR 0x12198: D0 -> 00 (Seasons) Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: Lin on February 19, 2011, 06:57:06 PM The palettes in the games change? I never knew that. Anyway, IF I remember correctly, the palettes in Link's Awakening get loaded into D000. That may be the Oracles, but I think LADX had something like that as well. I haven't messed with LADX too much past loading a dungeon tileset.
Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: arablizzard2413 on February 19, 2011, 08:18:15 PM I'm not sure what you mean, FF68-FF6B are the hardware addresses where the palette information is written to so it can be drawn on screen. The Oracle games make changes to these values just before they're written to those addresses and that's what I'm trying to replicate in LADX, but the code currently there is too short to overwrite with the code from the Oracle games. FF96 is the address in the Oracle games stores the value that determines if it should enable gba features after boot, it's just useful for tracing the code to determine where it branches off.
Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: Lin on February 19, 2011, 10:02:03 PM You just taught me something I've wanted to know. As for what you want, I'm really unsure because I haven't messed with anything like you're wanting.
Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: arablizzard2413 on February 19, 2011, 10:27:17 PM So you don't know where to find unused space in the rom and be able to jump to that address either? :(
Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: Lin on February 19, 2011, 10:53:47 PM Oh, doing something like that would be simple. It'd go kind of like this.
Code: LD A,05 ;05 = bank number LD (2222),A ;2222 = bank switch JP 1234 ;1234 = jump address Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: arablizzard2413 on February 20, 2011, 12:21:40 AM Right, but where can I find unused space that I can put my code into? That's the part I'm stuck at, I don't know the gameboy rom format well enough to tell what is just junk that I can put my own code in and have it run.
Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: Lin on February 20, 2011, 12:27:13 AM You can't just have code run. You have to call it. The space at bank 0 (0000-3FFF) is always active in the RAM, so put your code in the free space there. You're going to have to find the palette procedure and make it call the new code. In fact, you're probably going to have to copy some code over into the free space just to make things work.
Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: arablizzard2413 on February 20, 2011, 10:30:29 AM Yes I know, lol sorry if I'm frustrating you, I know about calls, jmp, replacing code, ret, etc the piece i was missing was bank 0 which is what I was trying to get at but didn't know the name for. When I said have it run, i meant a location that I can legally put code into and call it from the loop that writes to the palette registers and not some space like where the tiles are stored or whatever. Thanks, I'm gonna play around with it and see what i can come up with in the morning.
Edit: The code resides in bank 21 for Link's Awakening and bank 3f for the Oracle games (which makes sense given the address I mentioned earlier, 0xfc067). Lin, do you think you can take a look at this? I'm not to the point in asm where stuff like this makes sense to me, but I have a feeling it's much simpler than how it looks: RO3F:4067 Code: ldi a,(hl) ld c,a and a,e0 ld b,a ld a,(hl) and a,03 or b swap a ld b,a ldd a,(hl) and a,7c rrca rrca push hl ld hl,de60 rst 10 ld a,b ld b,(hl) ld hl,de21 rst 10 ldd a,(hl) or b ld b,a ld a,c and a,1f ld c,(hl) ld hl,de00 rst 10 ld a,(hl) or c pop hl ld c,h res 7,l ld h,df ldi (hl),a ld a,b ldi (hl),a set 7,l ld h,c ret Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: Jigglysaint on February 25, 2011, 06:50:00 PM As far as I'm aware, LADX only has a bit to determine if you are running on regular GB or GBC. I'm not sure how you could implement a hardware detect bit
Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: arablizzard2413 on February 25, 2011, 11:50:57 PM That's not what I'm trying to do :(
The Oracle games apply a mathematical formula to the palette values as they're being written to the GBC's palette registers when they detect that they're running on a gba so the colors look correct on the darker screen. I do not care about the gba detection part, I'm looking to take the mathematical formula it applies and put it in Link's Awakening. If you run the oracle games in a debugger you'll see what I'm talking about, the code branches off into a separate section of code when it writes to FF68-FF6B depending on the value in FF96 (the address where the game stores the gba detection flag after the initial boot). ie. You change the palette values at 0x5c008 in Oracle of Ages to 28 32 BE 13 00 31 00 00, when you run the game with the gba detect flag set those values become 30 53 FF 2B 00 52 00 00 in vram. Title: Re: ASM request: LA DX gba color adjust from Oracle games Post by: Lin on February 26, 2011, 06:42:46 AM I don't know how palettes get written, or oam is set to actually show up, or anything like that. If I knew I'd be able to debug and give you the code.
|