6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Sep 26, 2024 11:19 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Thu Feb 10, 2011 3:32 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
I have been working on a Tiny Compiled BASIC for the 6502, which I have named TCB02.

It's now functional enough to be released for Alpha testing.

Currently, the Assembly code generated is targeted to the 6502 Macro Assembler and Simulator by Michal Kowalski.

You can find it here https://docs.google.com/leaf?id=0BxwERmdWmiwjOWE5OTI5ODctMTUyMy00ZmVjLWE5ZjMtYzkyNmViODU5NGFj&hl=en


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 11, 2011 4:23 pm 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
I've updated the compiler. Added FOR/NEXT and MACRO definitions to allow code that is more BASIC like.

I also coded a fully working Hangman game to show that the compiler is fully usable.

Edit I forgot the link to the new version

https://docs.google.com/leaf?id=0BxwERmdWmiwjZDUyMTU0NjItM2EzNi00ZWFjLTk3Y2YtZjU1NjY5Y2YxNTc1&hl=en


Last edited by CurtisP on Fri Feb 11, 2011 10:25 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 11, 2011 6:15 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
:D

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Feb 14, 2011 3:29 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
Another major enhancement.

Added macros and improved the include capabilities.

TCB02 now allows targeting a single program to different machines using properly named configurstion and library files.

It will also create code for different assemblers by using configuration files.

https://docs.google.com/leaf?id=0BxwERmdWmiwjMzU5NTEzNzAtYmIxYi00MWI3LTllMGUtMmEzZmMxMDEyZTQ1&hl=en


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 16, 2011 2:36 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
To give you an idea of the syntax and possibilities of TCB02, here is the source code for the Hangman game.

By specifying the apropriate Import and Include Files, this source code can be compiled for multiple target machines. I have so far compiled versions the 6502 Simulator, and the Vic 20.

Code:
REM Hangman Game for TCB02
REM (C) 2011 Curtis F Kaylor

IMPORT "LIB"
INCLUDE "MACROS"

DIM C, I, J, Found

DIM Word[8]
DIM Right, Wrong, Pick[15]

LABEL Start
  LOCATE 0,10
  PRINT "PRESS ANY KEY TO BEGIN"

REM Set Random Seed Value
  LET I = 0
  REPEAT
    INCR I
    GET C
  UNTIL C <> 0 
  RANDOM I

REM Draw Screen
  CLS
  PUT #CDNRT
  FOR I = 1 TO 5
    PUT #HLINE
  NEXT I
  PUT #CDNLT
  LOCATE 6,1
  PUT ':'
  FOR I = 1 TO 6
    LOCATE 0, I
    PUT #VLINE
  NEXT I
  LOCATE 0,7
  PRINT " WORD ********"
  PRINT " MISS"
  LOCATE 0,10
  PRINT "PRESS A LETTER "

REM Pick Word
  LET Word = 8
  LET I = RND() & $F8
  FOR J = 1 TO 8
    LET I = I + 1
    LET Word[J] = WordList[I]
  NEXT

REM Initialize Variables
  LET Pick = 0
  LET Right = 0
  LET Wrong = 0

LABEL Main
  REM Input Character and Convert to Uppercase
  INP C
  IF C>='a' AND C<='z' THEN LET C=C-32

  REM Check For Break
  IF C = 3 THEN STOP

  REM Make sure it's a Letter
  IF C<'A' OR C>'Z' THEN GOTO Main

  REM See if Letter Was Already Picked
  FOR I = 1 TO Pick
    IF Pick[I] = C THEN GOTO Main
  NEXT

  REM See if Letter is in Word
  LET Found = 0
  FOR I = 1 to Word
    IF Word[I] = C THEN
      LET Right = Right + 1
      LOCATE I+5,7
      PUT C
      GOSUB Repos
      LET Found = 1
    ENDIF
  NEXT

  REM Letter Was Not In Word
  IF Found = 0 THEN
    LET Wrong = Wrong + 1
    LOCATE Wrong+5,8
    PUT C
    GOSUB BodyPart
    GOSUB Repos
  ENDIF

  REM Add to List of Picked Letters
  INCR Pick
  LET Pick[Pick] = C

  IF Right > 7 THEN
    LOCATE 5,9
    PRINT "YOU WIN!"
    GOTO Start
  ENDIF

  IF Wrong > 6 THEN
    LOCATE 5,9
    PRINT "YOU LOSE!"
    GOTO Start
   ENDIF

GOTO Main

LABEL BodyPart
  IF Wrong = 1 THEN
    LOCATE 6,2
    PUT 'O'
  ENDIF
  IF Wrong = 2 THEN
    LOCATE 5,3
    PUT #DLLUR
  ENDIF   
  IF Wrong = 3 THEN
    LOCATE 7,3
    PUT #DULLR
  ENDIF
  IF Wrong = 4 THEN
    LOCATE 6,3
    PUT #VLINE
  ENDIF
  IF Wrong = 5 THEN
    LOCATE 6,4
    PUT #VLINE
  ENDIF
  IF Wrong = 6 THEN
    LOCATE 5,5
    PUT #DLLUR
  ENDIF 
  IF Wrong = 7 THEN
    LOCATE 7,5
    PUT #DULLR
  ENDIF
  RETURN

LABEL Repos
  LOCATE 15,10
  RETURN

DIM WordList = "ABDICATE"
DATA "BACHELOR", "CALZONES", "DINOSAUR", "DUMPSTER"
DATA "DYSTOPIA". "EMPHATIC", "FATIGUED", "GERMANIC"
DATA "HARMONIC", "IGNORANT", "JEALOUSY", "KILOBYTE"
DATA "LAUGHTER", "MAGNETIC", "NOTARIZE", "ORDINARY"
DATA "PERILOUS", "QUACKERY", "REACTION", "SCROUNGE"
DATA "TAPESTRY", "VIRULENT", "BACTERIA", "AQUIFERS"
DATA "BIFOCALS", "ABNORMAL", "CAMISOLE", "DOLPHINS"
DATA "BRITCHES", "ARGUMENT", "BESTIARY"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 17, 2011 7:06 am 
Offline

Joined: Thu Jul 08, 2010 12:53 pm
Posts: 3
Hi,

i tried with 6502 Simulator, it's ok, no problems so far, thanks for your program :)


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 05, 2011 11:57 am 
Offline

Joined: Fri Nov 26, 2010 6:03 pm
Posts: 46
Location: NSW, Australia
Just what the world needs, another closed-source 6502 compiler that's binary-only for an anachronistic computer operating system. This can go into the same pile as the Windows98 GCC6502.EXE I picked off an Oric forum.


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 05, 2011 7:13 pm 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
cjb wrote:
Just what the world needs, another closed-source 6502 compiler that's binary-only for an anachronistic computer operating system. This can go into the same pile as the Windows98 GCC6502.EXE I picked off an Oric forum.


It's only closed source for now. The eventual goal is to rewrite the compiler in the compiled language itself.


Top
 Profile  
Reply with quote  
PostPosted: Sun Mar 06, 2011 7:20 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
CurtisP wrote:
It's only closed source for now. The eventual goal is to rewrite the compiler in the compiled language itself.

Please do open-source it! Even a work in progress is a benefit to others, who might be able to learn from it, or help you fix things or add things - or even test, or document.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Mar 07, 2011 5:17 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
I created a project on Google Code at http://code.google.com/p/tcb02/.

I need to get my code into a reasonable directory structure so I can upload it.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


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 post attachments in this forum

Search for:
Jump to: