Sunday, November 18, 2007

Texture fix and icon viewer

Yesterday I was rather bored for a few hours (even if I've a lot of real life stuff to do...), so after checking some information from the DS cartridge header (for some unrelated work still to be done), I thought how hard it'd be to add an icon viewer to the "Game Info" dialog. Extracting it from the header wasn't that hard, as the format is quite simple: a 32x32 pixels icon, stored on a 8x8 tile basis, 4bits per pixel, which are used to lookup on a fixed 16 colour palette (per icon).

In fact, converting the icon was easy, but I had major problems due to some recent changes, as I forgot I needed to use GDI+ to draw stuff on dialogs, rather than using plain GDI (that's what all desmume uses on the windows port). When I moved the drawing code of the icon to GDI+, it worked perfectly. I deleted all the MAP/OAM/etc viewers that relied on GDI code, as I plan to rewrite the GUI in the near future anyway, so there's no point in fixing that code.

After that, I wanted to finally fix the last bits of Mario&Luigi to look perfect. A few weeks ago, I cared to make it run where it "freezed" in the past: in fact, it didn't freeze, just took ages to render a new frame, due to a rather important bug in the 3D core. The main problem after that, is that ALL textures looked wrong: for example, where Koopa should be, only textures of arrows were shown.

When approaching the problem, I had only a stupid idea of what could be: due to the way the display lists are handled, there was a slight chance that the texture bind before drawing the polygons was done in wrong order. Well, to make a long story short, I was wrong: I tried changing a few bits, even hacking some stuff, and it didn't fix anything. In fact, the fix was easier and more logical.

I've been coding on PC for quite a few years, and I'm quite used to some stuff working in a certain way. While emulating the 3D core of the DS, I've already fallen on that problem quite a few times: on the DS, setting attributes per polygon (without starting a "primitive block") isn't that rare, for example, transformations (scaling, for example :P). In this case, it was the texture changing while the primitive block was open. I guess that, if you want to draw all the stuff onscreen, and you only use one type of primitive (a quad, for example), then changing the texture within the primitive block isn't that rare.

Anyway, adding the ability to change textures within a primitive block fixed "Mario&Luigi: Partners in time" and "Final Fantasy XII: Revenant Wings", so now both seem to be 100% playable and glitch free (and run rather fast). The usual screenshots:




Have fun :)

17 comments:

Cameron said...

So does this mean we'll get an update soon?

Really looking forward to being able to play Mario and Luigi.

And possible Ouendan and Elite Beat Agents, if the issue with battle screens was the same as the issue as the music tapping screens in Ouendan and EBA.

shash said...

No, I didn't say an update is incoming.

Ouendan and EBA has been running perfectly on my build for a while.

Peti said...

nice work shash! go on like this ;)

Someone! said...

Nice work, Shash! :D

Mario said...

Congratulations Shash's.
I'm very happy to see this particular evolution (playin' the LeM and FF13 is "unpay").
It's very hard find good articles about the emulation like your blog.
I read your blog and learn much of computer science, much think about how is hard dev an emulator. thank you.

lukeskyd said...

What about saves in desmume?
I've used a save from ideas and desmume crashes and i can't overwrite it? And savestate are supported ml partener in ti?me

shash said...

lukeskyd: I only have save state loading partially working, never cared to make saving work properly, or to fix loading.

Mario said...

"I only have save state loading partially working, never cared to make saving work properly, or to fix loading."

I think that have some more importants stuffs (like what you fix at the last days) to worry.

Lionel said...

is there any plans to release this sash?

Either way keep up the great work. :)

shash said...

In current form, it won't be released. In the future, whenever the debugging functionality has been remade, might be.

Mario said...

And the new post (about comparison ...) ... I'm waiting

shash said...

mario: I'm busy with exams these days, I'll have free time from the 9th of february, not before.

Mario said...

@Shash
mario: I'm busy with exams these days, I'll have free time from the 9th of february, not before.

I'll wait. :D

mudlord said...

Nice job with the GDI+ related work.

Mario said...

@shash : I'm busy with exams these days, I'll have free time from the 9th of february, not before.

Wow the new post is comming... :D

shash said...

Mario: Wow the new post is comming... :D

Sorry, I'm still a bit busy with the new semester starting today. If I'm able to, I'll try to write the post today, but it takes quite a bit to write, so no promises.

It'll be done this week, that for sure :)

Mario said...

It'll be done this week, that for sure :) No promisses

@dreampeppers99 (ngemu) = mario says:
Sure, I'll wait. :D