User avatar
RichardUK
Posts: 235
Joined: Fri Jun 01, 2012 5:12 pm

Re: Game Console OS

Wed Jun 06, 2012 12:47 pm

This is the sort of thing I was thinking. Basic OS with all the drivers that just loads a basic front end. Be good to also create an SDK that is easy to get up and running which maybe includes some libs for common tasks like games saves gamer tags etc.

Then let that be a base for many forks with different front ends etc, maybe even some kind of free marketplace for installing, maybe use bit torrent for hosting. One of my random idea's, but the point is that would be a addition to the basic setup.

One of the goals should be that if I write "super space game A" and it runs on my RPi with this distro I know it will run on all other RPi's using this distro as the base.

All the cuddly iTunes / Google Play / XBox live loveliness can be added by others.

There have been many attempts to create an open source console and they all suffered from defining a fixed hardware platform. This is an opportunity to get it up and running. :)

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: Game Console OS

Wed Jun 06, 2012 1:04 pm

RichardUK wrote:There have been many attempts to create an open source console and they all suffered from defining a fixed hardware platform. This is an opportunity to get it up and running. :)
You should not end up relying to fixed hardware. That's the receipt for becoming obsolete shortly. Yeah it's an opportunity, but do take measures to stay portable still.

Narishma
Posts: 151
Joined: Wed Nov 23, 2011 1:29 pm

Re: Game Console OS

Wed Jun 06, 2012 4:52 pm

cheery wrote:You should not end up relying to fixed hardware. That's the receipt for becoming obsolete shortly. Yeah it's an opportunity, but do take measures to stay portable still.
The Pi is already obsolete in terms of specs, so it's not like it matters in this case.

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: Game Console OS

Wed Jun 06, 2012 6:08 pm

Narishma wrote:
cheery wrote:You should not end up relying to fixed hardware. That's the receipt for becoming obsolete shortly. Yeah it's an opportunity, but do take measures to stay portable still.
The Pi is already obsolete in terms of specs, so it's not like it matters in this case.
There will be likely further hardware of similar design. It'd be good for them if they could run your software after porting couple libraries and perhaps a recompile. That's what I mean. Remember to provide the portability layer that the industry can go forward.

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: Game Console OS

Thu Jun 07, 2012 4:37 pm

You could use asm macro to make a basic like language, that way you would only need to change about 5% of code for each new device you port to.
And the game would run on all of them.
Batteries not included, Some assembly required.

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: Game Console OS

Thu Jun 07, 2012 5:05 pm

Do you have an example implementation of that? It sounds interesting.

User avatar
RichardUK
Posts: 235
Joined: Fri Jun 01, 2012 5:12 pm

Re: Game Console OS

Thu Jun 07, 2012 8:49 pm

