function ScreenMono(memblock, direction) remstart This function will replace the screen image with another greyscale image line by line, from the top of the screen remend `************************************************************ ` Create some variables to make the code more legible ` Screen Height sh = screen height() ` screen width sw = screen width() ` Screen depth sd = screen depth() ` Bytes per screen line. Screen depth is in bits, we are working in bytes. sb = sw * (sd / 8) `************************************************************ ` Calculate Direction variables... `************************************************************ if direction = 0 startline = 0 endline = sh - 1 stepline = 1 else endline = 0 startline = sh - 1 stepline = -1 endif `************************************************************ for y = startline to endline step stepline ` To prevent Darkbasic from overworking, we must manually lock the pixels ` Without this, the program will automatically lock and unlock the pixels ` before and after every operation. lock pixels ` We must convert the current line to the position in the memblock. linestart = (y * sb) screenlinestart = (y * pixpitch) for x = 0 to (sb - 4) step 4 grey = (memblock byte(memblock,linestart + 12 + x) + memblock _ byte(memblock,linestart + 12 + x + 1) + memblock _ byte(memblock,linestart + 12 + x + 2)) / 3 write memblock byte memblock,linestart + 12 + x,grey write memblock byte memblock,linestart + 12 + x + 1,grey write memblock byte memblock,linestart + 12 + x + 2,grey next x copy memory get pixels pointer() + linestart, get memblock _ ptr(memBlock) + linestart + 12, sb unlock pixels text 5,5, str$(screen fps()) sync next y endfunction