Jump to content
IGNORED

Plotting a dungeon


Opry99er

Recommended Posts

I had to run this program 20 times before it looked like anything resembling a dungeon:

 

map.jpg

 

I have alot of work to do.... but I'm encouraged. I'll post the code when it's more predictable. I spent about 2 hours on it today... gotta get some other things done tonight, but I'm making progress..

Edited by Opry99er
Link to comment
Share on other sites

Finally there is, what I consider, the best dungeon site not on the Internet (it is gone now.) Back when this site was up, it was very cool. Luckily we have the Wayback Machine and they even saved the zip files where the guy (Jamis Buck) provided the source code! I have downloaded all of it and I'm looking into setting it up on my own server. I don't know what happened to Jamis Buck, but the site was cool and his method work really well.

 

http://web.archive.org/web/20080203123815/www.aarg.net/~minam/dungeon_design.html

 

He describes how he makes a maze into a dungeon. On those pages, as a download, is also an offline windows version of the generator. I ran it an included the dungeon it generated (another one of the images), as well as the text it generated describing each room, its contents, booty, etc. The program will export a dungeon as a PNG for the map, and RTF for the room descriptions.

 

All the source is available except for his "Town" generator. I'll let you know if I get it up and running on my server.

 

I'm looking forward to that since the Wayback machine doesn't seem to execute the CGI scripts.

 

Speaking of Town generators, I always like to think how towns naturally emerge... or used to emerge... usually around a main street or a junction of multiple streets where there are more and more houses built around it, and then additional roads around the houses "emerge". Actually, the structure of town or city maps look similar to other fractal structures such as breaking glass, or dried-out mud. For instance, if you look at the lead picture for this video, as it appears here:

 

http://www.youtube.com/watch?v=sc7BdAd4Ejs

 

this looks like a bit like an excerpt out of a city map, if you look at the black grooves as being roads between houses. Also, if you look at leaves closely, they show a similar structure, like this:

 

leaf.jpg

 

Just imagine the thick yellow lines being main streets or highways, and the small white lines being secondary, tertiary etc. streets... down to the smallest white lines which would be the boundaries between single houses, or maybe footpaths. Then imagine the value of the black houses being the highest (because they are next to highways and secondary streets, so shops and restaurants built there get the most traffic) and the value of the light green ones being the lowest.

Link to comment
Share on other sites

I've just thrown together a small dungeon generation algorithm. It may not be what you expect at all, but I still think it's interesting...

It's written in XBasic. It basically first chooses one of four directions (Line 150) and a random line / column and then lets a particle fly (invisibly) until it hits another particle on the front or on the side, at which point it stops (and gets displayed). As soon as the structure grows beyond certain boundaries, the program stops and enters the endless loop in line 220.

 

10 REM MAZE GENERATOR BY KURT WOLOCH
100 XMIN = 11 :: XMAX = 13 :: YMIN = 15 :: YMAX = 17 :: RANDOMIZE :: CALL HCHAR(1,1,32,768)
105 CALL CHAR(33,"FFFFFFFFFFFFFFFF")
110 CALL HCHAR(12,16,33) !DRAW FIRST PARTICLE
150 DIR = INT(RND*4) !RANDOM DIRECTION
160 IF (DIR AND 1) = 0 THEN X = 1 + DIR * 10.5 :: Y = INT(RND * (YMAX-YMIN+1)) + YMIN :: DY = 0 :: DX = 1 - DIR :: GOTO 180
170 Y = 1 + (DIR - 1) * 14.5 :: X = INT(RND * (XMAX-XMIN+1)) + XMIN :: DX = 0 :: DY = 2 - DIR
180 Y = Y + DY :: X = X + DX :: CALL GCHAR(X,Y-1,C1) :: CALL GCHAR(X,Y+1,C2) :: CALL GCHAR(X-1,Y,C3) :: CALL GCHAR(X+1,Y,C4)
190 IF (C1 + C2 + C3 + C4) = 128 THEN 180
195 CALL HCHAR(X,Y,33)
200 XMIN = MIN(X-1,XMIN) :: XMAX = MAX(X+1,XMAX) :: YMIN = MIN(Y-1,YMIN) :: YMAX = MAX(Y+1,YMAX)
210 IF XMIN > 0 AND XMAX < 23 AND YMIN > 0 AND YMAX < 31 THEN 150
220 GOTO 220

 

