![]() |
Fill Routine - 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) +---- Forum: How-To & Tutorials (https://www.boriel.com/forum/forumdisplay.php?fid=13) +---- Thread: Fill Routine (/showthread.php?tid=439) |
Re: Fill Routine - boriel - 04-07-2012 I'm also wondering which one is faster! ![]() Except for the inc b/dec b (used to update pixel coords in BC for later use), which sub is faster? e.g. Here is DRAW incY: Notes: Line 292 (inc b) can be removed out, this is a DRAW requirement and can be done outside the sub The routine sets Carry on F', to signal the ATTR position must be also updated. Code: 288 ;; Given an HL screen position, calculates Re: Fill Routine - britlion - 04-08-2012 boriel Wrote:I'm also wondering which one is faster! I think they have to be....similar. Given they are byte for byte identical: Code: ; Re: Fill Routine - boriel - 04-08-2012 britlion Wrote::!:boriel Wrote:I'm also wondering which one is faster! ![]() Well, don't remember if I did them on my own, or took them from speccy.org (probably from there). Anyway, getting the next/previous scanline is quite standard: ZX Spectrum have few registers, and usually HL is used for "pokeing" the screen. So, yes: except for the INC B and attibute flag, this routine is identical. I think I'm going to remove the INC B out of it, and make them independent (separated in their own files). So they can be included by the Fill routine, and so. Re: Fill Routine - britlion - 04-08-2012 boriel Wrote:britlion Wrote:Since DRAW is alwaws packed with ZX BASIC I guess it would be rather easy to replace them so no duplicated code is included and so, some precious bytes saved! Boriel: Why is it always packed with ZX Basic? One thing Hisoft Basic did well was paring down the runtime modules to a minimum - they were only included in the final code if they were called. I suspect ZX Basic could be more modular, with more code separated out and INCLUDE ONCEd, so that it's only packed in if it's needed. If people are going to make full sized games, they are going to need every last byte! INCY/DECY are classic examples of code that could be included from SPPack and from Draw - but only if one parent is included; and INCLUDE ONCEd so that they only get glued in once if both are needed... Re: Fill Routine - boriel - 04-08-2012 I meant 'packed' (bundled?) not compiled. Whenever you use DRAW, these routines are compiled with your program. Otherwise they are not. I think we both are saying the same... ![]() The asm directive for this is #require "file.asm", which will include the file ONCE at the end of the compilation (include once does it in place). Re: Fill Routine - boriel - 04-08-2012 Another question: why the CP $40 at the end of the SP INC y routine?? Update: After examining the code, I guess it signals C carry if out of screen. Hmmm. Will try to integrate both routines in a single (common) one. Re: Fill Routine - britlion - 04-10-2012 boriel Wrote:I That's a new one for me. Huh. Is there a list of these compiler directives somewhere? Re: Fill Routine - boriel - 04-10-2012 britlion Wrote:Not yet :oops:boriel Wrote:I Anyway, it's safe to use include once always. But some times you want a library to be "included once later". Let's suppose we have the following files: file1.asm Code: ... Code: _FILE2: file1.asm Code: #require "SUB.asm" Code: ; Ensures file1.asm goes here Re: Fill Routine - britlion - 04-19-2012 So, without a handy list of compiler directives, what's the best way of making sure draw is in? Couldn't see a way to compile a jump to DECY... Re: Fill Routine - boriel - 04-19-2012 Sorry, Britlion. I've been busy this week. You can't jump to DECY because it's been declared as LOCAL. Basically I would:
Re: Fill Routine - boriel - 05-30-2012 I'm puzzled. The __DECY routine and the one in our code *differ* ![]() I now remember where did I took these routines from this Speccy Tutorial Code: __DECY: SPPixelDown: Accoding to Speccy.org seems to be an optimization. Any ideas? Re: Fill Routine - boriel - 05-30-2012 Update (cleaned up): Code: __DECY: SPPixelDown: Both this 2 routines do the same. :?: The one on the right seems optimized (It's used in ZX Basic DRAW) Re: Fill Routine - boriel - 06-01-2012 Update2: I got it. Both routines do the same. The one on the left is smaller (more optimized), but there is a chance that after the ADD A, 32 it returns with the RET C. Since the fill routine uses the Carry flag to signal out of screen, this should never happen. So the routine is rewritten like the one on the left. :mrgreen: So now I'm ready to integrate this into the ZX BASIC library ![]() Re: Fill Routine - boriel - 06-02-2012 Okay, I've finally imported it into ZX Basic. BTW should it be called SPPFill or SPFill ? Even better, I think it should be better to use the name patern SPFill (case sensitive). HOWTO: Put BeepFX Sound into ZXB code - boriel - 06-03-2012 britlion Wrote:The SPFill is already included and both Draw and it uses the same routines finally!boriel Wrote:Britlion, seriously, this is FANTASTIC! :o Code: #include <SP/Fill.bas> |