VOGONS

Common searches


Search results

Display options

Re: CGA Graphics library

in Milliways
@reenigne Actually, I think your approach is slightly different. You have the 8 cases in 2 sets of 4, where I have them in 4 sets of 2, I think. It would actually be interesting to compare the two approaches.

Re: CGA Graphics library

in Milliways
@reenigne Ah, you probably won't believe I came up with this independently now, but here is what I've been working on this afternoon. It uses basically exactly the same ideas you had. And yes, I think it works, with a few bytes to spare. PUBLIC _cga_draw_line2 _cga_draw_line2 PROC ARG x0:WORD, y0: …

Re: CGA Graphics library

in Milliways
@reenigne So far for verticalish lines there's only the original versions of the routines I wrote before posting here. These are in cga.asm in _cga_draw_line3 and _cga_draw_line4. One of them is for slightly right moving and the other for slightly left moving verticalish lines. cga5.asm is the only …

Re: CGA Graphics library

in Milliways
xor'ing or and'ing or or'ing the lines brings the time down to 18.7s overall, or about 70 cycles per pixel. Obviously if and and or are used to draw lines of colour 0 and 3 respectively, general random colour lines average out at 75 cycles per pixel. That's a nice figure to be at, since it is around …

Re: CGA Graphics library

in Milliways
For those still playing along at home, I did some timings and 60 frames of 66 lines of width 320 now takes ~21.30s, which works out to just about exactly 80 cycles per pixel. That's almost a 10% speedup over the course of the week (my previous estimate of 75 cycles before this speedup turns out to …

Re: CGA Graphics library

in Milliways
I did some slightly more careful timings and it seems that the loop unrolling makes far more difference than I thought. I have been having trouble with GitHub serving up old versions of files and I suspect what happened is I ran an older version when timing after I did the loop unrolling. Anyhow, …

Re: CGA Graphics library

in Milliways
@VileRancour Wow! That is one hell of an article by Abrash, complete with listings! Thanks very much for pointing it out. I'm curious what other things were in that journal now.

Re: CGA Graphics library

in Milliways
Success!! The file cga5.asm in my GitHub repo (see first post) is by far the fastest on the 8088. It takes only 1s to do 200 horizontalish lines of 320 pixels. That's about 75 cycles per pixel, which matches what I predicted was possible. I haven't tested it extensively, but it should be roughly …

Re: CGA Graphics library

in Milliways
I've uploaded cga4.asm to my GItHub which has the unrolled "slow" version of the code. It doesn't bother with the last few pixels and it only handles horizontalish lines with positive slope (increasing y). I think I may have an idea of how to combine reads and writes to the CGA memory for multiple …

Re: CGA Graphics library

in Milliways
I tried unrolling the "slow" version of the code by 4. I didn't bother writing the fixup at the end since it isn't needed to get an idea of the speed. At worst the last three pixels are not drawn. I used a computed jump into the unrolled loop and removed all the obvious bits that were no longer …

Re: CGA Graphics library

in Milliways
@reenigne I tried your xor trick in my "fast" code and the result was dramatic. It shaved nearly a quarter second off on the 8088 for horizontalish lines. My timing probably isn't very accurate (I'm still too lazy to hook up Abrash's zen timer to my code.) But the difference is actually really …

Re: CGA Graphics library

in Milliways
Thanks for the links, I will definitely read those. I remember reading Abrash's graphics stuff way back. Of course I've forgotten more than I remember.

Re: CGA Graphics library

in Milliways
By the way, is self-modifying code the standard way to preserve SP if you want to use it as a general register, or is there somewhere else I can conveniently stash it? You just have to put it somewhere where you'll be able to find it again afterwards. I usually just reserve some space in the code …

Re: CGA Graphics library

in Milliways
I tried your xor trick and the times for the "slow" and "fast" versions are now the same. After a short conversation with myself, I convinced myself to be happy about that. It's now clear the fast version can be sped up, e.g. by saving SP and using the same trick in that code or unrolling the "slow" …

Re: CGA Graphics library

in Milliways
I don't think I have any registers spare in the fast code. I do kind of unroll by 2 in the fast version, but I can't go any further with that due to the cost of long jumps. If you unroll by 2 but have the two copies of the routine be for even and odd scanlines respectively that might be a good …

Re: CGA Graphics library

in Milliways
By the way, I had concluded at some point that using SP as a general register was impossible. I will have to revisit that now, as my ellipse code really needed an extra register to be truly fast. And once you are short one register, you are short two. I have a super fast version of my ellipse code …

Re: CGA Graphics library

in Milliways
Thanks very much for taking a look at my code. Those are some really cool suggestions. I must admit I don't actually know how many cycles per pixel the fast version is at. Roughly speaking I think I can do around 200 horizontalish lines per second on an 8MHz CPU, with each line being 320 pixels. So …

CGA Graphics library

in Milliways
Recently I've been teaching myself how to program the 8088/86 processor and the CGA card. I've been writing some really fast routines for drawing lines, circles and ellipses, with and without clipping. They are much faster than the Borland Graphics Interface, so I thought I'd share them in case …

Page 4 of 4