flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > Hobby BASIC, a toy language interpreter written in fasm

Goto page Previous  1, 2, 3, 4, 5  Next
Author
Thread Post new topic Reply to topic
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 19 Jan 2021, 20:39
I liked the idea and it was relatively easy to add as a feature.
I have not thought about what issues may arise.
sleepsleep, you stressed me a little now.


Last edited by Picnic on 06 Jul 2021, 14:39; edited 2 times in total
Post 19 Jan 2021, 20:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19876
Location: In your JS exploiting you and your system
revolution 19 Jan 2021, 22:26
Running unaudited code directly from the Internet.

Nothing could possibly go wrong. Razz
Post 19 Jan 2021, 22:26
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 20 Jan 2021, 14:21
Guys, please, don’t say a word about JS Smile
Post 20 Jan 2021, 14:21
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 22 Jan 2021, 13:12
I can't do much at the moment other than leave it as is, or disable it. Smile

There's more ways to the interpreter for the downloading and running a program located on a remote server.
Code:

    url$ = 'https://sites.google.com/site/hobbybasicfiles/TEST.BAS'
    

Code:

    load url$,1
    if V0 = -1 then ? 'load error' : end
    run 'TEST.BAS'
    

or even
Code:

    run url$
    


get the source code
Code:

    a$ = GETSRC(url$)
    


I have uploaded a new version with minor improvements and bug fixes.

A console breakout game (with sounds) included in the examples.

Image


Last edited by Picnic on 22 Jan 2022, 08:39; edited 4 times in total
Post 22 Jan 2021, 13:12
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 02 Jul 2021, 09:42
Hi all,

I have uploaded a new version with minor improvements and bug fixes.

Smaller executable size. The wait command return to milliseconds. The time measurement in microseconds was abandoned. The SPC() function has been removed since the more flexible GEN() function now exists. Improved error messages. A point that I have neglected and HB suffers from. It still needs work but it's much better now. Small internal changes made the interpreter some ms faster overall in my measurements. Minor bug fixes. The interpreter works consistently on Windows XP, 7 and 10. Includes all programs presented in previous posts. The previous version of the Trim(string$) funtion was removing the whitespace and newline characters (0x9,0x20,0xA,0xD) simultaneously left and right on a string but without the option to select a side. The new syntax of the command is Trim(n,string). The values ​​obtained by the variable n are 0, 1 and 2, for TrimLR, TrimL and TrimR respectively. Enum command is also added. More information and examples have been added to the README file.

9/7/2021 - A silent update to version 1.2.1 concerning a fix at the internal ANSI interpreter module. A new command SCROLL is now available which scrolls the console screen buffer up or down, plus some new code examples.

18/7/2021 - A silent update to version 1.2.3. Small internal changes increase stability in Windows 10. Hobby BASIC now runs better on newer versions of Windows, but remains just as functional on XP. The version additions concern the SET command and a new function MATCH (arg, arg_list, ...). More demos has been added and the README file updated with the latest information.

8/8/2021 - A silent update to version 1.2.4. Passing arguments by reference is now possible. To pass an argument by reference, use 'byref' keyword before the argument on the subroutine call. Still under testing though. Also, some bug fixes made.

Passing arguments by value and by reference.
Code:

    sub foo(var,string$,array[])

    ends

    foo(x,a$,a[])                       ! by value
    foo(byref x, byref a$, byref a[])   ! by reference
    


Passing arguments by value and by reference example.
Code:

    a = 100
    b = 200

    print "Before swap, value of a: ",a
    print "Before swap, value of b: ",b

    swap(byref a, byref b)

    print "After swap, value of a: ",a
    print "After swap, value of b: ",b
    end

    sub swap(x,y)

        local temp

        temp = x
        x = y
        y = temp

    ends
    


Select..Case..Endsel has been added.
Code:

    x = 1
    select x
    case 1:
        ? "Choice is 1"
    case 2:
        ? "Choice is 2"
    case 3:
        ? "Choice is 3"
    case :
        ? "Choice is other than 1,2, or 3"
    endsel
    



