Search found 117 matches

by hjalfi
Sat Jun 02, 2018 10:16 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Turns out that running the entire computation with interrupts off and polling the system VIA is very easy and quite effective. And I don't need the event handler any more --- I can just test bit 1 in the system VIA IFR and it'll tell me whether there's a pending keypress. That's 2699 -> 2732 px/s, a...
by hjalfi
Fri Jun 01, 2018 10:35 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

@rtw: huh. That never even occurred to me! Turning off the ADC converter got about 77px/s. Interestingly, now jsbeeb and b-em are reporting the same times. I think jsbeeb might be skimping on the ADC emulation... So that's 2699 px/s, and a 12.1 second render. Wow. I think you're topping the leaderbo...
by hjalfi
Fri Jun 01, 2018 9:54 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Gah, misread my instruction timing chart. Yes, you're right, sta zp is 3 cycles. That explains why I didn't get any measurable change! (I do most of this stuff last thing at night before I go to bed --- can you tell?) Re moving recalculate_pixel into the kernel: there's 26 bytes spare, which is load...
by hjalfi
Fri Jun 01, 2018 8:47 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Sadly, that bit of code needs to leave screeny in A for a comparison. But I did find out that inc zp; lda zp is one cycle cheaper than lda zp; inc zp; sta zp, so I've changed that throughout. I can't give you a number, though, because I also reworked the floodfill routine completely --- it's now onl...
by hjalfi
Fri Jun 01, 2018 6:20 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Yes! PRECOMPUTE ALL THE THINGS! Self-modifying fixups yields 10 px/s. Moving the and in pick gives 4px/s. ...then I realised that tax; lda fixup_table,X is actually only six cycles, and can be used outside zero page. Unfortunately it consumes X which means there's one occurrence in the kernel which ...
by hjalfi
Wed May 30, 2018 8:41 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

@dp11: yes, yes I can. Sadly it's only 4 px/s --- that bit of code's only called at most 128*256 times --- but it's really neat. Thanks. 2576 px/s.
by hjalfi
Wed May 30, 2018 8:19 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

@rtw: re tsb: oh, hmm. Missed that. That's very neat. I have three spare bytes of zero page in the legal storage area. That's enough to fit a tsb <abs> and a rts... A jmp abs is three cycles, so jumping there and back wouldn't be worth it. So this would only be worth doing if I didn't need an explic...
by hjalfi
Wed May 30, 2018 7:21 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

@dp11: re palette, oh, that's cunning! Plus, because the entire iteration->palette mapping is predetermined, I can avoid using black for drawing stripes --- this makes the images look much crisper. Weirdly, though, it doesn't make a measurable difference in speed, which I don't really understand as ...
by hjalfi
Wed May 30, 2018 6:21 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

@rtw: d'oh! Obvious in hindsight. Sadly, tsb only has zp and abs addressing modes, so I still need an ora (screenptr); sta (screenptr), but that's a nice 15 px/s. @steve3000: yes, good idea! Um, 0 px/s? But it's friendlier to use. (At some point all that cursor code should be moved to machine code f...
by hjalfi
Tue May 29, 2018 9:45 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

...hey, everything helps! And a suggestion which nudges me into thinking about something in a different way that leads to a bigger improvement (like inlining the top of calculate) is really useful , so thanks! I'm keeping track of who suggested what so I know who to blame^H^H^H^H^Hcredit, BTW. Once ...
by hjalfi
Tue May 29, 2018 9:41 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Ooh, nice. The calculate simplifications: 2407 -> 2411. The midpoint simplifications: 2411 -> 2418. Removing that one flipping clc: 2418 -> 2421! Can you tell which one of these is in the hotspot? calculate's annoying because it has to return the colour in A, which means that even though putting the...
by hjalfi
Tue May 29, 2018 7:55 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Index the column table by pixel rather than by byte, avoiding the need for a scale: 2130 -> 2141 Inline calculate_screen_address (plus knockon microoptimisations): 2141 -> 2220 Use an event rather than osbyte to check for keypresses: 2220 -> 2322 Rearrange how the same-colour flag is stored: 2322 ->...
by hjalfi
Tue May 29, 2018 9:31 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

The flood fill routine already works a byte at a time (with no read/modify/write). That made a difference of about 50 px/s. The OSBYTE's probably not helping. I've traced through it and while it's not terrible , there's quite a lot of it. I did look at directly probing the buffer pointers but that's...
by hjalfi
Mon May 28, 2018 9:00 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Moving the kernel to zero page: 1655 -> 1671 px/s Self modifying all the things (using instruction payloads as variables): 1671->1711 px/s dp11's faster fixup code: 1711->1715 px/s Using physical screen coordinates throughout: 1715->1738 px/s Leaving the framebuffer mapped by default rather than the...
by hjalfi
Mon May 28, 2018 2:11 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Bah. Yes, you're right again.

