News: 11 March 2016 - Forum Rules

Author Topic: Oh lord. How NOT to do string pointers (6502).  (Read 4009 times)

Gideon Zhi

  • Discord Staff
  • Hero Member
  • *****
  • Posts: 3536
    • View Profile
    • Aeon Genesis
Oh lord. How NOT to do string pointers (6502).
« on: May 25, 2013, 11:34:30 pm »
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.

Code: [Select]
$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

  • Hero Member
  • *****
  • Posts: 4572
  • じー
    • View Profile
    • The BRPXQZME Network
Re: Oh lord. How NOT to do string pointers (6502).
« Reply #1 on: May 26, 2013, 12:01:52 am »
“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

  • Hero Member
  • *****
  • Posts: 2763
    • View Profile
Re: Oh lord. How NOT to do string pointers (6502).
« Reply #2 on: May 26, 2013, 05:34:30 am »
Mmh, pretty funny. They sure weren't too familiar with the 6502, and/or they used tools to generate such shitty code.

snarfblam

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 595
  • CANT HACK METROID
    • View Profile
    • snarfblam
Re: Oh lord. How NOT to do string pointers (6502).
« Reply #3 on: May 26, 2013, 09:52:34 am »
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

  • Hero Member
  • *****
  • Posts: 2763
    • View Profile
Re: Oh lord. How NOT to do string pointers (6502).
« Reply #4 on: May 26, 2013, 12:25:12 pm »
Quote
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.
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

  • Hero Member
  • *****
  • Posts: 4572
  • じー
    • View Profile
    • The BRPXQZME Network
Re: Oh lord. How NOT to do string pointers (6502).
« Reply #5 on: May 26, 2013, 12:40:25 pm »
Maybe they forgot how to fill it with ones and were too embarrassed to ask :-X
we are in a horrible and deadly danger