News:

11 March 2016 - Forum Rules

Main Menu

Oh lord. How NOT to do string pointers (6502).

Started by Gideon Zhi, May 25, 2013, 11:34:30 PM

Previous topic - Next topic

Gideon Zhi

Helping out an anon in the IRC channel dig through Legend of the River King for the NES. He was looking for the text; I went a step further and found the pointers. This is pretty funny.


$AD18:A2 A6     LDX #$A6
$AD1A:A0 34     LDY #$34
$AD1C:4C DB B0  JMP $B0DB
$AD1F:A2 B3     LDX #$B3
$AD21:A0 40     LDY #$40
$AD23:4C DB B0  JMP $B0DB
$AD26:A2 B3     LDX #$B3
$AD28:A0 55     LDY #$55
$AD2A:4C DB B0  JMP $B0DB
$AD2D:A2 B3     LDX #$B3
$AD2F:A0 6B     LDY #$6B
$AD31:4C DB B0  JMP $B0DB
$AD34:A2 B3     LDX #$B3
$AD36:A0 7B     LDY #$7B
$AD38:4C DB B0  JMP $B0DB
v-- this right here is the pointer for the text belonging to the balding NPC outside the player's home (B38A)
$AD3B:A2 B3     LDX #$B3
$AD3D:A0 8A     LDY #$8A
$AD3F:4C DB B0  JMP $B0DB
$AD42:A2 B3     LDX #$B3
$AD44:A0 9D     LDY #$9D
$AD46:4C DB B0  JMP $B0DB
$AD49:A2 B3     LDX #$B3
$AD4B:A0 AD     LDY #$AD
$AD4D:4C DB B0  JMP $B0DB
$AD50:A2 B3     LDX #$B3
$AD52:A0 C0     LDY #$C0
$AD54:4C DB B0  JMP $B0DB
$AD57:A2 B3     LDX #$B3
$AD59:A0 D5     LDY #$D5
$AD5B:4C DB B0  JMP $B0DB
$AD5E:A2 B3     LDX #$B3
$AD60:A0 EB     LDY #$EB
$AD62:4C DB B0  JMP $B0DB


It goes on like this for several hundred bytes in either direction.

BRPXQZME

"All problems in computer science can be solved by another level of indirection."—Wheeler (allegedly)
"... except for the problem of too many layers of indirection."—(also) Wheeler (also allegedly)
we are in a horrible and deadly danger

Bregalad

Mmh, pretty funny. They sure weren't too familiar with the 6502, and/or they used tools to generate such shitty code.

snarfblam

I've seen some similar things before, but never on such a magnificent scale. I can only imagine it's the product of a macro or tool, though, and going back and making code prettier doesn't pay the bills, so that's what we get.

Bregalad

QuoteI've seen some similar things before, but never on such a magnificent scale. I can only imagine it's the product of a macro or tool, though, and going back and making code prettier doesn't pay the bills, so that's what we get.
Making the game fit into a ROM which is one power of two smaller WOULD have saved costs. Now if you are anywhere remote form 2 power of two values for your ROM, wasting or preserving it will have not much effect.

BRPXQZME

Maybe they forgot how to fill it with ones and were too embarrassed to ask :-X
we are in a horrible and deadly danger