flat assembler
Message board for the users of flat assembler.

flat assembler > Examples and Tutorials > Hobby Basic, a toy language interpreter written in fasm

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16618
Location: In your JS exploiting you and your system
filox wrote:
Sorry but where i can find sources of Hobbybasic?
Have a look at the first post in this thread.
Post 21 Oct 2016, 12:13
View user's profile Send private message Visit poster's website Reply with quote
system error



Joined: 01 Sep 2013
Posts: 671
This is good. Keep it coming, bro!
Post 22 Oct 2016, 13:32
View user's profile Send private message Reply with quote
filox



Joined: 13 Feb 2013
Posts: 10
revolution wrote:
filox wrote:
Sorry but where i can find sources of Hobbybasic?
Have a look at the first post in this thread.


No source, only EXE and Demo.bas
Post 26 Oct 2016, 12:24
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8216
Location: ˛                              ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ Posts: 6699
hi filox,
you could try pm picnic for source etc
Post 26 Oct 2016, 12:36
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1273
Location: countryside
Hi filox, the source is not available, at least not yet. Hobby Basic has still some way to go. I want to extend the command list, find methods to make the intepreter faster, add features like user procedures with parameters and local variables and some other ideas i have. This is done somewhat slowly, the only days i can steal some time to work are the weekends.
Post 26 Oct 2016, 13:37
View user's profile Send private message Reply with quote
filox



Joined: 13 Feb 2013
Posts: 10
Picnic wrote:
Hi filox, the source is not available, at least not yet. Hobby Basic has still some way to go. I want to extend the command list, find methods to make the intepreter faster, add features like user procedures with parameters and local variables and some other ideas i have. This is done somewhat slowly, the only days i can steal some time to work are the weekends.


Hi picnic, if u can share code with us, we can help you possibly to improve it faster and i'm interested in it for educational scope Very Happy
Post 18 Nov 2016, 13:19
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1273
Location: countryside
Quote:
...and i'm interested in it for educational scope

Take a look at MINI-BASIC for fasm. It's a piece of code available for modifications.
Post 21 Nov 2016, 15:50
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1273
Location: countryside
A new version upload with some minor improvements, and fixes in bugs i noticed.

The command GRAB, which can be used for transferring from screen to 2d array and vice versa, has become more flexible.

Example.
Code:

    dim a[32,7]

    screen 80,25
    cursor 0,0
    color 0,0
    cls

    ansi "ART\CAR.ANS"

    grab 0,0,32,7,a[],0     ! screen to array

    color 1,1
    cls         

    grab 0,0,32,7,a[],1     ! array to screen
    grab 0,8,32,7,a[],2     ! array to screen (2nd method - skip zero cells)
    flip 0,8,32,7,0

    inkey
    

Image



A 2D moving car.
Code:

    rem  2D Moving Car

    VK_LEFT=37
    VK_RIGHT=39

    dim c1[32,7]
    dim c2[32,7]
    dim a[80,25]

    a$=PATH(1)+"\ART\FOREST.ANS"
    c$=PATH(1)+"\ART\CAR.ANS"
    x=2
    y=18

    title "Use the arrow keys to move"
    screen 80,25
    cursor 0,0
    ansi c$
    grab 0,0,32,7,c1[],0
    flip 0,0,32,7,0
    grab 0,0,32,7,c2[],0
    color 0,0:cls
    ansi a$
    grab 0,0,80,25,a[],0
    grab x,y,32,7,c1[],2

    do

        if (KEY(VK_LEFT) and x>0)
            grab x,y,32,7,a[],x,y   ! portion of an array to screen (3rd method)
            x=x-2
            grab x,y,32,7,c2[],2
        elseif (KEY(VK_RIGHT) and x<82)
            grab x,y,32,7,a[],x,y
            x=x+2
            grab x,y,32,7,c1[],2
        endif

        wait 12000

    until KEY(27)
    end
    

Image