Too distracted by work, getting in the way of the important things I have to do...
by hjalfi
Mon May 28, 2018 10:53 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Oh, I beg your pardon --- I completely misread what you were doing and thought you were using the bit6-to-v feature in bit. I'd completely failed to realise bit could be used like that, actually (and I spent while looking for a tst instruction, too!) So that's 9 cycles if bit 6 is clear and 6 if it'...
by hjalfi
Mon May 28, 2018 9:46 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Apparently bit immediate is weird and doesn't work the way one would expect: ---snip--- BIT has three additional addressing modes. The abs,X and zp,X addressing modes affect the same flags that the abs and zp addressing modes do. The immediate addressing mode only affects the Z flag. Note that the Z...
by hjalfi
Sun May 27, 2018 7:28 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

@BigEd: ew ew ew yeah that's a good idea. I'll try it. @dp11: cr and ci were actually originally self-modifying variables; I made them conventional zero page variables because Basic needed access to them (for setting the Julia cursor position) and I wanted them to have predictable addresses. Easily ...
by hjalfi
Sun May 27, 2018 1:25 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Hmm. I'm not sure it does. That'll flip the sign bit as well, won't it? So negative numbers have bit6=0, positive numbers have bit6=1. I _think_ that'll make the arithmetic go wrong (as I need to do conventional additions and subtractions as well as table lookups).

Could be wrong, though.
by hjalfi
Sun May 27, 2018 11:42 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Oh, d'oh, of course! Works fine; speed is up from 1586px/s to 1608. Thanks!
by hjalfi
Sun May 27, 2018 11:17 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Bit7 isn't known, because it'll get corrupted by the previous computation. The fixup adjusts the number so that it's a pointer to its square in the lookup table: bit6 is the sign bit, so positive numbers go in 0x8000 to 0xc000 (the top two bits are %10) and negative numbers go in 0x4000 to 0x8000 (t...
by hjalfi
Sun May 27, 2018 10:23 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Yup, works fine! And I chopped off a bit from the integer part and added it to the fractional part, which gives me two extra bits of precision --- you can now zoom all the way down to areas 0.25 across! Sadly the performance has suffered. The number fixup is more complex than I expected; I ended up ...
by hjalfi
Sun May 27, 2018 8:02 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

@dp11: ooh, nice! Every second counts --- that shaves a tenth of a second off the render speed for the default image (1805 px/s instead of 1795). ...you know, I think I can scrape another bit of precision out of this (which would add another zoom layer). I'd need a 32kB lookup table, which would ext...
by hjalfi
Sat May 26, 2018 10:47 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

WITNESS THE POWER OF MY FULLY OPERATIONAL... PROGRAM THING. http://cowlark.com/2018-05-26-bogomandel/animation.gif Now with pan-and-zoom support, Julia sets, actual help text, and three (3) levels of zoom! The writeup with all the maths in it is here: http://cowlark.com/2018-05-26-bogomandel/ (and a...
by hjalfi
Thu May 24, 2018 3:54 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Reenigne's kernel (it's at the bottom of https://github.com/davidgiven/bogomandel/blob/table-of-squares-14/mandel.asm, annotations mostly mine) is computing 2xy from (x+y)^2 - x^2 - y^2: zr2_plus_zi2 = zr^2 + zi^2 if zr2_plus_zi2 > 4 then bailout zr_plus_zi = zr + zi zr2_minus_zi2 = zr^2 - zi^2 zr =...
by hjalfi
Thu May 24, 2018 11:05 am
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Sadly, I must be absolutely clear that this is no longer my trick! (Although I can still claim responsibility for the recursive subdivision, which is a big help, at least once I fixed the big bug that meant it didn't work properly in my original version.) How does your boundary tracing version track...
by hjalfi
Wed May 23, 2018 9:57 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

I'm going to do a proper writeup, because it's really neat, but essentially: there are 16384 possible 14 bit numbers; if we enforce that the LSB is always 0, then there are 8192 possible 14 bit numbers, each of which are 2 apart; the top two bits are unused, so let's mask in $8000; now every possibl...
by hjalfi
Wed May 23, 2018 9:26 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

Sigh. I was feeling all smug there for a moment... So reenigne came up with an incredibly cunning and impossibly fast Mandelbrot kernel, using 14-point fixed point arithmetic and a 16kB lookup table. After patching it into my renderer, this happened... grab.png zoomout.png Jsbeeb link: https://bbc.g...
by hjalfi
Tue May 22, 2018 7:29 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

Re: 12-second Mandelbrot rendering on the BBC Master!

I got it down to 4.5 seconds! With some slight problems...
grab.jpg
grab.jpg (9.53 KiB) Viewed 1206 times
That's using reenigne's table-of-squares algorithm, but 2.6 fixed point just doesn't have enough precision to make it work and it's overflowing nearly everywhere. It's still getting the main set more-or-less right, though.
by hjalfi
Mon May 21, 2018 6:22 pm
Forum: programming
Topic: 12-second Mandelbrot rendering on the BBC Master!
Replies: 107
Views: 2913

12-second Mandelbrot rendering on the BBC Master!

Yes, really! Well, no, not really, but, yes really! Okay, I was distracted, and I decided to have a play with stupidly limited fixed-point arithmetic, and it led to this. The JSBeeb link is here: https://bbc.godbolt.org/?model=Master&disc=https://raw.githubusercontent.com/davidgiven/bogomandel/maste...