satyrsfaction Posted April 12, 2020 Share Posted April 12, 2020 I'm working on this game, a sequel to Text Adventure --- it works fine on Stella, but I'm told it has line count issues on real hardware. Any pointers on how to clean up the code? text_adventure2.bas text_adventure2.bas.bin Quote Link to comment Share on other sites More sharing options...
+stephena Posted April 12, 2020 Share Posted April 12, 2020 Not that the following info will help you fix the issues you have, but there is a setting in Stella that will allow you to see what happens on real hardware. Press Alt+L to see scanline counts. It's then obvious that the counts are varying each time you move and/or collide with a wall. Go to Options -> Developer -> Video, and then turn on Jitter/roll effect. This will simulate the roll you would see on a real TV. As I said, it won't fix your issues, but at least you will see them right away, before you have to test on real hardware. Quote Link to comment Share on other sites More sharing options...
RaymanC Posted May 13, 2020 Share Posted May 13, 2020 On 4/12/2020 at 3:47 PM, satyrsfaction said: I'm working on this game, a sequel to Text Adventure --- it works fine on Stella, but I'm told it has line count issues on real hardware. Any pointers on how to clean up the code? text_adventure2.bas 66.11 kB · 12 downloads text_adventure2.bas.bin 32 kB · 14 downloads Hello, To fix line count issues you need to have more flow control of your program using the goto command. For example, the following lines in your program... z = rand if z < 50 then y = 1 if z > 49 && z < 100 then y = 2 if z > 109 && z < 150 then y = 3 if z > 149 && z < 200 then y = 4 if z > 199 && z < 250 then y = 5 if z > 249 then y = 6 should be like this.... z = rand if z > 249 then y = 6 : goto _z_y_defined if z > 199 then y = 5 : goto _z_y_defined if z > 149 then y = 4 : goto _z_y_defined if z > 109 then y = 3 : goto _z_y_defined if z > 49 then y = 2 : goto _z_y_defined y = 1 _z_y_defined ......program continues Let's say that z turns out to be 200 then instead of executing all 7 lines, it will execute only 3 lines and then goto to the next label. Also try not to use AND (&&) and your program will be faster. There are also a few others changes that could be done so let me know if you are still having problems. Carlos 2 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 14, 2020 Share Posted May 14, 2020 there's a gap 100..109 where y doesn't get set 1 Quote Link to comment Share on other sites More sharing options...
RaymanC Posted May 14, 2020 Share Posted May 14, 2020 4 hours ago, bogax said: there's a gap 100..109 where y doesn't get set Yes, I think that is an error in his program. I believe that 109 should be replaced with 99 Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted May 15, 2020 Share Posted May 15, 2020 Haven't looked at the code, and don't know if rand&5 works, but maybe you can use it elsewhere instead of alot of if...thens temp5 = rand&5 ;get random value between 0 - 5, might not work y = yTable[temp5] ;use it as index data yTable 1, 2, 3, 4, 5, 6 end Quote Link to comment Share on other sites More sharing options...
bogax Posted May 15, 2020 Share Posted May 15, 2020 1 hour ago, Lillapojkenpåön said: Haven't looked at the code, and don't know if rand&5 works, but maybe you can use it elsewhere instead of alot of if...thens temp5 = rand&5 ;get random value between 0 - 5, might not work y = yTable[temp5] ;use it as index data yTable 1, 2, 3, 4, 5, 6 end it wont work but I like your thinking but I also don't think look up tables will be faster than only a few if statements and is 1 & 1 = 1 0 & 1 = 0 1 & 0 = 0 0 & 0 = 0 5 is %00000101 bit wise & is like so (corresponding bits are ANDed) %00000101 & %11111111 = %00000101 where there's a 0 in either, the result will have a 0 so rand & 5 can produce only 4 possibilities %00000000, %00000001, %00000100, %00000101 I think this will give you 0..5 temp1 = rand/2 : y = (temp1/2 + temp1)/32 look up tables would have a more consistent timing and probably use less code in the given example there may not be enough if statements to make it worth while but it looks like there may be several other places in the code where it would here's some table code (the data statements would have ot be moved out of the way) a table look up uses the x register as an index, since x doesn't change here it doesn't need to keep being loaded so the macro loads the variable without reloading the x register with the value it already contains set optimization noinlinedata dim ptr = temp1 def mov_in = callmacro mvim macro mvim asm lda {2},x sta {1} end end ptr = rand/2 if ptr > 106 then skip_rand_5 ptr = (ptr/2 + ptr)/32 g = g_dat[ptr] mov_in k k_dat mov_in t t_dat mov_in w w_dat mov_in x x_dat mov_in var3 v3_dat mov_in var5 v5_dat mov_in var6 v6_dat mov_in var7 v7_dat mov_in var8 v8_dat data g_dat 21, 21, 21, 12, 21 end data k_dat 14, 7, 14, 7, 16 end data t_dat 7, 5, 5, 17, 4 end data w_dat 6, 14, 7, 14, 11 end data x_dat 17, 23, 8, 21, 7 end data v3_dat 1, 14, 15, 2, 23 end data v5_dat 6, 6, 7, 16, 9 end data v6_dat 16, 7, 16, 9, 7 end data v7_dat 12, 12, 6, 15, 14 end data v8_dat 4, 5, 23, 4, 5 end on gosub and on goto also use table lookups 1 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 15, 2020 Share Posted May 15, 2020 (edited) speed wise this is (almost) the best I came up with (the bank switch code is in one spot which I then goto it adds 3 cycles but saves a bunch of code) this is somewhat faster than the tables maybe 5..6 if statments, half a scan line or so (on average, around 40 cycles) I tried to make the intervals even y doesn't get set. looks like it gets set to 0 in bank three anyway spreading the if statements out keeps the branches short enough that the target labels are in range so you don't have to use goto's z = rand if z > 127 then gt_127 if z > 85 then set_3 if z > 42 then set_2 set_1 g = 21 : x = 17 : w = 6 : k = 14 : rem flame, shield, lyre, key room var5 = 6 : rem gorgon room var3 = 1 : var1 = 5 : rem troll room var8 = 4 : var0 = 15 : rem snake room var6 = 16 : var7 = 12 : t = 7 : rem hero, seer, theif room goto go_bnk3 set_2 g = 21 : x = 23 : w = 14 : k = 7 : rem flame, shield, lyre, key room var5 = 6 : rem gorgon room var3 = 14 : var1 = 4 : rem troll room var8 = 5 : var0 = 7 : rem snake room var6 = 7 : var7 = 12 : t = 5 : rem hero, seer, theif room goto go_bnk3 gt_127 if z < 171 then set_4 if z < 213 then set_5 go_bnk3 goto _start bank3 set_3 g = 21 : x = 8 : w = 7 : k = 14 : rem flame, shield, lyre, key room var5 = 7 : rem gorgon room var3 = 15 : var1 = 6 : rem troll room var8 = 23 : var0 = 4 : rem snake room var6 = 16 : var7 = 6 : t = 5 : rem hero, seer, theif room goto go_bnk3 set_4 g = 12 : x = 21 : w = 14 : k = 7 : rem flame, shield, lyre, key room var5 = 16 : rem gorgon room var3 = 2 : var1 = 5 : rem troll room var8 = 4 : var0 = 7 : rem snake room var6 = 9 : var7 = 15 : t = 17 : rem hero, seer, theif room goto go_bnk3 set_5 g = 21 : x = 7 : w = 11 : k = 16 : rem flame, shield, lyre, key room var5 = 9 : rem gorgon room var3 = 23 : var1 = 12 : rem troll room var8 = 5 : var0 = 15 : rem snake room var6 = 7 : var7 = 14 : t = 4 : rem hero, seer, theif room goto go_bnk3 Edited May 15, 2020 by bogax goofed the code, additional info 1 Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted May 16, 2020 Share Posted May 16, 2020 On 5/15/2020 at 2:22 AM, Lillapojkenpåön said: Haven't looked at the code, and don't know if rand&5 works, but maybe you can use it elsewhere instead of alot of if...thens temp5 = rand&5 ;get random value between 0 - 5, might not work y = yTable[temp5] ;use it as index data yTable 1, 2, 3, 4, 5, 6 end Haha, just realized something ridiculous, if this would have worked why wouldn't you just do y = rand&5 + 1 1 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.