Videopac / Odyssey2 forum
October 31, 2020, 07:56:45 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Join Rafael's Haunted Woods contest and win a copy of the game!
 
   Home   arcade Help Login Register links videopac.nl  
Pages: 1 [2] 3   Go Down
  Print  
Author Topic: Swell Foop (in C7420 Basic)  (Read 9159 times)
manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1139



« Reply #15 on: May 28, 2012, 11:43:41 PM »

cool game :-)
Logged

sex, lies, and videopac
Rafael
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2587



« Reply #16 on: May 29, 2012, 02:02:27 AM »

Great  Cheesy
No more a long time wait for the last movements, and also cleaning bonus.
Thereīs no chance to include a kind of grid on it Huh?
Logged
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #17 on: May 29, 2012, 07:21:44 AM »

Great  Cheesy
No more a long time wait for the last movements, and also cleaning bonus.
Speed improved a lot by some rethinking of the test routines, at first I was testing a whole column piece by piece to check if it was empty realizing later that I only needed to test the bottom piece Smiley

Quote
Thereīs no chance to include a kind of grid on it Huh?
Yes that should be possible, I used a single redefined character as object and then display it double height and width, by using 4 redefined characters at normal size it is possible to make an outline and smoother objects. The background color is also not used yet. I first concentrated on the game algorithms which proved much more of a challenge than I thought Smiley

BTW, to make the game a bit more difficult try setting NC to a number greater than 3 (and less than 7) in line 1480
The more different colors the lesser the chance you have large fields of the same color. You can also set the board dimensions MX and MY
Code:
1480 MX=14:MY=9:NC=3

The structure of the code is such that it should be possible to translate the whole game into 8048 assembler.
« Last Edit: May 29, 2012, 07:32:53 AM by gertk » Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #18 on: June 03, 2012, 05:59:51 PM »

Some minor changes, endgame detection sped up a bit by removing redundant checks.
And a grid is visible too  Cheesy
Enjoy!