Text Draw was updated in version 0.5 after some time. It now works more stable (especially in Windows 7) and some new features have been added.

I will show you what it can do now.
I am opening an ANSI file.
We can paint using the character set.
We can change the colors of the image, rotate image, cut it into pieces.
Make copies of the pieces, or insert a new image.
Open long static ANSI images switching from one frame to another.
Text Draw converts an ANSI image to .HB format (always the screen we see) and saves 2 files.
One in the dimension 80x50 and one smaller in the dimension 80x25 (the classic size of the old ANSI files).

Image

Image


Pressing F10 the interpreter does the conversion and exports a loader script.

Image


Bugs and small problems exist.
I used google translate.


Last edited by Picnic on 27 Apr 2022, 08:06; edited 14 times in total
Post 02 Jul 2021, 09:42
View user's profile Send private message Reply with quote
pabloreda



Joined: 24 Jan 2007
Posts: 115
Location: Argentina
pabloreda 03 Jul 2021, 00:05
Very nice project picnic!

congrat!
Post 03 Jul 2021, 00:05
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 14 Feb 2022, 11:48
pabloreda wrote:
Very nice project picnic!

congrat!

Thank you pabloreda.
Note for everyone, I will continue to update the interpreter, but I will stop adding new posts here.
Post 14 Feb 2022, 11:48
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 30 Nov 2022, 10:01
Hello,

This is an arcade puzzle game I wrote in Hobby BASIC.

The aim is to click 4 tiles of the same color and form squares or rectangles as big as you can.
All the tiles that are inside your rectangle will get erased and replaced by new random tiles.
You will get more points for making bigger squares but hurry up, you have limited time to get a high score.
Left Click on four same colored tiles to make a square or a rectangle.
Press Spacebar to get a new board anytime during the game. new
Press Esc to return to the menu, Q to quit.

Image
Post 30 Nov 2022, 10:01
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 27 Dec 2022, 14:17
I just added a new example.

LEDIX is a Sokoban-style game.
Your goal is to push the blue orbs into the marked positions.
Small levels but can be delightfully tricky and surprisingly difficult to solve.
Use keyboard arrows to move, every room has a solution, remember that!
Press 2 to skip to next room, 1 for previous room.
Press spacebar to reset current room.

Image


Last edited by Picnic on 02 Jul 2023, 11:13; edited 1 time in total
Post 27 Dec 2022, 14:17
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 12 Jan 2023, 09:55
Hello, happy new Year to all forum members.

I just added a new example. The game works with the latest version of the Interpreter.

Colorsok is a clone of an old Sokoban-style java game called 'Socolor'
Blocks of the same color need to be pushed all together.

Use keyboard arrows to move.
Press spacebar to reset current room.
Press 2 to skip to next room.
Press 1 for previous room.
Press 4 to undo a move.

Image


Last edited by Picnic on 02 Jul 2023, 11:14; edited 2 times in total
Post 12 Jan 2023, 09:55
View user's profile Send private message Reply with quote
al_Fazline



Joined: 24 Oct 2018
Posts: 54
al_Fazline 12 Jan 2023, 15:08
Hello, Picnic. Is there a way to run it on GNU+Linux without wine/emulation? Windows is kinda dated by now, people are switching away from it.
Post 12 Jan 2023, 15:08
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 13 Jan 2023, 08:05
Hello al_Fazlinem

I'm afraid (i think) that is not possible, Hobby BASIC oriented exclusively to Windows, it heavily uses Windows console functions.
Post 13 Jan 2023, 08:05
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 23 Jan 2023, 14:48
Hello,

I just added a new example. The game works with the latest version of the Interpreter.

D-Star is a clone of an old puzzle game originally written for TI-83/84 calculator.
The object of the game is to collect the yellow diamonds.
You move all the way to the next wall with every move.
You may use spacebar to switch your place with the red block.
Try to clear the board in the least number of moves.
You have 1024 moves limit to complete 10 mazes.

