Page 2 of 2

Re: FreeBasic

Posted: Fri May 03, 2013 5:22 pm
by GMac
Forgive me asking a dumb question, if I'm using say freedos, and fbc, then is not the exe produced sitting at org100?, and how would I make this org0?
would I use a tool for example exe2asm several of which I have, or what? is there a way from fbc itself to reflect org0?, I prefer turbobasic or failing that powerbasic to fbc, or the latest basic am using that being XST, which spits out an ansi c file, seeing as it uses djgpp ver 2 for it's compiler, and I just installed djgpp. sadly, am not a c or cpp coder tho have maybe 20 different versions of c, and 10 or so cpp compilers.

Re: FreeBasic

Posted: Sat May 04, 2013 10:26 am
by 0CodErr
GMac wrote:would I use a tool for example exe2asm
You may use compiler option "-r", which mean "Write asm file only, do not compile or link".
For example:
fbc -r "MyProgram.bas"
After that file in project folder "MyProgram.asm" will be created.

Re: FreeBasic

Posted: Tue Jun 11, 2013 4:33 pm
by ddarias
Can you use the rtl of FreeBasic, without port it to kolibri? for example stdlib.

Basic language for kolibris?

Posted: Sun Mar 16, 2014 1:39 pm
by MrSiuol
Hello,
Can you intergrer to KolibriOS a basic compiler language ?
Because asssembleur is very hard :x !

Re: Basic language for kolibris?

Posted: Sun Mar 16, 2014 1:43 pm
by yogev_ezra
MrSiuol wrote:Hello,
Can you intergrer to KolibriOS a basic compiler language ?
Because asssembleur is very hard :x !
We have FreeBasic available - please check this topic.

Re: FreeBasic

Posted: Sun Mar 16, 2014 2:26 pm
by MrSiuol
Thank you,
But it is not intergrer to Kolibrios like Fasm, it goes through windows !

Re: FreeBasic

Posted: Sun Mar 16, 2014 8:26 pm
by Wildwest

Re: FreeBasic

Posted: Sun Oct 16, 2016 3:02 pm
by 0CodErr
This is updated frame example that uses these frame border styles: raised, sunken, etched, ridged.
Source:
Spoiler:

Code: Select all

 ' Event Constants
  Const REDRAW_EVENT = 1
  Const KEY_EVENT    = 2
  Const BUTTON_EVENT = 3
  Const MOUSE_EVENT  = 6

  ' Window Style Constants
  Const WS_SKINNED_FIXED    = &H4000000
  Const WS_SKINNED_SIZABLE  = &H3000000
  Const WS_FIXED            = &H0000000
  Const WS_SIZABLE          = &H2000000
  Const WS_FILL_TRANSPARENT = &B1000000000000000000000000000000
  Const WS_FILL_GRADIENT    = &B10000000000000000000000000000000
  Const WS_COORD_CLIENT     = &B100000000000000000000000000000
  Const WS_CAPTION          = &B10000000000000000000000000000

 ' Caption styles
  Const CAPTION_MOVABLE     = &H00000000
  Const CAPTION_NONMOVABLE  = &H01000000

 ' FR_FLAGS
  Const FR_CAPTION = &B00001
  Const FR_DOUBLE  = &B00000
  Const FR_RAISED  = &B00010
  Const FR_SUNKEN  = &B00100
  Const FR_ETCHED  = &B00110
  Const FR_RIDGED  = &B01000
  Const FR_FILLED  = &B10000

 ' FR_TEXT_POSITION
  Const FR_TEXT_POS_BOTTOM = 1
  Const FR_TEXT_POS_TOP    = 0

  Type Size
    Height As UShort
    Width  As UShort
  End Type

  Type Frame
    Style         As ULong
    Width         As UShort
    Left          As UShort
    Height        As UShort
    Top           As UShort
    Outer_color   As ULong
    Inner_color   As ULong
    Flags         As ULong
    Text          As ZString Ptr
    Text_position As ULong
    Font          As ULong
    Font_height   As ULong
    Fore_color    As ULong
    Back_color    As ULong
  End Type

  Type Rect
   Left    As Long
   Top     As Long
   Right   As Long
   Bottom  As Long
  End Type

  Dim Shared Scr As Size
  Dim Shared Wnd As Rect

  Dim Shared hBoxLib As Long

  Dim Shared Frame1 As Frame
  Dim Shared Frame2 As Frame
  Dim Shared Frame3 As Frame
  Dim Shared Frame4 As Frame
  Dim Shared Frame5 As Frame

  Declare Function WaitEvent() As Long
  Declare Function GetKeyCode() As Long
  Declare Function GetButton() As Long
  Declare Function GetScreenSize() As Size
  Declare Function GetSkinHeight() As ULong
  Declare Function LoadLibrary(filename As ZString) As Long
  Declare Function GetProcAddress(hLib As Long, ProcName As ZString) As Long
  Declare Sub DrawWindow(WLeft As Long, WTop As Long, WRight As Long, WBottom As Long, Caption As ZString, BackColor As ULong, Style As ULong, CapStyle As ULong)
  Declare Sub On_Redraw()
  Declare Sub On_KeyPress()
  Declare Sub On_ButtonPress()
  Dim Shared FrameDraw As Sub(frame As frame)