Yes, I know the program is slow and not well commented and lacks any proper loops, having all loops inplemented with GOTO's.

Link to comment
Share on other sites

Hey Kurt... your program works nicely, but then it quits unexpectedly with "*BAD VALUE IN 180" when it starts to espand outward from the center... I'd say it makes about 25 moves before it shut down on me. Perhaps it's a random thing, because when I ran it a second time, it went quite a bit further before it bonked out.

Link to comment
Share on other sites

Owen, what code is that of John's? Is that something he posted or sent you via PM? I'd be interested in seeing that, and maybe doing an assembly version. :)

 

Matthew

 

 

It's on my mazes memory and dungeons thread,

but here it is again,

100 RANDOMIZE
110 DIM MZ$(12,5)
120 CALL CLEAR
130 CALL COLOR(8,11,2)
140 CALL COLOR(9,2,7)
150 C=65
160 N=4
170 CALL CHAR(33,"FFFFFFFFFFFFFFFF")
180 CALL CHAR(34,"FFFFFFFFFFFFFFFF")
190 CALL CHAR(88,"8800220088002200")
200 CALL CHAR(89,"80081C08BE081422")
210 CALL CHAR(96,"FF44FF11FF44FF11")
220 CALL HCHAR(2,1,33,736)
230 FOR X=2 TO 31
240 FOR Y=3 TO 23
250 IF INT(RND*100)<C THEN 260 ELSE 270
260 CALL HCHAR(Y,X,34)
270 NEXT Y
280 NEXT X
290 FOR X=2 TO 31
300 FOR Y=3 TO 23
310 T=0
320 FOR I=-1 TO 1
330 CALL GCHAR(Y+I,X,A)
340 IF A=34 THEN 350 ELSE 360
350 T=T+1
360 CALL GCHAR(Y,X+I,A)
370 IF A=34 THEN 380 ELSE 390
380 T=T+1
390 IF T>N-1 THEN 400 ELSE 420
400 CALL HCHAR(Y,X,34)
410 GOTO 430
420 NEXT I
430 NEXT Y
440 NEXT X
450 T=0
460 X=INT(RND*30)+2
470 Y=INT(RND*22)+2
480 FOR I=-1 TO 1
490 CALL GCHAR(Y+I,X,A)
500 CALL GCHAR(Y,X+I,A1)
510 IF A=34 THEN 520 ELSE 530
520 T=T+1
530 IF A1=34 THEN 540 ELSE 550
540 T=T+1
550 NEXT I
560 IF T<6 THEN 450
570 DATA 0,1,0,2,0,3,0,1,1,2,1,3,1,1,2,2,2,2,1,0,2,1,3,1
580 DIM LOS(12,2)
590 FOR I=1 TO 12
600 READ A,B
610 LOS(I,1)=A
620 LOS(I,2)=B
630 NEXT I
640 CALL HCHAR(Y,X,89)
660 FOR S=1 TO 4
670 FOR I=1 TO 3
680 LO=(S-1)*3+I
690 CALL GCHAR(Y+LOS(LO,1),X+LOS(LO,2),A)
700 IF (A=34)+(A=88)THEN 701 else 703
701 A=88 
702 goto 710
703 A=96
710 CALL HCHAR(Y+LOS(LO,1),X+LOS(LO,2),A)
720 IF A=96 THEN 740
730 NEXT I
740 NEXT S
760 FOR S=1 TO 4
770 FOR I=1 TO 3
780 LO=(S-1)*3+I
790 CALL GCHAR(Y+LOS(LO,2),X-LOS(LO,1),A)
800 IF (A=34)+(A=88)THEN 801 else 803
801 A=88 
802 goto 810
803 A=96
810 CALL HCHAR(Y+LOS(LO,2),X-LOS(LO,1),A)
820 IF A=96 THEN 840
830 NEXT I
840 NEXT S
860 FOR S=1 TO 4
870 FOR I=1 TO 3
880 LO=(S-1)*3+I
890 CALL GCHAR(Y-LOS(LO,1),X-LOS(LO,2),A)
900 IF (A=34)+(A=88)THEN 901 else 903
901 A=88
902 goto 910
903 A=96
910 CALL HCHAR(Y-LOS(LO,1),X-LOS(LO,2),A)
920 IF A=96 THEN 940
930 NEXT I
940 NEXT S
960 FOR S=1 TO 4
970 FOR I=1 TO 3
980 LO=(S-1)*3+I
990 CALL GCHAR(Y-LOS(LO,2),X+LOS(LO,1),A)
1000 IF (A=34)+(A=88)THEN 1001 else 1003
1001 A=88 
1002 goto 1010
1003 A=96
1010 CALL HCHAR(Y-LOS(LO,2),X+LOS(LO,1),A)
1020 IF A=96 THEN 1040
1030 NEXT I
1040 NEXT S
1050 CALL JOYST(1,JX,JY)
1060 IF (JX<>0)*(JY<>0)THEN 1050
1070 X=X+JX/4
1080 Y=Y-JY/4
1090 CALL GCHAR(Y,X,A)
1100 IF A=88 THEN 1110 ELSE 1130
1110 CALL HCHAR(Y+JY/4,X-JX/4,88)
1120 GOTO 640
1130 X=X-JX/4
1140 Y=Y+JY/4
1150 GOTO 1050

 

 