Use keyboard arrows to move.
Press spacebar to switch.
Press 1 to restart room.

Image



11/3/2023

Hello,

Today I added a new example, it's a simple SAME game for Windows console, play with mouse.
The game works with the latest version of the Interpreter.

Move fast and make bunches of same colors.
Left click to replace a tile with its neighbor.
Right spacebar to collect colored bunches.
Press 1 to reset the board.

Image

Image



27/3/2023

Hello,

Today I added a new example, it's a simple Lights Out game for Windows console, play with mouse.
The game works with the latest version of the Interpreter.

The game consists of a 5 by 5 grid of lights.
When the game starts, a stored pattern of these lights is switched on.
Clicking any of the lights will toggle it and the adjacent lights.
The goal is to switch all the lights off, preferably in as few clicks as possible.
Press spacebar to reset current stage.
Press 1 to (circular) skip to next stage.

Image



9/4/2023

Hello,

Today I added a new puzzle, its called Tilt Maze.
The game works with the latest version of the Interpreter.

Collect all the blue squares with the red square.
Use keyboard arrows to move.
Press spacebar to restart current maze.
Press 1 to skip to next maze.
Tile Maze requires Windows 7 or 10.

Image



27/4/2023

Hello,

I added an Othello game written in Hobby BASIC.
Player vs CPU (that chooses random moves).
For Windows 7/10.

Image



2/7/2023

Hello,

I just added a new puzzle game, Box Up.
The game works with the latest version of the Interpreter.

This is a puzzle similar to traditional sokoban.
But here all the boxes are hollow and open on one side.
They can only be moved by pushing from the inside.
There are two sizes of boxes, small and large.
The aim is to push the small red box inside the blue box.
Black boxes may help or hinder your progress.
A small box inside a large box can be pushed together.

Use keyboard arrows to move.
Press 2 to skip to next level.
Press 1 for previous level.
Press spacebar to restart level.
Press S to toggle music on/off.

For Windows 7/10.

Image



18/8/2023

Hello,

I just added a new puzzle game, Freefall.
The game works with the latest version of the Interpreter.

Hobby BASIC now works more stable on Windows 10. Almost all accompanying examples run on Windows 10 without the need to "Use Legacy Console" option.
Right now, only DRAW.BAS and BOXUP.BAS examples need it.


Freefall is a remake of an old Java game.
The aim of this game is to remove all colored shapes from the board.
Keep in mind that colored shapes are always subject to gravity first.
The number of moves you can make in each level is limited.

Click on a shape and move mouse right or left, then release mouse.
Press spacebar to restart room.
Press 2 to skip to next room.
Press 1 for previous room.
Press S to toggle music on/off.

Image




31/8/2023

Hello,

I just added Q, a new puzzle game.
The game works with the latest version of the Interpreter.

Q is a hidden puzzle game inside Ericsson T68i.
The goal is to place the colored marbles in their respective holes.
Click and hold mouse on a marble, choose direction and release mouse.

Press spacebar to restart room.
Press 2 to skip to next room.
Press 1 for previous room.
Press 0 to change window size (default is small).
Press S to toggle music on/off.

Image




21/10/2023

Hello,

I just added BLIX, a new puzzle game.
The game works with the latest version of the Interpreter.

BLIX is a game with a simple target.
Form columns of same-color tiles by scrolling the three rows.
Each scroll costs 2 moves, and each cleared column wins you 1 move.
The game ends when you run out of moves.

Press 1,2,3,4 to restart level anytime: EASY,NORMAL,HARD,EXPERT.
Press Spacebar to scroll the three rows randomly (costs 1 move).
Click on the arrow buttons to scroll a row.
Press S to toggle music on/off.
BLIX requires Windows 7 or later.

Image




26/10/2023

Hello,

