![]() |
Weirdness 3 - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15) +---- Thread: Weirdness 3 (/showthread.php?tid=145) |
Weirdness 3 - britlion - 01-28-2010 Code: FOR i=0 to 7 This is a snippet of the same program as previously mentioned. I didn't think it was working right with loops. So, I added a beep. It duly beeps once, clears the screen (with NO cls command) and moves on. If I add a print charASave command, it crashes instead. Shouldn't try to catch it out, I guess. Boriel, a little while ago,[a version or two back] this was far more stable and predictable...what is going on here? Best clue I have is that when installing it said something about a newer version being there already. So I uninstalled completely and reinstalled. Is my SDK corrupt?? Is there something completely broken about the 'latest version' on the ftp site? Am I quietly going insane? Re: Weirdness 3 - LCD - 01-28-2010 How is the variable [i] defined? Have you tried to define it AS BYTE or AS WORD? Maybe there is a problem if you use unsigned types? Cannot test it at moment here with my version and my IDE because I was at rewriting some parts which forces the compiler to generate a binary file, and broke my leg, before it was finished. Re: Weirdness 3 - britlion - 01-28-2010 LCD Wrote:How is the variable [i] defined? Have you tried to define it AS BYTE or AS WORD? Maybe there is a problem if you use unsigned types? You broke your leg? Oh my word! I hope you are okay! I could send you the whole source code to date if you like. I'm most worried that I'm getting odd problems - such as a function that works and is tested, and then later stops working as I add code. I stick some print statements into it to see what it's doing, and voila, it starts working perfectly again. I've got my eye on -O3 optimizing out variables that it thinks aren't used at the moment. (As soon as I print it, it's used!) I think I'll try NOT leaving -O3 in the default build script. What I'm working on, since I have a script for it in the original, is a reworking of the old game FOOTBALL MANAGER. This is one reason I need a lot of string handling! It's mostly text based. I'm a little worried that I'm being wasteful on memory too - having LET team$(1)="Arsenal" - puts the name of the team into the code twice. It would be much nicer to have DIM team$(64)=>{"Arsenal","Liverpool",......} since the compiler could hard code those into the variable without actually having the strings in the code and in the variable space at the same time. That particular snippet I posted here is from a routine that should take a string, and print out a squished string, with 4 bit wide characters. (giving me 64 char printing). i is defined as a byte right now - DIM i as byte Code: SUB Squishprint (characters$ as STRING) I'm fully aware that there should be more efficient ways of getting binary equivalents of numbers. There's probably a better way of printing a pair of characters than dropping them into the left and right halves of a UDG as well. Advice would be appreciated! I'm starting to dip into asm mode - as you might have seen - but the SDK isn't documented for how calls are made. Fastcall I've worked out seems to get the one parameter in A if it's a byte. I can handle that. I think a uInteger gets sent in HL. Maybe. Standard calls...I have no clue, looking at the code, where the parameters are put. I thought they were pushed on the stack, but then Boriel's versions seem to mess with the stack pointer in ways I can't quite work out. I did have the idea this morning of instead of saving the bytes at USR "A", I should DIM a uByte array, and point the UDG at that temporarily, and fill that with my print data. It also has the advantage that I could put in up to 21 characters at a time before printing, which should make it smoother. [Remembering of course that if we ever go 128 compatible, that will be 19 characters] Re: Weirdness 3 - LCD - 01-29-2010 britlion Wrote:Well, I'm not that okay, because I have pains. The doctor found also some problems with my heart and liver, which also need urgently a fixLCD Wrote:How is the variable [i] defined? Have you tried to define it AS BYTE or AS WORD? Maybe there is a problem if you use unsigned types? britlion Wrote:I could send you the whole source code to date if you like. I'm most worried that I'm getting odd problems - such as a function that works and is tested, and then later stops working as I add code. I stick some print statements into it to see what it's doing, and voila, it starts working perfectly again.I know what you are talking about. maybe a problem with the Peephole optimiser. Larger code can be very unstable. britlion Wrote:I've got my eye on -O3 optimizing out variables that it thinks aren't used at the moment. (As soon as I print it, it's used!) I think I'll try NOT leaving -O3 in the default build script.Yes, try it without any optimisations britlion Wrote:What I'm working on, since I have a script for it in the original, is a reworking of the old game FOOTBALL MANAGER. This is one reason I need a lot of string handling! It's mostly text based. I'm a little worried that I'm being wasteful on memory too - having LET team$(1)="Arsenal" - puts the name of the team into the code twice. It would be much nicer to have DIM team$(64)=>{"Arsenal","Liverpool",......} since the compiler could hard code those into the variable without actually having the strings in the code and in the variable space at the same time.Then why not using memory access? POKE a String to a label adress (@label), and you can import these data from a binary file. Working with memory is also much faster and you can hard-code some additional routines to manipulate these strings as you like britlion Wrote:That particular snippet I posted here is from a routine that should take a string, and print out a squished string, with 4 bit wide characters. (giving me 64 char printing).64 char text is not well readable, but maybe Borial can include such code. z88dk can switch to 64 char/line mode, so this could be put into Wishlist thread. To store fonts I use: Code: font: this works well I do not know why your routine beeps only once, but maybe if you send the source code to Boriel, he can find the problem. britlion Wrote:I'm fully aware that there should be more efficient ways of getting binary equivalents of numbers. There's probably a better way of printing a pair of characters than dropping them into the left and right halves of a UDG as well. Advice would be appreciated!You can check the SHL and SHR commands. They binary shift variables to left or right. This is a more efficient way Preparing one 4x8 Font, and shifting all the bytes by 4 bits will do the job. britlion Wrote:I'm starting to dip into asm mode - as you might have seen - but the SDK isn't documented for how calls are made. Fastcall I've worked out seems to get the one parameter in A if it's a byte. I can handle that. I think a uInteger gets sent in HL. Maybe.The problem is that detailed instructions are not in english language. So I hope, this will be translated. britlion Wrote:I did have the idea this morning of instead of saving the bytes at USR "A", I should DIM a uByte array, and point the UDG at that temporarily, and fill that with my print data. It also has the advantage that I could put in up to 21 characters at a time before printing, which should make it smoother. [Remembering of course that if we ever go 128 compatible, that will be 19 characters]You should use the normal Spectrum Fonts and just switch between them using the System variable 23606 and 23607. This is the smoothest way. Re: Weirdness 3 - britlion - 01-30-2010 Good to see that I'm not the only person having frustrations with code suddenly not working in strange and unexplained ways that was working perfectly beforehand. I've got one routine in there that works perfectly the first 12 times it's called - so it does about 1.5 characters, and then locks up. Baffles me, that. What I was originally trying to do was algorithmically come up with something that is readable without actually storing a font - that is take the character "A" from the system font (or from a user defined one) and halve it by algorithm. I'm pretty convinced by now that I should give that up as a bad job. No fixed algorithm seems to come up with a good result in all cases. There's always something that looks bad. Best so far? Sending in a line of 8 pixels, send out 4 that are the results of a logical or of each pair. [SO the result is (0 OR 1),(2 OR 3),(4 OR 5),(6 OR 7)]. You'd think that would set too many pixels, but it seems to work pretty well for most cases. Most 64 char printing systems use 3 pixel characters, though. Re: Weirdness 3 - britlion - 01-30-2010 Does this work for you? It crashes for me. I seem to have crashes if I use @ anywhere. I also can't seem to get logical operators to work properly. This code has both (but the crash prevents me testing the AND) Oh, yes, - the strings. I couldn't seem to find a convenient way of putting in a 0 byte to null terminate them. I didn't really want to put in DEFB "string" and then DEFB 0 each line. So they are 48 [ascii zero] terminated instead ![]() Code: teams: Re: Weirdness 3 - LCD - 01-30-2010 Please try this: Code: goto start Re: Weirdness 3 - britlion - 01-31-2010 That works. Nice font, by the way. My code was bugged - I had stringbuild, StringBuild as variables. Bad me. One problem with JUST putting them in as defb is that they are hell to edit later on of course :-) Though it's definitely smaller. Re: Weirdness 3 - LCD - 01-31-2010 britlion Wrote:That works. Nice font, by the way.Ouch, I did not saw that. Yes, ZXBC is veeeery case sensitive. I used Retro-X's Font editor to build the DEFB Data structure (It has also thin font build in). Later also other graphic data can be autogenerated too. Re: Weirdness 3 - britlion - 02-01-2010 That said, I just tried to compile this: Code: DIM n as uByte It crashes. Built using zxb -T -B -a test.bas and then importing the test.tzx. If I build with zxb test.bas and then Code: CLEAR 32767 It crashes differently. It was far more spectacular in the first version. I get this sort of weird behavior all the time. Apparently today, I can't use CHR(uByte) without a crash. It will probably work tomorrow. @label was crashing a few days ago. Before that it was AND giving non true values. And sometimes those earlier problems come back. It's most frustrating. If I change the code to CHR$(32) it works perfectly. I tried renaming the Program folder, and put in an older copy 1.2.4 I had. This one compiled and ran fine. Hmm. I'll download a new copy and see if it got corrupted. Re: Weirdness 3 - britlion - 02-01-2010 I tried a reinstall and get "There was a network error while reading from c:\users\desktop\username\zxbasic-latest-version.msi" So, my C drive is a network. Weirdness continues... Time to reinstall windows from scratch? Time to go to Linux? ![]() Re: Weirdness 3 - britlion - 02-06-2010 Even after successfully reinstalling, I still get: Test #2 Code: FOR smallLoopCounter=144 to 159: print chr$(smallLoopCounter); : next smallLoopCounter to crash on me (after printing out a number of gibberish squares that are NOT the same UDG I get from BASIC) Re: Weirdness 3 - boriel - 02-11-2010 LCD Wrote:I'm sorry to hear that!! :?britlion Wrote:Well, I'm not that okay, because I have pains. The doctor found also some problems with my heart and liver, which also need urgently a fixLCD Wrote:How is the variable [i] defined? Have you tried to define it AS BYTE or AS WORD? Maybe there is a problem if you use unsigned types? ![]() I've just read this thread. I really hope you get well soon and your problems be fixed. britlion Wrote:I could send you the whole source code to date if you like. I'm most worried that I'm getting odd problems - such as a function that works and is tested, and then later stops working as I add code. I stick some print statements into it to see what it's doing, and voila, it starts working perfectly again. Thanks to both you for your code snippets. After I've fixed the compiler bugs (or most of them) we can discuss which snippets could be included with the compiler (as libraries), and how, if you like. :roll: On the other hand, the library keys.bas (#include <keys.bas>) already has the MultiKeys function, which is able to read multiple keys at once without having to enable interrupts. Re: Weirdness 3 - boriel - 02-11-2010 britlion Wrote:That said, I just tried to compile this:I've checked both CHR$(uByte) tests, and they work fine for me. :?: Don't know if these are related to the <= uByte bug (since FOR uses <= :!: , which now is fixed). I'm going to upload a 1.2.5beta for you to test. Which file type are you using? .zip or .msi? Re: Weirdness 3 - britlion - 02-12-2010 I'm using the msi. I can't quite work out how to get the .zip to install. - I expected it to be an over-the-top copy, but it seems to have a different directory structure than the folder in c:\program files. |