notice that here is the LOS and that I copied and pasted it 4 times this could be made smaller and more efficient by making it 1 pass not 4 since it is the same thing done 4 time in a different direction.

660 FOR S=1 TO 4
670 FOR I=1 TO 3
680 LO=(S-1)*3+I
690 CALL GCHAR(Y+LOS(LO,1),X+LOS(LO,2),A)
700 IF (A=34)+(A=88)THEN 701 else 703
701 A=88 
702 goto 710
703 A=96
710 CALL HCHAR(Y+LOS(LO,1),X+LOS(LO,2),A)
720 IF A=96 THEN 740
730 NEXT I
740 NEXT S
760 FOR S=1 TO 4
770 FOR I=1 TO 3
780 LO=(S-1)*3+I
790 CALL GCHAR(Y+LOS(LO,2),X-LOS(LO,1),A)
800 IF (A=34)+(A=88)THEN 801 else 803
801 A=88 
802 goto 810
803 A=96
810 CALL HCHAR(Y+LOS(LO,2),X-LOS(LO,1),A)
820 IF A=96 THEN 840
830 NEXT I
840 NEXT S
860 FOR S=1 TO 4
870 FOR I=1 TO 3
880 LO=(S-1)*3+I
890 CALL GCHAR(Y-LOS(LO,1),X-LOS(LO,2),A)
900 IF (A=34)+(A=88)THEN 901 else 903
901 A=88
902 goto 910
903 A=96
910 CALL HCHAR(Y-LOS(LO,1),X-LOS(LO,2),A)
920 IF A=96 THEN 940
930 NEXT I
940 NEXT S
960 FOR S=1 TO 4
970 FOR I=1 TO 3
980 LO=(S-1)*3+I
990 CALL GCHAR(Y-LOS(LO,2),X+LOS(LO,1),A)
1000 IF (A=34)+(A=88)THEN 1001 else 1003
1001 A=88 
1002 goto 1010
1003 A=96
1010 CALL HCHAR(Y-LOS(LO,2),X+LOS(LO,1),A)
1020 IF A=96 THEN 1040
1030 NEXT I
1040 NEXT S

Link to comment
Share on other sites

Well it's in assembly but not assembly you would program and not efficient if you programmed it yourself. The compiler has a sub for say CALL HCHAR and every time the basic program uses CALL HCHAR the assembly in branches to that sub with what it needs (y,x,c) pass into registers

 

      DEF RUN,CON
RUNEA  B @RUNEA5
FRSTLN
L100
L110
L120
      DATA CLEAR
L130
      DATA COLOR,NC1,NC2,NC3
L140
      DATA COLOR,NC4,NC3,NC5
L150
      DATA LET,NV1,NC6
L160
      DATA LET,NV2,NC7
L170
      DATA CHAR,NC8,SC1
L180
      DATA CHAR,NC9,SC1
L190
      DATA CHAR,NC10,SC2
L200
      DATA CHAR,NC11,SC3
L210
      DATA CHAR,NC12,SC4
L220
      DATA HCHAR,NC3,NC13,NC8,NC14
L230
FOR1
      DATA FOR,NV3,NC3,NC15,ONE,0,0
L240
FOR2
      DATA FOR,NV4,NC16,NC17,ONE,0,0
