Why the hoop jumping?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Why the hoop jumping?

Post by Oziphantom »

So I'm digging around Ogre Battle and it has this function that it uses a lot at $001199, and it takes a Long stored after the jsr. It then calls said long. Here is a trace of its execution

Code: Select all

$05/B19E 20 99 11    JSR $1199  [$05:1199]   A:FFD2 X:0650 Y:07C4 P:envMxdizc
$05/B1A1 66 8E 05
$05/119A 5C 8E 9F 00 JMP $009F8E[$00:9F8E]   A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F8E 8B          PHB                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F8F F4 9D 11    PEA $119D               A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F92 0B          PHD                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F93 4B          PHK                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F94 08          PHP                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F95 C2 20       REP #$20                A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F97 0B          PHD                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F98 48          PHA                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F99 3B          TSC                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9F9A 5B          TCD                     A:1FDD X:0650 Y:01C4 P:envmxdizc
$00/9F9B D4 0D	    PEI ($0D)  [$B1A0]      A:1FDD X:0650 Y:01C4 P:envmxdizc
$00/9F9D A5 0B       LDA $0B    [$00:1FE8]   A:1FDD X:0650 Y:01C4 P:envmxdizc
$00/9F9F 85 0D       STA $0D    [$00:1FEA]   A:0505 X:0650 Y:01C4 P:envmxdizc
$00/9FA1 68          PLA                     A:0505 X:0650 Y:01C4 P:envmxdizc
$00/9FA2 85 0C       STA $0C    [$00:1FE9]   A:B1A0 X:0650 Y:01C4 P:eNvmxdizc
$00/9FA4 E6 0C       INC $0C    [$00:1FE9]   A:B1A0 X:0650 Y:01C4 P:eNvmxdizc
$00/9FA6 A7 0C       LDA [$0C]  [$05:B1A1]   A:B1A0 X:0650 Y:01C4 P:eNvmxdizc
$00/9FA8 E6 0C       INC $0C    [$00:1FE9]   A:8E66 X:0650 Y:01C4 P:eNvmxdizc
$00/9FAA 3A          DEC A                   A:8E66 X:0650 Y:01C4 P:eNvmxdizc
$00/9FAB 85 06       STA $06    [$00:1FE3]   A:8E65 X:0650 Y:01C4 P:eNvmxdizc
$00/9FAD E6 0C       INC $0C    [$00:1FE9]   A:8E65 X:0650 Y:01C4 P:eNvmxdizc
$00/9FAF E2 20       SEP #$20                A:8E65 X:0650 Y:01C4 P:eNvmxdizc
$00/9FB1 A7 0C       LDA [$0C]  [$05:B1A3]   A:8E65 X:0650 Y:01C4 P:eNvMxdizc
$00/9FB3 85 08       STA $08    [$00:1FE5]   A:8E00 X:0650 Y:01C4 P:envMxdiZc
$00/9FB5 48          PHA                     A:8E00 X:0650 Y:01C4 P:envMxdiZc
$00/9FB6 AB          PLB                     A:8E00 X:0650 Y:01C4 P:envMxdiZc
$00/9FB7 C2 20       REP #$20                A:8E00 X:0650 Y:01C4 P:envMxdiZc
$00/9FB9 68          PLA                     A:8E00 X:0650 Y:01C4 P:envmxdiZc
$00/9FBA 2B          PLD                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/9FBB 28          PLP                     A:03E2 X:0650 Y:01C4 P:envmxdiZc
$00/9FBC 6B          RTL                     A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/8E66 29 FF 03    AND #$03FF              A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/8E69 0A          ASL A                   A:03E2 X:0650 Y:01C4 P:envmxdizc
$00/8E6A A8          TAY                     A:07C4 X:0650 Y:01C4 P:envmxdizc
$00/8E6B B9 6F 8E    LDA $8E6F,y[$00:9633]   A:07C4 X:0650 Y:07C4 P:envmxdizc
$00/8E6E 60          RTS                     A:FFD2 X:0650 Y:07C4 P:eNvmxdizc
$00/119E AB          PLB                     A:FFD2 X:0650 Y:07C4 P:eNvmxdizc
$00/119F 6B          RTL                     A:FFD2 X:0650 Y:07C4 P:envmxdizc
$05/B1A4 85 8A       STA $8A    [$00:008A]   A:FFD2 X:0650 Y:07C4 P:envmxdizc
$05/B1A6 E2 20       SEP #$20                A:FFD2 X:0650 Y:07C4 P:envmxdizc
$05/B1A8 60          RTS                     A:FFD2 X:0650 Y:07C4 P:envMxdizc
This seems a lot of work and fancing around to do JSL $008e66, looks like it probably clears any DP movement/data page when doing the jump, so you call the function without changing the DP/Data bank. But also seems like overkill for such functionality. Am I missing something?
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: Why the hoop jumping?

Post by psycopathicteen »

