Re: Fastest Print to Screen
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Nov 23, 1998
- 589 views
>I stumbled across "perform.doc" and read that puts ain't the way to go >for speed. I tried display_text_image() but apparently it would be a >pain to parse out the sequence I want printed with all the colors in >between, or maybe it wouldn't. Putsxy is for graphics modes. No, you want to poke your data to the memory. Here's a fast, text-mode only version, it clips at 25,80 But you can easily change the constants. The code has been tested by me. -- Fast display_text_image and save_text_image constant BPC = 2, -- 2 bytes per char (one for the color) CLIP_Y = 25, -- 25 lines down CLIP_X = 80 * BPC, -- 80 columns right VIDEO = #B8000 -1, -- Use #B0000 for monochrome FALSE = 0 global procedure display_text_image (sequence pos, sequence data) integer skip, max_width, max_height, pos_x, begin, offset sequence row -- Calculating offset pos_x = pos[2] * BPC - 1 offset = pos_x + (pos[1]-1) * CLIP_X + VIDEO -- Check if the offset is out-of-bounds if offset <= VIDEO then skip = VIDEO - offset + 1 offset = VIDEO - 1 else skip = FALSE end if -- Set the maximum length for each row max_width = CLIP_X - pos_x begin = FALSE for skip_index = 1 to length(data) do if not skip then if length(data)-skip_index > CLIP_Y then max_height = skip_index + CLIP_Y else max_height = length(data) end if for index = skip_index to max_height do row = data[index] if length(row) > max_width then if begin then poke (offset, row[begin..begin+max_width]) else poke (offset, row[1..max_width+1]) end if else if begin then poke(offset,row[begin..length(row)]) else poke (offset, row) end if end if offset = offset + CLIP_X end for exit end if if skip < CLIP_X then begin = skip skip = FALSE else skip = skip - CLIP_X end if end for end procedure --- End of code