Willsy Posted April 19, 2010 Share Posted April 19, 2010 (edited) Here's the source for one of the demo's. This probably looks scary, but it isn't. If I can do it, *anyone* can, seriously! Please ask if there's anything you don't understand. By the way: DCHAR is the equivalent of CHAR in TI BASIC. (CHAR means something else in Forth ) ( ** StarField Sprite Demo ** ) VARIABLE RND HERE RND ! ( seed ) VARIABLE StringSpace 82 CHARS ALLOT ( create a string buffer ) StringSpace 84 32 FILL ( initialise it to ASCII 32 ) S" The Power Of Forth!" ( addr len ) StringSpace ( addr len addr ) SWAP ( addr addr len ) CMOVE> ( move string into buffer ) 0 VALUE FlipFlop ( ascii codes for small, medium, and big stars ) 64 CONSTANT Sml* 65 CONSTANT Med* 66 CONSTANT Big* ( keyboard codes ) CHAR E CONSTANT KeyE CHAR S CONSTANT KeyS CHAR D CONSTANT KeyD CHAR X CONSTANT KeyX ( define colours ) 15 CONSTANT White ( set up user defined graphics for the 3 star sizes ) : UDG 8000$ 0 0 0 4 Sml* DCHAR ( define small star ) 40E0$ 4000$ 0 0 4 Med* DCHAR ( define medium star ) 70F8$ F870$ 0 0 4 Big* DCHAR ( define large star ) ; : RANDOM ( limit -- rnd ) RND @ 31421 * 6927 + DUP RND ! ABS SWAP MOD ; ( generate a random Y coordinate ) : RndY 180 RANDOM ; ( generate a random X coordinate ) : RndX 256 RANDOM ; ( set up our sprites. 10 small, 10 medium, 10 large ) : 10Small 10 FOR I RndY RndX Sml* White SPRITE NEXT ; : 10Med 10 FOR I 10 + RndY RndX Med* White SPRITE NEXT ; : 10Big 10 FOR I 20 + RndY RndX Big* White SPRITE NEXT ; ( these routines set up the sprite movement list for each direction ) : GoLeft 10 FOR I 0 -1 SMLIST NEXT 10 FOR I 10 + 0 -2 SMLIST NEXT 10 FOR I 20 + 0 -3 SMLIST NEXT ; : GoRight 10 FOR I 0 1 SMLIST NEXT 10 FOR I 10 + 0 2 SMLIST NEXT 10 FOR I 20 + 0 3 SMLIST NEXT ; : GoUp 10 FOR I -1 0 SMLIST NEXT 10 FOR I 10 + -2 0 SMLIST NEXT 10 FOR I 20 + -3 0 SMLIST NEXT ; : GoDown 10 FOR I 1 0 SMLIST NEXT 10 FOR I 10 + 2 0 SMLIST NEXT 10 FOR I 20 + 3 0 SMLIST NEXT ; : Delay 100 FOR NEXT ; : DoFlipFlop FlipFlop NOT DUP TO FlipFlop ; : ScanKeys KEY? CASE KeyE OF GoUp ENDOF KeyS OF GoLeft ENDOF KeyD OF GoRight ENDOF KeyX OF GoDown ENDOF ENDCASE BREAK? ; : Scroll DoFlipFlop IF [ StringSpace 83 + LITERAL ] C@ [ StringSpace LITERAL StringSpace 1+ LITERAL ] 83 CMOVE> [ StringSpace LITERAL ] C! 0 0 GOTOXY [ StringSpace 32 + LITERAL ] 31 TYPE 0 23 GOTOXY [ StringSpace 32 + LITERAL ] 31 TYPE ScanKeys THEN ; : Setup 1 GMODE 0 SCREEN UDG 10Small 10Med 10Big GoRight ; : GO Setup BEGIN 0 30 SPRMOV Scroll Delay AGAIN ; GO Edited April 19, 2010 by Willsy Quote Link to comment Share on other sites More sharing options...
unhuman Posted April 19, 2010 Share Posted April 19, 2010 btw - if you could eventually get interrupt driven sprites to work, or provide some mechanism to sync to the refresh rate, that'd be awesome. Wouldn't want our games to behave all crazy depending on the amount of work done in the game loop.... Quote Link to comment Share on other sites More sharing options...
Willsy Posted April 20, 2010 Share Posted April 20, 2010 btw - if you could eventually get interrupt driven sprites to work, or provide some mechanism to sync to the refresh rate, that'd be awesome. Wouldn't want our games to behave all crazy depending on the amount of work done in the game loop.... Ok, I'll add it to the 'to do' list! Mark Quote Link to comment Share on other sites More sharing options...
unhuman Posted April 20, 2010 Share Posted April 20, 2010 Ok, I'll add it to the 'to do' list! Wow. If it's that easy to get you to do work, I'll humbly request that you make it write the game itself. Quote Link to comment Share on other sites More sharing options...
The Codex Posted April 20, 2010 Share Posted April 20, 2010 Yeah, can I have MIDI support built in now? Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 20, 2010 Author Share Posted April 20, 2010 Yea-- I want speech to text capabilities... All that typing stuff is overrated. Speech to text--- I can program while I'm driving all over this country. Quote Link to comment Share on other sites More sharing options...
Willsy Posted April 20, 2010 Share Posted April 20, 2010 Ok, I'll add it to the 'to do' list! Wow. If it's that easy to get you to do work, I'll humbly request that you make it write the game itself. This feature is already included. Just type DOGAME. Takes a VERY long time to run though Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 20, 2010 Author Share Posted April 20, 2010 So THATS the word!!! I was trying "WRITEMYGAMEBITCH" and it kept kicking out a question mark Quote Link to comment Share on other sites More sharing options...
unhuman Posted April 26, 2010 Share Posted April 26, 2010 Got my book. It looks to be written C-Bible style, which is a complement. Hopefully I'll get to the actual reading soon. -H Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 28, 2010 Author Share Posted April 28, 2010 I have received my big blue Forth book in the mail as well. To this point, I have done my reading online and worked with Wycove Forth on Classic99. Happy happy joy joy!!! Come on Willsy... OUT WITH TURBOFORTH!!!! Quote Link to comment Share on other sites More sharing options...
unhuman Posted April 28, 2010 Share Posted April 28, 2010 Yeah gave it a good read last night. Think I made it through 3 or 4 chapters. I'm hoping that we don't have to deal with the file system limitations described in the book. Icky! -H I have received my big blue Forth book in the mail as well. To this point, I have done my reading online and worked with Wycove Forth on Classic99. Happy happy joy joy!!! Come on Willsy... OUT WITH TURBOFORTH!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.