2D Scrolling Background.
Code:

    rem  2D Scrolling Background

    VK_LEFT=37
    VK_RIGHT=39
    VK_SPACE=32

    dim a[6,4]
    dim m[160,25]

    title "Use the arrow keys to move, space to jump"
    screen 80,25
    cursor 0,0

    color 13,13
    paint 0,0,6,4,0x20,1
    color 0,0
    paint 1,1,4,2,0x20,1
    grab 0,0,6,4,a[],0
    cls

    for y=1 to 6
        x=RND(70)
        color x&7,0
        paint x,y*3,5,3,0x20,1
    next

    grab 0,0,160,25,m[],0

    for x=0 to 79
        for y=0 to 24
            m[x+80,y]=m[x,y]
        next
    next

    color 0,0:cls:color 1,8
    paint 0,22,80,3,0x2591,1

    x=35
    y=18
    j=0

    grab x,2,80,20,m[],0,2
    grab x,y,6,4,a[],2

    do

        if (KEY(VK_SPACE) and ~j)
            j=1
            v=-1
        elseif KEY(VK_LEFT)
            d=-2
        elseif KEY(VK_RIGHT)
            d=2
        else
            d=0
        endif

        if j
            y=y+v
            if y=2
                v=1
            elseif y=19
                y=18
                j=0
            endif
        endif

        x=x+d
        if x<0 then x=80
        if x>80 then x=0

        grab x,2,80,20,m[],0,2
        grab 35,y,6,4,a[],2

        wait 12000

    until KEY(27)
    end
    

Image


Last edited by Picnic on 16 Jun 2019, 11:09; edited 29 times in total
Post 21 Dec 2016, 12:34
View user's profile Send private message Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 170
Location: Madrid - Spain
Hello, it is very interesting. I was very fond of qbasic. I'd just say that it would be nice to see your page in English, Greek is a bit hard for me Smile
Post 21 Dec 2016, 13:20
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1273
Location: countryside
Hobby Basic includes an embedded ANSI file loader that recognizes standard ANSI.SYS escape codes for colors and cursor movement.

Loading an ANSI image is easy.

Code:

    ! s controls the drawing speed
    ! s=0 unlimited (default)
    ! s=1 slow...50 fast


    path$="ART\APPLE.ANS"
    ansi path$,0
    inkey
    

Image


Code:

    path$="ART\APPLE.ANS"
    ansi path$,0
    color 8,0
    paint 0,0,40,25,-1,1
    flip 40,0,40,25,0
    inkey
    

Image




Rearranging the screen by using Block.
Code:

    ansi "ART\APPLE.ANS"

    A=1001
    B=1002
    C=1003
    D=1004

    block 0,0,40,12,A
    block 40,0,40,12,B
    block 0,12,40,12,C
    block 40,12,40,12,D

    cls
    block 0,0,B
    block 40,0,A
    block 0,12,D
    block 40,12,C
    inkey
    

Image




Creating a tile texture to fill the screen on the fly.
Code:

    ansi "ART\APPLE.ANS"

    block 0,0,5,5,700
    cls

    for i=0 to 79
        block (i%16)*5,(i/16)*5,700
    next

    inkey
    

Image




A screen shuffler program.
Code:

    dim a[16]=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

    title "Press a key to shuffle the screen"

    ansi "ART\APPLE.ANS"

    for i=0 to 15
        block (i%4)*20,(i/4)*6,20,6,i
    next

   shuffle#

    a[]=-1

    inkey:if V0=27 then end

    for i=0 to 15
        block (i%4)*20,(i/4)*6,a[i]
    next

    goto shuffle
    

Image




This program is an ANSI text file viewer.
Code:

    rem  ANSI Text File Viewer

    a = 1                                ! auto play slide-show 0/1
    s = 20                               ! drawing text speed
    m = 250                              ! max files in folder
    d = 2000000                          ! delay between images
    path$ = PATH(1)+"\ART\"              ! path to ART folder

    cmd$ = "dir /b "+CHR(0x22)+path$+CHR(0x22)
    exec cmd$,dir$

    screen 80,30
    cursor 0,0

    forever#

    c=0
    for n=1 to m
        a$=READLN(n,dir$)
        if V0<>-1
            a$=path$+a$
            if COMP(UCASE(RIGHT(a$,4)),".ANS")
                title a$
                color 0,7:cls
                ansi a$,s
                if KEY(27) then end
                if a then wait d else inkey
                c=c+1
            endif
        endif
    next

    if c=0 then alert "no files found":end
    goto forever
    

Image


Last edited by Picnic on 16 Jun 2019, 15:11; edited 17 times in total
Post 28 May 2018, 13:49
View user's profile Send private message Reply with quote
Robocod



Joined: 05 Mar 2018
Posts: 15
Source code?
Post 19 Dec 2018, 21:23
View user's profile Send private message Reply with quote
sts-q



Joined: 29 Nov 2018
Posts: 16
Post 20 Dec 2018, 09:33
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3

< 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-2019, Tomasz Grysztar.

Powered by rwasa.