News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

The XIII Emperor Gamebook - Updates (edited title)

Started by enteka, 09:52, 31 May 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

enteka

Just added the hypertext feature (no, it's not point and click with a mouse on a link, but inputting the number associated to the link), as it's done in Gopher and Gemini (I mean the protocols)

enteka

New update. Well, it's being a bumpy ride, mostly with the limitations that 64kb and AMSDOS imposes, namely two of them
1) It only allows for 64 or so files per disk2) The program practial limit of 30-40kb
Text is heavy, bytewise,so after consulting with the friendly people at the Programming sub-forum (fora?) this is what I have come up with
a) The gamebook will be released in parts. That has also the adventage of having feedback and knowning when to stop.
b) Texts that are to be displayed less often will be stored on files, while text that is most likely to be displayed will be hard coded on the program. While not being very systematic that helps with having the whole game in a single disk/tape and still keep the main program in small bits.c) The flags array is now a stringd) Comments, remarks and so on have been mostly taken to an auxiliary readme file

enteka

Just tested a partial implementaion of the game and it's all working, well enough. Errors seem know to arise from  badly formated files and other data, the logic is not yet robust but it works
Main program file size is about 11K now, but 25% of the game is done and the new sections of the gamebook take less and less space (as most of the text is on seperate files)
Also, I'm probably not doing a version for tape as I cannot see how I could make that not to freaking slow

Animalgril987

Looking forward to the finished article :D

enteka

Something funny happened here. Please, disregard :)

enteka

I have re-worked the whole thing from the ground up.

The TLDR

Refresher:

a gamebook is an interactive book that you play by choosing links of some sort (like turn to page... ) and (sometimes) rolling dice and checking your character sheet.

Limitations of the Amstrad 464 means I can't simply load a beast of a text and hope for our electronic hero to cope with all that just with 64K

Also, as reading from files, even from disks, takes noticeable time on an Amstrad, I cannot turn each section (or page/paragraph) into a single file.

Instead, I'm bundling them into "chapters".

Once the player has cleared a full chapter, the computer will load a full chapter into a buffer (an array string, with each item containing a line)To make things simpler each chapter has but one entry point (i.e, you begin at "page 1" of each chapter)So that limits the number of files used and reading operations, while still avoiding to overflow the memory.

Now the project has these files:

1. X.BAS  with the code 6.4K at this point

2. CH1.TXT, CH2.TXT etc about 7K each

3. README.TXTThe CH1.TXT are the "chapter" files, bundling together, in simple plain text, the , well, text of several sections

The README is now serving me as a replacement for REM statements, to keep the file size small. So I have the definition of variables, where the subroutines are and what they do, same for functions, and the bit of logic for each section. Kinda useful, really.The algorythmAfter the initial stuff is done (getting input from the player like age and name of the character)...

1. "Cros" (that was the nickname I gave my Amstrad back in the day) read a whole "chapter" from disk, each line going to the bfr$() array 
It goes like: (it's patronizing, I know, but I used to be a newbie and there's the odd chance somebody could benefit, so bear with me )


1065 chSize%=138:cfile$="CH1":GOSUB 100


That is to mean. Cross, my  new "chapter" is 138 lines long, its filename starts with CH1. Now, be a nice friend and gosub 100, where the instructions to read and process the chapter are.


100'Load buffer
105 ERASE bfr$:DIM bfr$(chSize%)
110 OPENIN cfile$+".TXT"
115 FOR li%=1 TO chSize%
120    LINE INPUT #9, bfr$(li%)
125 NEXT
130 CLOSEIN
135 RETURN


Which is to mean, Cross, erase the bfr$() we had earlier, please. I don't want that text any longer for we are going to use a new one.And this new bfr$() will be as long as the lenght of the chapter I told you beforeThen, Cross open the file for me, read each line into an element of bfr$()Once you are done, close the file so no garbage enters it and return to the line you came from


1070'S1.1
1075 bop%=1:eop%=14:GOSUB 400
1080 GOSUB 440


