News: 11 March 2016 - Forum Rules

Author Topic: Help with Contra / Super C gfx...  (Read 4420 times)

omega_rugal

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Help with Contra / Super C gfx...
« on: April 15, 2015, 10:36:46 am »
Sorry to bother you guys but i have small request to all those people who make GFX hacks... hacking gfx is not my specialty...

some time ago i made a small hack for Contra and Super (NES) that disabled lives entirely, i have been playing these games for sooo long and since nowdays i just play them for fun and not for the challenge (i can beat them blindfolded anyway) i got the idea of removing the "badge" gfx that represent the lives, it`s no longer needed and i prefer to have a clear screen. so i fired up yy-chr and loaded the ROMS and... i can`t see a damn thing... i must be going blind or something, tiles are so small that i can`t find the so called badges in that garbled mess...

so here i am, if anyone can point me in the right direction i would really apreciate it...
Done your packing?, your life journey is over...

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #1 on: April 15, 2015, 12:04:30 pm »
I haven't looked at Super C, but a quick glance at Contra tells me the graphics are compressed.  You're not going to be able to edit them in a tile editor directly, you'll have to decompress them first.

Figuring out compression algorithms pretty much requires asm knowledge, and is probably more work than it's worth for such a minor graphical hack.  Instead of removing the graphics, it might actually be easier to simply modify the game code so that it doesn't draw the badges.

And I was bored... so...


In Contra:  change offset 0x06FF9 from '85' to '60'

This will disable the routine that draws the badges for both players, effectively hiding them in game.
Note this does not remove the "REST" display between levels.

omega_rugal

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #2 on: April 15, 2015, 12:27:04 pm »
are they compressed? all of them? because there are a few thing i can distinguish like some BGs, text and the characters sprites

anyway I though about doing it through code but since it was just a minor tweak i went for the gfx hack instead...

Quote
change offset 0x06FF9 from '85' to '60'

so there`s where the "draw lives" code starts? that spare space may be useful...

Quote
Note this does not remove the "REST" display between levels.

Totally fine, since i was thinking to change the lives behavior to increase and display how many lives you have USED instead of how many you have LEFT, the text change is already done, it says "USED" but i haven`t done anything to the code yet... also i was thinking about changing the score system to a time attack, so it increases during ingame and tracks how faster you can beat the game... too bad i don`t have much spare time so progress is slow...

thanks i`ll try it out once i get home...

oh that`s for Contra right? so i still have to dig in Super C...
Done your packing?, your life journey is over...

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #3 on: April 15, 2015, 12:52:43 pm »
are they compressed? all of them? because there are a few thing i can distinguish like some BGs, text and the characters sprites

Yeah I can sort of make out some graphics too, but that's pretty typical.  Just because they're compressed doesn't mean they'd all be unrecognizable.

LZ compression, for example, has to have the uncompressed pattern stored somewhere before it can be repeated and reused.  Though that doesn't necessarily mean contra uses LZ compression -- it's just an example.

Quote
so there`s where the "draw lives" code starts? that spare space may be useful...

Sort of.  The routine actually starts earlier than that, but I didn't want to take the time to figure out where the exact entry point was or where it ended.  That particular byte is the start of the loop that draws each badge.

Quote
thanks i`ll try it out once i get home...

oh that`s for Contra right? so i still have to dig in Super C...

No probalo.

And yes that's for Contra.  I didn't look into Super C at all.

omega_rugal

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #4 on: April 15, 2015, 03:12:24 pm »
It works, thank you again.

that frees 43 bytes of data that is executed in the main game loop... what do i put here?

Quote
I didn't look into Super C at all

don`t worry i found it: offset C02F same thing, change 85 to 60 (ret)

the code is VERY similar except for a few addresses so i found it with just a few clicks...
Done your packing?, your life journey is over...

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #5 on: April 15, 2015, 03:20:00 pm »
Quote
that frees 43 bytes of data that is executed in the main game loop... what do i put here?

