![]() |
Screen handling - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +--- Thread: Screen handling (/showthread.php?tid=454) |
Screen handling - britlion - 04-18-2012 This is interesting. There's quite a lot of overhead in PLOT, I think - this is fairly unoptimized, still - and appears to be a little buggy. It also doesn't use the screen tables lookup yet. But it's late and I need to go to bed ![]() Code: SUB plotPoint (x as uByte, y as uByte) Re: Screen handling - slenkar - 04-18-2012 nice, i got 11 secs for zxbasic and 7 secs for your function I cant seem to get any colour of dots except black Code: SUB plotPoint (x as uByte, y as uByte) On the second pass only the green paper shows up Re: Screen handling - britlion - 04-18-2012 You know, looking at this, I'm particularly impressed with this bit: Code: As we know, the bit pattern for a screen address is 010LLrrr LLLCCCCC - where L = character line number (0-31), r=row in character. C=column. This rotates in the 010, and slides over the two first line bits LL. Then it does something really clever. It puts in the last 3 bits from the original, left in e. I'd have probably done something like: Code: RRCA Which is far more faffing. XOR/AND/XOR. How cool is that for three instructions to merge some bits of one register with another? New trick learned. Re: Screen handling - boriel - 04-18-2012 slenkar Wrote:nice, i got 11 secs for zxbasic and 7 secs for your functionZX Basic uses ROMs PLOT (which is already somewhat optimized, BTW!), but uses a different entry point, to allow 192 scanlines. On the other hand, DRAW has already been optimized and no longer uses PLOT, but PIXELADDR for the 1st point of a scan line (remaining points are computed relatively to the last plotted dot). Also, keep en mind that ZX Basic/ROM PLOT routine also updates ATTR according to TEMP ATTRs and also take into account the SCREEN_ADDR variable (so you can draw/print in another memory/region like a temporary buffer). Re: Screen handling - britlion - 04-18-2012 slenkar Wrote:nice, i got 11 secs for zxbasic and 7 secs for your function The routine, as it stands, just sets the ink point on - it doesn't touch attributes, change the current plot values or any such thing - it's optimized to get that point changed, and do nothing else. Slenkar - if you did a CLS after setting ink and paper values, you'd get what you were looking for, since that would change all the attribute data on the screen for you. As Boriel points out, the standard plot routine also changes the attribute value and does some housekeeping in the background. That said, it's pretty rare that a draw needs to do this, since the effect is usually terrible. I can't think of any games that would require it - usually all the attribs in the game area are set already. It might be reasonable to set up a fastplot and fastdraw routine for games purposes, that don't do the overhead. If so, it would be a plot similar to this, an absolute draw (from x1,y1 to x2,y2 - no relative movement), and routines to change the ink and paper in an area block - which would go with the clearblock routine. The reason for not using relative draw is if you were working with a vector game, you'd generate the vertices explicitly, so a draw from vertex point 1 to vertex point 2 is probably more useful. Re: Screen handling - britlion - 04-18-2012 Code: SUB plotPoint (x as uByte, y as uByte) Using screen address tables shaves this down to 6.42 seconds for 50,000 points plotted. That's not too bad, all told. (screentables.asm is available elsewhere in the forum, I promise!) Considering that quite a few routines can use the screen lookup tables, 512 bytes of screen tables isn't crazy for a solid speedup (and of course, if you are using a shadow screen, then you could either rewrite a bit, or make screen tables that point to your shadow screen memory). Not sure requiring rotate tables, which is much bigger, is a win, here for one loop removal. Re: Screen handling - slenkar - 04-18-2012 ive never required any color dots than black anyway i suppose, the zxbasic plot doesnt seem to draw colored dots either I dont think. those lookup tables really seem worth using Re: Screen handling - LCD - 04-18-2012 Uncontended Memory: ZXBC Plot: 11 Sec. Britlions FastPlot: 7.7 sec Contended Memory: ZXBC Plot: 12.1 Sec. Britlions FastPlot: 9.1 sec Impressive!!! Re: Screen handling - boriel - 04-18-2012 slenkar Wrote:ive never required any color dots than black anyway i suppose,It does (otherwise, it would be a bug). ZXBC tries to mimic Sinclair BASIC command as much as possible while trying not to increase the overhead. BTW impressive measures! Re: Screen handling - britlion - 04-18-2012 Slenkar: Perhaps these are useful for setting colours? They both paint a rectangle in the specified colours - one needs ink/paper/bright/flash separately, the second takes the attribute byte directly. Code: SUB WindowPaint(x as uByte,y as uByte, width as uByte, height as uByte, inkCol as ubyte, paperCol as uByte, isBright as uByte, isFlash as uByte) Code: SUB paint (x as uByte,y as uByte, width as uByte, height as uByte, attribute as ubyte) |