Code:
1000 REM Swell Foop for Videopac+
1010 REM by gertk(at)xs4all.nl
1020 REM clear screen, disable top line
1030 INIT 0
1040 PRINTCHR$(150);
1050 STORE
1060 TX 2,3,0
1070 PRINT "VViiddeeooppaacc  ";
1080 PRINT "CC77442200"
1090 PRINT "VViiddeeooppaacc  ";
1100 PRINT "CC77442200"
1110 TX 3,3,0
1120 PRINT
1130 PRINT
1140 PRINT "SSwweellll  FFoooopp"
1150 PRINT "SSwweellll  FFoooopp"
1160 PRINT
1170 PRINT
1180 TX 4,0,0
1190 PRINT "(c)2012 gertk@xs4all.nl";
1200 DISPLAY:SCREEN
1210 FOR T=1 TO 2000:NEXT T
1220 INIT 0
1230 PRINTCHR$(150);
1240 STORE
1250 TX 7,0,0
1260 PRINT "Swell Foop is a puzzle ";
1270 PRINT "game."
1280 PRINT
1290 PRINT "The goal is to remove";
1300 PRINT " as many objects"
1310 PRINT "as possible in ";
1320 PRINT "as few moves as"
1330 PRINT "possible."
1340 PRINT "Objects adjacent to each";
1350 PRINT " other get"
1360 PRINT "removed as a group."
1370 PRINT "The remaining objects";
1380 PRINT " then collapse"
1390 PRINT "to fill in the gaps and";
1400 PRINT " new groups are"
1410 PRINT "formed."
1420 PRINT "You cannot remove single";
1430 PRINT " objects."
1440 PRINT
1450 TX 2,0,0
1460 PRINT "press button to start.."
1470 DISPLAY:SCREEN
1480 GOSUB 3570
1490 REM reset score
1500 SC=0
1510 REM board dimensions and nr. of colors
1520 MX=15:MY=10:NC=4
1530 REM define graphics characters
1540 SETET 37,"00fefefefefefefefefe"
1550 SETET 38,"00412214080814224100"
1560 DIM BD(MX,MY)
1570 REM pseudo stack for search
1580 DIM SX(MX*MY),SY(MX*MY)
1590 REM fill array
1600 FOR X=0 TO MX
1610 FOR Y=0 TO MY
1620 BD(X,Y)=1+INT(RND(1)*NC)
1630 NEXT Y
1640 NEXT X
1650 PY=MY:PX=0
1660 EX=MX
1670 INIT 4
1680 PRINTCHR$(150);
1690 REM main loop
1700 GOSUB 3010
1710 GOSUB 3210
1720 SOUND 6
1730 STORE
1740 MD=1:DX=PX:DY=PY:GOSUB 2840
1750 SCREEN:DISPLAY
1760 REM wait for joystick movement
1770 JS=ACTION(0):IF JS=0 THEN 1770
1780 REM action button pressed
1790 IF JS AND 1 THEN 1940
1800 STORE
1810 MD=0:DX=PX:DY=PY:GOSUB 2840
1820 SCREEN:DISPLAY
1830 REM check directional movement
1840 IF JS AND 8 THEN PY=PY+1
1850 IF PY>MY THEN PY=MY
1860 IF JS AND 16 THEN PY=PY-1
1870 IF PY<0 THEN PY=0
1880 IF JS AND 2 THEN PX=PX+1
1890 IF PX>MX THEN PX=MX
1900 IF JS AND 4 THEN PX=PX-1
1910 IF PX<0 THEN PX=0
1920 GOTO 1730
1930 REM action !
1940 FC=BD(PX,PY)
1950 REM check for empty space
1960 IF FC=0 THEN SOUND 5:GOTO 1730
1970 REM set search coordinates
1980 FX=PX:FY=PY
1990 REM reset yield
2000 YD=0
2010 STORE
2020 GOSUB 2230
2030 SOUND 1
2040 REM show yield in double height
2050 TX 7,1,0
2060 CURSORY 10:CURSORX 33
2070 PRINT"Yield:";
2080 CURSORY 11:CURSORX 33
2090 PRINT"Yield:";
2100 CURSORY 12:CURSORX 33
2110 PRINT STR$(YD);"  ";
2120 CURSORY 13:CURSORX 33
2130 PRINT STR$(YD);"  ";
2140 REM force screen update and redraw
2150 DISPLAY:SCREEN
2160 REM check fall or swoop
2170 GOSUB 2350
2180 REM calculate score
2190 IF YD<2 THEN SOUND 8:GOTO 1730
2200 SC=SC+(YD-2)^2
2210 GOTO 1700
2220 REM search start
2230 SP=0
2240 REM searchloop
2250 X=FX+1:Y=FY:GOSUB 2730
2260 X=FX-1:Y=FY:GOSUB 2730
2270 X=FX:Y=FY-1:GOSUB 2730
2280 X=FX:Y=FY+1:GOSUB 2730
2290 REM if no adjacent pieces found
2300 IF SP=0 THEN RETURN
2310 REM get next coordinates from stack
2320 FX=SX(SP):FY=SY(SP):SP=SP-1
2330 GOTO 2250
2340 REM swoop or fall
2350 FOR X=0 TO EX
2360 Y=MY
2370 CC=0
2380 IF BD(X,Y)=0 THEN 2430
2390 IF CC>0 THEN 2450
2400 Y=Y-1
2410 IF Y<0 THEN 2530
2420 GOTO 2380
2430 CC=CC+1
2440 GOTO 2400
2450 FOR Z=Y TO 0 STEP -1
2460 BD(X,Z+CC)=BD(X,Z)
2470 NEXT Z
2480 Y=Y+CC
2490 CC=CC-1
2500 BD(X,CC)=0
2510 IF CC=0 THEN 2400
2520 GOTO 2490
2530 NEXT X
2540 REM check for empty columns
2550 X=0
2560 IF BD(X,MY) THEN 2690
2570 IF X>EX THEN 2710
2580 FOR S=X TO EX-1
2590 FOR T=0 TO MY
2600 BD(S,T)=BD(S+1,T)
2610 NEXT T
2620 NEXT S
2630 FOR T=0 TO MY
2640 BD(EX,T)=0
2650 NEXT T
2660 EX=EX-1
2670 if EX<0 THEN 2710
2680 GOTO 2560
2690 X=X+1
2700 IF X<EX THEN 2560
2710 RETURN
2720 REM check limits and piece for color
2730 IF Y>MY OR Y<0 THEN RETURN
2740 IF X>EX OR X<0 THEN RETURN
2750 IF BD(X,Y)<>FC THEN RETURN
2760 REM found same color, push on stack
2770 SP=SP+1:SX(SP)=X:SY(SP)=Y
2780 DX=X:DY=Y:MD=1:GOSUB 2840
2790 BD(X,Y)=0
2800 REM increase yield counter
2810 YD=YD+1
2820 RETURN
2830 REM display white cross if empty
2840 IF BD(DX,DY) OR MD=0 THEN 2920
2850 ET 7,3,MD
2860 CURSORX DX*2+1:CURSORY DY*2
2870 PRINT"&&";
2880 CURSORX DX*2+1:CURSORY DY*2+1
2890 PRINT"&&";
2900 RETURN
2910 REM display single piece
2920 DC=BD(DX,DY)
2930 IF DC>3 THEN DC=DC+1
2940 ET DC,3,MD
2950 CURSORX DX*2+1:CURSORY DY*2
2960 PRINT"%%";
2970 CURSORX DX*2+1:CURSORY DY*2+1
2980 PRINT"%%";
2990 RETURN
3000 REM draw board
3010 STORE
3020 REM display score
3030 CURSORY 0:CURSORX 33
3040 TX 6,1,0
3050 PRINT"Score:";
3060 CURSORY 1:CURSORX 33
3070 PRINT"Score:";
3080 CURSORY 2:CURSORX 33
3090 PRINT STR$(SC);
3100 CURSORY 3:CURSORX 33
3110 PRINT STR$(SC);
3120 REM draw all pieces in mode 0
3130 MD=0
3140 FOR DY=0 TO MY
3150 FOR DX=0 TO MX
3160 GOSUB 2920
3170 NEXT DX
3180 NEXT DY
3190 DISPLAY:SCREEN
3200 RETURN
3210 X=0
3220 Y=MY
3230 C=0
3240 IF BD(X,Y)=0 THEN 3300
3250 GOSUB 3340
3260 IF C>0 THEN RETURN
3270 Y=Y-1
3280 IF Y>=0 THEN 3230
3290 GOTO 3310
3300 IF X=0 AND Y=MY THEN 3420
3310 X=X+1
3320 IF X>EX THEN 3430
3330 GOTO 3220
3340 FC=BD(X,Y)
3350 IF (X+1)>EX THEN 3370
3360 IF BD(X+1,Y)=FC THEN 3400
3370 IF (Y-1)<0 THEN 3390
3380 IF BD(X,Y-1)=FC THEN 3400
3390 RETURN
3400 C=C+1
3410 RETURN
3420 SC=SC+1000
3430 STORE
3440 TX 6,1,0
3450 CURSORY 2:CURSORX 33
3460 PRINT STR$(SC);
3470 CURSORY 3:CURSORX 33
3480 PRINT STR$(SC);
3490 TX 7,3,1
3500 CURSORY 4:CURSORX 7
3510 PRINT "GGAAMMEE  OOVVEERR";
3520 CURSORY 5:CURSORX 7
3530 PRINT "GGAAMMEE  OOVVEERR";
3540 DISPLAY:SCREEN
3550 GOSUB 3570
3560 RUN 1490
3570 JS=ACTION(0)
3580 IF JS<>0 THEN 3570
3590 JS=ACTION(0)
3600 IF (JS AND 1)=0 THEN 3590
3610 RETURN
3620 END
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Rafael
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2587