I should post this code on wiki.superfamicom.org as an example of non-optimized code.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Why the hoop jumping?

Post by Oziphantom »

If you do be sure to call it not optimized code ;) or verbose code.

If you really want to see code that is badly optimized, have a look at tetris attack... oh boy, bad code for days.... even the tables are bad... hell they couldn't be bothered to make a random number generator so just threw half a bank at random number table ;)
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Why the hoop jumping?

Post by calima »

Maybe they needed lots of random numbers, fast :P
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Why the hoop jumping?

Post by 93143 »

In a puzzle game?

I was going to use a random number table for my bullet hell port, since it's going to be squeezed for performance and I figured it'd be faster. But it turns out that accessing data outside the current bank is a pain in the ass on Super FX, and I managed to hunt up a reasonably high-quality 16-bit version of xorshift that's nearly as fast as the table lookup would have been, while having twice the period...
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Why the hoop jumping?

Post by tepples »

Random numbers in Puzzle League also have to avoid self-clearing patterns with three aligned like panels. Do the random numbers in that game look pre-processed to meet this constraint?
User avatar
Sumez
Posts: 919
Joined: Thu Sep 15, 2016 6:29 am
Location: Denmark (PAL)

Re: Why the hoop jumping?

Post by Sumez »

93143 wrote: I was going to use a random number table for my bullet hell port
What game are you porting?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Why the hoop jumping?

Post by tepples »

My guess is that naming the original game would violate some NDA with its publisher and cause 93143 to lose the license to port it. And even if the publisher has a policy to tolerate non-commercial fan works, like Team Shanghai Alice's Touhou Project games, announcing the title might put an undue burden on 93143 of fielding incessant "are we there yet" requests from its fan base.
User avatar
Sumez
Posts: 919
Joined: Thu Sep 15, 2016 6:29 am
Location: Denmark (PAL)

Re: Why the hoop jumping?

Post by Sumez »

Oh, I was just curious...
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Why the hoop jumping?

Post by Oziphantom »

It is a puzzle game so avoiding a match 3 is probably idea, but from memory I think it has set starting patterns or at least a few possible starting patterns.

Code: Select all

a048290                          .word $C52C,$2405,$F5B7,$AD2A,$224F,$70DE,$C297,$F421
                                 .word $45C2,$96B0,$E4B1,$FD3B,$AB54,$C1E5,$CA3F,$57FD
                                 .word $188B,$40FB,$E8F0,$72BE,$1120,$0605,$3866,$242B
                                 .word $617F,$2C27,$B6B9,$26C4,$964A,$6C1D,$E1F3,$965B
                                 .word $83D5,$A6B3,$3F93,$759A,$BDAA,$5E4B,$D70D,$287C
                                 .word $2004,$395C,$B647,$FAD0,$4A56,$85EF,$6D1B,$96BC
                                 .word $1DC3,$B023,$90D9,$8E36,$3FA5,$CEA8,$36C4,$D98A
                                 .word $9B09,$1645,$7E93,$4FD9,$E02F,$6355,$06F0,$2D96
                                 .word $FF0C,$B543,$73FA,$9609,$AFCA,$AF14,$EEC4,$0ECE
                                 .word $EA44,$19DC,$A3D5,$FE55,$6F8D,$5E45,$43A8,$3562
                                 .word $4068,$0D0D,$812C,$638C,$24CF,$5986,$9744,$9EC0
                                 .word $246F,$9B17,$C046,$E0BD,$1028,$CDB8,$BD7D,$8598
                                 .word $F990,$0F78,$52A9,$CF37,$B66E,$25F8,$C87C,$63D8
                                 .word $6241,$F5EF,$6B1D,$CB89,$DAB9,$0AA6,$0BA7,$F4AF
                                 .word $423B,$157B,$7DA8,$B082,$7F5F,$6960,$19A4,$348D
                                 .word $BB73,$7D5B,$3C92,$9931,$E6F7,$6C06,$C65C,$5C21
                                 .word $3221,$760F,$9B62,$E0E5,$9459,$7FB7,$23F5,$E859
                                 .word $48BB,$8C55,$CCDE,$202C,$4C9A,$4BD2,$85D6,$9464
                                 .word $E1FA,$8A2C,$430E,$35D7,$1014,$BDF5,$7EA6,$59B2
                                 .word $21D4,$7BD3,$B338,$3AF4,$235B,$FF00,$E14D,$74F1
                                 .word $697F,$AACA,$0EE4,$89D1,$0948,$7D12,$C1F0,$5E11
                                 .word $5D73,$A1CE,$88D8,$BEFF,$84F1,$E189,$72F7,$D440
                                 .word $DF67,$2CE0,$931C,$B34B,$97AE,$1605,$850A,$CFEE
                                 .word $1452,$553E,$E3F7,$83C6,$8614,$4765,$CF0E,$8CC9
                                 .word $5E6A,$6967,$6BEF,$8ABD,$D3FD,$DFC7,$612C,$84C0
                                 .word $5F28,$F11B,$5ECC,$63C1,$417D,$8A8C,$90C9,$7403
                                 .word $FC41,$B958,$2E94,$E89F,$D4ED,$3251,$EE8E,$5601
                                 .word $56AD,$CC5C,$8E8F,$3567,$CFE3,$02F5,$4F61,$6467
                                 .word $D1A3,$75A9,$7343,$A469,$B436,$6698,$C469,$1B27
                                 .word $109A,$3EFB,$0E78,$D132,$46FE,$089A,$A10D,$346E
                                 .word $F648,$F352,$D235,$9692,$8891,$D397,$7AF4,$ACAB
                                 .word $A6A6,$9FEE,$74C0,$0F98,$BE87,$F271,$2105,$BD8D
                                 .word $83E9,$8C4D,$E5A1,$9693,$6AB6,$D145,$A867,$E105
                                 .word $2F89,$472E,$589E,$C712,$5035,$1A73,$6581,$D53F
                                 .word $8F3D,$9990,$42BF,$7CE4,$725B,$B899,$E8FB,$93AC
                                 .word $C4FC,$8EB3,$534B,$D118,$14C0,$D697,$05BA,$55FB
                                 .word $33FC,$7115,$81C8,$21FD,$B83A,$E08C,$CFE7,$981A
                                 .word $7DB6,$CC74,$FDFE,$0522,$21E0,$80D7,$9AE7,$1638
                                 .word $86DF,$6BD2,$3BF3...
