User Tools

Site Tools


sd:sd-8516_stellar_basic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sd:sd-8516_stellar_basic [2026/04/21 15:55] appledogsd:sd-8516_stellar_basic [2026/04/28 15:55] (current) appledog
Line 7: Line 7:
  
 == It's fast! == It's fast!
-Stellar BASIC is a kind of 8 bit TinyBASIC, with a few improvements under the hood. It runs at 2500 lines per second at 4 MHz (1.28 MIPS)!+Stellar BASIC is a kind of 8 bit TinyBASIC, with a few improvements under the hood. It can execute over 3,000 lines per second at 4 MHz! Although of course, graphics-heavy statements can slow this down to about half that. Check out our [[Practical Speed Tests]].
  
-Now, compared to a C64 running at 1mhz, why is it so fast? You would expect it to top out at 800 lines per second at 4MHz equivalent. First, the SD-8516 does not experience the register pressure of a 6502. With more registers available to the programmer, the code size could easily be cut by 50% (and double the speed). Steve Wozniak's Sweet-16 virtual machine is a great real-world example. It's a 16-register 16-bit bytecode interpreter (just under 400 bytes of 6502 code). It trades speed for density and is roughly 2x denser than raw 6502 for 16-bit operations. Half the code often translates into double the speed.+Now, compared to a C64 running at 1mhz, why is it so fast? You would expect it to top out at ~800 lines per second since it's four times faster. First, the SD-8516 does not experience the register pressure of a 6502. With more registers available to the programmer, the code size is smaller, and therefore faster.
  
-Secondly, Commodore BASIC 2.0 treats all numbers as floats, which is expensive and slows down the interpreter. Stellar BASIC is more advanced because it has 26 dedicated INT registers (A-Z). When you use A to Z, it is a native INT (native 16 bit register width).+Secondly, Commodore BASIC 2.0 is inefficient. It treats all numbers as floats, which is expensive and slows down the interpreter. Stellar BASIC is more advanced because it has 26 dedicated INT registers (A-Z). When you use A to Z, it is a native INT (native 16 bit register width).
  
 == Terminal Control == Terminal Control
Line 77: Line 77:
 </codify> </codify>
  
-The problem with this is that it's a bit slow. In fact, it executes in 6 seconds at 100mhz.+The problem with this is that it's a bit slow. In fact, it takes over a minute to finish drawing!
  
-The reason why it takes so long is because Mode 3 uses a packed pixel format -- one byte holds two pixels (each pixel is four bits). In fact, if we wrote this program normally it would take over 12 seconds because we would have to PEEK the byte, modify it, and write it out again. The 6 seconds it took is much faster because we used an optimization that draws two pixels at once.+The reason why it takes so long is because Mode 3 uses a packed pixel format -- one byte holds two pixels (each pixel is four bits). In fact, if we wrote this program normally it would take even longer to finish, because we would have to PEEK the byte, modify it, and write it out again.
  
-If you'd like to use something a bit faster, you can try the 2d accelerated graphics commands PIXEL and PEXEL.+Let's try something a bit fasterthe 2d accelerated graphics commands PIXEL and PEXEL.
  
 === PIXEL and PEXEL === PIXEL and PEXEL
Line 107: Line 107:
     30 FOR X = 0 TO 19     30 FOR X = 0 TO 19
     40 FOR Y = 0 TO 199     40 FOR Y = 0 TO 199
-    50 PIXEL(C * 20 + X, Y, C)+    50 PIXEL C * 20 + X, Y, C
     60 NEXT Y     60 NEXT Y
     70 NEXT X     70 NEXT X
Line 113: Line 113:
     90 REM DIAGONAL LINE IN WHITE     90 REM DIAGONAL LINE IN WHITE
    100 FOR I = 0 TO 199    100 FOR I = 0 TO 199
-   110 PIXEL(I, I, 3)+   110 PIXEL I, I, 3
    120 NEXT I    120 NEXT I
    130 INPUT "PRESS ENTER"; A$    130 INPUT "PRESS ENTER"; A$
Line 119: Line 119:
 </codify> </codify>
  
-If you time this program you will find that it is even slower than the POKE version. This is because we're writing out the full 64,000 pixels-- the POKE version only wrote 32,000. If you weigh it pound for pound, comparably, PIXEL is about 30% faster than using POKE to draw.+If you time this program you will find that it is vastly faster than the POKE version, completing in //under// a minute! We may need something faster.
  
 === 160x200 CGA Mode === 160x200 CGA Mode
Line 139: Line 139:
  
 It's still slow to POKE, but if you're just drawing a scene or some letters or art, you can easily get away with POKE in 160x200 mode. It's still slow to POKE, but if you're just drawing a scene or some letters or art, you can easily get away with POKE in 160x200 mode.
- 
  
 === LINE === LINE
Line 154: Line 153:
 </codify> </codify>
  
-Line drawing is much faster. It takes 0.14 seconds at 100mhz. That is an incredible speed-up over the previous record. But there is an even faster command than this -- the  RECT drawing command.+Line drawing is much faster. It takes under a second. That is an incredible speed-up over the previous record. But there is an even faster command than thisthe RECT drawing command.
  
 === RECT === RECT
-Yes! What's even better than a LINE? A rectangle!+What's even better than a LINE? A rectangle, of course.
  
 <codify BASIC> <codify BASIC>
Line 169: Line 168:
 </codify> </codify>
  
-This program is even shorter than the others, and ever so much faster! Clocking in at well under a tenth of a second, it is the fastest version of this demo yet.+This program is even shorter than the others, and ever so much faster. It's so fast you may have trouble timing it. It is the fastest version of this demo yet.
  
 === CIRCLE === CIRCLE
Line 182: Line 181:
     60 MODE 1     60 MODE 1
 </codify> </codify>
 +
 +The format is:
 +
 +    CIRCLE x1,y1, xr, yr, color
  
 Now you can create truly stunning art on the SD-8516! Now you can create truly stunning art on the SD-8516!
sd/sd-8516_stellar_basic.1776786924.txt.gz · Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki