Primary Zelda Hacking
April 21, 2014, 09:54:20 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Current Zelda Oracles Hacking Suite beta version: 0.05
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: ASM request: LA DX gba color adjust from Oracle games  (Read 1482 times)
arablizzard2413
Newcomer
*
Offline Offline

Posts: 6


View Profile
« 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)
« Last Edit: February 19, 2011, 10:51:35 AM by arablizzard2413 » Logged
Lin
ZOLE Creator
Administrator
Hero Member
*****
Offline Offline

Posts: 580



View Profile
« Reply #1 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.
Logged
arablizzard2413
Newcomer
*
Offline Offline

Posts: 6


View Profile
« Reply #2 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.
« Last Edit: February 19, 2011, 08:22:01 PM by arablizzard2413 » Logged
Lin
ZOLE Creator
Administrator
Hero Member
*****
Offline Offline

Posts: 580



View Profile
« Reply #3 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.
Logged
arablizzard2413
Newcomer
*
Offline Offline

Posts: 6


View Profile
« Reply #4 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? Sad
Logged
Lin
ZOLE Creator
Administrator
Hero Member
*****
Offline Offline

Posts: 580



View Profile
« Reply #5 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
Logged
arablizzard2413
Newcomer
*
Offline Offline

Posts: 6


View Profile
« Reply #6 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.
« Last Edit: February 20, 2011, 12:24:05 AM by arablizzard2413 » Logged
Lin
ZOLE Creator
Administrator
Hero Member
*****
Offline Offline

Posts: 580



View Profile
« Reply #7 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.
Logged
arablizzard2413
Newcomer
*
Offline Offline

Posts: 6


View Profile
« Reply #8 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
« Last Edit: February 22, 2011, 06:27:27 AM by arablizzard2413 » Logged
Jigglysaint
Hacking Guru
Full Member
*****
Offline Offline

Posts: 150


View Profile
« Reply #9 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
Logged
arablizzard2413
Newcomer
*
Offline Offline

Posts: 6


View Profile
« Reply #10 on: February 25, 2011, 11:50:57 PM »

That's not what I'm trying to do Sad

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.
Logged
Lin
ZOLE Creator
Administrator
Hero Member
*****
Offline Offline

Posts: 580



View Profile
« Reply #11 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!