« Reply #19 on: June 03, 2012, 08:44:43 PM »

Beautifull, Gert Smiley
Now, with 4 colors itīs hardest, too.
Logged
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #20 on: June 03, 2012, 10:27:17 PM »

Indeed with 4 colors you need to plan your moves a lot more  Smiley

BTW: The Basic source above is generated by a pre-processor.
I write the program with a text-editor and use labels instead of line numbers which makes it a lot easier to add and remove code.
The pre-processor then replaces all the labels by linenumbers. I wrote that pre-processor a long long time ago for another basic computer.
The input code is attached for anyone interested and is probably a lot more readable as it contains lots of comment  Smiley

If I can find some time I will try and translate the program to 8048 assembler. I will leave this code as it is for now.

First I want to concentrate on my Multicartridge PCB design and get to grips with either Eagle or Designspark  Roll Eyes
« Last Edit: June 03, 2012, 10:33:01 PM by gertk » Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Rafael
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2587



« Reply #21 on: June 04, 2012, 12:17:11 AM »

Indeed with 4 colors you need to plan your moves a lot more  Smiley

Itīs just because you not included an undo button Smiley
Do you have an idea when the multcart will be ready?
Logged
timdu
Freedom Fighter
****
Posts: 309



« Reply #22 on: June 20, 2012, 03:25:21 PM »