if that is massaged or not, you guess is a lot better than mine ;)
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Why the hoop jumping?

Post by 93143 »

tepples wrote:My guess is that naming the original game would violate some NDA with its publisher and cause 93143 to lose the license to port it. And even if the publisher has a policy to tolerate non-commercial fan works, like Team Shanghai Alice's Touhou Project games, announcing the title might put an undue burden on 93143 of fielding incessant "are we there yet" requests from its fan base.
Well, mainly it's closer to the latter. I've had bad experiences with overpromising and underdelivering in the past - not so much that people bug me, but that I disappoint them. I still plan to finish all my projects, but when I start something it's more likely to end up like Duke Nukem Forever than Haunted: Halloween '85.

I mentioned it on this forum a few years ago because I needed help getting started and figuring things out - it's my first SNES project. But maybe I should stop gratuitously referencing it when it doesn't add much to the conversation...
Sumez wrote:Oh, I was just curious...
Sorry. This happens every time, and I never learn...
Oziphantom wrote:massaged
That could be a good point.

On the other hand, it shouldn't be impossible to "massage" a real PRNG, say by rejecting results that don't meet a certain standard of playability, or by tying probability ranges to history when using the result - doesn't Tetris do this?

I suppose if you've got half a bank free anyway, a table might be the simplest approach...
User avatar
Sumez
Posts: 919
Joined: Thu Sep 15, 2016 6:29 am
Location: Denmark (PAL)

Re: Why the hoop jumping?

Post by Sumez »

Yes, NES Tetris does that. Strangely every Nintendo published Tetris game since that doesn't, and they really suffer from it.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Why the hoop jumping?

Post by lidnariq »

Oziphantom wrote:if that is massaged
600 bytes isn't really enough to do any statistical analysis, but a histogram of those looks less flat than I'd expect.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Why the hoop jumping?

Post by unregistered »

Sumez wrote:Yes, NES Tetris does that. Strangely every Nintendo published Tetris game since that doesn't, and they really suffer from it.
Does "every" include Famicom's "Tetris 2 (+BomBliss)"? I love that game! :)
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Why the hoop jumping?

Post by tepples »

Tetris 2 + Bombliss is BPS published, though its Game Boy port Tetris Blast was published by Nintendo in North America.

The RNG in Tetris since 2001 is heavily massaged. The "bag" RNG in most games deals all of a set of 7 distinct Tetriminos without replacement, and only once the set is empty is it refilled. The "history" RNG in Arika's Tetris The Grand Master is heavily biased against the four most recently dealt Tetriminos. (For more information, see Hard Drop Wiki.) Both of these paradigms improve the player's quality of life somewhat, with fewer SZ gluts and fewer I droughts.

I've used something conceptually similar to history in Thwaite for target building choice, RHDE for piece choice, and my NES port of robotfindskitten for NKI choice. The RNG in these games considers only those choices, roughly one-third to two-thirds of all available choices, that were least recently dealt. This has the advantage of a more even distribution while also letting me use raw numbers from the RNG with a power of 2 range, eliminating the need to multiply.

Puzzle League, on the other hand, needs a bit more massaging than a simple bag or LRU scheme. Not only must pieces be non-matching horizontally, but they also have to be non-matching vertically against the previously generated row. It'd be tricky to make a constant-time algorithm for that.
Post Reply