L250
      DATA MLTPLY,RND,NC18,NT1
      DATA INT,NT1,NT2
      DATA CLT,NT2,NV1,NT3
      DATA IF,NT3,L260,L270
L260
      DATA HCHAR,NV4,NV3,NC9
L270
      DATA NEXT,FOR2+2
L280
      DATA NEXT,FOR1+2
L290
FOR3
      DATA FOR,NV3,NC3,NC15,ONE,0,0
L300
FOR4
      DATA FOR,NV4,NC16,NC17,ONE,0,0
L310
      DATA LET,NV5,NC19
L320
      DATA MINUS,NC13,NT1
FOR5
      DATA FOR,NV6,NT1,NC13,ONE,0,0
L330
      DATA ADD,NV4,NV6,NT1
      DATA GCHAR,NT1,NV3,NV7
L340
      DATA CEQ,NV7,NC9,NT1
      DATA IF,NT1,L350,L360
L350
      DATA ADD,NV5,NC13,NT1
      DATA LET,NV5,NT1
L360
      DATA ADD,NV3,NV6,NT1
      DATA GCHAR,NV4,NT1,NV7
L370
      DATA CEQ,NV7,NC9,NT1
      DATA IF,NT1,L380,L390
L380
      DATA ADD,NV5,NC13,NT1
      DATA LET,NV5,NT1
L390
      DATA SBTRCT,NV2,NC13,NT1
      DATA CGT,NV5,NT1,NT2
      DATA IF,NT2,L400,L420
L400
      DATA HCHAR,NV4,NV3,NC9
L410
      DATA GOTO,L430
L420
      DATA NEXT,FOR5+2
L430
      DATA NEXT,FOR4+2
L440
      DATA NEXT,FOR3+2
L450
      DATA LET,NV5,NC19
L460
      DATA MLTPLY,RND,NC20,NT1
      DATA INT,NT1,NT2
      DATA ADD,NT2,NC3,NT3
      DATA LET,NV3,NT3
L470
      DATA MLTPLY,RND,NC21,NT1
      DATA INT,NT1,NT2
      DATA ADD,NT2,NC3,NT3
      DATA LET,NV4,NT3
L480
      DATA MINUS,NC13,NT1
FOR6
      DATA FOR,NV6,NT1,NC13,ONE,0,0
L490
      DATA ADD,NV4,NV6,NT1
      DATA GCHAR,NT1,NV3,NV7
L500
      DATA ADD,NV3,NV6,NT1
      DATA GCHAR,NV4,NT1,NV8
L510
      DATA CEQ,NV7,NC9,NT1
      DATA IF,NT1,L520,L530
L520
      DATA ADD,NV5,NC13,NT1
      DATA LET,NV5,NT1
L530
      DATA CEQ,NV8,NC9,NT1
      DATA IF,NT1,L540,L550
L540
      DATA ADD,NV5,NC13,NT1
      DATA LET,NV5,NT1
L550
      DATA NEXT,FOR6+2
L560
      DATA CLT,NV5,NC22,NT1
      DATA IF,NT1,L450
L580
L590
FOR7
      DATA FOR,NV6,NC13,NC23,ONE,0,0
L600
      DATA READ,NV7,NV9
L610
      DATA LET,NA1,NV6,NC13,NV7
L620
      DATA LET,NA1,NV6,NC3,NV9
L630
      DATA NEXT,FOR7+2
L640
      DATA HCHAR,NV4,NV3,NC11
L650
      DATA LET,NV10,NC19
L660
FOR8
      DATA FOR,NV11,NC13,NC7,ONE,0,0
L670
FOR9
      DATA FOR,NV6,NC13,NC16,ONE,0,0
L680
      DATA SBTRCT,NV11,NC13,NT1
      DATA MLTPLY,NT1,NC16,NT2
      DATA ADD,NT2,NV6,NT3
      DATA LET,NV10,NT3
L690
      DATA ADD,NV4,NA1,NV10,NC13,NT1
      DATA ADD,NV3,NA1,NV10,NC3,NT2
      DATA GCHAR,NT1,NT2,NV7
L700
      DATA CEQ,NV7,NC9,NT1
      DATA CEQ,NV7,NC10,NT2
      DATA ADD,NT1,NT2,NT3
      DATA IF,NT3,L701,L703
L701
      DATA LET,NV7,NC10
L702
      DATA GOTO,L710