I just added Eliminator, a new puzzle game.
The game works with the latest version of the Interpreter.

Eliminator is a remake of a old java applet.
Remove all balls of the same color by lining them up against each other.
You have a small number of moves on each level.
The grey balls cannot be removed.

Use the arrow keys to play.
Press spacebar to restart level.
Press 2 to skip to next level.
Press 1 for previous level.
Press 0 to change window size (default is small).
Press S to toggle music on/off.
Eliminator requires Windows 7 or later.

Image

Press 0 to change window size (default is small) new

Image



23/11/2023

Hello,

I just added RGB Theme Creator, a small application that allows us to create RGB themes for the Windows console.
The program works with the latest 1.7.3 version of the Interpreter.

Press 1 to 7 to change theme.
Click mouse to select and edit a color.
Press space to reload theme.
Press 0 to export theme.
Press Esc to exit.

Image

Image


Last edited by Picnic on 23 Nov 2023, 09:09; edited 1 time in total
Post 23 Jan 2023, 14:48
View user's profile Send private message Reply with quote
386



Joined: 11 Nov 2023
Posts: 28
Location: Ukraine (Ruthenia)
386 15 Nov 2023, 12:01
Wow! It looks great! Smile

But why the 58,5 KB program running tiny examples uses 397 MB of memory? Sad

Could you reduce it to 39,7 MB or, even better, to 3,97 MB?

My system is Windows 7 x64 SP1.
Post 15 Nov 2023, 12:01
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 15 Nov 2023, 17:01
It plays great too, I've tested it on different versions of Windows.
Thanks for the feedback 386 I can definitely reduce it to have very low startup requirements.
Anyway, I uploaded a new version.
The memory footprint should be should be around 30 MB now.


Last edited by Picnic on 15 Nov 2023, 22:48; edited 4 times in total
Post 15 Nov 2023, 17:01
View user's profile Send private message Reply with quote
386



Joined: 11 Nov 2023
Posts: 28
Location: Ukraine (Ruthenia)
386 15 Nov 2023, 22:32
Thanks, Picnic! 30 MB is much better than 397 MB! Smile

Just curious: is it possible to make 3 MB or 300 KB?
Post 15 Nov 2023, 22:32
View user's profile Send private message Reply with quote
386



Joined: 11 Nov 2023
Posts: 28
Location: Ukraine (Ruthenia)
386 15 Nov 2023, 22:36
I'm trying to understand, what you have changed:
Code:
HB_OLD.EXE                                                               HB_NEW.EXE

