[Algorithm] maze generation (for pengo like game for instance)

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
User avatar
waskol
Flight Lieutenant
Posts: 425
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

[Algorithm] maze generation (for pengo like game for instance)

Post by waskol »

I put this here because of lack of time due to health care considerations :

Code: Select all

 //#include <lib.h>
 #define plot(X,Y,C) poke(0xBBA8+(X)+(Y)*40,C)
 #define scrn(X,Y) peek(0xBBA8+(X)+(Y)*40)
 
	#define ICE   		'a'
	#define PINGURIGHT	'b'
	#define PINGULEFT 	'd'
	#define PINGU     	'c'
	#define WALL        254
	#define EGG         'f' 
	#define MONSTER     'g'
	#define MONSTERDEAD 'h'
	#define FLAG      'i'
    #define MX 7
	#define MY 8
 char rnd(char max);
 void wait(unsigned int wait_cs);
 void plots(char x,char y,const char *msg);
 void iplot(unsigned char xx, unsigned char yy);
 char redefchar[72]=   //208 +24
{
 30,51,33,33,33,51,30,0,	//(a)glace 
 12,10,12,30,45,45,12,14,	//(b)pingouin droite 
 45,45,63,18,18,30,12,30,	//(c)pingouin 
 12,20,12,30,45,45,12,28,	//(d)pingouin gauche
 63,33,33,33,33,33,33,63,	//(e) mur
 30,51,33,45,45,33,51,30,	//(f) oeuf
 0,12,30,45,63,18,30,12,	//(g) monstre 
 0,0,0,0,12,30,45,63,		//(h) monstre raplapla
 16,24,28,30,16,16,16,16	//(i) drapeau 
 };

/*
//ice2
15,24,51,38,44,40,40,40,
60,6,3,1,1,1,1,1,
40,32,32,32,32,49,24,15,
1,1,5,13,25,51,6,60,

//bear left
6,9,8,16,18,16,16,9,
12,50,2,1,9,33,33,17,
24,32,32,24,25,34,34,31,
7,9,9,7,33,3,6,60,

//pingu
3,7,13,13,7,14,23,19,     //faceleft
48,56,44,44,56,28,58,50,  //faceright
59,59,59,55,39,47,47,6,   //leftlegdown
55,55,55,59,57,61,61,24,  //rightleg down

 3,7,13,13,7,14,7,31,
48,56,44,44,56,28,56,62,
63,62,62,52,44,47,47,6,
63,31,31,11,13,61,61,24,

//pingu right
3,7,15,15,15,31,25,48,
48,24,62,48,48,56,56,56,
  //legs1
48,48,33,35,38,47,63,31,
56,40,40,8,24,48,62,0,

  //legs2
 48,48,33,35,38,47,63,1,
56,40,40,8,24,48,32,60,

  //legs3/0
  48,48,33,35,38,47,63,15,
56,40,40,8,24,48,32,48,

//bear
24,60,36,55,31,11,14,12,
14,31,19,55,62,52,28,12,
15,31,63,62,54,15,15,12,
60,62,63,31,27,60,60,12, */
 
 struct pstack {unsigned char c,r;};
 char x=0,y=0,level=0;
 unsigned char i=0,j=0,k=0,c=0,r=0,tx=0,ty=0,u=0,z=0,celldone=0;
 unsigned char sw[MX+2][MY+2];ew[MX+2][MY+2]; //south walls, est walls
 unsigned char v[MX+2][MY+2]; //visited cells
 struct pstack ps[MX*MY+2];
 void main()
{	
	text(); cls(); paper(0); ink(1);
	//cell = 'c';
    //wall = 'w';

	memcpy((unsigned char*)46856,redefchar,32);
	
	
	for (x=9;x<=23;x++){ 
		//curset(x*6+9,y*6,0);
		plot(x,4,WALL);
		plot(x,20,WALL);
	}
	
	for (y=5;y<=19;y++){  //0-14
		plot(9,y,WALL);
		plot(23,y,WALL);
	}
	lbl_redo:
	 for (x=10;x<=22;x++){    //2*13=26 (+2=28)  1-13
		 for (y=5;y<=19;y++){ //2*15=30 1-15
		 plot(x,y,ICE+128);
		}
	}
		
    plots(3,1,"Initializing...");
	tx=MX+1; ty=MY+1;
    for(c=0;c<=tx;c++) {
		for(r=0;r<=ty;r++) {
          sw[c][r]=1;ew[c][r]=1;v[c][r]=0;
		}
	}
	//SET BORDER CELLS TO VISITED
	for(c=0;c<=tx;c++) {
		v[c][0]=1;v[c][ty]=1;
    }
	for(r=0;r<=ty;r++) {
		v[0][r]=1;v[tx][r]=1;
    }
	
	plots(3,1,"Building...");
	c=rnd(MX)+1;
	r=rnd(MY)+1;
 	lbl_push:
		u++;ps[u].c=c;ps[u].r=r;
		v[c][r]=1;			plot((c<<1)+8,(r<<1)+3,' '+128);
	lbl_test:
	    if(v[c][r+1]==1 && v[c+1][r]==1 && v[c][r-1]==1 && v[c-1][r]==1) goto lbl_pop;
	lbl_explore:
	    z=rnd(4);
		if(z==0 && v[c][r+1]==0){
			sw[c][r]=0;   plot((c<<1)+8,(r<<1)+3+1,' '+128);
			r++;
			goto lbl_push;
		}
		if(z==1 && v[c+1][r]==0){
			ew[c][r]=0;    plot((c<<1)+8+1,(r<<1)+3,' '+128);
			c++;
			goto lbl_push;
		}
		if(z==2 && v[c][r-1]==0){
			sw[c][r-1]=0;    plot((c<<1)+8,(r<<1)+3-1,' '+128);
			r--;
			goto lbl_push;
		}
		if(z==3 && v[c-1][r]==0){
			ew[c-1][r]=0;    plot((c<<1)+8-1,(r<<1)+3,' '+128);
			c--;
			goto lbl_push;
		}
		goto lbl_explore;
	lbl_pop:
	    c=ps[u].c;r=ps[u].r;u--;
		if (u>0) goto lbl_test; 

	get();
	goto lbl_redo;
}

