Jump to content
IGNORED

Tic Tac Toe for INTV


vprette

Recommended Posts

I try to practise with intybasic by porting a simple Tic Tac Toe concept.

 

So far I just started using the Print statement, and defining the variables.

 

One question: is the INT command implemented? to extract integer from a math expression? I dont see in the manual..

If I compile the line

x=3*INT((m-1)/3)+1

compilation is fine, but when running with jzintv I have error..

 

Do you like the blinking color yellow/green I use? dont know if it is ok for the title screen..

thanks

tic_v03.rom

Edited by vprette
  • Like 2
Link to comment
Share on other sites

I try to practise with intybasic by porting a simple Tic Tac Toe concept.

 

So far I just started using the Print statement, and defining the variables.

 

One question: is the INT command implemented? to extract integer from a math expression? I dont see in the manual..

If I compile the line

x=3*INT((m-1)/3)+1

compilation is fine, but when running with jzintv I have error..

 

Do you like the blinking color yellow/green I use? dont know if it is ok for the title screen..

thanks

 

The blinking effect looks cool. The green on black does not really look appealing for a title screen, at least in my opinion, unless it relates to the game (like a space war). It could be also that it looks much too plain for a title screen.

 

I would recommend playing with the layout first: center the title horizontally on the screen, and maybe add a simple # grid with x's and 0's below it. You can make the x's and 0's alternate between green and yellow. :)

 

-dZ.

Link to comment
Share on other sites

 

The blinking effect looks cool. The green on black does not really look appealing for a title screen, at least in my opinion, unless it relates to the game (like a space war). It could be also that it looks much too plain for a title screen.

 

I would recommend playing with the layout first: center the title horizontally on the screen, and maybe add a simple # grid with x's and 0's below it. You can make the x's and 0's alternate between green and yellow. :)

 

-dZ.

improved

tic_v04.rom

Link to comment
Share on other sites

new version

 

I use now cont1.xxx to store info about buttons pressed on the controller.

I use to move from title to main screen.

Seems convenient, but I have some strange behaviour, like when going again in the same procedure to check a second time the buttons (say, to move from main screen to second screen) it's like the value of cont1.left is the same of before, so when I press left in the Title screen, everytine I check again, seems like left is pressed forever.. sorery something I check wrong.. have to understand

tic_v05.rom

Edited by vprette
Link to comment
Share on other sites

new version

 

I use now cont1.xxx to store info about buttons pressed on the controller.

I use to move from title to main screen.

Seems convenient, but I have some strange behaviour, like when going again in the same procedure to check a second time the buttons (say, to move from main screen to second screen) it's like the value of cont1.left is the same of before, so when I press left in the Title screen, everytine I check again, seems like left is pressed forever.. sorery something I check wrong.. have to understand

How do i start a game? I tried v04 and could not get off the title screen.

Link to comment
Share on other sites

new version

 

I use now cont1.xxx to store info about buttons pressed on the controller.

I use to move from title to main screen.

Seems convenient, but I have some strange behaviour, like when going again in the same procedure to check a second time the buttons (say, to move from main screen to second screen) it's like the value of cont1.left is the same of before, so when I press left in the Title screen, everytine I check again, seems like left is pressed forever.. sorery something I check wrong.. have to understand

 

Much better title screen! The only thing I would change is to make the highlight change of the text have an even delay on every change. To me it seems like it does:

 

One... Two... ThreeOne... Two... ThreeOne... Two... ThreeOne... (etc.)

 

As if it restarts too fast after the last change.

 

As for your problem, I don't really understand it. Is "cont1.xxx" a variable you defined? If so, you may need to clear it before waiting for a key.

 

-dZ.

Link to comment
Share on other sites

new version

 

I use now cont1.xxx to store info about buttons pressed on the controller.

I use to move from title to main screen.

Seems convenient, but I have some strange behaviour, like when going again in the same procedure to check a second time the buttons (say, to move from main screen to second screen) it's like the value of cont1.left is the same of before, so when I press left in the Title screen, everytine I check again, seems like left is pressed forever.. sorery something I check wrong.. have to understand

cont1.xxx returns the "state" of the buttons, rather than a button press.

On your second screen, you should wait until cont1.xxx = 0 (maybe for several times in a row), then check for a pressed value again.

 

Maybe something like this:

rem draw title screen

check_key: if (cont1.left =1) then goto select_screen
      wait
