Jump to content



Opry99er's Photo

Opry99er

Member Since 18 Nov 2009
OFFLINE Last Active Oct 31 2011 5:16 PM

Posts I've Made

In Topic: Forth Tutorials

Mon Oct 31, 2011 5:20 PM

Good info, Lee and Mark. I'm very appreciative and I will be factoring my code out a bit more. I'm very busy these days at work, but glad to have TF to take my mind off monotony. Gracias...

In Topic: Forth Tutorials

Wed Oct 26, 2011 8:49 PM

<<erased double post>>

In Topic: Forth Tutorials

Wed Oct 26, 2011 8:49 PM

Hey Willsy... I'm working on something and I thought I'd post it here. I use two blocks, 9 and 10. Basically it tests out GCHAR very simply. One issue I'm having, however--- I think I know why it's doing this, but I'll post it here to hear more informed opinions than my own.


**sorry for the bad butchering of indentation and formatting
**Block 9**
: TEST															
BEGIN													  
		PY PX 42 1 HCHAR											  
	    KEY? DUP											  
		-1 <> IF														
  PY PX 32 1 HCHAR									  
	 RCHK DUP 68 = IF DROP PX XMAX 1- < IF 1 +TO PX THEN ELSE	  
     UCHK DUP 69 = IF DROP PY 0 > IF -1 +TO PY THEN ELSE	  
	 LCHK DUP 83 = IF DROP PX 0 > IF -1 +TO PX THEN ELSE			
	 DCHK DUP 88 = IF DROP PY 23 < IF 1 +TO PY THEN ELSE	  
		 32 = IF EXIT THEN											
   THEN THEN THEN THEN									
		ELSE DROP 2 + THEN AGAIN							  
;
**************************************
**Block 10**

10 VALUE PX 5 VALUE PY										
: RCHK DUP 68 = IF PY PX 1+ GCHAR							  
	 32 <> IF 2 +													  
  THEN THEN ;											
: UCHK DUP 69 = IF PY 1- PX GCHAR								  
32 <> IF 2+											  
		THEN THEN ;											
: LCHK DUP 83 = IF PY PX 1- GCHAR							  
	 32 <> IF 2 +													  
  THEN THEN ;											
: DCHK DUP 88 = IF PY 1+ PX GCHAR								  
32 <> IF 2 +											  
		THEN THEN ;																											
9 LOAD														
: TRY PAGE 11 6 35 10 HCHAR TEST ;							

When I run this, it works wonderfully. I'm kind of taking a roundabout way of doing this, I think, but my first goal was to "get something to work" and then find the "right" way to do it shortly thereafter.

The bar in the middle of the screen appears and you move around the screen very nicely. When you encounter the bar, it works as expected and doesn't allow movement. Fast fast fast.... nothing like GCHAR in XB... So I am very pleased thus far.

Now to the issue... When you're at the very top row of the screen and moving left, you can move out of the screen causing a crash. Now, the way I handled the "flag" for GCHAR is unconventional at best and probably inefficient, but it works for the most part... I basically skew the key input (if the checked screen location holds something other than a "space" character) so that it won't show up in the IF checks for the remainder of the loop, thereby skipping some steps. It's probably the absolute WRONG way to do it, but I figured it out and it seems to work (for the most part).

I'll be back on tomorrow night with some optimizations... I started incorporating all the checks for GCHAR AND screen parameters into one word per direction but haven't finished that yet. UCHK will have GCHAR as well as check for screen parameters... It's about done but not quite. then I'm actually going to draw something to navigate through... a maze of sorts.

In Topic: Forth Tutorials

Tue Oct 25, 2011 1:54 PM

Most of the code should be portable, however the conventions and built-in words different. Mark would have more information than I would about this, but my suggestion would be to try to load the programs or type in some of the smaller ones and see if they work. More than likely (as it seems with most Forths) it will be mostly compatible with some differences in root words. Others would be better suited to answer this than myself, but I thought I'd lend my minute understanding to the conversation.

I spent part of Sunday working on GCHAR additions to the test code we had going above... got some neat stuff going... I should be able to show something in the next couple of days. =)

In Topic: Forth Tutorials

Sat Oct 22, 2011 8:57 PM

Wow... that's GREAT stuff, Mark. =) Tomorrow should be a good day for me. I had to work this Saturday (tonight) but Sunday I'm taking a bit of time to work on a Forthing project or two.

XMAX is an interesting thing... And the optimization ideas are enlightening. And yes... I'm learning to love Forth. =)