Opry99er Posted March 18, 2015 Share Posted March 18, 2015 (edited) Okay, I've been trying to find all my old code inside 3 hard drives, several USB sticks and a bunch of online storage locations. Got most of it off my laptop hard drive. My first attempt at using TIdBiT was the following. Code In: REM MENU A: CALL CLEAR :: CALL SCREEN(2) DISPLAY AT(1,4):"THIS IS A MENU TEST";" FOR BERYL REICHARDT"; DISPLAY AT(8,1):"PRESS 1 FOR WEAPONS";"PRESS 2 FOR STATS";"PRESS 3 TO EXIT"; K: CALL KEY(0,K,S):: IF S=0 THEN GOTO K IF K>51 THEN GOTO K ELSE IF K<49 THEN GOTO K ON K-48 GOTO W,S,E W: CALL CLEAR :: PRINT "WEAPONS" :: PRINT "PRESS ENTER TO EXIT" W1: CALL KEY(0,K,S):: IF S=0 THEN GOTO W1 IF K=13 THEN GOTO A ELSE W S: CALL CLEAR :: PRINT "STATS" :: PRINT "PRESS ENTER TO EXIT" S1: CALL KEY(0,K,S):: IF S=0 THEN GOTO S1 IF K=13 THEN GOTO A ELSE S E: CALL CLEAR :: GOTO 150 Code Out: 1000 CALL CLEAR :: CALL SCREEN(2) 1010 DISPLAY AT(1,4):"THIS IS A MENU TEST";" FOR BERYL REICHARDT"; 1020 DISPLAY AT(8,1):"PRESS 1 FOR WEAPONS";"PRESS 2 FOR STATS";"PRESS 3 TO EXIT"; 1030 CALL KEY(0,K,S):: IF S=0 THEN GOTO 1030 1040 IF K>51 THEN GOTO 1030 ELSE IF K<49 THEN GOTO 1030 1050 ON K-48 GOTO 1060,1090,1120 1060 CALL CLEAR :: PRINT "WEAPONS" :: PRINT "PRESS ENTER TO EXIT" 1070 CALL KEY(0,K,S):: IF S=0 THEN GOTO 1070 1080 IF K=13 THEN GOTO 1000 ELSE 1060 1090 CALL CLEAR :: PRINT "STATS" :: PRINT "PRESS ENTER TO EXIT" 1100 CALL KEY(0,K,S):: IF S=0 THEN GOTO 1100 1110 IF K=13 THEN GOTO 1000 ELSE 1090 1120 CALL CLEAR :: GOTO 150 This was relatively simple and it was my first test to make a simple menu skeleton. As you can see, I needed to have multiple sections of the same chunk of code (W,W1,S,S1) in order to handle what would happen if certain conditions were met. It worked very well (although I do not believe this particular example works anymore... since it was put into the game code {hybridized} I had to make some changes)... You can see the structure there. Love what TIdBiT did to the code, even though it looks wonky to me, it works beautifully. So, I have lots of GOSUBS leading into other GOSUBS with multiple returns and the like in this Beryl code. It might get even more messy when I tear it apart and put it back together again... We will see. To give you a sense of what I'm talking about, I'll post the current incarnation of the code here.... pre-RESequence. I have not found my completely-commented Notepad++ file yet, but here's the working code for the game as it stands. To do next: Work on status menu for the characters using the same "ALEV=RLEV" type plug-in conversion as in item menu Also, FIX THE MENU ITEMS!!!! LOOKING LIKE CRAP, WILL NOT CLEAR SCREEN BEFORE DISPLAYING MENU ITEM INFO 100 REM LINK UP TO LOAD DATA INTO MEMORY 200 CALL LDAT 300 REM DESIGNATE MAP AND CHARACTER START POINT 400 MX=1 :: MY=1 500 PX=18 :: PY=8 600 SPX=(PX-1)*8+1 :: SPY=(PY-1)*8+17 650 REM REMEMBER TO CHANGE HPO, MPO, and ELI in existing code 700 REM STATISTICS FOR PARTY 800 GLD=100 :: HPO=4 :: MPO=4 :: ELI=4 :: SCR=0 900 REM REPEATED STRINGS AND ITEMS 1000 EX$="PRESS ENTER TO EXIT" 1100 BS$="BROADSWORD" 1200 EXU$="^^^^^^^^^^^^^^^^^^^" 1300 REM PARTY BATTLE STATS FOR BERYL, REPTO, SKYLAR, and MARKUS 1400 BMHP=20 :: BHP=15 :: BMMP=20 :: BMP=5 :: BDEF=10 :: BATK=10 :: BMDEF=7 :: BMATK=4 1500 RMHP=16 :: RHP=5 :: RMMP=40 :: RMP=20 :: RDEF=3 :: RATK=4 :: RMDEF=10 :: RMATK=12 1600 MMHP=25 :: MHP=18 :: MMMP=0 :: MMP=0 :: MDEF=15 :: MATK=15 :: MMDEF=5 :: MMATK=0 1700 SMHP=12 :: SHP=5 :: SMMP=20 :: SMP=12 :: SDEF=5 :: SATK=4 :: SMDEF=9 :: SMATK=8 1710 REM LEVELS 1720 BLEV=1 :: RLEV=1 :: MLEV=1 :: SLEV=1 1800 REM SET UP SCREEN AND BORDER FOR EXPLORATION 1900 CALL CLEAR 2000 CALL SCREEN(2) 2100 CALL HCHAR(9,1,101,32):: CALL HCHAR(24,1,101,32):: CALL VCHAR(9,1,97,16):: CALL VCHAR(9,32,97,16) 2200 CALL HCHAR(9,1,98):: CALL HCHAR(9,32,100):: CALL HCHAR(24,1,99):: CALL HCHAR(24,32,96) 2300 CALL CHAR(42,"193DD9FFD91924C3"):: CALL COLOR(2,16,2) 2400 GOSUB 10700 2500 REM Beginning of main game loop 2600 CALL SETMAP(MX,MY) 2700 CALL SPRITE(#1,42,16,SPX,SPY) 2800 REM CHARACTER ON SCREEN 2900 REM DISPLAY AT(PX,PY):CHR$(42); 3000 SPX=(PX-1)*8+1 :: SPY=(PY-1)*8+17 3100 CALL LOCATE(#1,SPX,SPY) 3200 REM KEYBOARD SCAN 3300 CALL KEY(0,K,S):: IF S=0 THEN 3300 3400 REM must add 2 to each column to compensate for the DISPLAY/GCHAR offset 3500 IF K=69 THEN CALL GCHAR(PX-1,PY+2,Q):: IF Q>104 THEN 3300 ELSE PX=PX-1 :: GOTO 4300 3600 IF K=83 THEN CALL GCHAR(PX,PY+1,Q):: IF Q>104 THEN 3300 ELSE PY=PY-1 :: GOTO 4300 3700 IF K=68 THEN CALL GCHAR(PX,PY+3,Q):: IF Q>104 THEN 3300 ELSE PY=PY+1 :: GOTO 4300 3800 IF K=88 THEN CALL GCHAR(PX+1,PY+2,Q):: IF Q>104 THEN 3300 ELSE PX=PX+1 :: GOTO 4300 3900 REM CHECK FOR THE MENU AND EXAMINE COMMANDS (space bar and "M" key) 4000 IF K=32 THEN GOSUB 5500 4100 IF K=77 THEN GOTO 7100 4200 GOTO 3300 4300 REM this determines the boundaries onscreen and sets the map to be drawn by assembly routine 4400 REM PX, PY are the current player's position on the screen 4500 REM MX, MY are the designations for which map will be drawn 4600 IF PX<11 THEN PX=22 :: MY=MY-1 :: GOTO 5100 4700 IF PX>22 THEN PX=11 :: MY=MY+1 :: GOTO 5100 4800 IF PY<1 THEN PY=28 :: MX=MX-1 :: GOTO 5100 4900 IF PY>28 THEN PY=1 :: MX=MX+1 :: GOTO 5100 5000 GOTO 3000 5100 IF MX<1 THEN MX=1 ELSE IF MX>2 THEN MX=2 5200 IF MY<1 THEN MY=1 ELSE IF MY>6 THEN MY=6 5300 CALL DELSPRITE(#1) 5400 GOTO 2600 5500 REM "EXAMINE" 5600 DISPLAY AT(1,1):" ":" ":" ":" ":" ":" ":" ":" " 5700 DISPLAY AT(1,1):"WHICH DIRECTION?"; 5800 CALL KEY(0,K,S):: IF S=0 THEN 5800 5900 IF K=69 THEN CALL GCHAR(PX-1,PY+2,Q):: GOSUB 6400 :: RETURN 6000 IF K=83 THEN CALL GCHAR(PX,PY+1,Q):: GOSUB 6400 :: RETURN 6100 IF K=68 THEN CALL GCHAR(PX,PY+3,Q):: GOSUB 6400 :: RETURN 6200 IF K=88 THEN CALL GCHAR(PX+1,PY+2,Q):: GOSUB 6400 :: RETURN 6300 GOTO 5800 6400 IF Q=115 THEN IT$=BS$ :: GOTO 6600 6500 DISPLAY AT(1,1):" " :: GOSUB 10700 :: RETURN 6600 DISPLAY AT(1,1):"YOU FOUND A ";IT$;:"ADD TO INVENTORY? (Y/N)"; 6700 CALL KEY(0,K,S):: IF S=0 THEN 6700 6800 IF K=89 THEN DISPLAY AT(1,1):" ":" " :: GOSUB 10700 :: RETURN 6900 IF K=78 THEN DISPLAY AT(1,1):" ":" " :: GOSUB 10700 :: RETURN 7000 GOTO 6700 7100 REM MENU 7200 CALL CLEAR :: CALL SCREEN(2):: CALL DELSPRITE(#1) 7300 CALL HCHAR(5,1,101,32):: CALL HCHAR(20,1,101,32):: CALL VCHAR(5,1,97,15):: CALL VCHAR(5,32,97,15) 7400 CALL HCHAR(5,1,98):: CALL HCHAR(5,32,100):: CALL HCHAR(20,1,99):: CALL HCHAR(20,32,96) 7500 GOSUB 10100:: GOSUB 10400 7600 DISPLAY AT(8,1):"1) ITEMS":"2) ARMOR":"3) WEAPONS":"4) SPELLS":"5) STATUS"; 7700 CALL KEY(0,K,S):: IF S=0 THEN GOTO 7700 7750 IF K=13 THEN CALL CLEAR :: GOTO 2100 7800 IF K>54 THEN GOTO 7700 ELSE IF K<49 THEN GOTO 7700 7900 ON K-48 GOTO 8000,8400,8900,9300,9700 8000 REM ITEM MENU 8010 GOSUB 10100 8100 DISPLAY AT(1,12):"ITEMS";:: DISPLAY AT(2,12):"^^^^^" :: GOSUB 10400 8110 DISPLAY AT(8,1):"USE ON WHICH CHARACTER?";:"1) BERYL";:"2) REPTOSLICER";:"3) MARKUS";:"4) SKYLAR"; 8111 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8111 8112 IF K=13 THEN GOTO 7500 8113 IF K>52 THEN GOTO 8111 ELSE IF K<49 THEN GOTO 8111 8114 ON K-48 GOSUB 8125,8135,8145,8155 8115 GOTO 8000 8120 REM ACN=name, ANSP=name starting point, ANL=name length 8125 REM BERYL 8126 AMHP=BMHP :: AHP=BHP :: AMMP=BMMP :: AMP=BMP :: ACN$="BERYL" :: ANSP=12 :: ANL=5 8128 GOSUB 8177 8131 BHP=AHP :: BMP=AMP :: RETURN 8135 REM REPTO 8136 AMHP=RMHP :: AHP=RHP :: AMMP=RMMP :: AMP=RMP :: ACN$="REPTOSLICER" :: ANSP=9 :: ANL=11 8138 GOSUB 8177 8141 RHP=AHP :: RMP=AMP :: RETURN 8145 REM MARKUS 8146 AMHP=MMHP :: AHP=MHP :: AMMP=MMMP :: AMP=MMP :: ACN$="MARKUS" :: ANSP=12 :: ANL=6 8148 GOSUB 8177 8151 MHP=AHP :: MMP=AMP :: RETURN 8155 REM SKYLAR 8156 AMHP=SMHP :: AHP=SHP :: AMMP=SMMP :: AMP=SMP :: ACN$="SKYLAR" :: ANSP=12 :: ANL=6 8158 GOSUB 8177 8161 SHP=AHP:: SMP=AMP :: RETURN 8176 REM **THIS IS THE MEAT OF THE ITEM MENU CODE** 8177 GOSUB 10100 :: DISPLAY AT(1,ANSP):ACN$;:: CALL HCHAR(2,ANSP+2,94,ANL) 8179 GOSUB 10400 8181 DISPLAY AT(8,1):"1) POTION";HPO;:"2) ETHER";MPO;:"3) ELIXIR";ELI; 8183 DISPLAY AT(3,1):"HP:";AHP;"/";AMHP;:: DISPLAY AT(3,16):"MP:";AMP;"/";AMMP; 8184 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8184 8185 IF K=13 THEN GOTO 8000 8187 IF K>51 THEN GOTO 8183 ELSE IF K<49 THEN GOTO 8183 8189 ON K-48 GOSUB 8195,8201,8207 8191 CALL SCREEN(16):: FOR I=1 TO 20 :: NEXT I :: CALL SCREEN(2) 8192 DISPLAY AT(3,1):"HP:";AHP;"/";AMHP;:: DISPLAY AT(3,16):"MP:";AMP;"/";AMMP; 8193 DISPLAY AT(8,1):"1) POTION";HPO;:"2) ETHER";MPO;:"3) ELIXIR";ELI;:: FOR I=1 TO 400 :: NEXT I 8194 RETURN 8195 IF HPO<1 THEN CALL SOUND(30,440,1):: HPO=0 :: GOTO 8181 8197 HPO=HPO-1 :: AHP=AHP+10 :: IF AHP>AMHP THEN AHP=AMHP 8199 RETURN 8201 IF MPO<1 THEN CALL SOUND(30,440,1):: MPO=0 :: GOTO 8181 8203 MPO=MPO-1 :: AMP=AMP+10 :: IF AMP>AMMP THEN AMP=AMMP 8205 RETURN 8207 IF ELI<1 THEN CALL SOUND(30,440,1):: ELI=0 :: GOTO 8181 8209 ELI=ELI-1 :: AHP=AHP+5 :: IF AHP>AMHP THEN AHP=AMHP 8211 AMP=AMP+5 :: IF AMP>AMMP THEN AMP=AMMP 8213 RETURN 8400 REM ARMOR MENU 8500 GOSUB 10100:: DISPLAY AT(1,12):"ARMOR";:: DISPLAY AT(2,12):"^^^^^" :: GOSUB 10400 8600 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8600 8700 IF K=13 THEN GOTO 7500 ELSE 8600 8800 GOSUB 10100 8899 REM WEAPONS MENU 8900 GOSUB 10100 :: DISPLAY AT(1,11):"WEAPONS";:: DISPLAY AT(2,11):"^^^^^^^" :: GOSUB 10400 9000 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9000 9100 IF K=13 THEN GOTO 7500 ELSE 9000 9200 GOSUB 10100 8299 REM SPELLS MENU 9300 GOSUB 10100 :: DISPLAY AT(1,12):"SPELLS";:: DISPLAY AT(2,12):"^^^^^^" :: GOSUB 10400 9400 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9400 9500 IF K=13 THEN GOTO 7500 ELSE 9400 9600 GOSUB 10100 ************************** **** NEXT AREA OF WORK**** ************************** 9696 REM STATUS MENU 9697 REM THIS IS THE NEXT AREA OF FOCUS... GET WORKING STATUS MENU GOING BY LOADING THE "A" SET WITH CHAR'S INFO 9698 REM **USE THESE: ALEV=BLEV :: AMHP=BMHP :: AHP=BHP :: AMMP=BMMP :: AMP=BMP :: ADEF=BDEF :: AATK=BATK :: AMDEF=BMDEF 9699 REM **AMATK=BMATK :: ACN$="BERYL" :: ANSP=14 :: ANL=5 9700 GOSUB 10100 :: DISPLAY AT(1,12):"STATUS";:: DISPLAY AT(2,12):"^^^^^^" :: GOSUB 10400 9800 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9800 9900 IF K=13 THEN GOTO 7500 ELSE 9800 10000 CALL CLEAR :: GOTO 2100 10100 REM CLEAR MENU INFO 10200 DISPLAY AT(8,1):" ":" ":" ":" ":" ":" " :: DISPLAY AT(1,1):" ":" ":" " :: DISPLAY AT(22,1):" ":" " 10300 RETURN 10400 REM MENU RETURN GAME STRING 10500 DISPLAY AT(22,5):EX$;:: DISPLAY AT(23,5):EXU$; 10600 RETURN 10700 REM SCREEN INFO DISPLAY 10800 DISPLAY AT(1,9):"FORESTIA" 10900 DISPLAY AT(2,1):"BERYL":"HP:";BHP:"MP:";BMP :: DISPLAY AT(2,9):"^^^^^^^^"; 11000 DISPLAY AT(2,18):"REPTOSLICER" :: DISPLAY AT(3,18):"HP:";RHP :: DISPLAY AT(4,18):"MP:";RMP 11100 DISPLAY AT(6,1):"SKYLAR":"HP:";SHP:"MP:";SMP 11200 DISPLAY AT(6,18):"MARKUS" :: DISPLAY AT(7,18):"HP:";MHP :: DISPLAY AT(8,18):"MP:";MMP 11300 RETURN 11400 REM **END MAIN GAME LOOP** 11500 REM **SUB TO CALL THE ASSEMBLY ROUTINE TO LOAD MAP INTO MEMORY** 11600 SUB LDAT 11700 CALL INIT 11800 CALL LOAD("DSK1.NEWFORO") 11900 SUBEND 12000 REM **SUB TO DRAW THE MAP ONSCREEN** 12100 SUB SETMAP(MX,MY) 12200 X=MX :: Y=MY 12300 IF ADR<>0 THEN 12600 12400 CALL PEEK(16382,P,Q) 12500 ADR=P*256+Q+2 12600 Y=Y-1 :: MAP=Y*2+X 12700 IF MAP<1 OR MAP>12 THEN SUBEXIT 12800 CALL LOAD(ADR,0,MAP) 12900 CALL LINK("DRAW") 13000 SUBEND Not asking anyone to actually read the whole thing, but hopefully this will help give some sense of what I'm about to try here. Again, thanks for TIdBiT... It'll make my life so much easier AFTER it makes my life a living hell for a while. LOL!!! Lines 700-1720 are in-game variables Lines 1900-2400 make up the primary display block Lines 2600-5400 are the main game loop Lines 5500-7000 make up the the "examine" block Lines 7100-10000 are all the Menu block Lines 10100-13000 are SUBs. Like I said, no need to examine it all unless you're completely bored, but you can see some funky stuff Like: Line 4000 GOSUBs Line 5500--which conditionally GOSUBs 6400, which GOSUBs 10700 which returns, returns, returns, all the way back to 4000. Edited March 18, 2015 by Opry99er 1 Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 18, 2015 Share Posted March 18, 2015 I guess technically, the Menu and Examine blocks should be true SUBroutines, with a CALL MENU and CALL EXAMINE. Thats why I REALLY need to convert this to TIdBiT... It will make everything so much more logical to work on. Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 18, 2015 Share Posted March 18, 2015 Owen, you're still not taking advantage of the main strengths of TidBit: descriptive long comments and indentation. Remember you can break up long statements with a .. at the end of each so you can indent them, and yet they will still come out as a single statement in the final conversion. Here's what your code could look like. I did not tackle the labels though. It does make for longer listings, but IMHO much clearer and easier to follow ones. // MENU A: CALL CLEAR :: CALL SCREEN(2) DISPLAY AT(1,4):"THIS IS A MENU TEST";" FOR BERYL REICHARDT"; DISPLAY AT(8,1):"PRESS 1 FOR WEAPONS";"PRESS 2 FOR STATS";"PRESS 3 TO EXIT"; K: CALL KEY(0,K,S):: .. IF S=0 THEN .. GOTO K IF K>51 THEN .. GOTO K .. ELSE .. IF K<49 THEN .. GOTO K ON K-48 GOTO W,S,E W: CALL CLEAR :: .. PRINT "WEAPONS" :: .. PRINT "PRESS ENTER TO EXIT" W1: CALL KEY(0,K,S):: .. IF S=0 THEN .. GOTO W1 IF K=13 THEN .. GOTO A .. ELSE .. W S: CALL CLEAR :: .. PRINT "STATS" :: .. PRINT "PRESS ENTER TO EXIT" S1: CALL KEY(0,K,S):: .. IF S=0 THEN .. GOTO S1 IF K=13 THEN .. GOTO A .. ELSE .. S E: CALL CLEAR :: .. GOTO 150 Quote Link to comment Share on other sites More sharing options...
TheMole Posted March 18, 2015 Share Posted March 18, 2015 Yeah, longer labels would make it a lot more readable. Especially if you're coming back to your code at a later point in time and you have to figure out what each label stood for. Something like this might make sense maybe? // MENU PRINT_MENU: CALL CLEAR :: CALL SCREEN(2) DISPLAY AT(1,4):"THIS IS A MENU TEST";" FOR BERYL REICHARDT"; DISPLAY AT(8,1):"PRESS 1 FOR WEAPONS";"PRESS 2 FOR STATS";"PRESS 3 TO EXIT"; SELECT_ITEM: CALL KEY(0,K,S):: .. IF S=0 THEN .. GOTO SELECT_ITEM IF K>51 THEN .. GOTO SELECT_ITEM .. ELSE .. IF K<49 THEN .. GOTO SELECT_ITEM ON K-48 GOTO PRINT_WEAPONS, STATS, EXIT_MENU PRINT_WEAPONS: CALL CLEAR :: .. PRINT "WEAPONS" :: .. PRINT "PRESS ENTER TO EXIT" SELECT_WEAPON: CALL KEY(0,K,S):: .. IF S=0 THEN .. GOTO SELECT_WEAPON IF K=13 THEN .. GOTO PRINT_MENU .. ELSE .. PRINT_WEAPONS PRINT_STATS: CALL CLEAR :: .. PRINT "STATS" :: .. PRINT "PRESS ENTER TO EXIT" SELECT_STAT: CALL KEY(0,K,S):: .. IF S=0 THEN .. GOTO SELECT_STAT IF K=13 THEN .. GOTO PRINT_MENU .. ELSE .. PRINT_STATS EXIT_MENU: CALL CLEAR :: .. GOTO 150 Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 18, 2015 Share Posted March 18, 2015 Yea.. As I said, this was done a few years ago... Thanks for the code suggestions guys. It is quite amazing how much one can learn from small little snippits of code. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 18, 2015 Share Posted March 18, 2015 (edited) The funny thing is, At first glance, I understood your BASIC listing more clearly than the TIdBiT source, Vorticon... But thats because of my lack of knowledge of higher level languages. When I translate this over myself, however, I have a feeling I.will grasp it so much better... And moving forward, I'll likely do all my XB in TIdBiT. Edited March 18, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 18, 2015 Share Posted March 18, 2015 Yeah, Python can really hammer indentation into you. In that language, indentations matter and you actually get an error if you get them wrong! Quote Link to comment Share on other sites More sharing options...
matthew180 Posted March 18, 2015 Author Share Posted March 18, 2015 Owen, have you ever programmed in anything other than TI BASIC/XB? If not, you will need to unlearn a lot of inherent bad that comes with any ROM BASIC from the 80's computers. Formatting you code helps you read it and keep the parts of it logically organized. Formatting code is for humans (the computer does not care) and is arguably as important as structuring written text. Imagine trying to read a book that has no sentence, paragraph, or chapter structure. Some format tips: Use descriptive labels. TidBit replaces labels with line numbers, so their length has no impact on your code or memory use. This is not the case for variables though, and unfortunately shorter is better in that case (a side effect of using a ROM BASIC.) Put labels on their own line. A label simply "names" a point in your code that you can refer to. Use indentation to help you see what code gets executed based on a logical path. An "IF-THEN" is the easiest example: IF A<1 THEN .. A=1 .. ELSE IF A>32 THEN .. A=32 ENDIF To most people that is easier to read than: IF A<1 THEN A=1 ELSE IF A>32 THEN A=32 Arguably this is not a very complex example, so the advantage might not be as clear. Loops make it more clear though. 10 RUNNING=1 20 IF RUNNING<>1 THEN 100 20 FOR Y=1 TO 24 30 FOR X=1 TO 32 40 CALL HCHAR(X,Y,32) 50 NEXT X 60 NEXT Y 70 INKEY$(0,K,S) 80 IF S<>0 THEN RUNNING=0 90 GOTO 20 100 END Again, smaller examples are not quite as tedious to read, but still, with a little formatting is is easier to follow the flow (and see the simulated "while" loop that TI XB does not have): RUNNING=1 // Main Loop main_while: IF RUNNING<>1 THEN main_while_end FOR Y=1 TO 24 FOR X=1 TO 32 CALL HCHAR(X,Y,32) NEXT X NEXT Y INKEY$(0,K,S) IF S<>0 THEN RUNNING=0 GOTO main_while main_while_end: END It is easier to see what happens inside each loop, especially when the loop body grows and you can't always see the "NEXT" on the same screen as the FOR. Anyway, these are small and contrived examples, but it will make a difference as you code grows. But thats because of my lack of knowledge of higher level languages. Actually, BASIC is a high-level language. Language "level" typically refers to how *close* to assembly language (i.e. the CPU and direct hardware access) the language is. A language's syntax and/or formatting have nothing to do with its "level". Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 18, 2015 Share Posted March 18, 2015 Good stuff. Ive done a little html and some 9900 assembly, but the majority of my projects have been in XB/ROM BASIC. Should hopefully have some time tonight to start breaking up this code into something more legible. If i get off.before midnight... Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 18, 2015 Share Posted March 18, 2015 (edited) Also got through the 2 day beginners tutorial using C# in the eclipse package. That was miserable... Also some rudimentary Forth on the Jupiter Ace computer. Edited March 18, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 19, 2015 Share Posted March 19, 2015 (edited) Got a chunk converted over tonight.... No indentation yet, but what's there WILL convert (I'm hoping) It's actually going more quickly than I thought.... But I really haven't gotten into the real spaghetti of the code yet. In the code box below, you can see I started at the top of the code, doing sections of subroutines as they got referenced in the loop. The ones I haven't done yet are the biggies... Examine and Menu. Most of the other stuff will get very simplified as I go forward. Let me know what you think so far! Beryl Reichardt TIdBiT transfer workstation: 3/18/15 // first thing to do is call the link up to load the map data into memory InitLoad MapData: CALL LDAT PlayerStartup: // Give player a "place to start" // MX and MY are which map in the world are going to be drawn. In this case, it's 1,1 // PX&PY are the players' X location and Y location on the screen, SPX and SPY are the location of the SPRITE corresponding to the character position MX=1 :: MY=1 PX=18 :: PY=8 SPX=(PX-1)*8+1 :: SPY=(PY-1)*8+17 // These are party inventory... Starting with 100 gold, 4 health potions, 4 magic potions, 4 Elixirs, and zero scrolls GLD=100 :: HPO=4 :: MPO=4 :: ELI=4 :: SCR=0 // These are repeated strings. Currently there are only two, but there will be many more to come EX$="PRESS ENTER TO EXIT" BS$="BROADSWORD" EXU$="^^^^^^^^^^^^^^^^^^^" // These are Individual statistics for Beryl, Skylar, and Markus. // MHP is max health power, HP is current health power // MMP is max magic power, MP is current magic power // DEF and ATK are the current stats for defense and attack // MDEF and MATK are max stats for defense and attack BMHP=20 :: BHP=15 :: BMMP=20 :: BMP=5 :: BDEF=10 :: BATK=10 :: BMDEF=7 :: BMATK=4 RMHP=16 :: RHP=5 :: RMMP=40 :: RMP=20 :: RDEF=3 :: RATK=4 :: RMDEF=10 :: RMATK=12 MMHP=25 :: MHP=18 :: MMMP=0 :: MMP=0 :: MDEF=15 :: MATK=15 :: MMDEF=5 :: MMATK=0 SMHP=12 :: SHP=5 :: SMMP=20 :: SMP=12 :: SDEF=5 :: SATK=4 :: SMDEF=9 :: SMATK=8 //These are the player "levels". When the player level goes up, so will most of the maximum stats above. BLEV=1 :: RLEV=1 :: MLEV=1 :: SLEV=1 Setscreen: // set up screen and border for exploration routines CALL CLEAR CALL SCREEN(2) !black screen CALL HCHAR(9,1,101,32):: CALL HCHAR(24,1,101,32):: CALL VCHAR(9,1,97,16):: CALL VCHAR(9,32,97,16) !border around viewport CALL HCHAR(9,1,98):: CALL HCHAR(9,32,100):: CALL HCHAR(24,1,99):: CALL HCHAR(24,32,96) !corners CALL CHAR(42,"193DD9FFD91924C3"):: CALL COLOR(2,16,2) !CHAR(42) is the little character representation so far... may change soon GOSUB TopInfo TopGameLoop: // This is the very top of the game loop. CALL SETMAP(MX,MY) CALL SPRITE(#1,42,16,SPX,SPY) MidGameLoop: // midpoint for returns from bottom of loop // displays the character on screen based on player position SPX=(PX-1)*8+1 :: SPY=(PY-1)*8+17 CALL LOCATE(#1,SPX,SPY) MidgameLoop Keyscan: GOSUB KeyScan //upon keypress, up down, left, right checking for tiles in the direction selected //must be a tile below (lower than)CHR$(104) to allow motion //must add 2 to each column to compensate for the DISPLAY/GCHAR offset IF K=69 THEN CALL GCHAR(PX-1,PY+2,Q):: IF Q>104 THEN GOTO MidgameLoop Keyscan ELSE PX=PX-1 :: GOTO CheckBoundary IF K=83 THEN CALL GCHAR(PX,PY+1,Q):: IF Q>104 THEN GOTO MidgameLoop Keyscan ELSE PY=PY-1 :: GOTO CheckBoundary IF K=68 THEN CALL GCHAR(PX,PY+3,Q):: IF Q>104 THEN GOTO MidgameLoop Keyscan ELSE PY=PY+1 :: GOTO CheckBoundary IF K=88 THEN CALL GCHAR(PX+1,PY+2,Q):: IF Q>104 THEN GOTO MidgameLoop Keyscan ELSE PX=PX+1 :: GOTO CheckBoundary //If M is pressed, goto menu block, if space bar, goto examine block IF K=32 THEN GOSUB Examine IF K=77 THEN GOTO MainMenu GOTO MidgameLoop Keyscan CheckBoundary: // this determines the boundaries onscreen and sets the map to be drawn by assembly routine // PX, PY are the current player's position on the screen // MX, MY are the designations for which map will be drawn IF PX<11 THEN PX=22 :: MY=MY-1 :: GOTO CheckMap !if player walks off top of screen, place character on opposite side of screen IF PX>22 THEN PX=11 :: MY=MY+1 :: GOTO CheckMap !if player walks off bottom of screen, place character on opposite side of screen IF PY<1 THEN PY=28 :: MX=MX-1 :: GOTO CheckMap !if player walks off left of screen, place character on opposite side of screen IF PY>28 THEN PY=1 :: MX=MX+1 :: GOTO CheckMap !if player walks off right of screen, place character on opposite side of screen GOTO MidGameLoop CheckMap: IF MX<1 THEN MX=1 ELSE IF MX>2 THEN MX=2 IF MY<1 THEN MY=1 ELSE IF MY>6 THEN MY=6 CALL DELSPRITE(#1) GOTO TopGameLoop //End game Loop!!!!!!!!!!!!// //Subroutines follow TopInfo: //this displays all necessary information at the top of the screen during gameplay DISPLAY AT(1,9):"FORESTIA" DISPLAY AT(2,1):"BERYL":"HP:";BHP:"MP:";BMP :: DISPLAY AT(2,9):"^^^^^^^^"; DISPLAY AT(2,18):"REPTOSLICER" :: DISPLAY AT(3,18):"HP:";RHP :: DISPLAY AT(4,18):"MP:";RMP DISPLAY AT(6,1):"SKYLAR":"HP:";SHP:"MP:";SMP DISPLAY AT(6,18):"MARKUS" :: DISPLAY AT(7,18):"HP:";MHP :: DISPLAY AT(8,18):"MP:";MMP RETURN Keyscan: CALL KEY(0,K,S):: IF S=0 THEN Keyscan RETURN ******************************************** ******************************************** **This is the remainder of the code I have** **not converted yet. Most of these lines ** **or sections of lines are referenced in ** **the lines above, which are already ** **converted. ** ******************************************** ******************************************** 5500 REM "EXAMINE" 5600 DISPLAY AT(1,1):" ":" ":" ":" ":" ":" ":" ":" " 5700 DISPLAY AT(1,1):"WHICH DIRECTION?"; 5800 CALL KEY(0,K,S):: IF S=0 THEN 5800 5900 IF K=69 THEN CALL GCHAR(PX-1,PY+2,Q):: GOSUB 6400 :: RETURN 6000 IF K=83 THEN CALL GCHAR(PX,PY+1,Q):: GOSUB 6400 :: RETURN 6100 IF K=68 THEN CALL GCHAR(PX,PY+3,Q):: GOSUB 6400 :: RETURN 6200 IF K=88 THEN CALL GCHAR(PX+1,PY+2,Q):: GOSUB 6400 :: RETURN 6300 GOTO 5800 6400 IF Q=115 THEN IT$=BS$ :: GOTO 6600 6500 DISPLAY AT(1,1):" " :: GOSUB 10700 :: RETURN 6600 DISPLAY AT(1,1):"YOU FOUND A ";IT$;:"ADD TO INVENTORY? (Y/N)"; 6700 CALL KEY(0,K,S):: IF S=0 THEN 6700 6800 IF K=89 THEN DISPLAY AT(1,1):" ":" " :: GOSUB 10700 :: RETURN 6900 IF K=78 THEN DISPLAY AT(1,1):" ":" " :: GOSUB 10700 :: RETURN 7000 GOTO 6700 7100 REM MENU 7200 CALL CLEAR :: CALL SCREEN(2):: CALL DELSPRITE(#1) 7300 CALL HCHAR(5,1,101,32):: CALL HCHAR(20,1,101,32):: CALL VCHAR(5,1,97,15):: CALL VCHAR(5,32,97,15) 7400 CALL HCHAR(5,1,98):: CALL HCHAR(5,32,100):: CALL HCHAR(20,1,99):: CALL HCHAR(20,32,96) 7500 GOSUB 10100:: GOSUB 10400 7600 DISPLAY AT(8,1):"1) ITEMS":"2) ARMOR":"3) WEAPONS":"4) SPELLS":"5) STATUS"; 7700 CALL KEY(0,K,S):: IF S=0 THEN GOTO 7700 7750 IF K=13 THEN CALL CLEAR :: GOTO 2100 7800 IF K>54 THEN GOTO 7700 ELSE IF K<49 THEN GOTO 7700 7900 ON K-48 GOTO 8000,8400,8900,9300,9700 8000 REM ITEM MENU 8010 GOSUB 10100 8100 DISPLAY AT(1,12):"ITEMS";:: DISPLAY AT(2,12):"^^^^^" :: GOSUB 10400 8110 DISPLAY AT(8,1):"USE ON WHICH CHARACTER?";:"1) BERYL";:"2) REPTOSLICER";:"3) MARKUS";:"4) SKYLAR"; 8111 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8111 8112 IF K=13 THEN GOTO 7500 8113 IF K>52 THEN GOTO 8111 ELSE IF K<49 THEN GOTO 8111 8114 ON K-48 GOSUB 8125,8135,8145,8155 8115 GOTO 8000 8120 REM ACN=name, ANSP=name starting point, ANL=name length 8125 REM BERYL 8126 AMHP=BMHP :: AHP=BHP :: AMMP=BMMP :: AMP=BMP :: ACN$="BERYL" :: ANSP=12 :: ANL=5 8128 GOSUB 8177 8131 BHP=AHP :: BMP=AMP :: RETURN 8135 REM REPTO 8136 AMHP=RMHP :: AHP=RHP :: AMMP=RMMP :: AMP=RMP :: ACN$="REPTOSLICER" :: ANSP=9 :: ANL=11 8138 GOSUB 8177 8141 RHP=AHP :: RMP=AMP :: RETURN 8145 REM MARKUS 8146 AMHP=MMHP :: AHP=MHP :: AMMP=MMMP :: AMP=MMP :: ACN$="MARKUS" :: ANSP=12 :: ANL=6 8148 GOSUB 8177 8151 MHP=AHP :: MMP=AMP :: RETURN 8155 REM SKYLAR 8156 AMHP=SMHP :: AHP=SHP :: AMMP=SMMP :: AMP=SMP :: ACN$="SKYLAR" :: ANSP=12 :: ANL=6 8158 GOSUB 8177 8161 SHP=AHP:: SMP=AMP :: RETURN 8176 REM **THIS IS THE MEAT OF THE ITEM MENU CODE** 8177 GOSUB 10100 :: DISPLAY AT(1,ANSP):ACN$;:: CALL HCHAR(2,ANSP+2,94,ANL) 8179 GOSUB 10400 8181 DISPLAY AT(8,1):"1) POTION";HPO;:"2) ETHER";MPO;:"3) ELIXIR";ELI; 8183 DISPLAY AT(3,1):"HP:";AHP;"/";AMHP;:: DISPLAY AT(3,16):"MP:";AMP;"/";AMMP; 8184 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8184 8185 IF K=13 THEN GOTO 8000 8187 IF K>51 THEN GOTO 8183 ELSE IF K<49 THEN GOTO 8183 8189 ON K-48 GOSUB 8195,8201,8207 8191 CALL SCREEN(16):: FOR I=1 TO 20 :: NEXT I :: CALL SCREEN(2) 8192 DISPLAY AT(3,1):"HP:";AHP;"/";AMHP;:: DISPLAY AT(3,16):"MP:";AMP;"/";AMMP; 8193 DISPLAY AT(8,1):"1) POTION";HPO;:"2) ETHER";MPO;:"3) ELIXIR";ELI;:: FOR I=1 TO 400 :: NEXT I 8194 RETURN 8195 IF HPO<1 THEN CALL SOUND(30,440,1):: HPO=0 :: GOTO 8181 8197 HPO=HPO-1 :: AHP=AHP+10 :: IF AHP>AMHP THEN AHP=AMHP 8199 RETURN 8201 IF MPO<1 THEN CALL SOUND(30,440,1):: MPO=0 :: GOTO 8181 8203 MPO=MPO-1 :: AMP=AMP+10 :: IF AMP>AMMP THEN AMP=AMMP 8205 RETURN 8207 IF ELI<1 THEN CALL SOUND(30,440,1):: ELI=0 :: GOTO 8181 8209 ELI=ELI-1 :: AHP=AHP+5 :: IF AHP>AMHP THEN AHP=AMHP 8211 AMP=AMP+5 :: IF AMP>AMMP THEN AMP=AMMP 8213 RETURN 8400 REM ARMOR MENU 8500 GOSUB 10100:: DISPLAY AT(1,12):"ARMOR";:: DISPLAY AT(2,12):"^^^^^" :: GOSUB 10400 8600 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8600 8700 IF K=13 THEN GOTO 7500 ELSE 8600 8800 GOSUB 10100 8899 REM WEAPONS MENU 8900 GOSUB 10100 :: DISPLAY AT(1,11):"WEAPONS";:: DISPLAY AT(2,11):"^^^^^^^" :: GOSUB 10400 9000 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9000 9100 IF K=13 THEN GOTO 7500 ELSE 9000 9200 GOSUB 10100 8299 REM SPELLS MENU 9300 GOSUB 10100 :: DISPLAY AT(1,12):"SPELLS";:: DISPLAY AT(2,12):"^^^^^^" :: GOSUB 10400 9400 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9400 9500 IF K=13 THEN GOTO 7500 ELSE 9400 9600 GOSUB 10100 ************************** **** NEXT AREA OF WORK**** ************************** 9696 REM STATUS MENU 9697 REM THIS IS THE NEXT AREA OF FOCUS... GET WORKING STATUS MENU GOING BY LOADING THE "A" SET WITH CHAR'S INFO 9698 REM **USE THESE: ALEV=BLEV :: AMHP=BMHP :: AHP=BHP :: AMMP=BMMP :: AMP=BMP :: ADEF=BDEF :: AATK=BATK :: AMDEF=BMDEF 9699 REM **AMATK=BMATK :: ACN$="BERYL" :: ANSP=14 :: ANL=5 9700 GOSUB 10100 :: DISPLAY AT(1,12):"STATUS";:: DISPLAY AT(2,12):"^^^^^^" :: GOSUB 10400 9800 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9800 9900 IF K=13 THEN GOTO 7500 ELSE 9800 10000 CALL CLEAR :: GOTO 2100 10100 REM CLEAR MENU INFO 10200 DISPLAY AT(8,1):" ":" ":" ":" ":" ":" " :: DISPLAY AT(1,1):" ":" ":" " :: DISPLAY AT(22,1):" ":" " 10300 RETURN 10400 REM MENU RETURN GAME STRING 10500 DISPLAY AT(22,5):EX$;:: DISPLAY AT(23,5):EXU$; 10600 RETURN 10700 REM SCREEN INFO DISPLAY 10800 DISPLAY AT(1,9):"FORESTIA" 10900 DISPLAY AT(2,1):"BERYL":"HP:";BHP:"MP:";BMP :: DISPLAY AT(2,9):"^^^^^^^^"; 11000 DISPLAY AT(2,18):"REPTOSLICER" :: DISPLAY AT(3,18):"HP:";RHP :: DISPLAY AT(4,18):"MP:";RMP 11100 DISPLAY AT(6,1):"SKYLAR":"HP:";SHP:"MP:";SMP 11200 DISPLAY AT(6,18):"MARKUS" :: DISPLAY AT(7,18):"HP:";MHP :: DISPLAY AT(8,18):"MP:";MMP 11300 RETURN 11400 REM **END MAIN GAME LOOP** 11500 REM **SUB TO CALL THE ASSEMBLY ROUTINE TO LOAD MAP INTO MEMORY** 11600 SUB LDAT 11700 CALL INIT 11800 CALL LOAD("DSK1.NEWFORO") 11900 SUBEND 12000 REM **SUB TO DRAW THE MAP ONSCREEN** 12100 SUB SETMAP(MX,MY) 12200 X=MX :: Y=MY 12300 IF ADR<>0 THEN 12600 12400 CALL PEEK(16382,P,Q) 12500 ADR=P*256+Q+2 12600 Y=Y-1 :: MAP=Y*2+X 12700 IF MAP<1 OR MAP>12 THEN SUBEXIT 12800 CALL LOAD(ADR,0,MAP) 12900 CALL LINK("DRAW") 13000 SUBEND Edited March 19, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 19, 2015 Share Posted March 19, 2015 (edited) Interestingly, I DO have rudimentary indentation in that code, but it isn't translating into the code box.... Wonder why? Edited March 19, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
matthew180 Posted March 19, 2015 Author Share Posted March 19, 2015 The first thing that jumps out at me is that you are using spaces in some of your labels. Since humans use space to denote separation between words, that characteristic almost always transfers to programming languages. Labels can have A..Z, a..z, 0..9, -, _ and must start with a non-numeric character. They are also case sensitive (I think). The other thing you can do to help you find translation problems is to add your code in chunks. Get the fist 50 lines or so working, then add another 50, etc. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 19, 2015 Share Posted March 19, 2015 Cool... Ill definitely give it a whirl tonight... And i will try to figure out why my code indentations didnt translate to the code box on here. I just used simple TABs in Notepad++ using .asm format, then switched it to .c and neither worked. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 19, 2015 Share Posted March 19, 2015 (edited) Switched the MidgameLoop Keyscan and InitLoad MapData to eliminate the " " character. These were the only offending labels. I'll be working more on this tonight... Hopefully get it done and tested by Saturday night. Sure will make life easier. Edited March 19, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
matthew180 Posted March 19, 2015 Author Share Posted March 19, 2015 Web browsers and textboxes don't like tabs. Set your editor to use spaces for tabs and your copy-and-paste should work out better. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 19, 2015 Share Posted March 19, 2015 (edited) Hmm... Ill try that, for sure... I had my old Notepad++ dialed in just the way I wanted it with indentation, spacing, and syntax highlighting. (Indentation was primarily on the REM comments that didnt have a line number associated with them) Edited March 19, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 20, 2015 Share Posted March 20, 2015 (edited) Tried different indentation method, also changed incorrect labels, finished converting the "Examine" function. Let me know how this looks (so far) Beryl Reichardt TIdBiT transfer workstation: 3/18/15 // first thing to do is call the link up to load the map data into memory InitLoad-MapData: CALL LDAT PlayerStartup: // Give player a "place to start" // MX and MY are which map in the world are going to be drawn. In this case, it's 1,1 // PX&PY are the players' X location and Y location on the screen // SPX and SPY are the location of the SPRITE corresponding to the character position MX=1 :: MY=1 PX=18 :: PY=8 SPX=(PX-1)*8+1 :: SPY=(PY-1)*8+17 // These are party inventory... Starting with 100 gold, 4 health potions, 4 magic potions, 4 Elixirs, and zero scrolls GLD=100 :: HPO=4 :: MPO=4 :: ELI=4 :: SCR=0 // These are repeated strings. Currently there are only two, but there will be many more to come EX$="PRESS ENTER TO EXIT" BS$="BROADSWORD" EXU$="^^^^^^^^^^^^^^^^^^^" // These are Individual statistics for Beryl, Skylar, and Markus. // MHP is max health power, HP is current health power // MMP is max magic power, MP is current magic power // DEF and ATK are the current stats for defense and attack // MDEF and MATK are max stats for defense and attack BMHP=20 :: BHP=15 :: BMMP=20 :: BMP=5 :: BDEF=10 :: BATK=10 :: BMDEF=7 :: BMATK=4 RMHP=16 :: RHP=5 :: RMMP=40 :: RMP=20 :: RDEF=3 :: RATK=4 :: RMDEF=10 :: RMATK=12 MMHP=25 :: MHP=18 :: MMMP=0 :: MMP=0 :: MDEF=15 :: MATK=15 :: MMDEF=5 :: MMATK=0 SMHP=12 :: SHP=5 :: SMMP=20 :: SMP=12 :: SDEF=5 :: SATK=4 :: SMDEF=9 :: SMATK=8 //These are the player "levels". When the player level goes up, so will most of the maximum stats above. BLEV=1 :: RLEV=1 :: MLEV=1 :: SLEV=1 Setscreen: // set up screen and border for exploration routines CALL CLEAR CALL SCREEN(2) !black screen CALL HCHAR(9,1,101,32):: CALL HCHAR(24,1,101,32):: CALL VCHAR(9,1,97,16):: CALL VCHAR(9,32,97,16) !border around viewport CALL HCHAR(9,1,98):: CALL HCHAR(9,32,100):: CALL HCHAR(24,1,99):: CALL HCHAR(24,32,96) !corners CALL CHAR(42,"193DD9FFD91924C3"):: CALL COLOR(2,16,2) !CHAR(42) is the little character representation so far... may change soon GOSUB TopInfo ****BEGIN GAME LOOP**** TopGameLoop: // This is the very top of the game loop. CALL SETMAP(MX,MY) CALL SPRITE(#1,42,16,SPX,SPY) MidGameLoop: // midpoint for returns from bottom of loop // displays the character on screen based on player position SPX=(PX-1)*8+1 :: SPY=(PY-1)*8+17 CALL LOCATE(#1,SPX,SPY) MidgameLoop-Keyscan: GOSUB KeyScan //upon keypress, up down, left, right checking for tiles in the direction selected //must be a tile below (lower than)CHR$(104) to allow motion //must add 2 to each column to compensate for the DISPLAY/GCHAR offset IF K=69 THEN CALL GCHAR(PX-1,PY+2,Q):: IF Q>104 THEN GOTO MidgameLoop-Keyscan ELSE PX=PX-1 :: GOTO CheckBoundary IF K=83 THEN CALL GCHAR(PX,PY+1,Q):: IF Q>104 THEN GOTO MidgameLoop-Keyscan ELSE PY=PY-1 :: GOTO CheckBoundary IF K=68 THEN CALL GCHAR(PX,PY+3,Q):: IF Q>104 THEN GOTO MidgameLoop-Keyscan ELSE PY=PY+1 :: GOTO CheckBoundary IF K=88 THEN CALL GCHAR(PX+1,PY+2,Q):: IF Q>104 THEN GOTO MidgameLoop-Keyscan ELSE PX=PX+1 :: GOTO CheckBoundary //If M is pressed, goto menu block, if space bar, goto examine block IF K=32 THEN GOSUB Examine IF K=77 THEN GOTO MainMenu GOTO MidgameLoop-Keyscan CheckBoundary: // this determines the boundaries onscreen and sets the map to be drawn by assembly routine // PX, PY are the current player's position on the screen // MX, MY are the designations for which map will be drawn IF PX<11 THEN PX=22 :: MY=MY-1 :: GOTO CheckMap !if player walks off top of screen, place character on opposite side of screen IF PX>22 THEN PX=11 :: MY=MY+1 :: GOTO CheckMap !if player walks off bottom of screen, place character on opposite side of screen IF PY<1 THEN PY=28 :: MX=MX-1 :: GOTO CheckMap !if player walks off left of screen, place character on opposite side of screen IF PY>28 THEN PY=1 :: MX=MX+1 :: GOTO CheckMap !if player walks off right of screen, place character on opposite side of screen GOTO MidGameLoop CheckMap: IF MX<1 THEN MX=1 ELSE IF MX>2 THEN MX=2 IF MY<1 THEN MY=1 ELSE IF MY>6 THEN MY=6 CALL DELSPRITE(#1) GOTO TopGameLoop //END GAME LOOP!!!!!!!!!!!!// ***SUBROUTINES BELOW*** //BEGIN EXAMINE LOOP// Examine: DISPLAY AT(1,1):" ":" ":" ":" ":" ":" ":" ":" " DISPLAY AT(1,1):"WHICH DIRECTION?"; ExamineKeyscan: GOSUB Keyscan IF K=69 THEN CALL GCHAR(PX-1,PY+2,Q):: GOSUB ExamineCheck :: RETURN IF K=83 THEN CALL GCHAR(PX,PY+1,Q):: GOSUB ExamineCheck :: RETURN IF K=68 THEN CALL GCHAR(PX,PY+3,Q):: GOSUB ExamineCheck :: RETURN IF K=88 THEN CALL GCHAR(PX+1,PY+2,Q):: GOSUB ExamineCheck :: RETURN GOTO ExamineKeyscan ExamineCheck: //This is the "YES" or "correct tile, IS an item" bit IF Q=115 THEN IT$=BS$ :: GOTO ItemYesFlag //This is the "NO" or "incorrect tile, is not an item" bit DISPLAY AT(1,1):" " :: GOSUB TopInfo :: RETURN ItemYesFlag: DISPLAY AT(1,1):"YOU FOUND A ";IT$;:"ADD TO INVENTORY? (Y/N)"; MidExamineLoop-Keyscan: GOSUB Keyscan IF K=89 THEN DISPLAY AT(1,1):" ":" " :: GOSUB TopInfo :: RETURN IF K=78 THEN DISPLAY AT(1,1):" ":" " :: GOSUB TopInfo :: RETURN GOTO MidExamineLoop-Keyscan //END EXAMINE LOOP// TopInfo: //this displays all necessary information at the top of the screen during gameplay DISPLAY AT(1,9):"FORESTIA" DISPLAY AT(2,1):"BERYL":"HP:";BHP:"MP:";BMP :: DISPLAY AT(2,9):"^^^^^^^^"; DISPLAY AT(2,18):"REPTOSLICER" :: DISPLAY AT(3,18):"HP:";RHP :: DISPLAY AT(4,18):"MP:";RMP DISPLAY AT(6,1):"SKYLAR":"HP:";SHP:"MP:";SMP DISPLAY AT(6,18):"MARKUS" :: DISPLAY AT(7,18):"HP:";MHP :: DISPLAY AT(8,18):"MP:";MMP RETURN Keyscan: CALL KEY(0,K,S):: IF S=0 THEN Keyscan RETURN ******************************************** ******************************************** **This is the remainder of the code I have** **not converted yet. Most of these lines ** **or sections of lines are referenced in ** **the lines above, which are already ** **converted. ** ******************************************** ******************************************** 7100 REM MENU 7200 CALL CLEAR :: CALL SCREEN(2):: CALL DELSPRITE(#1) 7300 CALL HCHAR(5,1,101,32):: CALL HCHAR(20,1,101,32):: CALL VCHAR(5,1,97,15):: CALL VCHAR(5,32,97,15) 7400 CALL HCHAR(5,1,98):: CALL HCHAR(5,32,100):: CALL HCHAR(20,1,99):: CALL HCHAR(20,32,96) 7500 GOSUB 10100:: GOSUB 10400 7600 DISPLAY AT(8,1):"1) ITEMS":"2) ARMOR":"3) WEAPONS":"4) SPELLS":"5) STATUS"; 7700 CALL KEY(0,K,S):: IF S=0 THEN GOTO 7700 7750 IF K=13 THEN CALL CLEAR :: GOTO 2100 7800 IF K>54 THEN GOTO 7700 ELSE IF K<49 THEN GOTO 7700 7900 ON K-48 GOTO 8000,8400,8900,9300,9700 8000 REM ITEM MENU 8010 GOSUB 10100 8100 DISPLAY AT(1,12):"ITEMS";:: DISPLAY AT(2,12):"^^^^^" :: GOSUB 10400 8110 DISPLAY AT(8,1):"USE ON WHICH CHARACTER?";:"1) BERYL";:"2) REPTOSLICER";:"3) MARKUS";:"4) SKYLAR"; 8111 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8111 8112 IF K=13 THEN GOTO 7500 8113 IF K>52 THEN GOTO 8111 ELSE IF K<49 THEN GOTO 8111 8114 ON K-48 GOSUB 8125,8135,8145,8155 8115 GOTO 8000 8120 REM ACN=name, ANSP=name starting point, ANL=name length 8125 REM BERYL 8126 AMHP=BMHP :: AHP=BHP :: AMMP=BMMP :: AMP=BMP :: ACN$="BERYL" :: ANSP=12 :: ANL=5 8128 GOSUB 8177 8131 BHP=AHP :: BMP=AMP :: RETURN 8135 REM REPTO 8136 AMHP=RMHP :: AHP=RHP :: AMMP=RMMP :: AMP=RMP :: ACN$="REPTOSLICER" :: ANSP=9 :: ANL=11 8138 GOSUB 8177 8141 RHP=AHP :: RMP=AMP :: RETURN 8145 REM MARKUS 8146 AMHP=MMHP :: AHP=MHP :: AMMP=MMMP :: AMP=MMP :: ACN$="MARKUS" :: ANSP=12 :: ANL=6 8148 GOSUB 8177 8151 MHP=AHP :: MMP=AMP :: RETURN 8155 REM SKYLAR 8156 AMHP=SMHP :: AHP=SHP :: AMMP=SMMP :: AMP=SMP :: ACN$="SKYLAR" :: ANSP=12 :: ANL=6 8158 GOSUB 8177 8161 SHP=AHP:: SMP=AMP :: RETURN 8176 REM **THIS IS THE MEAT OF THE ITEM MENU CODE** 8177 GOSUB 10100 :: DISPLAY AT(1,ANSP):ACN$;:: CALL HCHAR(2,ANSP+2,94,ANL) 8179 GOSUB 10400 8181 DISPLAY AT(8,1):"1) POTION";HPO;:"2) ETHER";MPO;:"3) ELIXIR";ELI; 8183 DISPLAY AT(3,1):"HP:";AHP;"/";AMHP;:: DISPLAY AT(3,16):"MP:";AMP;"/";AMMP; 8184 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8184 8185 IF K=13 THEN GOTO 8000 8187 IF K>51 THEN GOTO 8183 ELSE IF K<49 THEN GOTO 8183 8189 ON K-48 GOSUB 8195,8201,8207 8191 CALL SCREEN(16):: FOR I=1 TO 20 :: NEXT I :: CALL SCREEN(2) 8192 DISPLAY AT(3,1):"HP:";AHP;"/";AMHP;:: DISPLAY AT(3,16):"MP:";AMP;"/";AMMP; 8193 DISPLAY AT(8,1):"1) POTION";HPO;:"2) ETHER";MPO;:"3) ELIXIR";ELI;:: FOR I=1 TO 400 :: NEXT I 8194 RETURN 8195 IF HPO<1 THEN CALL SOUND(30,440,1):: HPO=0 :: GOTO 8181 8197 HPO=HPO-1 :: AHP=AHP+10 :: IF AHP>AMHP THEN AHP=AMHP 8199 RETURN 8201 IF MPO<1 THEN CALL SOUND(30,440,1):: MPO=0 :: GOTO 8181 8203 MPO=MPO-1 :: AMP=AMP+10 :: IF AMP>AMMP THEN AMP=AMMP 8205 RETURN 8207 IF ELI<1 THEN CALL SOUND(30,440,1):: ELI=0 :: GOTO 8181 8209 ELI=ELI-1 :: AHP=AHP+5 :: IF AHP>AMHP THEN AHP=AMHP 8211 AMP=AMP+5 :: IF AMP>AMMP THEN AMP=AMMP 8213 RETURN 8400 REM ARMOR MENU 8500 GOSUB 10100:: DISPLAY AT(1,12):"ARMOR";:: DISPLAY AT(2,12):"^^^^^" :: GOSUB 10400 8600 CALL KEY(0,K,S):: IF S=0 THEN GOTO 8600 8700 IF K=13 THEN GOTO 7500 ELSE 8600 8800 GOSUB 10100 8899 REM WEAPONS MENU 8900 GOSUB 10100 :: DISPLAY AT(1,11):"WEAPONS";:: DISPLAY AT(2,11):"^^^^^^^" :: GOSUB 10400 9000 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9000 9100 IF K=13 THEN GOTO 7500 ELSE 9000 9200 GOSUB 10100 8299 REM SPELLS MENU 9300 GOSUB 10100 :: DISPLAY AT(1,12):"SPELLS";:: DISPLAY AT(2,12):"^^^^^^" :: GOSUB 10400 9400 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9400 9500 IF K=13 THEN GOTO 7500 ELSE 9400 9600 GOSUB 10100 ************************** **** NEXT AREA OF WORK**** ************************** 9696 REM STATUS MENU 9697 REM THIS IS THE NEXT AREA OF FOCUS... GET WORKING STATUS MENU GOING BY LOADING THE "A" SET WITH CHAR'S INFO 9698 REM **USE THESE: ALEV=BLEV :: AMHP=BMHP :: AHP=BHP :: AMMP=BMMP :: AMP=BMP :: ADEF=BDEF :: AATK=BATK :: AMDEF=BMDEF 9699 REM **AMATK=BMATK :: ACN$="BERYL" :: ANSP=14 :: ANL=5 9700 GOSUB 10100 :: DISPLAY AT(1,12):"STATUS";:: DISPLAY AT(2,12):"^^^^^^" :: GOSUB 10400 9800 CALL KEY(0,K,S):: IF S=0 THEN GOTO 9800 9900 IF K=13 THEN GOTO 7500 ELSE 9800 10000 CALL CLEAR :: GOTO 2100 10100 REM CLEAR MENU INFO 10200 DISPLAY AT(8,1):" ":" ":" ":" ":" ":" " :: DISPLAY AT(1,1):" ":" ":" " :: DISPLAY AT(22,1):" ":" " 10300 RETURN 10400 REM MENU RETURN GAME STRING 10500 DISPLAY AT(22,5):EX$;:: DISPLAY AT(23,5):EXU$; 10600 RETURN 10700 REM SCREEN INFO DISPLAY 10800 DISPLAY AT(1,9):"FORESTIA" 10900 DISPLAY AT(2,1):"BERYL":"HP:";BHP:"MP:";BMP :: DISPLAY AT(2,9):"^^^^^^^^"; 11000 DISPLAY AT(2,18):"REPTOSLICER" :: DISPLAY AT(3,18):"HP:";RHP :: DISPLAY AT(4,18):"MP:";RMP 11100 DISPLAY AT(6,1):"SKYLAR":"HP:";SHP:"MP:";SMP 11200 DISPLAY AT(6,18):"MARKUS" :: DISPLAY AT(7,18):"HP:";MHP :: DISPLAY AT(8,18):"MP:";MMP 11300 RETURN 11400 REM **END MAIN GAME LOOP** 11500 REM **SUB TO CALL THE ASSEMBLY ROUTINE TO LOAD MAP INTO MEMORY** 11600 SUB LDAT 11700 CALL INIT 11800 CALL LOAD("DSK1.NEWFORO") 11900 SUBEND 12000 REM **SUB TO DRAW THE MAP ONSCREEN** 12100 SUB SETMAP(MX,MY) 12200 X=MX :: Y=MY 12300 IF ADR<>0 THEN 12600 12400 CALL PEEK(16382,P,Q) 12500 ADR=P*256+Q+2 12600 Y=Y-1 :: MAP=Y*2+X 12700 IF MAP<1 OR MAP>12 THEN SUBEXIT 12800 CALL LOAD(ADR,0,MAP) 12900 CALL LINK("DRAW") 13000 SUBEND Edited March 20, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 20, 2015 Share Posted March 20, 2015 This looks much better Owen In the end it all comes down to personal preference. For me, I prefer not to overload the code lines, and therefore put every statement on its own line which I find clearer to read, at the expense of longer listings. Regardless, I'm really glad to see you coding again. Your enthusiasm is contagious! Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 20, 2015 Share Posted March 20, 2015 "Mongo only pawn--in game of life" I am in the company of giants... I wish only to contribute in whatever small way I can. Beryl will take a while... My project game plan is underway, code is getting reorganized,then I get to start work on my maps in Magellan. TIdBiT is going to allow for much more flexibility. Then I can expand it freely without line number restrictions. Total freedom. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 20, 2015 Share Posted March 20, 2015 Well, tonight I should be able to finish the conversion and do some testing and debugging. Assuming, of course, I do not get off work too late. When I get it working, I'll post up the source and TIdBiT output code. Hopefully this little tangent in this thread will help future users convert their code to TIdBiT as well. Quote Link to comment Share on other sites More sharing options...
matthew180 Posted March 21, 2015 Author Share Posted March 21, 2015 It is looking pretty good. Something you might want to consider is the line continuation feature (double period): This code: IF PX<11 THEN PX=22 :: MY=MY-1 :: GOTO CheckMap !if player walks off top of screen, place character on opposite side of screen IF PX>22 THEN PX=11 :: MY=MY+1 :: GOTO CheckMap !if player walks off bottom of screen, place character on opposite side of screen IF PY<1 THEN PY=28 :: MX=MX-1 :: GOTO CheckMap !if player walks off left of screen, place character on opposite side of screen IF PY>28 THEN PY=1 :: MX=MX+1 :: GOTO CheckMap !if player walks off right of screen, place character on opposite side of screen Can be written like this: // if player walks off top of screen, place character on opposite side of screen IF PX<11 THEN .. PX=22 :: .. MY=MY-1 :: .. GOTO CheckMap ENDIF // if player walks off bottom of screen, place character on opposite side of screen IF PX>22 THEN .. PX=11 :: .. MY=MY+1 :: .. GOTO CheckMap ENDIF // if player walks off left of screen, place character on opposite side of screen IF PY<1 THEN .. PY=28 :: .. MX=MX-1 :: .. GOTO CheckMap ENDIF // if player walks off right of screen, place character on opposite side of screen IF PY>28 THEN .. PY=1 :: .. MX=MX+1 :: .. GOTO CheckMap ENDIF The ENDIF if totally optional and is a TidBit specific keyword that is just ignored, however it helps keep track of the end of a logical block (kind of like the "NEXT" in a for/next loop, etc). Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 21, 2015 Share Posted March 21, 2015 (edited) Hmm.... Thats pretty cool. Might do that when I start adding more code. It is much more legible. Thank you for the heads up. Edited March 21, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
+Retrospect Posted March 21, 2015 Share Posted March 21, 2015 I think I might benefit from this tidbit. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted March 21, 2015 Share Posted March 21, 2015 Give it a whirl. It's no joke... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.