Now that's Cross my section (aka paragraph) begins at line 1 and ends at line 14. (These are numbers I have to double check, and I'd rather do it like this than with some DATA statement, though this might change in the final version).

Then gosub 400 telling you to process each line, like making substitutions in the text. A * is substitued with the name the player chose for the character, a line containing nothing but ))) becomes "Your options" and so forthFinally a GOSUB 440 it's a simple "Any key to continue", This is used when the player is just asked to "turn the page", making no choices.

The code is a bit more complex than that for when the player can make a choice.

1 'The XIII Emperor a gamebook 'By Miguel de Luis See README.TXT
10 DEF FNdice(x%)=ROUND(RND(1)*(x%-1))+1
15 DEF FNtwoD3=FNdice(3)+FNdice(3) 'Ranges 2 to 6
17 DEF FNfourD3=FNtwoD3+FNtwoD3 'Ranges from 4 to 12
20 DEF FNustr$(x%)=STRING$(MAX(0,1 -(x%\10)),"0")+MID$(STR$(x%),2)
25 DEF FNshwStats$(x%,y%)=FNustr$(x%)+"/"+FNustr$(y%)
29'
30 DIM bfr$(1) 'bufferText
40 raw$="":name$="": 'rawInputFromPlayer
45 RANDOMIZE(TIME)
90 GOTO 1000 'startGame
99'
100'Load buffer
105 ERASE bfr$:DIM bfr$(chSize%)
110 OPENIN cfile$+".TXT"
115 FOR li%=1 TO chSize%
120    LINE INPUT #9, bfr$(li%)
125 NEXT
130 CLOSEIN
135 RETURN
149'
150'Display Text
155 FOR tIndex%=bop% to eop%
160    ltp$=bfr$(tIndex%):tabs%=5
162    GOSUB 'standard headings
165    IF MID$(ltp$,1,1)="\" THEN GOSUB 200 'centerLine
170    GOSUB 280 'replaceName
175    PRINT TAB(tabs%) ltp$
180 NEXT tIndex%
185 RETURN
199'
200'CenterLine
205 ltp$=MID$(ltp$,2)+CHR$(10):tabs%=(80 - LEN(ltp$))\2
210 RETURN
219'
220'getName
225 PRINT:INPUT "     > ", raw$
230 IF LEN(raw$) > 7 OR LEN(raw$) < 2 THEN GOSUB 250 ELSE GOTO 240
235 GOTO 225
240 name$=UPPER$(LEFT$(raw$,1))+LOWER$(MID$(raw$,2)):raw$="":PRINT
245 RETURN
249 '
250 'Clean4Reinput
255 PRINT CHR$(7);
260 LOCATE 1, VPOS(#0)-1
265 PRINT TAB(80)
270 LOCATE 1, VPOS(#0)
275 RETURN
279 '
280 'Replace Name
285 sI%=INSTR(ltp$,"*")
290 WHILE sI% <> 0
295    ltp$=LEFT$(ltp$, sI%-1)+name$+MID$(ltp$, sI%+1)
300    sI%=INSTR(ltp$,"*")
305 WEND
310 RETURN
329 '
330 'getAge
335 PRINT:INPUT "     > ", raw$
340 IF VAL(raw$) > 17 OR VAL(raw$) < 13 THEN GOSUB 250 ELSE GOTO 350
345 GOTO 335
350 age%=VAL(raw$):raw$="":PRINT
355 RETURN
359'
360'Generate Scores
365 knw%=MAX(6,FNtwoD3+(age%-10)\2):cknw%=knw%
370 per%=MAX(6,FNtwoD3+FNdice(3)):cper%=per%
375 grc%=MAX(6,FNtwoD3+(19-age%)\2):cgrc%=grc%
380 skl%=MAX(7,FNtwoD3+FNdice(3)):cskl%=skl%
385 htp%=FNtwoD3+age%:chtp%=htp%
387 rptn%=10
390 RETURN
399'
400'StartNewSection
405 'GOSUB 31900' Check for death
410 CLS:LOCATE 1,25 ' Print Status Line
415 ltp$= name$+","+FNustr$(age%)+" y/o"+" KNW "+FNshwStats$(knw%,cknw%)+" PER "+FNshwStats$(per%,cper%)+" GRC "+FNshwStats$(grc%,cgrc%)+" SKL "+FNshwStats$(skl%,cskl%)+" HTP "+FNshwStats$(htp%,chtp%)
420 PRINT TAB((80 - LEN(ltp$))\2) ltp$
425 LOCATE 1,1:GOSUB 150'displayText
430 RETURN
439'
440'AnyKey2continue
445 PRINT : PRINT TAB(25) ">>> Any key to continue <<<":CALL &BB18
450 RETURN
459'
460'GetPlayerChoice
465 raw$=INKEY$ : IF raw$="" GOTO 465
470 IF INSTR("12", raw$) <> 0 GOTO 495 
475 LOCATE 1,24
480 PRINT TAB(20) "Choices Available: 1 or 2";
485 GOTO 465
495 chc$=raw$ : raw$=""
500 RETURN
509'
510'theEnd
515 END
599'
600'Standard Headings
610 IF ltp$<>")))" GOTO 620
615 ltp$=CHR$(10)+"Your choices"+CHR$(10):GOTO 630
620 IF ltp$<>"..." GOTO 630
625 ltp$="\..:: The End ::.."
630 RETURN
998'
999'
1000'Start Game
1005 CLS:MODE 2
1007'
1008'Chapter 0
1009'
1010 chSize%=10:cfile$="CH0":GOSUB 100
1019'
1020'Secction 0.1
1020 bop%=1:eop%=6:GOSUB 150'displayText
1025 GOSUB 220 'getName
1034'
1035'Secction 0.2
1040 bop%=8:eop%=10:GOSUB 150'displayText
1045 GOSUB 330 'getAge
1050 GOSUB 360 'generateScores
1058'
1059'
1060'Chapter 1
1065 chSize%=138:cfile$="CH1":GOSUB 100
1069'
1070'S1.1
1075 bop%=1:eop%=14:GOSUB 400
1080 GOSUB 440
1089'
1090'S1.2
1095 bop%=16:eop%=25:GOSUB 400
1100 GOSUB 460'gPChoice$
1105 IF chc$="1" THEN GOTO 1160
1110 IF cknw+FNtwoD3 > 8 THEN GOTO 1120 ELSE 1140
1119'
1120'S1.3
1125 bop%=27:eop%=34:GOSUB 400
1130 GOSUB 440:GOTO 1180
1139'
1140'S1.4
1145 bop%=36:eop%=42:GOSUB 400
1150 GOSUB 440:GOTO 1180
1159'
1160'S1.5
1165 chtp%=chtp%-FNtwoD3:bop%=44:eop%=48:GOSUB 400
1170 GOSUB 440:GOTO 1140
1179'
1180'S1.6
1185 bop%=50:eop%=67:GOSUB 400
1190 GOSUB 440:GOTO 1200
1199'
1200'S1.7
1205 bop%=69:eop%=81:GOSUB 400
1210 GOSUB 460:IF chc$="1" THEN GOTO 1220 ELSE GOTO 1250
1219'
1220'S1.8
1225 bop%=83:eop%=89:GOSUB 400
1230 GOSUB 460'gPChoice$
1235 IF chc$="2" THEN GOTO 1275'S1.10
1240 IF cskl+FNtwoD3>9 THEN GOTO 1320 ELSE 1330
1249'
1250'S1.9
1255 bop%=91:eop%=95:GOSUB 400
1260 GOSUB 440'AnyKey2cont...
1265 GOTO 1270
1269'
1270'S1.10
1275 bop%=97:eop%=104:GOSUB 400
1280 GOSUB 460'gPChoice$
1285 IF chc$="2" THEN GOTO 1330'S1.13
1290 IF cskl+FNtwoD3>11 THEN GOTO 1300 ELSE GOTO 1320
1299'
1300'S1.11
1305 bop%=106:eop%=124:GOSUB 400
1310 GOSUB 460:IF chc$="1" THEN GOTO 1370 ELSE 1350
1319'
1320'S1.12 no text
1325 chtp%=chtp%-FNtwoD3:GOTO 1300
1329'
1330'S1.13
1335 bop%=128:eop%=130:GOSUB 400
1340 GOSUB 510
1349'
1350'S1.14
1355 bop%=132:eop%=138:GOSUB 400
1360 GOSUB 510'theEnd
1368'
1369'
1370'CHAPTER 2
1375 chSize%=158:cfile$="CH2":GOSUB 100
1479'
1380'S2.1
1385 bop%=1:eop%=16:GOSUB 400
1390 GOSUB 440
1399'
1400'S2.2
1405 bop%=18:eop%=31:GOSUB 400
1410 GOSUB 460
1415 IF chc$="1" THEN GOTO 1420 ELSE 1440
1419'
1420'S2.3
1425 bop%=33:eop%=42:GOSUB 400
1430 rptn%=rptn%-1:GOSUB 440:GOTO 1460
1439'
1440'S2.4
1445 bop%=44:eop%=50:GOSUB 400
1450 rptn%=rptn%+FNdice(3):GOSUB 440:GOTO 1460
1459'
1460'S2.5
1465 bop%=52:eop%=66:GOSUB 400
1470 GOSUB 460:IF chc$="1" THEN GOTO 1485 ELSE GOTO 1500
1479'
1480'S2.6
1485 bop%=68:eop%=85:GOSUB 400
1490 GOSUB 440:GOTO 1620
1499'
1500'S2.7
1505 bop%=87:eop%=103:GOSUB 400
1510 GOSUB 460'gPChoice$
1515 IF chc$="1" THEN GOTO 1530
1520 IF cgrc%+FNfourD3>14 THEN GOTO 1560 ELSE 1580
1529'
1530'S2.8
1535 bop%=105:eop%=120:GOSUB 400
1540 GOSUB 460'gPChoice$
1545 IF chc$="1" THEN GOTO 1600'2.11:::
1550 IF cgrc%+FNfourD3>12 THEN GOTO 1560 ELSE 1580
1559'
1560'S2.9
1565 bop%=122:eop%=135:GOSUB 400
1570 GOSUB 440:GOTO 2000'CH4.1 provisional!!!!!
1579'
1580'S2.10
1585 bop%=137:eop%=151:GOSUB 400
1590 flags%(1)=1:GOSUB 440:GOTO 2000'CH4.1 provisional!!!!!
1599'
1600'S.11
1605 bop%=153:eop%=158:GOSUB 400
1610 GOSUB 510'theEnd
1618'
1619'
1620'CH3
1625 chSize%=50:cfile$="CH3":GOSUB 100
1629'
1630'S3.1
1635 bop%=1:eop%=18:GOSUB 400:GOSUB 440
1639'
1640'S3.2
1645 bop%=20:eop%=33:GOSUB 400
1650 GOSUB 460:IF chc$="1" THEN GOTO 1660 ELSE GOTO 1680
1659'
1660'S3.3
1665 bop%=35:eop%=44:GOSUB 400
1670 GOSUB 460:IF chc$="1" THEN GOTO 1710
1675 IF cskl%+FNfourD3>14 THEN GOTO 'S3.6 ELSE 'S3.7
1679'
1680'S3.4
1690 bop%=46:eop%=50:GOSUB 400
1700 GOSUB 460:IF chc$="1" THEN GOTO 1710
1705 IF cskl%+FNfourD3>14 THEN GOTO 'S3.8 ELSE 'S3.9
1709'
1710'S3.5
1999'
2000'Ch4 provisional!!!
4000 END

Powered by SMFPacks Menu Editor Mod