intvnut Posted March 5, 2012 Share Posted March 5, 2012 Funny! By the way, Utopia uses the EXEC model, right? Do you happen to have the EXEC API mapped out, or are you just discerning the PRNG function from the disassembly? Various bits have been worked out over the years. Now here's one loop that boggles my mind: $5452: 0001 SDBD $5453: 02BC 00D4 0030 MVII #$30D4,R4 $5456: 0001 SDBD $5457: 02B9 0072 0045 MVII #$4572,R1 $545A: 0004 0114 029E JSR R5,$169E $545D: 0014 DECR R4 $545E: 00A4 TSTR R4 $545F: 0223 000A BPL $5456 $5461: 0281 0192 MVI $0192,R1 $5463: 0089 TSTR R1 It's calling the bounded-rand function $30D4 times. That's right, 12500 times. Why? WHY? And the value in R1 isn't even used for anything--the random number bound is in R0. And R0 seems to always be 0 when reaching this code, because it happens right after printing various strings: JSR R5, X_PRINT_R5 ; 543C 0004 0118 007B STRING "SCORES" ; 543F DECLE $0000 ; 5445 0000 B L_5452 ; 5446 0200 000A L_5448: JSR R5, X_PRINT_R5 ; 5448 0004 0118 007B STRING "TOTALS" ; 544B DECLE $0000 ; 5451 0000 It's calling the bounded RAND, but it never actually advances the random number generator, because the bounded-rand routine tests for 0 and short circuits. You can see it in the execution trace: 0000 0001 0162 0007 02E9 5452 02F5 5452 ----I-i- SDBD 131093862 0000 0001 0162 0007 02E9 5452 02F5 5453 ----ID-- MVII #$30D4,R4 131093866 0000 0001 0162 0007 30D4 5452 02F5 5456 ----I-i- SDBD 131093876 0000 0001 0162 0007 30D4 5452 02F5 5457 ----ID-- MVII #$4572,R1 131093880 0000 4572 0162 0007 30D4 5452 02F5 545A ----I-i- JSR R5,$169E 131093890 0000 4572 0162 0007 30D4 545D 02F5 169E ----I-i- PSHR R5 131093903 0000 4572 0162 0007 30D4 545D 02F6 169F ----I--- PSHR R1 131093912 0000 4572 0162 0007 30D4 545D 02F7 16A0 ----I--- PSHR R2 131093921 0000 4572 0162 0007 30D4 545D 02F8 16A1 ----I--- MOVR R0,R1 131093930 0000 0000 0162 0007 30D4 545D 02F8 16A2 ---ZI-i- BEQ $17D2 131093936 0000 0000 0162 0007 30D4 545D 02F8 17D2 ---ZI-i- PULR R2 131093945 0000 0000 0162 0007 30D4 545D 02F7 17D3 ---ZI-i- PULR R1 131093957 0000 4572 0162 0007 30D4 545D 02F6 17D4 ---ZI-i- PULR R7 131093969 0000 4572 0162 0007 30D4 545D 02F5 545D ---ZI-i- DECR R4 131093981 0000 4572 0162 0007 30D3 545D 02F5 545E ----I-i- TSTR R4 131093987 0000 4572 0162 0007 30D3 545D 02F5 545F ----I-i- BPL $5456 131093993 Crazy. I guess it's a delay loop that intends to cycle the random number generator, but fails to. Quote Link to comment Share on other sites More sharing options...
cparsley Posted March 5, 2012 Share Posted March 5, 2012 Remember it's not a bug, it's a feature! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.