News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[SM] [ASM] Repostitioning HUD icons and units

Started by snipereighteen, August 24, 2012, 11:46:54 AM

Previous topic - Next topic

snipereighteen

Hello there, does anybody know how to move the HUD icons to different positions? In this case, I wish to move the item icons (missile, super missile, power bomb, grapple beam and x-ray scope) and the units of the items. Like in SM Fear.
I'd be much appreciated.

Crashtour99

The HUD is completely hardcoded, so in order to change stuff with it you'll likely need LOTS of asm.  That said, if you know asm (and iirc) I put a disassembly of the entire HUD routines in the collab thread.  There are some other routines in $90 though that handle HUD selection and the like (mostly what you have selected, using button presses to update the appropriate RAM locations, telling the game what specific projectiles to spawn, etc.).

It's not an easy task, which is why it hasn't been done much. 
[spoiler]http://www.youtube.com/watch?v=2rywqnSt8Xc[/spoiler]

In case you can't find it in the collab thread:
http://db.tt/JZ1kJEQh  HUD disassembly.
http://db.tt/gJva7Z0c $90 partial (with some other random stuffs).

JAM

Well, as far as I know, moving the energy and ammo counters and energy tanks is not hard and required only hex editing at the right place. I could give you offsets, but I don't know what to do to move icons. I only partly know this stuff like I can edit positions when the icons will be draw when obtain missiles/super missiles/power bombs first, but when you selecting the icons, the wrong tiles are highlighted. If I got any progress with this, I'll post the stuff I know.

But Crashtour99 is right. To find what exactly to change you should know ASM.

Crashtour99

Well, when I say that it's hardcoded, it's REALLY hardcoded.  For example, here's a section of the HUD routine that draws the missile icon:
$80/99E1 AD A3 99    LDA $99A3  [$88:99A3]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99E4 8F 1C C6 7E STA $7EC61C[$7E:C61C]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99E8 AD A5 99    LDA $99A5  [$88:99A5]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99EB 8F 1E C6 7E STA $7EC61E[$7E:C61E]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99EF AD A7 99    LDA $99A7  [$88:99A7]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99F2 8F 20 C6 7E STA $7EC620[$7E:C620]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99F6 AD A9 99    LDA $99A9  [$88:99A9]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99F9 8F 5C C6 7E STA $7EC65C[$7E:C65C]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99FD AD AB 99    LDA $99AB  [$88:99AB]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/9A00 8F 5E C6 7E STA $7EC65E[$7E:C65E]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/9A04 AD AD 99    LDA $99AD  [$88:99AD]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/9A07 8F 60 C6 7E STA $7EC660[$7E:C660]   A:0010 X:0012 Y:00A8 P:envmxdizC


It's basically manually loading a tilemap, and then storing that to the appropriate RAM location.  The other icons are handled more efficiently, but essentially do the same (load tilemap values from an indexed set of tables, and use indexed store to RAM).  It's also essentially the same method that it uses to draw the numbers in the HUD, though those indexes are calculated from current ammo/energy/etc.  The programmers did their best to recycle code where possible to keep it from being overly bloated.
E-tanks are a bit different, since their locations in the HUD are in a table (which is easily editable via hex).
A problem of the wrong tiles being highlighted is probably because of a desync between the HUD routine and the "current HUD selection update routine" in $90.  The HUD routine is run first, so it won't update (highlight the icons) until the next frame, which works fine unless you start fiddling around with stuff.   :heheh:

The HUD relies heavily on what happened in the previous frame for its updates, and can glitch pretty badly if the data is wrong or corrupted (which is why you see all those mirrors for stuff in the RAMmap).  Something else to note is that items that appear in the HUD (like missiles) run certain subroutines within the HUD routine when you collect the item PLM.  So editing the HUD means you'll have to edit item PLMs as well.  The more you know, the trickier it gets.

snipereighteen

I can postition the energy tanks, I've actually posted a topic on energy tank postitions and energy units in Engine Works. I've constructed a energy tank style energy bar which covers all the weapon units (in this case, missile, super missile and power bomb). For each section (energy tank), you take 65 damage (hexadecimal).
Well I suppose I could reposition my energy tanks. The asm for the below is complicated.
Quote from: Crashtour99 on August 25, 2012, 02:21:53 AM
$80/99E1 AD A3 99    LDA $99A3  [$88:99A3]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99E4 8F 1C C6 7E STA $7EC61C[$7E:C61C]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99E8 AD A5 99    LDA $99A5  [$88:99A5]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99EB 8F 1E C6 7E STA $7EC61E[$7E:C61E]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99EF AD A7 99    LDA $99A7  [$88:99A7]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99F2 8F 20 C6 7E STA $7EC620[$7E:C620]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99F6 AD A9 99    LDA $99A9  [$88:99A9]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99F9 8F 5C C6 7E STA $7EC65C[$7E:C65C]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/99FD AD AB 99    LDA $99AB  [$88:99AB]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/9A00 8F 5E C6 7E STA $7EC65E[$7E:C65E]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/9A04 AD AD 99    LDA $99AD  [$88:99AD]   A:0010 X:0012 Y:00A8 P:envmxdizC
$80/9A07 8F 60 C6 7E STA $7EC660[$7E:C660]   A:0010 X:0012 Y:00A8 P:envmxdizC


