Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 308
» Latest member: Donaldvem
» Forum threads: 1,741
» Forum posts: 17,901

Full Statistics

Latest Threads
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 764
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,262
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 316
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155

 
  Finding Pi
Posted by: PhilOfPerth - 11-16-2022, 12:30 AM - Forum: Help Me! - Replies (18)

One for the Math (or ”outside-the-box-thinking”) gurus:  
Given an isoscles triangle ABC, with sides b and c (the sides opposite B and C) both 5 units in length, and with angle A=45degrees, is there a (simple?) way to find the length of side a, without resorting to pre-determined trig tables like sin, cos and tan, or pi
The reason I don’t want to use these is I’m trying to demonstrate how pi relates to the circumference of a circle, so I don’t want to involve anything that relies on pi – that would be “bootstrapping”,  sort of like lifting oneself up by the bootlaces.

Print this item

  Just an example: integration of documentation and IDE
Posted by: CharlieJV - 11-15-2022, 08:27 PM - Forum: General Discussion - No Replies

BAM is a stand-alone wiki for creation of BASIC programs.

It could also contain the programming reference, but that would make BAM heavier than I like, and would make the programming reference heavier than I like.  So the programming reference is a separate wiki.

When I look up documentation, I like to see sample source code, right there, embedded in the documentation.

But I also want to see the running program.

Here is what the programming reference does:

When I lookup a statement or function (let's say "CIRCLE"), the page for that documentation includes an iframe that shows relevant content from the BAM wiki.  The URL for the iframe is dynamically created by the programming reference, setup in a way that the BAM wiki is displayed in a way that matches the needs of the programming reference.  For CIRCLE, the programming reference generates the following URL fed to the iframe to use as SRC parameter, and now I have CIRCLE documentation enhanced with source code examples which I can run, right there:

The dynamically generated URL (click to see what the iframe in the programming reference would display.)

EDIT 2022-11-16: pasted the wrong URL in the code section below.  Fixed.

Code: (Select All)
https://basicanywheremachine.neocities.org/BAM_IDE.html?target=CIRCLE#View%20Program

That is my kind of documentation.  I've never seen this kind of thing done anywhere else, but it my world, it would be the norm.



Attached Files Thumbnail(s)
   
Print this item

  Day 010: _PUTIMAGE (Part II)
Posted by: SMcNeill - 11-15-2022, 07:40 PM - Forum: Keyword of the Day! - No Replies

So _PUTIMAGE has so many paramaters, and works so differently in so many unique situations, and since the conversation is still going so strongly about it and all its options, let's just devote another day to the subject.  

Join us at DAY 009:_PutImage (qb64phoenix.com), and ask all you want about the command and how it interacts with its 8 zillion parameters.  We'll do our best to answer all we can and give examples to help clarify any confusion and illustrate what we're talking about there.  Wink

Print this item

  ERROR: C++ compilation failed.
Posted by: Ed Davis - 11-15-2022, 07:13 PM - Forum: Help Me! - Replies (3)

I'm getting:

Quote:QB64-PE Compiler V3.4.0

Beginning C++ output from QB64 code...
[..............................................    ] 92%
Beginning C++ output from QB64 code...
[..................................................] 100%

Compiling C++ code into EXE...
ERROR: C++ compilation failed.
Check .\internal\temp\compilelog.txt for details.
On:

Code: (Select All)
declare sub main
declare sub get_numeric_args(args() as double)

dim args(4) as double
get_numeric_args(args())

sub get_numeric_args(args() as double)
  args(1) = 123
end sub

compilelog.txt:

Quote:internal\c\c_compiler\bin\c++.exe -O2 -w -std=gnu++11 -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/include -DDEPENDENCY_NO_SOCKETS -DDEPENDENCY_NO_PRINTER -DDEPENDENCY_NO_ICON -DDEPENDENCY_NO_SCREENIMAGE internal\c/qbx.cpp -c -o internal\c/qbx.o
In file included from internal\c/qbx.cpp:2529:
internal\c/..\\temp\\maindata.txt: In function 'void QBMAIN(void*)':
internal\c/..\\temp\\maindata.txt:13:2: error: 'pass1' was not declared in this scope
  pass1;
  ^~~~~
mingw32-make: *** [Makefile:412: internal\c/qbx.o] Error 1


maindata.txt
Code: (Select All)
if (!__ARRAY_DOUBLE_ARGS){
__ARRAY_DOUBLE_ARGS=(ptrszint*)mem_static_malloc(9*ptrsz);
new_mem_lock();
mem_lock_tmp->type=4;
((ptrszint*)__ARRAY_DOUBLE_ARGS)[8]=(ptrszint)mem_lock_tmp;
__ARRAY_DOUBLE_ARGS[4]= 0 ;
__ARRAY_DOUBLE_ARGS[5]=( 4 )-__ARRAY_DOUBLE_ARGS[4]+1;
__ARRAY_DOUBLE_ARGS[6]=1;
__ARRAY_DOUBLE_ARGS[0]=(ptrszint)mem_static_malloc(__ARRAY_DOUBLE_ARGS[5]*8);
memset((void*)(__ARRAY_DOUBLE_ARGS[0]),0,__ARRAY_DOUBLE_ARGS[5]*8);
__ARRAY_DOUBLE_ARGS[2]=1+2;
}
pass1;

main.txt
Code: (Select All)
S_0:;
do{

if(!qbevent)break;evnt(4);}while(r);
do{
SUB_GET_NUMERIC_ARGS(&(pass1=((double*)(__ARRAY_DOUBLE_ARGS[0]))[0]));
if(!qbevent)break;evnt(5);}while(r);
sub_end();
return;
}
void SUB_GET_NUMERIC_ARGS(ptrszint*_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS){
qbs *tqbs;
ptrszint tmp_long;
int32 tmp_fileno;
uint32 qbs_tmp_base=qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer=mem_static_pointer;
uint32 tmp_cmem_sp=cmem_sp;
#include "data1.txt"
mem_lock *sf_mem_lock;
new_mem_lock();
sf_mem_lock=mem_lock_tmp;
sf_mem_lock->type=3;
if (new_error) goto exit_subfunc;
do{
tmp_long=array_check(( 1 )-_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[4],_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[5]);
if (!new_error) ((double*)(_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[0]))[tmp_long]= 123 ;
if(!qbevent)break;evnt(8);}while(r);
exit_subfunc:;
free_mem_lock(sf_mem_lock);
#include "free1.txt"
if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;
cmem_sp=tmp_cmem_sp;
}
void SUB_VWATCH(){
qbs *tqbs;
ptrszint tmp_long;
int32 tmp_fileno;
uint32 qbs_tmp_base=qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer=mem_static_pointer;
uint32 tmp_cmem_sp=cmem_sp;
#include "data2.txt"
mem_lock *sf_mem_lock;
new_mem_lock();
sf_mem_lock=mem_lock_tmp;
sf_mem_lock->type=3;
if (new_error) goto exit_subfunc;
exit_subfunc:;
free_mem_lock(sf_mem_lock);
#include "free2.txt"
if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;
cmem_sp=tmp_cmem_sp;
}

