Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/17/21 in all areas

  1. I decided to create a different thread to document my approach to optimizing @SlithyMatt's BASIC code. Not because his code is bad. It is intended to teach. This is just a fun exercise to get a baseline calculation of the current code speed and what various optimizations do to enhance the performance. It will never run fast in BASIC! I've taken his code and removed the graphical parts of it. I think those parts are near optimal for BASIC. As he rightly observes, the math is what makes this program slow. So here is the baseline code I'm working with: 10 TI=0 100 FOR PY=0 TO 9 110 FOR PX=0 TO 9 120 XZ = PX*0.000036/320-0.747345 130 YZ = PY*0.000027/240+0.08784 140 X = 0 150 Y = 0 160 FOR I=0 TO 355 170 IF X*X+Y*Y > 4 THEN GOTO 215 180 XT = X*X - Y*Y + XZ 190 Y = 2*X*Y + YZ 200 X = XT 210 NEXT I 215 I = I - 100 216 IF I=256 THEN I=0 217 B = 0 218 OS = $4000 219 Y = PY 220 IF Y < 153 THEN GOTO 230 221 IF Y = 153 AND PX < 192 THEN GOTO 230 222 B = 1 223 OS = -192 224 Y = PY-153 230 REM 240 NEXT PX 260 NEXT PY 270 PRINT TI/60 Note that instead of a 320x240 plot, I'm restricting my calculations to the top left corner in a 10x10 area of the non-plot. While that might not be the slowest part of the program, it is "representative". In testing, it takes 115.5333 seconds to run. That is based on setting TI to 0 and then displaying TI/60 at the end. This generates the same number whether in warp mode or not, as the emulated computer still emulates the same system. 500% of real time speed means that I can run that 115.5333 second program in about 20 seconds of wall clock time, but jiffies pass at the same relative rate whether or not warp mode is enabled. So, baseline is 115.5333 seconds for a 10x10 area. If we extrapolate, there are 32x24 blocks that are 10x10, so 24.64 hours to calculate the information for an entire screen of 320x240. This is really close to what @SlithyMattreported, so it seems like a reasonable test case. Next post shortly...
    2 points
  2. You're completely missing the point. The C&C hardware that makes PCBs today uses vector data files. There's no accepting of image files, because the systems don't support image files. The whole point of the Gerber file is that this is the format the hardware needs. That's not companies being "stubborn". That's simply the only way they can make a PCB. Honestly, if the guy can make a "no code computer", he can use KiCad. I don't get the stubbornness.
    2 points
  3. I've uploaded a new version of X16 Edit (0.4.0) incorporating some improvements of the program I've been working on during the summer and this autumn. It's nothing major, mostly fixing small things in the user interface not working perfectly
    2 points
  4. Version 1.0.0

    34 downloads

    Got a day to kill with your X16? Run this BASIC program and generate this 256-color fractal plot. It's zoomed into a deep part of the Mandelbrot Set that is particularly pretty. This plot does up to 355 iterations and is within an area where all points require at least 100 iterations, so the whole 256-color palette is able to be represented, from white for 100 iterations to black for 355 iterations or more. For fastest results, run in "warp" mode with your emulator: x16emu -warp -bas x16-mandelbrot-vga-fancy.bas At 8Mhz, this will take literally all day, but if you have a beefy enough host for your emulator, it can be cranked out in a couple hours. Enjoy! From: https://github.com/SlithyMatt/multi-mandlebrot
    2 points
  5. I ran across a video from a YouTube channel I enjoy watching talking about a keyboard I loved, and is probably my all time favorite, the classic IBM Model M. While I do like my very modern Corsair Cherry MX RGB nonsense, I genuinely miss having a Model M. Well, there is a "modern" Model M, and an open source kit to "upgrade" an original Model M and also give it USB connectivity, and to fix the modern versions issue. Wendell explains it all really well, but it's something I am actually interested in, and am considering ordering myself a Unicomp "New Model M". Am I the only one interested in such things? What was, or is, your favorite keyboard of all time, or do you have a few different ones you like? Is it a modern marvel, or something from the past you wish you still had? As I said above, the classic well known Model M is mine. In a more modern context, I loved the Logitech G15, it's ample extra keys, and it's LCD screen + software. I geek out over the weirdest things.
    1 point
  6. Note that line 130 only really needs to be computed when the value of V changes. Move line 130 to line 105 so it is only computed once per iteration of V. Also note that we square X & Y twice in line 170 and 180. We can make that faster if we only do it once per loop and reuse it as needed. Finally, line 180 computes a temporary value as T, then computes Y, then puts the temp value in X. Since we precomputed X^2 & Y^2, we can remove the need for a temporary by swapping 180 and 190. New code: 10 TI=0:Y=0:X=0:I=0:V=0:U=0:N=0:M=0:R=0:Q=0 100 FOR V=0 TO 9 105 R = V*0.000027/240+0.08784 110 FOR U=0 TO 9 120 Q = U*0.000036/320-0.747345 140 X = 0 150 Y = 0 160 FOR I=0 TO 355 165 M=X*X:N=Y*Y 170 IF M+N > 4 THEN GOTO 215 180 Y = 2*X*Y + R 190 X = M - N + Q 210 NEXT I 215 I = I - 100 216 IF I=256 THEN I=0 230 REM 240 NEXT U 260 NEXT V 270 PRINT TI/60 New time: 98.0333 seconds. Extended time estimate: 20.91 hours. Total time saved: 3.73 hours. 15.1% faster.
    1 point
  7. Next I did one thing that helped a little bit but not as much as I'd hoped, and another I should have done for the baseline. Here is the code: 10 TI=0:Y=0:X=0:I=0:V=0:U=0:R=0:Q=0:T=0 100 FOR V=0 TO 9 110 FOR U=0 TO 9 120 Q = U*0.000036/320-0.747345 130 R = V*0.000027/240+0.08784 140 X = 0 150 Y = 0 160 FOR I=0 TO 355 170 IF X*X+Y*Y > 4 THEN GOTO 215 180 T = X*X - Y*Y + Q 190 Y = 2*X*Y + R 200 X = T 210 NEXT I 215 I = I - 100 216 IF I=256 THEN I=0 230 REM 240 NEXT U 260 NEXT V 270 PRINT TI/60 I've replaced all two character variable names with single character names. They are faster to interpret, but not as much as I thought. I also removed lines 217 - 229 as they are not really part of the math, they are part of the plot. Removing them actually slowed things down slightly. New time: 107.1666 seconds. Extended time estimate: 22.86 hours. Total time saved: 1.78 hours. 7.2% faster.
    1 point
  8. I didn't realize this worked in warp mode. Good to know!
    1 point
  9. The first change is just to a single line of code. Line 10 is replaced with: 10 TI=0:Y=0:X=0:I=0:PY=0:PX=0:YZ=0:XZ=0:XT=0 Every time a variable is accessed, BASIC has to look through the variable table for it. If it is the first variable, great! It is found quickly! If it is the 100th variable, it takes 100 times as long. Thus you want to create your variables in the order they will be most frequently accessed. In this case, X & Y are used the most, so they are created first (TI isn't a real variable). XZ, YZ, and ZT are used the least so we create them last. New time: 107.7666 seconds. Extended time estimate: 22.99 hours. Time saved: 1.65 hours. 6.7% faster.
    1 point
  10. I think I can judge it even in warp mode as long as I don't use wall clock time but use TI to report the number of jiffies a range of rows takes. I would clear TI to 0 after clearing the screen, then do a range of rows in the middle of the screen. Really, because the math is the intense part, removing the screen drawing completely would allow timing just the math code. That's the part in need of optimization (in as much as there is a "need" to do anything like this; there is far more utility to your easier to read and understand version than this, this is just "for fun".
    1 point
  11. Having worked in a plastics manufacturing plant, there is always "off-product/off-spec" made. Colour of the original plastic resin may have varied from shipment to shipment to Commodore. Plus the raw material used to make the resin would also have variation too. If the resin supplier had multiple factories that would account for variations as well. These variations can be minimized with a stringent quality-control program, but at a price. The plant I was in would keep any scrap resin around and find buyers who weren't particular in physical characteristics so much as getting a discount deal on price. It cost money to make plastic, so selling recoups some of the cost and avoids making more plastic. Does anyone know that the case molding wasn't outsourced to a sub-contractor? If the prototype theory is correct, most likely it was made at a location that wasn't the main factory using perhaps a different supply of resin, and certainly not the operators on the main factory floor. Heat/bake anything for a longer time will most likely result in a darker colour. That might explain the differences in colouration from a stock machine. As for the industrial use theory, perhaps it was a split unit so that the main electronics were in an enclosure for some reason (intrinsically safe?) , the keyboard external so that if something went wrong with it it would be easily and cheaply replaced. Anyway just some information and speculation on this retro mystery. Take it for the entertainment value that it is.
    1 point
  12. All very valid points. It is one thing to optimize a 32x22 (or whatever) plot so it shaves a few seconds off something that takes a couple minutes. It is quite another to shave a few seconds off a 320x240 plot that takes literal hours to run. I'm running a solution right now that does all the horrible unreadable tricks to the BASIC code to try to make it faster. I haven't tried timing the original vs this one (mainly because it takes so long; I need to tweak it to time how long it takes to render a random raster to have something that can be timed, just haven't had time to do that yet). But it seems to work. And it is ugly (and I do not like ugly code unless there is a really good reason, evidence to the contrary notwithstanding). 0 SCREEN0:POKE$9F2D,$07:POKE$9F2F,$20:POKE$9F29,$11:GOSUB12 1 YI=0.000027/240:YZ=0.08784:XS=-0.747345:XI=0.000036/320 2 C0=0:C1=1:C2=2:C4=4:CC=100:CH=256:CA=$4000:CB=153:CE=192:CF=320:CG=355 3 CI=239:CJ=319:POKE$9F20,0:POKE$9F21,$40:POKE$9F22,$10:VP=$9F23 4 FORPY=C0TOCI:XZ=XS:FORPX=C0TOCJ:X=C0:Y=C0:FORI=C0TOCG:X2=X*X:Y2=Y*Y 5 IT=I:IFX2+Y2>C4THENI=CG:NEXT:GOTO7 6 Y=C2*X*Y+YZ:X=X2-Y2+XZ:NEXT 7 I=IT-CC:IFI=CHTHENI=C0 8 B=C0:OS=CA:Y=PY:IFY<CBGOTO11 9 IFY=CBTHENIFPX<CEGOTO11 10 B=C1:OS=-CE:Y=PY-CB 11 POKEVP,I:XZ=XZ+XI:NEXT:YZ=YZ+YI:NEXT:END 12 POKE$9F20,0:POKE$9F21,$40:POKE$9F22,$10:VP=$9F23 13 FORI=1TO320*240:POKEVP,0:NEXT:RETURN I'll provide some quantitative data later measuring time to rasterize one line in each version, but I think the difference will not be great.
    1 point
  13. True to a point, but some of the variables are so difficult to analyze and discover that they might as well be impossible. Companies have a reputation. They have a process. Spending time creating another process that won't be often used, and may likely create substandard parts, is not a profitable use of time and resources. In the time it would take for them to cater to a non-standard process that few people would ever use, they could improve the existing process to benefit far more people. If they provide a new process to use PNG files, with the inherent imprecision of pixels vs vectors, and the boards come out defective due to the difference, their reputation suffers and potentially costs them far more in loss of customers due to bad publicity than it gains them from the one customer that wanted the process if the customer isn't happy with the results.
    1 point
  14. I think it boils down to "the known options require X; if realization of the design is not important enough to the creator to use the available tools, then there is nothing anyone can do".
    1 point
  15. There are some very low-hanging fruit that I haven't bothered with so far, in the interest of keeping the working, straightforward implementation of the algorithm in BASIC. I don't think any of these will have a huge impact, but they might shave off a bit of time: Line 10: Do a pair of VERA register pokes to set screen resolution to 324x240 After line 50: Set up VERA address registers manually for start of bitmap in VRAM ($4000) Then, replace lines 217-230 with a single line: POKE $9F23,I Lines 120, 130: Pre-calculate 0.000036/320 and 0.000027/240 After line 160: Calculate X*X and Y*Y Then, use pre-calculated squares for lines 170 and 180 This area of the plot is not symmetrical, so I don't think you can just do mirroring to save a big chunk of time. Anything else will take some really digging to come up with optimization. The core driver of the time is the math that just needs to happen.
    1 point
  16. TLDR; : There is no such thing as an unprofitable customer, there is only deficiency in price discovery. That is what defines bad business practice. There is the hourly rate, 'We don't have a clue what it will cost us to find or write a simple app to convert images for our many prospective customers who have old magazine articles they'd like us to make into PCBs, but, if you'd like to pay us $200 a week, we'll assign a worker for four hours a week to look into it and keep you updated with his or her progress." There is the F-off quote, " The cost is X amount ( X amount is a shockingly high amount which I've picked out of the air, it cannot possibly cost this much, however, I'll hold a straight face and tell you it's this much hoping you'll go away, OR say yes, and at that amount I will not only take the job but I'll smile and whistle the whole time because it's such a vast amount of money) and we can start the job this week if that meets your requirements " There is another explanation of the universal business practice of extra data is required no exceptions. You are the product. That's right, PCBs of top quality for $2 each are being subsidized which is to say, you are the product. I suggest people watch this video and then work out what all that additional data which is _demanded_and_not_optional_ is all about. A huge ocean of data designs of PCBs, with full circuit schematics and layouts, footprints, silkscreens, what could that massive and growing by the second treasure trove of data be used for, in a world which is going to use AI to replace just about everyone. What do they do with that data do you think, when you are the product and it is not an option in any way shape or form under any circumstance no matter what money you offer them, I'd pay $100 for the board right this moment, since when is that not economical ? There is_no_such_thing as an unprofitable customer, there is only poor pricing and lack of pricing. Offer a million dollars for a PCB and you'd discover that all of a sudden, yes, they do make PCB's. But they will not haggle because the data is what they are demanding and it's not negotiable. They won't even give me a price. Anyhow, I prefer to keep on topic please, the designer does not need to be elbowed out of the picture by an ugly board drawer, the designer just needs png to pcb, you know, on this planet.
    1 point
  17. LIAR !!!! I have an EXCLUSIVE EXPOSE video showing many of your so-called cage free electrons are actually raised in BATTERY-LIKE conditions !!!! scandal, news at 11.
    1 point
  18. Actually I can't promise anything. But I'll look at it!
    1 point
  19. Or just lousy debouncing.
    1 point
  20. Version 1.0.0

    44 downloads

    Another small intro. Sadly still no audio. If only it wasn't so painful to debug audio and if I had any sort of musical talent... Thanks for looking! Spinner.zip
    1 point
  21. Version 1.0.1

    64 downloads

    How many sprites does the Commander X16 have? Let's find out, shall we! Written in Prog8. Source code is here: https://github.com/irmen/prog8/blob/master/examples/cx16/bobs.p8
    1 point
  22. Now that's proper "retro" gaming! Nice setup you have there! If I only had the room for a cabinet... sadly, that's just not an option. I have wanted to build a full cabinet MAME system for a long time now, maybe someday, but for now I j ust don't have the space. Those were the good old days I remember so fondly, I spent untold numbers of quarters in the arcades of the 80's and early 90's. I did repair/maintain a few cabinets back then for a couple local businesses. Dig Dug, Asteroids, Rampage, Pole Position, and a few others. I did have a Pac-Man machine setup for my dad in their garage in the early 90's, he loved that machine, but ended up selling it when they bought a new home. I think my mom didn't want it coming with them. haha Good times!
    1 point
×
×
  • Create New...

Important Information

Please review our Terms of Use