drfloyd Posted May 23 Share Posted May 23 (edited)  Here is again the French casual coder, but passionate 😊 Who want to participate to NANO COSMOS development ? (CV Basic)  For now, I am in stress with the lake of string$ in CVBasic I would like to generate random name of planets & people  In another basic I would have done that :  Dim t$(10) Restore database For i=1 to 20 Read t$(i) Next i ' Planetname$=t$(random(10))+t$(random(10)) Print planetname$ ' Database: DATA TRAN,TOR,JU,PI,TER,NO,VA,SI,RIUS,SA DATA NEW,GA,MARS,TI,TAN,NEP,TUNE,PLU,TON,LA  No string in CV... How can i do with CV ? (With putting data in ROM)  I have a suggession from Nanochess in private : "You need to use DATA BYTE with strings. And keep a small 8-bit array to copy strings. And copy to screen from that 8-bit array."  Ok, but I do not unterstand. Who can give me an example ? You will be in the greetings of my game  Thanks Edited June 16 by drfloyd Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/ Share on other sites More sharing options...
carlsson Posted May 23 Share Posted May 23 (edited) I don't know how CV BASIC does it, but IntyBASIC has the same shortcomings when it comes to strings. That is kind of funny as people tend to suggest creating text adventures, without them knowing how difficult it is to handle string data. Â In one of the Intellivision games I'm developing, I have made a structure like this: Â mystring01: DATA number, "TEXT", 255 mystring02: DATA number,"MORE TEXT",255 Â Then I have another structure: Â mystrings: DATA VARPTR mystring01(0) DATA VARPTR mystring02(0) Â In the code, I'm using #addr = mystrings(i) + 1 (to skip the first numeric value) and a WHILE loop to plot the string: Â #where = SCREENADDR(x,y) : REM macro on the Intellivision WHILE (PEEK(#addr)<>255) #data = PEEK(#addr)*8 + BGCOL + FGCOL REM The later two are STIC specific, so you don't need them on the ColecoVision POKE #where,#data #addr = #addr + 1 #where = #where + 1 WEND Â I can't PRINT such strings, I have to plot them directly to screen memory. As you see, I'm using an odd data value (255) to indicate end of string. At first I wanted to use 0, but that is SPACE on the Intellivision, meaning my strings could not have spaces. Â I don't even want to start thinking about keeping strings in RAM, comparing them, concatenating them, dynamically change them and so on. I'm not sure if there is a C compiler better suited for that as well, or if you should not do string heavy programs on a video games console. Edited May 23 by carlsson 1 Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5472448 Share on other sites More sharing options...
+evg2000 Posted May 23 Share Posted May 23 something like this works:  t = 0 REM get length of word to print length = #LOCATIONS(1) REM get start of word to print start = #LOCATIONS(0) REM end of loop is one less than length of the word. FOR #c = $1800 TO $1800 + length - 1   REM get ascii value for letter   t = #WORDS(start)   REM print the int value read   print at 320 + start * 32, t   REM poke the ascii vaule on the screen   VPOKE #c, t      REM increment the point in the word table   start = start + 1 NEXT #c REM Same but for next word  length = #LOCATIONS(3)  start = #LOCATIONS(2) FOR #c = $1820 TO $1820 + length - 1   t = #WORDS(start)   print at 320 + start * 32, t   VPOKE #c, t      start = start + 1 NEXT #c REM loop forever while 1 = 1 wend REM word list in ascii values #WORDS:   DATA  72,69,76,76,79   DATA  76,69,79 REM location data odd value is where word starts, even value is the length #LOCATIONS:   DATA 0,5,5,3   Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5472490 Share on other sites More sharing options...
+nanochess Posted May 24 Share Posted May 24 I made a brief example. Â ' ' Example of string building ' ' by Oscar Toledo G. ' ' Creation date: May/23/2024. ' FOR #c = 4 TO 740 STEP 32 d = RANDOM(10) e = RANDOM(10) #d = #c c = d GOSUB point_to_word GOSUB show_word c = e GOSUB point_to_word GOSUB show_word NEXT #c WHILE 1: WEND point_to_word: PROCEDURE RESTORE planet_names WHILE c DO READ BYTE f LOOP WHILE f <> 0 c = c - 1 WEND END show_word: PROCEDURE DO READ BYTE f IF f THEN VPOKE $1800 + #d, f: #d = #d + 1 LOOP WHILE f <> 0 END planet_names: DATA BYTE "TRAN",0 DATA BYTE "TOR",0 DATA BYTE "JU",0 DATA BYTE "PI",0 DATA BYTE "TER",0 DATA BYTE "NO",0 DATA BYTE "VA",0 DATA BYTE "SI",0 DATA BYTE "RIUS",0 DATA BYTE "SA",0 DATA BYTE "NEW",0 DATA BYTE "GA",0 DATA BYTE "MARS",0 DATA BYTE "TI",0 DATA BYTE "TAN",0 DATA BYTE "NEP",0 DATA BYTE "TUNE",0 DATA BYTE "PLU",0 DATA BYTE "TON",0 DATA BYTE "LA",0 Â Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5472636 Share on other sites More sharing options...
drfloyd Posted May 24 Author Share Posted May 24 ok, thanks evg and Nano, everybody is helpfull  Will try a apply Nano solution in my program. I am i little disillusioned about the future of my game, as I need strings for planets, people, objects, etc.... Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5472804 Share on other sites More sharing options...
drfloyd Posted May 24 Author Share Posted May 24 (edited) Hi Nano, With your example, i have tried to simplify as possible for reading name of people in a table :  restore heroes ' **** my choice hero=5 ' ******go to mu choice for i=1 to hero do read byte f loop while f<>0 next i m=0 ' ******* display do read byte f vpoke $1800+m,f m=m+1 loop while f<>0 while 1 wend ' ******** table heroes: DATA BYTE 0 DATA BYTE "PETER",0 DATA BYTE "SAM",0 DATA BYTE "TEDDY",0 DATA BYTE "ROGER",0 DATA BYTE "NANOCHESS",0  it works. If a choose 1, it display PETER, 5, it display NANOCHESS  (Don't know if it if possible to simplify this code, perhaps) The only problem is with the display: at $1800 it's ok, it display at 0,0 but if i choose $1832 for exemple, to display a column 0, line 1 (in my logic)..... No, it display at another strange position :  Do not understand the display position  Edited May 24 by drfloyd Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5472939 Share on other sites More sharing options...
+evg2000 Posted May 24 Share Posted May 24 i think the problem is that 1800 is hex, so adding 32 moves you 50 from 0,0. you want 1820 Â $ means hex not decimal Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5472967 Share on other sites More sharing options...
drfloyd Posted May 24 Author Share Posted May 24 My god, i restart the code and now it's working correctly, i have change nothing...  Cannot unterstand...  So, apparently, my code if working, even for the display...  Sorry 😕 Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5473086 Share on other sites More sharing options...
artrag Posted May 24 Share Posted May 24 The error is the address In hexadecimal the second line is at $1820, the third at $1840 and so on Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5473150 Share on other sites More sharing options...
drfloyd Posted May 24 Author Share Posted May 24 cannot understand, now the code works with keeping $1800... Â Mystery Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5473159 Share on other sites More sharing options...
drfloyd Posted May 27 Author Share Posted May 27 Another question :  There is no transparency for PRINT ????  a choose 0 (transparent) for the second color, for exemple :  letter:    DATA BYTE $f0,$f0,$f0,$70,$70,$50,$50,$40  but it hide the tiles which are below the text   Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5475118 Share on other sites More sharing options...
youki Posted May 28 Share Posted May 28 Each character is a tile , when you print something at one place, you replace the previous tile.  The "transparency" just means that it is affected by the background or border color.  If you change the border color the part of your text where the color is "0" will become the color you choosed for the border/background.  If you chosed color 1 for instance (which is black) , if you change to background color it will stay black.  In fact the transparency was here because it was planed a kind of video incrustation capabilities for the VDP , if you choosed a color 0 and if you send a video source from a VHS for instance , you would have seen the VHS video every where the color is "0".    1 Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5475305 Share on other sites More sharing options...
drfloyd Posted May 28 Author Share Posted May 28 Thanks Youki ! Other question : Â Why i have only a total of 781 bytes ? Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5475643 Share on other sites More sharing options...
+nanochess Posted May 28 Share Posted May 28 24 minutes ago, drfloyd said: Other question : Â Why i have only a total of 781 bytes ? There are several things that the Z80 should care about while your game runs. Â Subtract the following work data from the original 1024 bytes of RAM: 64 bytes for stack (GOSUB/RETURN/video interrupt) 33 bytes for music player. 146 bytes for support variables (128 are the sprite table). Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5475658 Share on other sites More sharing options...
drfloyd Posted May 29 Author Share Posted May 29 ok, thanks  it's a un new difficulty for my game, but I beleive in my project, even with 781 octets ! Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5475925 Share on other sites More sharing options...
youki Posted May 29 Share Posted May 29 15 minutes ago, drfloyd said: ok, thanks  it's a un new difficulty for my game, but I beleive in my project, even with 781 octets !  781 bytes it is huge , it is more than 6 times what you would have if you are doing your game on a Atari VCS. 😃   And if you really don't have enough RAM , you can have still the possibility to use the free VDP RAM to store your variables. (using VPOKE and VPEEK i think in CVBasic) 1 Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5475941 Share on other sites More sharing options...
drfloyd Posted May 29 Author Share Posted May 29 I heard about free VRAM.... Is is really free RAM ? If a remember if about 3 or 4Kb ??? Is it slow ? (no very important for me, as it is not an action game) Â Perhaps could be interesting.... if someone give an example Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5476178 Share on other sites More sharing options...
+nanochess Posted May 29 Share Posted May 29 1 hour ago, drfloyd said: I heard about free VRAM.... Is is really free RAM ? If a remember if about 3 or 4Kb ??? Is it slow ? (no very important for me, as it is not an action game)  Perhaps could be interesting.... if someone give an example  In the normal mode you have 1K of VRAM free between $1c00 and $1fff. You can access it using VPOKE and VPEEK. Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5476213 Share on other sites More sharing options...
drfloyd Posted May 29 Author Share Posted May 29 ok, if it become impossible to finish the game with my 781bytes, I will consider that 1 Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5476251 Share on other sites More sharing options...
drfloyd Posted June 16 Author Share Posted June 16 (edited) Another (stupid) question ? Â How can a make variables as constants ? (in oder to not use RAM) Exemple : Â dim dmo(10) restore liste for i=1 to 10 Â read dmo(i) next i liste: data 5,7,8,5,4,7,8,9,8,7 Â I want dmo(10) do not use RAM, as values are fixed. Â Edited June 16 by drfloyd Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5486987 Share on other sites More sharing options...
artrag Posted June 16 Share Posted June 16 Use DATA with a label and recall the in these way liste(n) as it was an array  All you need is:  liste: data 5,7,8,5,4,7,8,9,8,7   Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5487065 Share on other sites More sharing options...
drfloyd Posted June 16 Author Share Posted June 16 cannot understand, could you please give me an exemple ? Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5487105 Share on other sites More sharing options...
+nanochess Posted June 16 Share Posted June 16 1 hour ago, drfloyd said: cannot understand, could you please give me an exemple ? FOR a = 1 TO 5 PRINT 32 + a * 32, <>liste(a) NEXT a WHILE 1: WEND ' Must be DATA BYTE because the label name doesn't start with # liste: DATA BYTE 1,2,3,4,5 Â Any label is ready to be read as an array. Â 1 Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5487153 Share on other sites More sharing options...
artrag Posted June 16 Share Posted June 16 for i=0 to 8 k = 2*liste(i) next i end: goto end liste: data byte 5,7,8,5,4,7,8,9,8,7 Â Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5487161 Share on other sites More sharing options...
artrag Posted June 16 Share Posted June 16 Oscar was faster 😄 1 Quote Link to comment https://forums.atariage.com/topic/367024-cv-basic-cvbasic-help-for-a-noob/#findComment-5487162 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.