L703
      DATA LET,NV7,NC12
L710
      DATA ADD,NV4,NA1,NV10,NC13,NT1
      DATA ADD,NV3,NA1,NV10,NC3,NT2
      DATA HCHAR,NT1,NT2,NV7
L720
      DATA CEQ,NV7,NC12,NT1
      DATA IF,NT1,L740
L730
      DATA NEXT,FOR9+2
L740
      DATA NEXT,FOR8+2
L750
      DATA LET,NV10,NC19
L760
FOR10
      DATA FOR,NV11,NC13,NC7,ONE,0,0
L770
FOR11
      DATA FOR,NV6,NC13,NC16,ONE,0,0
L780
      DATA SBTRCT,NV11,NC13,NT1
      DATA MLTPLY,NT1,NC16,NT2
      DATA ADD,NT2,NV6,NT3
      DATA LET,NV10,NT3
L790
      DATA ADD,NV4,NA1,NV10,NC3,NT1
      DATA SBTRCT,NV3,NA1,NV10,NC13,NT2
      DATA GCHAR,NT1,NT2,NV7
L800
      DATA CEQ,NV7,NC9,NT1
      DATA CEQ,NV7,NC10,NT2
      DATA ADD,NT1,NT2,NT3
      DATA IF,NT3,L801,L803
L801
      DATA LET,NV7,NC10
L802
      DATA GOTO,L810
L803
      DATA LET,NV7,NC12
L810
      DATA ADD,NV4,NA1,NV10,NC3,NT1
      DATA SBTRCT,NV3,NA1,NV10,NC13,NT2
      DATA HCHAR,NT1,NT2,NV7
L820
      DATA CEQ,NV7,NC12,NT1
      DATA IF,NT1,L840
L830
      DATA NEXT,FOR11+2
L840
      DATA NEXT,FOR10+2
L850
      DATA LET,NV10,NC19
L860
FOR12
      DATA FOR,NV11,NC13,NC7,ONE,0,0
L870
FOR13
      DATA FOR,NV6,NC13,NC16,ONE,0,0
L880
      DATA SBTRCT,NV11,NC13,NT1
      DATA MLTPLY,NT1,NC16,NT2
      DATA ADD,NT2,NV6,NT3
      DATA LET,NV10,NT3
L890
      DATA SBTRCT,NV4,NA1,NV10,NC13,NT1
      DATA SBTRCT,NV3,NA1,NV10,NC3,NT2
      DATA GCHAR,NT1,NT2,NV7
L900
      DATA CEQ,NV7,NC9,NT1
      DATA CEQ,NV7,NC10,NT2
      DATA ADD,NT1,NT2,NT3
      DATA IF,NT3,L901,L903
L901
      DATA LET,NV7,NC10
L902
      DATA GOTO,L910
L903
      DATA LET,NV7,NC12
L910
      DATA SBTRCT,NV4,NA1,NV10,NC13,NT1
      DATA SBTRCT,NV3,NA1,NV10,NC3,NT2
      DATA HCHAR,NT1,NT2,NV7
L920
      DATA CEQ,NV7,NC12,NT1
      DATA IF,NT1,L940
L930
      DATA NEXT,FOR13+2
L940
      DATA NEXT,FOR12+2
L950
      DATA LET,NV10,NC19
L960
FOR14
      DATA FOR,NV11,NC13,NC7,ONE,0,0
L970
FOR15
      DATA FOR,NV6,NC13,NC16,ONE,0,0
L980
      DATA SBTRCT,NV11,NC13,NT1
      DATA MLTPLY,NT1,NC16,NT2
      DATA ADD,NT2,NV6,NT3
      DATA LET,NV10,NT3
L990
      DATA SBTRCT,NV4,NA1,NV10,NC3,NT1
      DATA ADD,NV3,NA1,NV10,NC13,NT2
      DATA GCHAR,NT1,NT2,NV7
L1000
      DATA CEQ,NV7,NC9,NT1
      DATA CEQ,NV7,NC10,NT2
      DATA ADD,NT1,NT2,NT3
      DATA IF,NT3,L1001,L1003
L1001
      DATA LET,NV7,NC10
L1002
      DATA GOTO,L1010
L1003
      DATA LET,NV7,NC12
