Jump to content

Recommended Posts

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 05

I have been wracking my brain on this for about month before I bother you guys.

 

 

 

TIA

MH

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...