JAM

Quote from: snipereighteen on August 25, 2012, 11:08:32 AM
The asm for the below is complicated.
Actually, there are basic ASM operators, load value to A and store value to A. Nothing too complicated. Something that I call complicated is this subroutine. Or glow subroutine, for example.

Quote from: snipereighteen on August 25, 2012, 11:08:32 AM
Well I suppose I could reposition my energy tanks.
You could reposition everything with less than 20 22 hex tweaks. The only "hard" part is Missile icon.

Here you go:
Highlighed icon positions:
1D6E:
14 00 -- Missile
1C 00 -- Super Missile
22 00 -- Power Bomb
28 00 -- Grapple
2E 00 -- X-Ray


Drawing icon positions (when collecting the items):
19E5:
1C C6 -- Missile (tile 1)

19EC:
1E C6 -- Missile (tile 2)

19F3:
20 C6 -- Missile (tile 3)

19FA:
5C C6 -- Missile (tile 4)

1A01:
5E C6 -- Missile (tile 5)

1A08:
60 C6 -- Missile (tile 6)

1A1A:
1C 00 -- Super Missile

1A2A:
22 00 -- Power Bomb

1A3A:
28 00 -- Grapple

1A4A:
2E 00 -- X-Ray


Numbers under icons:
1BF4:
8C -- Energy

1B0A:
94 -- Missiles

1C11:
94 -- Missiles

1B15:
9C -- Super Missiles

1C27:
9C -- Super Missiles

1B26
A2 -- Power Bombs

1C50:
A2 -- Power Bombs


As for energy tank positions, you already know when they are =)


How to move it
Substract 2 to move left
Add 2 to move right
Substract $40 to move up
Add $40 to move down

NOTE: to use upper row of HUD, a lot (about 20 tweaks) should be done

snipereighteen


Crashtour99

Quote from: JAM on August 28, 2012, 05:41:36 AM
NOTE: to use upper row of HUD, a lot (about 20 tweaks) should be done
This would actually take a bit of custom asm to do.  There is no RAM location for the top row of the HUD, and the only time it's ever defined is during the HUD loading and backing up to VRAM (at the very start of the loading routine).  If you want to use it, you'll have to do something like what Scyzer did, and move the entire location to free RAM (iirc she moved it to somewhere around $3200 which is only rarely used).  And that includes the VRAM backup, which is very important (I haven't found it yet, but I'm fairly sure that there's a routine somewhere that uses the tilemap backed up in VRAM to draw on layer_3 (the bottom 3 lines of the HUD is written to VRAM via DMA transfer using the table @ $D0 at the end of the HUD routine)).

snipereighteen

All shall be fine. I've only used the bottom 3 rows anyway.  :^_^:

JAM

Quote from: Crashtour99 on August 29, 2012, 05:53:01 AM
Quote from: JAM on August 28, 2012, 05:41:36 AM
NOTE: to use upper row of HUD, a lot (about 20 tweaks) should be done
This would actually take a bit of custom asm to do.  There is no RAM location for the top row of the HUD, and the only time it's ever defined is during the HUD loading and backing up to VRAM (at the very start of the loading routine). 

There are, actually.
RAM map says

7E:C608 - 7E:C6C7    Status bar tilemap

But 7E:C5C8 - 7E:C607 used (or can be used) by upper row. As least, I've used it, thanks to -DC-. So I did this



Quote from: Crashtour99 on August 29, 2012, 05:53:01 AM
If you want to use it, you'll have to do something like what Scyzer did, and move the entire location to free RAM (iirc she moved it to somewhere around $3200 which is only rarely used). 
Upper row was activated by numerous tweaks but nothing too complicated like relocating HUD tilemap at RAM. ASM was only used to make 4 digit counter for energy.

I had only 1 side effect when power bomb is exploading, but I've fixed that already.

snipereighteen

#10
Sweet, you'd be invincible!

Here's my idea:



The "FUNK POWER" extends upto 14 tiles in total.