goto check_key


select_screen:
rem draw select screen

wait_for_key_release: 
       if (cont1.left=1) then wait : goto wait_for_key_release

check_key2:
    if (cont1.left =1) then goto game_screen
    wait

goto check_key2

game_screen:
Link to comment
Share on other sites

 

cont1.xxx returns the "state" of the buttons, rather than a button press.

On your second screen, you should wait until cont1.xxx = 0 (maybe for several times in a row), then check for a pressed value again.

 

Maybe something like this:

rem draw title screen

check_key: if (cont1.left =1) then goto select_screen
      wait
goto check_key


select_screen:
rem draw select screen

wait_for_key_release: 
       if (cont1.left=1) then wait : goto wait_for_key_release

check_key2:
    if (cont1.left =1) then goto game_screen
    wait

goto check_key2

game_screen:

 

it does not sound very clear to me, bu I will understand testing some code tonight

Link to comment
Share on other sites

I'm waiting in the main screen for a hitten button.

I do gosub this procedure

 

hit: procedure
IF cont1.left THEN tasto=15
IF cont1.right THEN tasto=15
IF cont1.up THEN tasto=15
IF cont1.down THEN tasto=15
IF cont1.button THEN tasto=15
IF CONT1.KEY=1 THEN tasto=1
IF CONT1.KEY=2 THEN tasto=2
IF CONT1.KEY=3 THEN tasto=3
IF CONT1.KEY=4 THEN tasto=4
IF CONT1.KEY=5 THEN tasto=5
IF CONT1.KEY=6 THEN tasto=6
IF CONT1.KEY=7 THEN tasto=7
IF CONT1.KEY=8 THEN tasto=8
IF CONT1.KEY=9 THEN tasto=9
IF CONT1.KEY=10 THEN tasto=10
IF CONT1.KEY=12 THEN tasto=12
return
end

 

and want to use the value of tasto after then...

but value of tasto is nosense...

Edited by vprette
Link to comment
Share on other sites

Sometimes it's difficult to check the true behavior of a subroutine.

 

I would suggest to create a small program to test your subroutine:

main:
   WAIT
   GOSUB hit
   PRINT AT 40,(tasto/10%10+16)*8+7,(tasto%10+16)*8+7
   GOTO main

Please note that CONT1.KEY and CONT2.KEY are only updated after each WAIT, so if you check them continously, these will be fixed until control passes through a WAIT statement.

Link to comment
Share on other sites

I'm waiting in the main screen for a hitten button.

I do gosub this procedure

 

hit: procedure

IF cont1.left THEN tasto=15

IF cont1.right THEN tasto=15

IF cont1.up THEN tasto=15

IF cont1.down THEN tasto=15

IF cont1.button THEN tasto=15

IF CONT1.KEY=1 THEN tasto=1

IF CONT1.KEY=2 THEN tasto=2

IF CONT1.KEY=3 THEN tasto=3

IF CONT1.KEY=4 THEN tasto=4

IF CONT1.KEY=5 THEN tasto=5

IF CONT1.KEY=6 THEN tasto=6

IF CONT1.KEY=7 THEN tasto=7

IF CONT1.KEY=8 THEN tasto=8

IF CONT1.KEY=9 THEN tasto=9

IF CONT1.KEY=10 THEN tasto=10

IF CONT1.KEY=12 THEN tasto=12

return

end

 

and want to use the value of tasto after then...

but value of tasto is nosense...

Maybe you need to initialize tasto at the beginning of the procedure?

 

hit: procedure

tasto = 0

IF cont1.left THEN tasto=15

IF cont1.right THEN tasto=15

 

That way, no buttons are pressed, the tasto is zero.

Link to comment
Share on other sites

Maybe you need to initialize tasto at the beginning of the procedure?

 

hit: procedure

tasto = 0

IF cont1.left THEN tasto=15

IF cont1.right THEN tasto=15

 

That way, no buttons are pressed, the tasto is zero.

 

to be honest, it really look like the cont1.left value is buffered for a long time... so no matter if each loop I set tasto=0, it suddendly goes to 15 because cont1.left is still not zero even if I press nothing...

in fact I solved the issue inserting many wait commands

 

hit: procedure

tasto = 0

wait

IF cont1.left THEN tasto=15

wait

IF cont1.right THEN tasto=15

wait

IF cont1.up THEN tasto=15

