Page 1 of 1

thought i would share this with yall....

Posted: Thu May 07, 2009 5:04 pm
by bongomeno
Me and my friend were messing around with a game boy emulator and had an idea..... LETS MAKE A GAME FOR THE GAME BOY!!!

so we did some studying for a night and came up with this:
only ASM and C are usually used to program the gameboy. (and maby c++ with extra effort)
he knows c++ and I know Basic...

i tried looking for a basic interpreter/compiler for the gameboy and found 1. GB BASIC! it is a line oriented basic interpreter that runs on the gameboy!!!! cool, but not what we need.... (i will only use it for fun)
we are now learning C. and started on making a game!

AAAAAAAAAANNNNNNNYYYYYY WAAAAAAAAYYYYYY......................

i got the idea to write a simple BASIC to C translater!!!!!

****************************************
THIS REQUIRES THE GBDK (game boy development kit) C COMPILER IF YOU WANT TO COMPILE THE C CODE THAT IT OUTPUTS!
****************************************

here is the test version (works fine when tested):
sorry for the sloppy uncommented code... lol

Code: Select all

CLS
PRINT "GBE-BASIC,"
PRINT "THE EXTENDED TINY BASIC TO C TRANSLATOR FOR THE GAME BOY."
PRINT
PRINT "GEEK BASIC SOFTWARE"
PRINT

LINE INPUT "SOURCE *.BAS : "; source$
LINE INPUT "OUTPUT *.C   : "; output$

OPEN source$ + ".BAS" FOR INPUT AS #1
OPEN output$ + ".C" FOR OUTPUT AS #2

PRINT #2, "#include <gb>"
PRINT #2, "#include <stdio>"
PRINT #2, "int main(){"

DO UNTIL EOF(1)

LINE INPUT #1, in$
LET in$ = LTRIM$(RTRIM$(in$))

IF LEFT$(in$, 3) = "REM" THEN
PRINT #2, "//" + MID$(in$, 4, LEN(in$) - 3)
END IF

IF LEFT$(in$, 4) = "DEF " THEN
PRINT #2, "int "; MID$(in$, 5, LEN(in$) - 4); ";"
END IF

IF LEFT$(in$, 6) = "PRINT " THEN
PRINT #2, "printf(" + MID$(in$, 7, LEN(in$) - 6) + ");"
END IF

IF LEFT$(in$, 6) = "INPUT " THEN
PRINT #2, MID$(in$, 7, LEN(in$) - 6) + "=joypad();"
END IF

IF LEFT$(in$, 4) = "LET " THEN
PRINT #2, MID$(in$, 5, LEN(in$) - 4) + ";"
END IF

IF LEFT$(in$, 3) = "IF " THEN
PRINT #2, "if ("; MID$(in$, 4, INSTR(in$, " THEN") - 4) + "){"
END IF

IF in$ = "ENDIF" THEN
PRINT #2, "}"
END IF

IF LEFT$(in$, 6) = "WHILE " THEN
PRINT #2, "while (" + MID$(in$, 7, LEN(in$) - 6) + "){"
END IF

IF in$ = "WEND" THEN
PRINT #2, "}"
END IF

IF in$ = "EXIT" THEN
PRINT #2, "break;"
END IF

IF in$ = "END" THEN
PRINT #2, "printf(" + CHR$(34) + "\n---END OF PROGRAM---" + CHR$(34) + ");"
PRINT #2, "while (1){}"
END IF

LOOP

PRINT #2, "}"

CLOSE #1
CLOSE #2

PRINT "DONE!"
SLEEP
END
HERE IS A SAMPLE PROGRAM...

Code: Select all

REM 99 BOTTLES OF BEER!!!

DEF beer
DEF k

LET beer=99
LET k=0

PRINT "PRESS START TO START...\n"

WHILE 1
INPUT k
IF k&J_START THEN
EXIT
ENDIF
WEND

WHILE beer>1
PRINT "%d",beer
PRINT " BOTTLES OF BEER ON THE WALL!\n"
PRINT "%d",beer
PRINT " BOTTLES OF BEER!\n"
PRINT "TAKE ONE DOWN AND PASS IT AROUND...\n"
LET beer=beer-1
WEND

PRINT "AWWW.... NO MORE BEER!"
END

Posted: Thu May 07, 2009 5:07 pm
by bongomeno
eeerrrmmmm... something is wrong with this froum thing.
parts of the code were snipped off!
the part that prints the preprocessors for example should have .h extensions.....

Posted: Fri May 08, 2009 3:51 am
by jasbales
Have you tried BCX?

wat

Posted: Sat May 09, 2009 9:17 am
by floogle11
whats bcx

Posted: Sat May 09, 2009 10:10 am
by bongomeno
yes i have, bcx dosent create C source to be compiled for the gameboy!
i needed one that compiles with the GBDK.

bcx isa good basic to c translator

cool

Posted: Wed May 20, 2009 11:51 pm
by iamdenteddisk
if I am not mistaken the Game boy uses a cmos type Z80 processor if I can find a little bit of info on its functions list "rom routines" I could maybe burn your program to a eprom chip for you and make a actual cartridge game of it . How dedicated to this idea are you?

Posted: Thu May 21, 2009 3:22 pm
by TmEE
Retro game systems should not be programmed in anything besides ASM.... Z80 ASM is quite nice, and I prefer it over x86... it does not beat 680x0 though :P
You can probably burn a 32KB EPROM, but if you want more then you need some banking method, best method is to use an existing game and replace its mask ROM with a flash ROM chip so you can easily update the contents, that will require some dedicated hardware though.
I cannot comment too much on other game systems besides Mega Drive / Genesis... MD is total jawusumness to mess with.

Posted: Thu May 21, 2009 4:53 pm
by bongomeno
the gb does use z80 up til the gba which uses 2 z80 AND another.
i made this because i dont like using C and C++, but i have written some games in C. i just think that it would be cool if the gameboy had a BASIC compiler/translator. kind of like bataribasic for the atari 2600.
I plan on buying some blank carts and a flash thinggy and working more on learning C so i can make this BASIC idea better.

here is an update btw:

http://www.freewebs.com/geekbasic/GBEBASIC.BAS