00469004:  61                    popad                                |  00469004:  4D                    dec ebp
00469005:  93                    xchg eax, ebx                        |  00469005:  F8                    clc 
00469006:  50                    push eax                             |  00469006:  54                    push esp
00469024:  61                    popad                                |  00469024:  4D                    dec ebp
00469025:  93                    xchg eax, ebx                        |  00469025:  F8                    clc 
00469026:  50                    push eax                             |  00469026:  54                    push esp
0046903C:  61                    popad                                |  0046903C:  4D                    dec ebp
0046903D:  93                    xchg eax, ebx                        |  0046903D:  F8                    clc 
0046903E:  50                    push eax                             |  0046903E:  54                    push esp
------------------------------------------------------------------------------------------------------------------------------------------
00469053:  006193                add byte ptr [ecx-6Dh], ah           |  00469053:  004DF8                add byte ptr [ebp-08h], cl
00469056:  50                    push eax                             |  00469056:  54                    push esp
0046906B:  006193                add byte ptr [ecx-6Dh], ah           |  0046906B:  004DF8                add byte ptr [ebp-08h], cl
0046906E:  50                    push eax                             |  0046906E:  54                    push esp
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
004690C5:  0001                  add byte ptr [ecx], al               |  004690C5:  0002                  add byte ptr [edx], al
004690CD:  0001                  add byte ptr [ecx], al               |  004690CD:  0002                  add byte ptr [edx], al
------------------------------------------------------------------------------------------------------------------------------------------
0046920B:  0031                  add byte ptr [ecx], dh               |  0046920B:  0032                  add byte ptr [edx], dh
0046923B:  0031                  add byte ptr [ecx], dh               |  0046923B:  0032                  add byte ptr [edx], dh
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
0046E021:  0031                  add byte ptr [ecx], dh               |  0046E021:  0032                  add byte ptr [edx], dh
------------------------------------------------------------------------------------------------------------------------------------------
00471DDF:  0031                  add byte ptr [ecx], dh               |  00471DDF:  0032                  add byte ptr [edx], dh
------------------------------------------------------------------------------------------------------------------------------------------
0047201F:  6800008005            push 05800000h                       |  0047201F:  6800002000            push 00200000h
0047202E:  6800005800            push 00580000h                       |  0047202E:  6800002000            push 00200000h
00472038:  A300494000            mov dword ptr [00404900h], eax       |  00472038:  A308494000            mov dword ptr [00404908h], eax
0047203D:  6800008005            push 05800000h                       |  0047203D:  6800002000            push 00200000h
00472047:  A308494000            mov dword ptr [00404908h], eax       |  00472047:  A3FC484000            mov dword ptr [004048FCh], eax
0047204C:  6800008005            push 05800000h                       |  0047204C:  6800002000            push 00200000h
00472056:  A3FC484000            mov dword ptr [004048FCh], eax       |  00472056:  A30C494000            mov dword ptr [0040490Ch], eax
0047205B:  6800008005            push 05800000h                       |  0047205B:  6800002000            push 00200000h
00472065:  A30C494000            mov dword ptr [0040490Ch], eax       |  00472065:  A300494000            mov dword ptr [00404900h], eax
0047206A:  6800005800            push 00580000h                       |  0047206A:  6800002000            push 00200000h
00472079:  6800005800            push 00580000h                       |  00472079:  6800002000            push 00200000h
00472088:  6800005800            push 00580000h                       |  00472088:  6800002000            push 00200000h
00472097:  6800100000            push 00001000h                       |  00472097:  6800000100            push 00010000h
004720A6:  6800100000            push 00001000h                       |  004720A6:  6800000100            push 00010000h
004720B5:  6800100000            push 00001000h                       |  004720B5:  6800000100            push 00010000h
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
00472034:  C08EFFFFA30049        ror byte ptr [esi+00A3FFFFh], 000000 |  00472034:  C08EFFFFA30849        ror byte ptr [esi+08A3FFFFh], 00000049h
0047203F:  008005E8B18E          add byte ptr [eax-714E17FBh], al     |  0047203F:  0020                  add byte ptr [eax], ah
                                                                      |  00472041:  00E8                  add al, ch
                                                                      |  00472043:  B18E                  mov cl, 8Eh
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
    
Post 15 Nov 2023, 22:36
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 15 Nov 2023, 22:46
Hobby BASIC uses one main internal structure for all data types, 88 bytes in size.
This practically means that, for example, every 1 mb of memory I allocate, I get about 12000 elements (strings, variables, arrays, labels, etc.)
More than enough for a simple toy interpreter.
But maybe I should let the user decide the size of memory they want to use.

I changed a few values in memory allocation calls at startup. That's all. Smile


Last edited by Picnic on 16 Nov 2023, 12:00; edited 3 times in total
Post 15 Nov 2023, 22:46
View user's profile Send private message Reply with quote
386



Joined: 11 Nov 2023
Posts: 28
Location: Ukraine (Ruthenia)
386 15 Nov 2023, 22:54
Quote:
But maybe I should let the user decide the size of memory they want to use.
Wow! That would be extremely super!

Users do like to decide! Smile
Post 15 Nov 2023, 22:54
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 15 Nov 2023, 23:01
It's easy to implement, i'll think about that. Thanks again for your feedback 386. Quite useful !
Post 15 Nov 2023, 23:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.