Are you asking me?  =P

Put whatever you want there.  Free space is free space.

omega_rugal

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #6 on: April 15, 2015, 04:24:00 pm »
Actually i was thinking about what feature i can add here...
Done your packing?, your life journey is over...

Trax

  • RHDN Patreon Supporter!
  • Hero Member
  • *****
  • Posts: 604
    • View Profile
    • Trax ROM Hacking
Re: Help with Contra / Super C gfx...
« Reply #7 on: April 16, 2015, 12:04:54 am »
Here's my analysis of the graphics loading code for Contra:

1C8E3: Pointer table for Graphics Groups Codes (D * 2 = 1A bytes)

FDC8 -> 1C8FD
05C9 -> 1C905
16C9 -> 1C916
0DC9 -> 1C90D
1EC9 -> 1C91E
26C9 -> 1C926
2EC9 -> 1C92E
36C9 -> 1C936
3BC9 -> 1C93B
40C9 -> 1C940
46C9 -> 1C946
48C9 -> 1C948
4BC9 -> 1C94B

----

Tables for Graphics Groups Codes (53 bytes)

1C8FD: 03 13 19 1A 14 16 05 FF      Level 1
1C905: 03 04 06 0A 0F 10 11 FF      Level 2
1C90D: 03 04 06 0A 0F 10 11 12 FF   Level 4
1C916: 03 13 19 1A 14 16 07 FF      Level 3
1C91E: 03 13 19 1A 15 16 0B FF      Level 5
1C926: 03 13 19 1A 15 16 0C FF      Level 6
1C92E: 03 13 19 1A 15 16 0D FF      Level 7
1C936: 03 13 19 0E FF         Level 8
1C93B: 03 04 13 08 FF         Level 2 Boss Room
1C940: 03 04 13 08 09 FF      Level 4 Boss Room
1C946: 01 FF            Intro Graphics
1C948: 01 02 FF            Intro Graphics and Tile Mappings
1C94B: 01 03 17 18 FF         Ending Scene

----

1C950: Tables for Graphics Groups Data pointers (1B * 3 = 51 bytes)

XXXX ..      Pointer
.... XX      Bank Number (except 00 -> 07)

00: 36CB 00   1CB36 (used to reset PPU name tables to zeroes)

01: 2DAA 04   12A2D
02: 9790 02    9097
03: 0180 04   10001
04: AE85 04   105AE
05: 0180 05   14001
06: FC99 04   119FC
07: 618A 05   14A61
08: 6C88 04   1086C
09: CD99 04   119CD
0A: 05A0 04   12005
0B: E093 05   153E0
0C: 0180 06   18001
0D: DC8C 06   18CDC
0E: D69B 06   19BD6
0F: 46A3 04   12346
10: 03A0 84   12003
11: E7A3 04   123E7
12: 40A9 04   12940
13: A187 04   107A1
14: 14A8 05   16814
15: 7AB0 06   1B07A
16: 5CB1 06   1B15C
17: DFAD 05   16DDF
18: 0DB3 05   1730D
19: 1BA3 05   1631B
1A: 00A5 05   16500

00: CPU 1CB36 - 1D3DF
01: CPU 12A2D - 138B8
02: CPU  9097 - 9251
03: CPU 10001 - 105AD
04: CPU 105AE - 107A0
05: CPU 14001 - 14A60
06: CPU 119FC - 12002
07: CPU 14A61 - 153DF
08: CPU 1086C - 119CC
09: CPU 119CD - 119FB
0A: CPU 12005 - 12345
0B: CPU 153E0 - 1631A
0C: CPU 18001 - 18CDB
0D: CPU 18CDC - 19BD5
0E: CPU 19BD6 - 1B079
0F: CPU 12346 - 123E6
10: CPU 12003 - 12345
11: CPU 123E7 - 1293F
12: CPU 12940 - 12A2C
13: CPU 107A1 - 1086B
14: CPU 16814 - 16DDE
15: CPU 1B07A - 1B15B
16: CPU 1B15C - 1B261
17: CPU 16DDF - 1730C
18: CPU 1730D - 1735D
19: CPU 1631B - 164FF
1A: CPU 16500 - 16813