void wait(unsigned int wait_cs)
 {
	unsigned int start=deek(0x0276);
	unsigned int tw=start-wait_cs;
	while (tw<start) {start=deek(0x0276);};
}
 
 void plots(char x_pos,char y_pos, const char *msg)
{
    memcpy((unsigned char*)(0xBBA8+x_pos+y_pos*40),msg,strlen(msg));	
}

char rnd(char max)
 {
 return (char) (rand()/(32768/max));
 }
User avatar
kenneth
Squad Leader
Posts: 533
Joined: Fri Nov 26, 2010 9:11 pm
Location: France PdD
Contact:

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by kenneth »

I always dreamed of seeing Pengo on Oric. I wish you a good recovery. :wink:
User avatar
Dbug
Site Admin
Posts: 4943
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by Dbug »

kenneth wrote: Fri Jan 10, 2025 7:11 pm I always dreamed of seeing Pengo on Oric. I wish you a good recovery. :wink:
Well, there's definitely was a version of it, possibly a type-in from Theoric or Hebdogiciel...

And there are four (quite a few missing tapes and screenshot though) on oric.org:
https://www.oric.org/index.php?page=sof ... waresearch
User avatar
coco.oric
Squad Leader
Posts: 741
Joined: Tue Aug 11, 2009 9:50 am
Location: North of France
Contact:

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by coco.oric »

Hello, i hope you'll be better very soon and able to push this idea at its end. A new classic to play as well as your kong game
coco.oric as DidierV, CEO Member
Historic owner of Oric, Apple II, Atari ST, Amiga
User avatar
rax
Flying Officer
Posts: 206
Joined: Tue Jul 24, 2018 3:16 pm

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by rax »

Hi!,

The place for my post may not be right here, but I'm not sure if it needs a new topic.

I've never seen this game Pengo before. @iss showed it to me (along with the post here).
I'm not sure if these arcade games are still interesting to anyone (I personally like them, but I think I'm one of the few).

The concept is interesting, and the game itself has an intriguing history (from what I found online—here’s one of the links: https://sega.fandom.com/wiki/Pengo).

Here’s the compiled version of the code provided above by @waskol, courtesy of @iss.
pengo.tap
(3.25 KiB) Downloaded 17 times

I ran a few experiments testing some sprites and found that it can be implemented and look good in text mode using character-based sprites at a 3x2 ratio.
This would make the sprite size 18x16 pixels. Here’s a test of the sprites I made:

pengo.jpg

@iss thinks this could turn into an interesting game and should be attempted.
I'm not sure if the game would appeal to the small community we have, and after all, the idea belongs to @waskol.

What do you think?
User avatar
xahmol
Squad Leader
Posts: 611
Joined: Sun Jun 28, 2020 7:32 pm
Location: Utrecht, The Netherlands
Contact:

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by xahmol »

Nice concept Rax. And yes, this is exactly the type of games I like and would play.

And my initial question that arose on the screenshot of ‘how does he do that colour change without char in between’ was followed by me realising ‘of course, inverse. Red <-> Cyan and Black <-> White)
And then the idea that I should have a colour picker with also the result in inverse in Oric Screen Editor. Added to my roadmap :D
User avatar
ibisum
Wing Commander
Posts: 1918
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by ibisum »

Oh, its awesome! Please don't ever question whether games like this belong on Oric - they DO!!!

One thing: can you guys set up a repo so that maybe the progress can be captured for prosperity, and so that maybe some of us can make contributions?

About the text/attribute situation - I'm pretty sure you can do this game in HIRES mode as well, but with much more potential colour. One thing I've learned with soundToy hacking is that we really should not be afraid to push colours on Oric - we just have to understand the rules, and if we use the LDA/STA technique, performance on par with TEXT chars is quite feasible, after all TEXT mode is just HIRES mode with pre-loaded LDA/STA data ..

Looking forward to seeing Pengo on Oric! It was a lot of fun back in the day, especially in the more frantic levels. Hope you'll do the repo!
User avatar
Chema
Game master
Posts: 3139
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by Chema »

I almost overlook this post. Waskol, I hope you get well soon. Please keep us informed.

Nice code and demo!
User avatar
waskol
Flight Lieutenant
Posts: 425
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Re: [Algorithm] maze generation (for pengo like game for instance)

Post by waskol »

I'll be back in a month or so. So far I am OK, taking care of myself. Thank you for your nice messages.
Post Reply