L1010
      DATA SBTRCT,NV4,NA1,NV10,NC3,NT1
      DATA ADD,NV3,NA1,NV10,NC13,NT2
      DATA HCHAR,NT1,NT2,NV7
L1020
      DATA CEQ,NV7,NC12,NT1
      DATA IF,NT1,L1040
L1030
      DATA NEXT,FOR15+2
L1040
      DATA NEXT,FOR14+2
L1050
      DATA JOYST,NC13,NV12,NV13
L1060
      DATA CNE,NV12,NC19,NT1
      DATA CNE,NV13,NC19,NT2
      DATA MLTPLY,NT1,NT2,NT3
      DATA IF,NT3,L1050
L1070
      DATA DIVIDE,NV12,NC7,NT1
      DATA ADD,NV3,NT1,NT2
      DATA LET,NV3,NT2
L1080
      DATA DIVIDE,NV13,NC7,NT1
      DATA SBTRCT,NV4,NT1,NT2
      DATA LET,NV4,NT2
L1090
      DATA GCHAR,NV4,NV3,NV7
L1100
      DATA CEQ,NV7,NC10,NT1
      DATA IF,NT1,L1110,L1130
L1110
      DATA DIVIDE,NV13,NC7,NT1
      DATA DIVIDE,NV12,NC7,NT2
      DATA ADD,NV4,NT1,NT3
      DATA SBTRCT,NV3,NT2,NT4
      DATA HCHAR,NT3,NT4,NC10
L1120
      DATA GOTO,L640
L1130
      DATA DIVIDE,NV12,NC7,NT1
      DATA SBTRCT,NV3,NT1,NT2
      DATA LET,NV3,NT2
L1140
      DATA DIVIDE,NV13,NC7,NT1
      DATA ADD,NV4,NT1,NT2
      DATA LET,NV4,NT2
L1150
      DATA GOTO,L1050
LASTLN DATA STOP
OPTBAS DATA 0
NC0
ZERO   DATA 0
ONE    DATA 1
PI     DATA 3
RND    DATA 0
NC1    DATA 8
NC2    DATA 11
NC3    DATA 2
NC4    DATA 9
NC5    DATA 7
NC6    DATA 65
NC7    DATA 4
NC8    DATA 33
NC9    DATA 34
NC10   DATA 88
NC11   DATA 89
NC12   DATA 96
NC13   DATA 1
NC14   DATA 736
NC15   DATA 31
NC16   DATA 3
NC17   DATA 23
NC18   DATA 100
NC19   DATA 0
NC20   DATA 30
NC21   DATA 22
NC22   DATA 6
NC23   DATA 12
NV0
NV1    DATA 0 C
NV2    DATA 0 N
NV3    DATA 0 X
NV4    DATA 0 Y
NV5    DATA 0 T
NV6    DATA 0 I
NV7    DATA 0 A
NV8    DATA 0 A1
NV9    DATA 0 B
NV10   DATA 0 LO
NV11   DATA 0 S
NV12   DATA 0 JX
NV13   DATA 0 JY
NT1    DATA 0 
NT2    DATA 0 
NT3    DATA 0 
NT4    DATA 0 
SC0
SC1    DATA SC1+2 
      BYTE 16,70,70,70,70,70,70,70,70,70
      BYTE 70,70,70,70,70,70,70
      EVEN
SC2    DATA SC2+2 
      BYTE 16,56,56,48,48,50,50,48,48,56
      BYTE 56,48,48,50,50,48,48
      EVEN
SC3    DATA SC3+2 
      BYTE 16,56,48,48,56,49,67,48,56,66
      BYTE 69,48,56,49,52,50,50
      EVEN
SC4    DATA SC4+2 
      BYTE 16,70,70,52,52,70,70,49,49,70
      BYTE 70,52,52,70,70,49,49
      EVEN
SV0
SA0
SA1    DATA 12,5,0 MZ$
      BSS 156
NA0
NA1    DATA 12,2,0 LOS
      BSS 78
FRSTDT
L570
      BYTE 1,48,1,49,1,48,1,50,1,48
      BYTE 1,51,1,48,1,49,1,49,1,50
      BYTE 1,49,1,51,1,49,1,49,1,50
      BYTE 1,50,1,50,1,50,1,49,1,48
      BYTE 1,50,1,49,1,51,1,49
LASTDT
      EVEN
      COPY "DSK2.RUNTIME1"
      COPY "DSK2.RUNTIME2"
      END

 