wait

...

...

 

BUT this way the pause is too long so maybe I have the opposite: pressing the key again and nothing happend because there is still a wait instance not ended....

so now my sw works but looks like the controller button is broken and you have to hit it 2-3 times :-)

Edited by vprette
Link to comment
Share on other sites

Valter,

 

The WAIT statement pauses execution until the next VBLANK interrupt.

 

I'm not sure how IntyBASIC reads the controller, but by your description, it sounds like it only does so during the ISR, 60 times a second, so you require a WAIT before reading the controller.

 

If so, you'll need something like:

 

hit: procedure

tasto = 0

wait

 

if cont1.left then tasto = 15

if cont1.right then tasto = 15

...

Etc.

 

 

P.S. Is it me or does "tasto" sound like a brand of canned sauce? "Just add Tast-O and PRESTO! Instant delicious chicken casserole!" :lol:

Link to comment
Share on other sites

Small tip - stop reading the controller so many times. Every read of it requires a WAIT, which as you have discovered slows things down tremendously.

 

Instead try this:

 

WAIT

c1=cont1

if c1= *magic number that indicates left* then tasto=10

if c1= *magic number that indicates right* then tasto=15

 

Take the controller 1 input and store it in its own variable. Then do your checks on that variable. I've found that it's the only way to do really fancy work with the keypad - maybe I'm missing something with IntyBASIC. Oh, and the magic numbers? You'll need to work them out. Quick and dirty way, write a loop that does this:

 

loop:

WAIT

c1=cont1

PRINT AT 20,(c1*16)*8+6

 

goto loop

 

That will display the controller 1 value depending on what you press. You can make a quick lookup table that way.

 

There may be a better way to do this, but I've found that IntyBASIC is not the most efficient way to read keypad input. It works just fine for UDLR and the fire buttons though.

Link to comment
Share on other sites

Hello

thanks for you suggestions!

I made an intybasic program that I share to check the hitted keypads, and I shere with you: if you test it and find bugs please tell me

 

NOTE:

c1 and 2 show the actual value stored by system var cont1 and cont2

 

1 BUG I already know: form some reason I'm not able to detect the Enter button in the controllers.

 

keypad V02

keypad_v02.rom

Edited by vprette
Link to comment
Share on other sites

and this is the last fixed rom.

I did my best but there is still the Enter bug

 

according to manual, when pressing Enter, I should have con1.key=12

but for mistery if I check this number it appears to be always pressed: it's like for the compiler the controller Enter is always on... any hint?

 

My copy of the manual says:

 

CONT1.KEY Current pressed key (0-9 for numbers, 10-Clear, 11-Enter, 12-Not pressed)

So pressing enter should return the value 11, and pressing no key should return 12.

  • Like 1
Link to comment
Share on other sites

So far so good. I can't lose!

 

I think it would be cool if you drew the grid, and used the numbers instead of "E". That way it would be easy to see what buttons to press.

 

Something like this:

 

post-14916-0-78812400-1414512543_thumb.gif

 

Here is the code I used to draw that:

	REM
	REM TTT grid
	REM Created in IntyBASIC
	REM by Catsfolly
	REM October 2014.
	REM 
			

REM some Intellivision hardware constants

	CONST BACKTAB		= $0200
	CONST CS_GRAM		= $0800				' get picture from gram
	CONST CS_CARD		= $01f8				' gram or grom card number

	CONST MB_X_XPOS		= $00FF				' mask for x pos
	CONST MB_X_INTR		= $0100				' enable collision regs
	CONST MB_X_VIS		= $0200				' make mob visible
	CONST MB_X_XSIZE	= $0400				' double size in x

	CONST MB_Y_YPOS		= $007F				' mask for y pos
	CONST MB_Y_YRES		= $0080				' 16 bits in y
	CONST MB_Y_YSIZ2	= $0100				' double y size
	CONST MB_Y_YSIZ4	= $0200				' 4 times y size
	CONST MB_Y_YSIZ8	= $0300				' 8 times y size
	CONST MB_Y_XFLIP	= $0400				' x flip
	CONST MB_Y_YFLIP	= $0800				' y flip

	CONST MB_A_GRAM		= $0800				' get picture from gram
	CONST MB_A_CARD		= $07f8				' mask for picture no.
	CONST MB_A_PRIO		= $2000				' priority (above/below bkgnd)


