jschultzpedersen Posted April 29 Share Posted April 29 Hi The last few weeks I have looked at scrolling in TurboForth, and whether I could manage the real time update of 32 patterns (one complete line in Graphic mode 1) at a sensible speed only using standard Forth - no assembly routine calls. Perhaps a bit pointless, but bear with me! There is at least one mile-long discussion on scrolling using assembler or one of the Basic versions with specific support for it. But I did not see one involving TurboForth only. Anyway, I managed to do about 4.4 updates per second - that is 4.4 updates of 256 bytes of pattern data as well as counting in the effect of their neighbour pattern bytes and adding new data every 8 shifts. All calculations are done on a copy of the pattern data in RAM, and the updated data are then block moved to VRAM. This produces a stutter-free update of the screen and increases speed because it does not have to read/write data in VRAM all the time. The central SCROLL word is surprisingly simple... CSTART is the address in RAM for the copy of the pattern data. PIXLEN is the total length of the pattern bytes. A call to SCROLL will shift everything 1 pixel to the left. : SCROLL CSTART PIXLEN + CSTART DO I DUP DUP C@ 1 << SWAP 8 + C@ 7 >> + SWAP C! LOOP ; After 8 repeats I call a word that updates the rightmost pattern to the pattern of the next character. This pattern is not displayed on screen, and it scrolls nicely on screen during the next 8 shifts. 4.4 updates per second is still kind of slow, but if you only want to display 16 patterns, the speed roughly doubles, and if you modify it to do 2-pixels scroll (simply change the shift values), the speed redoubles again, and then we have something. Besides, it is very good at making scrolling starfields with large numbers of stars by repeating sets of patterns at different lines on the screen and making sure they start at different x-locations. You can also feed text strings of any length to it and repeat them endlessly just by resetting a pointer. So it is not without practical use. This note is just to let others know I am having a lot of fun learning TurboForth 😀 regards Jesper 4 Quote Link to comment Share on other sites More sharing options...
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.