Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Interesting code speedup
Author | Message | ||||
Bleep Guru Joined: 09/01/2022 Location: United KingdomPosts: 509 |
I was playing around with the Matrix Code Rain code which is in Javavi File Manager. I was attempting to use the font rotation, to give even more variation to the falling code. While I've found, probably not unsurprisingly, that it won't work with 90 or 270 Deg rotation, it will at least do Inverted. However, when I implemented this change, using the TEXT command, rather than the Print@ command in the original, I found that one complete loop of the code, so printing a single character at each character position across the screen, sped up from 60ms to 17ms, (2040 VGA @ 378MHz) and the character can be rotated? to to give approximately the same code rain speed, I've had to increase the loop pause, which slows it down, from 10 to 50? Code attached, with both versions, one line commented out, if you feel like experimenting. 'Matrix Code Rain '0,0 "LTN" or -1,-1 "RBI" Option Default Integer MODE 1 TILE height 12 Const FW=MM.Info(FONTWIDTH): FH=MM.Info(FONTHEIGHT) Const CHR=MM.HRes\FW-1: CVR=MM.VRes\FH Dim String rotate(1)=("LTN","RBI") Dim Integer H(1)=(0,-1), W(1)=(0,-1), O Dim Integer matr(CHR),fade(CHR),clr,x For x=0 To CHR:matr(x)=CVR*Rnd:fade(x)=&hF*Rnd:Next Do ' Print @(20,60)Timer:Timer =0 For x=0 To CHR clr=&h1000*(fade(x)-&hF) And &hFF00 Colour clr Text x*FW+W(O),matr(x)*FH+H(O),Chr$(Rnd*223+32),rotate(O) ' Print @(x*FW-FW,matr(x)*FH)Chr$(Rnd*223+32);'95 If matr(x)<=CVR Then Inc matr(x) Else matr(x)=0 If fade(x)><&hF0 Then Inc fade(x) Else fade(x)=0 Next O=Rnd Pause 50 Loop While Inkey$="" CLS End |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4212 |
Print also outputs to the console. Text only to vga screen There was a remark about console slowing down print already issued. Not sure if it can be fixed. Volhout Edited 2024-11-14 02:57 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Print this page |