Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
Fun with Ray Casting
Forum: a740g
Last Post: MasterGy
37 minutes ago
» Replies: 8
» Views: 125
|
QBJS - ANSI Draw
Forum: QBJS, BAM, and Other BASICs
Last Post: dbox
52 minutes ago
» Replies: 3
» Views: 69
|
Cautionary tale of open, ...
Forum: General Discussion
Last Post: doppler
6 hours ago
» Replies: 3
» Views: 80
|
Extended KotD #23 and #24...
Forum: Keyword of the Day!
Last Post: SMcNeill
7 hours ago
» Replies: 0
» Views: 31
|
Big problem for me.
Forum: General Discussion
Last Post: JRace
11 hours ago
» Replies: 11
» Views: 183
|
Virtual Arrays
Forum: Site Suggestions
Last Post: hsiangch_ong
Today, 12:35 AM
» Replies: 8
» Views: 297
|
QBJS v0.9.0 - Release
Forum: QBJS, BAM, and Other BASICs
Last Post: hsiangch_ong
Today, 12:25 AM
» Replies: 17
» Views: 305
|
Very basic key mapping de...
Forum: SMcNeill
Last Post: SMcNeill
Yesterday, 11:18 PM
» Replies: 0
» Views: 33
|
1990's 3D Doom-Like Walls...
Forum: Programs
Last Post: a740g
Yesterday, 06:12 PM
» Replies: 10
» Views: 323
|
Editor WIP
Forum: bplus
Last Post: aadityap0901
Yesterday, 08:54 AM
» Replies: 12
» Views: 687
|
|
|
BAM: About + Links |
Posted by: CharlieJV - 11-08-2022, 03:12 AM - Forum: QBJS, BAM, and Other BASICs
- Replies (2)
|
|
Basic Anywhere Machine (check it out)
What it is, the "short"(?) version:
Imagine Wikipedia (as in the software behind it), all existing in one self-editing and self-saving HTML file. Imagine it hosting a QB64 interpreter, IDE, all of the programming tools and programs, and everything to support all processes and artefacts for project management, source code management, and everything end-to-end in a software development process.
Still early going, but that's where it is heading.
And all you need is a web browser. Offline, online, fine. What you do with it will still work in 15 or 20 years. You won't need to find software or an operating system to run it. Just find a web browser. Everything else you need (every single thing other than a web browser) is in the one HTML file.
It is like a fully self-contained virtual computer that will have everything you need to manage QB64PE code for huge projects. Kind of like a QB64PE software development "bottle garden" (not sealed! you can still put stuff in it and get stuff out of it!)
Some technical clarifications:
Okay, it is not Wikipedia software. It is a "TiddlyWiki" instance. Because TiddlyWiki has the goods (goodies) to create just about anything. Don't let the cutesy name fool you. The thing is a powerhouse.
The embedded BASIC interpreter started off with vanilla wwwBASIC, but BAM's version is significantly enhanced. (An on-going process.) At the moment very focused on GW-BASIC "reasonable" compatibility before moving on to QB64PE "reasonable" compatibility. (I say "reasonable" because I cannot stand javascript, so updating the interpreter to handle the more intricate/complicated statements/functions/features, I just don't want to think of that just yet.)
Aside: - multi-member team software development project? That is a BASIC Anywhere Machine "TiddlyWiki Farm" running on a node.js server; awesome, but not required if you have good workflow processes.
More info:
|
|
|
QBJS Rotating 4D cube |
Posted by: vince - 11-08-2022, 01:46 AM - Forum: QBJS, BAM, and Other BASICs
- Replies (10)
|
|
Code: (Select All) dim shared pi, p, q, d, z0, t, f, sw, sh
sw = 800
sh = 600
d = 700
z0 = 1500
pi = 4*atn(1)
dim x(16), y(16), z(16), w(16)
x(0)=0-1: y(0) =0-1: z(0) =0-1: w(0) = 0-1
x(1)= 1: y(1) =0-1: z(1) =0-1: w(1) = 0-1
x(2)= 1: y(2) = 1: z(2) =0-1: w(2) = 0-1
x(3)=0-1: y(3) = 1: z(3) =0-1: w(3) = 0-1
x(4)=0-1: y(4) =0-1: z(4) =1: w(4) = 0-1
x(5)= 1: y(5) =0-1: z(5) =1: w(5) = 0-1
x(6)= 1: y(6) = 1: z(6) =1: w(6) = 0-1
x(7)=0-1: y(7) = 1: z(7) =1: w(7) = 0-1
x( 8)=0-1: y( 8) =0-1: z( 8) =0-1: w( 8) = 1
x( 9)= 1: y( 9) =0-1: z( 9) =0-1: w( 9) = 1
x(10)= 1: y(10) = 1: z(10) =0-1: w(10) = 1
x(11)=0-1: y(11) = 1: z(11) =0-1: w(11) = 1
x(12)=0-1: y(12) =0-1: z(12) =1: w(12) = 1
x(13)= 1: y(13) =0-1: z(13) =1: w(13) = 1
x(14)= 1: y(14) = 1: z(14) =1: w(14) = 1
x(15)=0-1: y(15) = 1: z(15) =1: w(15) = 1
screen _newimage(sw, sh, 32)
do
for t = 0 to 8*pi step 0.01
cls
f=0
i = 0
proj x(i), y(i), z(i), w(i)
pset (p, q)
for i=1 to 3
proj x(i), y(i), z(i), w(i)
line -(p, q)
next
i = 0
proj x(i), y(i), z(i), w(i)
line -(p, q)
i = 4
proj x(i), y(i), z(i), w(i)
pset (p, q)
for i=4 to 7
proj x(i), y(i), z(i), w(i)
line -(p, q)
next
i = 4
proj x(i), y(i), z(i), w(i)
line -(p, q)
for i=0 to 3
proj x(i), y(i), z(i), w(i)
pset (p, q)
proj x(i+4), y(i+4), z(i+4), w(i+4)
line -(p, q)
next
f = 1
k = 8
i = 0+k
proj x(i), y(i), z(i), w(i)
pset (p, q), _rgb(255,0,0)
for i=1+k to 3+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
next
i = 0+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
i = 4+k
proj x(i), y(i), z(i), w(i)
pset (p, q), _rgb(255,0,0)
for i=4+k to 7+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
next
i = 4+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
for i=0+k to 3+k
proj x(i), y(i), z(i), w(i)
pset (p, q), _rgb(255,0,0)
proj x(i+4), y(i+4), z(i+4), w(i+4)
line -(p, q), _rgb(255,0,0)
next
for i=0 to 7
f = 0
proj x(i), y(i), z(i), w(i)
pset (p, q)
f = 1
proj x(i+k), y(i+k), z(i+k), w(i+k)
line -(p, q)
next
_display
_limit 50
next
loop
sub proj(x, y, z, w)
xx = x
yy = y*cos(t) - w*sin(t)
zz = z
ww = y*sin(t) + w*cos(t)
d2 = 3
w0 = 3
xx = xx*d2/(w0 + ww)
yy = yy*d2/(w0 + ww)
zz = zz*d2/(w0 + ww)
xxx = xx*cos(t) - zz*sin(t)
zzz = xx*sin(t) + zz*cos(t)
xx = xxx
zz = zzz
a = pi/3
b = pi/12
xxx = xx*cos(a) - yy*sin(a)
yyy = xx*sin(a) + yy*cos(a)
xx = xxx
yy = yyy
yyy = yy*cos(b) - zz*sin(b)
zzz = yy*sin(b) + zz*cos(b)
yy = yyy
zz = zzz
xx = 100*xx
yy = 100*yy
zz = 100*zz
p = sw/2 + 2*xx*d/(yy + z0)
q = sh/2 - 2*zz*d/(yy + z0)
end sub
|
|
|
BAM Features: tracking, Q&A, etc. |
Posted by: CharlieJV - 11-08-2022, 01:41 AM - Forum: QBJS, BAM, and Other BASICs
- Replies (6)
|
|
[i]Note: Due to lack of interest in BASIC Anywhere Machine by the QB64 community, and unless interest in BASIC Anywhere Machine picks up, I'm (1) suspending posting updates about BASIC Anywhere Machine in the QB64(pe) forum and (2) suspending efforts to improve BASIC Anywhere Machine's compatibility with QB64/QB64(pe). If anybody wants to discuss BAM, I'm there for you, but I'm otherwise not bringing up my project.[/i]
Newly added to BASIC Anywhere Machine: Task Management
Newly added to "On the radar": - Ideas Management (A placeholder to manage ideas which may, or may not, turn into tasks, or requirements, or whatever)
Implemented:
On the radar:
|
|
|
What's your Wheel House? |
Posted by: Pete - 11-07-2022, 10:29 PM - Forum: General Discussion
- Replies (7)
|
|
Some folks mostly love to use programs, others love to develop them.
Out of curiosity, do you think if we had a lot of usable libraries on the boards, would you use them to build your programs, or prefer to make your own routines?
Pete
|
|
|
QBJS v0.6.0 Release |
Posted by: dbox - 11-07-2022, 01:43 PM - Forum: QBJS, BAM, and Other BASICs
- Replies (32)
|
|
Hi All,
The latest version of QBJS (0.6.0) is now available. Here are some of the highlights for this release:
File I/O Support
Support has been added for standard QBasic file input/output. QBJS now has a virtual file system that supports most file system operations. As part of this update there is now a File tab in the console to manage the virtual file system. Files can be dragged into the currently selected folder and downloaded by clicking the file name.
What is supported so far:
- INPUT, OUTPUT, APPEND and BINARY file modes
What is NOT supported yet:
- RANDOM file mode
Project Support
Now more complex projects can be managed and shared in QBJS. There is a new toolbar which allows you to open and save either individual .bas source files or a .zip file containing an entire project. Additionally, you can share publicly published projects with the src parameter. Here are a couple of examples:
- Simple Project Example
- Sleighless
Expanded Set of QB/QB64 Keywords
25 new keywords have been included with this release:
_CWD$, _DirExists, _FileExists, _OS$, _StartDir, ChDir, Close, EOF, Files, FreeFile, Get, Input (file statement), Kill, Line Input (file statement), LOF, MkDir, Open, Print (file statement), Put, Name, RmDir, Seek, Write, Write (file statement), XOR (bitwise)
See the full release announcement for a complete list of fixes and enhancements.
Download the latest version of QBJS at: https://github.com/boxgaming/qbjs/releases/latest
Try it out online here: https://qbjs.org
|
|
|
QBJS Complex Numbers |
Posted by: vince - 11-07-2022, 09:03 AM - Forum: QBJS, BAM, and Other BASICs
- No Replies
|
|
some basic complex math routines to get started
Code: (Select All) const sw = 1024
const sh = 768
dim shared pi
pi = 4*atn(1)
zoom = 140
screen _newimage(sw, sh, 32)
dim z(1), w(1), p(1), q(1), f(1), g(1)
for yy=0 to sh
for xx=0 to sw
x = (xx - sw/2)/zoom
y = (sh/2 - yy)/zoom
i=0
select case i
case 0
cnum p, x + 1, y - 1
cnum q, x + 1, y + 1
cnum z, 1, 0
cmul w, z, p
cnum z, w(0), w(1)
cmul w, z, q
cnum g, x - 1, y
cnum z, w(0), w(1)
cdiv w, z, g
'pset (xx, yy), checker(w)
pset (xx, yy), hue1(w)
case 1
'cnum z, exp(1), 0
cnum z, x, y
'cnum w, x, y
ccos w, z
'cexp w, z, w
pset (xx, yy), checker(w)
case 2
n=10
cnum g, 0, 0
for j=0 to n-1
'C: z(t)
p(0) = 1.5*cos(j*2*pi/n)
p(1) = 1.5*sin(j*2*pi/n)
'f(z(t))
csin w, p
'cnum f, exp(1), 0
'cexp w, f, w
'f(z)/(z - z0)^(n + 1)
cnum q, p(0) - x, p(1) - y
cnum f, 2, 0
cexp q, q, f
cdiv w, w, q
'dz/dt
cnum q, -1.5*sin(j*2*pi/n), 1.5*cos(j*2*pi/n)
cmul w, w, q
if j=0 or j=n - 1 then
g(0) = g(0) + 0.5*w(0)
g(1) = g(1) + 0.5*w(1)
else
g(0) = g(0) + 0.5*w(0)
g(1) = g(1) + 0.5*w(1)
end if
next
'dt
w(0) = g(0)*2*pi/n
w(1) = g(1)*2*pi/n
'1/(2 pi i)
cnum q, 0, -1/(2*pi)
cmul w, w, q
'n!
w(0) = 1*w(0)
w(1) = 1*w(1)
pset (xx, yy), checker(w)
case 3
cnum z, x + 1, y
cnum w, x - 1, y
zz = checker(z)
if zz = 0 then
else
pset (xx, yy), zz
end if
ww = checker(w)
if ww = 0 then
else
pset (xx, yy), ww
end if
'pset (xx, yy), checker(z)' + checker(w)
'pset (xx, yy), hue1(w)
end select
next
next
'n=100
'for a=0 to 2*pi step 2*pi/n
' x = 1.5*cos(a)
' y = 1.5*sin(a)
' circle (x*zoom + sw/2, sh/2 - y*zoom), 3, _rgb(255,255,0)
'next
'sleep
system
function hue1( z() )
m = sqr(z(0)*z(0) + z(1)*z(1))
a = (pi + _atan2(z(1), z(0))) / (2*_pi)
'dim rr, gg, bb
'hue(v) ( .6 + .6 * cos( 2.*PI*(v) + vec3(0,-2.*PI/3.,2.*PI/3.)))
rr = 0.5 - 0.5*sin(2*pi*a - pi/2)
gg = (0.5 + 0.5*sin(2*pi*a*1.5 - pi/2)) * (a < 0.66)
bb = (0.5 + 0.5*sin(2*pi*a*1.5 + pi/2)) * (a > 0.33)
'polar contouring
n = 16
mm = (m*500) mod 500
pp = abs(a*n - int(a*n))
rr = rr - 0.0005*mm - 0.14*pp
gg = gg - 0.0005*mm - 0.14*pp
bb = bb - 0.0005*mm - 0.14*pp
hue1 = _rgb(255*rr, 255*gg, 255*bb)
end function
function checker(z())
if 0 then
x = z(0)
y = z(1)
else
x = _atan2(z(1), z(0))/(pi/8)
y = sqr(z(0)*z(0) + z(1)*z(1))
end if
a = 2*(abs(x - int(x)))
'b = 2*(abs(y - int(y)))
$If Javascript Then
c = a ^ b;
$End If
if c = 0 then
checker = 0'_rgb(0,0,0)
else
checker = _rgb(255,255,255)
end if
end function
sub cnum( w(), x, y )
w(0) = x
w(1) = y
end sub
sub cmul( w(), z1(), z2() )
x1 = z1(0)
y1 = z1(1)
a1 = z2(0)
b1 = z2(1)
w(0) = x1*a1 - y1*b1
w(1) = x1*b1 + y1*a1
end sub
sub cdiv( w(), z1(), z2() )
x1 = z1(0)
y1 = z1(1)
a1 = z2(0)
b1 = z2(1)
d1 = a1*a1 + b1*b1
w(0) = (x1*a1 + y1*b1)/d1
w(1) = (y1*a1 - x1*b1)/d1
end sub
sub cexp( w(), z1(), z2() )
x1 = z1(0)
y1 = z1(1)
a1 = z2(0)
b1 = z2(1)
lnz = x1*x1 + y1*y1
if lnz = 0 then
w(0) = 0
w(1) = 0
else
lnz = 0.5*log(lnz)
argz = _atan2(y1, x1)
mz = exp(a1*lnz - b1*argz)
az = a1*argz + b1*lnz
w(0) = mz*cos(az)
w(1) = mz*sin(az)
end if
end sub
function cosh(x)
cosh = 0.5*(exp(x) + exp(-x))
end function
function sinh(x)
sinh = 0.5*(exp(x) - exp(-x))
end function
sub csin( w(), z1() )
x1 = z1(0)
y1 = z1(1)
w(0) = sin(x1)*cosh(y1)
w(1) = cos(x1)*sinh(y1)
end sub
sub ccos( w(), z1() )
x1 = z1(0)
y1 = z1(1)
w(0) = cos(x1)*cosh(y1)
w(1) =-sin(x1)*sinh(y1)
end sub
|
|
|
QBJS Sextris |
Posted by: vince - 11-07-2022, 08:57 AM - Forum: QBJS, BAM, and Other BASICs
- No Replies
|
|
Block stacking game
Code: (Select All) 'todo: optimize shape rotations around center of mass, otherwise is playable
randomize timer
'pentris
'dim shared piece(17, 2, 4)
'sextris
dim shared piece(34, 2, 5)
dim shared piece_color(34)
dim shared size, sw, sh
'big x and y
dim shared xx, yy
size = 25
sw = 16
sh = 35
redim shared board(sw - 1, sh - 1)
piece(0,0,0)=0: piece(0,1,0)=1: piece(0,2,0)=0
piece(0,0,1)=0: piece(0,1,1)=1: piece(0,2,1)=0
piece(0,0,2)=0: piece(0,1,2)=1: piece(0,2,2)=0
piece(0,0,3)=0: piece(0,1,3)=1: piece(0,2,3)=0
piece(0,0,4)=0: piece(0,1,4)=1: piece(0,2,4)=0
piece(0,0,5)=0: piece(0,1,5)=1: piece(0,2,5)=0
piece(1,0,0)=0: piece(1,1,0)=0: piece(1,2,0)=0
piece(1,0,1)=0: piece(1,1,1)=1: piece(1,2,1)=1
piece(1,0,2)=0: piece(1,1,2)=1: piece(1,2,2)=0
piece(1,0,3)=0: piece(1,1,3)=1: piece(1,2,3)=0
piece(1,0,4)=0: piece(1,1,4)=1: piece(1,2,4)=0
piece(1,0,5)=0: piece(1,1,5)=1: piece(1,2,5)=0
piece(2,0,0)=0: piece(2,1,0)=0: piece(2,2,0)=0
piece(2,0,1)=0: piece(2,1,1)=1: piece(2,2,1)=0
piece(2,0,2)=0: piece(2,1,2)=1: piece(2,2,2)=1
piece(2,0,3)=0: piece(2,1,3)=1: piece(2,2,3)=0
piece(2,0,4)=0: piece(2,1,4)=1: piece(2,2,4)=0
piece(2,0,5)=0: piece(2,1,5)=1: piece(2,2,5)=0
piece(3,0,0)=0: piece(3,1,0)=0: piece(3,2,0)=0
piece(3,0,1)=0: piece(3,1,1)=1: piece(3,2,1)=0
piece(3,0,2)=0: piece(3,1,2)=1: piece(3,2,2)=0
piece(3,0,3)=0: piece(3,1,3)=1: piece(3,2,3)=1
piece(3,0,4)=0: piece(3,1,4)=1: piece(3,2,4)=0
piece(3,0,5)=0: piece(3,1,5)=1: piece(3,2,5)=0
piece(4,0,0)=0: piece(4,1,0)=0: piece(4,2,0)=0
piece(4,0,1)=0: piece(4,1,1)=0: piece(4,2,1)=1
piece(4,0,2)=0: piece(4,1,2)=1: piece(4,2,2)=1
piece(4,0,3)=0: piece(4,1,3)=1: piece(4,2,3)=0
piece(4,0,4)=0: piece(4,1,4)=1: piece(4,2,4)=0
piece(4,0,5)=0: piece(4,1,5)=1: piece(4,2,5)=0
piece(5,0,0)=0: piece(5,1,0)=0: piece(5,2,0)=0
piece(5,0,1)=0: piece(5,1,1)=0: piece(5,2,1)=0
piece(5,0,2)=0: piece(5,1,2)=1: piece(5,2,2)=1
piece(5,0,3)=0: piece(5,1,3)=1: piece(5,2,3)=1
piece(5,0,4)=0: piece(5,1,4)=1: piece(5,2,4)=0
piece(5,0,5)=0: piece(5,1,5)=1: piece(5,2,5)=0
piece(6,0,0)=0: piece(6,1,0)=0: piece(6,2,0)=0
piece(6,0,1)=0: piece(6,1,1)=0: piece(6,2,1)=0
piece(6,0,2)=0: piece(6,1,2)=1: piece(6,2,2)=1
piece(6,0,3)=0: piece(6,1,3)=1: piece(6,2,3)=0
piece(6,0,4)=0: piece(6,1,4)=1: piece(6,2,4)=1
piece(6,0,5)=0: piece(6,1,5)=1: piece(6,2,5)=0
'''
piece(7,0,0)=0: piece(7,1,0)=0: piece(7,2,0)=0
piece(7,0,1)=0: piece(7,1,1)=0: piece(7,2,1)=0
piece(7,0,2)=0: piece(7,1,2)=1: piece(7,2,2)=1
piece(7,0,3)=0: piece(7,1,3)=1: piece(7,2,3)=0
piece(7,0,4)=0: piece(7,1,4)=1: piece(7,2,4)=0
piece(7,0,5)=0: piece(7,1,5)=1: piece(7,2,5)=1
piece(8,0,0)=0: piece(8,1,0)=0: piece(8,2,0)=0
piece(8,0,1)=0: piece(8,1,1)=0: piece(8,2,1)=0
piece(8,0,2)=0: piece(8,1,2)=1: piece(8,2,2)=0
piece(8,0,3)=0: piece(8,1,3)=1: piece(8,2,3)=1
piece(8,0,4)=0: piece(8,1,4)=1: piece(8,2,4)=1
piece(8,0,5)=0: piece(8,1,5)=1: piece(8,2,5)=0
piece(9,0,0)=0: piece(9,1,0)=0: piece(9,2,0)=0
piece(9,0,1)=0: piece(9,1,1)=0: piece(9,2,1)=0
piece(9,0,2)=1: piece(9,1,2)=1: piece(9,2,2)=1
piece(9,0,3)=1: piece(9,1,3)=0: piece(9,2,3)=0
piece(9,0,4)=1: piece(9,1,4)=0: piece(9,2,4)=0
piece(9,0,5)=1: piece(9,1,5)=0: piece(9,2,5)=0
piece(10,0,0)=0: piece(10,1,0)=0: piece(10,2,0)=0
piece(10,0,1)=0: piece(10,1,1)=0: piece(10,2,1)=0
piece(10,0,2)=1: piece(10,1,2)=0: piece(10,2,2)=0
piece(10,0,3)=1: piece(10,1,3)=1: piece(10,2,3)=1
piece(10,0,4)=1: piece(10,1,4)=0: piece(10,2,4)=0
piece(10,0,5)=1: piece(10,1,5)=0: piece(10,2,5)=0
piece(11,0,0)=0: piece(11,1,0)=0: piece(11,2,0)=0
piece(11,0,1)=0: piece(11,1,1)=0: piece(11,2,1)=0
piece(11,0,2)=1: piece(11,1,2)=1: piece(11,2,2)=1
piece(11,0,3)=0: piece(11,1,3)=1: piece(11,2,3)=0
piece(11,0,4)=0: piece(11,1,4)=1: piece(11,2,4)=0
piece(11,0,5)=0: piece(11,1,5)=1: piece(11,2,5)=0
piece(12,0,0)=0: piece(12,1,0)=0: piece(12,2,0)=0
piece(12,0,1)=0: piece(12,1,1)=0: piece(12,2,1)=0
piece(12,0,2)=0: piece(12,1,2)=1: piece(12,2,2)=1
piece(12,0,3)=1: piece(12,1,3)=1: piece(12,2,3)=0
piece(12,0,4)=0: piece(12,1,4)=1: piece(12,2,4)=0
piece(12,0,5)=0: piece(12,1,5)=1: piece(12,2,5)=0
piece(13,0,0)=0: piece(13,1,0)=0: piece(13,2,0)=0
piece(13,0,1)=0: piece(13,1,1)=0: piece(13,2,1)=0
piece(13,0,2)=0: piece(13,1,2)=1: piece(13,2,2)=1
piece(13,0,3)=0: piece(13,1,3)=1: piece(13,2,3)=0
piece(13,0,4)=1: piece(13,1,4)=1: piece(13,2,4)=0
piece(13,0,5)=0: piece(13,1,5)=1: piece(13,2,5)=0
'''
piece(14,0,0)=0: piece(14,1,0)=0: piece(14,2,0)=0
piece(14,0,1)=0: piece(14,1,1)=0: piece(14,2,1)=0
piece(14,0,2)=0: piece(14,1,2)=1: piece(14,2,2)=1
piece(14,0,3)=0: piece(14,1,3)=1: piece(14,2,3)=0
piece(14,0,4)=0: piece(14,1,4)=1: piece(14,2,4)=0
piece(14,0,5)=1: piece(14,1,5)=1: piece(14,2,5)=0
piece(15,0,0)=0: piece(15,1,0)=0: piece(15,2,0)=0
piece(15,0,1)=0: piece(15,1,1)=0: piece(15,2,1)=0
piece(15,0,2)=0: piece(15,1,2)=1: piece(15,2,2)=0
piece(15,0,3)=0: piece(15,1,3)=1: piece(15,2,3)=1
piece(15,0,4)=1: piece(15,1,4)=1: piece(15,2,4)=0
piece(15,0,5)=0: piece(15,1,5)=1: piece(15,2,5)=0
piece(16,0,0)=0: piece(16,1,0)=0: piece(16,2,0)=0
piece(16,0,1)=0: piece(16,1,1)=0: piece(16,2,1)=0
piece(16,0,2)=0: piece(16,1,2)=1: piece(16,2,2)=0
piece(16,0,3)=1: piece(16,1,3)=1: piece(16,2,3)=1
piece(16,0,4)=0: piece(16,1,4)=1: piece(16,2,4)=0
piece(16,0,5)=0: piece(16,1,5)=1: piece(16,2,5)=0
piece(17,0,0)=0: piece(17,1,0)=0: piece(17,2,0)=0
piece(17,0,1)=0: piece(17,1,1)=0: piece(17,2,1)=0
piece(17,0,2)=0: piece(17,1,2)=1: piece(17,2,2)=0
piece(17,0,3)=1: piece(17,1,3)=1: piece(17,2,3)=1
piece(17,0,4)=1: piece(17,1,4)=0: piece(17,2,4)=0
piece(17,0,5)=1: piece(17,1,5)=0: piece(17,2,5)=0
piece(18,0,0)=0: piece(18,1,0)=0: piece(18,2,0)=0
piece(18,0,1)=0: piece(18,1,1)=0: piece(18,2,1)=0
piece(18,0,2)=0: piece(18,1,2)=1: piece(18,2,2)=0
piece(18,0,3)=1: piece(18,1,3)=1: piece(18,2,3)=0
piece(18,0,4)=1: piece(18,1,4)=0: piece(18,2,4)=0
piece(18,0,5)=1: piece(18,1,5)=1: piece(18,2,5)=0
piece(19,0,0)=0: piece(19,1,0)=0: piece(19,2,0)=0
piece(19,0,1)=0: piece(19,1,1)=1: piece(19,2,1)=0
piece(19,0,2)=0: piece(19,1,2)=1: piece(19,2,2)=0
piece(19,0,3)=1: piece(19,1,3)=1: piece(19,2,3)=0
piece(19,0,4)=1: piece(19,1,4)=0: piece(19,2,4)=0
piece(19,0,5)=1: piece(19,1,5)=0: piece(19,2,5)=0
piece(20,0,0)=0: piece(20,1,0)=0: piece(20,2,0)=0
piece(20,0,1)=0: piece(20,1,1)=0: piece(20,2,1)=0
piece(20,0,2)=0: piece(20,1,2)=1: piece(20,2,2)=0
piece(20,0,3)=1: piece(20,1,3)=1: piece(20,2,3)=0
piece(20,0,4)=1: piece(20,1,4)=1: piece(20,2,4)=0
piece(20,0,5)=1: piece(20,1,5)=0: piece(20,2,5)=0
'''
piece(21,0,0)=0: piece(21,1,0)=0: piece(21,2,0)=0
piece(21,0,1)=0: piece(21,1,1)=0: piece(21,2,1)=0
piece(21,0,2)=0: piece(21,1,2)=0: piece(21,2,2)=0
piece(21,0,3)=1: piece(21,1,3)=1: piece(21,2,3)=0
piece(21,0,4)=1: piece(21,1,4)=1: piece(21,2,4)=0
piece(21,0,5)=1: piece(21,1,5)=1: piece(21,2,5)=0
piece(22,0,0)=0: piece(22,1,0)=0: piece(22,2,0)=0
piece(22,0,1)=0: piece(22,1,1)=0: piece(22,2,1)=0
piece(22,0,2)=0: piece(22,1,2)=0: piece(22,2,2)=1
piece(22,0,3)=1: piece(22,1,3)=1: piece(22,2,3)=1
piece(22,0,4)=0: piece(22,1,4)=1: piece(22,2,4)=0
piece(22,0,5)=0: piece(22,1,5)=1: piece(22,2,5)=0
piece(23,0,0)=0: piece(23,1,0)=0: piece(23,2,0)=0
piece(23,0,1)=0: piece(23,1,1)=0: piece(23,2,1)=0
piece(23,0,2)=0: piece(23,1,2)=0: piece(23,2,2)=0
piece(23,0,3)=1: piece(23,1,3)=1: piece(23,2,3)=1
piece(23,0,4)=0: piece(23,1,4)=1: piece(23,2,4)=1
piece(23,0,5)=0: piece(23,1,5)=1: piece(23,2,5)=0
piece(24,0,0)=0: piece(24,1,0)=0: piece(24,2,0)=0
piece(24,0,1)=0: piece(24,1,1)=0: piece(24,2,1)=0
piece(24,0,2)=0: piece(24,1,2)=0: piece(24,2,2)=1
piece(24,0,3)=0: piece(24,1,3)=1: piece(24,2,3)=1
piece(24,0,4)=1: piece(24,1,4)=1: piece(24,2,4)=0
piece(24,0,5)=0: piece(24,1,5)=1: piece(24,2,5)=0
piece(25,0,0)=0: piece(25,1,0)=0: piece(25,2,0)=0
piece(25,0,1)=0: piece(25,1,1)=0: piece(25,2,1)=0
piece(25,0,2)=0: piece(25,1,2)=0: piece(25,2,2)=1
piece(25,0,3)=1: piece(25,1,3)=1: piece(25,2,3)=1
piece(25,0,4)=1: piece(25,1,4)=0: piece(25,2,4)=0
piece(25,0,5)=1: piece(25,1,5)=0: piece(25,2,5)=0
piece(26,0,0)=0: piece(26,1,0)=0: piece(26,2,0)=0
piece(26,0,1)=0: piece(26,1,1)=0: piece(26,2,1)=0
piece(26,0,2)=0: piece(26,1,2)=1: piece(26,2,2)=1
piece(26,0,3)=1: piece(26,1,3)=1: piece(26,2,3)=0
piece(26,0,4)=1: piece(26,1,4)=0: piece(26,2,4)=0
piece(26,0,5)=1: piece(26,1,5)=0: piece(26,2,5)=0
piece(27,0,0)=0: piece(27,1,0)=0: piece(27,2,0)=0
piece(27,0,1)=0: piece(27,1,1)=0: piece(27,2,1)=0
piece(27,0,2)=0: piece(27,1,2)=0: piece(27,2,2)=0
piece(27,0,3)=1: piece(27,1,3)=1: piece(27,2,3)=1
piece(27,0,4)=1: piece(27,1,4)=0: piece(27,2,4)=1
piece(27,0,5)=1: piece(27,1,5)=0: piece(27,2,5)=0
'''
piece(28,0,0)=0: piece(28,1,0)=0: piece(28,2,0)=0
piece(28,0,1)=0: piece(28,1,1)=0: piece(28,2,1)=0
piece(28,0,2)=0: piece(28,1,2)=0: piece(28,2,2)=0
piece(28,0,3)=1: piece(28,1,3)=0: piece(28,2,3)=1
piece(28,0,4)=1: piece(28,1,4)=1: piece(28,2,4)=1
piece(28,0,5)=1: piece(28,1,5)=0: piece(28,2,5)=0
piece(29,0,0)=0: piece(29,1,0)=0: piece(29,2,0)=0
piece(29,0,1)=0: piece(29,1,1)=0: piece(29,2,1)=0
piece(29,0,2)=0: piece(29,1,2)=0: piece(29,2,2)=0
piece(29,0,3)=1: piece(29,1,3)=0: piece(29,2,3)=1
piece(29,0,4)=1: piece(29,1,4)=1: piece(29,2,4)=1
piece(29,0,5)=0: piece(29,1,5)=1: piece(29,2,5)=0
piece(30,0,0)=0: piece(30,1,0)=0: piece(30,2,0)=0
piece(30,0,1)=0: piece(30,1,1)=0: piece(30,2,1)=0
piece(30,0,2)=0: piece(30,1,2)=1: piece(30,2,2)=1
piece(30,0,3)=0: piece(30,1,3)=1: piece(30,2,3)=0
piece(30,0,4)=1: piece(30,1,4)=1: piece(30,2,4)=0
piece(30,0,5)=1: piece(30,1,5)=0: piece(30,2,5)=0
piece(31,0,0)=0: piece(31,1,0)=0: piece(31,2,0)=0
piece(31,0,1)=0: piece(31,1,1)=0: piece(31,2,1)=0
piece(31,0,2)=0: piece(31,1,2)=0: piece(31,2,2)=0
piece(31,0,3)=1: piece(31,1,3)=0: piece(31,2,3)=0
piece(31,0,4)=1: piece(31,1,4)=1: piece(31,2,4)=0
piece(31,0,5)=1: piece(31,1,5)=1: piece(31,2,5)=1
piece(32,0,0)=0: piece(32,1,0)=0: piece(32,2,0)=0
piece(32,0,1)=0: piece(32,1,1)=0: piece(32,2,1)=0
piece(32,0,2)=0: piece(32,1,2)=0: piece(32,2,2)=0
piece(32,0,3)=0: piece(32,1,3)=1: piece(32,2,3)=0
piece(32,0,4)=1: piece(32,1,4)=1: piece(32,2,4)=1
piece(32,0,5)=1: piece(32,1,5)=1: piece(32,2,5)=0
piece(33,0,0)=0: piece(33,1,0)=0: piece(33,2,0)=0
piece(33,0,1)=0: piece(33,1,1)=0: piece(33,2,1)=0
piece(33,0,2)=0: piece(33,1,2)=0: piece(33,2,2)=0
piece(33,0,3)=0: piece(33,1,3)=0: piece(33,2,3)=1
piece(33,0,4)=1: piece(33,1,4)=1: piece(33,2,4)=1
piece(33,0,5)=1: piece(33,1,5)=1: piece(33,2,5)=0
piece(34,0,0)=0: piece(34,1,0)=0: piece(34,2,0)=0
piece(34,0,1)=0: piece(34,1,1)=0: piece(34,2,1)=0
piece(34,0,2)=0: piece(34,1,2)=0: piece(34,2,2)=1
piece(34,0,3)=0: piece(34,1,3)=1: piece(34,2,3)=1
piece(34,0,4)=1: piece(34,1,4)=1: piece(34,2,4)=0
piece(34,0,5)=1: piece(34,1,5)=0: piece(34,2,5)=0
screen _newimage(sw*size, sh*size, 32)
piece_color(0) = _rgb(255,0,0)
piece_color(1) = _rgb(255,145,0)
piece_color(2) = _rgb(255,200,211)
piece_color(3) = _rgb(0,255,220)
piece_color(4) = _rgb(0,230,255)
piece_color(5) = _rgb(0,170,10)
piece_color(6) = _rgb(0,250,20)
piece_color(7) = _rgb(128,230,0)
piece_color(8) = _rgb(80,150,0)
piece_color(9) = _rgb(0,200,0)
piece_color(10) = _rgb(50,160,170)
piece_color(11) = _rgb(50,110,175)
piece_color(12) = _rgb(50,50,175)
piece_color(13) = _rgb(110,50,175)
piece_color(14) = _rgb(210,0,255)
piece_color(15) = _rgb(110,0,130)
piece_color(16) = _rgb(255,0,140)
piece_color(17) = _rgb(170,0,100)
piece_color(18) = _rgb(50,160,170)
piece_color(19) = _rgb(50,110,175)
piece_color(20) = _rgb(50,50,175)
piece_color(21) = _rgb(110,50,175)
piece_color(22) = _rgb(210,0,255)
piece_color(23) = _rgb(110,0,130)
piece_color(24) = _rgb(255,0,140)
piece_color(25) = _rgb(170,0,100)
piece_color(26) = _rgb(50,160,170)
piece_color(27) = _rgb(50,110,175)
piece_color(28) = _rgb(50,50,175)
piece_color(29) = _rgb(110,50,175)
piece_color(30) = _rgb(210,0,255)
piece_color(31) = _rgb(110,0,130)
piece_color(32) = _rgb(255,0,140)
piece_color(33) = _rgb(170,0,100)
piece_color(34) = _rgb(170,0,100)
dim t as double
redraw = 1
speed = 3
lines = 0
pause = 0
putpiece = 0
startx = (sw - 4)/2
pn = int(rnd*35)
px = startx
py = -2
rot = 0
dim title$
title$ = "lines="+ltrim$(str$(lines))+",speed="++ltrim$(str$(speed))
_title title$
t = timer
do
if (timer - t) > (1/speed) and not pause then
if valid(pn, px, py + 1, rot) then py = py + 1 else putpiece = 1
t = timer
redraw = 1
end if
if putpiece then
if valid(pn, px, py, rot) then
n = place(pn, px, py, rot)
if n then
lines = lines + n
title$ = "lines="+ltrim$(str$(lines))+",speed="++ltrim$(str$(speed))
_title title$
end if
end if
pn = int(rnd*35)
px = startx
py = -2
rot = 0
putpiece = 0
redraw = 1
if not valid(pn, px, py, rot) then
for y=0 to sh-1
for x=0 to sw-1
board(x, y) = 0
next
next
lines = 0
title$ = "lines="+ltrim$(str$(lines))+",speed="++ltrim$(str$(speed))
_title title$
end if
end if
if redraw then
line (0,0)-(sw*size, sh*size),_rgb(0,0,0),bf
for y=0 to sh - 1
for x=0 to sw - 1
if board(x, y) <> 0 then
line (x*size, y*size)-step(size-2, size-2), piece_color(board(x, y)-1), bf
else
line (x*size, y*size)-step(size-2, size-2), _rgb(50,50,50), b
end if
next
next
for y=0 to 5
for x=0 to 2
rotate x, y, pn, rot
if piece(pn, x, y) then line ((px + xx)*size, (py + yy)*size)-step(size-2, size-2), piece_color(pn), bf
next
next
_display
redraw = 0
end if
k = _keyhit
if k then
shift = _keydown(100304) or _keydown(100303)
select case k
case 18432 'up
if valid(pn, px, py, (rot + 1) mod 4) then rot = (rot + 1) mod 4
pause = 0
case 19200 'left
if shift then
for x2=0 to sw-1
if not valid(pn, px - x2, py, rot) then exit for
next
px = px - x2 + 1
else
if valid(pn, px - 1, py, rot) then px = px - 1
end if
pause = 0
case 19712 'right
if shift then
for x2=px to sw-1
if not valid(pn, x2, py, rot) then exit for
next
px = x2 - 1
else
if valid(pn, px + 1, py, rot) then px = px + 1
end if
pause = 0
case 20480, 32 'down
if shift or k = 32 then
for y2=py to sh-1
if not valid(pn, px, y2, rot) then exit for
next
py = y2 - 1
putpiece = 1
else
if valid(pn, px, py + 1, rot) then py = py + 1
end if
pause = 0
case 112 'p
pause = not pause
case 13 'enter
for y=0 to sh-1
for x=0 to sw-1
board(x, y) = 0
next
next
pn = int(rnd*35)
px = startx
py = -2
rot = 0
putpiece = 0
lines = 0
title$ = "lines="+ltrim$(str$(lines))+",speed="++ltrim$(str$(speed))
_title title$
case 43, 61 'plus
if speed < 100 then
speed = speed + 1
title$ = "lines="+ltrim$(str$(lines))+",speed="++ltrim$(str$(speed))
_title title$
end if
case 95, 45
if speed > 1 then
speed = speed - 1
title$ = "lines="+ltrim$(str$(lines))+",speed="++ltrim$(str$(speed))
_title title$
end if
case 27
exit do
end select
redraw = 1
end if
_limit 60
loop
system
sub rotate(x, y, pn, rot)
select case pn
case 0
rot_new = rot mod 2
case else
rot_new = rot
end select
select case rot_new
case 0
xx = x
yy = y
case 1
if pn = 0 then
xx = y - 1
yy = 3 - x
elseif pn = 14 or pn = 15 then
xx = y - 1
yy = 3 - x
else
xx = y - 2
yy = 4 - x
end if
case 2
if pn = 14 or pn = 15 then
xx = 2 - x
yy = 4 - y
else
xx = 2 - x
yy = 6 - y
end if
case 3
if pn = 14 or pn = 15 then
xx = 3 - y
yy = x + 1
else
xx = 4 - y
yy = x + 2
end if
end select
end sub
function valid(pn, px, py, rot)
for y=0 to 5
for x=0 to 2
rotate x, y, pn, rot
if py + yy >= 0 then
if piece(pn, x, y) then
if (px + xx >= sw) or (px + xx < 0) then
valid = 0
exit function
end if
if (py + yy >= sh) then
valid = 0
exit function
end if
'if (py >= 0) then
if board(px + xx, py + yy) then
valid = 0
exit function
end if
'end if
end if
end if
next
next
valid = 1
end function
function place(pn, px, py, rot)
lines2 = 0
for y=0 to 5
for x=0 to 2
rotate x, y, pn, rot
if py + yy >= 0 then
if piece(pn, x, y) then board(px + xx, py + yy) = pn + 1
end if
next
next
'clear lines
for y=py-6 to py+6
if y>=0 and y<sh then
clr = 1
for x=0 to sw - 1
if board(x, y) = 0 then
clr = 0
exit for
end if
next
if clr then
lines2 = lines2 + 1
for y2=y to 1 step -1
for x=0 to sw-1
board(x, y2) = board(x, y2-1)
next
next
end if
end if
next
place = lines2
end function
|
|
|
DAY 002: CVSMBF |
Posted by: SMcNeill - 11-07-2022, 05:10 AM - Forum: Keyword of the Day!
- Replies (7)
|
|
Yay! Today, we get one of those keywords that I personally find utterly useless, but it is what it is.
Let's start by talking about how to decipher that long string of random characters, and try and understand what CVSMBF might actually stand for:
CV -- Convert
S -- SINGLE
M -- Microsoft
B -- Binary
F -- Format
So, what does it do?
It converts a properly formatted string (one stored in Microsoft Binary Format -- which is outdated and obsoleted and thus why I find this to be basically a worthless command, unless one is working with ancient data from the late 70s or early 80s) into a SINGLE precision number.
Let me share an example of this, and its twin function MKSMBF, and then I'll explain a little more about how and where one might use these type commands:
Code: (Select All) a! = 700.2213
Print "Value of a!:"; a!
b$ = MKSMBF$(a!): c$ = MKS$(a!)
Print "Value of a! encoded using MKSMBF$: "; b$
Print "The string above, decoded using CVSMBF:"; CVSMBF(b$)
Print "Value of a! encoded using MKS$: "; c$
Print "The string above, decoded using CVS:"; CVS(c$)
Now you'll notice that I started the above by converting a SINGLE value into a STRING. The reason for this is simple -- I don't know the string representations of the values off the top of my head, so it's just easier to start with a number which I do know how to represent, and then showcase the conversion back and forth.
You'll also notice that, in the example above, I also showcased MKS$ and CVS. These do exactly the same as MKSMBF$ and CVSMBF, with one exception -- they convert to the modern standard SINGLE values and not the antiquated Microsoft Binary Format.
So *WHY* would someone want to convert these values into such odd strings? Why not just use STR$(a!) and be done with it??
STR$() converts a number to a string -- but it basically preserves the formatting of that string. STR$(700.2213) would become " 700.2213" -- an eight digit string.
MKS$ and MKSMBF$ converts a number to a string -- but those strings are *always* going to be 4-bytes in size. The character representation you get is (more or less) going to be exactly the same as that value looks like in memory. (With the exception of MKSMBF which is, as I've said several times, an outdated method of representing the value in memory nowadays.)
123.456789 will convert to a 4-byte string.
1.1 will convert to a 4-byte string.
0 will convert to a 4-byte string.
And why is this 4-byte constant so important for us??
When saving data to the drive FOR BINARY or RANDOM access!!
We can store 100 numbers in a text file, in MKS$ format, and use a total of 400 bytes to store those numbers. Unlike variable length data entries, we can easily access our file and tell instantly where any certain number is in it.
At position 1 in the file is the zero-index number. (Think of my index here as DIM array(0 TO 99), for my 100 numbers.)
At position 5 in the file is the one-index number.
At position 41 in the file is the ten-index number.
At position (p) in the file in the file is the ((p - 1) / 4)-index number.
We convert the value to a set string size, so we can easily track where that value lands inside a larger string or a data file. Set and constant sized data makes data alignment a breeze.
|
|
|
|