Hi

First, let me say that GertK has been extremely helpful.  I have been sending him messages for the past few days and he
has been answering me quite promptly. I figured I would move my question to the public forum so
others can see. I read about Swell Foop and I became curious and wanted to try it out.
I'm in the USA so I have to use the new O2EM emulator 1.20

Anyway, here is what I do:

I load O2EM, and then go into the Videopac folder and choose the C7420 Basic cartridge. That loads
and I get the SELECT GAME, SELECT GAME, SELECT GAME, SELECT GAME screen in different colors.

Then I press 0.

I get the Videopac BASIC and OK prompt. Press F9 and I load the swell.txt file that I saved
which has GertK's BASIC listing.

I get a message that it loaded successfully and then I type RUN

I get the Title screen and instructions... press button to continue.

I press SCROLL LOCK on my keyboard and to emulate the joysticks...

then I press L ( for the fire button)

the program looks like it is going to continue and then I get


? SN ERROR IN 3370


Anyone have any ideas?


thanks

Tim



Logged
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #23 on: June 20, 2012, 06:32:26 PM »

Hi Tim,

What does

LIST 3370 (enter)

say ?

You need to press BREAK to keep the listing from scrolling too far but you should be able to see what is going on on that line.
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
timdu
Freedom Fighter
****
Posts: 309



« Reply #24 on: June 21, 2012, 03:48:18 PM »

This was my fault   Roll Eyes

When I looked at that line, it was incomplete.

I compared it to your code and it was missing some of the text.

Strange. Perhaps it didn't copy and paste correctly when I was making the text file.

It is running fine. Thank you!

Tim
Logged
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #25 on: June 21, 2012, 06:54:04 PM »

Great!  Smiley
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Rafael
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2587



« Reply #26 on: July 05, 2012, 11:09:42 PM »

I Swell the game starts with the pieces totally randomly. Do you know if is possible to clean the pieces in every game?
Logged
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #27 on: July 06, 2012, 07:33:25 AM »

I Swell the game starts with the pieces totally randomly. Do you know if is possible to clean the pieces in every game?

Since the pieces are layed out randomly it could be that a board is impossible to clean. If there is a way to set the random 'seed' it might be possible to generate the same board over and over and then try different strategies to clear the board. I am not sure if this is possible with the random function in C7420 basic.

I did notice that if I reset the G7400 and press '0' to start the Basic, load the game and type RUN, then the first board always looks the same.

 
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1139



« Reply #28 on: July 06, 2012, 09:03:23 AM »

of course it does :-) the emulator runs deterministic, i.e. the program always behaves the same every time you start it (which means that the seed value is always set to the same value in the beginning, if you don't do anything that is dependent on external values (like user input) that changes the number of executed cycles until the first randomizer is started - if you would wait for a joystick input BEFORE you first use the random, the board should be different ...
Logged

sex, lies, and videopac
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #29 on: July 06, 2012, 07:47:22 PM »

of course it does :-) the emulator runs deterministic, i.e. the program always behaves the same every time you start it (which means that the seed value is always set to the same value in the beginning

I know, but maybe we can use this to our advantage to generate random boards but from a known seed so you can try different strategies to solve it. That way you can share 'seeds' and see who can get the best score for that board.

Quote
if you don't do anything that is dependent on external values (like user input) that changes the number of executed cycles until the first randomizer is started - if you would wait for a joystick input BEFORE you first use the random, the board should be different ...

And I have never seen a 'familiar' board after the first one, maybe we can find out where the seed is stored.
On my mbed C7420 emulator it behaves consistent too so the random routine may be tricked/spoofed.

Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Pages: 1 [2] 3   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!