'* -------------------------------------------------------- *'
  #Undef RGB
  #Define RGB(r,g,b) ((cuint(r) shl 16) or (cuint(g) shl 8) or Cuint(b))
'* -------------------------------------------------------- *'
  #Macro ThreadTerminate()
    Asm
        mov    eax, -1
        int    64
    End Asm
  #EndMacro
'* -------------------------------------------------------- *'
  #Macro BeginDraw()
    Asm
        mov    eax, 12
        mov    ebx, 1
        int    64
    End Asm
  #EndMacro
'* -------------------------------------------------------- *'
  #Macro EndDraw()
    Asm
        mov    eax, 12
        mov    ebx, 2
        int    64
    End Asm
  #EndMacro
'* -------------------------------------------------------- *'
  Sub Main()
    Scr = GetScreenSize()

    Wnd.Right  = 731
    Wnd.Bottom = 127
    Wnd.Left   = (Scr.width  - Wnd.Right)  Shr 1
    Wnd.Top    = (Scr.height - Wnd.Bottom) Shr 1

    hBoxLib   = LoadLibrary("/sys/lib/box_lib.obj")
    FrameDraw = GetProcAddress(hBoxLib, "frame_draw")

    With Frame1
      .style         = 0
      .width         = 131
      .left          = 8
      .height        = 81
      .top           = 13
      .outer_color   = &H00FFFFFF
      .inner_color   = &H00808080
      .flags         = FR_RAISED OR FR_CAPTION OR FR_FILLED
      .text          = @" raised "
      .text_position = FR_TEXT_POS_TOP
      .font          = 1
      .font_height   = 16
      .fore_color    = RGB(200, 0, 0)
      .back_color    = &H00D0D0D0
    End With

    With Frame2
      .style         = 0
      .width         = 131
      .left          = 152
      .height        = 81
      .top           = 13
      .outer_color   = &H00FFFFFF
      .inner_color   = &H00808080
      .flags         = FR_SUNKEN OR FR_CAPTION
      .text          = @" sunken "
      .text_position = FR_TEXT_POS_BOTTOM
      .font          = 1
      .font_height   = 16
      .fore_color    = RGB(0, 200, 0)
      .back_color    = &HD4D0C8
    End With

    With Frame3
      .style         = 0
      .width         = 131
      .left          = 296
      .height        = 81
      .top           = 13
      .outer_color   = &H00FFFFFF
      .inner_color   = &H00808080
      .flags         = FR_ETCHED OR FR_CAPTION OR FR_FILLED
      .text          = @" etched "
      .text_position = FR_TEXT_POS_TOP
      .font          = 1
      .font_height   = 16
      .fore_color    = RGB(0, 0, 200)
      .back_color    = &H00D0D0D0
    End With

    With Frame4
      .style         = 0
      .width         = 131
      .left          = 440
      .height        = 81
      .top           = 13
      .outer_color   = &H00FFFFFF
      .inner_color   = &H00808080
      .flags         = FR_RIDGED OR FR_CAPTION
      .text          = @" ridged "
      .text_position = FR_TEXT_POS_BOTTOM
      .font          = 1
      .font_height   = 16
      .fore_color    = RGB(200, 0, 200)
      .back_color    = &HD4D0C8
    End With

    With Frame5
      .style         = 0
      .width         = 131
      .left          = 584
      .height        = 81
      .top           = 13
      .outer_color   = &H00FFFFFF
      .inner_color   = &H00808080
      .flags         = FR_DOUBLE OR FR_CAPTION OR FR_FILLED
      .text          = @" double "
      .text_position = FR_TEXT_POS_TOP
      .font          = 1
      .font_height   = 16
      .fore_color    = RGB(0, 200, 200)
      .back_color    = &H00D0D0D0
    End With

    Do
      Select Case WaitEvent()
       Case REDRAW_EVENT : On_Redraw
       Case KEY_EVENT    : On_KeyPress
       Case BUTTON_EVENT : On_ButtonPress
      End Select
    Loop
  End Sub
