Mike Harris Posted April 11, 2019 Share Posted April 11, 2019 Can someone provide a mathematical formula or code to wrap text around the screen?I have looked all over Coleco and MSX forums but have come up empty.Say I have a block of data such as; DB 00,01,02,03,04,05,06,07,08,09,10,12,13,14,15,16,17,18,19,20,21,22,23 So if I shift this all to the right say 6 spaces how can I have this display on the same line when it hits the end of the screen like this example; 18 19 20 21 22 23 00 01 02 03 04 05 06 07 08 09 10 12 13 14 15 16 17 Or if I take away I would do the same but in reverse like this; 06 07 08 09 10 12 13 14 15 16 17 18 19 20 21 22 23 00 01 02 03 04 05I have been wracking my brain on this for about month before I bother you guys. TIA MH Quote Link to comment Share on other sites More sharing options...
+5-11under Posted April 11, 2019 Share Posted April 11, 2019 Use a pointer... Keep the data at 00-23, always. Use a pointer to find the starting point. Whenever you hit 24, basically subtract 24 from the pointer. If you get less than 00, add 24. For instance, in you examples above... Initial starting point was 00. Go right 6, so subtract 6, so you have -6 - is less than 0, so add 24... 18. Start at 18, when you hit >23, subtract 24 so you're back at 0, etc. Initial starting point was 00. Go left 6, so add 6, so you have 6. Start at 6, when you hit >23, subtract 24 so you're back at 0, etc. Does that help, or no? Quote Link to comment Share on other sites More sharing options...
Mike Harris Posted April 11, 2019 Author Share Posted April 11, 2019 I'll try it and post the results. It seems the hardest things in Assembly end up being the easiest in the long run. thanks Quote Link to comment Share on other sites More sharing options...
ChildOfCv Posted April 11, 2019 Share Posted April 11, 2019 More generally, have a 2-stage loop. The first stage starts in the middle of your array (but beginning of line on the screen) and outputs until the end of the wrapping data. The second stage finishes what's left to display back at array element 0 and up. This saves you from changing the display address between stages. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted April 11, 2019 Share Posted April 11, 2019 Repeat the data at the end, so you don't have to add a lenghty comparison inside the loop. The start pointer is the only that should return to 0 once you reach 24. 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.