Narishma wrote:
cheery wrote:You should not end up relying to fixed hardware. That's the receipt for becoming obsolete shortly. Yeah it's an opportunity, but do take measures to stay portable still.
The Pi is already obsolete in terms of specs, so it's not like it matters in this case.
Yes that is what I was thinking. No need to get hung up on hardware as it's been set for us. My thoughts were, which I suspect the projects author is doing, is that the front end just runs an app / script and then quits. As long as the app, or it's script (shouldn't matter which) restarts the front end then the games need no extra code. Just add a script to run it and some info for the front end and you're done. This will also mean it supported new hardware, just port / recompile the front end and any games if they need to.

In short, define the OS, make simple front end, create some howto's and job done.

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: Game Console OS

Thu Jun 07, 2012 9:20 pm

cheery wrote:Do you have an example implementation of that? It sounds interesting.
Yes this simple example is coded to run on x86 linux

Code: Select all

include 'FBasic_L.inc'
CLS
COLOR  11
LOCATE 2,1
PRINT "This app is written in Macro Basic, for Linux "
COLOR  12
LOCATE 2,2
PRINT "With the ease of Basic and the power of ASM "
COLOR  15
LOCATE 2,3
PRINT "It user's the basic commands:"
PRINT " "
PRINT "    CLS"
PRINT "    SCREEN"
PRINT "    COLOR"
PRINT "    LOCATE"
PRINT "    PRINT"
PRINT "    GOSUB"
PRINT "    RETURN"
PRINT "    SLEEP"
PRINT "    END"
PRINT " "
GOSUB TestSub
SLEEP
END

TestSub:
PRINT "  Press any key to quit."
RETURN                                            
This would stay the same, other than you change "FBasic_L.inc"
Which is this file:

Code: Select all

;============================================================
; FBasic is based on a idea by rCX, for a fasm macro basic.
; The esae of basic, with the power of ASM.
;
; Code input by:
;   Dex
;   rCX
;   Steve
;   TonyMac
;
; This include is for 32BIT Linux terminal.
;
;============================================================

;=======================================================  ;
;  File header.                                           ;
;=======================================================  ; 
format ELF executable                                     ;
entry  start                                              ;
                                                          ;
;=======================================================  ;
;  CLS.                                                   ;
;=======================================================  ; 
macro CLS                                                 ;
{                                                         ;
local .Done                                               ;
local .a                                                  ;
local .b                                                  ;
                                                          ;
        mov     eax,4                                     ; Print function
        mov     ebx,1                                     ;
        mov     ecx,.a                                    ;
        mov     edx,.b                                    ;
        int     80h                                       ;
        jmp     .Done                                     ;
                                                          ;
.a db 1bh, "[2J",1bh, "[01;01H"                           ; clear screen.
.b = $-.a                                                 ;
.Done:                                                    ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  PRINT.                                                 ;
;=======================================================  ; 
macro PRINT String{                                       ;
local .Done                                               ;
local .a                                                  ;
local .b                                                  ;
                                                          ;
        mov     eax,4                                     ; Print function
        mov     ebx,1                                     ;
        mov     ecx,.a                                    ;
        mov     edx,.b                                    ;
        int     80h                                       ;
        jmp     .Done                                     ;
                                                          ;
.a db String,0xa                                          ;
.b = $-.a                                                 ;
.Done:                                                    ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  LOCATE.                                                ;
;=======================================================  ; 
macro LOCATE col,row                                      ;
{                                                         ;
local .Done                                               ;
local .CursorX                                            ;
local .CursorY                                            ;
local .ColumnRow                                          ;
local .ColumnRowSize                                      ;
        pushad                                            ;
        mov     dh, 10                                    ;
                                                          ;
        mov     ax, row                                   ; AX = character column
        and     ax, 0FFh                                  ;
        div     dh                                        ; divide by 10
        add     ax, "00"                                  ;
        mov     [.CursorX], ax                            ;
                                                          ;
        mov     ax, col                                   ; AX = character row
        and     ax, 0FFh                                  ;
        div     dh                                        ; divide by 10
        add     ax, "00"                                  ;
        mov     [.CursorY], ax                            ;
                                                          ;
        mov     eax,4                                     ; Print function
        mov     ebx,1                                     ;
        mov     ecx,.ColumnRow                            ;
        mov     edx,.ColumnRowSize                        ;
        int     80h                                       ;
        jmp     .Done                                     ;
                                                          ;
                                                          ;
.ColumnRow      db      1bh, "["                          ; cursor positioning sequence
.CursorX        dw      0                                 ;
                db      ";"                               ;
.CursorY        dw      0                                 ;
                db      "H"                               ;
.ColumnRowSize = $-.ColumnRow                             ;
.Done:                                                    ;
        popad                                             ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  END.                                                   ;
;=======================================================  ; 
macro COLOR NewColor                                      ;
{                                                         ;
local .Done                                               ;
local .Done1                                              ;
local .black                                              ;
local .red                                                ;
local .green                                              ;
local .yellow                                             ;
local .blue                                               ;
local .magenta                                            ;
local .cyan                                               ;
local .white                                              ;
local .Size1                                              ;
local .Size2                                              ;
                                                          ;
        mov     al,NewColor                               ;
        cmp     al,15                                     ;
        ja      .Done                                     ;
        cmp     al,15                                     ;
        jne     @f                                        ;
        mov     ecx,.white                                ;
        jmp     .Done1                                    ;
@@:                                                       ;
        cmp     al,0                                      ;
        jne     @f                                        ;
        mov     ecx,.black                                ;
        jmp     .Done1                                    ;
@@:                                                       ;
        cmp     al,11                                     ;
        jne     @f                                        ;
        mov     ecx,.cyan                                 ;
        jmp     .Done1                                    ;
@@:                                                       ;
        cmp     al,12                                     ;
        jne     @f                                        ;
        mov     ecx,.red                                  ;
        jmp     .Done1                                    ;
@@:                                                       ;
        cmp     al,14                                     ;
        jne     @f                                        ;
        mov     ecx,.yellow                               ;
        jmp     .Done1                                    ;
@@:                                                       ;
        cmp     al,10                                     ;
        jne     @f                                        ;
        mov     ecx,.green                                ;
        jmp     .Done1                                    ;
@@:                                                       ;
        cmp     al,13                                     ;
        jne     @f                                        ;
        mov     ecx,.magenta                              ;
        jmp     .Done1                                    ;
@@:                                                       ;
        cmp     al,9                                      ;
        jne     @f                                        ;
        mov     ecx,.blue                                 ;
        jmp     .Done1                                    ;
@@:                                                       ;
        jmp     .Done                                     ;
.Done1:                                                   ;
        mov     eax,4                                     ; Print function
        mov     ebx,1                                     ;
        mov     edx,.Size2                                ;
        int     80h                                       ;
        jmp     .Done                                     ;
                                                          ;
                                                          ;
.black    db 1bh, "[0;30;49m"                             ;
.red      db 1bh, "[0;31;49m"                             ;
.green    db 1bh, "[0;32;49m"                             ;
.yellow   db 1bh, "[0;33;49m"                             ;
.blue     db 1bh, "[0;34;49m"                             ;
.magenta  db 1bh, "[0;35;49m"                             ;
.cyan     db 1bh, "[0;36;49m"                             ;
.white    db 1bh, "[0;37;49m"                             ;
.Size1    db 1bh, "[0;39;49m"                             ;
.Size2 = $-.Size1                                         ;
.Done:                                                    ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  GOTO.                                                  ;
;=======================================================  ;
Macro GOTO _op1                                           ;
{                                                         ;
        jmp     _op1                                      ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  GOSUB.                                                 ;
;=======================================================  ;
Macro GOSUB _subname                                      ;
{                                                         ;
        call     _subname                                 ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  RETURN.                                                ;
;=======================================================  ;
Macro RETURN                                              ;
{                                                         ;
        ret                                               ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  SLEEP.                                                 ;
;=======================================================  ;
macro SLEEP                                               ;
{                                                         ;
        pushad                                            ;
        mov     eax,3                                     ;
        xor     ebx,ebx                                   ;
        mov     ecx,1                                     ;
        mov     edx,buffer                                ;
        int     80h                                       ;
        popad                                             ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  END.                                                   ;
;=======================================================  ; 
macro END                                                 ;
{                                                         ;
local .Done                                               ;
local .restore                                            ;
local .Size2                                              ;
        pushad                                            ;
        mov     ecx,.restore                              ;
        mov     eax,4                                     ; Print function
        mov     ebx,1                                     ;
        mov     edx,.Size2                                ;
        int     80h                                       ;
                                                          ;
        mov     eax,1                                     ; Exit function
        xor     ebx,ebx                                   ;
        int     80h                                       ;
        jmp     .Done                                     ;
                                                          ;
.restore db 1bh, "[0;39;49m"                              ;
.Size2 = $-.restore                                       ;
.Done:                                                    ;
        popad                                             ;
}                                                         ;
                                                          ;
;=======================================================  ;
;  START of Program.                                      ;
;=======================================================  ;
segment readable writeable executable                     ;
buffer rb 1                                               ;
start:                                                    ;       
Theres vers for windows, linux, dexos, dos and working on R-PI for both bare metal and linux.
Heres a screenshot on linux:
Image
Heres it running in DexOS gui
Image
This is a text mode DexOS example:
Image

You just need to change the include file and assemble, lucky theres a FasmArm for arm code.
Note: This is a basic like language, but you could just as easy make any other language. eg: python like language.
This size is still small and the macros are only added if used, it does not matter how many macro you have in the include file as it does not make the file size any bigger.
So a hello world will still be small.
Batteries not included, Some assembly required.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Game Console OS

Fri Jun 08, 2012 7:35 am

DexOS wrote:Note: This is a basic like language, but you could just as easy make any other language. eg: python like language.
That's an interesting assertion, and tickles a question I've had floating about since you first mentioned this.

Your language is generated by using a set of macros for FASM, if I've understood everything correctly. In fact, it *is* assembler, just accessed by using macros. And those macros are merely (relatively) simple textual replacement rules, which are applied at "compile" time.

So, my questions (and I'm not sure I know the answers to any, let alone all of them) are:

- what about dynamic languages? Unless you're carrying an assembler around with you, you can't do something like `eval "add foo to bar"` because that code would have to be built and "compiled" at runtime.
- is it possible to convert every expression of any given (even restricted to static-only) language using simple textual replacement? I'm almost certain that it's possible to produce valid expressions in any turing complete language where simple replacement will produce nonsensical code.
- How do you deal with issues like register allocation within functions, particularly in the case where you have more variables than available registers?
- What of optimisation? Any significant program written in your language is surely going to be massively inefficient, thus throwing away the benefit of being "assembler".

I mention the latter because benchmarks of the early compiler for Armpit Scheme (which generates bare metal code) placed the results more or less on a par with an interpreted, bytecode VM scheme (Guile) running on the same hardware, and between 4 and 30 times slower than the same code run through the Chez Scheme compiler (which targets "C", then lets the C compiler get on with optimising the results).

I'm not saying it's a wrong approach, just asking what you think.

Simon

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Game Console OS

Fri Jun 08, 2012 8:31 am

The macros do not target any expressions; all that has to be done with assembler. IIRC (DexOS posted the include file a while ago,) only the macros shown in the screenshots are implemented. There are no FOR or WHILE statements either.

So it's efficient and it probably makes user-interface work easier, but calling it a language implementation is, in my view, rather over-extended. Using BASIC as a metaphore rather than inventing an arbitrary set of macros is a very good idea, and with a more powerful macro processor (or maybe just more work) it could be taken a little further; FOR, WHILE, IF and even ON GOTO should all be possible. But implementing expressions with any efficiency would require a whole new technology.

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: Game Console OS

Fri Jun 08, 2012 2:16 pm

A compiler transforms from source language to target language. DexOS has written a compiler in assembler macros. He doesn't claim it's BASIC, but just something alike and he's correct. I like the approach.
tufty wrote:- what about dynamic languages? Unless you're carrying an assembler around with you, you can't do something like `eval "add foo to bar"` because that code would have to be built and "compiled" at runtime.
You'd have to write the compiler self-hosting and then you could carry it around. Because it's doing just substitution, that'd be somewhat trivial to come up with.
- is it possible to convert every expression of any given (even restricted to static-only) language using simple textual replacement? I'm almost certain that it's possible to produce valid expressions in any turing complete language where simple replacement will produce nonsensical code.
Care to explain this? I thought you can implement substitutions that produce valid program for any given expression. Alhough I expect you'd parse the code into AST before doing substitutions on it.
- How do you deal with issues like register allocation within functions, particularly in the case where you have more variables than available registers?
Efficient register allocation is an optimization. In fact, you should see the whole compiling as an optimization. I'll explain in a moment.
- What of optimisation? Any significant program written in your language is surely going to be massively inefficient, thus throwing away the benefit of being "assembler".
Premature optimization is a failure in optimization.

There are people saying interpreters would be more efficient than substitution compiled code. I tend to agree, because theoretically they are the same thing. Here let me explain it with code.

We have a program listing, and we want to translate it into a program. This is an implementation of interpreter:

Code: Select all

instruction_table = [pointers to machine code blobs]

program = blob of bytes, substituted from listing

main() {
    vm_pc_reg = program+0
    jump to *instruction_table[*vm_pc_reg]
}
Now here's a substitution table compiler:

Code: Select all

compile(instruction) -> [machine code blob]

main() {
    program = []
    for instruction in listing {
        program += compile(instruction)
    }
    output program
}
In fact the interpreter also needs that kind of substitution table compiler, but instead of machine code blobs it is translating to byte code, which is more compact. The non-interpreted approach wastes memory and hurts cache performance in practise. This is why a trivial compiler is less efficient than a trivial interpreter.

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: Game Console OS

Fri Jun 08, 2012 6:50 pm

The idea behind FBasic is more of a teaching tool to teach assembly, l believe that it is important for any coder including kids to have this as a skill.
So as not to scare them you start by teaching them FBasic until they get a feel for it, then you start adding bits of asm.
I myself only converted a basic ver from a simple dos ver written by someone called rCX, i also added the linux ver the code is now being worked on by a DexOS team member called Steve, so far its got these commands
BEEP
CLS
COLOR
END
GOSUB
GOTO
INPUT
LET
LOCATE
PEEK
POKE
PRINT
RETURN
REBOOT
IN_PORT
OUT_PORT
SLEEP
SCREEN
SOUND
DEF
CURSORON
CURSOROFF
PAUSE
CURSOR
Also theres stuff like "else if" that you can use in fasm
Eample:

Code: Select all

;___________CURSOR__________________

macro CURSOR option*            ;Turns on cursor if option = TRUE, off if option = FALSE.
{
        pushf
        pusha
        mov   ch,0x0b           ;Turns on cursor if option = TRUE
        mov   cl,0x0c
        if option = FALSE
                mov   ch,0x1c   ;turns it off if option = FALSE.
                mov   cl,0x1b
        end if
        mov   ah,1              ;Set cursor status
        call  [RealModeInt10h]
        popa
        popf
}
Or

Code: Select all

;________________DEF___________________

Macro DEF  _varname, _vartype, _varval
{
        if _vartype = Short
           _varname     db 0
                        db _varval
        else if _vartype = Integer
           _varname     db 1
                        dw _varval
        else if _vartype = Long
           _varname     db 2
                        dd _varval
        else if _vartype = String
           _varname     db 9
                        dw 128        ;need to let it be defined several ways<----------**
                        db _varval,0
        end if
}
But how far you can take the idea is anyones guess, so far the only down side is it makes your program bigger than if you called a procedure.
As a side effect it's also possible to make portable programs, these to me would run faster and be more optimized than using an interpreted language.
All i can say is fasm is a superb assembler, with many cool macros.
There is little difference between using a macro and inserting the same code in your program.
We also have a gui ver that includes a DarkBasic type commands for higher res graphics.
Batteries not included, Some assembly required.

CartBlanche
Posts: 16
Joined: Fri Nov 04, 2011 10:04 pm
Contact: Website

Re: Game Console OS

Thu Oct 25, 2012 9:33 pm

It has nearly been a year since I posted on this thread, but progress has been made, and I just wanted to point out that Dean, from the MonoGame team, has successly got MonoGame and 3D working on the Raspberry Pi. Please watch the video here - http://www.youtube.com/watch?v=jwbYe6eoZgE

I'd still love to see an ultra cheap hand held gaming device that almost anyone can write games for.

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: Game Console OS

Thu Oct 25, 2012 11:32 pm

https://github.com/cheery/node-video

This is my GNOMEDIE -attack vector. If it unfolds it'll make game programming on linux little bit more pleasant.

Return to “Other projects”