So you fetch the pointer from the first table (1C8E3) according to the level. This pointer points to a second table (1C8FD) with a series of codes, that are indexes into the third table (1C950), FF means end of sequence. The third table contains the address in ROM for the beginning of the data and the bank the pointer points to...

For each of these chunks of graphics, the first 2 bytes determine the initial PPU position. Then take the next byte, if bit 7 is set (>= 0x80), it's a litteral sequence, so the byte's bits 0-6 sets the next n bytes to feed to the PPU. If bit 7 is clear, then it's a RLE, so the byte's bits 0-6 sets the next byte to be sent to the PPU n times. Repeat until you hit FF. If you hit 7F, then take the next 2 bytes and set the PPU writing head with this address. Another detail: if the bank number in the third table (1C950) has bit 7 set (only chunk index 10 in the above list), it means all the bytes sent to the PPU for this chunk must be horizontally mirrored, i.e. bit 0 swapped with bit 7, bit 1 with bit 6, and so on...

Got all that?

Bregalad

  • Hero Member
  • *****
  • Posts: 2763
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #8 on: April 16, 2015, 05:01:40 am »
some time ago i made a small hack for Contra and Super (NES) that disabled lives entirely, i have been playing these games for sooo long and since nowdays i just play them for fun and not for the challenge (i can beat them blindfolded anyway) i got the idea of removing the "badge" gfx that represent the lives, it`s no longer needed and i prefer to have a clear screen. so i fired up yy-chr and loaded the ROMS and... i can`t see a damn thing... i must be going blind or something, tiles are so small that i can`t find the so called badges in that garbled mess...
Graphics are compressed in Contra (U), but are not compressed in Contra (J) nor any version of Super C, because those use CHR-ROM, so the graphics can't be compressed.

Replacing the medals by blank tiles would be a very lame way to remove them, because they'd still interfere with sprite flickering. A proper way would be to find the code that displays them, and replace it by NOPs for example, so that the medals are actually not displayed.

In order to do this, figure out which tile# is the medals, and watch writes to shadow OAM ($200-$2ff) until there is a write that correspond to the medal's sprite. Then trace up calls, and see what "jsr" call is responsible for this, replace it with 3 NOP instead (note : you might need some trial and error here, replacing a call too low in the call tree would have a radical effect such as disable many different sprites).

omega_rugal

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #9 on: April 16, 2015, 02:55:55 pm »
Ok, we figured out, in a slighty diferent way but we got it.

So Contra (j) is not compressed? AFAIK it has more content than the US version for some reason... isn`t there a translation hack available? if so maybe i should have tinker with that version instead...
Done your packing?, your life journey is over...

mrrichard999

  • Hero Member
  • *****
  • Posts: 686
  • So Goooood! :D
    • View Profile
    • GameFAQS Profile

omega_rugal

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: Help with Contra / Super C gfx...
« Reply #11 on: May 05, 2015, 11:29:22 pm »
That free space will be perfect to implement the weapon change...

ok is done

since it was a quick code, i ran out of space and only 3 weapons can be selected

Hold Select, then press Left for Laser, Down for Spread and Right for Fire...

the machine gun is so lame that i don`t know if must include it or not... anyway, if theres space left after the code has been optimized, i`ll add it...

WTF? pressing select with no direction actually SWITCHES TO THE MACHINE GUN! wow, i didn`t expect that...

ok i got it, i left the code to switch to the Machine gun, but since no direction is pressed, no branches are taken and the "switch to M gun" routine is executed by default...
« Last Edit: May 06, 2015, 03:15:03 pm by omega_rugal »
Done your packing?, your life journey is over...