thought i would share this with yall....

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

thought i would share this with yall....

Post 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
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

Post 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.....
jasbales
Coder
Posts: 17
Joined: Mon Nov 22, 2004 11:36 am
Location: Prescott AZ
Contact:

Post by jasbales »

Have you tried BCX?
User avatar
floogle11
Veteran
Posts: 71
Joined: Sat May 02, 2009 7:08 pm
Location: Zorgon planet
Contact:

wat

Post by floogle11 »

whats bcx
Go to my Qbsite its: Trueqb.webs.com
Or if you play nazi zombies go to www.Nazizombys.com and register for cheats, hints, and strategys.
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

Post 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
iamdenteddisk
Veteran
Posts: 185
Joined: Mon Jun 30, 2008 4:10 pm

cool

Post 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?
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post 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.
Mida sa loed ? Nagunii aru ei saa :P
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

Post 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
Post Reply