so you see the file is nothing but labels with the basic commands broken down to needed parts. The runtime files are added to the code at the bottom.

They are a great read too as they contain all of his subs for assembly equivalents for basic commands.

 

As I told you in chat the other day I'm building a new compiler based on this on but executed on the pc for speed. I'm far from having anything postable for it, but I'm getting there and it includes a full text editor that you can type your basic code in and see the assembly source output. after this contest is done, I'm going to hit it hard and get something going so people can try it. And maybe some of the gurus on here can help me include tibits Harry didn't like disk access that seems very complicated in assembly.

Link to comment
Share on other sites

Here is his HCHAR routines

HCHAR  BL @HCHGAD
HCHAR4 BL @VSBW          Note use of BL, not BLWP
HCHAR3 DEC R6
      JEQ HCHAR1
      INC R0
      CI R0,>4300
      JL HCHAR2
      CLR R0
      JMP HCHAR4
HCHAR2 MOVB R1,@>8C00
      JMP HCHAR3
HCHAR1 B @RTN


VSBW   ORI R0,>4000      WRITE OPERATION
      SWPB R0
      MOVB R0,@>8C02
      SWPB R0
      MOVB R0,@>8C02
      MOVB R1,@>8C00
      B *R11


HCHGAD MOV R11,R10
      BL @GET3
      MOV *R4,R0    ROW to R0
      MOV *R5,R2    COL to R2
      MOV *R6,R1    ASCII to R1
      C *R13,R15    See if next word is a number or an instruction
      JLT HCHARX    optional number included
      LI R6,1
      JMP HCHARY
HCHARX BL @GET1
      MOV *R6,R6
HCHARY DEC R0
      DEC R2
      SLA R0,5
      A R2,R0
      SWPB R1
      AI R1,>6000
      B *R10

 

The only thing I wish I had was he phraser where he breaks down the basic code, but I'm about there on that too.

Link to comment
Share on other sites

Can someone tell me where my bug is?

 

100 DIM MAZE(28,32)
110 RANDOMIZE
120 CALL SCREEN(7)
130 CALL CLEAR
140 SIZEX=INT(RND*5)+4
150 SIZEY=INT(RND*5)+4
160 RX=INT(RND*+1
170 RY=INT(RND*10)+1
180 FOR Q=1 TO SIZEY
190 FOR A=1 TO SIZEX
210 RY=RY+1
215 MAZE(RX,RY)=1
220 NEXT A
230 RX=RX+1
240 RY=RY-SIZEX
250 NEXT Q
260 FOR I=1 TO 28
261 FOR P=1 TO 32
270 DISPLAY AT(I,P):MAZE(I,P);
280 NEXT P
300 NEXT I

 

 

It plots the room to the array, but I can't seem to get it to display consistently. A zero scans each line and displays a "1" where the room should be... problem is, though, that it doesn't hold the display except for a line of zeros on the left side of the screen. I'm sure it's a simple syntax thing... I may have misplaced a variable or something. Anyway, any help you can give would be great. =) Thanks

Link to comment
Share on other sites

I got it to work using HCHAR, but I really want to try to do it tile by tile... This code here doesn't even use the maze array... I left it in while I'm working, but all it does is call HCHAR for the variables and doesn't access the array in memory

 