REM colors for color stack, border, etc

	CONST C_BLK  = $0              ' Black
	CONST C_BLU  = $1              ' Blue
	CONST C_RED  = $2              ' Red
	CONST C_TAN  = $3              ' Tan
	CONST C_DGR  = $4              ' Dark Green
	CONST C_GRN  = $5              ' Green
	CONST C_YEL  = $6              ' Yellow
	CONST C_WHT  = $7              ' White
	CONST C_GRY  = $8              ' Grey
	CONST C_CYN  = $9              ' Cyan
	CONST C_ORG  = $A              ' Orange
	CONST C_BRN  = $B              ' Brown
	CONST C_PNK  = $C              ' Pink
	CONST C_LBL  = $D              ' Light Blue
	CONST C_YGR  = $E              ' Yellow-Green
	CONST C_PUR  = $F              ' Purple

rem colors for backtab or mob a
	CONST X_BLK  = $0              ' Black
	CONST X_BLU  = $1              ' Blue
	CONST X_RED  = $2              ' Red
	CONST X_TAN  = $3              ' Tan
	CONST X_DGR  = $4              ' Dark Green
	CONST X_GRN  = $5              ' Green
	CONST X_YEL  = $6              ' Yellow
	CONST X_WHT  = $7              ' White
	CONST X_GRY  = $1000           ' Grey
	CONST X_CYN  = $1001           ' Cyan
	CONST X_ORG  = $1002           ' Orange
	CONST X_BRN  = $1003           ' Brown
	CONST X_PNK  = $1004           ' Pink
	CONST X_LBL  = $1005           ' Light Blue
	CONST X_YGR  = $1006           ' Yellow-Green
	CONST X_PUR  = $1007           ' Purple

	CONST GRID_COL = X_YEL
	CONST H_BAR = ( 211 *  + GRID_COL
	CONST V_BAR = (  92 *  + GRID_COL
	CONST TEE   = (  60 *  + GRID_COL + CS_GRAM




title:
	mode 0,C_DGR,C_DGR,C_DGR,C_DGR
	WAIT
        DEFINE 60,1,gramchars ' load the custom character definitions
	WAIT

	cls		' clear the screen
	
	
    REM the screen is 20 chars wide so position is 20 * row + col
        print at (20* 3 + 5) COLOR C_WHT,"1"
	print  V_BAR
	print  "2"
	print  V_BAR
	print "3"

   	print at (20* 4 + 5), H_BAR
	print TEE
	print H_BAR
	print TEE
	print H_BAR

   	print at (20* 5 + 5) COLOR C_WHT,"4"
	print  V_BAR
	print  "5"
	print  V_BAR
	print "6"

	print at (20* 6 + 5), H_BAR
	print TEE
	print H_BAR
	print TEE
	print H_BAR

	print at (20* 7 + 5) COLOR C_WHT,"7"
	print  V_BAR
	print  "8"
	print  V_BAR
	print "9"
 	
	WAIT
	

		
REM *****************************************************************
REM
REM loop - main gameplay loop
REM
REM *****************************************************************
loop:	
	WAIT

    goto loop
	
	
REM main gameplay loop end *****************************************************************	
	
gramchars:

REM 60

	BITMAP "   ##   "
	BITMAP "   ##   "
	BITMAP "   ##   "
	BITMAP "########"

	BITMAP "########"
	BITMAP "   ##   "
	BITMAP "   ##   "
	BITMAP "   ##   "


Catsfolly

Edited by catsfolly
  • Like 1
Link to comment
Share on other sites

I have a running rom now, but some bug make the intellivision freeze when 2nd cell is occupied, and in some configuration it pass the turn without chosing a cell... so I think I will write the logic from scratch myself (I was using Ahl tic tac toe algorithm)

 

If I could work on it every day I guess I would deliver this rom in 3 weeks... need to find time in fact during night :-)

  • Like 1
Link to comment
Share on other sites

I have a running rom now, but some bug make the intellivision freeze when 2nd cell is occupied, and in some configuration it pass the turn without chosing a cell... so I think I will write the logic from scratch myself (I was using Ahl tic tac toe algorithm)

 

If I could work on it every day I guess I would deliver this rom in 3 weeks... need to find time in fact during night :-)

Valter,

If you post your code, I may be able to help you find out the problem. If you don't want to share your source publicly, you can send me a PM.

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...