LostCause Posted January 30 Share Posted January 30 I am in the hope of finding someone who still has some, QBasic Skills. I have a game in mind that may push QBasic over it's limits. If interested, I would like you to look over the delay subroutine, I derived from Google searches that the results didn't quite, fit the bill. The overflow errors had me going thru loops. My solutions seem to make no difference logically, yet work! Let me know and I will post the code and explain the logical anomalies, I ran into. Thank you for reading. Quote Link to comment Share on other sites More sharing options...
LostCause Posted January 30 Author Share Posted January 30 I currently have a working prototype for the game. At this point my thoughts on were to go with this far exceed what has been done. I have done preliminary testing on a way to use dynamic arrays in user defined types. Something Google said can't be done. The tests have produced positive results. Now, I am attempting work on the nuts and bolts of the engine before concerning myself with graphics, sound and music. Back in the Ms-DOS days I only dabbled in QBasic, this is new territories for me. With that said, I will go ahead and initiate this thing. Maybe there is a better approach then what I'm using or some logical error I am not aware of that you could help me out with. On with the show. To error is human, I am by no means an exception to that rule. Starting off making dumb rookie errors and typos. I will begin with the first issue I do not get. This gave an overflow error: micro = millisec * 1000 However this does not: micro = millisec micro = micro * 1000 millisec is defined as an integer and micro as a long integer. The next issue that makes no sense is this piece of code here: tmpvar = (micro AND 65535) IF tmpvar < 32768 THEN word = tmpvar ELSE word = tmpvar - 65536 END IF regs.dx = word tmpvar is a long integer and word is an integer. Since the high word would produce a very long delay it was the low word that caused the error. Originally I attempted using hex in place of the numerical constants. For reasons beyond me that did not work. Go figure. Anyway, here is the DELAY subroutine in its full glory or not. Any help is greatly appreciated. SUB DELAY (millisec AS INTEGER) DIM regs AS RegTypeX DIM word AS INTEGER DIM micro AS LONG DIM tmpvar AS LONG micro = millisec micro = micro * 1000 regs.ax = &H8600 tmpvar = (micro AND -65536) / 65536 IF tmpvar < 32768 THEN word = tmpvar ELSE word = tmpvar - 65536 END IF regs.cx = word tmpvar = (micro AND 65535) IF tmpvar < 32768 THEN word = tmpvar ELSE word = tmpvar - 65536 END IF regs.dx = word INTERRUPTX &H15, regs, regs END SUB Quote Link to comment Share on other sites More sharing options...
Krebizfan Posted January 30 Share Posted January 30 IIRC, integers in QBasic are signed so the short integer goes from -32K to +32K while the long goes from -2 billion something to +2 billion something. micro = millisec * 1000 should fail since it will evaluate the multiplication in a short integer and any millisec value greater than 32 will overflow. Moving to the long before multiplication solves that problem. The entire tmpvar routine is complex enough I will need to fire up QBasic and figure out what should happen. Hopefully, someone else will remember what to do before then. Quote Link to comment Share on other sites More sharing options...
LostCause Posted January 30 Author Share Posted January 30 (edited) It is extremely refreshing to my soul that you have taken the time to examine the sub. You, and hopefully others could be my inspiration to complete this game. I have DOS and drivers loaded in high memory, not much left there. I have close to the full 640k conventional memory free, if QBasic can utilize that, waits to be explored. I hope this becomes a development thread for the game. Interested, stay tuned. After my last post, I suspected the multiplication was evaluated as a signed word before being cast. The first tmpvar assignment is meant to strip the high word value and dividing by 65536 to convert to word value. The if – end if clause assigns the signed dword value to the signed word based on whether it should be passed as a positive integer or twos compliment. I can see already that instead if dividing by 65536 that the bit shift operator may have been a better choice. If that will work. Edited January 30 by LostCause Quote Link to comment Share on other sites More sharing options...
Krebizfan Posted January 31 Share Posted January 31 I think I see several possible issues. Make millisec a long integer. I don't believe INT 15h AH=86h does what you intend. It also only works on an AT or PS/2. I think the AND with a negative number is the wrong operation. At least when I try, I get the same value no matter what value I put with AND -65356. In practical terms, I suspect it might be good enough to divide by 65536 on its own to get the value of the higher bits and then use MOD 65536 to get the value of lower bits. I doubt the plan is to wait more than 30 minutes which is about how long two billion microseconds would take. I haven't done filling of registers in QBasic in a lot of years so I am probably forgetting something. tmpvar = INT(micro/65536) tmpvar = micro mod 65536 Stylistic point, I wouldn't reuse a variable unless the program is pushing the memory limits. Just makes debugging a lot easier. Quote Link to comment Share on other sites More sharing options...
LostCause Posted January 31 Author Share Posted January 31 (edited) I am running Ms-Dos 6.22 in DosBox-X. The BIOS lists it as a PC/AT. The BIOS call appears to work perfectly. Calling the sub with DELAY 30000 agrees with the stop watch on my phone. Currently I am using a 200 millisecond delay. I suppose, I could have passed it a long integer, I prefer DELAY 200 over DELAY 200000. The (value and -65536) should be the same as (value and FFFF0000h). However, using hex notation caused an overflow error. Setting break points and using the Immediate mode window shows the code producing the correct results. tmpvar = INT(micro/65536) tmpvar = micro mod 65536 That is why I posted, Thank you. I have known Mod since antiquity. For some strange reason, I just never got accustomed to using it. Maybe a remnant from Vic-20 and Atari 800XL days. Edited January 31 by LostCause Quote Link to comment Share on other sites More sharing options...
The Usotsuki Posted January 31 Share Posted January 31 To explicitly note a constant as long, you can end it with & (e.g., &H12345678&). Quote Link to comment Share on other sites More sharing options...
wierd_w Posted January 31 Share Posted January 31 9 hours ago, LostCause said: It is extremely refreshing to my soul that you have taken the time to examine the sub. You, and hopefully others could be my inspiration to complete this game. I have DOS and drivers loaded in high memory, not much left there. I have close to the full 640k conventional memory free, if QBasic can utilize that, waits to be explored. I hope this becomes a development thread for the game. Interested, stay tuned. After my last post, I suspected the multiplication was evaluated as a signed word before being cast. The first tmpvar assignment is meant to strip the high word value and dividing by 65536 to convert to word value. The if – end if clause assigns the signed dword value to the signed word based on whether it should be passed as a positive integer or twos compliment. I can see already that instead if dividing by 65536 that the bit shift operator may have been a better choice. If that will work. Disk space is cheap. BSAVE and BLOAD can be used on arbitrary data contained inside of arrays. This allows it to be used with custom types, etc, and thus can be used for slow disk paging of entire memory structures. 640k is only really limiting in terms of the size of the array. Even then, it is possible to directly hook and prod at XMS memory, if it is available, by writing to the appropriate handlers. (Initiating calls with io requests, with data in registers, et al.) What qbasic lacks is an efficient bulk memory copy routine. Writing one as an assembler stub, then executing it after pulling it into memory, and wrapping that invocation in a sub statement should do the trick though. Quote Link to comment Share on other sites More sharing options...
Krebizfan Posted January 31 Share Posted January 31 If you decide to move up to the full QuickBasic product, I should point out that the Crescent Software tools have been released into the public domain. The parts of the tools I have used were very good. Lots and lots of routines, some of which can be used with QBasic. QuickPak-Pro-DOS is a good starting point on getting a handle on whether the products might help. https://github.com/geneb?tab=repositories Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted January 31 Share Posted January 31 Any reason for not going with QB64 (QuickBASIC compatible modern compiler) https://qb64.com/ If you want to keep it DOS there's FreeBASIC https://www.freebasic.net/ My journey started with QBasic,, GW-BASIC, QuickBASIC 4.5 and finally PDS. As I bumped up against the limitations changing to the next. 1 Quote Link to comment Share on other sites More sharing options...
LostCause Posted January 31 Author Share Posted January 31 I have considered the possible need for extended memory. I have been brushing up on my Turbo Assembler and Borland C++ programming as well. The processes of adding ML functions in QBasic is something I believe, I have a good grasp on. I downloaded the Crescent Software tools, have not really looked into what's available there yet. I have been using QB64 and FreeBasic for a very long time. I currently have the 64-bit Windows versions. I am beginning to wonder why but, also have 32-bit versions. My plan includes a Windows 64-bit FreeBasic release. I started the project in QBasic, guess I what to find out if I can complete it in QBasic. 8 hours ago, The Usotsuki said: To explicitly note a constant as long, you can end it with & (e.g., &H12345678&). I will have to try that. Definitely would cause overflow errors if required. Much appreciation for all your help. 1 Quote Link to comment Share on other sites More sharing options...
LostCause Posted February 1 Author Share Posted February 1 I am in the process of restructuring the code and have added credit in sections of the code, while I can recall who to credit. When I have this done, I would like to post the code at that point. I have one issue and a question or two. 1: Is there a way to post code in a box with a scrollbar. 2: I added the meta statement ' $DYNAMIC at the beginning of the code. This does not show in the QBasic editor, but when I open the basic file in notepad REM $STATIC appears before the functions and subroutines. Is ' $DYNAMIC really necessary. Thank you Quote Link to comment Share on other sites More sharing options...
LostCause Posted February 1 Author Share Posted February 1 OK, found out that Static meta statement only affects the main body. Quote Link to comment Share on other sites More sharing options...
LostCause Posted February 5 Author Share Posted February 5 (edited) I have begun developing a website to chronicle the game. The game itself is moving along quit nicely. I decided to at least implement a border graphics tile with score and lives. Currently the graphics and game play have not been combined. Still have to work on file structure before uploading the compressed file. Getting late, been working most of the day. So, the work in progress page will have to wait till tomorrow. In the mean time check it out at https://onewhackedoutguy.neocities.org/ and tell me what you think. Edited February 5 by LostCause Quote Link to comment Share on other sites More sharing options...
r_chase Posted February 6 Share Posted February 6 On 1/31/2023 at 9:13 AM, Gemintronic said: Any reason for not going with QB64 (QuickBASIC compatible modern compiler) https://qb64.com/ If you want to keep it DOS there's FreeBASIC https://www.freebasic.net/ My journey started with QBasic,, GW-BASIC, QuickBASIC 4.5 and finally PDS. As I bumped up against the limitations changing to the next. Welp! Thanks to you, I want to try programming in QB64. It's not like I have other projects piling up and stuff. 1 Quote Link to comment Share on other sites More sharing options...
LostCause Posted February 19 Author Share Posted February 19 (edited) Ditched the whole website idea. I found it was distracting me from developing the game. Sorry. I have one working level with graphics. I am working on ways to simplify the whole game development process. I have coded the interrupt routine in Turbo Assembly to simplify adding additional routines. I have put this code together that reads the COM file and converts it to be loaded with BLOAD. All this little additional work, I feel will be well worth the effort. The conversion program seems to work great. Let me know you foresee any issues. Thanks DEFINT A-Z OPEN "mcode.com" FOR BINARY AS #1 Bytes = LOF(1) ArraySize = CINT(Bytes / 2 - 1) DIM MCode(ArraySize) FOR i = 0 TO ArraySize GET #1, , MCode(i) NEXT i CLOSE DEF SEG = VARSEG(MCode(0)) BSAVE "mcode.mlc", VARPTR(MCode(0)), Bytes DEF SEG CLS PRINT "Machine Language Code saved as" PRINT "MCODE.MLC" END Edited February 19 by LostCause Quote Link to comment Share on other sites More sharing options...
wierd_w Posted February 19 Share Posted February 19 If you are wanting to wrap an assembler program as a subprogram, this vintage text file might be informative. http://petesqbsite.com/sections/tutorials/tutorials/asm.txt BLOADing in the data should work I think, but the final bit of that text file covers passing variables, which would be quite useful for you I think. Quote Link to comment Share on other sites More sharing options...
LostCause Posted February 19 Author Share Posted February 19 I believe, I have read everything of interest on Pete's QB Site before beginning programming this game. If I only knew then what I know now. Some of the tuts on Pete's site that the author didn't understand particular points, I now fully understand. There is just so much information readily available these days. Thank you, nonetheless. Quote Link to comment Share on other sites More sharing options...
LostCause Posted February 19 Author Share Posted February 19 Actually that is the only document in a sub directory in the game folder not my own. 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.