'* -------------------------------------------------------- *'
  Sub On_KeyPress()
    GetKeyCode
  End Sub
'* -------------------------------------------------------- *'
 Sub On_ButtonPress()
   Select Case GetButton() Shr 8
   Case 1
     ThreadTerminate()
   End Select
 End Sub
'* -------------------------------------------------------- *'
 Sub On_Redraw()
   BeginDraw()
   DrawWindow Wnd.Left, Wnd.Top, Wnd.Right, Wnd.Bottom, "Frames", RGB(192, 192, 192), WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE
   FrameDraw(Frame1)
   FrameDraw(Frame2)
   FrameDraw(Frame3)
   FrameDraw(Frame4)
   FrameDraw(Frame5)
   EndDraw()
 End Sub
'* -------------------------------------------------------- *'
  Sub DrawWindow(WLeft As Long, WTop As Long, WRight As Long, WBottom As Long, Caption As ZString, BackColor As ULong, Style As ULong, CapStyle As ULong)
    Asm
        xor    eax, eax
        mov    ebx, [WLeft]
        shl    ebx, 16
        add    ebx, [WRight]
        mov    ecx, [WTop]
        shl    ecx, 16
        add    ecx, [WBottom]
        mov    edx, [Style]
        or     edx, [BackColor]
        mov    edi, [Caption]
        mov    esi, [CapStyle]
        int    64
    End Asm
  End Sub
'* -------------------------------------------------------- *'
  Function WaitEvent Naked() As Long
    Asm
        mov    eax, 10
        int    64
        ret
    End Asm
  End Function
'* -------------------------------------------------------- *'
  Function GetKeyCode Naked() As Long
    Asm
        mov    eax, 2
        int    64
        ret
    End Asm
  End Function
'* -------------------------------------------------------- *'
  Function GetButton Naked() As Long
    Asm
        mov    eax, 17
        int    64
        ret
    End Asm
  End Function
'* -------------------------------------------------------- *'
  Function GetScreenSize Naked() As Size
    Asm
        push   ebx
        mov    eax, 61
        mov    ebx, 1
        int    64
        pop    ebx
        ret
    End Asm
  End Function
'* -------------------------------------------------------- *'
  Function GetSkinHeight Naked() As ULong
    Asm
        push   ebx
        mov    eax, 48
        mov    ebx, 4
        int    64
        pop    ebx
        ret
    End Asm
  End Function
'* -------------------------------------------------------- *'
  Function LoadLibrary(filename As ZString) As Long
    Asm
        mov    eax, 68
        mov    ebx, 19
        mov    ecx, [filename]
        int    64
        mov    [Function], eax
    End Asm
  End Function
'* -------------------------------------------------------- *'
  Function GetProcAddress(hLib As Long, procname As ZString) As Long
    Asm
        mov    edx, [hLib]
        xor    eax, eax
        test   edx, edx
        jz     2f
      ' -----------------------
      1:
        cmp    dword ptr [edx], 0
        jz     2f

        xor    eax, eax
        mov    esi, [edx]
        mov    edi, [procname]
      ' -----------------------
      0:
        lodsb
        scasb
        jne    0f
        or     al, al
        jnz    0b
        jmp    1f
      ' -----------------------
      0:
        add    edx, 8
        jmp    1b
      ' -----------------------
      1:
        mov    eax, [edx + 4]
      ' -----------------------
      2:
        mov    [Function], eax
    End Asm
  End Function
Result:
Spoiler:
Frames.PNG
Frames.PNG (5.29 KiB)
Viewed 11811 times

Re: FreeBasic

Posted: Sat Feb 05, 2022 3:33 pm
by KPG
Интересно, что на FreeBasic имеется и проект ОС. :)
a little os in freebasic
(у автора репозитория ещё есть какие то разработки ОС на FreeBasic)

P.S.на FreeBasic 988 решений задач с ресурса rosettacode.org
там же ещё есть и, к примеру, на Basic-256, BBC Basic и др.
по Basic256 10-ть лет назад BHV издало и книгу, а сама сборка Basic256 включалась в учебный комплект ПО в составе Alt Linux.

FreeBasic до сих пор включает сборку для ДОС и соответсвенно его можно, вероятно, использоватьчерез запуск в DosBox.
имеющегося в KolibriOS.

Re: FreeBasic

Posted: Sun Feb 06, 2022 1:21 am
by Doczom
но лучше полностью портировать его, чем запускать через dosbox