100 DIM MAZE(28,32)
110 RANDOMIZE
120 CALL SCREEN(7)
130 CALL CLEAR
140 SIZEX=INT(RND*5)+4
150 SIZEY=INT(RND*5)+4
160 RX=INT(RND*+1
170 RY=INT(RND*10)+1
180 FOR Q=1 TO SIZEY
190 FOR A=1 TO SIZEX
200 RY=RY+1
210 MAZE(RX,RY)=1
220 NEXT A
230 RX=RX+1
240 RY=RY-SIZEX
250 NEXT Q
260 FOR I=1 TO SIZEY
270 CALL HCHAR(RX,RY,35,SIZEX)
280 RX=RX+1
290 NEXT I
300 FOR DEL=1 TO 300 :: NEXT DEL
310 GOTO 130

Edited by Opry99er
Link to comment
Share on other sites

100 DIM MAZE(28,32)
110 RANDOMIZE
120 CALL SCREEN(7)
130 CALL CLEAR
rem size of room
140 SIZEX=INT(RND*5)+4
150 SIZEY=INT(RND*5)+4
rem location of room
160 RX=INT(RND*+1
170 RY=INT(RND*10)+1
rem for next loops to draw room into array
rem for next for room starts at room location and goes to room location +size
180 FOR Q=rx TO rx+SIZEY
190 FOR A=ry TO ry+SIZEX
rem change each tile in this loop to 1 in the array
210 MAZE(a,q)=1
220 NEXT A
250 NEXT Q


rem array is made now with room so lets draw it
260 for x=1 to 32
270 for y=1 to 28
275 if maze(y,x)=1 then CALL HCHAR(Y,x,35)
280 next y
290 NEXT x
310 GOTO 130

 

each time this does line 310 and gotos 130 it erase the screen not the array and adds another room to the array. if you want the array to be clear you have to clear the array and you can do it by adding a line in the draw array loop to erase the point in the array after you draw the point on the screen like this,

 

275 if maze(y,x)=1 then CALL HCHAR(Y,x,35)::maze(y,x)=0

 

notice line 210 stores a point in the array

210 MAZE(a,q)=1

see it change a 0 to a 1

 

a better way to do all of this is like this, but I wanted you to see it more clearly first. This code will draw the ascii code to the array and then draw from the array to the screen and erase the array at the same time.

rem a new array all set to 0's
100 DIM MAZE(28,32)
110 RANDOMIZE
120 CALL SCREEN(7)
130 CALL CLEAR
rem size of room
140 SIZEX=INT(RND*5)+4
150 SIZEY=INT(RND*5)+4
rem location of room
160 RX=INT(RND*+1
170 RY=INT(RND*10)+1
rem for next loops to draw room into array
rem for next for room starts at room location and goes to room location +size
180 FOR Q=rx TO rx+SIZEY
190 FOR A=ry TO ry+SIZEX
rem change each tile in this loop to 35 in the array
210 MAZE(a,q)=35
220 NEXT A
250 NEXT Q


rem array is made now with room so lets draw it
260 for x=1 to 32
270 for y=1 to 28
275 if maze(y,x)>0 then CALL HCHAR(Y,x,maze(y,x))  :: maze(y,x)=0
280 next y
290 NEXT x
310 GOTO 130

no notice line 275 that draws the array. it will draw what ever character is in the array if it's not zero. so like this you can include more then one character and not use a bunch of if thens for each character code used.

to drive that home change this line,

210 MAZE(a,q)=int(rnd*60)+35

Edited by jchase1970
Link to comment
Share on other sites

That cleared it up, thanks John! =)

 

I was just missing the check for 0 or 1 in the loop. I was trying to just DRAW them all, but it didn't quite work like I wanted. Okay... I've updated my code, I'm filing it away, and then gonna chill on it for a bit.

 

I need to get back to the Baby Steps thread. =)

Link to comment
Share on other sites

100 DIM MAZE(24,32) <only 24 lines on the screen>
110 RANDOMIZE
120 CALL SCREEN(7)
130 CALL CLEAR
140 SIZEX=INT(RND*5)+4
150 SIZEY=INT(RND*5)+4
160 RX=INT(RND*+1
170 RY=INT(RND*10)+1
180 FOR Q=RY TO RY+SIZEY <tighter loops doing just what you want>
190 FOR A=RX TO RX+SIZEX
215 MAZE(Q,A)=1
220 NEXT A
250 NEXT Q
260 FOR I=1 TO 24
261 FOR P=1 TO 32
270 CALL HCHAR(I,P,MAZE(I,P)+33) <plotting either chr.code 33 or 34>
280 NEXT P
300 NEXT I

:)

Edited by sometimes99er
Link to comment
Share on other sites

Here's another way to do the same stuff

 

100 DIM MAZE$(24)
110 RANDOMIZE
120 CALL SCREEN(7)
130 CALL CLEAR
140 SIZEX=INT(RND*5)+4
150 SIZEY=INT(RND*5)+4
160 RX=INT(RND*+1
170 RY=INT(RND*10)+1
180 FOR Q=RY TO RY+SIZEY
215 MAZE$(Q)=RPT$(" ",RX-1)&RPT$("!",SIZEX)
250 NEXT Q
260 FOR I=1 TO 24
270 DISPLAY AT(I,1):MAZE$(I);
300 NEXT I

:)

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...