Thanks for any help!

Print this item

  Small 25 line program
Posted by: Gadgetjack - 11-15-2022, 06:40 PM - Forum: Programs - Replies (22)

I found this on the "mmbasic" site and converted it to run on qb64.

Screen 12
n = 255
r = (2 * pi) / 235
x = 0
v = 0
t = 0
sz = 200
s = 0
scrw = 640: scrh = 480
sw = scrw / sz: sh = scrh / sz
offset = scrh / 4.5
Do
    Cls
    For i = 50 To n
        For j = 50 To n
            u = Sin(i + v) + Sin(r * i + x)
            v = Cos(i + v) + Cos(r * i + x)
            x = u + t
            q = scrw / 2 + u * offset
            a = scrh / 2 + v * offset
            PSet (q, a), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
        Next j
    Next i
    t = t + .025
Loop


A screen shot really does not look as good so run it and see.

Print this item

  _TITLE and extended ASCII characters.
Posted by: Pete - 11-15-2022, 04:25 PM - Forum: Help Me! - Replies (37)

I'd like to put CHR$(240), three small horizontal lines, in my title bar, but the _TITLE function cannot convert extended ASCII characters. Is there another method that wold print the 3 horizontal bars into the title bar so it doesn't look like this: ð

Pete

Print this item

  DAY 009:_PutImage
Posted by: bplus - 11-15-2022, 12:00 AM - Forum: Keyword of the Day! - Replies (54)

Here is what it looks like in Wiki:

Quote:_PUTIMAGE [STEP] [(dx1dy1)-[STEP][(dx2dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1sy1)[-STEP][(sx2sy2)]][_SMOOTH]


Yikes! but all we are doing is copying an image from Source Image Handle and rectangular section to Destination Image Handle and rectangular section.

After working with it for awhile now this is what I see:
(for the moment ignore all that STEPping)

_PutImage rectangle, handle, handle, rectangle
2 line rectangles on either end of the parameters.
2 Image handles in the middle of the parameters.

What belongs to what, the order is: D,S,D,S 
D for Destination where you want the rectangle image to go.
S for Source where the image is coming from.
(Kind of an odd sequence but... let us continue.)

Now Rectangle knowledge from working with Line (left, top)-(right, bottom) format comes in handy here (as does the practice with Step). (top, left) corner to (bottom, right) corner defines the rectangle space we are grabbing from Source and then pasting into the Destination.

If you want to fill the whole destination rectangle with the image, leave destination rectangle blank and it will fill the destination image by default. Same with the other end, if you want to use the whole image from the Source handle leave the Source rectangle blank as default.

Where do image handles come from?
Well most important is the current screen image, it is 0 automatically.
You can start an Image handle, say IH& Long Type from
IH& = _LoadImage("Filename.ext")
or
IH& = _NewImage(width, height, colorMode) ' starts a container to draw and/or _PutImage and/or start font and print.

STEP allows you to use the last graphics command (x, y) as the start for the next graphics, a very handy use of step for images is to start with the (x,y) location of the top left corner of the rectangle and -Step(ImageWidth, ImageHeight) instead of adding width to x height to y and finding the absolute position value for the 2nd (x, y).

I think this covers the most common uses of _PutImage there are plenty more details to go over, maybe pick those off with discussion?

Print this item

  Function to calculate FPS with another FPS
Posted by: TerryRitchie - 11-14-2022, 05:37 PM - Forum: Utilities - No Replies

In another post I asked for help in how to determine slower frame rates within a master frame rate for a Pac-Man clone I'm working on. DSMan decoded some of the original Ms. Pac-Man assembly code to reveal how it was being accomplished.

I took that idea and created a function that will determine any frame rate within a master frame rate up to 60 FPS. The function and demo code created to show the function in action are below. With this function you can change the frame rate of a game at any time and still maintain any object's desired slower frame rate.

There is an anomaly in the slope that you'll see as it is drawn. I'm not really sure what to make of this? Any ideas?

Code: (Select All)
' Getting slower frame rates within a master frame rate

DIM F(60) AS INTEGER '           frame counters
DIM FramesPerSecond AS INTEGER ' game's frames per second
DIM Dummy AS INTEGER '           used to set intital data
DIM Frame AS INTEGER '           frame counter
DIM Wipe AS INTEGER '            trigger a clearing of frame counters
DIM x AS INTEGER '               cycle through 1 to FramesPerSecond

'+--------------+
'+ Example code |
'+--------------+

Frame = 0 '                                                         reset frame counter
FramesPerSecond = 60 '                                              set game FPS
SCREEN _NEWIMAGE(640, 480, 32) '                                    create graphics screen
DO '                                                                begin various FPS loop
    Dummy = FPS(-1, FramesPerSecond) '                              create frame data set
    DO '                                                            begin demo loop
        _LIMIT FramesPerSecond '                                    limit loop to game's frame rate
        CLS '                                                       clear the screen
        LOCATE 2, 2: PRINT "Counting down from 60 FPS to 1 FPS" '   inform user of progress
        LOCATE 3, 2: PRINT "Frames per second ="; FramesPerSecond
        LOCATE 4, 1: PRINT INT(Frame / FramesPerSecond) + 1; "of 5 seconds elapsed"
        Frame = Frame + 1 '                                         increment game frame counter
        Wipe = 0 '                                                  reset frame counter wipe trigger
        IF Frame = FramesPerSecond * 5 THEN Frame = 0: Wipe = -1 '  when 5 seconds has elapsed reset frame counter and trigger a wipe
        FOR x = 1 TO FramesPerSecond '                              cycle through all available frame rates
            IF Wipe THEN F(x) = 0 '                                 clear frame counter if wipe triggered
            IF FPS(x, Frame) THEN F(x) = F(x) + 1 '                 is this frame rate's frame active during this frame in the game?
            LINE (10, 200 - x * 2)-(10 + F(x), 200 - x * 2) '       yes, draw a line showing progress of frames counted
        NEXT x
        _DISPLAY '                                                  update the screen with changes
    LOOP UNTIL Wipe OR _KEYDOWN(27) '                               leave when user presses the ESC key or a wipe triggered
    FramesPerSecond = FramesPerSecond - 1 '                         decrease the game's frames per second
    IF FramesPerSecond < 1 THEN FramesPerSecond = 60 '              reset the game's frame rate when needed
LOOP UNTIL _KEYDOWN(27) '                                           leave when user presses the ESC key
SYSTEM '                                                            return to the operating system

'--------------------------------------------------------------------------------------------------------------------------------------------+-----+
FUNCTION FPS (TargetFPS AS INTEGER, Frame AS INTEGER) STATIC '                                                                               | FPS |
    '+---------------------------------------------------------------------------------------------------------------------------------------+-----+
    '| Returns frame rates embedded in a master frame rate                                                                                         |
    '|                                                                                                                                             |
    '| Usage:   dummy   = FPS(-1, 60)           When the target FPS is less than 1 a new data set is created for the requested frame rate          |
    '|          MoveNow = FPS(24, InputFrame)   Will return -1 (TRUE) if input frame is on during the target frame rate                            |
    '|                                                                                                                                             |
    '| Example: IF FPS(Object.FPS, GameFrame) then Move(Object)  Move the object if the object's frame is on within the game's current frame count |
    '+---------------------------------------------------------------------------------------------------------------------------------------------+

    DIM f AS INTEGER '                                  frame counter/value
    DIM b AS SINGLE '                                   bit counter/step rate
    DIM FramesCreated AS INTEGER '                      numer of frames calculated

    IF TargetFPS < 1 THEN '                             calculate frame counters?
        REDIM FPSnum(Frame) AS _UNSIGNED _INTEGER64 '   yes, resize 64bit value array
        REDIM Bit(Frame) AS _UNSIGNED _INTEGER64 '      resize bit value array
        FOR b = 1 TO Frame '                            cycle through bit values
            Bit(b) = 2 ^ (b - 1) '                      calculate value of each bit
        NEXT b
        FOR f = 1 TO Frame '                            cycle through requested frames
            FOR b = 1 TO Frame STEP (Frame / f) '       cycle through bits at current frames per second
                FPSnum(f) = FPSnum(f) + Bit(b) '        calculate which bits are turned on
            NEXT b
        NEXT f
        FramesCreated = Frame '                         remember number of frames created
        EXIT FUNCTION '                                 leave function
    END IF
    IF FramesCreated = 0 THEN EXIT FUNCTION '           no data created yet, leave
    f = Frame '                                         don't modify input value
    IF f < 1 THEN EXIT FUNCTION '                       invalid frame number requested, leave
    IF f > FramesCreated THEN f = f MOD FramesCreated ' keep frame number within range
    IF FPSnum(TargetFPS) AND Bit(f) THEN FPS = -1 '     report if bit is on for current frame in requested FPS

END FUNCTION
'---------------------------------------------------------------------------------------------------------------------------------------------------

Print this item

  DRAW sequence m option
Posted by: PhilOfPerth - 11-14-2022, 08:47 AM - Forum: Help Me! - Replies (22)

Can someone please elaborate a bit on the m x,y (and its related +/- options)  in the draw command? It doesn't get a mention (that I can find) in the Help file, and the Wiki one is pretty unclear. How is it fitted into a draw string, and does it need parentheses, or commas etc?  Confused

Print this item

  BAM "SDLC" Tools
Posted by: CharlieJV - 11-14-2022, 04:43 AM - Forum: QBJS, BAM, and Other BASICs - No Replies

Just in case you geek out on this kind of stuff or are otherwise interested/curious...

SDLC = Software Development Life Cycle

I'm just in the process of laying out BAM's "SDLC" Tools, starting out with the basics:

  • Idea Manager
  • Requirement Manager
  • Change Request Manager
  • Issue Manager
  • Task Manager

Imagine you're working on a complex QB64PE project.

You have an idea, you add it to BAM via the Idea Manager.

That Idea may eventually get deleted/dropped, or may transition into being a new Requirement, or transition into being a Change Request to a previously fulfilled Requirement (a requirement can be a defined need to solve a defined problem, might be a feature, might be a constraint).

If it is a new requirement, eventually that requirement transitions into being a task.  When that task gets completed, it transitions to being a fulfilled requirement AND a completed task.

If a Change Request, that change request is linked to some previously fulfilled requirement, and eventually the change request transitions into being a task.  When done, that task transitions to being a completed task AND an implemented change request.

An issue (problem/bug/whatever), that issue might be related to a previously fulfilled requirement, and eventually the issue transitions into being a task (AND an issue in the process of being resolved).  Or the issue transitions into being a new requirement, and the new requirement eventually transitions into also is a task (AND an issue being resolved).

Something like that.

Just piecing together "flow" to have an idea how to build the "managers" of all this info, and the "editors" for all of this info.

Print this item